@sigmacomputing/plugin 0.7.56 → 1.0.0-rc.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/.gitignore +30 -0
- package/.lintstagedrc +3 -0
- package/.nvmrc +1 -0
- package/.prettierrc +5 -0
- package/CHANGELOG.md +25 -0
- package/CONTRIBUTING.md +60 -0
- package/{LICENSE.md → LICENSE} +0 -0
- package/README.md +782 -8
- package/assets/sigma-logo-dark.svg +54 -0
- package/assets/sigma-logo-light.svg +50 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/{client.js → client/index.js} +2 -1
- package/dist/client/initialize.d.ts +3 -0
- package/dist/client/initialize.d.ts.map +1 -0
- package/dist/{initialize.js → client/initialize.js} +1 -1
- package/dist/client/react/Context.d.ts +4 -0
- package/dist/client/react/Context.d.ts.map +1 -0
- package/dist/client/react/Context.js +6 -0
- package/dist/client/react/Provider.d.ts +8 -0
- package/dist/client/react/Provider.d.ts.map +1 -0
- package/dist/client/react/Provider.js +9 -0
- package/dist/client/react/hooks.d.ts +48 -0
- package/dist/client/react/hooks.d.ts.map +1 -0
- package/dist/{react/index.js → client/react/hooks.js} +23 -60
- package/dist/client/react/index.d.ts +4 -0
- package/dist/client/react/index.d.ts.map +1 -0
- package/dist/client/react/index.js +21 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/types.d.ts +262 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/{deepEqual.d.ts → utils/deepEqual.d.ts} +0 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +29 -0
- package/jest.config.ts +22 -0
- package/package.json +50 -14
- package/src/client/__tests__/initialize.test.ts +30 -0
- package/src/client/index.ts +5 -0
- package/src/client/initialize.ts +199 -0
- package/src/client/react/Context.ts +6 -0
- package/src/client/react/Provider.tsx +19 -0
- package/src/client/react/hooks.ts +178 -0
- package/src/client/react/index.tsx +6 -0
- package/src/index.ts +3 -0
- package/src/types.ts +322 -0
- package/src/utils/deepEqual.ts +24 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +35 -0
- package/yarn.lock +3226 -0
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +0 -1
- package/dist/deepEqual.d.ts.map +0 -1
- package/dist/deepEqual.js +0 -46
- package/dist/initialize.d.ts +0 -3
- package/dist/initialize.d.ts.map +0 -1
- package/dist/initialize.test.d.ts +0 -2
- package/dist/initialize.test.d.ts.map +0 -1
- package/dist/initialize.test.js +0 -26
- package/dist/react/index.d.ts +0 -58
- package/dist/react/index.d.ts.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 24.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
|
4
|
+
y="0px" viewBox="0 0 841.9 595.3" style="enable-background:new 0 0 841.9 595.3;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0 {
|
|
7
|
+
fill: #00C3AF;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.st1 {
|
|
11
|
+
fill: #FFFFFF;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
<g>
|
|
15
|
+
<g>
|
|
16
|
+
<polygon class="st0" points="279.2,379.8 205.4,347.7 253.1,347.7 " />
|
|
17
|
+
<polygon class="st0" points="233.3,315.1 285.6,379.2 264.8,281.4 " />
|
|
18
|
+
<polygon class="st0" points="164.4,246.8 229.5,311.3 261,277.7 " />
|
|
19
|
+
<polygon class="st0" points="289.8,247.5 265.4,273.6 241.8,266.1 " />
|
|
20
|
+
<polygon class="st0" points="295,249.8 281.1,263.8 318.8,264.5 " />
|
|
21
|
+
</g>
|
|
22
|
+
<g>
|
|
23
|
+
<g>
|
|
24
|
+
<path class="st1" d="M372.1,291.1h15v60.2h-15V291.1z" />
|
|
25
|
+
</g>
|
|
26
|
+
<g>
|
|
27
|
+
<path class="st1" d="M459.7,291.1v51.7c0,27.1-12.8,38.8-33,38.8c-12.1,0-22.7-6.7-27.8-17.7l12.1-5.7c2.9,5.9,9.3,9.8,15.7,9.8
|
|
28
|
+
c11.3,0,18.4-6.7,18.4-23.8v-0.9c-4.2,6.2-12.3,9.3-19.5,9.3c-15.5,0-28.9-12.2-28.9-31.5c0-19.3,13.3-31.3,28.8-31.3
|
|
29
|
+
c7.6,0,15.5,3,19.6,9.2v-7.9H459.7z M444.8,321c0-10.6-8.6-17.3-17-17.3c-9.1,0-16.5,7.2-16.5,17.3s7.4,17.5,16.5,17.5
|
|
30
|
+
C436.8,338.5,444.8,331.6,444.8,321z" />
|
|
31
|
+
</g>
|
|
32
|
+
<g>
|
|
33
|
+
<path class="st1" d="M567.5,317.5v33.8h-14.8v-32.6c0-9.7-5-14.4-12-14.4c-8.6,0-14.1,6.4-13.4,17.3l-0.1-0.5v30.3h-15v-32.6
|
|
34
|
+
c0-9.7-5-14.4-11.5-14.4c-7,0-13.9,3.9-13.9,15.3v31.7h-15v-60.2h15v10.3c2.2-7.6,10.4-11.6,17.9-11.6c8.8,0,16,4.1,19.5,11.9
|
|
35
|
+
c4.8-9.5,14.2-11.9,20.2-11.9C559.5,289.8,567.5,300,567.5,317.5z" />
|
|
36
|
+
</g>
|
|
37
|
+
<g>
|
|
38
|
+
<path class="st1"
|
|
39
|
+
d="M312.1,332.6H327c0,4.1,3.8,8,10.5,8c6.3,0,10.4-2.7,10.4-6.6c0-3.4-2.7-4.9-7.5-5.9l-8.5-2.1
|
|
40
|
+
c-14.3-3.6-18-10.8-18-18.4c0-9.4,9.8-17.7,23.7-17.7c11.3,0,24.1,5.3,24,18.8h-15.1c0-4.3-4-6.8-8.5-6.8c-4.9,0-8.3,2.6-8.3,6.3
|
|
41
|
+
c0,3.1,3.1,4.9,6.8,5.7l10.2,2.6c14.3,3.5,16.9,12,16.9,17.5c0,12.2-13,18.7-25.9,18.7C325.1,352.7,312.4,345.5,312.1,332.6z" />
|
|
42
|
+
</g>
|
|
43
|
+
<g>
|
|
44
|
+
<ellipse class="st1" cx="379.6" cy="276.5" rx="9" ry="9.3" />
|
|
45
|
+
</g>
|
|
46
|
+
<g>
|
|
47
|
+
<path class="st1" d="M632.6,315.3v36h-14.7v-8c-4,5.5-12.6,9.3-20.6,9.3c-12.5,0-21.5-7.3-21.5-18.7c0-12.1,10.4-18.8,23.7-18.8
|
|
48
|
+
c6.8,0,13.7,1.7,18.4,4.3v-3.6c0-7.6-5.2-12.9-13.6-12.9c-7.2,0-14,2.7-17.1,6.4l-8.1-8.5c4.9-6.6,15.1-11,26.1-11
|
|
49
|
+
C621.1,289.8,632.6,298.8,632.6,315.3z M617.9,331.8v-2.4c-3.9-2.4-10.1-4-15.8-4c-8.2,0-12.3,3.6-12.3,7.9
|
|
50
|
+
c0,4.3,3.9,7.1,10.3,7.1C606.6,340.4,614.3,337.1,617.9,331.8z" />
|
|
51
|
+
</g>
|
|
52
|
+
</g>
|
|
53
|
+
</g>
|
|
54
|
+
</svg>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 24.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
|
4
|
+
y="0px" viewBox="0 0 841.9 595.3" style="enable-background:new 0 0 841.9 595.3;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0 {
|
|
7
|
+
fill: #00C3AF;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
<g>
|
|
11
|
+
<g>
|
|
12
|
+
<polygon class="st0" points="255.8,388.4 153.6,344 219.7,344 " />
|
|
13
|
+
<polygon class="st0" points="192.3,298.8 264.6,387.6 235.9,252.2 " />
|
|
14
|
+
<polygon class="st0" points="96.9,204.4 187,293.7 230.6,247.1 " />
|
|
15
|
+
<polygon class="st0" points="270.4,205.3 236.6,241.4 204.1,231 " />
|
|
16
|
+
<polygon class="st0" points="277.6,208.4 258.5,227.8 310.6,228.8 " />
|
|
17
|
+
</g>
|
|
18
|
+
<g>
|
|
19
|
+
<g>
|
|
20
|
+
<path d="M384.4,265.7h20.7V349h-20.7V265.7z" />
|
|
21
|
+
</g>
|
|
22
|
+
<g>
|
|
23
|
+
<path d="M505.6,265.7v71.6c0,37.5-17.8,53.7-45.6,53.7c-16.7,0-31.4-9.3-38.5-24.4l16.7-7.9c4,8.2,12.9,13.6,21.8,13.6
|
|
24
|
+
c15.7,0,25.4-9.3,25.4-33v-1.2c-5.7,8.6-17.1,12.8-27,12.8c-21.4,0-40.1-17-40.1-43.5c0-26.8,18.5-43.4,39.9-43.4
|
|
25
|
+
c10.5,0,21.4,4.1,27.2,12.7v-10.9H505.6z M485,307c0-14.6-11.8-23.9-23.5-23.9c-12.5,0-22.8,10-22.8,23.9s10.3,24.3,22.8,24.3
|
|
26
|
+
C473.9,331.3,485,321.7,485,307z" />
|
|
27
|
+
</g>
|
|
28
|
+
<g>
|
|
29
|
+
<path d="M654.8,302.2V349h-20.5v-45.1c0-13.4-7-20-16.6-20c-12,0-19.4,8.9-18.6,23.9L599,307V349h-20.7v-45.1
|
|
30
|
+
c0-13.4-7-20-15.9-20c-9.6,0-19.3,5.4-19.3,21.2V349h-20.7v-83.3h20.7v14.3c3-10.5,14.5-16.1,24.8-16.1
|
|
31
|
+
c12.1,0,22.1,5.7,26.9,16.4c6.6-13.2,19.6-16.4,28-16.4C643.8,263.9,654.8,278,654.8,302.2z" />
|
|
32
|
+
</g>
|
|
33
|
+
<g>
|
|
34
|
+
<path d="M301.4,323.1h20.6c0,5.7,5.3,11.1,14.5,11.1c8.7,0,14.3-3.7,14.3-9.1c0-4.6-3.8-6.8-10.4-8.2l-11.7-2.9
|
|
35
|
+
c-19.8-5-24.9-15-24.9-25.5c0-13,13.6-24.4,32.8-24.4c15.7,0,33.4,7.3,33.2,26.1h-20.9c0-5.9-5.5-9.5-11.7-9.5
|
|
36
|
+
c-6.8,0-11.5,3.6-11.5,8.7c0,4.3,4.3,6.8,9.4,7.9l14.2,3.6c19.8,4.8,23.4,16.6,23.4,24.3c0,17-17.9,25.9-35.9,25.9
|
|
37
|
+
C319.3,351,301.7,341,301.4,323.1z" />
|
|
38
|
+
</g>
|
|
39
|
+
<g>
|
|
40
|
+
<ellipse cx="394.7" cy="245.4" rx="12.4" ry="12.9" />
|
|
41
|
+
</g>
|
|
42
|
+
<g>
|
|
43
|
+
<path d="M744.9,299.2V349h-20.4v-11.1c-5.6,7.7-17.5,12.8-28.5,12.8c-17.3,0-29.7-10.2-29.7-25.9c0-16.8,14.4-26.1,32.8-26.1
|
|
44
|
+
c9.3,0,19,2.3,25.5,5.9v-5c0-10.5-7.1-17.8-18.9-17.8c-10,0-19.4,3.7-23.6,8.9L670.9,279c6.8-9.1,20.9-15.2,36.2-15.2
|
|
45
|
+
C729,263.9,744.9,276.4,744.9,299.2z M724.6,322v-3.4c-5.4-3.4-13.9-5.5-21.9-5.5c-11.4,0-17,5-17,10.9c0,5.9,5.4,9.8,14.3,9.8
|
|
46
|
+
C708.9,333.8,719.6,329.3,724.6,322z" />
|
|
47
|
+
</g>
|
|
48
|
+
</g>
|
|
49
|
+
</g>
|
|
50
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAO,MAAM,MAAM,iCAAe,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.client = void 0;
|
|
3
|
+
exports.initialize = exports.client = void 0;
|
|
4
4
|
const initialize_1 = require("./initialize");
|
|
5
|
+
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return initialize_1.initialize; } });
|
|
5
6
|
exports.client = (0, initialize_1.initialize)();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/client/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAKf,MAAM,OAAO,CAAC;AAEf,wBAAgB,UAAU,CAAC,CAAC,GAAG,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CA6LtD"}
|
|
@@ -21,7 +21,7 @@ function initialize() {
|
|
|
21
21
|
emit('config', (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {});
|
|
22
22
|
});
|
|
23
23
|
// send initialize event
|
|
24
|
-
void execPromise('wb:plugin:init', require(
|
|
24
|
+
void execPromise('wb:plugin:init', require("../../package.json").version).then(config => {
|
|
25
25
|
Object.assign(pluginConfig, config);
|
|
26
26
|
emit('init', pluginConfig);
|
|
27
27
|
emit('config', pluginConfig.config);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/client/react/Context.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,eAAO,MAAM,aAAa,8CAAwC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { PluginInstance } from 'types';
|
|
3
|
+
export interface SigmaClientProviderProps<T = any> {
|
|
4
|
+
client: PluginInstance<T>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function SigmaClientProvider<T = any>(props: SigmaClientProviderProps<T>): JSX.Element;
|
|
8
|
+
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/client/react/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,GAAG;IAC/C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,eAOnC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SigmaClientProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Context_1 = require("./Context");
|
|
6
|
+
function SigmaClientProvider(props) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(Context_1.PluginContext.Provider, Object.assign({ value: props.client }, { children: props.children })));
|
|
8
|
+
}
|
|
9
|
+
exports.SigmaClientProvider = SigmaClientProvider;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PluginInstance, CustomPluginConfigOptions, WorkbookElementColumns, WorkbookElementData, WorkbookVariable } from 'types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the entire plugin instance
|
|
4
|
+
* @returns {PluginInstance} Context for the current plugin instance
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePlugin(): PluginInstance<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Provides a setter for the Plugin's Config Options
|
|
9
|
+
* @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
|
|
10
|
+
*/
|
|
11
|
+
export declare function useEditorPanelConfig(nextOptions: CustomPluginConfigOptions[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* React hook for Plugin Config loading state
|
|
14
|
+
* @param {boolean} initialState Initial value to set loading state to
|
|
15
|
+
* @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
|
|
16
|
+
*/
|
|
17
|
+
export declare function useLoadingState(initialState: boolean): [boolean, (nextState: boolean) => void];
|
|
18
|
+
/**
|
|
19
|
+
* Provides the latest column values from corresponding sheet
|
|
20
|
+
* @param {string} id Sheet ID to retrieve from workbook
|
|
21
|
+
* @returns {WorkbookElementColumns} Values of corresponding columns contained within the sheet
|
|
22
|
+
*/
|
|
23
|
+
export declare function useElementColumns(id: string): WorkbookElementColumns;
|
|
24
|
+
/**
|
|
25
|
+
* Provides the latest data values from corresponding sheet
|
|
26
|
+
* @param {string} id Sheet ID to get element data from
|
|
27
|
+
* @returns {WorkbookElementData} Element Data for corresponding sheet, if any
|
|
28
|
+
*/
|
|
29
|
+
export declare function useElementData(id: string): WorkbookElementData;
|
|
30
|
+
/**
|
|
31
|
+
* Provides the latest value for entire config or certain key within the config
|
|
32
|
+
* @param {string} key Key within Plugin Config, optional
|
|
33
|
+
* @returns Entire config if no key passed in or value for key within plugin config
|
|
34
|
+
*/
|
|
35
|
+
export declare function useConfig(key?: string): any;
|
|
36
|
+
/**
|
|
37
|
+
* React hook for accessing a workbook variable
|
|
38
|
+
* @param {string} id ID of variable within Plugin Config to use
|
|
39
|
+
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating value of the variable and setter for the variable
|
|
40
|
+
*/
|
|
41
|
+
export declare function useVariable(id: string): [WorkbookVariable | undefined, Function];
|
|
42
|
+
/**
|
|
43
|
+
* React hook for accessing a workbook interaction selections state
|
|
44
|
+
* @param {string} id ID of variable within Plugin Config to use
|
|
45
|
+
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
46
|
+
*/
|
|
47
|
+
export declare function useInteraction(id: string, elementId: string): [unknown, Function];
|
|
48
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/client/react/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAGf;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAAC,GAAG,CAAC,CAE/C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,GACvC,IAAI,CAWN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,OAAO,GACpB,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC,CAezC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,CAWpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAW9D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAmB3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,GACT,CAAC,gBAAgB,GAAG,SAAS,EAAE,QAAQ,CAAC,CAc1C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,GAChB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAoBrB"}
|
|
@@ -1,54 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useInteraction = exports.useVariable = exports.useConfig = exports.useElementData = exports.useElementColumns = exports.useLoadingState = exports.useEditorPanelConfig = exports.usePlugin =
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const deepEqual_1 = require("
|
|
30
|
-
const client_1 = require("../client");
|
|
31
|
-
const Context = (0, react_1.createContext)(client_1.client);
|
|
3
|
+
exports.useInteraction = exports.useVariable = exports.useConfig = exports.useElementData = exports.useElementColumns = exports.useLoadingState = exports.useEditorPanelConfig = exports.usePlugin = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Context_1 = require("./Context");
|
|
6
|
+
const deepEqual_1 = require("../../utils/deepEqual");
|
|
32
7
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
* @returns {JSXElement} Context Provider for passed in props
|
|
36
|
-
*/
|
|
37
|
-
function SigmaClientProvider(props) {
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(Context.Provider, Object.assign({ value: props.client }, { children: props.children })));
|
|
39
|
-
}
|
|
40
|
-
exports.SigmaClientProvider = SigmaClientProvider;
|
|
41
|
-
/**
|
|
42
|
-
* A constantly updating getter for the entire Plugin Instance
|
|
43
|
-
* @returns {plugin.PluginInstance} Context for the current plugin instance
|
|
8
|
+
* Gets the entire plugin instance
|
|
9
|
+
* @returns {PluginInstance} Context for the current plugin instance
|
|
44
10
|
*/
|
|
45
11
|
function usePlugin() {
|
|
46
|
-
return (0, react_1.useContext)(
|
|
12
|
+
return (0, react_1.useContext)(Context_1.PluginContext);
|
|
47
13
|
}
|
|
48
14
|
exports.usePlugin = usePlugin;
|
|
49
15
|
/**
|
|
50
16
|
* Provides a setter for the Plugin's Config Options
|
|
51
|
-
* @param {
|
|
17
|
+
* @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
|
|
52
18
|
*/
|
|
53
19
|
function useEditorPanelConfig(nextOptions) {
|
|
54
20
|
const client = usePlugin();
|
|
@@ -86,9 +52,9 @@ function useLoadingState(initialState) {
|
|
|
86
52
|
}
|
|
87
53
|
exports.useLoadingState = useLoadingState;
|
|
88
54
|
/**
|
|
89
|
-
* Provides
|
|
55
|
+
* Provides the latest column values from corresponding sheet
|
|
90
56
|
* @param {string} id Sheet ID to retrieve from workbook
|
|
91
|
-
* @returns {
|
|
57
|
+
* @returns {WorkbookElementColumns} Values of corresponding columns contained within the sheet
|
|
92
58
|
*/
|
|
93
59
|
function useElementColumns(id) {
|
|
94
60
|
const client = usePlugin();
|
|
@@ -102,22 +68,23 @@ function useElementColumns(id) {
|
|
|
102
68
|
}
|
|
103
69
|
exports.useElementColumns = useElementColumns;
|
|
104
70
|
/**
|
|
105
|
-
* Provides
|
|
71
|
+
* Provides the latest data values from corresponding sheet
|
|
106
72
|
* @param {string} id Sheet ID to get element data from
|
|
107
|
-
* @returns {
|
|
73
|
+
* @returns {WorkbookElementData} Element Data for corresponding sheet, if any
|
|
108
74
|
*/
|
|
109
75
|
function useElementData(id) {
|
|
110
76
|
const client = usePlugin();
|
|
111
77
|
const [data, setData] = (0, react_1.useState)({});
|
|
112
78
|
(0, react_1.useEffect)(() => {
|
|
113
|
-
if (id)
|
|
79
|
+
if (id) {
|
|
114
80
|
return client.elements.subscribeToElementData(id, setData);
|
|
81
|
+
}
|
|
115
82
|
}, [client, id]);
|
|
116
83
|
return data;
|
|
117
84
|
}
|
|
118
85
|
exports.useElementData = useElementData;
|
|
119
86
|
/**
|
|
120
|
-
* Provides
|
|
87
|
+
* Provides the latest value for entire config or certain key within the config
|
|
121
88
|
* @param {string} key Key within Plugin Config, optional
|
|
122
89
|
* @returns Entire config if no key passed in or value for key within plugin config
|
|
123
90
|
*/
|
|
@@ -138,7 +105,7 @@ exports.useConfig = useConfig;
|
|
|
138
105
|
/**
|
|
139
106
|
* React hook for accessing a workbook variable
|
|
140
107
|
* @param {string} id ID of variable within Plugin Config to use
|
|
141
|
-
* @returns {[(
|
|
108
|
+
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating value of the variable and setter for the variable
|
|
142
109
|
*/
|
|
143
110
|
function useVariable(id) {
|
|
144
111
|
const client = usePlugin();
|
|
@@ -146,16 +113,14 @@ function useVariable(id) {
|
|
|
146
113
|
(0, react_1.useEffect)(() => {
|
|
147
114
|
return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);
|
|
148
115
|
}, [client, id]);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
react_1.default.useCallback((...values) => client.config.setVariable(id, ...values), [id]),
|
|
152
|
-
];
|
|
116
|
+
const setVariable = (0, react_1.useCallback)((...values) => client.config.setVariable(id, ...values), [id]);
|
|
117
|
+
return [workbookVariable, setVariable];
|
|
153
118
|
}
|
|
154
119
|
exports.useVariable = useVariable;
|
|
155
120
|
/**
|
|
156
121
|
* React hook for accessing a workbook interaction selections state
|
|
157
122
|
* @param {string} id ID of variable within Plugin Config to use
|
|
158
|
-
* @returns {[(
|
|
123
|
+
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
159
124
|
*/
|
|
160
125
|
function useInteraction(id, elementId) {
|
|
161
126
|
const client = usePlugin();
|
|
@@ -163,11 +128,9 @@ function useInteraction(id, elementId) {
|
|
|
163
128
|
(0, react_1.useEffect)(() => {
|
|
164
129
|
return client.config.subscribeToWorkbookInteraction(id, setWorkbookInteraction);
|
|
165
130
|
}, [client, id]);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}, [id]),
|
|
171
|
-
];
|
|
131
|
+
const setInteraction = (0, react_1.useCallback)((value) => {
|
|
132
|
+
client.config.setInteraction(id, elementId, value);
|
|
133
|
+
}, [id]);
|
|
134
|
+
return [workbookInteraction, setInteraction];
|
|
172
135
|
}
|
|
173
136
|
exports.useInteraction = useInteraction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/react/index.tsx"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SigmaClientProvider = void 0;
|
|
18
|
+
__exportStar(require("./hooks"), exports);
|
|
19
|
+
var Provider_1 = require("./Provider");
|
|
20
|
+
Object.defineProperty(exports, "SigmaClientProvider", { enumerable: true, get: function () { return Provider_1.SigmaClientProvider; } });
|
|
21
|
+
__exportStar(require("../../types"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE5C,cAAc,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,14 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
var initialize_1 = require("./initialize");
|
|
19
|
-
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return initialize_1.initialize; } });
|
|
17
|
+
exports.initialize = exports.client = void 0;
|
|
20
18
|
var client_1 = require("./client");
|
|
21
19
|
Object.defineProperty(exports, "client", { enumerable: true, get: function () { return client_1.client; } });
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* however typescript does not yet support this.
|
|
25
|
-
* Tracked: https://github.com/microsoft/TypeScript/issues/33079
|
|
26
|
-
*/
|
|
27
|
-
__exportStar(require("./react"), exports);
|
|
20
|
+
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return client_1.initialize; } });
|
|
21
|
+
__exportStar(require("./types"), exports);
|