The defineComponent function takes the following parameters:

Param Type Required
component Component true
meta Meta true
config Config true

Meta is defined as follows:

Param Type Required
name string true
label string true
classNames string[] false
inputs InputMeta[] false
events EventMeta[] false
variables VariableMeta[] false
defaultWidth number false
defaultHeight number false

Example

An example component that uses most of the options available in Meta is a dropdown component (see full code here):

import { defineComponent, EmbeddedComponentMeta } from '@embeddable.com/react';
import { loadData, Value } from '@embeddable.com/core';

import Component from './index';

export const meta: EmbeddedComponentMeta = {
  name: 'BasicDropdownComponent',
  label: 'Basic Dropdown',
	classNames: ['add-border'],
	defaultWidth: 320,
  defaultHeight: 80,
  inputs: [
    {
      name: 'title',
      type: 'string',
      label: 'Title',
      description: 'The text to show next to the dropdown',
			defaultValue: 'My title',
    },
    {
      name: "ds",
      type: "dataset",
      label: "Dataset to display",
    },
    {
      name: "values",
      type: "dimension",
      label: "Values",
      config: {
        dataset: "ds",
      },
    },
    {
      name: 'defaultValue',
      type: 'string',
      label: 'Default value',
      description: 'The initial value'
    },
    
  ],
  events: [
    {
      name: 'onChange',
      label: 'Change',
      properties: [
        {
          name: 'value',
          type: 'string'
        }
      ]
    }],
  variables: [
    {
      name: 'chosen value',
      type: 'string',
      defaultValue: Value.noFilter(),
      inputs: ['defaultValue'],
      events: [{ name: 'onChange', property: 'value'}]
    }
  ]
};

type Inputs = {
  title: string;
  ds: Dataset;
  values: Dimension;
  defaultValue: string;
}

export default defineComponent<Inputs>(Component, meta, {
  props: (inputs) => {
    return {
      ...inputs,
      results: loadData({
        from: inputs.ds,
        dimensions: [inputs.values],
      })
    };
  },
  events: {
    onChange: (value) => ({ value: value || Value.noFilter() })
  }
});