import { Corner, Side } from '../../util/svg-util'; import { FieldConfig } from './diagram-config'; import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config'; /** * Configuration for the components of the diagram. * @public */ export type ComponentsConfig = { /** * Configuration for the buttons component in the diagram. * If left undefined, it is interpreted as disabling the buttons component, * same as if the attribute `enabled` in its configuration was set to `false`. */ buttons?: ButtonsComponentConfig; /** * Configuration for the errors component in the diagram. * If left undefined, it is interpreted as disabling the errors component, * same as if the attribute `enabled` in its configuration was set to `false`. */ errors?: ErrorsComponentConfig; /** * Configuration for the palette component in the diagram. * If left undefined, it is interpreted as disabling the palette component, * same as if the attribute `enabled` in its configuration was set to `false`. */ palette?: PaletteComponentConfig; /** * Configuration for the property editor component in the diagram. * If left undefined, it is interpreted as disabling the property editor component, * same as if the attribute `enabled` in its configuration was set to `false`. */ propertyEditor?: PropertyEditorComponentConfig; }; /** * Configuration for the buttons component in a diagram. * @public * @see DiagramButtonsComponent */ export interface ButtonsComponentConfig { /** * Whether this component is present in the diagram. * @default true */ enabled?: boolean; /** * Location of this component in the screen. * @default 'bottom-right' */ location?: Corner; /** * Direction that this component extends towards. * @default 'top' */ direction?: Side; /** * Duration of the center animation when pressing the center button. May be set to `0` or `undefined` to make it instant without animation. * @default undefined */ centerAnimationDuration?: number; /** * Whether to enable the user action (undo, redo) buttons in this component. * @default true */ enableAction?: boolean; /** * Whether to enable the filter button in this component. * @default false */ enableFilter?: boolean; /** * Whether to enable the layout button in this component. * @default false */ enableLayout?: boolean; /** * Whether to enable the user selection (copy, paste, cut, delete) buttons in this component. * @default true */ enableSelection?: boolean; /** * Whether to enable the zoom buttons in this component. * @default true */ enableZoom?: boolean; } /** * Configuration for the errors component in a diagram. * @public * @see ErrorsComponent */ export interface ErrorsComponentConfig { /** * Whether this component is present in the diagram. * @default true */ enabled?: boolean; } /** * Configuration for the palette component in a diagram. * @public * @see PaletteComponent */ export interface PaletteComponentConfig { /** * Whether this component is present in the diagram. * @default true */ enabled?: boolean; /** * Whether this component is open (not collapsed) by default in the diagram. * @default true */ open?: boolean; /** * Location of this component in the screen. * @default 'top-left' */ location?: Corner; /** * Direction that this component extends towards. * @default 'bottom' */ direction?: Side; /** * Dimension of this component in the direction perpendicular to the direction that it extends towards. * @default '12rem' */ width?: string; /** * Dimension of this component in the direction that it extends towards. * @default 'min-content' */ length?: string; /** * Gap between the templates in this palette. * @default '1rem' */ gap?: string; /** * Value of the `justify-content` property in the elemments of the palette. * @default 'center' */ justifyContent?: string; /** * Configuration for the sections of this palette. By default, no sections are created. * @default undefined */ sections?: PaletteSectionConfig[]; } /** * Configuration for the property editor component in a diagram. * @public * @see PropertyEditorComponent */ export interface PropertyEditorComponentConfig { /** * Whether this component is present in the diagram. * @default true */ enabled?: boolean; /** * Whether this component is open (not collapsed) by default in the diagram. * @default true */ open?: boolean; /** * Location of this component in the screen. * @default 'top-right' */ location?: Corner; /** * Direction that this component extends towards. * @default 'bottom' */ direction?: Side; /** * Dimension of this component in the direction perpendicular to the direction that it extends towards. * @default '24rem' */ width?: string; /** * Dimension of this component in the direction that it extends towards. * @default 'min-content' */ length?: string; /** * Title that appears heading this component. * @default 'Diagram properties' */ title?: string; } /** * Configuration for a palette. * @public * @see PaletteComponent */ export interface PaletteSectionConfig { /** * Name of this palette. Displayed in the tab of this palette in the palette component. Can be left undefined if this is the only palette. */ name?: string; /** * Categories of this palette. Used to enable displaying one of different categories of templates as defined here. Can be left undefined if there are no categories. */ categories?: { [key: string]: (NodeTemplateConfig | ConnectionTemplateConfig)[]; }; /** * List of templates that are always displayed in this palette. Can be left undefined. */ templates?: (NodeTemplateConfig | ConnectionTemplateConfig)[]; } /** * Configuration for a template of a node in a palette. * @public * @see PaletteComponent */ export interface NodeTemplateConfig { /** * String used to indicate that this is a template of a node. */ templateType: 'node'; /** * Id of the type of node of this template. Must correspond to the id of a type of node defined in the nodeTypes list. */ type: string; /** * Width of this template as it appears on the palette. By default, the width of the type of node is used. */ width?: number | null; /** * Height of this template as it appears on the palette. By default, the height of the type of node is used. */ height?: number | null; /** * Look of this template as it appears on the palette which can be used to override the default look of the nodes of this type. */ look?: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig; /** * Label of this template as it appears on the palette and label that will be given to nodes created from this template. */ label?: string; /** * Look of the label of this template as it appears on the palette. By default, the label of the type of node is used. */ labelLook?: FieldConfig | null; /** * Default values of the properties of nodes created from this template. */ values?: { [key: string]: unknown; }; } /** * Configuration for a template of a connection in a palette. * @public * @see PaletteComponent */ export interface ConnectionTemplateConfig { /** * String used to indicate that this is a template of a connection. */ templateType: 'connection'; /** * Id of the type of connection of this template. Must correspond to the id of a type of connection defined in the connectionTypes list. */ type: string; /** * Label of this template as it appears on the palette. */ label: string; /** * Background color of this template as it appears on the palette. */ backgroundColor: string; /** * File path of the background image of this template as it appears on the palette. */ icon: string; /** * File path of the background image of this template as it appears on the palette when this connection type is selected. */ selectedIcon: string; /** * Width of this template in diagram units as it appears on the palette. */ width: number; /** * Height of this template in diagram units as it appears on the palette. */ height: number; }