Fixes #21718 This is a PR for review of approach that I have come up with refactor for issue : #21718. We can discuss the approach in the comments. This PR moves autocomplete suggestions from a static utility file, entityDefinitions, to widget/index.ts file of each widget. This refactor will help in the long term project of moving widgets into its own module as well as support for custom widgets.
87 lines
2.0 KiB
TypeScript
87 lines
2.0 KiB
TypeScript
import Widget from "./widget";
|
|
import IconSVG from "./icon.svg";
|
|
import { ButtonPlacementTypes, ButtonVariantTypes } from "components/constants";
|
|
import { MenuItemsSource } from "./constants";
|
|
|
|
export const CONFIG = {
|
|
type: Widget.getWidgetType(),
|
|
name: "Menu Button",
|
|
iconSVG: IconSVG,
|
|
defaults: {
|
|
label: "Open Menu",
|
|
menuVariant: ButtonVariantTypes.PRIMARY,
|
|
placement: ButtonPlacementTypes.CENTER,
|
|
isCompact: false,
|
|
isDisabled: false,
|
|
isVisible: true,
|
|
animateLoading: true,
|
|
menuItemsSource: MenuItemsSource.STATIC,
|
|
menuItems: {
|
|
menuItem1: {
|
|
label: "First Menu Item",
|
|
id: "menuItem1",
|
|
widgetId: "",
|
|
isVisible: true,
|
|
isDisabled: false,
|
|
index: 0,
|
|
},
|
|
menuItem2: {
|
|
label: "Second Menu Item",
|
|
id: "menuItem2",
|
|
widgetId: "",
|
|
isVisible: true,
|
|
isDisabled: false,
|
|
index: 1,
|
|
},
|
|
menuItem3: {
|
|
label: "Third Menu Item",
|
|
id: "menuItem3",
|
|
widgetId: "",
|
|
isVisible: true,
|
|
isDisabled: false,
|
|
index: 2,
|
|
},
|
|
},
|
|
rows: 4,
|
|
columns: 16,
|
|
widgetName: "MenuButton",
|
|
version: 1,
|
|
},
|
|
properties: {
|
|
derived: Widget.getDerivedPropertiesMap(),
|
|
default: Widget.getDefaultPropertiesMap(),
|
|
meta: Widget.getMetaPropertiesMap(),
|
|
config: Widget.getPropertyPaneConfig(),
|
|
contentConfig: Widget.getPropertyPaneContentConfig(),
|
|
styleConfig: Widget.getPropertyPaneStyleConfig(),
|
|
stylesheetConfig: Widget.getStylesheetConfig(),
|
|
autocompleteDefinitions: Widget.getAutocompleteDefinitions(),
|
|
},
|
|
autoLayout: {
|
|
defaults: {
|
|
rows: 4,
|
|
columns: 6.632,
|
|
},
|
|
autoDimension: {
|
|
width: true,
|
|
},
|
|
widgetSize: [
|
|
{
|
|
viewportMinWidth: 0,
|
|
configuration: () => {
|
|
return {
|
|
minWidth: "120px",
|
|
maxWidth: "360px",
|
|
};
|
|
},
|
|
},
|
|
],
|
|
disableResizeHandles: {
|
|
vertical: true,
|
|
horizontal: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
export default Widget;
|