Skip to content

Commit 7ac9067

Browse files
Fan out types, update variable type
1 parent 496cbc5 commit 7ac9067

File tree

1 file changed

+88
-89
lines changed

1 file changed

+88
-89
lines changed

src/types.ts

Lines changed: 88 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface PluginConfig<T> {
3030
*/
3131
export interface WorkbookVariable {
3232
name: string;
33-
defaultValue: { type: string };
33+
defaultValue: { type: string; value: any };
3434
}
3535

3636
export type WorkbookSelection = Record<string, { type: string; val?: unknown }>;
@@ -81,6 +81,80 @@ export interface WorkbookElementColumns {
8181
*/
8282
export type Unsubscriber = () => void;
8383

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

181180
/**
182181
* @typedef {object} PluginInstance

0 commit comments

Comments
 (0)