@sigmacomputing/react-embed-sdk 0.2.0 → 0.2.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/index.d.mts CHANGED
@@ -1,6 +1,52 @@
1
1
  import { WorkbookLoadedEvent, WorkbookErrorEvent } from '@sigmacomputing/embed-sdk';
2
+ export * from '@sigmacomputing/embed-sdk';
2
3
 
3
- declare function useWorkbookLoaded(iframeRef: React.RefObject<HTMLIFrameElement>, onLoaded: (event: WorkbookLoadedEvent) => void): void;
4
- declare function useWorkbookError(iframeRef: React.RefObject<HTMLIFrameElement>, onError: (event: WorkbookErrorEvent) => void): void;
4
+ type OnLoaded = (event: WorkbookLoadedEvent) => void;
5
+ type OnError = (event: WorkbookErrorEvent) => void;
6
+ /**
7
+ * Listen for a workbook loaded event, and execute the given callback when it occurs.
8
+ *
9
+ * @example
10
+ * ```
11
+ * function MyEmbed() {
12
+ * const [loading, setLoading] = useState(true);
13
+ * const loadingCallback = useCallback(() => setLoading(false), []);
14
+ * const iframeRef = useRef<HTMLIFrameElement>(null);
15
+ * useWorkbookLoaded(iframeRef, loadingCallback);
16
+ * return (
17
+ * <iframe
18
+ * className{loading ? "hidden" : "show"}
19
+ * ref={iframeRef}
20
+ * src="https://sigmacomputing.app/embed"
21
+ * />
22
+ * );
23
+ * }
24
+ * ```
25
+ *
26
+ */
27
+ declare function useWorkbookLoaded(iframeRef: React.RefObject<HTMLIFrameElement>, onLoaded: OnLoaded): void;
28
+ /**
29
+ * Listen for a workbook error event, and execute the given callback when it occurs.
30
+ *
31
+ * @example
32
+ * ```
33
+ * function MyEmbed() {
34
+ * const [error, setError] = useState<string | null>(null);
35
+ * const onError = useCallback((event: WorkbookErrorEvent) => {
36
+ * sendToErrorReporting(event.message);
37
+ * setError(event.message);
38
+ * }, []);
39
+ * const iframeRef = useRef<HTMLIFrameElement>(null);
40
+ * return (
41
+ * <iframe
42
+ * ref={iframeRef}
43
+ * src="https://sigmacomputing.app/embed"
44
+ * />
45
+ * );
46
+ * }
47
+ * ```
48
+ *
49
+ */
50
+ declare function useWorkbookError(iframeRef: React.RefObject<HTMLIFrameElement>, onError: OnError): void;
5
51
 
6
- export { useWorkbookError, useWorkbookLoaded };
52
+ export { type OnError, type OnLoaded, useWorkbookError, useWorkbookLoaded };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,52 @@
1
1
  import { WorkbookLoadedEvent, WorkbookErrorEvent } from '@sigmacomputing/embed-sdk';
2
+ export * from '@sigmacomputing/embed-sdk';
2
3
 
3
- declare function useWorkbookLoaded(iframeRef: React.RefObject<HTMLIFrameElement>, onLoaded: (event: WorkbookLoadedEvent) => void): void;
4
- declare function useWorkbookError(iframeRef: React.RefObject<HTMLIFrameElement>, onError: (event: WorkbookErrorEvent) => void): void;
4
+ type OnLoaded = (event: WorkbookLoadedEvent) => void;
5
+ type OnError = (event: WorkbookErrorEvent) => void;
6
+ /**
7
+ * Listen for a workbook loaded event, and execute the given callback when it occurs.
8
+ *
9
+ * @example
10
+ * ```
11
+ * function MyEmbed() {
12
+ * const [loading, setLoading] = useState(true);
13
+ * const loadingCallback = useCallback(() => setLoading(false), []);
14
+ * const iframeRef = useRef<HTMLIFrameElement>(null);
15
+ * useWorkbookLoaded(iframeRef, loadingCallback);
16
+ * return (
17
+ * <iframe
18
+ * className{loading ? "hidden" : "show"}
19
+ * ref={iframeRef}
20
+ * src="https://sigmacomputing.app/embed"
21
+ * />
22
+ * );
23
+ * }
24
+ * ```
25
+ *
26
+ */
27
+ declare function useWorkbookLoaded(iframeRef: React.RefObject<HTMLIFrameElement>, onLoaded: OnLoaded): void;
28
+ /**
29
+ * Listen for a workbook error event, and execute the given callback when it occurs.
30
+ *
31
+ * @example
32
+ * ```
33
+ * function MyEmbed() {
34
+ * const [error, setError] = useState<string | null>(null);
35
+ * const onError = useCallback((event: WorkbookErrorEvent) => {
36
+ * sendToErrorReporting(event.message);
37
+ * setError(event.message);
38
+ * }, []);
39
+ * const iframeRef = useRef<HTMLIFrameElement>(null);
40
+ * return (
41
+ * <iframe
42
+ * ref={iframeRef}
43
+ * src="https://sigmacomputing.app/embed"
44
+ * />
45
+ * );
46
+ * }
47
+ * ```
48
+ *
49
+ */
50
+ declare function useWorkbookError(iframeRef: React.RefObject<HTMLIFrameElement>, onError: OnError): void;
5
51
 
6
- export { useWorkbookError, useWorkbookLoaded };
52
+ export { type OnError, type OnLoaded, useWorkbookError, useWorkbookLoaded };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigmacomputing/react-embed-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React JavaScript SDK to interact with Sigma Computing's Embed API",
5
5
  "scripts": {
6
6
  "prepublish": "npm run build",
@@ -23,11 +23,12 @@
23
23
  "react-dom": "^16.8 || ^17 || ^18"
24
24
  },
25
25
  "devDependencies": {
26
+ "@sigmacomputing/typescript-config": "*",
26
27
  "@types/react": "^18.2.66",
27
28
  "react": "^18.2.0",
28
29
  "react-dom": "^18.2.0"
29
30
  },
30
31
  "dependencies": {
31
- "@sigmacomputing/embed-sdk": "^0.2.0"
32
+ "@sigmacomputing/embed-sdk": "latest"
32
33
  }
33
34
  }