@datalayer/core 0.0.1 → 0.0.3
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/README.md +187 -7
- package/lib/App.css +47 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +21 -5
- package/lib/__tests__/App.test.d.ts +1 -0
- package/lib/__tests__/App.test.js +17 -0
- package/lib/__tests__/hooks.test.d.ts +1 -0
- package/lib/__tests__/hooks.test.js +19 -0
- package/lib/__tests__/index.test.d.ts +1 -0
- package/lib/__tests__/index.test.js +27 -0
- package/lib/__tests__/integration.test.d.ts +1 -0
- package/lib/__tests__/integration.test.js +57 -0
- package/lib/__tests__/utils.test.d.ts +1 -0
- package/lib/__tests__/utils.test.js +59 -0
- package/lib/api/DatalayerApi.d.ts +75 -0
- package/lib/api/DatalayerApi.js +145 -0
- package/lib/api/index.d.ts +3 -0
- package/lib/api/index.js +7 -0
- package/lib/api/jupyter/exec/Python.d.ts +5 -0
- package/lib/api/jupyter/exec/Python.js +100 -0
- package/lib/api/jupyter/exec/Snippets.d.ts +145 -0
- package/lib/api/jupyter/exec/Snippets.js +120 -0
- package/lib/api/jupyter/exec/index.d.ts +2 -0
- package/lib/api/jupyter/exec/index.js +6 -0
- package/lib/api/jupyter/index.d.ts +2 -0
- package/lib/api/jupyter/index.js +6 -0
- package/lib/api/jupyter/kernelsHandler.d.ts +8 -0
- package/lib/api/jupyter/kernelsHandler.js +39 -0
- package/lib/api/runtimes/actions.d.ts +102 -0
- package/lib/api/runtimes/actions.js +264 -0
- package/lib/api/runtimes/apis.d.ts +273 -0
- package/lib/api/runtimes/apis.js +5 -0
- package/lib/api/runtimes/index.d.ts +5 -0
- package/lib/api/runtimes/index.js +9 -0
- package/lib/api/runtimes/settings.d.ts +15 -0
- package/lib/api/runtimes/settings.js +31 -0
- package/lib/api/runtimes/snapshots.d.ts +25 -0
- package/lib/api/runtimes/snapshots.js +150 -0
- package/lib/api/runtimes/utils.d.ts +7 -0
- package/lib/api/runtimes/utils.js +17 -0
- package/lib/assets/react.svg +1 -0
- package/lib/components/avatars/BoringAvatar.d.ts +19 -0
- package/lib/components/avatars/BoringAvatar.js +44 -0
- package/lib/components/avatars/BoringAvatar.stories.d.ts +27 -0
- package/lib/components/avatars/BoringAvatar.stories.js +23 -0
- package/lib/components/avatars/UserProfileAvatar.d.ts +13 -0
- package/lib/components/avatars/UserProfileAvatar.js +32 -0
- package/lib/components/avatars/index.d.ts +2 -0
- package/lib/components/avatars/index.js +6 -0
- package/lib/components/banners/NoAutomationBanner.d.ts +2 -0
- package/lib/components/banners/NoAutomationBanner.js +13 -0
- package/lib/components/banners/index.d.ts +1 -0
- package/lib/components/banners/index.js +5 -0
- package/lib/components/buttons/DownloadCSVButton.d.ts +13 -0
- package/lib/components/buttons/DownloadCSVButton.js +16 -0
- package/lib/components/buttons/DownloadJsonButton.d.ts +16 -0
- package/lib/components/buttons/DownloadJsonButton.js +18 -0
- package/lib/components/buttons/LongActionButton.d.ts +28 -0
- package/lib/components/buttons/LongActionButton.js +24 -0
- package/lib/components/buttons/UploadButton.d.ts +37 -0
- package/lib/components/buttons/UploadButton.js +43 -0
- package/lib/components/buttons/VariantType.d.ts +1 -0
- package/lib/components/buttons/VariantType.js +5 -0
- package/lib/components/buttons/index.d.ts +5 -0
- package/lib/components/buttons/index.js +9 -0
- package/lib/components/checkout/StripeCheckout.d.ts +32 -0
- package/lib/components/checkout/StripeCheckout.js +95 -0
- package/lib/components/checkout/index.d.ts +1 -0
- package/lib/components/checkout/index.js +5 -0
- package/lib/components/confetti/ConfettiSuccess.d.ts +2 -0
- package/lib/components/confetti/ConfettiSuccess.js +12 -0
- package/lib/components/confetti/index.d.ts +1 -0
- package/lib/components/confetti/index.js +5 -0
- package/lib/components/context/OrganizationSelect.d.ts +2 -0
- package/lib/components/context/OrganizationSelect.js +35 -0
- package/lib/components/context/SpaceSelect.d.ts +2 -0
- package/lib/components/context/SpaceSelect.js +43 -0
- package/lib/components/context/index.d.ts +2 -0
- package/lib/components/context/index.js +6 -0
- package/lib/components/display/AvatarSkeleton.d.ts +5 -0
- package/lib/components/display/AvatarSkeleton.js +11 -0
- package/lib/components/display/CenteredSpinner.d.ts +14 -0
- package/lib/components/display/CenteredSpinner.js +20 -0
- package/lib/components/display/CodePreview.d.ts +4 -0
- package/lib/components/display/CodePreview.js +15 -0
- package/lib/components/display/DatalayerBox.d.ts +8 -0
- package/lib/components/display/DatalayerBox.js +28 -0
- package/lib/components/display/HorizontalCenter.d.ts +9 -0
- package/lib/components/display/HorizontalCenter.js +14 -0
- package/lib/components/display/JupyterDialog.d.ts +69 -0
- package/lib/components/display/JupyterDialog.js +115 -0
- package/lib/components/display/Markdown.d.ts +23 -0
- package/lib/components/display/Markdown.js +20 -0
- package/lib/components/display/NavLink.d.ts +9 -0
- package/lib/components/display/NavLink.js +17 -0
- package/lib/components/display/NotebookSkeleton.d.ts +2 -0
- package/lib/components/display/NotebookSkeleton.js +11 -0
- package/lib/components/display/Placeholder.d.ts +2 -0
- package/lib/components/display/Placeholder.js +9 -0
- package/lib/components/display/ToTopBranded.d.ts +2 -0
- package/lib/components/display/ToTopBranded.js +11 -0
- package/lib/components/display/VisuallyHidden.d.ts +5 -0
- package/lib/components/display/VisuallyHidden.js +24 -0
- package/lib/components/display/index.d.ts +12 -0
- package/lib/components/display/index.js +16 -0
- package/lib/components/echarts/EChartsReact.d.ts +11 -0
- package/lib/components/echarts/EChartsReact.js +53 -0
- package/lib/components/echarts/index.d.ts +1 -0
- package/lib/components/echarts/index.js +5 -0
- package/lib/components/flashes/FlashClosable.d.ts +22 -0
- package/lib/components/flashes/FlashClosable.js +64 -0
- package/lib/components/flashes/FlashDisclaimer.d.ts +2 -0
- package/lib/components/flashes/FlashDisclaimer.js +18 -0
- package/lib/components/flashes/FlashGuest.d.ts +2 -0
- package/lib/components/flashes/FlashGuest.js +30 -0
- package/lib/components/flashes/FlashSurveys.d.ts +6 -0
- package/lib/components/flashes/FlashSurveys.js +36 -0
- package/lib/components/flashes/FlashUnauthorized.d.ts +2 -0
- package/lib/components/flashes/FlashUnauthorized.js +18 -0
- package/lib/components/flashes/index.d.ts +6 -0
- package/lib/components/flashes/index.js +10 -0
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +3 -0
- package/lib/components/flashes/surveys/Survey2025_1.js +129 -0
- package/lib/components/flashes/surveys/SurveyProps.d.ts +6 -0
- package/lib/components/flashes/surveys/SurveyProps.js +5 -0
- package/lib/components/flashes/surveys/index.d.ts +2 -0
- package/lib/components/flashes/surveys/index.js +6 -0
- package/lib/components/iam/ExternalTokenSilentLogin.d.ts +5 -0
- package/lib/components/iam/ExternalTokenSilentLogin.js +33 -0
- package/lib/components/iam/index.d.ts +1 -0
- package/lib/components/iam/index.js +5 -0
- package/lib/components/icons/ArtifactIcon.d.ts +10 -0
- package/lib/components/icons/ArtifactIcon.js +58 -0
- package/lib/components/icons/index.d.ts +1 -0
- package/lib/components/icons/index.js +5 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +5 -0
- package/lib/components/labels/VisibilityLabel.d.ts +4 -0
- package/lib/components/labels/VisibilityLabel.js +17 -0
- package/lib/components/labels/index.d.ts +1 -0
- package/lib/components/labels/index.js +5 -0
- package/lib/components/landings/StepBlock.d.ts +11 -0
- package/lib/components/landings/StepBlock.js +12 -0
- package/lib/components/landings/index.d.ts +1 -0
- package/lib/components/landings/index.js +5 -0
- package/lib/components/navbar/NavigationVisbilityObserver.d.ts +5 -0
- package/lib/components/navbar/NavigationVisbilityObserver.js +58 -0
- package/lib/components/navbar/SubdomainNavBar.d.ts +81 -0
- package/lib/components/navbar/SubdomainNavBar.js +235 -0
- package/lib/components/navbar/SubdomainNavBar.module.css +718 -0
- package/lib/components/navbar/index.d.ts +2 -0
- package/lib/components/navbar/index.js +6 -0
- package/lib/components/nbgrader/NbGradesDetails.d.ts +5 -0
- package/lib/components/nbgrader/NbGradesDetails.js +17 -0
- package/lib/components/nbgrader/index.d.ts +1 -0
- package/lib/components/nbgrader/index.js +5 -0
- package/lib/components/notebooks/JupyterNotebook.d.ts +12 -0
- package/lib/components/notebooks/JupyterNotebook.js +36 -0
- package/lib/components/notebooks/JupyterNotebookToolbar.d.ts +2 -0
- package/lib/components/notebooks/JupyterNotebookToolbar.js +39 -0
- package/lib/components/notebooks/index.d.ts +2 -0
- package/lib/components/notebooks/index.js +6 -0
- package/lib/components/primer/Helper.d.ts +32 -0
- package/lib/components/primer/Helper.js +19 -0
- package/lib/components/primer/Portals.d.ts +9 -0
- package/lib/components/primer/Portals.js +26 -0
- package/lib/components/primer/Styles.d.ts +2 -0
- package/lib/components/primer/Styles.js +11 -0
- package/lib/components/primer/index.d.ts +2 -0
- package/lib/components/primer/index.js +6 -0
- package/lib/components/progress/ConsumptionBar.d.ts +40 -0
- package/lib/components/progress/ConsumptionBar.js +49 -0
- package/lib/components/progress/CreditsIndicator.d.ts +27 -0
- package/lib/components/progress/CreditsIndicator.js +24 -0
- package/lib/components/progress/ProgressBar.d.ts +2 -0
- package/lib/components/progress/ProgressBar.js +21 -0
- package/lib/components/progress/ProgressRing.d.ts +36 -0
- package/lib/components/progress/ProgressRing.js +31 -0
- package/lib/components/progress/Timer.d.ts +9 -0
- package/lib/components/progress/Timer.js +28 -0
- package/lib/components/progress/index.d.ts +5 -0
- package/lib/components/progress/index.js +9 -0
- package/lib/components/runtimes/RuntimeCellVariables.d.ts +39 -0
- package/lib/components/runtimes/RuntimeCellVariables.js +172 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.d.ts +37 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +101 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +53 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.js +250 -0
- package/lib/components/runtimes/RuntimePickerBase.d.ts +69 -0
- package/lib/components/runtimes/RuntimePickerBase.js +109 -0
- package/lib/components/runtimes/RuntimePickerCell.d.ts +34 -0
- package/lib/components/runtimes/RuntimePickerCell.js +106 -0
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +42 -0
- package/lib/components/runtimes/RuntimePickerNotebook.js +168 -0
- package/lib/components/runtimes/RuntimeReservationControl.d.ts +47 -0
- package/lib/components/runtimes/RuntimeReservationControl.js +38 -0
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +34 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +156 -0
- package/lib/components/runtimes/RuntimeTransfer.d.ts +16 -0
- package/lib/components/runtimes/RuntimeTransfer.js +5 -0
- package/lib/components/runtimes/RuntimeUtils.d.ts +17 -0
- package/lib/components/runtimes/RuntimeUtils.js +168 -0
- package/lib/components/runtimes/RuntimeVariables.d.ts +38 -0
- package/lib/components/runtimes/RuntimeVariables.js +75 -0
- package/lib/components/runtimes/index.d.ts +11 -0
- package/lib/components/runtimes/index.js +15 -0
- package/lib/components/screenshot/ScreenCapture.d.ts +38 -0
- package/lib/components/screenshot/ScreenCapture.js +174 -0
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +3 -0
- package/lib/components/screenshot/ScreenCaptureButton.js +21 -0
- package/lib/components/screenshot/index.d.ts +2 -0
- package/lib/components/screenshot/index.js +6 -0
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +36 -0
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +164 -0
- package/lib/components/snapshots/index.d.ts +1 -0
- package/lib/components/snapshots/index.js +5 -0
- package/lib/components/snippets/SnippetDialog.d.ts +42 -0
- package/lib/components/snippets/SnippetDialog.js +42 -0
- package/lib/components/snippets/index.d.ts +1 -0
- package/lib/components/snippets/index.js +5 -0
- package/lib/components/storage/ContentsBrowser.d.ts +32 -0
- package/lib/components/storage/ContentsBrowser.js +255 -0
- package/lib/components/storage/ContentsItems.d.ts +58 -0
- package/lib/components/storage/ContentsItems.js +78 -0
- package/lib/components/storage/index.d.ts +2 -0
- package/lib/components/storage/index.js +6 -0
- package/lib/components/students/StudentItemStatus.d.ts +7 -0
- package/lib/components/students/StudentItemStatus.js +47 -0
- package/lib/components/students/index.d.ts +1 -0
- package/lib/components/students/index.js +5 -0
- package/lib/components/subnav/SubNav.d.ts +84 -0
- package/lib/components/subnav/SubNav.js +265 -0
- package/lib/components/subnav/SubNav.module.css +683 -0
- package/lib/components/subnav/index.d.ts +1 -0
- package/lib/components/subnav/index.js +5 -0
- package/lib/components/tables/DataTable.d.ts +5 -0
- package/lib/components/tables/DataTable.js +19 -0
- package/lib/components/tables/index.d.ts +1 -0
- package/lib/components/tables/index.js +5 -0
- package/lib/components/text-reveal/TextRevealAnimation.d.ts +6 -0
- package/lib/components/text-reveal/TextRevealAnimation.js +49 -0
- package/lib/components/text-reveal/TextRevealAnimation.module.css +43 -0
- package/lib/components/text-reveal/index.d.ts +1 -0
- package/lib/components/text-reveal/index.js +5 -0
- package/lib/components/text-reveal/useTextRevealAnimationLines.d.ts +4 -0
- package/lib/components/text-reveal/useTextRevealAnimationLines.js +47 -0
- package/lib/components/tokens/SpaceVariantToken.d.ts +5 -0
- package/lib/components/tokens/SpaceVariantToken.js +20 -0
- package/lib/components/tokens/index.d.ts +1 -0
- package/lib/components/tokens/index.js +5 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +4 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.js +18 -0
- package/lib/components/toolbars/DocumentEditorToolbar.d.ts +2 -0
- package/lib/components/toolbars/DocumentEditorToolbar.js +12 -0
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +29 -0
- package/lib/components/toolbars/NotebookEditorToolbar.js +30 -0
- package/lib/components/toolbars/index.d.ts +3 -0
- package/lib/components/toolbars/index.js +7 -0
- package/lib/components/users/PeerIndicator.d.ts +18 -0
- package/lib/components/users/PeerIndicator.js +100 -0
- package/lib/components/users/index.d.ts +1 -0
- package/lib/components/users/index.js +5 -0
- package/lib/config/Configuration.d.ts +111 -0
- package/lib/config/Configuration.js +25 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.js +6 -0
- package/lib/config/integrations/Loom.d.ts +1 -0
- package/lib/config/integrations/Loom.js +16 -0
- package/lib/config/integrations/index.d.ts +1 -0
- package/lib/config/integrations/index.js +5 -0
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +24 -0
- package/lib/examples/NotebookExample.d.ts +8 -0
- package/lib/examples/NotebookExample.js +22 -0
- package/lib/examples/NotebookExample1.ipynb.json +136 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +19 -0
- package/lib/hooks/assets/OutputshotPlaceholders.js +23 -0
- package/lib/hooks/assets/index.d.ts +1 -0
- package/lib/hooks/assets/index.js +5 -0
- package/lib/hooks/index.d.ts +28 -0
- package/lib/hooks/index.js +33 -0
- package/lib/hooks/layouts/LayoutBackdrop.d.ts +2 -0
- package/lib/hooks/layouts/LayoutBackdrop.js +30 -0
- package/lib/hooks/layouts/LayoutScreenshot.css +58 -0
- package/lib/hooks/layouts/LayoutScreenshot.d.ts +3 -0
- package/lib/hooks/layouts/LayoutScreenshot.js +44 -0
- package/lib/hooks/layouts/index.d.ts +2 -0
- package/lib/hooks/layouts/index.js +6 -0
- package/lib/hooks/useAIAgents.d.ts +13 -0
- package/lib/hooks/useAIAgents.js +72 -0
- package/lib/hooks/useAuthorization.d.ts +19 -0
- package/lib/hooks/useAuthorization.js +124 -0
- package/lib/hooks/useBackdrop.d.ts +28 -0
- package/lib/hooks/useBackdrop.js +100 -0
- package/lib/hooks/useBackdropJupyterLab.d.ts +15 -0
- package/lib/hooks/useBackdropJupyterLab.js +51 -0
- package/lib/hooks/useCache.d.ts +306 -0
- package/lib/hooks/useCache.js +3098 -0
- package/lib/hooks/useCellOutputshot.d.ts +4 -0
- package/lib/hooks/useCellOutputshot.js +28 -0
- package/lib/hooks/useContainsFocus.d.ts +9 -0
- package/lib/hooks/useContainsFocus.js +43 -0
- package/lib/hooks/useDatalayer.d.ts +21 -0
- package/lib/hooks/useDatalayer.js +81 -0
- package/lib/hooks/useError.d.ts +9 -0
- package/lib/hooks/useError.js +26 -0
- package/lib/hooks/useExternalScript.d.ts +2 -0
- package/lib/hooks/useExternalScript.js +17 -0
- package/lib/hooks/useFocusTrap.d.ts +30 -0
- package/lib/hooks/useFocusTrap.js +48 -0
- package/lib/hooks/useIAM.d.ts +14 -0
- package/lib/hooks/useIAM.js +93 -0
- package/lib/hooks/useId.d.ts +19 -0
- package/lib/hooks/useId.js +100 -0
- package/lib/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js +11 -0
- package/lib/hooks/useJupyterLabTheme.d.ts +6 -0
- package/lib/hooks/useJupyterLabTheme.js +24 -0
- package/lib/hooks/useKeyboardEscape.d.ts +1 -0
- package/lib/hooks/useKeyboardEscape.js +18 -0
- package/lib/hooks/useLocationHandles.d.ts +10 -0
- package/lib/hooks/useLocationHandles.js +22 -0
- package/lib/hooks/useNavigate.d.ts +2 -0
- package/lib/hooks/useNavigate.js +24 -0
- package/lib/hooks/useNotebookAIAgent.d.ts +8 -0
- package/lib/hooks/useNotebookAIAgent.js +54 -0
- package/lib/hooks/useOnClickOutside.d.ts +1 -0
- package/lib/hooks/useOnClickOutside.js +29 -0
- package/lib/hooks/useRef.d.ts +10 -0
- package/lib/hooks/useRef.js +17 -0
- package/lib/hooks/useRuntimes.d.ts +5 -0
- package/lib/hooks/useRuntimes.js +34 -0
- package/lib/hooks/useScreenshot.d.ts +21 -0
- package/lib/hooks/useScreenshot.js +60 -0
- package/lib/hooks/useToast.d.ts +42 -0
- package/lib/hooks/useToast.js +141 -0
- package/lib/hooks/useUpload.d.ts +7 -0
- package/lib/hooks/useUpload.js +46 -0
- package/lib/hooks/useUser.d.ts +3 -0
- package/lib/hooks/useUser.js +22 -0
- package/lib/hooks/useVisibilityObserver.d.ts +5 -0
- package/lib/hooks/useVisibilityObserver.js +42 -0
- package/lib/hooks/useWindowSize.d.ts +21 -0
- package/lib/hooks/useWindowSize.js +74 -0
- package/lib/i18n/Labels.d.ts +1 -0
- package/lib/i18n/Labels.js +5 -0
- package/lib/i18n/index.d.ts +1 -0
- package/lib/i18n/index.js +5 -0
- package/lib/index.css +73 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +5 -2
- package/lib/mocks/components/FlashMock.d.ts +2 -0
- package/lib/mocks/components/FlashMock.js +13 -0
- package/lib/mocks/components/index.d.ts +1 -0
- package/lib/mocks/components/index.js +5 -0
- package/lib/mocks/hooks/index.d.ts +1 -0
- package/lib/mocks/hooks/index.js +5 -0
- package/lib/mocks/hooks/rests/index.d.ts +1 -0
- package/lib/mocks/hooks/rests/index.js +5 -0
- package/lib/mocks/hooks/rests/rests.d.ts +22 -0
- package/lib/mocks/hooks/rests/rests.js +32 -0
- package/lib/mocks/hooks/useDatalayerMock.d.ts +6 -0
- package/lib/mocks/hooks/useDatalayerMock.js +78 -0
- package/lib/mocks/index.d.ts +4 -0
- package/lib/mocks/index.js +9 -0
- package/lib/mocks/jupyter/index.d.ts +1 -0
- package/lib/mocks/jupyter/index.js +5 -0
- package/lib/mocks/models/CodeBlockMock.d.ts +1 -0
- package/lib/mocks/models/CodeBlockMock.js +5 -0
- package/lib/mocks/models/CodelineMock.d.ts +1 -0
- package/lib/mocks/models/CodelineMock.js +5 -0
- package/lib/mocks/models/CourseMock.d.ts +6 -0
- package/lib/mocks/models/CourseMock.js +29 -0
- package/lib/mocks/models/InviteMock.d.ts +6 -0
- package/lib/mocks/models/InviteMock.js +22 -0
- package/lib/mocks/models/JupyterLabUserMock.d.ts +2 -0
- package/lib/mocks/models/JupyterLabUserMock.js +17 -0
- package/lib/mocks/models/OrganisationMock.d.ts +5 -0
- package/lib/mocks/models/OrganisationMock.js +24 -0
- package/lib/mocks/models/SchoolMock.d.ts +6 -0
- package/lib/mocks/models/SchoolMock.js +25 -0
- package/lib/mocks/models/SpaceMock.d.ts +6 -0
- package/lib/mocks/models/SpaceMock.js +25 -0
- package/lib/mocks/models/TeamMock.d.ts +5 -0
- package/lib/mocks/models/TeamMock.js +26 -0
- package/lib/mocks/models/UserMock.d.ts +2 -0
- package/lib/mocks/models/UserMock.js +29 -0
- package/lib/mocks/models/index.d.ts +9 -0
- package/lib/mocks/models/index.js +13 -0
- package/lib/mocks/views/ActionMenuMock.d.ts +5 -0
- package/lib/mocks/views/ActionMenuMock.js +12 -0
- package/lib/mocks/views/ChartMock.d.ts +5 -0
- package/lib/mocks/views/ChartMock.js +15 -0
- package/lib/mocks/views/ChartMockOptions.d.ts +92 -0
- package/lib/mocks/views/ChartMockOptions.js +102 -0
- package/lib/mocks/views/DashboardMock.d.ts +2 -0
- package/lib/mocks/views/DashboardMock.js +118 -0
- package/lib/mocks/views/FormMock.d.ts +5 -0
- package/lib/mocks/views/FormMock.js +28 -0
- package/lib/mocks/views/TableMock.d.ts +5 -0
- package/lib/mocks/views/TableMock.js +155 -0
- package/lib/mocks/views/WipMock.d.ts +5 -0
- package/lib/mocks/views/WipMock.js +12 -0
- package/lib/mocks/views/index.d.ts +7 -0
- package/lib/mocks/views/index.js +11 -0
- package/lib/models/AIAgent.d.ts +17 -0
- package/lib/models/AIAgent.js +5 -0
- package/lib/models/Account.d.ts +4 -0
- package/lib/models/Account.js +5 -0
- package/lib/models/Assignment.d.ts +7 -0
- package/lib/models/Assignment.js +5 -0
- package/lib/models/Base.d.ts +16 -0
- package/lib/models/Base.js +5 -0
- package/lib/models/Cell.d.ts +8 -0
- package/lib/models/Cell.js +5 -0
- package/lib/models/CodeBlock.d.ts +10 -0
- package/lib/models/CodeBlock.js +5 -0
- package/lib/models/CodefeedBlocks.d.ts +7 -0
- package/lib/models/CodefeedBlocks.js +5 -0
- package/lib/models/Contact.d.ts +73 -0
- package/lib/models/Contact.js +90 -0
- package/lib/models/ContactEvent.d.ts +10 -0
- package/lib/models/ContactEvent.js +14 -0
- package/lib/models/ContactIAMProvider.d.ts +12 -0
- package/lib/models/ContactIAMProvider.js +20 -0
- package/lib/models/ContactTags.d.ts +23 -0
- package/lib/models/ContactTags.js +73 -0
- package/lib/models/Content.d.ts +5 -0
- package/lib/models/Content.js +5 -0
- package/lib/models/Course.d.ts +17 -0
- package/lib/models/Course.js +5 -0
- package/lib/models/Credits.d.ts +76 -0
- package/lib/models/Credits.js +11 -0
- package/lib/models/Dataset.d.ts +16 -0
- package/lib/models/Dataset.js +5 -0
- package/lib/models/Datasource.d.ts +11 -0
- package/lib/models/Datasource.js +14 -0
- package/lib/models/Dean.d.ts +3 -0
- package/lib/models/Dean.js +5 -0
- package/lib/models/Document.d.ts +8 -0
- package/lib/models/Document.js +5 -0
- package/lib/models/Environment.d.ts +82 -0
- package/lib/models/Environment.js +5 -0
- package/lib/models/Errors.d.ts +6 -0
- package/lib/models/Errors.js +13 -0
- package/lib/models/Exercise.d.ts +16 -0
- package/lib/models/Exercise.js +5 -0
- package/lib/models/GrowthKPI.d.ts +5 -0
- package/lib/models/GrowthKPI.js +9 -0
- package/lib/models/IAMProviderLinked.d.ts +9 -0
- package/lib/models/IAMProviderLinked.js +13 -0
- package/lib/models/IAMProviderPost.d.ts +8 -0
- package/lib/models/IAMProviderPost.js +22 -0
- package/lib/models/IAMProviderUsers.d.ts +49 -0
- package/lib/models/IAMProviderUsers.js +29 -0
- package/lib/models/IAMProvidersSpecs.d.ts +22 -0
- package/lib/models/IAMProvidersSpecs.js +72 -0
- package/lib/models/IAMToken.d.ts +11 -0
- package/lib/models/IAMToken.js +14 -0
- package/lib/models/Inbound.d.ts +25 -0
- package/lib/models/Inbound.js +29 -0
- package/lib/models/Instructor.d.ts +3 -0
- package/lib/models/Instructor.js +5 -0
- package/lib/models/Invite.d.ts +14 -0
- package/lib/models/Invite.js +24 -0
- package/lib/models/Item.d.ts +20 -0
- package/lib/models/Item.js +5 -0
- package/lib/models/ItemType.d.ts +2 -0
- package/lib/models/ItemType.js +5 -0
- package/lib/models/LandingRoles.d.ts +3 -0
- package/lib/models/LandingRoles.js +27 -0
- package/lib/models/Lesson.d.ts +5 -0
- package/lib/models/Lesson.js +5 -0
- package/lib/models/Library.d.ts +10 -0
- package/lib/models/Library.js +5 -0
- package/lib/models/Member.d.ts +3 -0
- package/lib/models/Member.js +5 -0
- package/lib/models/Notebook.d.ts +11 -0
- package/lib/models/Notebook.js +5 -0
- package/lib/models/Organization.d.ts +27 -0
- package/lib/models/Organization.js +36 -0
- package/lib/models/OrganizationMember.d.ts +6 -0
- package/lib/models/OrganizationMember.js +5 -0
- package/lib/models/Outbound.d.ts +41 -0
- package/lib/models/Outbound.js +45 -0
- package/lib/models/Page.d.ts +36 -0
- package/lib/models/Page.js +23 -0
- package/lib/models/PageTag.d.ts +19 -0
- package/lib/models/PageTag.js +26 -0
- package/lib/models/Profile.d.ts +1 -0
- package/lib/models/Profile.js +5 -0
- package/lib/models/Role.d.ts +9 -0
- package/lib/models/Role.js +5 -0
- package/lib/models/RolesOrganization.d.ts +9 -0
- package/lib/models/RolesOrganization.js +58 -0
- package/lib/models/RolesPlatform.d.ts +16 -0
- package/lib/models/RolesPlatform.js +142 -0
- package/lib/models/RolesTeam.d.ts +7 -0
- package/lib/models/RolesTeam.js +34 -0
- package/lib/models/Runtime.d.ts +123 -0
- package/lib/models/Runtime.js +18 -0
- package/lib/models/RuntimeSnapshot.d.ts +92 -0
- package/lib/models/RuntimeSnapshot.js +13 -0
- package/lib/models/School.d.ts +11 -0
- package/lib/models/School.js +5 -0
- package/lib/models/Secret.d.ts +10 -0
- package/lib/models/Secret.js +13 -0
- package/lib/models/Space.d.ts +34 -0
- package/lib/models/Space.js +39 -0
- package/lib/models/SpaceItem.d.ts +10 -0
- package/lib/models/SpaceItem.js +5 -0
- package/lib/models/SpaceMember.d.ts +6 -0
- package/lib/models/SpaceMember.js +5 -0
- package/lib/models/Student.d.ts +6 -0
- package/lib/models/Student.js +5 -0
- package/lib/models/StudentItem.d.ts +21 -0
- package/lib/models/StudentItem.js +5 -0
- package/lib/models/Survey.d.ts +20 -0
- package/lib/models/Survey.js +14 -0
- package/lib/models/Team.d.ts +22 -0
- package/lib/models/Team.js +32 -0
- package/lib/models/TeamMember.d.ts +6 -0
- package/lib/models/TeamMember.js +5 -0
- package/lib/models/URN.d.ts +63 -0
- package/lib/models/URN.js +40 -0
- package/lib/models/Usage.d.ts +46 -0
- package/lib/models/Usage.js +21 -0
- package/lib/models/User.d.ts +71 -0
- package/lib/models/User.js +98 -0
- package/lib/models/UserEvent.d.ts +10 -0
- package/lib/models/UserEvent.js +14 -0
- package/lib/models/UserOnboarding.d.ts +14 -0
- package/lib/models/UserOnboarding.js +19 -0
- package/lib/models/UserSettings.d.ts +16 -0
- package/lib/models/UserSettings.js +27 -0
- package/lib/models/WaitingListFormData.d.ts +6 -0
- package/lib/models/WaitingListFormData.js +5 -0
- package/lib/models/index.d.ts +65 -0
- package/lib/models/index.js +69 -0
- package/lib/routes/Routes.d.ts +3 -0
- package/lib/routes/Routes.js +7 -0
- package/lib/routes/index.d.ts +1 -0
- package/lib/routes/index.js +5 -0
- package/lib/state/State.d.ts +33 -0
- package/lib/state/State.js +44 -0
- package/lib/state/index.d.ts +3 -0
- package/lib/state/index.js +7 -0
- package/lib/state/storage/IAMStorage.d.ts +33 -0
- package/lib/state/storage/IAMStorage.js +76 -0
- package/lib/state/storage/index.d.ts +1 -0
- package/lib/state/storage/index.js +5 -0
- package/lib/state/substates/AIAgentState.d.ts +11 -0
- package/lib/state/substates/AIAgentState.js +40 -0
- package/lib/state/substates/CellState.d.ts +12 -0
- package/lib/state/substates/CellState.js +21 -0
- package/lib/state/substates/CoreState.d.ts +25 -0
- package/lib/state/substates/CoreState.js +88 -0
- package/lib/state/substates/DatasourceState.d.ts +11 -0
- package/lib/state/substates/DatasourceState.js +16 -0
- package/lib/state/substates/DocumentState.d.ts +10 -0
- package/lib/state/substates/DocumentState.js +14 -0
- package/lib/state/substates/GradeState.d.ts +10 -0
- package/lib/state/substates/GradeState.js +14 -0
- package/lib/state/substates/IAMState.d.ts +75 -0
- package/lib/state/substates/IAMState.js +291 -0
- package/lib/state/substates/JupyterLabState.d.ts +16 -0
- package/lib/state/substates/JupyterLabState.js +17 -0
- package/lib/state/substates/LayoutState.d.ts +62 -0
- package/lib/state/substates/LayoutState.js +74 -0
- package/lib/state/substates/NbformatState.d.ts +13 -0
- package/lib/state/substates/NbformatState.js +16 -0
- package/lib/state/substates/OrganizationState.d.ts +11 -0
- package/lib/state/substates/OrganizationState.js +16 -0
- package/lib/state/substates/RuntimesState.d.ts +88 -0
- package/lib/state/substates/RuntimesState.js +178 -0
- package/lib/state/substates/SpaceState.d.ts +11 -0
- package/lib/state/substates/SpaceState.js +16 -0
- package/lib/state/substates/SurveysState.d.ts +14 -0
- package/lib/state/substates/SurveysState.js +98 -0
- package/lib/state/substates/TeamState.d.ts +11 -0
- package/lib/state/substates/TeamState.js +17 -0
- package/lib/state/substates/index.d.ts +15 -0
- package/lib/state/substates/index.js +19 -0
- package/lib/stories/assets/accessibility.png +0 -0
- package/lib/stories/assets/accessibility.svg +1 -0
- package/lib/stories/assets/addon-library.png +0 -0
- package/lib/stories/assets/assets.png +0 -0
- package/lib/stories/assets/context.png +0 -0
- package/lib/stories/assets/discord.svg +1 -0
- package/lib/stories/assets/docs.png +0 -0
- package/lib/stories/assets/figma-plugin.png +0 -0
- package/lib/stories/assets/github.svg +1 -0
- package/lib/stories/assets/share.png +0 -0
- package/lib/stories/assets/styling.png +0 -0
- package/lib/stories/assets/testing.png +0 -0
- package/lib/stories/assets/theming.png +0 -0
- package/lib/stories/assets/tutorials.svg +1 -0
- package/lib/stories/assets/youtube.svg +1 -0
- package/lib/stories/button.css +35 -0
- package/lib/stories/header.css +37 -0
- package/lib/stories/page.css +73 -0
- package/lib/test-setup.d.ts +1 -0
- package/lib/test-setup.js +57 -0
- package/lib/theme/DatalayerTheme.d.ts +37 -0
- package/lib/theme/DatalayerTheme.js +62 -0
- package/lib/theme/DatalayerThemeProvider.d.ts +17 -0
- package/lib/theme/DatalayerThemeProvider.js +69 -0
- package/lib/theme/Palette.d.ts +5 -0
- package/lib/theme/Palette.js +22 -0
- package/lib/theme/index.d.ts +3 -0
- package/lib/theme/index.js +7 -0
- package/lib/utils/Array.d.ts +2 -0
- package/lib/utils/Array.js +16 -0
- package/lib/utils/Avatar.d.ts +9 -0
- package/lib/utils/Avatar.js +34 -0
- package/lib/utils/Browser.d.ts +3 -0
- package/lib/utils/Browser.js +63 -0
- package/lib/utils/Cells.d.ts +2 -0
- package/lib/utils/Cells.js +28 -0
- package/lib/utils/Cookie.d.ts +12 -0
- package/lib/utils/Cookie.js +48 -0
- package/lib/utils/Date.d.ts +2 -0
- package/lib/utils/Date.js +60 -0
- package/lib/utils/Download.d.ts +3 -0
- package/lib/utils/Download.js +48 -0
- package/lib/utils/DownloadFile.d.ts +10 -0
- package/lib/utils/DownloadFile.js +36 -0
- package/lib/utils/Env.d.ts +1 -0
- package/lib/utils/Env.js +7 -0
- package/lib/utils/File.d.ts +7 -0
- package/lib/utils/File.js +16 -0
- package/lib/utils/Format.d.ts +17 -0
- package/lib/utils/Format.js +54 -0
- package/lib/utils/Ids.d.ts +2 -0
- package/lib/utils/Ids.js +12 -0
- package/lib/utils/Jupyter.d.ts +1 -0
- package/lib/utils/Jupyter.js +12 -0
- package/lib/utils/Lazy.d.ts +8 -0
- package/lib/utils/Lazy.js +23 -0
- package/lib/utils/Msc.d.ts +16 -0
- package/lib/utils/Msc.js +28 -0
- package/lib/utils/Name.d.ts +7 -0
- package/lib/utils/Name.js +34 -0
- package/lib/utils/Notebook.d.ts +19 -0
- package/lib/utils/Notebook.js +37 -0
- package/lib/utils/Number.d.ts +1 -0
- package/lib/utils/Number.js +21 -0
- package/lib/utils/Plots.d.ts +16 -0
- package/lib/utils/Plots.js +56 -0
- package/lib/utils/Random.d.ts +1 -0
- package/lib/utils/Random.js +7 -0
- package/lib/utils/Screenshot.d.ts +1 -0
- package/lib/utils/Screenshot.js +27 -0
- package/lib/utils/Scroll.d.ts +2 -0
- package/lib/utils/Scroll.js +32 -0
- package/lib/utils/Sleep.d.ts +2 -0
- package/lib/utils/Sleep.js +8 -0
- package/lib/utils/Snapshot.d.ts +7 -0
- package/lib/utils/Snapshot.js +21 -0
- package/lib/utils/String.d.ts +1 -0
- package/lib/utils/String.js +13 -0
- package/lib/utils/Uri.d.ts +2 -0
- package/lib/utils/Uri.js +26 -0
- package/lib/utils/Validator.d.ts +12 -0
- package/lib/utils/Validator.js +44 -0
- package/lib/utils/WithSuspense.d.ts +2 -0
- package/lib/utils/WithSuspense.js +21 -0
- package/lib/utils/index.d.ts +26 -0
- package/lib/utils/index.js +31 -0
- package/package.json +86 -17
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +62 -3
- package/style/index.css +2 -3
- package/style/index.js +0 -7
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Kernel } from '@jupyterlab/services';
|
|
2
|
+
type Props = {
|
|
3
|
+
connection: Kernel.IKernelConnection;
|
|
4
|
+
metadata: {
|
|
5
|
+
filename: string;
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Snapshot a runtime through the frontend and upload it to the cloud.
|
|
12
|
+
*
|
|
13
|
+
* Note: You should use this only for browser runtimes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createRuntimeSnapshot(props: Props): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Load a snapshot within a browser kernel.
|
|
18
|
+
*
|
|
19
|
+
* Note: You should use this only for browser kernels.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadBrowserRuntimeSnapshot({ connection, id }: {
|
|
22
|
+
connection: Kernel.IKernelConnection;
|
|
23
|
+
id: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { KernelExecutor } from '@datalayer/jupyter-react';
|
|
6
|
+
import { createRuntimeSnapshotDownloadURL, uploadRuntimeSnapshot } from '.';
|
|
7
|
+
/**
|
|
8
|
+
* Snapshot a runtime through the frontend and upload it to the cloud.
|
|
9
|
+
*
|
|
10
|
+
* Note: You should use this only for browser runtimes.
|
|
11
|
+
*/
|
|
12
|
+
export async function createRuntimeSnapshot(props) {
|
|
13
|
+
const { connection, metadata, onUploadProgress } = props;
|
|
14
|
+
const dump = await new KernelExecutor({ connection })
|
|
15
|
+
.execute(GET_RUNTIME_SNAPSHOT_SNIPPET, {
|
|
16
|
+
storeHistory: false
|
|
17
|
+
});
|
|
18
|
+
const serializedData = (dump.get(0)?.data['application/vnd.jupyter.stdout'] ?? '');
|
|
19
|
+
// Convert the data to blob.
|
|
20
|
+
const bytes = base64ToBytes(serializedData);
|
|
21
|
+
const file = new Blob([bytes.buffer]);
|
|
22
|
+
return uploadRuntimeSnapshot({
|
|
23
|
+
file,
|
|
24
|
+
metadata,
|
|
25
|
+
onProgress: onUploadProgress
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function base64ToBytes(base64) {
|
|
29
|
+
// Taken from https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa#unicode_strings
|
|
30
|
+
const binString = atob(base64);
|
|
31
|
+
// @ts-expect-error TypeScript does not like this
|
|
32
|
+
return Uint8Array.from(binString, m => m.codePointAt(0));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load a snapshot within a browser kernel.
|
|
36
|
+
*
|
|
37
|
+
* Note: You should use this only for browser kernels.
|
|
38
|
+
*/
|
|
39
|
+
export async function loadBrowserRuntimeSnapshot({ connection, id }) {
|
|
40
|
+
const downloadURL = createRuntimeSnapshotDownloadURL(id);
|
|
41
|
+
const response = await fetch(downloadURL);
|
|
42
|
+
const buffer = await response.arrayBuffer();
|
|
43
|
+
const base64 = bytesToBase64(new Uint8Array(buffer));
|
|
44
|
+
await new KernelExecutor({
|
|
45
|
+
connection
|
|
46
|
+
}).execute(getLoadRuntimeSnapshotSnippet(base64), {
|
|
47
|
+
storeHistory: false,
|
|
48
|
+
silent: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function bytesToBase64(bytes) {
|
|
52
|
+
// Taken from https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa#unicode_strings
|
|
53
|
+
const binString = Array.from(bytes, byte => String.fromCodePoint(byte)).join('');
|
|
54
|
+
return btoa(binString);
|
|
55
|
+
}
|
|
56
|
+
const GET_RUNTIME_SNAPSHOT_SNIPPET = `def _create_snapshot():
|
|
57
|
+
import logging
|
|
58
|
+
import os
|
|
59
|
+
import pickle
|
|
60
|
+
from base64 import encodebytes
|
|
61
|
+
from tempfile import TemporaryFile
|
|
62
|
+
from types import BuiltinFunctionType, BuiltinMethodType, FunctionType, MethodType, MethodWrapperType, ModuleType, TracebackType
|
|
63
|
+
|
|
64
|
+
# print(pickle.DEFAULT_PROTOCOL)
|
|
65
|
+
|
|
66
|
+
class NotFound:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
missing = NotFound()
|
|
70
|
+
|
|
71
|
+
FORBIDDEN_TYPES = [type, BuiltinFunctionType, BuiltinMethodType, FunctionType, MethodType, MethodWrapperType, ModuleType, TracebackType, NotFound]
|
|
72
|
+
try:
|
|
73
|
+
from IPython.core.autocall import ExitAutocall
|
|
74
|
+
from IPython.core.interactiveshell import InteractiveShell
|
|
75
|
+
FORBIDDEN_TYPES.extend([ExitAutocall, InteractiveShell])
|
|
76
|
+
except ImportError:
|
|
77
|
+
pass
|
|
78
|
+
exclude = tuple(FORBIDDEN_TYPES)
|
|
79
|
+
|
|
80
|
+
all = frozenset(filter(lambda n: not n.startswith("_"), globals()))
|
|
81
|
+
|
|
82
|
+
line_separator = bytes(os.linesep, "utf-8")
|
|
83
|
+
with TemporaryFile() as dump:
|
|
84
|
+
for _n in all:
|
|
85
|
+
_v = globals().get(_n, missing)
|
|
86
|
+
|
|
87
|
+
if not (
|
|
88
|
+
isinstance(_v, exclude) or
|
|
89
|
+
# Special IPython variables
|
|
90
|
+
(_n == "In" and isinstance(_v, list)) or
|
|
91
|
+
(_n == "Out" and isinstance(_v, dict))
|
|
92
|
+
):
|
|
93
|
+
try:
|
|
94
|
+
dumped_n = _n.encode("utf-8") + line_separator + pickle.dumps(_v) + line_separator + b"\\x00" + line_separator
|
|
95
|
+
dump.write(dumped_n)
|
|
96
|
+
except BaseException as e:
|
|
97
|
+
logging.warning("Failed to dump variable [%s ([%s])].", _n, type(_v).__qualname__, exc_info=e)
|
|
98
|
+
else:
|
|
99
|
+
logging.debug("Variable [%s] dumped", _n)
|
|
100
|
+
|
|
101
|
+
dump.seek(0)
|
|
102
|
+
print(encodebytes(dump.read()).decode("ascii"))
|
|
103
|
+
|
|
104
|
+
_create_snapshot()
|
|
105
|
+
del _create_snapshot
|
|
106
|
+
`;
|
|
107
|
+
function getLoadRuntimeSnapshotSnippet(content) {
|
|
108
|
+
return `async def _load_snapshot():
|
|
109
|
+
import os
|
|
110
|
+
import logging
|
|
111
|
+
import platform
|
|
112
|
+
import pickle
|
|
113
|
+
from base64 import decodebytes
|
|
114
|
+
is_pyodide = platform.node() == "emscripten"
|
|
115
|
+
|
|
116
|
+
snapshot = decodebytes("${content}".encode("ascii"))
|
|
117
|
+
line_sep = bytes(os.linesep, "utf-8")
|
|
118
|
+
variable_separator = b"\\x00" + line_sep
|
|
119
|
+
name = b""
|
|
120
|
+
value = b""
|
|
121
|
+
for line in snapshot.splitlines():
|
|
122
|
+
line += line_sep
|
|
123
|
+
if line == variable_separator:
|
|
124
|
+
name_s = name.strip().decode("utf-8")
|
|
125
|
+
try:
|
|
126
|
+
try:
|
|
127
|
+
globals()[name_s] = pickle.loads(value)
|
|
128
|
+
except ModuleNotFoundError as m:
|
|
129
|
+
if is_pyodide:
|
|
130
|
+
import micropip
|
|
131
|
+
logging.info(f'Installing %s...', m.name)
|
|
132
|
+
await micropip.install(m.name)
|
|
133
|
+
globals()[name_s] = pickle.loads(value)
|
|
134
|
+
else:
|
|
135
|
+
raise m
|
|
136
|
+
except BaseException as e:
|
|
137
|
+
logging.warning("Failed to load variable [%s].", name_s, exc_info=e)
|
|
138
|
+
else:
|
|
139
|
+
logging.debug("Variable [%s] loaded", name_s)
|
|
140
|
+
|
|
141
|
+
name = b""
|
|
142
|
+
value = b""
|
|
143
|
+
else:
|
|
144
|
+
if not name:
|
|
145
|
+
name = line
|
|
146
|
+
else:
|
|
147
|
+
value += line
|
|
148
|
+
await _load_snapshot()
|
|
149
|
+
del _load_snapshot`;
|
|
150
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
const NON_REMOTE_LOCATION = [
|
|
6
|
+
'browser',
|
|
7
|
+
'local',
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Check whether the location is remote or not.
|
|
11
|
+
*
|
|
12
|
+
* @param location The location to test
|
|
13
|
+
* @returns The result
|
|
14
|
+
*/
|
|
15
|
+
export function isRuntimeRemote(location) {
|
|
16
|
+
return !NON_REMOTE_LOCATION.includes(location);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type VariantType = "marble" | "beam" | "pixel" | "sunset" | "ring" | "bauhaus" | undefined;
|
|
2
|
+
type IBoringAvatarProps = {
|
|
3
|
+
displayName: string;
|
|
4
|
+
variant: VariantType;
|
|
5
|
+
size: number;
|
|
6
|
+
square: boolean;
|
|
7
|
+
style: object;
|
|
8
|
+
};
|
|
9
|
+
export declare const BoringAvatar: {
|
|
10
|
+
(props: IBoringAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
defaultProps: {
|
|
12
|
+
displayName: string;
|
|
13
|
+
variant: VariantType;
|
|
14
|
+
size: number;
|
|
15
|
+
square: boolean;
|
|
16
|
+
style: undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default BoringAvatar;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import BoringAvatars from 'boring-avatars';
|
|
7
|
+
/*
|
|
8
|
+
const variants = [
|
|
9
|
+
"bauhaus",
|
|
10
|
+
"beam",
|
|
11
|
+
"marble",
|
|
12
|
+
"pixel",
|
|
13
|
+
"ring",
|
|
14
|
+
"sunset",
|
|
15
|
+
];
|
|
16
|
+
export const getRandomBoringAvatarVariant = () => variants[Math.floor(Math.random() * variants.length)] as VariantType;
|
|
17
|
+
*/
|
|
18
|
+
const getRandomBoringAvatarVariant = () => "bauhaus";
|
|
19
|
+
const RANDOM_BORING_AVATOR_VARIANT = getRandomBoringAvatarVariant();
|
|
20
|
+
export const BoringAvatar = (props) => {
|
|
21
|
+
const { displayName, size, square, style } = props;
|
|
22
|
+
const variant = props.variant ?? getRandomBoringAvatarVariant();
|
|
23
|
+
return (_jsx("span", { style: { ...style || {} }, children: _jsx(BoringAvatars, { size: size, name: displayName, variant: variant, square: square, colors: [
|
|
24
|
+
'#000000',
|
|
25
|
+
'#146A7C',
|
|
26
|
+
'#16A085',
|
|
27
|
+
'#1ABC9C',
|
|
28
|
+
'#2ECC71',
|
|
29
|
+
'#59595C',
|
|
30
|
+
'#92A1C6',
|
|
31
|
+
'#C20D90',
|
|
32
|
+
'#C271B4',
|
|
33
|
+
'#F0AB3D',
|
|
34
|
+
// '#FFFFFF',
|
|
35
|
+
] }) }));
|
|
36
|
+
};
|
|
37
|
+
BoringAvatar.defaultProps = {
|
|
38
|
+
displayName: '',
|
|
39
|
+
variant: RANDOM_BORING_AVATOR_VARIANT,
|
|
40
|
+
size: 40,
|
|
41
|
+
square: false,
|
|
42
|
+
style: undefined,
|
|
43
|
+
};
|
|
44
|
+
export default BoringAvatar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: {
|
|
5
|
+
(props: {
|
|
6
|
+
displayName: string;
|
|
7
|
+
variant: "marble" | "beam" | "pixel" | "sunset" | "ring" | "bauhaus" | undefined;
|
|
8
|
+
size: number;
|
|
9
|
+
square: boolean;
|
|
10
|
+
style: object;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
defaultProps: {
|
|
13
|
+
displayName: string;
|
|
14
|
+
variant: "marble" | "beam" | "pixel" | "sunset" | "ring" | "bauhaus" | undefined;
|
|
15
|
+
size: number;
|
|
16
|
+
square: boolean;
|
|
17
|
+
style: undefined;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
tags: string[];
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
export declare const SimpleAvatar: Story;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { BoringAvatar } from './BoringAvatar';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Datalayer/BoringAvatar',
|
|
8
|
+
component: BoringAvatar,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'fullscreen',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
export const SimpleAvatar = {
|
|
16
|
+
args: {
|
|
17
|
+
displayName: 'Jane Doe',
|
|
18
|
+
variant: 'bauhaus',
|
|
19
|
+
size: 40,
|
|
20
|
+
square: false,
|
|
21
|
+
style: {},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IUser } from '../../models';
|
|
2
|
+
type IUserProfileAvatarProps = {
|
|
3
|
+
user?: IUser;
|
|
4
|
+
size?: number;
|
|
5
|
+
onClick?: React.MouseEventHandler<any>;
|
|
6
|
+
};
|
|
7
|
+
export declare const UserProfileAvatar: {
|
|
8
|
+
(props: IUserProfileAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
defaultProps: {
|
|
10
|
+
size: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default UserProfileAvatar;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { Avatar, Link } from '@primer/react';
|
|
7
|
+
import { Box } from "@datalayer/primer-addons";
|
|
8
|
+
import { AvatarSkeleton } from '../../components/display';
|
|
9
|
+
import { getAvatarURL } from '../../utils';
|
|
10
|
+
const Profile = (props) => {
|
|
11
|
+
const { user, size, onClick } = props;
|
|
12
|
+
return (_jsx(Box, { style: { width: size }, children: _jsx(Avatar
|
|
13
|
+
// square
|
|
14
|
+
, {
|
|
15
|
+
// square
|
|
16
|
+
src: getAvatarURL(user?.avatarUrl), size: size, onClick: onClick }) }));
|
|
17
|
+
};
|
|
18
|
+
export const UserProfileAvatar = (props) => {
|
|
19
|
+
const { onClick, user, size } = props;
|
|
20
|
+
return (user ?
|
|
21
|
+
onClick
|
|
22
|
+
?
|
|
23
|
+
_jsx(Link, { href: "javascript: return false;", onClick: onClick, children: _jsx(Profile, { ...props }) })
|
|
24
|
+
:
|
|
25
|
+
_jsx(Profile, { ...props })
|
|
26
|
+
:
|
|
27
|
+
_jsx(AvatarSkeleton, { size: size }));
|
|
28
|
+
};
|
|
29
|
+
UserProfileAvatar.defaultProps = {
|
|
30
|
+
size: 100,
|
|
31
|
+
};
|
|
32
|
+
export default UserProfileAvatar;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { Link } from "@primer/react";
|
|
7
|
+
import { Banner } from "@primer/react/experimental";
|
|
8
|
+
import { useNavigate } from "../../hooks";
|
|
9
|
+
export const NoAutomationBanner = () => {
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
return (_jsx(_Fragment, { children: _jsx(Banner, { title: "Warning", description: _jsxs(_Fragment, { children: ["We don't have bandwidth to automate this feature. ", _jsx(Link, { href: "", onClick: e => navigate('/contact', e), children: "Please reach out" }), " to prioritize this."] }), primaryAction: _jsx(Banner.PrimaryAction, { onClick: e => navigate('/contact', e), children: "Reach out" }), variant: "warning" }) }));
|
|
12
|
+
};
|
|
13
|
+
export default NoAutomationBanner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NoAutomationBanner';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VariantType } from './VariantType';
|
|
2
|
+
type IDownloadCSVButtonProps = {
|
|
3
|
+
data?: object;
|
|
4
|
+
fileName: string;
|
|
5
|
+
variant: VariantType;
|
|
6
|
+
};
|
|
7
|
+
export declare const DownloadCSVButton: {
|
|
8
|
+
(props: IDownloadCSVButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
defaultProps: {
|
|
10
|
+
variant: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default DownloadCSVButton;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { Button } from '@primer/react';
|
|
7
|
+
import { DownloadIcon } from '@primer/octicons-react';
|
|
8
|
+
import { downloadCSV } from '../../utils';
|
|
9
|
+
export const DownloadCSVButton = (props) => {
|
|
10
|
+
const { data, fileName, variant } = props;
|
|
11
|
+
return (_jsx(Button, { variant: variant, leadingVisual: DownloadIcon, onClick: e => downloadCSV(data, fileName), children: "Download" }));
|
|
12
|
+
};
|
|
13
|
+
DownloadCSVButton.defaultProps = {
|
|
14
|
+
variant: "default",
|
|
15
|
+
};
|
|
16
|
+
export default DownloadCSVButton;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VariantType } from './VariantType';
|
|
2
|
+
type IDownloadJsonButtonProps = {
|
|
3
|
+
data?: object;
|
|
4
|
+
fileName: string;
|
|
5
|
+
extension: string;
|
|
6
|
+
variant: VariantType;
|
|
7
|
+
};
|
|
8
|
+
export declare const DownloadJsonButton: {
|
|
9
|
+
(props: IDownloadJsonButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
defaultProps: {
|
|
11
|
+
variant: string;
|
|
12
|
+
name: string;
|
|
13
|
+
extension: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default DownloadJsonButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { Button } from '@primer/react';
|
|
7
|
+
import { DownloadIcon } from '@primer/octicons-react';
|
|
8
|
+
import { downloadJson } from '../../utils';
|
|
9
|
+
export const DownloadJsonButton = (props) => {
|
|
10
|
+
const { data, fileName, variant, extension } = props;
|
|
11
|
+
return (_jsx(Button, { variant: variant, leadingVisual: DownloadIcon, onClick: e => downloadJson(data, fileName, extension), children: "Download" }));
|
|
12
|
+
};
|
|
13
|
+
DownloadJsonButton.defaultProps = {
|
|
14
|
+
variant: 'default',
|
|
15
|
+
name: 'data',
|
|
16
|
+
extension: 'json',
|
|
17
|
+
};
|
|
18
|
+
export default DownloadJsonButton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ElementType } from 'react';
|
|
2
|
+
type ILongActionButtonProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Button onClick callback
|
|
5
|
+
*/
|
|
6
|
+
onClick: () => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Button icon
|
|
9
|
+
*/
|
|
10
|
+
icon: ElementType<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Force displaying button as inProgress
|
|
13
|
+
*/
|
|
14
|
+
inProgress?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Button label
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* Button disabled state
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Icon button displaying a spinner while its callback is running.
|
|
26
|
+
*/
|
|
27
|
+
export declare function LongActionButton(props: ILongActionButtonProps): JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useState } from 'react';
|
|
7
|
+
import { IconButton, Spinner } from '@primer/react';
|
|
8
|
+
/**
|
|
9
|
+
* Icon button displaying a spinner while its callback is running.
|
|
10
|
+
*/
|
|
11
|
+
export function LongActionButton(props) {
|
|
12
|
+
const { label, disabled, onClick, icon, inProgress } = props;
|
|
13
|
+
const [internalInProgress, setInternalInProgress] = useState(false);
|
|
14
|
+
const handleClick = useCallback(async () => {
|
|
15
|
+
setInternalInProgress(true);
|
|
16
|
+
try {
|
|
17
|
+
await onClick();
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
setInternalInProgress(false);
|
|
21
|
+
}
|
|
22
|
+
}, [onClick, setInternalInProgress]);
|
|
23
|
+
return (_jsx(IconButton, { "aria-label": label, title: label, disabled: disabled || internalInProgress || inProgress, icon: internalInProgress || inProgress ? () => _jsx(Spinner, { size: "small" }) : icon, size: "small", variant: "invisible", onClick: handleClick }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { VariantType } from './VariantType';
|
|
2
|
+
interface IUploadBaseButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* Button component factory
|
|
5
|
+
*/
|
|
6
|
+
buttonFactory: (onClick: () => void) => JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the upload support one or more files
|
|
9
|
+
*/
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Upload callback
|
|
13
|
+
*/
|
|
14
|
+
upload: (file: File) => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface IUploadIconButtonProps extends Omit<IUploadBaseButtonProps, 'buttonFactory'> {
|
|
17
|
+
/**
|
|
18
|
+
* Button aria-label
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function UploadIconButton(props: IUploadIconButtonProps): JSX.Element;
|
|
23
|
+
export interface IUploadButtonProps extends Omit<IUploadBaseButtonProps, 'buttonFactory'> {
|
|
24
|
+
/**
|
|
25
|
+
* Button aria-label
|
|
26
|
+
*/
|
|
27
|
+
label: string;
|
|
28
|
+
/**
|
|
29
|
+
* Button variant
|
|
30
|
+
*/
|
|
31
|
+
variant?: VariantType;
|
|
32
|
+
}
|
|
33
|
+
export declare function UploadButton(props: IUploadButtonProps): JSX.Element;
|
|
34
|
+
export declare namespace UploadButton {
|
|
35
|
+
var defaultProps: Partial<IUploadButtonProps>;
|
|
36
|
+
}
|
|
37
|
+
export default UploadButton;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
7
|
+
import { Button, IconButton } from '@primer/react';
|
|
8
|
+
import { UploadIcon } from '@primer/octicons-react';
|
|
9
|
+
function UploadBaseButton(props) {
|
|
10
|
+
const { buttonFactory, multiple, upload } = props;
|
|
11
|
+
const inputRef = useRef(null);
|
|
12
|
+
const onInputChanged = useCallback(() => {
|
|
13
|
+
if (inputRef.current && inputRef.current.files) {
|
|
14
|
+
const files = Array.from(inputRef.current.files);
|
|
15
|
+
Promise.all(files.map(file => upload(file))).catch(reason => {
|
|
16
|
+
const msg = 'Failed to upload files.';
|
|
17
|
+
console.error(msg, reason);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}, [inputRef.current, upload]);
|
|
21
|
+
const onInputClick = useCallback(() => {
|
|
22
|
+
if (inputRef.current) {
|
|
23
|
+
inputRef.current.value = '';
|
|
24
|
+
}
|
|
25
|
+
}, [inputRef.current]);
|
|
26
|
+
return (_jsxs(_Fragment, { children: [buttonFactory(() => {
|
|
27
|
+
inputRef.current?.click();
|
|
28
|
+
}), _jsx("input", { ref: inputRef, style: { display: 'none' }, type: "file", multiple: multiple, onClick: onInputClick, onChange: onInputChanged })] }));
|
|
29
|
+
}
|
|
30
|
+
export function UploadIconButton(props) {
|
|
31
|
+
const { label, ...others } = props;
|
|
32
|
+
const factory = useMemo(() => (onClick) => (_jsx(IconButton, { "aria-label": label, icon: UploadIcon, size: "small", variant: "invisible", onClick: onClick })), []);
|
|
33
|
+
return _jsx(UploadBaseButton, { buttonFactory: factory, ...others });
|
|
34
|
+
}
|
|
35
|
+
export function UploadButton(props) {
|
|
36
|
+
const { label, variant, ...others } = props;
|
|
37
|
+
const factory = useMemo(() => (onClick) => (_jsx(Button, { "aria-label": label, leadingVisual: () => _jsx(UploadIcon, { fill: "white" }), size: "small", variant: variant, onClick: onClick, children: label })), []);
|
|
38
|
+
return _jsx(UploadBaseButton, { buttonFactory: factory, ...others });
|
|
39
|
+
}
|
|
40
|
+
UploadButton.defaultProps = {
|
|
41
|
+
variant: "primary",
|
|
42
|
+
};
|
|
43
|
+
export default UploadButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'link';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
export * from './DownloadCSVButton';
|
|
6
|
+
export * from './DownloadJsonButton';
|
|
7
|
+
export * from './LongActionButton';
|
|
8
|
+
export * from './UploadButton';
|
|
9
|
+
export * from './VariantType';
|