Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 88 additions & 89 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface PluginConfig<T> {
*/
export interface WorkbookVariable {
name: string;
defaultValue: { type: string };
defaultValue: { type: string; value: any };
}

export type WorkbookSelection = Record<string, { type: string; val?: unknown }>;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down