Skip to content

Commit 00aa7a2

Browse files
Fan out config option types, update variable type (#32)
1 parent d35a765 commit 00aa7a2

File tree

1 file changed

+93
-93
lines changed

1 file changed

+93
-93
lines changed

src/types.ts

Lines changed: 93 additions & 93 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
/**
@@ -98,6 +98,84 @@ export interface WorkbookElementColumns {
9898
*/
9999
export type Unsubscriber = () => void;
100100

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

202202
/**
203203
* @typedef {object} PluginInstance

0 commit comments

Comments
 (0)