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