Skip to content

Commit 495807f

Browse files
Fan out types, update variable type
1 parent 87f84bd commit 495807f

1 file changed

Lines changed: 88 additions & 89 deletions

File tree

src/types.ts

Lines changed: 88 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface PluginStyle {
3939
*/
4040
export interface WorkbookVariable {
4141
name: string;
42-
defaultValue: { type: string };
42+
defaultValue: { type: string; value: any };
4343
}
4444

4545
export type WorkbookSelection = Record<string, { type: string; val?: unknown }>;
@@ -90,6 +90,80 @@ export interface WorkbookElementColumns {
9090
*/
9191
export type Unsubscriber = () => void;
9292

93+
export interface CustomPluginConfigOptionBase {
94+
name: string;
95+
label?: string;
96+
}
97+
export interface CustomPluginConfigGroup extends CustomPluginConfigOptionBase {
98+
type: 'group';
99+
}
100+
export interface CustomPluginConfigElement
101+
extends CustomPluginConfigOptionBase {
102+
type: 'element';
103+
}
104+
export interface CustomPluginConfigColumn extends CustomPluginConfigOptionBase {
105+
type: 'column';
106+
allowedTypes?: ValueType[];
107+
source: string;
108+
allowMultiple: boolean;
109+
}
110+
export interface CustomPluginConfigText extends CustomPluginConfigOptionBase {
111+
type: 'text';
112+
source?: string; // can point to a group or element config
113+
// if true will omit from prehydrated configs passed through querystring
114+
secure?: boolean;
115+
multiline?: boolean;
116+
placeholder?: string;
117+
defaultValue?: string;
118+
}
119+
export interface CustomPluginConfigToggle extends CustomPluginConfigOptionBase {
120+
type: 'toggle';
121+
source?: string;
122+
defaultValue?: number;
123+
}
124+
export interface CustomPluginConfigCheckbox
125+
extends CustomPluginConfigOptionBase {
126+
type: 'checkbox';
127+
source?: string;
128+
defaultValue?: number;
129+
}
130+
export interface CustomPluginConfigRadio extends CustomPluginConfigOptionBase {
131+
type: 'radio';
132+
source?: string;
133+
singleLine?: boolean;
134+
values: string[];
135+
defaultValue?: string;
136+
}
137+
export interface CustomPluginConfigDropdown
138+
extends CustomPluginConfigOptionBase {
139+
type: 'dropdown';
140+
source?: string;
141+
width?: string;
142+
values: string[];
143+
defaultValue?: string;
144+
}
145+
export interface CustomPluginConfigColor extends CustomPluginConfigOptionBase {
146+
type: 'color';
147+
source?: string;
148+
}
149+
export interface CustomPluginConfigVariable
150+
extends CustomPluginConfigOptionBase {
151+
type: 'variable';
152+
allowedTypes?: ControlType[];
153+
}
154+
export interface CustomPluginConfigInteraction
155+
extends CustomPluginConfigOptionBase {
156+
type: 'interaction';
157+
}
158+
export interface CustomPluginConfigActionTrigger
159+
extends CustomPluginConfigOptionBase {
160+
type: 'action-trigger';
161+
}
162+
export interface CustomPluginConfigActionEffect
163+
extends CustomPluginConfigOptionBase {
164+
type: 'action-effect';
165+
}
166+
93167
/**
94168
* Different types Plugin Config Options
95169
* @typedef {object} CustomPluginConfigOptions
@@ -98,94 +172,19 @@ export type Unsubscriber = () => void;
98172
* @property {(string | undefined)} label Displayed label for config option
99173
*/
100174
export type CustomPluginConfigOptions =
101-
| {
102-
type: 'group';
103-
name: string;
104-
label?: string;
105-
}
106-
| {
107-
type: 'element';
108-
name: string;
109-
label?: string;
110-
}
111-
| {
112-
type: 'column';
113-
name: string;
114-
label?: string;
115-
allowedTypes?: ValueType[];
116-
source: string;
117-
allowMultiple: boolean;
118-
}
119-
| {
120-
type: 'text';
121-
name: string;
122-
label?: string;
123-
source?: string; // can point to a group or element config
124-
// if true will omit from prehydrated configs passed through querystring
125-
secure?: boolean;
126-
multiline?: boolean;
127-
placeholder?: string;
128-
defaultValue?: string;
129-
}
130-
| {
131-
type: 'toggle';
132-
name: string;
133-
label?: string;
134-
source?: string;
135-
defaultValue?: boolean;
136-
}
137-
| {
138-
type: 'checkbox';
139-
name: string;
140-
label?: string;
141-
source?: string;
142-
defaultValue?: boolean;
143-
}
144-
| {
145-
type: 'radio';
146-
name: string;
147-
label?: string;
148-
source?: string;
149-
values: string[];
150-
singleLine?: boolean;
151-
defaultValue?: string;
152-
}
153-
| {
154-
type: 'dropdown';
155-
name: string;
156-
label?: string;
157-
source?: string;
158-
width?: string;
159-
values: string[];
160-
defaultValue?: string;
161-
}
162-
| {
163-
type: 'color';
164-
name: string;
165-
label?: string;
166-
source?: string;
167-
}
168-
| {
169-
type: 'variable';
170-
name: string;
171-
label?: string;
172-
allowedTypes?: ControlType[];
173-
}
174-
| {
175-
type: 'interaction';
176-
name: string;
177-
label?: string;
178-
}
179-
| {
180-
type: 'action-trigger';
181-
name: string;
182-
label?: string;
183-
}
184-
| {
185-
type: 'action-effect';
186-
name: string;
187-
label?: string;
188-
};
175+
| CustomPluginConfigGroup
176+
| CustomPluginConfigElement
177+
| CustomPluginConfigColumn
178+
| CustomPluginConfigText
179+
| CustomPluginConfigToggle
180+
| CustomPluginConfigCheckbox
181+
| CustomPluginConfigRadio
182+
| CustomPluginConfigDropdown
183+
| CustomPluginConfigColor
184+
| CustomPluginConfigVariable
185+
| CustomPluginConfigInteraction
186+
| CustomPluginConfigActionTrigger
187+
| CustomPluginConfigActionEffect;
189188

190189
/**
191190
* @typedef {object} PluginInstance

0 commit comments

Comments
 (0)