@datalayer/core 0.0.2 → 0.0.4
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 +124 -2
- package/lib/App.css +47 -0
- package/lib/App.js +14 -2
- package/lib/__tests__/index.test.js +7 -6
- package/lib/api/{RunApi.d.ts → DatalayerApi.d.ts} +4 -4
- package/lib/api/{RunApi.js → DatalayerApi.js} +6 -11
- package/lib/api/index.d.ts +3 -2
- package/lib/api/index.js +3 -7
- package/lib/api/{runtimes → jupyter}/exec/Python.js +0 -5
- package/lib/api/{runtimes → jupyter}/exec/Snippets.js +0 -5
- package/lib/api/{runtimes → jupyter}/exec/index.js +0 -5
- package/lib/api/jupyter/index.d.ts +2 -0
- package/lib/api/jupyter/index.js +6 -0
- package/lib/api/{runtimes → jupyter}/kernelsHandler.d.ts +1 -1
- package/lib/api/{runtimes → jupyter}/kernelsHandler.js +1 -6
- package/lib/api/runtimes/actions.d.ts +102 -0
- package/lib/api/runtimes/{runtimesApi.js → actions.js} +47 -53
- package/lib/api/runtimes/{runtimesApi.d.ts → apis.d.ts} +8 -105
- package/lib/api/runtimes/apis.js +5 -0
- package/lib/api/runtimes/index.d.ts +2 -4
- package/lib/api/runtimes/index.js +2 -9
- package/lib/api/runtimes/settings.js +3 -8
- package/lib/api/runtimes/snapshots.d.ts +1 -1
- package/lib/api/runtimes/snapshots.js +8 -13
- package/lib/api/runtimes/utils.js +1 -9
- package/lib/assets/react.svg +1 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +9 -0
- package/lib/collaboration/DatalayerCollaboration.js +28 -0
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +54 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +162 -0
- package/lib/collaboration/index.d.ts +2 -0
- package/lib/collaboration/index.js +6 -0
- package/lib/components/avatars/BoringAvatar.d.ts +2 -3
- package/lib/components/avatars/BoringAvatar.js +14 -9
- package/lib/components/avatars/BoringAvatar.stories.d.ts +27 -0
- package/lib/components/avatars/BoringAvatar.stories.js +23 -0
- package/lib/components/avatars/UserProfileAvatar.js +2 -14
- package/lib/components/avatars/index.js +0 -5
- package/lib/components/banners/NoAutomationBanner.js +4 -9
- package/lib/components/banners/index.js +0 -5
- package/lib/components/buttons/DownloadCSVButton.d.ts +1 -1
- package/lib/components/buttons/DownloadCSVButton.js +1 -6
- package/lib/components/buttons/DownloadJsonButton.d.ts +1 -1
- package/lib/components/buttons/DownloadJsonButton.js +0 -5
- package/lib/components/buttons/LongActionButton.js +0 -5
- package/lib/components/buttons/UploadButton.js +1 -6
- package/lib/components/buttons/index.js +0 -5
- package/lib/components/checkout/StripeCheckout.d.ts +1 -1
- package/lib/components/checkout/StripeCheckout.js +6 -11
- package/lib/components/checkout/index.js +0 -5
- package/lib/components/confetti/ConfettiSuccess.js +1 -6
- package/lib/components/confetti/index.js +0 -5
- package/lib/components/context/OrganizationSelect.js +5 -10
- package/lib/components/context/SpaceSelect.js +7 -12
- package/lib/components/context/index.js +0 -5
- package/lib/components/display/AvatarSkeleton.js +1 -6
- package/lib/components/display/CenteredSpinner.js +4 -9
- package/lib/components/display/CodePreview.js +4 -9
- package/lib/components/display/DatalayerBox.js +13 -19
- package/lib/components/display/HorizontalCenter.d.ts +1 -1
- package/lib/components/display/HorizontalCenter.js +1 -1
- package/lib/components/display/JupyterDialog.js +17 -20
- package/lib/components/display/NavLink.d.ts +4 -2
- package/lib/components/display/NavLink.js +6 -9
- package/lib/components/display/NotebookSkeleton.js +2 -7
- package/lib/components/display/Placeholder.js +1 -6
- package/lib/components/display/ToTopBranded.js +1 -6
- package/lib/components/display/VisuallyHidden.js +0 -5
- package/lib/components/display/index.js +0 -5
- package/lib/components/echarts/EChartsReact.d.ts +1 -1
- package/lib/components/echarts/EChartsReact.js +7 -7
- package/lib/components/echarts/index.js +0 -5
- package/lib/components/flashes/FlashClosable.js +11 -16
- package/lib/components/flashes/FlashDisclaimer.js +2 -8
- package/lib/components/flashes/FlashGuest.js +3 -9
- package/lib/components/flashes/FlashSurveys.js +3 -9
- package/lib/components/flashes/FlashUnauthorized.js +2 -7
- package/lib/components/flashes/index.js +0 -5
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
- package/lib/components/flashes/surveys/Survey2025_1.js +62 -90
- package/lib/components/flashes/surveys/index.js +0 -5
- package/lib/components/iam/ExternalTokenSilentLogin.js +6 -9
- package/lib/components/iam/index.js +0 -5
- package/lib/components/icons/ArtifactIcon.d.ts +2 -2
- package/lib/components/icons/ArtifactIcon.js +39 -44
- package/lib/components/icons/index.js +0 -5
- package/lib/components/index.js +1 -6
- package/lib/components/labels/VisibilityLabel.js +2 -10
- package/lib/components/labels/index.js +0 -5
- package/lib/components/landings/StepBlock.d.ts +1 -1
- package/lib/components/landings/StepBlock.js +1 -6
- package/lib/components/landings/index.js +0 -5
- package/lib/components/navbar/NavigationVisbilityObserver.js +2 -7
- package/lib/components/navbar/SubdomainNavBar.js +46 -29
- package/lib/components/navbar/SubdomainNavBar.module.css +737 -0
- package/lib/components/navbar/index.js +0 -5
- package/lib/components/nbgrader/NbGradesDetails.d.ts +1 -1
- package/lib/components/nbgrader/NbGradesDetails.js +5 -13
- package/lib/components/nbgrader/index.js +0 -5
- package/lib/components/notebooks/JupyterNotebook.js +5 -10
- package/lib/components/notebooks/JupyterNotebookToolbar.js +3 -8
- package/lib/components/notebooks/index.js +0 -5
- package/lib/components/primer/Helper.d.ts +1 -1
- package/lib/components/primer/Helper.js +5 -3
- package/lib/components/primer/Portals.d.ts +1 -1
- package/lib/components/primer/Portals.js +2 -7
- package/lib/components/primer/Styles.js +1 -6
- package/lib/components/primer/index.js +0 -5
- package/lib/components/progress/ConsumptionBar.js +2 -7
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/progress/CreditsIndicator.js +4 -13
- package/lib/components/progress/ProgressBar.js +0 -5
- package/lib/components/progress/ProgressRing.js +2 -2
- package/lib/components/progress/Timer.js +0 -5
- package/lib/components/progress/index.js +0 -5
- package/lib/components/runtimes/RuntimeCellVariables.js +9 -14
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +7 -12
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -2
- package/lib/components/runtimes/RuntimeLauncherDialog.js +32 -40
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +42 -36
- package/lib/components/runtimes/RuntimePickerCell.js +9 -17
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -2
- package/lib/components/runtimes/RuntimePickerNotebook.js +45 -50
- package/lib/components/runtimes/RuntimeReservationControl.js +10 -20
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.js +44 -52
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.js +22 -17
- package/lib/components/runtimes/RuntimeVariables.js +7 -12
- package/lib/components/runtimes/index.js +0 -5
- package/lib/components/screenshot/ScreenCapture.js +10 -19
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +1 -1
- package/lib/components/screenshot/ScreenCaptureButton.js +14 -8
- package/lib/components/screenshot/index.js +0 -5
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +19 -22
- package/lib/components/snapshots/index.js +0 -5
- package/lib/components/snippets/SnippetDialog.js +5 -10
- package/lib/components/snippets/index.js +0 -5
- package/lib/components/storage/ContentsBrowser.js +75 -63
- package/lib/components/storage/ContentsItems.js +10 -13
- package/lib/components/storage/index.js +0 -5
- package/lib/components/students/StudentItemStatus.d.ts +1 -1
- package/lib/components/students/StudentItemStatus.js +38 -21
- package/lib/components/students/index.js +0 -5
- package/lib/components/subnav/SubNav.d.ts +3 -3
- package/lib/components/subnav/SubNav.js +34 -24
- package/lib/components/subnav/SubNav.module.css +717 -0
- package/lib/components/subnav/index.js +0 -5
- package/lib/components/tables/DataTable.js +1 -9
- package/lib/components/tables/index.js +0 -5
- package/lib/components/text-reveal/TextRevealAnimation.js +7 -8
- package/lib/components/text-reveal/TextRevealAnimation.module.css +45 -0
- package/lib/components/text-reveal/index.js +0 -5
- package/lib/components/text-reveal/useTextRevealAnimationLines.js +0 -5
- package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
- package/lib/components/tokens/SpaceVariantToken.js +5 -10
- package/lib/components/tokens/index.js +0 -5
- package/lib/components/toolbars/AssignmentEditorToolbar.js +1 -8
- package/lib/components/toolbars/DocumentEditorToolbar.js +0 -5
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +1 -1
- package/lib/components/toolbars/NotebookEditorToolbar.js +0 -5
- package/lib/components/toolbars/index.js +0 -5
- package/lib/components/users/PeerIndicator.d.ts +1 -1
- package/lib/components/users/PeerIndicator.js +5 -10
- package/lib/components/users/index.js +0 -5
- package/lib/config/Configuration.d.ts +48 -0
- package/lib/config/Configuration.js +42 -5
- package/lib/config/index.js +0 -5
- package/lib/config/integrations/Loom.js +3 -8
- package/lib/config/integrations/index.js +0 -5
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +55 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +75 -0
- package/lib/examples/NativeNavigationExample.d.ts +8 -0
- package/lib/examples/NativeNavigationExample.js +97 -0
- package/lib/examples/NotebookExample.d.ts +6 -0
- package/lib/examples/NotebookExample.js +24 -0
- package/lib/examples/NotebookMutationsKernel.d.ts +2 -0
- package/lib/examples/NotebookMutationsKernel.js +115 -0
- package/lib/examples/NotebookMutationsServiceManager.d.ts +2 -0
- package/lib/examples/NotebookMutationsServiceManager.js +107 -0
- package/lib/examples/ReactRouterExample.d.ts +6 -0
- package/lib/examples/ReactRouterExample.js +175 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +45 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +6 -0
- package/lib/examples/main.js +153 -0
- package/lib/examples/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/notebooks/Lite.ipynb.json +128 -0
- package/lib/examples/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +10 -10
- package/lib/hooks/assets/OutputshotPlaceholders.js +9 -14
- package/lib/hooks/assets/index.js +0 -5
- package/lib/hooks/index.d.ts +29 -28
- package/lib/hooks/index.js +29 -33
- package/lib/hooks/layouts/LayoutBackdrop.js +3 -11
- package/lib/hooks/layouts/LayoutScreenshot.css +58 -0
- package/lib/hooks/layouts/LayoutScreenshot.d.ts +1 -0
- package/lib/hooks/layouts/LayoutScreenshot.js +7 -11
- package/lib/hooks/layouts/index.js +0 -5
- package/lib/hooks/useAIAgents.d.ts +1 -1
- package/lib/hooks/useAIAgents.js +13 -18
- package/lib/hooks/useAuthorization.js +4 -10
- package/lib/hooks/useBackdrop.js +7 -12
- package/lib/hooks/useBackdropJupyterLab.d.ts +1 -1
- package/lib/hooks/useBackdropJupyterLab.js +4 -9
- package/lib/hooks/useCache.d.ts +8 -4
- package/lib/hooks/useCache.js +410 -361
- package/lib/hooks/useCellOutputshot.js +3 -11
- package/lib/hooks/useContainsFocus.js +2 -6
- package/lib/hooks/useDatalayer.d.ts +21 -0
- package/lib/hooks/{useRun.js → useDatalayer.js} +16 -18
- package/lib/hooks/useError.d.ts +1 -1
- package/lib/hooks/useError.js +2 -7
- package/lib/hooks/useExternalScript.js +4 -9
- package/lib/hooks/useFocusTrap.d.ts +1 -1
- package/lib/hooks/useFocusTrap.js +3 -7
- package/lib/hooks/useIAM.js +6 -12
- package/lib/hooks/useId.js +6 -11
- package/lib/hooks/useIsomorphicLayoutEffect.js +0 -5
- package/lib/hooks/useJupyterLabTheme.js +3 -6
- package/lib/hooks/useKeyboardEscape.js +0 -5
- package/lib/hooks/useLocation.d.ts +22 -0
- package/lib/hooks/useLocation.js +149 -0
- package/lib/hooks/useLocationHandles.d.ts +2 -2
- package/lib/hooks/useLocationHandles.js +6 -9
- package/lib/hooks/useNavigate.d.ts +5 -1
- package/lib/hooks/useNavigate.js +62 -12
- package/lib/hooks/useNotebookAIAgent.js +3 -6
- package/lib/hooks/useOnClickOutside.js +0 -5
- package/lib/hooks/useParams.d.ts +5 -0
- package/lib/hooks/useParams.js +152 -0
- package/lib/hooks/useRef.js +0 -5
- package/lib/hooks/useRuntimes.js +2 -7
- package/lib/hooks/useScreenshot.js +5 -10
- package/lib/hooks/useToast.js +21 -21
- package/lib/hooks/useUpload.js +9 -14
- package/lib/hooks/useUser.js +1 -1
- package/lib/hooks/useVisibilityObserver.js +0 -5
- package/lib/hooks/useWindowSize.js +0 -6
- package/lib/i18n/Labels.js +0 -5
- package/lib/i18n/index.js +0 -5
- package/lib/index.css +73 -0
- package/lib/index.d.ts +6 -3
- package/lib/index.js +7 -3
- package/lib/main.js +1 -2
- package/lib/mocks/components/FlashMock.js +4 -9
- package/lib/mocks/components/index.js +0 -5
- package/lib/mocks/hooks/index.d.ts +1 -1
- package/lib/mocks/hooks/index.js +1 -6
- package/lib/mocks/hooks/rests/index.js +0 -5
- package/lib/mocks/hooks/rests/rests.js +15 -23
- package/lib/mocks/hooks/useDatalayerMock.d.ts +6 -0
- package/lib/mocks/hooks/{useRunMock.js → useDatalayerMock.js} +9 -14
- package/lib/mocks/index.js +0 -5
- package/lib/mocks/jupyter/index.js +1 -6
- package/lib/mocks/models/CodeBlockMock.js +1 -6
- package/lib/mocks/models/CodelineMock.js +1 -6
- package/lib/mocks/models/CourseMock.d.ts +1 -1
- package/lib/mocks/models/CourseMock.js +10 -15
- package/lib/mocks/models/InviteMock.d.ts +1 -1
- package/lib/mocks/models/InviteMock.js +21 -11
- package/lib/mocks/models/JupyterLabUserMock.js +2 -2
- package/lib/mocks/models/OrganisationMock.d.ts +1 -1
- package/lib/mocks/models/OrganisationMock.js +11 -7
- package/lib/mocks/models/SchoolMock.d.ts +1 -1
- package/lib/mocks/models/SchoolMock.js +6 -6
- package/lib/mocks/models/SpaceMock.d.ts +1 -1
- package/lib/mocks/models/SpaceMock.js +9 -14
- package/lib/mocks/models/TeamMock.d.ts +1 -1
- package/lib/mocks/models/TeamMock.js +6 -6
- package/lib/mocks/models/UserMock.d.ts +1 -1
- package/lib/mocks/models/UserMock.js +4 -11
- package/lib/mocks/models/index.js +0 -5
- package/lib/mocks/views/ActionMenuMock.js +1 -6
- package/lib/mocks/views/ChartMock.js +3 -8
- package/lib/mocks/views/ChartMockOptions.js +24 -29
- package/lib/mocks/views/DashboardMock.js +74 -79
- package/lib/mocks/views/FormMock.js +1 -6
- package/lib/mocks/views/TableMock.js +1 -6
- package/lib/mocks/views/WipMock.js +0 -5
- package/lib/mocks/views/index.js +0 -5
- package/lib/models/Account.d.ts +2 -2
- package/lib/models/Assignment.d.ts +2 -2
- package/lib/models/Cell.d.ts +1 -1
- package/lib/models/CodeBlock.d.ts +1 -1
- package/lib/models/CodefeedBlocks.d.ts +2 -2
- package/lib/models/Contact.d.ts +1 -1
- package/lib/models/Contact.js +14 -19
- package/lib/models/ContactEvent.js +0 -5
- package/lib/models/ContactIAMProvider.js +2 -2
- package/lib/models/Course.d.ts +7 -7
- package/lib/models/Credits.js +0 -5
- package/lib/models/Dataset.d.ts +2 -2
- package/lib/models/Datasource.js +0 -5
- package/lib/models/Dean.d.ts +1 -1
- package/lib/models/Document.d.ts +1 -1
- package/lib/models/Environment.d.ts +2 -2
- package/lib/models/Errors.js +0 -5
- package/lib/models/Exercise.d.ts +1 -1
- package/lib/models/GrowthKPI.js +0 -5
- package/lib/models/IAMProviderLinked.js +1 -1
- package/lib/models/IAMProviderUsers.js +0 -5
- package/lib/models/IAMToken.js +0 -5
- package/lib/models/Inbound.js +0 -5
- package/lib/models/Instructor.d.ts +1 -1
- package/lib/models/Invite.d.ts +2 -2
- package/lib/models/Invite.js +1 -1
- package/lib/models/Item.d.ts +5 -5
- package/lib/models/LandingRoles.js +18 -23
- package/lib/models/Lesson.d.ts +1 -1
- package/lib/models/Member.d.ts +1 -1
- package/lib/models/Notebook.d.ts +1 -1
- package/lib/models/Organization.d.ts +4 -4
- package/lib/models/Organization.js +2 -7
- package/lib/models/OrganizationMember.d.ts +2 -2
- package/lib/models/Outbound.js +7 -12
- package/lib/models/Page.js +4 -2
- package/lib/models/PageTag.d.ts +2 -2
- package/lib/models/PageTag.js +56 -9
- package/lib/models/Profile.d.ts +1 -1
- package/lib/models/RolesOrganization.d.ts +1 -1
- package/lib/models/RolesOrganization.js +4 -17
- package/lib/models/RolesPlatform.d.ts +1 -1
- package/lib/models/RolesPlatform.js +12 -39
- package/lib/models/RolesTeam.d.ts +1 -1
- package/lib/models/RolesTeam.js +3 -15
- package/lib/models/Runtime.d.ts +59 -1
- package/lib/models/Runtime.js +11 -9
- package/lib/models/RuntimeSnapshot.js +1 -1
- package/lib/models/School.d.ts +4 -4
- package/lib/models/Secret.js +0 -5
- package/lib/models/Space.d.ts +5 -5
- package/lib/models/Space.js +3 -3
- package/lib/models/SpaceItem.d.ts +8 -8
- package/lib/models/SpaceMember.d.ts +2 -2
- package/lib/models/Student.d.ts +2 -2
- package/lib/models/StudentItem.d.ts +3 -3
- package/lib/models/Survey.js +0 -5
- package/lib/models/Team.d.ts +3 -3
- package/lib/models/Team.js +2 -7
- package/lib/models/TeamMember.d.ts +2 -2
- package/lib/models/URN.js +1 -6
- package/lib/models/User.d.ts +2 -2
- package/lib/models/User.js +7 -10
- package/lib/models/UserEvent.js +0 -5
- package/lib/models/UserOnboarding.d.ts +1 -1
- package/lib/models/UserOnboarding.js +7 -12
- package/lib/models/UserSettings.js +2 -7
- package/lib/models/index.d.ts +2 -2
- package/lib/models/index.js +2 -7
- package/lib/navigation/adapters/native.d.ts +11 -0
- package/lib/navigation/adapters/native.js +48 -0
- package/lib/navigation/adapters/nextjs.d.ts +9 -0
- package/lib/navigation/adapters/nextjs.js +35 -0
- package/lib/navigation/adapters/react-router.d.ts +4 -0
- package/lib/navigation/adapters/react-router.js +12 -0
- package/lib/navigation/components.d.ts +20 -0
- package/lib/navigation/components.js +36 -0
- package/lib/navigation/index.d.ts +4 -0
- package/lib/navigation/index.js +12 -0
- package/lib/routes/Routes.js +0 -5
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/index.js +1 -6
- package/lib/services/DatalayerServiceManager.d.ts +22 -0
- package/lib/services/DatalayerServiceManager.js +79 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +7 -0
- package/lib/services/reconnectToRuntime.d.ts +32 -0
- package/lib/services/reconnectToRuntime.js +59 -0
- package/lib/state/State.d.ts +1 -1
- package/lib/state/State.js +1 -6
- package/lib/state/index.d.ts +1 -1
- package/lib/state/index.js +1 -6
- package/lib/state/storage/IAMStorage.js +14 -7
- package/lib/state/storage/index.d.ts +1 -1
- package/lib/state/storage/index.js +1 -6
- package/lib/state/substates/AIAgentState.js +4 -7
- package/lib/state/substates/CellState.js +6 -10
- package/lib/state/substates/CoreState.d.ts +1 -1
- package/lib/state/substates/CoreState.js +23 -20
- package/lib/state/substates/DatasourceState.js +1 -6
- package/lib/state/substates/DocumentState.js +0 -5
- package/lib/state/substates/GradeState.js +0 -5
- package/lib/state/substates/IAMState.d.ts +5 -1
- package/lib/state/substates/IAMState.js +88 -72
- package/lib/state/substates/JupyterLabState.js +1 -6
- package/lib/state/substates/LayoutState.d.ts +2 -2
- package/lib/state/substates/LayoutState.js +41 -28
- package/lib/state/substates/NbformatState.js +0 -5
- package/lib/state/substates/OrganizationState.js +1 -6
- package/lib/state/substates/RuntimesState.d.ts +2 -2
- package/lib/state/substates/RuntimesState.js +6 -10
- package/lib/state/substates/SpaceState.js +1 -6
- package/lib/state/substates/SurveysState.js +7 -12
- package/lib/state/substates/TeamState.js +1 -6
- package/lib/state/substates/index.js +0 -5
- 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.js +73 -1
- package/lib/theme/DatalayerTheme.js +1 -6
- package/lib/theme/DatalayerThemeProvider.js +17 -19
- package/lib/theme/Palette.js +1 -6
- package/lib/theme/index.js +0 -5
- package/lib/utils/Array.js +0 -5
- package/lib/utils/Avatar.js +2 -7
- package/lib/utils/Browser.js +6 -11
- package/lib/utils/Cells.d.ts +1 -1
- package/lib/utils/Cookie.js +1 -6
- package/lib/utils/Date.js +5 -10
- package/lib/utils/Download.js +5 -8
- package/lib/utils/DownloadFile.js +4 -7
- package/lib/utils/Env.js +2 -6
- package/lib/utils/File.js +0 -5
- package/lib/utils/Ids.js +0 -5
- package/lib/utils/Jupyter.js +0 -5
- package/lib/utils/Lazy.d.ts +1 -1
- package/lib/utils/Lazy.js +2 -8
- package/lib/utils/Name.js +10 -13
- package/lib/utils/Notebook.d.ts +1 -1
- package/lib/utils/Notebook.js +3 -3
- package/lib/utils/Number.js +13 -14
- package/lib/utils/Plots.d.ts +1 -1
- package/lib/utils/Plots.js +5 -5
- package/lib/utils/Random.js +0 -5
- package/lib/utils/Screenshot.js +1 -6
- package/lib/utils/Scroll.js +3 -7
- package/lib/utils/Sleep.js +1 -6
- package/lib/utils/Snapshot.js +2 -7
- package/lib/utils/String.js +2 -7
- package/lib/utils/Uri.js +2 -7
- package/lib/utils/Validator.js +0 -5
- package/lib/utils/WithSuspense.js +3 -11
- package/lib/utils/index.js +0 -5
- package/package.json +96 -30
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +64 -0
- package/style/index.css +6 -0
- package/lib/__tests__/App.test.js +0 -17
- package/lib/api/runtimes/models.d.ts +0 -59
- package/lib/api/runtimes/models.js +0 -11
- package/lib/hooks/useRun.d.ts +0 -21
- package/lib/mocks/hooks/useRunMock.d.ts +0 -6
- /package/lib/api/{runtimes → jupyter}/exec/Python.d.ts +0 -0
- /package/lib/api/{runtimes → jupyter}/exec/Snippets.d.ts +0 -0
- /package/lib/api/{runtimes → jupyter}/exec/index.d.ts +0 -0
- /package/lib/{__tests__/App.test.d.ts → examples/main.d.ts} +0 -0
package/lib/hooks/useNavigate.js
CHANGED
|
@@ -2,19 +2,68 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
|
-
import { useNavigate as useRouterNavigate } from "react-router-dom";
|
|
5
|
+
import { useCallback } from 'react';
|
|
11
6
|
import { useLayoutStore } from '../state';
|
|
7
|
+
import { createNativeNavigate } from '../navigation/adapters/native';
|
|
8
|
+
// Import React Router hooks from our wrapper
|
|
9
|
+
import { useNavigateRR } from '../navigation/adapters/react-router';
|
|
10
|
+
// Import Next.js hooks from our wrapper
|
|
11
|
+
// Currently not used but kept for future Next.js support
|
|
12
|
+
// import { useRouterNext } from '../navigation/adapters/nextjs';
|
|
13
|
+
/**
|
|
14
|
+
* Main navigation hook that provides a universal navigate function
|
|
15
|
+
* Works with React Router, Next.js, or native browser navigation
|
|
16
|
+
*/
|
|
12
17
|
export const useNavigate = () => {
|
|
13
|
-
const routerNavigate = useRouterNavigate();
|
|
14
18
|
const layoutStore = useLayoutStore();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
// Detect environment
|
|
20
|
+
const isNextJs = typeof window !== 'undefined' && !!window.__NEXT_DATA__;
|
|
21
|
+
const isClient = typeof window !== 'undefined';
|
|
22
|
+
// Try to use React Router's useNavigate if available
|
|
23
|
+
let rrNavigate = null;
|
|
24
|
+
let isReactRouter = false;
|
|
25
|
+
if (!isNextJs && useNavigateRR && isClient) {
|
|
26
|
+
try {
|
|
27
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
28
|
+
rrNavigate = useNavigateRR();
|
|
29
|
+
isReactRouter = !!rrNavigate;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Not in a Router context
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// If React Router is available, return it directly (wrapped for consistency)
|
|
36
|
+
if (isReactRouter && rrNavigate) {
|
|
37
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
38
|
+
return useCallback((to, options) => {
|
|
39
|
+
// For React Router, just pass through directly without side effects
|
|
40
|
+
return rrNavigate(to, options);
|
|
41
|
+
}, [rrNavigate]);
|
|
42
|
+
}
|
|
43
|
+
// Otherwise use native navigation with our custom behavior
|
|
44
|
+
const baseNavigate = createNativeNavigate();
|
|
45
|
+
// Wrap with our custom behavior for native navigation
|
|
46
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
47
|
+
const navigate = useCallback((location, optionsOrEvent, resetPortals = true, extraOptions) => {
|
|
48
|
+
// Handle different call signatures for native navigation
|
|
49
|
+
let options = undefined;
|
|
50
|
+
let event = undefined;
|
|
51
|
+
if (optionsOrEvent && optionsOrEvent.preventDefault) {
|
|
52
|
+
// Legacy signature with event as second parameter
|
|
53
|
+
event = optionsOrEvent;
|
|
54
|
+
options = extraOptions;
|
|
55
|
+
}
|
|
56
|
+
else if (typeof optionsOrEvent === 'boolean') {
|
|
57
|
+
// Legacy signature with resetPortals as second parameter
|
|
58
|
+
resetPortals = optionsOrEvent;
|
|
59
|
+
options = extraOptions;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Standard signature with options as second parameter
|
|
63
|
+
options = optionsOrEvent;
|
|
64
|
+
}
|
|
65
|
+
if (event) {
|
|
66
|
+
event.preventDefault();
|
|
18
67
|
}
|
|
19
68
|
if (resetPortals) {
|
|
20
69
|
layoutStore.resetLeftPortal();
|
|
@@ -22,8 +71,9 @@ export const useNavigate = () => {
|
|
|
22
71
|
}
|
|
23
72
|
window.scrollTo(0, 0);
|
|
24
73
|
document.body.scrollTop = 0;
|
|
25
|
-
|
|
26
|
-
|
|
74
|
+
// Use native navigation
|
|
75
|
+
baseNavigate(location, options);
|
|
76
|
+
}, [baseNavigate, layoutStore]);
|
|
27
77
|
return navigate;
|
|
28
78
|
};
|
|
29
79
|
export default useNavigate;
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { useEffect } from 'react';
|
|
11
6
|
import { useAIAgentStore } from '../state';
|
|
12
7
|
import { useAIAgents } from './useAIAgents';
|
|
@@ -24,7 +19,9 @@ export function useNotebookAIAgent(notebookId) {
|
|
|
24
19
|
const refreshAIAgent = async () => {
|
|
25
20
|
abortController = new AbortController();
|
|
26
21
|
try {
|
|
27
|
-
const response = await getAIAgent(notebookId, {
|
|
22
|
+
const response = await getAIAgent(notebookId, {
|
|
23
|
+
signal: abortController.signal,
|
|
24
|
+
});
|
|
28
25
|
if (!response.success) {
|
|
29
26
|
deleteAIAgent(notebookId);
|
|
30
27
|
return;
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { useEffect } from 'react';
|
|
11
6
|
export function useOnClickOutside(ref, handler) {
|
|
12
7
|
useEffect(() => {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useState, useMemo } from 'react';
|
|
6
|
+
import { useParamsRR } from '../navigation/adapters/react-router';
|
|
7
|
+
import { useParamsNext, useSearchParamsNext, } from '../navigation/adapters/nextjs';
|
|
8
|
+
/**
|
|
9
|
+
* Hook to get URL parameters
|
|
10
|
+
* Works with Next.js App Router, React Router, or falls back to URL parsing
|
|
11
|
+
*/
|
|
12
|
+
export const useParams = () => {
|
|
13
|
+
// State for fallback URL search params
|
|
14
|
+
const [searchParams, setSearchParams] = useState({});
|
|
15
|
+
// Detect environment
|
|
16
|
+
const isNextJs = typeof window !== 'undefined' && !!window.__NEXT_DATA__;
|
|
17
|
+
const isClient = typeof window !== 'undefined';
|
|
18
|
+
// Try to get params from different sources
|
|
19
|
+
let routeParams = {};
|
|
20
|
+
const queryParams = {};
|
|
21
|
+
let paramsSource = 'fallback';
|
|
22
|
+
// 1. Try Next.js first (if detected)
|
|
23
|
+
if (isNextJs && useParamsNext) {
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
|
+
routeParams = useParamsNext() || {};
|
|
27
|
+
paramsSource = 'nextjs';
|
|
28
|
+
// Also get search params in Next.js
|
|
29
|
+
if (useSearchParamsNext) {
|
|
30
|
+
try {
|
|
31
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
32
|
+
const searchParamsObj = useSearchParamsNext();
|
|
33
|
+
if (searchParamsObj) {
|
|
34
|
+
searchParamsObj.forEach((value, key) => {
|
|
35
|
+
queryParams[key] = value;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Not in Next.js context or search params not available
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Not in Next.js router context
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// 2. Try React Router (if not Next.js)
|
|
49
|
+
if (paramsSource === 'fallback' && !isNextJs && useParamsRR) {
|
|
50
|
+
try {
|
|
51
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
52
|
+
routeParams = useParamsRR() || {};
|
|
53
|
+
paramsSource = 'react-router';
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Not in React Router context
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// 3. Get URL search params (for React Router and fallback)
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!isClient || paramsSource === 'nextjs')
|
|
62
|
+
return;
|
|
63
|
+
const updateSearchParams = () => {
|
|
64
|
+
const params = {};
|
|
65
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
66
|
+
urlParams.forEach((value, key) => {
|
|
67
|
+
params[key] = value;
|
|
68
|
+
});
|
|
69
|
+
setSearchParams(params);
|
|
70
|
+
};
|
|
71
|
+
updateSearchParams();
|
|
72
|
+
// Listen for URL changes
|
|
73
|
+
window.addEventListener('popstate', updateSearchParams);
|
|
74
|
+
window.addEventListener('pushstate', updateSearchParams);
|
|
75
|
+
window.addEventListener('replacestate', updateSearchParams);
|
|
76
|
+
return () => {
|
|
77
|
+
window.removeEventListener('popstate', updateSearchParams);
|
|
78
|
+
window.removeEventListener('pushstate', updateSearchParams);
|
|
79
|
+
window.removeEventListener('replacestate', updateSearchParams);
|
|
80
|
+
};
|
|
81
|
+
}, [isClient, paramsSource]);
|
|
82
|
+
// 4. For fallback, also try to parse route params from URL path
|
|
83
|
+
const fallbackRouteParams = useMemo(() => {
|
|
84
|
+
if (!isClient || paramsSource !== 'fallback')
|
|
85
|
+
return {};
|
|
86
|
+
const pathname = window.location.pathname;
|
|
87
|
+
const params = {};
|
|
88
|
+
// Common patterns to match
|
|
89
|
+
// /products/123 -> { id: '123' }
|
|
90
|
+
// /users/john-doe -> { username: 'john-doe' }
|
|
91
|
+
// /blog/2024/01/my-post -> { year: '2024', month: '01', slug: 'my-post' }
|
|
92
|
+
const patterns = [
|
|
93
|
+
{ regex: /^\/products\/([^/]+)$/, params: ['id'] },
|
|
94
|
+
{ regex: /^\/products\/([^/]+)\/reviews$/, params: ['id'] },
|
|
95
|
+
{ regex: /^\/users\/([^/]+)$/, params: ['username'] },
|
|
96
|
+
{
|
|
97
|
+
regex: /^\/blog\/(\d{4})\/(\d{2})\/([^/]+)$/,
|
|
98
|
+
params: ['year', 'month', 'slug'],
|
|
99
|
+
},
|
|
100
|
+
{ regex: /^\/posts\/([^/]+)$/, params: ['slug'] },
|
|
101
|
+
{ regex: /^\/([^/]+)\/([^/]+)$/, params: ['category', 'id'] },
|
|
102
|
+
];
|
|
103
|
+
for (const pattern of patterns) {
|
|
104
|
+
const match = pathname.match(pattern.regex);
|
|
105
|
+
if (match) {
|
|
106
|
+
pattern.params.forEach((paramName, index) => {
|
|
107
|
+
if (match[index + 1]) {
|
|
108
|
+
params[paramName] = match[index + 1];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return params;
|
|
115
|
+
}, [isClient, paramsSource, isClient ? window.location.pathname : '']);
|
|
116
|
+
// Combine all params with proper memoization to prevent re-renders
|
|
117
|
+
const combinedParams = useMemo(() => {
|
|
118
|
+
const result = {};
|
|
119
|
+
// Add route params
|
|
120
|
+
for (const [key, value] of Object.entries(routeParams)) {
|
|
121
|
+
if (value !== undefined) {
|
|
122
|
+
// Handle array values (Next.js catch-all routes)
|
|
123
|
+
result[key] = Array.isArray(value) ? value.join('/') : String(value);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Add query params (Next.js)
|
|
127
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
128
|
+
result[key] = value;
|
|
129
|
+
}
|
|
130
|
+
// Add search params (React Router and fallback)
|
|
131
|
+
if (paramsSource !== 'nextjs') {
|
|
132
|
+
for (const [key, value] of Object.entries(searchParams)) {
|
|
133
|
+
result[key] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Add fallback route params
|
|
137
|
+
if (paramsSource === 'fallback') {
|
|
138
|
+
for (const [key, value] of Object.entries(fallbackRouteParams)) {
|
|
139
|
+
result[key] = value;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}, [
|
|
144
|
+
// Use JSON.stringify for deep comparison
|
|
145
|
+
JSON.stringify(routeParams),
|
|
146
|
+
JSON.stringify(queryParams),
|
|
147
|
+
JSON.stringify(searchParams),
|
|
148
|
+
JSON.stringify(fallbackRouteParams),
|
|
149
|
+
paramsSource,
|
|
150
|
+
]);
|
|
151
|
+
return combinedParams;
|
|
152
|
+
};
|
package/lib/hooks/useRef.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { useRef } from 'react';
|
|
11
6
|
/**
|
|
12
7
|
* There are some situations where we only want to create a new ref if one is not provided to a component
|
package/lib/hooks/useRuntimes.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { requestJupyterKernelsExtension } from '../api';
|
|
11
6
|
export const useRuntimes = () => {
|
|
12
7
|
// Folder Mounting ----------------------------------------------------------
|
|
@@ -21,7 +16,7 @@ export const useRuntimes = () => {
|
|
|
21
16
|
};
|
|
22
17
|
const unmountLocalFolder = (kernelId) => {
|
|
23
18
|
requestJupyterKernelsExtension(`jump/${kernelId}`, {
|
|
24
|
-
method: 'DELETE'
|
|
19
|
+
method: 'DELETE',
|
|
25
20
|
})
|
|
26
21
|
.then(data => {
|
|
27
22
|
// console.log('--- Unmount Local Folder', data);
|
|
@@ -33,7 +28,7 @@ export const useRuntimes = () => {
|
|
|
33
28
|
// --------------------------------------------------------------------------
|
|
34
29
|
return {
|
|
35
30
|
mountLocalFolder,
|
|
36
|
-
unmountLocalFolder
|
|
31
|
+
unmountLocalFolder,
|
|
37
32
|
};
|
|
38
33
|
};
|
|
39
34
|
export default useRuntimes;
|
|
@@ -3,13 +3,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
8
|
-
*
|
|
9
|
-
* Datalayer License
|
|
10
|
-
*/
|
|
11
6
|
import { createContext, useState, useContext } from 'react';
|
|
12
|
-
import { LayoutScreenshot } from
|
|
7
|
+
import { LayoutScreenshot } from './layouts';
|
|
13
8
|
export const ScreenshotContext = createContext({
|
|
14
9
|
closeScreenshot: () => { },
|
|
15
10
|
displayScreenshot: (nextScreenshot) => { },
|
|
@@ -27,7 +22,7 @@ export const ScreenshotContextProvider = ScreenshotContext.Provider;
|
|
|
27
22
|
export function ScreenshotProvider(props) {
|
|
28
23
|
const { children, zIndex, disableDarken, screenshotSurface } = props;
|
|
29
24
|
const defaultScreenshotSurface = {
|
|
30
|
-
position:
|
|
25
|
+
position: 'fixed',
|
|
31
26
|
top: 0,
|
|
32
27
|
left: 0,
|
|
33
28
|
width: '100%',
|
|
@@ -40,18 +35,18 @@ export function ScreenshotProvider(props) {
|
|
|
40
35
|
};
|
|
41
36
|
const [screenshot, setScreenshot] = useState({
|
|
42
37
|
open: false,
|
|
43
|
-
render: (closeScreenshot) => _jsx(_Fragment, {})
|
|
38
|
+
render: (closeScreenshot) => _jsx(_Fragment, {}),
|
|
44
39
|
});
|
|
45
40
|
const displayScreenshot = (nextScreenshot) => {
|
|
46
41
|
setScreenshot({
|
|
47
42
|
open: true,
|
|
48
|
-
render: nextScreenshot
|
|
43
|
+
render: nextScreenshot,
|
|
49
44
|
});
|
|
50
45
|
};
|
|
51
46
|
const closeScreenshot = () => {
|
|
52
47
|
setScreenshot({
|
|
53
48
|
open: false,
|
|
54
|
-
render: (closeScreenshot) => _jsx(_Fragment, {})
|
|
49
|
+
render: (closeScreenshot) => _jsx(_Fragment, {}),
|
|
55
50
|
});
|
|
56
51
|
};
|
|
57
52
|
return (_jsxs(ScreenshotContextProvider, { value: { closeScreenshot, displayScreenshot }, children: [_jsx(LayoutScreenshot, {}), children, screenshot.open &&
|
package/lib/hooks/useToast.js
CHANGED
|
@@ -3,23 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
8
|
-
*
|
|
9
|
-
* Datalayer License
|
|
10
|
-
*/
|
|
11
6
|
import React from 'react';
|
|
12
7
|
import { toast } from 'react-toastify';
|
|
13
8
|
import { Notification } from '@jupyterlab/apputils';
|
|
14
9
|
import { Button } from '@primer/react';
|
|
15
10
|
import { isInsideJupyterLab } from '../utils';
|
|
16
11
|
import { DatalayerThemeProvider } from '../theme';
|
|
17
|
-
const TOAST_POSITION =
|
|
12
|
+
const TOAST_POSITION = 'bottom-right';
|
|
18
13
|
const displayType2Class = {
|
|
19
14
|
accent: 'primary',
|
|
20
15
|
link: 'invisible',
|
|
21
16
|
warn: 'danger',
|
|
22
|
-
default: 'default'
|
|
17
|
+
default: 'default',
|
|
23
18
|
};
|
|
24
19
|
/**
|
|
25
20
|
* Create a button with customized callback in a toast
|
|
@@ -53,11 +48,10 @@ export const useToast = () => {
|
|
|
53
48
|
switch (options.variant) {
|
|
54
49
|
case 'info': {
|
|
55
50
|
return insideJupyterLab
|
|
56
|
-
?
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
51
|
+
? Notification.info(message, {
|
|
52
|
+
autoClose: autoClose ?? 5000,
|
|
53
|
+
actions,
|
|
54
|
+
})
|
|
61
55
|
: toast.info(({ closeToast }) => createContent(message, () => {
|
|
62
56
|
if (closeToast)
|
|
63
57
|
closeToast();
|
|
@@ -67,7 +61,7 @@ export const useToast = () => {
|
|
|
67
61
|
return insideJupyterLab
|
|
68
62
|
? Notification.success(message, {
|
|
69
63
|
autoClose: autoClose ?? 5000,
|
|
70
|
-
actions
|
|
64
|
+
actions,
|
|
71
65
|
})
|
|
72
66
|
: toast.success(({ closeToast }) => createContent(message, () => {
|
|
73
67
|
if (closeToast)
|
|
@@ -78,7 +72,7 @@ export const useToast = () => {
|
|
|
78
72
|
return insideJupyterLab
|
|
79
73
|
? Notification.warning(message, {
|
|
80
74
|
autoClose: autoClose ?? false,
|
|
81
|
-
actions
|
|
75
|
+
actions,
|
|
82
76
|
})
|
|
83
77
|
: toast.warning(({ closeToast }) => createContent(message, () => {
|
|
84
78
|
if (closeToast)
|
|
@@ -89,7 +83,7 @@ export const useToast = () => {
|
|
|
89
83
|
return insideJupyterLab
|
|
90
84
|
? Notification.error(message, {
|
|
91
85
|
autoClose: autoClose ?? false,
|
|
92
|
-
actions
|
|
86
|
+
actions,
|
|
93
87
|
})
|
|
94
88
|
: toast.error(({ closeToast }) => createContent(message, () => {
|
|
95
89
|
if (closeToast)
|
|
@@ -104,10 +98,13 @@ export const useToast = () => {
|
|
|
104
98
|
: toast.promise(promise, {
|
|
105
99
|
error: { render: options.error.message, ...options.error.options },
|
|
106
100
|
pending: options.pending.message,
|
|
107
|
-
success: {
|
|
101
|
+
success: {
|
|
102
|
+
render: options.success.message,
|
|
103
|
+
...options.success.options,
|
|
104
|
+
},
|
|
108
105
|
}, {
|
|
109
106
|
position: TOAST_POSITION,
|
|
110
|
-
...options.pending.options
|
|
107
|
+
...options.pending.options,
|
|
111
108
|
});
|
|
112
109
|
};
|
|
113
110
|
return Object.freeze({
|
|
@@ -125,9 +122,12 @@ export const useToast = () => {
|
|
|
125
122
|
* @param id Toast id
|
|
126
123
|
*/
|
|
127
124
|
dismiss: (id) => {
|
|
128
|
-
insideJupyterLab
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
if (insideJupyterLab) {
|
|
126
|
+
Notification.dismiss(id);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
toast.dismiss(id);
|
|
130
|
+
}
|
|
131
131
|
},
|
|
132
132
|
/**
|
|
133
133
|
* Track the progress of an asynchronous task
|
|
@@ -137,7 +137,7 @@ export const useToast = () => {
|
|
|
137
137
|
* @param options Task progress options
|
|
138
138
|
* @returns Toast id
|
|
139
139
|
*/
|
|
140
|
-
trackAsyncTask
|
|
140
|
+
trackAsyncTask,
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
export default useToast;
|
package/lib/hooks/useUpload.js
CHANGED
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
|
-
import { useState } from "react";
|
|
11
|
-
import axios from "axios";
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import axios from 'axios';
|
|
12
7
|
// import useRun from "./useRun";
|
|
13
|
-
import { useIAMStore } from
|
|
8
|
+
import { useIAMStore } from '../state';
|
|
14
9
|
// TODO reuse useRun hook.
|
|
15
10
|
export const useUploadForm = (url) => {
|
|
16
11
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
@@ -27,21 +22,21 @@ export const useUploadForm = (url) => {
|
|
|
27
22
|
setIsLoading(true);
|
|
28
23
|
const { data } = await axios.post(url, formData, {
|
|
29
24
|
headers: {
|
|
30
|
-
|
|
31
|
-
Authorization: `Bearer ${token}
|
|
25
|
+
'Content-Type': 'multipart/form-data',
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
32
27
|
},
|
|
33
|
-
onUploadProgress:
|
|
28
|
+
onUploadProgress: progressEvent => {
|
|
34
29
|
const progress = (progressEvent.loaded / progressEvent.total) * 50;
|
|
35
30
|
setProgress(progress);
|
|
36
31
|
},
|
|
37
|
-
onDownloadProgress:
|
|
32
|
+
onDownloadProgress: progressEvent => {
|
|
38
33
|
const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
|
|
39
34
|
setProgress(progress);
|
|
40
35
|
},
|
|
41
36
|
});
|
|
42
37
|
setProgress(100);
|
|
43
|
-
await new Promise(
|
|
44
|
-
setTimeout(() => resolve(
|
|
38
|
+
await new Promise(resolve => {
|
|
39
|
+
setTimeout(() => resolve('success'), 500);
|
|
45
40
|
});
|
|
46
41
|
setIsSuccess(true);
|
|
47
42
|
setProgress(0);
|
package/lib/hooks/useUser.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { useState, useEffect } from 'react';
|
|
11
6
|
export function useVisibilityObserver(navigationRef, children) {
|
|
12
7
|
const [visibilityMap, setVisibilityMap] = useState({});
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
import { useState, useEffect } from 'react';
|
|
11
6
|
export var BreakpointSize;
|
|
12
7
|
(function (BreakpointSize) {
|
|
@@ -48,7 +43,6 @@ export function useWindowSize() {
|
|
|
48
43
|
currentBreakpointSize: breakpointSwitch(window.innerWidth),
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
|
-
// eslint-disable-next-line github/prefer-observers
|
|
52
46
|
window.addEventListener('resize', handleResize);
|
|
53
47
|
handleResize();
|
|
54
48
|
return () => window.removeEventListener('resize', handleResize);
|
package/lib/i18n/Labels.js
CHANGED
|
@@ -2,9 +2,4 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
export const NO_RUNTIME_AVAILABLE_LABEL = 'The runtime you have requested is currently not available due to resource limitations. Please try again later...';
|
package/lib/i18n/index.js
CHANGED
package/lib/index.css
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
8
|
+
line-height: 1.5;
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
|
|
11
|
+
color-scheme: light dark;
|
|
12
|
+
color: rgba(255, 255, 255, 0.87);
|
|
13
|
+
background-color: #242424;
|
|
14
|
+
|
|
15
|
+
font-synthesis: none;
|
|
16
|
+
text-rendering: optimizeLegibility;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
-moz-osx-font-smoothing: grayscale;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
a {
|
|
22
|
+
font-weight: 500;
|
|
23
|
+
color: #646cff;
|
|
24
|
+
text-decoration: inherit;
|
|
25
|
+
}
|
|
26
|
+
a:hover {
|
|
27
|
+
color: #535bf2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
body {
|
|
31
|
+
margin: 0;
|
|
32
|
+
display: flex;
|
|
33
|
+
place-items: center;
|
|
34
|
+
min-width: 320px;
|
|
35
|
+
min-height: 100vh;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
h1 {
|
|
39
|
+
font-size: 3.2em;
|
|
40
|
+
line-height: 1.1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
button {
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
border: 1px solid transparent;
|
|
46
|
+
padding: 0.6em 1.2em;
|
|
47
|
+
font-size: 1em;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
font-family: inherit;
|
|
50
|
+
background-color: #1a1a1a;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: border-color 0.25s;
|
|
53
|
+
}
|
|
54
|
+
button:hover {
|
|
55
|
+
border-color: #646cff;
|
|
56
|
+
}
|
|
57
|
+
button:focus,
|
|
58
|
+
button:focus-visible {
|
|
59
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (prefers-color-scheme: light) {
|
|
63
|
+
:root {
|
|
64
|
+
color: #213547;
|
|
65
|
+
background-color: #ffffff;
|
|
66
|
+
}
|
|
67
|
+
a:hover {
|
|
68
|
+
color: #747bff;
|
|
69
|
+
}
|
|
70
|
+
button {
|
|
71
|
+
background-color: #f9f9f9;
|
|
72
|
+
}
|
|
73
|
+
}
|
package/lib/index.d.ts
CHANGED