@sigmacomputing/plugin 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,298 @@
1
+ import * as React from 'react';
2
+
3
+ import {
4
+ PluginInstance,
5
+ CustomPluginConfigOptions,
6
+ WorkbookElementColumns,
7
+ WorkbookElementData,
8
+ WorkbookSelection,
9
+ WorkbookVariable,
10
+ PluginStyle,
11
+ UrlParameter,
12
+ } from '../types';
13
+ import { deepEqual } from '../utils/deepEqual';
14
+
15
+ import { PluginContext } from './Context';
16
+
17
+ /**
18
+ * Gets the entire plugin instance
19
+ * @returns {PluginInstance} Context for the current plugin instance
20
+ */
21
+ export function usePlugin(): PluginInstance<any> {
22
+ return React.useContext(PluginContext);
23
+ }
24
+
25
+ /**
26
+ * Provides a setter for the Plugin's Config Options
27
+ * @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
28
+ */
29
+ export function useEditorPanelConfig(
30
+ nextOptions: CustomPluginConfigOptions[],
31
+ ): void {
32
+ const client = usePlugin();
33
+ const optionsRef = React.useRef({});
34
+
35
+ React.useEffect(() => {
36
+ if (nextOptions == null) return;
37
+ if (!deepEqual(nextOptions, optionsRef.current)) {
38
+ client.config.configureEditorPanel(nextOptions);
39
+ optionsRef.current = nextOptions;
40
+ }
41
+ }, [client, nextOptions]);
42
+ }
43
+
44
+ /**
45
+ * React hook for Plugin Config loading state
46
+ * @param {boolean} initialState Initial value to set loading state to
47
+ * @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
48
+ */
49
+ export function useLoadingState(
50
+ initialState: boolean,
51
+ ): [boolean, (nextState: boolean) => void] {
52
+ const client = usePlugin();
53
+ const [loading, setLoading] = React.useState(() => {
54
+ client.config.setLoadingState(initialState);
55
+ return initialState;
56
+ });
57
+
58
+ return [
59
+ loading,
60
+ nextState => {
61
+ if (nextState === loading) return;
62
+ setLoading(nextState);
63
+ client.config.setLoadingState(nextState);
64
+ },
65
+ ];
66
+ }
67
+
68
+ /**
69
+ * Provides the latest column values from corresponding config element
70
+ * @param {string} configId ID from the config for fetching element columns, with type: 'element'
71
+ * @returns {WorkbookElementColumns} Values of corresponding columns contained
72
+ * within the config element
73
+ */
74
+ export function useElementColumns(configId: string): WorkbookElementColumns {
75
+ const client = usePlugin();
76
+ const [columns, setColumns] = React.useState<WorkbookElementColumns>({});
77
+
78
+ React.useEffect(() => {
79
+ if (configId) {
80
+ return client.elements.subscribeToElementColumns(configId, setColumns);
81
+ }
82
+ }, [client, configId]);
83
+
84
+ return columns;
85
+ }
86
+
87
+ /**
88
+ * Provides the latest data values from config element (max 25_000)
89
+ * @param {string} configId ID from the config for fetching element data, with type: 'element'
90
+ * @returns {WorkbookElementData} Element Data for config element, if any
91
+ */
92
+ export function useElementData(configId: string): WorkbookElementData {
93
+ const client = usePlugin();
94
+ const [data, setData] = React.useState<WorkbookElementData>({});
95
+
96
+ React.useEffect(() => {
97
+ if (configId) {
98
+ return client.elements.subscribeToElementData(configId, setData);
99
+ }
100
+ }, [client, configId]);
101
+
102
+ return data;
103
+ }
104
+
105
+ /**
106
+ * Provides the latest data values from corresponding config element with a callback to
107
+ * fetch more in chunks of 25_000 data points
108
+ * @param {string} configId ID from the config for fetching paginated
109
+ * element data, with type: 'element'
110
+ * @returns {WorkbookElementData} Element Data for configured config element, if any
111
+ */
112
+ export function usePaginatedElementData(
113
+ configId: string,
114
+ ): [WorkbookElementData, () => void] {
115
+ const client = usePlugin();
116
+ const [data, setData] = React.useState<WorkbookElementData>({});
117
+
118
+ const loadMore = React.useCallback(() => {
119
+ if (configId) {
120
+ client.elements.fetchMoreElementData(configId);
121
+ }
122
+ }, [configId, client.elements]);
123
+
124
+ React.useEffect(() => {
125
+ if (configId) {
126
+ return client.elements.subscribeToElementData(configId, setData);
127
+ }
128
+ }, [client, configId]);
129
+
130
+ return [data, loadMore];
131
+ }
132
+
133
+ /**
134
+ * Provides the latest value for entire config or certain key within the config
135
+ * @param {string} key Key within Plugin Config, optional
136
+ * @returns Entire config if no key passed in or value for key within plugin config
137
+ */
138
+ export function useConfig(key?: string): any {
139
+ const client = usePlugin();
140
+ const [config, setConfig] = React.useState<any>(
141
+ key != null ? client.config.getKey(key) : client.config.get(),
142
+ );
143
+
144
+ React.useEffect(
145
+ () =>
146
+ client.config.subscribe(newConfig => {
147
+ if (key != null && newConfig[key] !== config[key]) {
148
+ setConfig(newConfig[key]);
149
+ } else {
150
+ setConfig(newConfig);
151
+ }
152
+ }),
153
+ [client, key, config],
154
+ );
155
+
156
+ return config;
157
+ }
158
+
159
+ /**
160
+ * React hook for accessing a workbook control variable
161
+ * @param {string} id ID from the config of type: 'variable'
162
+ * @returns {[(WorkbookVariable | undefined), Function]} Constantly updating
163
+ * value of the control variable and setter for the variable
164
+ */
165
+ export function useVariable(
166
+ id: string,
167
+ ): [WorkbookVariable | undefined, Function] {
168
+ const client = usePlugin();
169
+ const [workbookVariable, setWorkbookVariable] =
170
+ React.useState<WorkbookVariable>();
171
+
172
+ const isFirstRender = React.useRef<boolean>(true);
173
+
174
+ React.useEffect(() => {
175
+ if (isFirstRender.current) {
176
+ setWorkbookVariable(client.config.getVariable(id));
177
+ isFirstRender.current = false;
178
+ }
179
+ return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);
180
+ }, [client, id]);
181
+
182
+ const setVariable = React.useCallback(
183
+ (...values: unknown[]) => client.config.setVariable(id, ...values),
184
+ [id, client.config],
185
+ );
186
+
187
+ return [workbookVariable, setVariable];
188
+ }
189
+
190
+ /**
191
+ * React hook for accessing a url parameter
192
+ * @param {string} id ID from the config of type: 'url-parameter'
193
+ * @returns {[(UrlParameter | undefined), Function]} Constantly updating value of the url parameter and setter for the url parameter
194
+ */
195
+ export function useUrlParameter(
196
+ id: string,
197
+ ): [UrlParameter | undefined, (value: string) => void] {
198
+ const client = usePlugin();
199
+ const [urlParameter, setUrlParameter] = React.useState<UrlParameter>();
200
+
201
+ const isFirstRender = React.useRef<boolean>(true);
202
+
203
+ React.useEffect(() => {
204
+ if (isFirstRender.current) {
205
+ setUrlParameter(client.config.getUrlParameter(id));
206
+ isFirstRender.current = false;
207
+ }
208
+ return client.config.subscribeToUrlParameter(id, setUrlParameter);
209
+ }, [client, id]);
210
+
211
+ const setter = React.useCallback(
212
+ (value: string) => client.config.setUrlParameter(id, value),
213
+ [client, id],
214
+ );
215
+
216
+ return [urlParameter, setter];
217
+ }
218
+
219
+ /**
220
+ * @deprecated Use Action API instead
221
+ * React hook for accessing a workbook interaction selections state
222
+ * @param {string} id ID from the config of type: 'interaction'
223
+ * @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
224
+ */
225
+ export function useInteraction(
226
+ id: string,
227
+ elementId: string,
228
+ ): [unknown, Function] {
229
+ const client = usePlugin();
230
+ const [workbookInteraction, setWorkbookInteraction] =
231
+ React.useState<WorkbookSelection[]>();
232
+
233
+ React.useEffect(() => {
234
+ return client.config.subscribeToWorkbookInteraction(
235
+ id,
236
+ setWorkbookInteraction,
237
+ );
238
+ }, [client, id]);
239
+
240
+ const setInteraction = React.useCallback(
241
+ (value: WorkbookSelection[]) => {
242
+ client.config.setInteraction(id, elementId, value);
243
+ },
244
+ [id, elementId, client.config],
245
+ );
246
+
247
+ return [workbookInteraction, setInteraction];
248
+ }
249
+
250
+ /**
251
+ * React hook for returning a triggering callback function for the registered
252
+ * action trigger
253
+ * @param {string} configId ID from the config of type: 'action-trigger'
254
+ * @returns {Function} A callback function to trigger the action
255
+ */
256
+ export function useActionTrigger(configId: string): () => void {
257
+ const client = usePlugin();
258
+
259
+ return React.useCallback(() => {
260
+ client.config.triggerAction(configId);
261
+ }, [client, configId]);
262
+ }
263
+
264
+ /**
265
+ * React hook for registering and unregistering an action effect
266
+ * @param {string} configId ID from the config of type: 'action-effect'
267
+ * @param {Function} effect The function to be called when the action is triggered
268
+ */
269
+ export function useActionEffect(configId: string, effect: () => void) {
270
+ const client = usePlugin();
271
+
272
+ const effectRef = React.useRef(effect);
273
+
274
+ React.useEffect(() => {
275
+ effectRef.current = effect;
276
+ });
277
+
278
+ React.useEffect(() => {
279
+ return client.config.registerEffect(configId, effectRef.current);
280
+ }, [client, configId, effect]);
281
+ }
282
+
283
+ /**
284
+ * React hook for accessing plugin style with live updates
285
+ * @returns {PluginStyle | undefined} Style properties from the workbook if available
286
+ */
287
+ export function usePluginStyle(): PluginStyle | undefined {
288
+ const client = usePlugin();
289
+ const [style, setStyle] = React.useState<PluginStyle | undefined>();
290
+
291
+ React.useEffect(() => {
292
+ // Request initial style data on mount and subscribe to updates
293
+ void client.style.get().then(response => setStyle(response));
294
+ return client.style.subscribe(setStyle);
295
+ }, [client]);
296
+
297
+ return style;
298
+ }
package/src/react.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './react/hooks';
2
+ export type { SigmaClientProviderProps } from './react/Provider';
3
+ export { SigmaClientProvider } from './react/Provider';
package/src/types.ts ADDED
@@ -0,0 +1,412 @@
1
+ export type ScalarType = 'boolean' | 'datetime' | 'number' | 'integer' | 'text';
2
+ export type PrimitiveType = ScalarType | 'variant' | 'link';
3
+ export type ValueType = PrimitiveType | 'error';
4
+
5
+ /**
6
+ * All mutable workbook control variable types
7
+ */
8
+ export type ControlType =
9
+ | 'boolean'
10
+ | 'date'
11
+ | 'number'
12
+ | 'text'
13
+ | 'text-list'
14
+ | 'number-list'
15
+ | 'date-list'
16
+ | 'number-range'
17
+ | 'date-range';
18
+
19
+ export interface PluginConfig<T> {
20
+ id: string;
21
+ config: T;
22
+ screenshot: boolean;
23
+ [key: string]: any;
24
+ }
25
+
26
+ /**
27
+ * Style colors available to plugins
28
+ * @typedef {object} PluginStyle
29
+ * @property {string} backgroundColor Background color set from workbook if any
30
+ */
31
+ export interface PluginStyle {
32
+ backgroundColor: string;
33
+ }
34
+
35
+ /**
36
+ * @typedef {object} WorkbookVariable
37
+ * @property {string} name Name of control variable within workbook
38
+ * @property {{string}} defaultValue Current value containing at least type as string
39
+ */
40
+ export interface WorkbookVariable {
41
+ name: string;
42
+ defaultValue: { type: string; value: any };
43
+ }
44
+
45
+ /**
46
+ * @typedef {object} UrlParameter
47
+ * @property {string} value Current url value
48
+ */
49
+ export interface UrlParameter {
50
+ value: string;
51
+ }
52
+
53
+ export type WorkbookSelection = Record<string, { type: string; val?: unknown }>;
54
+
55
+ export type PluginMessageResponse = MessageEvent<{
56
+ type: string;
57
+ result: any[];
58
+ error: any;
59
+ }>;
60
+
61
+ export interface WbElement {
62
+ id: string;
63
+ }
64
+
65
+ /**
66
+ * @typedef {object} WorkbookElementData
67
+ * @property {Object<string, any>} data Workbook data sorted by column ID
68
+ */
69
+ export interface WorkbookElementData {
70
+ [colId: string]: any[];
71
+ }
72
+
73
+ /**
74
+ * Column data
75
+ * @typedef {object} WorkbookElementColumn
76
+ * @property {string} id Column ID
77
+ * @property {string} name Column Name
78
+ * @property {string} columnType Type of data contained within column
79
+ */
80
+ export interface WorkbookElementColumn {
81
+ id: string;
82
+ name: string;
83
+ columnType: ValueType;
84
+ }
85
+
86
+ /**
87
+ * Record of Column data with corresponding IDs
88
+ * @typedef {object} WorkbookElementColumns
89
+ * @property {Object<string, WorkbookElementColumn>} column Column ID and corresponding column data
90
+ */
91
+ export interface WorkbookElementColumns {
92
+ [colId: string]: WorkbookElementColumn;
93
+ }
94
+
95
+ /**
96
+ * Function to Unsubscribe from the corresponding elements
97
+ * @typedef {() => void} Unsubscriber
98
+ */
99
+ export type Unsubscriber = () => void;
100
+
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 extends CustomPluginConfigOptionBase {
109
+ type: 'element';
110
+ }
111
+ export interface CustomPluginConfigColumn extends CustomPluginConfigOptionBase {
112
+ type: 'column';
113
+ allowedTypes?: ValueType[];
114
+ source: string;
115
+ allowMultiple: boolean;
116
+ }
117
+ export interface CustomPluginConfigText extends CustomPluginConfigOptionBase {
118
+ type: 'text';
119
+ source?: string; // can point to a group or element config
120
+ // if true will omit from prehydrated configs passed through querystring
121
+ secure?: boolean;
122
+ multiline?: boolean;
123
+ placeholder?: string;
124
+ defaultValue?: string;
125
+ }
126
+ export interface CustomPluginConfigToggle extends CustomPluginConfigOptionBase {
127
+ type: 'toggle';
128
+ source?: string;
129
+ defaultValue?: boolean;
130
+ }
131
+ export interface CustomPluginConfigCheckbox extends CustomPluginConfigOptionBase {
132
+ type: 'checkbox';
133
+ source?: string;
134
+ defaultValue?: boolean;
135
+ }
136
+ export interface CustomPluginConfigRadio extends CustomPluginConfigOptionBase {
137
+ type: 'radio';
138
+ source?: string;
139
+ singleLine?: boolean;
140
+ values: string[];
141
+ defaultValue?: string;
142
+ }
143
+ export interface CustomPluginConfigDropdown extends CustomPluginConfigOptionBase {
144
+ type: 'dropdown';
145
+ source?: string;
146
+ width?: string;
147
+ values: string[];
148
+ defaultValue?: string;
149
+ }
150
+ export interface CustomPluginConfigColor extends CustomPluginConfigOptionBase {
151
+ type: 'color';
152
+ source?: string;
153
+ }
154
+ export interface CustomPluginConfigVariable extends CustomPluginConfigOptionBase {
155
+ type: 'variable';
156
+ allowedTypes?: ControlType[];
157
+ }
158
+ export interface CustomPluginConfigInteraction extends CustomPluginConfigOptionBase {
159
+ type: 'interaction';
160
+ }
161
+ export interface CustomPluginConfigActionTrigger extends CustomPluginConfigOptionBase {
162
+ type: 'action-trigger';
163
+ }
164
+ export interface CustomPluginConfigActionEffect extends CustomPluginConfigOptionBase {
165
+ type: 'action-effect';
166
+ }
167
+ export interface CustomPluginConfigUrlParameter extends Omit<
168
+ CustomPluginConfigOptionBase,
169
+ 'label'
170
+ > {
171
+ type: 'url-parameter';
172
+ }
173
+
174
+ /**
175
+ * Different types Plugin Config Options
176
+ * @typedef {object} CustomPluginConfigOptions
177
+ * @property {string} type Type of config option
178
+ * @property {string} name Name ID of config option
179
+ * @property {(string | undefined)} label Displayed label for config option
180
+ */
181
+ export type CustomPluginConfigOptions =
182
+ | CustomPluginConfigGroup
183
+ | CustomPluginConfigElement
184
+ | CustomPluginConfigColumn
185
+ | CustomPluginConfigText
186
+ | CustomPluginConfigToggle
187
+ | CustomPluginConfigCheckbox
188
+ | CustomPluginConfigRadio
189
+ | CustomPluginConfigDropdown
190
+ | CustomPluginConfigColor
191
+ | CustomPluginConfigVariable
192
+ | CustomPluginConfigInteraction
193
+ | CustomPluginConfigActionTrigger
194
+ | CustomPluginConfigActionEffect
195
+ | CustomPluginConfigUrlParameter;
196
+
197
+ /**
198
+ * @typedef {object} PluginInstance
199
+ * @template T Type of Config passed in
200
+ * @property {string} sigmaEnv Permissions within Sigma Environment
201
+ * @property {object} config Set of helper functions for interacting with Plugin Config
202
+ * @property {object} elements Set of helper functions for interacting with Workbook Element Data
203
+ * @property {Function} destroy Destroys Plugin Instance and removes all subscriptions
204
+ */
205
+ export interface PluginInstance<T = any> {
206
+ sigmaEnv: 'author' | 'viewer' | 'explorer';
207
+
208
+ config: {
209
+ /**
210
+ * Getter for entire Plugin Config
211
+ * @template T Config type to be passed in
212
+ * @returns {Partial<T>} Current Plugin Config
213
+ */
214
+ get(): Partial<T> | undefined;
215
+
216
+ /**
217
+ * Performs a shallow merge between current config and passed in config
218
+ * @template T Config type to be passed in
219
+ * @param {Partial<T>} config Config to directly assign
220
+ */
221
+ set(config: Partial<T>): void;
222
+
223
+ /**
224
+ * Getter for key within plugin config
225
+ * @template K Possible key within CustomPluginConfigOptions
226
+ * @param {K} key Key within config to retrieve
227
+ * @returns Value within config for passed in key
228
+ */
229
+ getKey<K extends keyof T>(key: K): Pick<T, K>;
230
+
231
+ /**
232
+ * Assigns key value pair within plugin
233
+ * @template K Possible key within CustomPluginConfigOptions
234
+ * @template V Value corresponding to K
235
+ * @param {K} key Key within config to set
236
+ * @param {V} value New value to set key to
237
+ */
238
+ setKey<K extends keyof T>(key: K, value: Pick<T, K>): void;
239
+
240
+ /**
241
+ * Subscriber for Plugin Config
242
+ * @param {Function} listener Function to be called upon changes to Plugin Config
243
+ */
244
+ subscribe(listener: (arg0: T) => void): Unsubscriber;
245
+
246
+ /**
247
+ * Set possible options for plugin config
248
+ * @param {CustomPluginConfigOptions[]} options Possible config options
249
+ */
250
+ configureEditorPanel(options: CustomPluginConfigOptions[]): void;
251
+
252
+ /**
253
+ * Gets a static image of a workbook variable
254
+ * @param {string} configId ID from config of type: 'variable'
255
+ * @returns {WorkbookVariable} Current value of the workbook variable
256
+ */
257
+ getVariable(configId: string): WorkbookVariable;
258
+
259
+ /**
260
+ * Setter for workbook variable passed in
261
+ * @param {string} configId ID from config of type: 'variable'
262
+ * @param {unknown[]} values Values to assign to the workbook variable
263
+ */
264
+ setVariable(configId: string, ...values: unknown[]): void;
265
+
266
+ /**
267
+ * @deprecated Use Action API instead
268
+ * Getter for interaction selection state
269
+ * @param {string} configId ID from config of type: 'interaction'
270
+ */
271
+ getInteraction(configId: string): WorkbookSelection[];
272
+
273
+ /**
274
+ * @deprecated Use Action API instead
275
+ * Setter for interaction selection state
276
+ * @param {string} configId ID from config of type: 'interaction'
277
+ * @param {string} elementId Source element ID from element type in Plugin Config
278
+ * @param {Object} selection List of column IDs or Columns and values and key-value pairs to select
279
+ */
280
+ setInteraction(
281
+ configId: string,
282
+ elementId: string,
283
+ selection: WorkbookSelection[],
284
+ ): void;
285
+
286
+ /**
287
+ * Triggers an action based on the provided action trigger ID
288
+ * @param {string} configId ID from config of type: 'action-trigger'
289
+ */
290
+ triggerAction(configId: string): void;
291
+
292
+ /**
293
+ * Registers an effect with the provided action effect ID
294
+ * @param {string} configId ID from config of type: 'action-effect'
295
+ * @param {Function} effect The effect function to register
296
+ * @returns {Unsubscriber} A callable unsubscriber
297
+ */
298
+ registerEffect(configId: string, effect: () => void): () => void;
299
+
300
+ /**
301
+ * Tell the workbook whether the plugin is still loading. Pass false when the plugin
302
+ * has finished loading and is ready to be used.
303
+ * @param {boolean} isLoading Boolean representing if Plugin Config is still loading
304
+ */
305
+ setLoadingState(isLoading: boolean): void;
306
+
307
+ /**
308
+ * Allows users to subscribe to changes in the passed in variable
309
+ * @param {string} configId ID from config of type: 'variable'
310
+ * @callback callback Function to be called upon receiving an updated workbook variable
311
+ * @returns {Unsubscriber} A callable unsubscriber
312
+ */
313
+ subscribeToWorkbookVariable(
314
+ configId: string,
315
+ callback: (input: WorkbookVariable) => void,
316
+ ): Unsubscriber;
317
+
318
+ /**
319
+ * Allows users to subscribe to changes in the url parameter
320
+ * @param {string} configId ID from config of type: 'url-parameter'
321
+ * @callback callback Function to be called upon receiving an updated url parameter
322
+ * @returns {Unsubscriber} A callable unsubscriber
323
+ */
324
+ subscribeToUrlParameter(
325
+ configId: string,
326
+ callback: (input: UrlParameter) => void,
327
+ ): Unsubscriber;
328
+
329
+ /**
330
+ * Gets the current value of a url parameter
331
+ * @param {string} configId ID from config of type: 'url-parameter'
332
+ * @returns {UrlParameter} Current value of the url parameter
333
+ */
334
+ getUrlParameter(configId: string): UrlParameter;
335
+
336
+ /**
337
+ * Setter for url parameter
338
+ * @param {string} configId ID from config of type: 'url-parameter'
339
+ * @param {string} value Value to assign to the url parameter
340
+ */
341
+ setUrlParameter(configId: string, value: string): void;
342
+
343
+ /**
344
+ * @deprecated Use Action API instead
345
+ * Allows users to subscribe to changes in the passed in interaction ID
346
+ * @param {string} configId ID from the config of type: 'interaction'
347
+ * @callback callback Function to be called upon receiving an updated interaction selection state
348
+ * @returns {Unsubscriber} A callable unsubscriber
349
+ */
350
+ subscribeToWorkbookInteraction(
351
+ configId: string,
352
+ callback: (input: WorkbookSelection[]) => void,
353
+ ): Unsubscriber;
354
+ };
355
+
356
+ elements: {
357
+ /**
358
+ * Getter for Column Data by parent sheet ID
359
+ * @param {string} configId ID from config of type: 'element'
360
+ * @returns {WorkbookElementColumns} Column values contained within corresponding sheet
361
+ */
362
+ getElementColumns(configId: string): Promise<WorkbookElementColumns>;
363
+
364
+ /**
365
+ * Subscriber to changes in column data by ID
366
+ * @param {string} configId ID from config of type: 'element'
367
+ * @callback callback Callback function to be called upon changes to column data
368
+ * @returns {Unsubscriber} Callable unsubscriber to column data changes
369
+ */
370
+ subscribeToElementColumns(
371
+ configId: string,
372
+ callback: (cols: WorkbookElementColumns) => void,
373
+ ): Unsubscriber;
374
+
375
+ /**
376
+ * Subscriber for the data within a given sheet
377
+ * @param {string} configId ID from config of type: 'element'
378
+ * @callback callback Function to call on data passed in
379
+ * @returns {Unsubscriber} A callable unsubscriber to changes in the data
380
+ */
381
+ subscribeToElementData(
382
+ configId: string,
383
+ callback: (data: WorkbookElementData) => void,
384
+ ): Unsubscriber;
385
+
386
+ /**
387
+ * Ask sigma to load more data
388
+ * @param {string} configId ID from config of type: 'element'
389
+ */
390
+ fetchMoreElementData(configId: string): void;
391
+ };
392
+
393
+ style: {
394
+ /**
395
+ * Subscribe to style updates
396
+ * @param callback Function to call when style updates
397
+ * @returns Unsubscriber function
398
+ */
399
+ subscribe(callback: (style: PluginStyle) => void): () => void;
400
+
401
+ /**
402
+ * Request current style from workbook
403
+ * @returns Promise with current style
404
+ */
405
+ get(): Promise<PluginStyle>;
406
+ };
407
+
408
+ /**
409
+ * Destroys plugin instance and removes all subscribers
410
+ */
411
+ destroy(): void;
412
+ }