@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
|
@@ -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 } from 'react';
|
|
11
6
|
import { useCellStore } from '../state';
|
|
12
7
|
import { takeHTMLNodeScreenshot } from '../utils/Screenshot';
|
|
@@ -15,7 +10,8 @@ const useCellOutputshot = () => {
|
|
|
15
10
|
const [error, setError] = useState();
|
|
16
11
|
const { update } = useCellStore();
|
|
17
12
|
const takeOutputshot = (node) => {
|
|
18
|
-
takeHTMLNodeScreenshot(node)
|
|
13
|
+
takeHTMLNodeScreenshot(node)
|
|
14
|
+
.then(outputshotData => {
|
|
19
15
|
setOutputshot(outputshotData);
|
|
20
16
|
update({
|
|
21
17
|
outputshotData,
|
|
@@ -24,10 +20,6 @@ const useCellOutputshot = () => {
|
|
|
24
20
|
})
|
|
25
21
|
.catch(reason => setError(reason));
|
|
26
22
|
};
|
|
27
|
-
return [
|
|
28
|
-
outputshot,
|
|
29
|
-
takeOutputshot,
|
|
30
|
-
{ error }
|
|
31
|
-
];
|
|
23
|
+
return [outputshot, takeOutputshot, { error }];
|
|
32
24
|
};
|
|
33
25
|
export default useCellOutputshot;
|
|
@@ -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 { useCallback, useEffect, useState } from 'react';
|
|
11
6
|
/**
|
|
12
7
|
* Determine if a child element of the provided ref is currently focussed.
|
|
@@ -31,7 +26,8 @@ export const useContainsFocus = (containerRef, onFocusChange) => {
|
|
|
31
26
|
updateState(true);
|
|
32
27
|
};
|
|
33
28
|
const handleFocusOut = (event) => {
|
|
34
|
-
if (containerRef.current &&
|
|
29
|
+
if (containerRef.current &&
|
|
30
|
+
!containerRef.current.contains(event.relatedTarget)) {
|
|
35
31
|
updateState(false);
|
|
36
32
|
}
|
|
37
33
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IRequestDatalayerAPIOptions } from '../api';
|
|
2
|
+
export type IDatalayerRequestProps = {
|
|
3
|
+
/**
|
|
4
|
+
* React router login route
|
|
5
|
+
*
|
|
6
|
+
* @default '/login'
|
|
7
|
+
*/
|
|
8
|
+
loginRoute?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Notify user through toast on errors.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
notifyOnError?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface DatalayerRequest extends IDatalayerRequestProps, IRequestDatalayerAPIOptions {
|
|
17
|
+
}
|
|
18
|
+
export declare function useDatalayer(props?: IDatalayerRequestProps): {
|
|
19
|
+
requestDatalayer: <T = any>(request: DatalayerRequest) => Promise<T>;
|
|
20
|
+
};
|
|
21
|
+
export default useDatalayer;
|
|
@@ -2,32 +2,30 @@
|
|
|
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 { useLocation } from 'react-router-dom';
|
|
5
|
+
import { useLocation } from './useLocation';
|
|
11
6
|
import { useNavigate } from './useNavigate';
|
|
12
7
|
import { useToast } from './useToast';
|
|
13
|
-
import {
|
|
14
|
-
import { useIAMStore
|
|
15
|
-
import {
|
|
16
|
-
export function
|
|
8
|
+
// import { useRuMnock } from './../mocks';
|
|
9
|
+
import { useIAMStore } from '../state';
|
|
10
|
+
import { requestDatalayerAPI } from '../api';
|
|
11
|
+
export function useDatalayer(props = {}) {
|
|
17
12
|
const { loginRoute = '/login', notifyOnError = true } = props;
|
|
18
13
|
const location = useLocation();
|
|
14
|
+
/*
|
|
15
|
+
// TODO Fix the conditional hook call.
|
|
19
16
|
const coreStore = useCoreStore();
|
|
20
17
|
// Don't remove === true for the test, otherwise it will always be true???
|
|
21
18
|
if (coreStore.configuration.useMock === true) {
|
|
22
|
-
|
|
19
|
+
return useDatalayerMock();
|
|
23
20
|
}
|
|
21
|
+
*/
|
|
24
22
|
const { enqueueToast } = useToast();
|
|
25
23
|
const iamStore = useIAMStore();
|
|
26
24
|
const navigate = useNavigate();
|
|
27
|
-
const
|
|
25
|
+
const requestDatalayer = async (request) => {
|
|
28
26
|
const { loginRoute: loginRoute_ = loginRoute, notifyOnError: notifyOnError_ = notifyOnError, ...apiRequest } = request;
|
|
29
27
|
const token = apiRequest.token ?? iamStore.token;
|
|
30
|
-
return
|
|
28
|
+
return requestDatalayerAPI({
|
|
31
29
|
...apiRequest,
|
|
32
30
|
token,
|
|
33
31
|
})
|
|
@@ -59,7 +57,9 @@ export function useRun(props = {}) {
|
|
|
59
57
|
enqueueToast(`API Error`, { variant: 'error' });
|
|
60
58
|
}
|
|
61
59
|
if (responseError.exceptionMessage) {
|
|
62
|
-
enqueueToast(`${responseError.exceptionMessage}`, {
|
|
60
|
+
enqueueToast(`${responseError.exceptionMessage}`, {
|
|
61
|
+
variant: 'error',
|
|
62
|
+
});
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -78,8 +78,6 @@ export function useRun(props = {}) {
|
|
|
78
78
|
throw error;
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
return {
|
|
82
|
-
requestRun
|
|
83
|
-
};
|
|
81
|
+
return { requestDatalayer };
|
|
84
82
|
}
|
|
85
|
-
export default
|
|
83
|
+
export default useDatalayer;
|
package/lib/hooks/useError.d.ts
CHANGED
package/lib/hooks/useError.js
CHANGED
|
@@ -3,16 +3,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
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
|
-
import { useState } from "react";
|
|
6
|
+
import { useState } from 'react';
|
|
12
7
|
import { Flash } from '@primer/react';
|
|
13
8
|
export const ErrorMessage = ({ message }) => {
|
|
14
9
|
if (message instanceof Array) {
|
|
15
|
-
return _jsx("div", { children: message.map((m, i) => _jsx(Flash, { variant: "danger", children: m }, i)) });
|
|
10
|
+
return (_jsx("div", { children: message.map((m, i) => (_jsx(Flash, { variant: "danger", children: m }, i))) }));
|
|
16
11
|
}
|
|
17
12
|
else {
|
|
18
13
|
return _jsx(Flash, { variant: "danger", children: message });
|
|
@@ -2,17 +2,12 @@
|
|
|
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 { useEffect } from "react";
|
|
5
|
+
import { useEffect } from 'react';
|
|
11
6
|
const useExternalScript = (url) => {
|
|
12
7
|
useEffect(() => {
|
|
13
|
-
const head = document.querySelector(
|
|
14
|
-
const script = document.createElement(
|
|
15
|
-
script.setAttribute(
|
|
8
|
+
const head = document.querySelector('head');
|
|
9
|
+
const script = document.createElement('script');
|
|
10
|
+
script.setAttribute('src', url);
|
|
16
11
|
head.appendChild(script);
|
|
17
12
|
return () => {
|
|
18
13
|
head.removeChild(script);
|
|
@@ -22,7 +22,7 @@ export interface FocusTrapHookSettings {
|
|
|
22
22
|
/**
|
|
23
23
|
* Hook used to trap focus inside a container. Returns a ref that can be added to the container
|
|
24
24
|
* that should trap focus.
|
|
25
|
-
* @param settings
|
|
25
|
+
* @param settings {FocusTrapHookSettings}
|
|
26
26
|
*/
|
|
27
27
|
export declare function useFocusTrap(settings?: FocusTrapHookSettings, dependencies?: React.DependencyList): {
|
|
28
28
|
containerRef: React.RefObject<HTMLElement> | undefined;
|
|
@@ -2,17 +2,12 @@
|
|
|
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 React from 'react';
|
|
11
6
|
import { focusTrap } from '@primer/behaviors';
|
|
12
7
|
/**
|
|
13
8
|
* Hook used to trap focus inside a container. Returns a ref that can be added to the container
|
|
14
9
|
* that should trap focus.
|
|
15
|
-
* @param settings
|
|
10
|
+
* @param settings {FocusTrapHookSettings}
|
|
16
11
|
*/
|
|
17
12
|
export function useFocusTrap(settings, dependencies = []) {
|
|
18
13
|
const containerRef = settings?.containerRef;
|
|
@@ -29,7 +24,8 @@ export function useFocusTrap(settings, dependencies = []) {
|
|
|
29
24
|
// to the previously-focused element (if necessary).
|
|
30
25
|
function disableTrap() {
|
|
31
26
|
abortController.current?.abort();
|
|
32
|
-
if (settings?.restoreFocusOnCleanUp &&
|
|
27
|
+
if (settings?.restoreFocusOnCleanUp &&
|
|
28
|
+
previousFocusedElement.current instanceof HTMLElement) {
|
|
33
29
|
previousFocusedElement.current.focus();
|
|
34
30
|
previousFocusedElement.current = null;
|
|
35
31
|
}
|
package/lib/hooks/useIAM.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
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, useState } from 'react';
|
|
11
6
|
import { useCache } from './useCache';
|
|
12
|
-
import { coreStore, useIAMStore, useLayoutStore, useOrganizationStore, useSpaceStore } from '../state';
|
|
13
|
-
import { asUser, ANONYMOUS_USER, ANONYMOUS_USER_TOKEN } from '../models';
|
|
14
|
-
import {
|
|
7
|
+
import { coreStore, useIAMStore, useLayoutStore, useOrganizationStore, useSpaceStore, } from '../state';
|
|
8
|
+
import { asUser, ANONYMOUS_USER, ANONYMOUS_USER_TOKEN, } from '../models';
|
|
9
|
+
import { requestDatalayerAPI } from '../api';
|
|
15
10
|
export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
16
11
|
const { token } = props;
|
|
17
12
|
const [iamState, setIAMState] = useState(props);
|
|
@@ -22,7 +17,7 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
|
22
17
|
const { clearAllCaches, whoami } = useCache();
|
|
23
18
|
const loginAndNavigate = async (token, logout, refresh, navigate, homeRoute) => {
|
|
24
19
|
try {
|
|
25
|
-
const resp = await
|
|
20
|
+
const resp = await requestDatalayerAPI({
|
|
26
21
|
url: `${iamStore.iamRunUrl}/api/iam/v1/login`,
|
|
27
22
|
method: 'POST',
|
|
28
23
|
body: { token },
|
|
@@ -70,8 +65,7 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
|
70
65
|
};
|
|
71
66
|
useEffect(() => {
|
|
72
67
|
if (token) {
|
|
73
|
-
whoami()
|
|
74
|
-
.then(resp => {
|
|
68
|
+
whoami().then(resp => {
|
|
75
69
|
if (resp.success) {
|
|
76
70
|
const user = asUser(resp.profile);
|
|
77
71
|
setIAMState({ user, token });
|
|
@@ -92,7 +86,7 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
|
|
|
92
86
|
token: iamState.token,
|
|
93
87
|
loginAndNavigate,
|
|
94
88
|
setLogin,
|
|
95
|
-
logout
|
|
89
|
+
logout,
|
|
96
90
|
};
|
|
97
91
|
};
|
|
98
92
|
export default useIAM;
|
package/lib/hooks/useId.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
|
/*
|
|
11
6
|
* Welcome to @reach/auto-id!
|
|
12
7
|
|
|
@@ -63,8 +58,8 @@
|
|
|
63
58
|
* server hydration and never again, SO BACK OFF ALRIGHT?
|
|
64
59
|
*/
|
|
65
60
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
66
|
-
import * as React from
|
|
67
|
-
import { useLayoutEffect } from
|
|
61
|
+
import * as React from 'react';
|
|
62
|
+
import { useLayoutEffect } from 'react';
|
|
68
63
|
let serverHandoffComplete = false;
|
|
69
64
|
let id = 0;
|
|
70
65
|
function genId() {
|
|
@@ -72,16 +67,16 @@ function genId() {
|
|
|
72
67
|
}
|
|
73
68
|
// Workaround for https://github.com/webpack/webpack/issues/14814
|
|
74
69
|
// https://github.com/eps1lon/material-ui/blob/8d5f135b4d7a58253a99ab56dce4ac8de61f5dc1/packages/mui-utils/src/useId.ts#L21
|
|
75
|
-
const maybeReactUseId = React[
|
|
70
|
+
const maybeReactUseId = React['useId'.toString()];
|
|
76
71
|
function useId(providedId) {
|
|
77
72
|
if (maybeReactUseId !== undefined) {
|
|
78
|
-
|
|
73
|
+
const generatedId = maybeReactUseId();
|
|
79
74
|
return providedId ?? generatedId;
|
|
80
75
|
}
|
|
81
76
|
// If this instance isn't part of the initial render, we don't have to do the
|
|
82
77
|
// double render/patch-up dance. We can just generate the ID and return it.
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
const initialId = providedId ?? (serverHandoffComplete ? genId() : null);
|
|
79
|
+
const [id, setId] = React.useState(initialId);
|
|
85
80
|
useLayoutEffect(() => {
|
|
86
81
|
if (id === null) {
|
|
87
82
|
// Patch the ID after render. We do this in `useLayoutEffect` to avoid any
|
|
@@ -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, useLayoutEffect } from 'react';
|
|
11
6
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' &&
|
|
12
7
|
typeof window.document !== 'undefined' &&
|
|
@@ -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, useState } from 'react';
|
|
11
6
|
export var JupyterLabTheme;
|
|
12
7
|
(function (JupyterLabTheme) {
|
|
@@ -14,7 +9,9 @@ export var JupyterLabTheme;
|
|
|
14
9
|
JupyterLabTheme["DARK"] = "JupyterLab Dark";
|
|
15
10
|
})(JupyterLabTheme || (JupyterLabTheme = {}));
|
|
16
11
|
export const useJupyterLabTheme = (themeManager) => {
|
|
17
|
-
const isLight = themeManager && themeManager.theme
|
|
12
|
+
const isLight = themeManager && themeManager.theme
|
|
13
|
+
? themeManager.isLight(themeManager.theme)
|
|
14
|
+
: true;
|
|
18
15
|
const [theme, setTheme] = useState(isLight ? JupyterLabTheme.LIGHT : JupyterLabTheme.DARK);
|
|
19
16
|
useEffect(() => {
|
|
20
17
|
const handleThemeChange = (newTheme, event) => {
|
|
@@ -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 { useCallback, useEffect } from 'react';
|
|
11
6
|
export function useKeyboardEscape(handler) {
|
|
12
7
|
const handleKeyboardEscape = useCallback(event => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Location {
|
|
2
|
+
pathname: string;
|
|
3
|
+
search: string;
|
|
4
|
+
hash: string;
|
|
5
|
+
state: any;
|
|
6
|
+
key: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hook to get current location
|
|
10
|
+
* Detects and uses React Router when available, falls back to native browser location
|
|
11
|
+
*/
|
|
12
|
+
export declare const useLocation: () => Location;
|
|
13
|
+
/**
|
|
14
|
+
* Hook to get history functions
|
|
15
|
+
* Detects and uses React Router history when available, falls back to browser history
|
|
16
|
+
*/
|
|
17
|
+
export declare const useHistory: () => {
|
|
18
|
+
back: () => void;
|
|
19
|
+
forward: () => void;
|
|
20
|
+
replace: (to: string, state?: any) => void;
|
|
21
|
+
push: (to: string, state?: any) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
// Import React Router hooks from our wrapper
|
|
7
|
+
import { useLocationRR, useNavigateRR, } from '../navigation/adapters/react-router';
|
|
8
|
+
// Import Next.js hooks from our wrapper
|
|
9
|
+
// Currently not used but kept for future Next.js support
|
|
10
|
+
// import {
|
|
11
|
+
// usePathnameNext,
|
|
12
|
+
// useSearchParamsNext,
|
|
13
|
+
// } from '../navigation/adapters/nextjs';
|
|
14
|
+
/**
|
|
15
|
+
* Hook to get current location
|
|
16
|
+
* Detects and uses React Router when available, falls back to native browser location
|
|
17
|
+
*/
|
|
18
|
+
export const useLocation = () => {
|
|
19
|
+
// Native location state for fallback
|
|
20
|
+
const [nativeLocation, setNativeLocation] = useState(() => {
|
|
21
|
+
if (typeof window === 'undefined') {
|
|
22
|
+
return {
|
|
23
|
+
pathname: '/',
|
|
24
|
+
search: '',
|
|
25
|
+
hash: '',
|
|
26
|
+
state: null,
|
|
27
|
+
key: 'default',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
pathname: window.location.pathname,
|
|
32
|
+
search: window.location.search,
|
|
33
|
+
hash: window.location.hash,
|
|
34
|
+
state: window.history.state,
|
|
35
|
+
key: 'default',
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
// Detect environment
|
|
39
|
+
const isNextJs = typeof window !== 'undefined' && !!window.__NEXT_DATA__;
|
|
40
|
+
const isClient = typeof window !== 'undefined';
|
|
41
|
+
// Try to use React Router if available
|
|
42
|
+
let routerLocation = null;
|
|
43
|
+
let isReactRouter = false;
|
|
44
|
+
try {
|
|
45
|
+
// Only actually use the hook if we have it and not in Next.js
|
|
46
|
+
if (!isNextJs && useLocationRR && isClient) {
|
|
47
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
|
+
routerLocation = useLocationRR();
|
|
49
|
+
isReactRouter = !!routerLocation;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Not in a Router context, fallback to native
|
|
54
|
+
}
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
// Only set up native listeners if not using React Router
|
|
57
|
+
if (isReactRouter)
|
|
58
|
+
return;
|
|
59
|
+
// Listen to popstate for browser navigation changes
|
|
60
|
+
const handleLocationChange = () => {
|
|
61
|
+
setNativeLocation({
|
|
62
|
+
pathname: window.location.pathname,
|
|
63
|
+
search: window.location.search,
|
|
64
|
+
hash: window.location.hash,
|
|
65
|
+
state: window.history.state,
|
|
66
|
+
key: 'native-' + Date.now(),
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
window.addEventListener('popstate', handleLocationChange);
|
|
70
|
+
// Also listen for custom navigation events if needed
|
|
71
|
+
window.addEventListener('pushstate', handleLocationChange);
|
|
72
|
+
window.addEventListener('replacestate', handleLocationChange);
|
|
73
|
+
return () => {
|
|
74
|
+
window.removeEventListener('popstate', handleLocationChange);
|
|
75
|
+
window.removeEventListener('pushstate', handleLocationChange);
|
|
76
|
+
window.removeEventListener('replacestate', handleLocationChange);
|
|
77
|
+
};
|
|
78
|
+
}, [isReactRouter]);
|
|
79
|
+
// Return React Router location if available, otherwise native location
|
|
80
|
+
return isReactRouter && routerLocation ? routerLocation : nativeLocation;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Hook to get history functions
|
|
84
|
+
* Detects and uses React Router history when available, falls back to browser history
|
|
85
|
+
*/
|
|
86
|
+
export const useHistory = () => {
|
|
87
|
+
// Detect environment
|
|
88
|
+
const isNextJs = typeof window !== 'undefined' && !!window.__NEXT_DATA__;
|
|
89
|
+
const isClient = typeof window !== 'undefined';
|
|
90
|
+
// Try to use React Router if available
|
|
91
|
+
let routerNavigate = null;
|
|
92
|
+
let isReactRouter = false;
|
|
93
|
+
try {
|
|
94
|
+
if (!isNextJs && useNavigateRR && isClient) {
|
|
95
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
96
|
+
routerNavigate = useNavigateRR();
|
|
97
|
+
isReactRouter = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Not in a Router context
|
|
102
|
+
}
|
|
103
|
+
if (isReactRouter && routerNavigate) {
|
|
104
|
+
// Use React Router navigation
|
|
105
|
+
return {
|
|
106
|
+
back: () => {
|
|
107
|
+
routerNavigate(-1);
|
|
108
|
+
},
|
|
109
|
+
forward: () => {
|
|
110
|
+
routerNavigate(1);
|
|
111
|
+
},
|
|
112
|
+
replace: (to, state) => {
|
|
113
|
+
routerNavigate(to, { replace: true, state });
|
|
114
|
+
},
|
|
115
|
+
push: (to, state) => {
|
|
116
|
+
routerNavigate(to, { state });
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Fall back to native browser history
|
|
121
|
+
return {
|
|
122
|
+
back: () => {
|
|
123
|
+
if (typeof window !== 'undefined') {
|
|
124
|
+
window.history.back();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
forward: () => {
|
|
128
|
+
if (typeof window !== 'undefined') {
|
|
129
|
+
window.history.forward();
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
replace: (to, state) => {
|
|
133
|
+
if (typeof window !== 'undefined') {
|
|
134
|
+
const url = new URL(to, window.location.href);
|
|
135
|
+
window.history.replaceState(state || null, '', url.href);
|
|
136
|
+
// Dispatch custom event for location hooks
|
|
137
|
+
window.dispatchEvent(new Event('replacestate'));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
push: (to, state) => {
|
|
141
|
+
if (typeof window !== 'undefined') {
|
|
142
|
+
const url = new URL(to, window.location.href);
|
|
143
|
+
window.history.pushState(state || null, '', url.href);
|
|
144
|
+
// Dispatch custom event for location hooks
|
|
145
|
+
window.dispatchEvent(new Event('pushstate'));
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
};
|
|
@@ -3,8 +3,8 @@ export declare const useLocationHandles: () => {
|
|
|
3
3
|
spaceHandler: string | undefined;
|
|
4
4
|
spaceHandle?: undefined;
|
|
5
5
|
} | {
|
|
6
|
-
accountHandle: string
|
|
7
|
-
spaceHandle: string
|
|
6
|
+
accountHandle: string;
|
|
7
|
+
spaceHandle: string;
|
|
8
8
|
spaceHandler?: undefined;
|
|
9
9
|
};
|
|
10
10
|
export default useLocationHandles;
|
|
@@ -2,18 +2,15 @@
|
|
|
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 { useLocation, useParams } from "react-router-dom";
|
|
11
|
-
import { useRunStore } from "../state";
|
|
5
|
+
import { useLocation } from './useLocation';
|
|
6
|
+
import { useParams } from './useParams';
|
|
7
|
+
import { useRunStore } from '../state';
|
|
12
8
|
export const useLocationHandles = () => {
|
|
13
|
-
const
|
|
9
|
+
const params = useParams();
|
|
10
|
+
const { accountHandle, spaceHandle } = params;
|
|
14
11
|
const { pathname } = useLocation();
|
|
15
12
|
const runStore = useRunStore();
|
|
16
|
-
if (pathname.startsWith(
|
|
13
|
+
if (pathname.startsWith('/public')) {
|
|
17
14
|
return {
|
|
18
15
|
accountHandle: runStore.iam().user?.handle,
|
|
19
16
|
spaceHandler: runStore.layout().space?.handle,
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Main navigation hook that provides a universal navigate function
|
|
3
|
+
* Works with React Router, Next.js, or native browser navigation
|
|
4
|
+
*/
|
|
5
|
+
export declare const useNavigate: () => (location: string, optionsOrEvent?: any, resetPortals?: boolean, extraOptions?: any) => void;
|
|
2
6
|
export default useNavigate;
|