@sigmacomputing/plugin 1.0.4 → 1.1.0-alpha.1
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/dist/cjs/client/index.js +9 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/client/initialize.js +158 -0
- package/dist/cjs/client/initialize.js.map +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/utils/polyfillRequestAnimationFrame.js +17 -0
- package/dist/cjs/utils/polyfillRequestAnimationFrame.js.map +1 -0
- package/dist/esm/client/index.esm.js +6 -0
- package/dist/esm/client/index.esm.js.map +1 -0
- package/dist/esm/client/initialize.esm.js +156 -0
- package/dist/esm/client/initialize.esm.js.map +1 -0
- package/dist/esm/index.esm.js +4 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js +15 -0
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js.map +1 -0
- package/dist/mjs/client/index.mjs +6 -0
- package/dist/mjs/client/index.mjs.map +1 -0
- package/dist/mjs/client/initialize.mjs +156 -0
- package/dist/mjs/client/initialize.mjs.map +1 -0
- package/dist/mjs/index.mjs +4 -0
- package/dist/mjs/index.mjs.map +1 -0
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs +15 -0
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs.map +1 -0
- package/dist/types/.tsbuildinfo +1 -0
- package/dist/types/client/index.d.ts +4 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/initialize.d.ts +3 -0
- package/dist/types/client/initialize.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{types.d.ts → types/types/index.d.ts} +1 -1
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/polyfillRequestAnimationFrame.d.ts +8 -0
- package/dist/types/utils/polyfillRequestAnimationFrame.d.ts.map +1 -0
- package/dist/umd/plugin.development.js +181 -0
- package/dist/umd/plugin.development.js.map +1 -0
- package/dist/umd/plugin.production.js +2 -0
- package/dist/umd/plugin.production.js.map +1 -0
- package/package.json +27 -39
- package/src/client/index.ts +5 -0
- package/src/client/initialize.ts +196 -0
- package/src/globals.d.ts +5 -0
- package/src/index.ts +4 -0
- package/src/types/index.ts +322 -0
- package/src/utils/polyfillRequestAnimationFrame.ts +13 -0
- package/LICENSE +0 -21
- package/README.md +0 -795
- package/dist/client/initialize.d.ts +0 -3
- package/dist/client/initialize.d.ts.map +0 -1
- package/dist/client/initialize.js +0 -157
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -20
- 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 -48
- package/dist/react/hooks.d.ts.map +0 -1
- package/dist/react/hooks.js +0 -136
- 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.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/requestAnimationFramePolyfill.d.ts +0 -2
- package/dist/utils/requestAnimationFramePolyfill.d.ts.map +0 -1
- package/dist/utils/requestAnimationFramePolyfill.js +0 -8
package/README.md
DELETED
|
@@ -1,795 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://github.com/sigmacomputing/plugin">
|
|
3
|
-
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/sigmacomputing/plugin/blob/main/assets/sigma-logo-dark.svg">
|
|
5
|
-
<img alt="Sigma Logo" src="https://github.com/sigmacomputing/plugin/blob/main/assets/sigma-logo-light.svg" width="400px">
|
|
6
|
-
</picture>
|
|
7
|
-
</a>
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
|
-
Sigma Computing Plugins provides an API for third-party applications add
|
|
11
|
-
additional functionality into an existing Sigma workbook.
|
|
12
|
-
|
|
13
|
-
Plugins are built using Sigma’s Plugin API. This API communicates data and
|
|
14
|
-
interaction events between a Sigma workbook and the plugin. Plugins are hosted
|
|
15
|
-
by their developer and rendered in an iframe in Sigma.
|
|
16
|
-
|
|
17
|
-
#### Warning: Breaking Changes
|
|
18
|
-
|
|
19
|
-
`@sigmacomputing/plugin` has moved to https://github.com/sigmacomputing/plugin and
|
|
20
|
-
is now open source. Please read our
|
|
21
|
-
[CHANGELOG.md](https://github.com/sigmacomputing/plugin/blob/main/CHANGELOG.md)
|
|
22
|
-
to review any breaking changes that have been made.
|
|
23
|
-
|
|
24
|
-
## Requirements
|
|
25
|
-
|
|
26
|
-
To test your plugin in Sigma Plugin Dev Playground, you must:
|
|
27
|
-
|
|
28
|
-
- Have an Admin, Creator or Explorer account type
|
|
29
|
-
- Have Can Edit permission on the work
|
|
30
|
-
- Be in the workbook’s Edit mode
|
|
31
|
-
|
|
32
|
-
To test a development version of a registered plugin, you must:
|
|
33
|
-
|
|
34
|
-
- Have either:
|
|
35
|
-
|
|
36
|
-
- An Admin account type
|
|
37
|
-
- A custom account type that supports plugin developer feature permissions
|
|
38
|
-
|
|
39
|
-
- Have "can edit" permission on the workbook
|
|
40
|
-
- Be in the workbook’s Edit mode
|
|
41
|
-
|
|
42
|
-
Your plugin must be a Javascript-based project and run in the browser.
|
|
43
|
-
|
|
44
|
-
## Getting Started
|
|
45
|
-
|
|
46
|
-
### Installation
|
|
47
|
-
|
|
48
|
-
Provided you have already followed the steps to create a plugin and a plugin
|
|
49
|
-
development environment, you can install `@sigmacomputing/plugin` using one of
|
|
50
|
-
the following commands
|
|
51
|
-
|
|
52
|
-
```sh
|
|
53
|
-
yarn add @sigmacomputing/plugin
|
|
54
|
-
# or
|
|
55
|
-
npm install @sigmacomputing/plugin
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
If you have yet to set up your development environment, follow one of the setup
|
|
59
|
-
guides below
|
|
60
|
-
|
|
61
|
-
### Create a Development Project
|
|
62
|
-
|
|
63
|
-
At Sigma, we use React for all of our frontend development. This was taken into
|
|
64
|
-
consideration when building Sigma’s Plugin feature.
|
|
65
|
-
|
|
66
|
-
While you are not required to use React for your plugin, it must be written in
|
|
67
|
-
Javascript and React is recommended. We support both a standard Javascript API
|
|
68
|
-
and a React Hooks API.
|
|
69
|
-
|
|
70
|
-
#### Create a Project with React
|
|
71
|
-
|
|
72
|
-
1. Open your terminal and navigate to the directory you want to create your
|
|
73
|
-
project in.
|
|
74
|
-
2. Create your new project. We recommend using Facebook’s
|
|
75
|
-
[`create-react-app`](https://create-react-app.dev/).
|
|
76
|
-
|
|
77
|
-
```sh
|
|
78
|
-
npx create-react-app <my-cool-plugin>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
3. Navigate to the project's main directory.
|
|
82
|
-
|
|
83
|
-
```sh
|
|
84
|
-
cd <my-cool-plugin>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
4. Use your package manager to install Sigma’s plugin library. We recommend
|
|
88
|
-
using `yarn`.
|
|
89
|
-
|
|
90
|
-
```sh
|
|
91
|
-
yarn add @sigmacomputing/plugin
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
5. Spin up your local development server.
|
|
95
|
-
|
|
96
|
-
```sh
|
|
97
|
-
yarn && yarn start
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
6. Start developing:
|
|
101
|
-
|
|
102
|
-
- Get started with Sigma’s Plugin APIs.
|
|
103
|
-
- Test your plugin directly in a Sigma workbook using the Sigma Plugin Dev
|
|
104
|
-
Playground.
|
|
105
|
-
- By default, Create React App dev servers run on http://localhost:3000.
|
|
106
|
-
|
|
107
|
-
## Testing your Plugin
|
|
108
|
-
|
|
109
|
-
Plugin developers should have access to a special plugin called Sigma Plugin Dev
|
|
110
|
-
Playground. This plugin is available from any workbook and points to
|
|
111
|
-
http://localhost:3000, by default.
|
|
112
|
-
|
|
113
|
-
If you cannot find this plugin, or would like a development playground with an
|
|
114
|
-
alternative default host, please contact your Organization Admin with a request
|
|
115
|
-
to Register a Plugin with its production URL set to your preferred development
|
|
116
|
-
URL.
|
|
117
|
-
|
|
118
|
-
### Using the Development Playground
|
|
119
|
-
|
|
120
|
-
Before you start:
|
|
121
|
-
|
|
122
|
-
- Set your plugin’s development URL to http://localhost:3000.
|
|
123
|
-
- Start your plugin locally
|
|
124
|
-
|
|
125
|
-
> Note: If you followed our recommendations under
|
|
126
|
-
> [#create-a-development-project](#create-a-development-project), enter the
|
|
127
|
-
> following command in your terminal:
|
|
128
|
-
>
|
|
129
|
-
> ```sh
|
|
130
|
-
> yarn && yarn start
|
|
131
|
-
> ```
|
|
132
|
-
|
|
133
|
-
1. Create/open a workbook.
|
|
134
|
-
2. In the workbook header, click Edit.
|
|
135
|
-
3. Click the + button in the sidebar, to open the workbook’s ADD NEW panel.
|
|
136
|
-
4. Select the PLUGINS element type, located under UI ELEMENTS.
|
|
137
|
-
5. The editor panel will show you a list of available plugins. Select Sigma
|
|
138
|
-
Plugin Dev Playground.
|
|
139
|
-
6. Your new plugin element will appear on the page.
|
|
140
|
-
|
|
141
|
-
> **Note:**
|
|
142
|
-
> The editor panel will only display content if you have configured your plugin
|
|
143
|
-
> using Sigma’s plugin [Configuration API](#documentation).
|
|
144
|
-
> Likewise, the element will only display content if your plugin is configured to display content.
|
|
145
|
-
> If you change a plugin's configuration options, input values will need to be
|
|
146
|
-
> re-added in the editor panel.
|
|
147
|
-
|
|
148
|
-
**Now what?**
|
|
149
|
-
|
|
150
|
-
- You can refresh your plugin as you make changes to its code. This option is
|
|
151
|
-
available from the element’s menu.
|
|
152
|
-
- You are responsible for hosting your plugin. [Learn more](#host-your-plugin).
|
|
153
|
-
- When you’re ready to register your plugin, [Add your custom your
|
|
154
|
-
Plugin](https://help.sigmacomputing.com/hc/en-us/articles/4410105794963) with
|
|
155
|
-
Sigma.
|
|
156
|
-
|
|
157
|
-
## Documentation
|
|
158
|
-
|
|
159
|
-
#### CustomPluginConfigOptions
|
|
160
|
-
|
|
161
|
-
A plugin can be configured with any number of configuration fields. Each field
|
|
162
|
-
type has its own configuration options. Each field type is also garunteed to
|
|
163
|
-
have a the following options:
|
|
164
|
-
|
|
165
|
-
- `name : string` - the name of the field
|
|
166
|
-
- `type : string` - the field type
|
|
167
|
-
- `label : string (optional)` - a display name for the field
|
|
168
|
-
|
|
169
|
-
<details>
|
|
170
|
-
<summary>Full CustomPluginConfigOptions Type</summary>
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
type CustomPluginConfigOptions =
|
|
174
|
-
| {
|
|
175
|
-
type: 'group';
|
|
176
|
-
name: string;
|
|
177
|
-
label?: string;
|
|
178
|
-
}
|
|
179
|
-
| {
|
|
180
|
-
type: 'element';
|
|
181
|
-
name: string;
|
|
182
|
-
label?: string;
|
|
183
|
-
}
|
|
184
|
-
| {
|
|
185
|
-
type: 'column';
|
|
186
|
-
name: string;
|
|
187
|
-
label?: string;
|
|
188
|
-
allowedTypes?: ValueType[];
|
|
189
|
-
source: string;
|
|
190
|
-
allowMultiple: boolean;
|
|
191
|
-
}
|
|
192
|
-
| {
|
|
193
|
-
type: 'text';
|
|
194
|
-
name: string;
|
|
195
|
-
label?: string;
|
|
196
|
-
source?: string; // can point to a group or element config
|
|
197
|
-
secure?: boolean; // if true will omit from prehydrated configs
|
|
198
|
-
multiline?: boolean;
|
|
199
|
-
placeholder?: string;
|
|
200
|
-
defaultValue?: string;
|
|
201
|
-
}
|
|
202
|
-
| {
|
|
203
|
-
type: 'toggle';
|
|
204
|
-
name: string;
|
|
205
|
-
label?: string;
|
|
206
|
-
source?: string;
|
|
207
|
-
defaultValue?: boolean;
|
|
208
|
-
}
|
|
209
|
-
| {
|
|
210
|
-
type: 'checkbox';
|
|
211
|
-
name: string;
|
|
212
|
-
label?: string;
|
|
213
|
-
source?: string;
|
|
214
|
-
defaultValue?: boolean;
|
|
215
|
-
}
|
|
216
|
-
| {
|
|
217
|
-
type: 'radio';
|
|
218
|
-
name: string;
|
|
219
|
-
label?: string;
|
|
220
|
-
source?: string;
|
|
221
|
-
values: string[];
|
|
222
|
-
singleLine?: boolean;
|
|
223
|
-
defaultValue?: string;
|
|
224
|
-
}
|
|
225
|
-
| {
|
|
226
|
-
type: 'dropdown';
|
|
227
|
-
name: string;
|
|
228
|
-
label?: string;
|
|
229
|
-
source?: string;
|
|
230
|
-
width?: string;
|
|
231
|
-
values: string[];
|
|
232
|
-
defaultValue?: string;
|
|
233
|
-
}
|
|
234
|
-
| {
|
|
235
|
-
type: 'color';
|
|
236
|
-
name: string;
|
|
237
|
-
label?: string;
|
|
238
|
-
source?: string;
|
|
239
|
-
}
|
|
240
|
-
| {
|
|
241
|
-
type: 'variable';
|
|
242
|
-
name: string;
|
|
243
|
-
label?: string;
|
|
244
|
-
allowedTypes?: ControlType[];
|
|
245
|
-
}
|
|
246
|
-
| {
|
|
247
|
-
type: 'interaction';
|
|
248
|
-
name: string;
|
|
249
|
-
label?: string;
|
|
250
|
-
};
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
</details>
|
|
254
|
-
|
|
255
|
-
**Group**
|
|
256
|
-
|
|
257
|
-
Can be used to identify a group of related fields
|
|
258
|
-
|
|
259
|
-
**Element**
|
|
260
|
-
|
|
261
|
-
A custom element that is added by your plugin
|
|
262
|
-
|
|
263
|
-
**Column**
|
|
264
|
-
|
|
265
|
-
A custom column configuration that your plugin uses
|
|
266
|
-
|
|
267
|
-
Additional Fields
|
|
268
|
-
|
|
269
|
-
- `allowedTypes : ValueType[] (optional)` - the allowed data types that this
|
|
270
|
-
column can contain where `ValueType` has the following type:
|
|
271
|
-
|
|
272
|
-
```ts
|
|
273
|
-
type ValueType =
|
|
274
|
-
| 'boolean'
|
|
275
|
-
| 'datetime'
|
|
276
|
-
| 'number'
|
|
277
|
-
| 'integer'
|
|
278
|
-
| 'text'
|
|
279
|
-
| 'variant'
|
|
280
|
-
| 'link'
|
|
281
|
-
| 'error';
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
- `source : string` - the data source that should be used to supply this field
|
|
285
|
-
- `allowMultiple : boolean` - whether multiple columns should be allowed as
|
|
286
|
-
input for this field
|
|
287
|
-
|
|
288
|
-
**Text**
|
|
289
|
-
|
|
290
|
-
A configurable text input for your plugin
|
|
291
|
-
|
|
292
|
-
Additional Fields
|
|
293
|
-
|
|
294
|
-
- `source : string (optional)` - the data source that should be used to supply this field
|
|
295
|
-
- `secure : boolean (optional)` - whether to omit input from pre-hydrated configs
|
|
296
|
-
- `multiline : boolean (optional)` - whether this text input should allow
|
|
297
|
-
multiple lines
|
|
298
|
-
- `placeholder : string (optional)` - the placeholder for this input field
|
|
299
|
-
- `defaultValue : string (optional)` - the default value for this input field
|
|
300
|
-
|
|
301
|
-
**Toggle**
|
|
302
|
-
|
|
303
|
-
A configurable toggle for your plugin
|
|
304
|
-
|
|
305
|
-
Additional Fields
|
|
306
|
-
|
|
307
|
-
- `source : string (optional)` - the data source that should be used to supply this field
|
|
308
|
-
- `defaultValue : boolean (optional)` - the default value for this input field
|
|
309
|
-
|
|
310
|
-
**Checkbox**
|
|
311
|
-
|
|
312
|
-
A configurable checkbox for your plugin
|
|
313
|
-
|
|
314
|
-
Additional Fields
|
|
315
|
-
|
|
316
|
-
- `source : string (optional)` - the data source that should be used to supply this field
|
|
317
|
-
- `defaultValue : boolean (optional)` - the default value for this input field
|
|
318
|
-
|
|
319
|
-
**Radio**
|
|
320
|
-
|
|
321
|
-
A configurable radio button for your plugin
|
|
322
|
-
|
|
323
|
-
Additional Fields
|
|
324
|
-
|
|
325
|
-
- `source : string (optional)` - the data source that should be used to supply
|
|
326
|
-
this field
|
|
327
|
-
- `values : string[]` - the options to show for this input field
|
|
328
|
-
- `singleLine : boolean (optional)` - whether to display options on a single
|
|
329
|
-
line. Good for (2-3) options
|
|
330
|
-
- `defaultValue : boolean (optional)` - the default value for this input field
|
|
331
|
-
|
|
332
|
-
**Dropdown**
|
|
333
|
-
|
|
334
|
-
A configurable dropdown for your plugin
|
|
335
|
-
|
|
336
|
-
Additional Fields
|
|
337
|
-
|
|
338
|
-
- `source : string (optional)` - the data source that should be used to supply
|
|
339
|
-
this field
|
|
340
|
-
- `values : string[]` - the options to show for this input field
|
|
341
|
-
- `width : string (optional)` - how wide the dropdown should be in pixels
|
|
342
|
-
- `defaultValue : boolean (optional)` - the default value for this input field
|
|
343
|
-
|
|
344
|
-
**Color**
|
|
345
|
-
|
|
346
|
-
A configurable color picker for your plugin
|
|
347
|
-
|
|
348
|
-
Additional Fields
|
|
349
|
-
|
|
350
|
-
- `source : string (optional)` - the data source that should be used to supply
|
|
351
|
-
this field
|
|
352
|
-
|
|
353
|
-
**Variable**
|
|
354
|
-
|
|
355
|
-
A configurable workbook variable to control other elements within your workbook
|
|
356
|
-
|
|
357
|
-
Additional Fields
|
|
358
|
-
|
|
359
|
-
- `allowedTypes : ControlType[] (optional)` - the allowed control types that this
|
|
360
|
-
variable can use where `ControlType` has the following type:
|
|
361
|
-
|
|
362
|
-
```ts
|
|
363
|
-
type ControlType =
|
|
364
|
-
| 'boolean'
|
|
365
|
-
| 'date'
|
|
366
|
-
| 'number'
|
|
367
|
-
| 'text'
|
|
368
|
-
| 'text-list'
|
|
369
|
-
| 'number-list'
|
|
370
|
-
| 'date-list'
|
|
371
|
-
| 'number-range'
|
|
372
|
-
| 'date-range';
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
**Interaction**
|
|
376
|
-
|
|
377
|
-
A configurable workbook interaction to interact with other charts within your workbook
|
|
378
|
-
|
|
379
|
-
#### PluginInstance
|
|
380
|
-
|
|
381
|
-
```ts
|
|
382
|
-
interface PluginInstance<T> {
|
|
383
|
-
sigmaEnv: 'author' | 'viewer' | 'explorer';
|
|
384
|
-
|
|
385
|
-
config: {
|
|
386
|
-
/**
|
|
387
|
-
* Getter for entire Plugin Config
|
|
388
|
-
*/
|
|
389
|
-
get(): Partial<T> | undefined;
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Performs a shallow merge between current config and passed in config
|
|
393
|
-
*/
|
|
394
|
-
set(config: Partial<T>): void;
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Getter for key within plugin config
|
|
398
|
-
*/
|
|
399
|
-
getKey<K extends keyof T>(key: K): Pick<T, K>;
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Assigns key value pair within plugin
|
|
403
|
-
*/
|
|
404
|
-
setKey<K extends keyof T>(key: K, value: Pick<T, K>): void;
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Subscriber for Plugin Config
|
|
408
|
-
*/
|
|
409
|
-
subscribe(listener: (arg0: T) => void): Unsubscriber;
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Set possible options for plugin config
|
|
413
|
-
*/
|
|
414
|
-
configureEditorPanel(options: CustomPluginConfigOptions[]): void;
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Gets a static image of a workbook variable
|
|
418
|
-
*/
|
|
419
|
-
getVariable(id: string): WorkbookVariable;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Setter for workbook variable passed in
|
|
423
|
-
*/
|
|
424
|
-
setVariable(id: string, ...values: unknown[]): void;
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Getter for interaction selection state
|
|
428
|
-
*/
|
|
429
|
-
getInteraction(id: string): WorkbookSelection[];
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Setter for interaction selection state
|
|
433
|
-
*/
|
|
434
|
-
setInteraction(
|
|
435
|
-
id: string,
|
|
436
|
-
elementId: string,
|
|
437
|
-
selection: WorkbookSelection[],
|
|
438
|
-
): void;
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Overrider function for Config Ready state
|
|
442
|
-
*/
|
|
443
|
-
setLoadingState(ready: boolean): void;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Allows users to subscribe to changes in the passed in variable
|
|
447
|
-
*/
|
|
448
|
-
subscribeToWorkbookVariable(
|
|
449
|
-
id: string,
|
|
450
|
-
callback: (input: WorkbookVariable) => void,
|
|
451
|
-
): Unsubscriber;
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Allows users to subscribe to changes in the passed in interaction ID
|
|
455
|
-
*/
|
|
456
|
-
subscribeToWorkbookInteraction(
|
|
457
|
-
id: string,
|
|
458
|
-
callback: (input: WorkbookSelection[]) => void,
|
|
459
|
-
): Unsubscriber;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
elements: {
|
|
463
|
-
/**
|
|
464
|
-
* Getter for Column Data by parent sheet ID
|
|
465
|
-
*/
|
|
466
|
-
getElementColumns(id: string): Promise<WbElementColumns>;
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Subscriber to changes in column data by ID
|
|
470
|
-
*/
|
|
471
|
-
subscribeToElementColumns(
|
|
472
|
-
id: string,
|
|
473
|
-
callback: (cols: WbElementColumns) => void,
|
|
474
|
-
): Unsubscriber;
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Subscriber for the data within a given sheet
|
|
478
|
-
*/
|
|
479
|
-
subscribeToElementData(
|
|
480
|
-
id: string,
|
|
481
|
-
callback: (data: WbElementData) => void,
|
|
482
|
-
): Unsubscriber;
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Destroys plugin instance and removes all subscribers
|
|
487
|
-
*/
|
|
488
|
-
destroy(): void;
|
|
489
|
-
}
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
### Framework Agnostic API
|
|
493
|
-
|
|
494
|
-
#### client
|
|
495
|
-
|
|
496
|
-
The client is a pre-initialized plugin instance. You can use this instance
|
|
497
|
-
directly or create your own instance using `initialize`
|
|
498
|
-
|
|
499
|
-
```ts
|
|
500
|
-
const client: PluginInstance = initialize();
|
|
501
|
-
```
|
|
502
|
-
|
|
503
|
-
Usage
|
|
504
|
-
|
|
505
|
-
```ts
|
|
506
|
-
import { client } from '@sigmacomputing/plugin';
|
|
507
|
-
|
|
508
|
-
client.config.configureEditorPanel([
|
|
509
|
-
{ name: 'source', type: 'element' },
|
|
510
|
-
{ name: 'dimension', type: 'column', source: 'source', allowMultiple: true },
|
|
511
|
-
]);
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
#### initialize()
|
|
515
|
-
|
|
516
|
-
Instead of using the pre-initialized plugin instance, you can create your own
|
|
517
|
-
plugin instance.
|
|
518
|
-
|
|
519
|
-
```ts
|
|
520
|
-
function initialize<T = {}>(): PluginInstance<T>;
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
Usage
|
|
524
|
-
|
|
525
|
-
```ts
|
|
526
|
-
import { initialize } from '@sigmacomputing/plugin';
|
|
527
|
-
|
|
528
|
-
const myClient: PluginInstance = initialize();
|
|
529
|
-
|
|
530
|
-
myClient.config.configureEditorPanel([
|
|
531
|
-
{ name: 'source', type: 'element' },
|
|
532
|
-
{ name: 'dimension', type: 'column', source: 'source', allowMultiple: true },
|
|
533
|
-
]);
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
### React API
|
|
537
|
-
|
|
538
|
-
#### <SigmaClientProvider />
|
|
539
|
-
|
|
540
|
-
A context provider your plugin that enables all of the other React API hooks.
|
|
541
|
-
You should wrap your plugin with this provider if your want to use the plugin
|
|
542
|
-
hook API.
|
|
543
|
-
|
|
544
|
-
```ts
|
|
545
|
-
interface SigmaClientProviderProps {
|
|
546
|
-
client: PluginInstance;
|
|
547
|
-
children?: ReactNode;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function SigmaClientProvider(props: SigmaClientProviderProps): ReactNode;
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
#### usePlugin()
|
|
554
|
-
|
|
555
|
-
Gets the entire plugin instance
|
|
556
|
-
|
|
557
|
-
```ts
|
|
558
|
-
function usePlugin(): PluginInstance;
|
|
559
|
-
```
|
|
560
|
-
|
|
561
|
-
#### useEditorPanelConfig()
|
|
562
|
-
|
|
563
|
-
Provides a setter for the plugin's configuration options
|
|
564
|
-
|
|
565
|
-
```ts
|
|
566
|
-
function useEditorPanelConfig(nextOptions: CustomPluginConfigOptions[]): void;
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
Provides a setter for the Plugin's Config Options
|
|
570
|
-
|
|
571
|
-
Arguments
|
|
572
|
-
|
|
573
|
-
- `nextOptions : CustomPluginConfigOptions[]` - Updated possible Config Options
|
|
574
|
-
|
|
575
|
-
#### useLoadingState()
|
|
576
|
-
|
|
577
|
-
Gets the current plugin's loading stat. Returns a value and a setter allowing
|
|
578
|
-
you to update the plugin's loading state
|
|
579
|
-
|
|
580
|
-
```ts
|
|
581
|
-
function useLoadingState(
|
|
582
|
-
initialState: boolean,
|
|
583
|
-
): [boolean, (nextState: boolean) => void];
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
Arguments
|
|
587
|
-
|
|
588
|
-
- `initialState : boolean` - Initial value to set loading state to
|
|
589
|
-
|
|
590
|
-
#### useElementColumns()
|
|
591
|
-
|
|
592
|
-
Provides the latest column values from corresponding sheet
|
|
593
|
-
|
|
594
|
-
```ts
|
|
595
|
-
function useElementColumns(elementId: string): WorkbookElementColumns;
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Arguments
|
|
599
|
-
|
|
600
|
-
- `elementId : string` - A workbook element’s unique identifier.
|
|
601
|
-
|
|
602
|
-
Returns the column information from the specified element.
|
|
603
|
-
|
|
604
|
-
```ts
|
|
605
|
-
interface WorkbookElementColumn {
|
|
606
|
-
id: string;
|
|
607
|
-
name: string;
|
|
608
|
-
columnType: ValueType;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
interface WorkbookElementColumns {
|
|
612
|
-
[colId: string]: WbElementColumn;
|
|
613
|
-
}
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
#### useElementData()
|
|
617
|
-
|
|
618
|
-
Provides the latest data values from corresponding sheet
|
|
619
|
-
|
|
620
|
-
```ts
|
|
621
|
-
function useElementData(elementId: string): WorkbookElementData;
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
Arguments
|
|
625
|
-
|
|
626
|
-
- `elementId : string` - A workbook element’s unique identifier.
|
|
627
|
-
|
|
628
|
-
Returns the row data from the specified element.
|
|
629
|
-
|
|
630
|
-
```ts
|
|
631
|
-
interface WorkbookElementData {
|
|
632
|
-
[colId: string]: any[];
|
|
633
|
-
}
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
#### useVariable()
|
|
637
|
-
|
|
638
|
-
Returns a given variable's value and a setter to update that variable
|
|
639
|
-
|
|
640
|
-
```ts
|
|
641
|
-
function useVariable(
|
|
642
|
-
variableId: string,
|
|
643
|
-
): [WorkbookVariable | undefined, (...values: unknown[]) => void];
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
Arguments
|
|
647
|
-
|
|
648
|
-
- `variableId : string` - The ID of the variable
|
|
649
|
-
|
|
650
|
-
The returned setter function accepts 1 or more variable values expressed as an
|
|
651
|
-
array or multiple parameters
|
|
652
|
-
|
|
653
|
-
```ts
|
|
654
|
-
function setVariableCallback(...values: unknown[]): void;
|
|
655
|
-
```
|
|
656
|
-
|
|
657
|
-
#### useInteraction()
|
|
658
|
-
|
|
659
|
-
Returns a given interaction's selection state and a setter to update that interation
|
|
660
|
-
|
|
661
|
-
```ts
|
|
662
|
-
function useInteraction(
|
|
663
|
-
interactionId: string,
|
|
664
|
-
elementId: string,
|
|
665
|
-
): [WorkbookSelection | undefined, (value: WorkbookSelection[]) => void];
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
Arguments
|
|
669
|
-
|
|
670
|
-
- `interactionId : string` - The ID of the interaction
|
|
671
|
-
- `elementId : string` - The ID of the element that this interaction is
|
|
672
|
-
associated with
|
|
673
|
-
|
|
674
|
-
The returned setter function accepts an array of workbook selection elements
|
|
675
|
-
|
|
676
|
-
```ts
|
|
677
|
-
function setVariableCallback(value: WorkbookSelection[]): void;
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
#### useConfig()
|
|
681
|
-
|
|
682
|
-
Returns the workbook element’s current configuration. If a key is provided, only
|
|
683
|
-
the associated configuration is returned.
|
|
684
|
-
|
|
685
|
-
```ts
|
|
686
|
-
function useConfig(key?: string): any;
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
Arguments
|
|
690
|
-
|
|
691
|
-
- `key : string (optional)` - The name of a key within the associated
|
|
692
|
-
`PluginConfigOptions` object
|
|
693
|
-
|
|
694
|
-
## Examples
|
|
695
|
-
|
|
696
|
-
Sigma’s development team has created a set of example plugins, listed below.
|
|
697
|
-
|
|
698
|
-
All of our example plugins are hosted and can be added to your organization. To
|
|
699
|
-
view / add an example plugin to your organization, follow the steps to register
|
|
700
|
-
a plugin using its Production URL, listed below.
|
|
701
|
-
|
|
702
|
-
You can also visit Sigma’s [Sample Plugin
|
|
703
|
-
repository](https://github.com/sigmacomputing/sigma-sample-plugins) directly on
|
|
704
|
-
Github.
|
|
705
|
-
|
|
706
|
-
### Available Plugins
|
|
707
|
-
|
|
708
|
-
- **Recharts Bar Chart** - A basic bar chart built with the Recharts library.
|
|
709
|
-
|
|
710
|
-
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/sample-plugin-bar-chart)
|
|
711
|
-
- Production URL: https://sigma-sample-bar-chart-54049.netlify.app/
|
|
712
|
-
|
|
713
|
-
- **D3 Candlestick** - A candlestick visualization built with D3.
|
|
714
|
-
|
|
715
|
-
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/sample-plugin-bar-chart)
|
|
716
|
-
- Production URL: https://sigma-sample-candlestick-chart-1664e5.netlify.app/
|
|
717
|
-
|
|
718
|
-
- **Narrative Science Quill** - Demonstrates secure text entry.
|
|
719
|
-
|
|
720
|
-
- [Source Code]()
|
|
721
|
-
- Production URL: https://narrativescience-quill-3ee312.netlify.app/
|
|
722
|
-
|
|
723
|
-
- **D3 Graph** - Demonstrates usage of multiple data sources and in-memory
|
|
724
|
-
joins.
|
|
725
|
-
|
|
726
|
-
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/d3-graph)
|
|
727
|
-
- Production URL: https://d3-graph-3a0d0f.netlify.app/
|
|
728
|
-
|
|
729
|
-
- **D3 Sunburst** - A sunburst visualization built with D3.
|
|
730
|
-
|
|
731
|
-
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/d3-sunburst)
|
|
732
|
-
- Production URL: https://d3-sunburst-b97c7c.netlify.app/
|
|
733
|
-
|
|
734
|
-
- **Frappe Heatmap** - A basic Frappe visualization example.
|
|
735
|
-
|
|
736
|
-
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/frappe-heatmap)
|
|
737
|
-
- Production URL: https://frappe-heatmap-9a4163.netlify.app/
|
|
738
|
-
|
|
739
|
-
### Use an Example in Your Organization
|
|
740
|
-
|
|
741
|
-
To add an example plugin to your organization, follow the steps to [register a
|
|
742
|
-
plugin](https://help.sigmacomputing.com/hc/en-us/articles/4410105794963) using
|
|
743
|
-
its Production URL, listed in the [examples](#available-plugins) above.
|
|
744
|
-
|
|
745
|
-
### Run an Example Locally
|
|
746
|
-
|
|
747
|
-
1. Open your terminal, and navigate to the directory you want to save the example’s in.
|
|
748
|
-
2. Clone Sigma’s [Sample Plugin
|
|
749
|
-
repository](https://github.com/sigmacomputing/sigma-sample-plugins).
|
|
750
|
-
|
|
751
|
-
```sh
|
|
752
|
-
git clone https://github.com/sigmacomputing/sigma-sample-plugins.git
|
|
753
|
-
```
|
|
754
|
-
|
|
755
|
-
3. Navigate to the plugin you would like to try.
|
|
756
|
-
|
|
757
|
-
```sh
|
|
758
|
-
cd sigma-sample-plugins/<plugin-name>
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
4. Run the plugin.
|
|
762
|
-
|
|
763
|
-
```sh
|
|
764
|
-
yarn && yarn start
|
|
765
|
-
```
|
|
766
|
-
|
|
767
|
-
> **Note**: For additional instructions, visit the README file located in the main directory of any given example plugin.
|
|
768
|
-
|
|
769
|
-
## Host Your Plugin
|
|
770
|
-
|
|
771
|
-
As a plugin developer, you are responsible for hosting your plugin(s). If you’re
|
|
772
|
-
new to hosting your own projects, here are a few popular hosting platforms you
|
|
773
|
-
can get started with:
|
|
774
|
-
|
|
775
|
-
- [Heroku](https://devcenter.heroku.com/)
|
|
776
|
-
- [Netlify](https://www.netlify.com/)
|
|
777
|
-
|
|
778
|
-
## Contributing
|
|
779
|
-
|
|
780
|
-
We welcome contributions to `@sigmacomputing/plugin`!
|
|
781
|
-
|
|
782
|
-
🐛 Issues, 📥 Pull requests and 🌟 Stars are always welcome.
|
|
783
|
-
Read our [contributing
|
|
784
|
-
guide](https://github.com/sigmacomputing/plugin/blob/main/CONTRIBUTING.md) to
|
|
785
|
-
get started.
|
|
786
|
-
|
|
787
|
-
**yarn format**
|
|
788
|
-
|
|
789
|
-
Format your code to match the sigmacomputing style guide
|
|
790
|
-
|
|
791
|
-
**yarn test**
|
|
792
|
-
|
|
793
|
-
Check if the unit tests all pass
|
|
794
|
-
|
|
795
|
-
> You can also run the tests in `--watch` mode with **yarn test:watch**
|