diff --git a/src/types.ts b/src/types.ts index a05c74c..0fa690e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -30,7 +30,7 @@ export interface PluginConfig { */ export interface WorkbookVariable { name: string; - defaultValue: { type: string }; + defaultValue: { type: string; value: any }; } export type WorkbookSelection = Record; @@ -81,6 +81,80 @@ export interface WorkbookElementColumns { */ export type Unsubscriber = () => void; +export interface CustomPluginConfigOptionBase { + name: string; + label?: string; +} +export interface CustomPluginConfigGroup extends CustomPluginConfigOptionBase { + type: 'group'; +} +export interface CustomPluginConfigElement + extends CustomPluginConfigOptionBase { + type: 'element'; +} +export interface CustomPluginConfigColumn extends CustomPluginConfigOptionBase { + type: 'column'; + allowedTypes?: ValueType[]; + source: string; + allowMultiple: boolean; +} +export interface CustomPluginConfigText extends CustomPluginConfigOptionBase { + type: 'text'; + source?: string; // can point to a group or element config + // if true will omit from prehydrated configs passed through querystring + secure?: boolean; + multiline?: boolean; + placeholder?: string; + defaultValue?: string; +} +export interface CustomPluginConfigToggle extends CustomPluginConfigOptionBase { + type: 'toggle'; + source?: string; + defaultValue?: number; +} +export interface CustomPluginConfigCheckbox + extends CustomPluginConfigOptionBase { + type: 'checkbox'; + source?: string; + defaultValue?: number; +} +export interface CustomPluginConfigRadio extends CustomPluginConfigOptionBase { + type: 'radio'; + source?: string; + singleLine?: boolean; + values: string[]; + defaultValue?: string; +} +export interface CustomPluginConfigDropdown + extends CustomPluginConfigOptionBase { + type: 'dropdown'; + source?: string; + width?: string; + values: string[]; + defaultValue?: string; +} +export interface CustomPluginConfigColor extends CustomPluginConfigOptionBase { + type: 'color'; + source?: string; +} +export interface CustomPluginConfigVariable + extends CustomPluginConfigOptionBase { + type: 'variable'; + allowedTypes?: ControlType[]; +} +export interface CustomPluginConfigInteraction + extends CustomPluginConfigOptionBase { + type: 'interaction'; +} +export interface CustomPluginConfigActionTrigger + extends CustomPluginConfigOptionBase { + type: 'action-trigger'; +} +export interface CustomPluginConfigActionEffect + extends CustomPluginConfigOptionBase { + type: 'action-effect'; +} + /** * Different types Plugin Config Options * @typedef {object} CustomPluginConfigOptions @@ -89,94 +163,19 @@ export type Unsubscriber = () => void; * @property {(string | undefined)} label Displayed label for config option */ export type CustomPluginConfigOptions = - | { - type: 'group'; - name: string; - label?: string; - } - | { - type: 'element'; - name: string; - label?: string; - } - | { - type: 'column'; - name: string; - label?: string; - allowedTypes?: ValueType[]; - source: string; - allowMultiple: boolean; - } - | { - type: 'text'; - name: string; - label?: string; - source?: string; // can point to a group or element config - // if true will omit from prehydrated configs passed through querystring - secure?: boolean; - multiline?: boolean; - placeholder?: string; - defaultValue?: string; - } - | { - type: 'toggle'; - name: string; - label?: string; - source?: string; - defaultValue?: boolean; - } - | { - type: 'checkbox'; - name: string; - label?: string; - source?: string; - defaultValue?: boolean; - } - | { - type: 'radio'; - name: string; - label?: string; - source?: string; - values: string[]; - singleLine?: boolean; - defaultValue?: string; - } - | { - type: 'dropdown'; - name: string; - label?: string; - source?: string; - width?: string; - values: string[]; - defaultValue?: string; - } - | { - type: 'color'; - name: string; - label?: string; - source?: string; - } - | { - type: 'variable'; - name: string; - label?: string; - allowedTypes?: ControlType[]; - } - | { - type: 'interaction'; - name: string; - label?: string; - } - | { - type: 'action-trigger'; - name: string; - label?: string; - } - | { - type: 'action-effect'; - name: string; - label?: string; - }; + | CustomPluginConfigGroup + | CustomPluginConfigElement + | CustomPluginConfigColumn + | CustomPluginConfigText + | CustomPluginConfigToggle + | CustomPluginConfigCheckbox + | CustomPluginConfigRadio + | CustomPluginConfigDropdown + | CustomPluginConfigColor + | CustomPluginConfigVariable + | CustomPluginConfigInteraction + | CustomPluginConfigActionTrigger + | CustomPluginConfigActionEffect; /** * @typedef {object} PluginInstance