ToolJet/frontend/src/Editor/WidgetManager/components.js
Kavin Venkatachalam ed43ca844a
[Feature]: Added universal props for widgets with Tooltip (#3096)
* Added universal props for widget

* Fixed lint issues

* Updated export name

* Fixed lint errors

* Updated genral variable name

* Updated file name in doc
2022-06-02 11:51:52 +05:30

35 lines
1,017 B
JavaScript

import { widgets } from './widgetConfig';
const universalProps = {
properties: {},
general: {
tooltip: { type: 'code', displayName: 'Tooltip' },
},
others: {},
events: {},
styles: {},
definition: {
others: {},
events: [],
styles: {},
},
};
const combineProperties = (widget, universal, isArray = false) => {
return {
...widget,
properties: { ...universal.properties, ...widget.properties },
general: { ...universal.general, ...widget.general },
others: { ...universal.others, ...widget.others },
events: isArray ? [...universal.events, ...widget.events] : { ...universal.events, ...widget.events },
styles: { ...universal.styles, ...widget.styles },
exposedVariables: { ...universal.exposedVariables, ...widget.exposedVariables },
};
};
export const componentTypes = widgets.map((widget) => {
return {
...combineProperties(widget, universalProps),
definition: combineProperties(widget.definition, universalProps.definition, true),
};
});