@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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Native Navigation Example
|
|
4
|
+
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
5
|
+
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NativeNavigationExample: React.FC;
|
|
8
|
+
export default NativeNavigationExample;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import { Box, Button, Heading, Text, Link as PrimerLink } from '@primer/react';
|
|
8
|
+
import { useNavigate, useLocation, useParams, useHistory } from '../hooks';
|
|
9
|
+
/**
|
|
10
|
+
* Native Navigation Example
|
|
11
|
+
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
12
|
+
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
13
|
+
*/
|
|
14
|
+
export const NativeNavigationExample = () => {
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
const location = useLocation();
|
|
17
|
+
const params = useParams();
|
|
18
|
+
const history = useHistory();
|
|
19
|
+
const [navigationType, setNavigationType] = useState('detecting...');
|
|
20
|
+
const [navigationCount, setNavigationCount] = useState(0);
|
|
21
|
+
const [currentView, setCurrentView] = useState('home');
|
|
22
|
+
// Track navigation type detection
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
// Since we're not using React Router, this should detect as 'native'
|
|
25
|
+
setNavigationType('native');
|
|
26
|
+
}, []);
|
|
27
|
+
// Track navigation events
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setNavigationCount(prev => prev + 1);
|
|
30
|
+
// Parse the path to determine which view to show
|
|
31
|
+
const path = location.pathname;
|
|
32
|
+
if (path.includes('page1')) {
|
|
33
|
+
setCurrentView('page1');
|
|
34
|
+
}
|
|
35
|
+
else if (path.includes('page2')) {
|
|
36
|
+
setCurrentView('page2');
|
|
37
|
+
}
|
|
38
|
+
else if (path.includes('page3')) {
|
|
39
|
+
setCurrentView('page3');
|
|
40
|
+
}
|
|
41
|
+
else if (path.includes('user')) {
|
|
42
|
+
setCurrentView('user');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setCurrentView('home');
|
|
46
|
+
}
|
|
47
|
+
}, [location]);
|
|
48
|
+
const handleProgrammaticNavigation = () => {
|
|
49
|
+
navigate('/page3', undefined, true);
|
|
50
|
+
};
|
|
51
|
+
const handleNavigateWithQuery = () => {
|
|
52
|
+
navigate('/page2?test=456&native=true', undefined, true);
|
|
53
|
+
};
|
|
54
|
+
const handleNavigateWithHash = () => {
|
|
55
|
+
navigate('/page3#native-section', undefined, true);
|
|
56
|
+
};
|
|
57
|
+
const handleBackNavigation = () => {
|
|
58
|
+
history.back();
|
|
59
|
+
};
|
|
60
|
+
const handleForwardNavigation = () => {
|
|
61
|
+
history.forward();
|
|
62
|
+
};
|
|
63
|
+
const handleReplaceNavigation = () => {
|
|
64
|
+
history.replace('/replaced-page', { replaced: true });
|
|
65
|
+
};
|
|
66
|
+
// Simple link handler for native navigation
|
|
67
|
+
const handleLinkClick = (e, path) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
navigate(path, e, true);
|
|
70
|
+
};
|
|
71
|
+
// Render different content based on current view
|
|
72
|
+
const renderContent = () => {
|
|
73
|
+
switch (currentView) {
|
|
74
|
+
case 'page1':
|
|
75
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 1 (Native)" }), _jsx(Text, { as: "p", children: "You've navigated to Page 1 using native browser navigation." })] }));
|
|
76
|
+
case 'page2':
|
|
77
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 2 (Native)" }), _jsx(Text, { as: "p", children: "This is Page 2 with native navigation. Check the query parameters!" })] }));
|
|
78
|
+
case 'page3':
|
|
79
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 3 (Native)" }), _jsx(Text, { as: "p", children: "Welcome to Page 3 using native browser APIs. Notice the hash in the URL!" })] }));
|
|
80
|
+
case 'user':
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "User Page (Native)" }), _jsxs(Text, { as: "p", children: ["User pages with native navigation. Path: ", location.pathname] })] }));
|
|
82
|
+
default:
|
|
83
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Home Page (Native)" }), _jsx(Text, { as: "p", children: "This is the home page of the Native navigation example." })] }));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return (_jsxs(Box, { sx: { minHeight: '100vh', p: 4 }, children: [_jsxs(Box, { sx: { mb: 4, p: 3, bg: 'canvas.subtle', borderRadius: 2 }, children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Native Browser Navigation Example" }), _jsx(Text, { as: "p", sx: { mb: 2 }, children: "This example demonstrates the navigation hooks WITHOUT React Router context. The hooks automatically fall back to native browser navigation (history API)." }), _jsx(Text, { as: "p", sx: { color: 'attention.fg', fontWeight: 'bold' }, children: "\u26A0\uFE0F No React Router is loaded in this example - using native browser APIs only!" })] }), renderContent(), _jsxs(Box, { sx: { mt: 4 }, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Navigation Information" }), _jsxs(Box, { sx: {
|
|
87
|
+
mb: 4,
|
|
88
|
+
p: 3,
|
|
89
|
+
borderWidth: 1,
|
|
90
|
+
borderStyle: 'solid',
|
|
91
|
+
borderColor: 'border.default',
|
|
92
|
+
borderRadius: 2,
|
|
93
|
+
}, children: [_jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Navigation Type Detected:" }), ' ', _jsx(Text, { as: "span", sx: {
|
|
94
|
+
color: navigationType === 'native' ? 'success.fg' : 'danger.fg',
|
|
95
|
+
}, children: navigationType })] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Current Path:" }), " ", location.pathname] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Search Params:" }), " ", location.search || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Hash:" }), " ", location.hash || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Location Key:" }), " ", location.key] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "State:" }), " ", JSON.stringify(location.state) || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "URL Params (parsed from search):" }), ' ', JSON.stringify(params)] }), _jsxs(Text, { as: "p", children: [_jsx("strong", { children: "Navigation Count:" }), " ", navigationCount] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test Programmatic Navigation" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap' }, children: [_jsx(Button, { onClick: handleProgrammaticNavigation, children: "Navigate to /page3" }), _jsx(Button, { onClick: handleNavigateWithQuery, variant: "default", children: "Navigate with Query Params" }), _jsx(Button, { onClick: handleNavigateWithHash, variant: "default", children: "Navigate with Hash" }), _jsx(Button, { onClick: handleReplaceNavigation, variant: "default", children: "Replace Current Entry" })] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test History API" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap' }, children: [_jsx(Button, { onClick: handleBackNavigation, variant: "default", children: "History Back" }), _jsx(Button, { onClick: handleForwardNavigation, variant: "default", children: "History Forward" })] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test Link Navigation" }), _jsxs(Box, { sx: { display: 'flex', gap: 3, flexWrap: 'wrap' }, children: [_jsx(PrimerLink, { href: "/", onClick: e => handleLinkClick(e, '/'), sx: { cursor: 'pointer' }, children: "Home" }), _jsx(PrimerLink, { href: "/page1", onClick: e => handleLinkClick(e, '/page1'), sx: { cursor: 'pointer' }, children: "Page 1" }), _jsx(PrimerLink, { href: "/page2?test=123", onClick: e => handleLinkClick(e, '/page2?test=123'), sx: { cursor: 'pointer' }, children: "Page 2 with Query" }), _jsx(PrimerLink, { href: "/page3#section", onClick: e => handleLinkClick(e, '/page3#section'), sx: { cursor: 'pointer' }, children: "Page 3 with Hash" }), _jsx(PrimerLink, { href: "/user/456", onClick: e => handleLinkClick(e, '/user/456'), sx: { cursor: 'pointer' }, children: "User 456" })] })] }), _jsxs(Box, { sx: { mt: 4, p: 3, bg: 'attention.subtle', borderRadius: 2 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "How This Works" }), _jsx(Text, { as: "p", sx: { mb: 2 }, children: "This example does NOT include React Router. The navigation hooks automatically detect this and:" }), _jsxs(Box, { as: "ul", sx: { pl: 4 }, children: [_jsxs(Text, { as: "li", children: ["Use ", _jsx("code", { children: "window.history.pushState()" }), " for navigation"] }), _jsxs(Text, { as: "li", children: ["Listen to ", _jsx("code", { children: "popstate" }), " events for browser back/forward"] }), _jsxs(Text, { as: "li", children: ["Parse ", _jsx("code", { children: "window.location" }), " for current path and params"] }), _jsx(Text, { as: "li", children: "Provide the same API as when React Router is present" })] }), _jsx(Text, { as: "p", sx: { mt: 2 }, children: "The beauty is that the same hooks work in both scenarios without any code changes!" })] })] })] }));
|
|
96
|
+
};
|
|
97
|
+
export default NativeNavigationExample;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
+
type INotebookExampleProps = {
|
|
3
|
+
serviceManager?: ServiceManager.IManager;
|
|
4
|
+
};
|
|
5
|
+
export declare const NotebookExample: (props: INotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default NotebookExample;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) 2021-2023 Datalayer, Inc.
|
|
8
|
+
*
|
|
9
|
+
* MIT License
|
|
10
|
+
*/
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
import { Box } from '@datalayer/primer-addons';
|
|
13
|
+
import { Notebook2, NotebookToolbar, CellSidebarExtension, CellSidebarButton, } from '@datalayer/jupyter-react';
|
|
14
|
+
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
15
|
+
const NOTEBOOK_ID = 'notebook-example-1';
|
|
16
|
+
export const NotebookExample = (props) => {
|
|
17
|
+
const { serviceManager } = props;
|
|
18
|
+
const extensions = useMemo(() => [new CellSidebarExtension({ factory: CellSidebarButton })], []);
|
|
19
|
+
if (!serviceManager) {
|
|
20
|
+
return (_jsxs(Box, { as: "h1", children: ["A Jupyter Notebook", _jsx("div", { children: "Loading..." })] }));
|
|
21
|
+
}
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx(Box, { as: "h1", children: "A Jupyter Notebook" }), _jsx(Notebook2, { id: NOTEBOOK_ID, nbformat: nbformatExample, serviceManager: serviceManager, startDefaultKernel: true, extensions: extensions, Toolbar: NotebookToolbar })] }));
|
|
23
|
+
};
|
|
24
|
+
export default NotebookExample;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { createRoot } from 'react-dom/client';
|
|
8
|
+
import { Box, SegmentedControl, Label, Text } from '@primer/react';
|
|
9
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
10
|
+
import { createLiteServiceManager, createServerSettings, setJupyterServerUrl, getJupyterServerUrl, getJupyterServerToken, ServiceManagerLess, loadJupyterConfig, DEFAULT_JUPYTER_SERVER_URL, useNotebookStore, Notebook, SpinnerCentered, JupyterReactTheme, } from '@datalayer/jupyter-react';
|
|
11
|
+
import { useCoreStore } from '../state/substates/CoreState';
|
|
12
|
+
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
13
|
+
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
14
|
+
const NOTEBOOK_ID = 'notebook-mutations-id';
|
|
15
|
+
loadJupyterConfig();
|
|
16
|
+
const SERVICE_MANAGER_LESS = new ServiceManagerLess();
|
|
17
|
+
const NotebookMutationsKernel = () => {
|
|
18
|
+
const [index, setIndex] = useState(0);
|
|
19
|
+
const [nbformat, setNbformat] = useState(nbformatExample);
|
|
20
|
+
const [readonly, setReadonly] = useState(true);
|
|
21
|
+
const [serverless, setServerless] = useState(true);
|
|
22
|
+
const [kernelIndex, setKernelIndex] = useState(-1);
|
|
23
|
+
const [waiting, setWaiting] = useState(false);
|
|
24
|
+
const [lite, setLite] = useState(false);
|
|
25
|
+
const [serviceManager, setServiceManager] = useState(SERVICE_MANAGER_LESS);
|
|
26
|
+
const [sessions, setSessions] = useState([]);
|
|
27
|
+
const { configuration } = useCoreStore();
|
|
28
|
+
const notebookStore = useNotebookStore();
|
|
29
|
+
const notebook = notebookStore.selectNotebook(NOTEBOOK_ID);
|
|
30
|
+
const onSessionConnection = (session) => {
|
|
31
|
+
console.log('Received a Kernel Session.', session);
|
|
32
|
+
if (session) {
|
|
33
|
+
setSessions(sessions.concat(session));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const changeIndex = (index) => {
|
|
37
|
+
setIndex(index);
|
|
38
|
+
switch (index) {
|
|
39
|
+
case 0: {
|
|
40
|
+
setKernelIndex(-1);
|
|
41
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
42
|
+
setServerless(true);
|
|
43
|
+
setReadonly(true);
|
|
44
|
+
setLite(false);
|
|
45
|
+
setServiceManager(SERVICE_MANAGER_LESS);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 1: {
|
|
49
|
+
setJupyterServerUrl(location.protocol + '//' + location.host);
|
|
50
|
+
createLiteServiceManager().then(liteServiceManager => {
|
|
51
|
+
setKernelIndex(-1);
|
|
52
|
+
console.log('Lite Service Manager is available', liteServiceManager);
|
|
53
|
+
setServiceManager(liteServiceManager);
|
|
54
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
55
|
+
setServerless(false);
|
|
56
|
+
setReadonly(false);
|
|
57
|
+
setLite(true);
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case 2: {
|
|
62
|
+
setJupyterServerUrl(DEFAULT_JUPYTER_SERVER_URL);
|
|
63
|
+
setKernelIndex(-1);
|
|
64
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
65
|
+
setServerless(false);
|
|
66
|
+
setReadonly(false);
|
|
67
|
+
setLite(false);
|
|
68
|
+
const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
|
|
69
|
+
const serviceManager = new ServiceManager({ serverSettings });
|
|
70
|
+
serviceManager['__NAME__'] = 'MutatingServiceManager';
|
|
71
|
+
setServiceManager(serviceManager);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 3: {
|
|
75
|
+
// setWaiting(true);
|
|
76
|
+
setLite(false);
|
|
77
|
+
createDatalayerServiceManager(configuration?.cpuEnvironment || 'python-simple-env', configuration?.credits || 1).then(serviceManager => {
|
|
78
|
+
serviceManager['__NAME__'] = 'DatalayerCPUServiceManager';
|
|
79
|
+
setServiceManager(serviceManager);
|
|
80
|
+
setServerless(false);
|
|
81
|
+
setReadonly(false);
|
|
82
|
+
setKernelIndex(0);
|
|
83
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
84
|
+
// setWaiting(false);
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case 4: {
|
|
89
|
+
setWaiting(true);
|
|
90
|
+
setLite(false);
|
|
91
|
+
createDatalayerServiceManager(configuration?.gpuEnvironment || 'pytorch-cuda-env', configuration?.credits || 1).then(serviceManager => {
|
|
92
|
+
setKernelIndex(0);
|
|
93
|
+
serviceManager['__NAME__'] = 'DatalayerGPUServiceManager';
|
|
94
|
+
setServiceManager(serviceManager);
|
|
95
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
96
|
+
setServerless(false);
|
|
97
|
+
setReadonly(false);
|
|
98
|
+
setWaiting(false);
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return (_jsx(JupyterReactTheme, { children: _jsxs(_Fragment, { children: [_jsxs(Box, { display: "flex", children: [_jsx(Box, { children: _jsxs(SegmentedControl, { onChange: index => changeIndex(index), "aria-label": "jupyter-react-example", children: [_jsx(SegmentedControl.Button, { defaultSelected: index === 0, children: "Readonly" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 1, children: "Browser Kernel" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 2, children: "OSS Kernel (CPU)" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 3, children: "Kernel (CPU)" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 4, children: "Kernel (GPU)" })] }) }), _jsxs(Box, { ml: 1, mt: 1, children: [_jsxs(Label, { children: ["Lite: ", String(notebook?.adapter?.lite)] }), _jsxs(Label, { children: ["Service Manager URL:", ' ', notebook?.adapter?.serviceManager.serverSettings.baseUrl] }), _jsxs(Label, { children: ["Service Manager is ready:", ' ', String(notebook?.adapter?.serviceManager.isReady)] }), _jsxs(Label, { children: ["Kernel ID: ", notebook?.adapter?.kernel?.id] }), _jsxs(Label, { children: ["Kernel Banner: ", notebook?.adapter?.kernel?.info?.banner] })] })] }), _jsx(Box, { children: _jsx(Text, { as: "h3", children: "Kernel Sessions" }) }), _jsx(Box, { children: sessions.map(session => {
|
|
105
|
+
return (_jsx(Box, { children: _jsxs(Text, { children: [session.name, " ", session.id, " ", _jsx(Label, { children: "Kernel" }), " clientId [", session.kernel?.clientId, ") - id ", session.kernel?.id] }) }, session.id));
|
|
106
|
+
}) }), waiting ? (_jsx(SpinnerCentered, {})) : (_jsx(Notebook, { height: "calc(100vh - 2.6rem)", id: NOTEBOOK_ID, lite: lite, nbformat: nbformat, onSessionConnection: onSessionConnection, readonly: readonly, serverless: serverless, serviceManager: serviceManager, useRunningKernelIndex: kernelIndex }))] }) }));
|
|
107
|
+
};
|
|
108
|
+
export default NotebookMutationsKernel;
|
|
109
|
+
// For standalone testing
|
|
110
|
+
if (typeof window !== 'undefined' && window.location.pathname === '/test') {
|
|
111
|
+
const div = document.createElement('div');
|
|
112
|
+
document.body.appendChild(div);
|
|
113
|
+
const root = createRoot(div);
|
|
114
|
+
root.render(_jsx(NotebookMutationsKernel, {}));
|
|
115
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { createRoot } from 'react-dom/client';
|
|
8
|
+
import { Box, SegmentedControl, Label, Text } from '@primer/react';
|
|
9
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
10
|
+
import { createLiteServiceManager, createServerSettings, setJupyterServerUrl, getJupyterServerUrl, getJupyterServerToken, ServiceManagerLess, loadJupyterConfig, DEFAULT_JUPYTER_SERVER_URL, useNotebookStore, Notebook, SpinnerCentered, JupyterReactTheme, } from '@datalayer/jupyter-react';
|
|
11
|
+
import { useCoreStore } from '../state/substates/CoreState';
|
|
12
|
+
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
13
|
+
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
14
|
+
const NOTEBOOK_ID = 'notebook-mutations-id';
|
|
15
|
+
loadJupyterConfig();
|
|
16
|
+
const SERVICE_MANAGER_LESS = new ServiceManagerLess();
|
|
17
|
+
const NotebookMutationsServiceManager = () => {
|
|
18
|
+
const [index, setIndex] = useState(0);
|
|
19
|
+
const [nbformat, setNbformat] = useState(nbformatExample);
|
|
20
|
+
const [readonly, setReadonly] = useState(true);
|
|
21
|
+
const [waiting, setWaiting] = useState(false);
|
|
22
|
+
const [lite, setLite] = useState(false);
|
|
23
|
+
const [serviceManager, setServiceManager] = useState(SERVICE_MANAGER_LESS);
|
|
24
|
+
const [sessions, setSessions] = useState([]);
|
|
25
|
+
const { configuration } = useCoreStore();
|
|
26
|
+
const notebookStore = useNotebookStore();
|
|
27
|
+
const notebook = notebookStore.selectNotebook(NOTEBOOK_ID);
|
|
28
|
+
const onSessionConnection = (session) => {
|
|
29
|
+
console.log('Received a Kernel Session.', session);
|
|
30
|
+
if (session) {
|
|
31
|
+
setSessions(sessions.concat(session));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const changeIndex = (index) => {
|
|
35
|
+
setIndex(index);
|
|
36
|
+
switch (index) {
|
|
37
|
+
case 0: {
|
|
38
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
39
|
+
setReadonly(true);
|
|
40
|
+
setLite(false);
|
|
41
|
+
setServiceManager(SERVICE_MANAGER_LESS);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case 1: {
|
|
45
|
+
setJupyterServerUrl(location.protocol + '//' + location.host);
|
|
46
|
+
createLiteServiceManager().then(liteServiceManager => {
|
|
47
|
+
console.log('Lite Service Manager is available', liteServiceManager);
|
|
48
|
+
setServiceManager(liteServiceManager);
|
|
49
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
50
|
+
setReadonly(false);
|
|
51
|
+
setLite(true);
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case 2: {
|
|
56
|
+
setJupyterServerUrl(DEFAULT_JUPYTER_SERVER_URL);
|
|
57
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
58
|
+
setReadonly(false);
|
|
59
|
+
setLite(false);
|
|
60
|
+
const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
|
|
61
|
+
const serviceManager = new ServiceManager({ serverSettings });
|
|
62
|
+
serviceManager['__NAME__'] = 'MutatingServiceManager';
|
|
63
|
+
setServiceManager(serviceManager);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 3: {
|
|
67
|
+
setReadonly(false);
|
|
68
|
+
setWaiting(true);
|
|
69
|
+
setLite(false);
|
|
70
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
71
|
+
createDatalayerServiceManager(configuration?.cpuEnvironment || 'python-simple-env', configuration?.credits || 1).then(serviceManager => {
|
|
72
|
+
serviceManager['__NAME__'] = 'DatalayerCPUServiceManager';
|
|
73
|
+
setServiceManager(serviceManager);
|
|
74
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
75
|
+
setReadonly(false);
|
|
76
|
+
setWaiting(false);
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case 4: {
|
|
81
|
+
setReadonly(false);
|
|
82
|
+
setWaiting(true);
|
|
83
|
+
setLite(false);
|
|
84
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
85
|
+
createDatalayerServiceManager(configuration?.gpuEnvironment || 'pytorch-cuda-env', configuration?.credits || 1).then(serviceManager => {
|
|
86
|
+
serviceManager['__NAME__'] = 'DatalayerGPUServiceManager';
|
|
87
|
+
setServiceManager(serviceManager);
|
|
88
|
+
setNbformat(notebook?.adapter?.notebookPanel?.content.model?.toJSON());
|
|
89
|
+
setReadonly(false);
|
|
90
|
+
setWaiting(false);
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return (_jsx(JupyterReactTheme, { children: _jsxs(_Fragment, { children: [_jsxs(Box, { display: "flex", children: [_jsx(Box, { children: _jsxs(SegmentedControl, { onChange: index => changeIndex(index), "aria-label": "jupyter-react-example", children: [_jsx(SegmentedControl.Button, { defaultSelected: index === 0, children: "Readonly" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 1, children: "Browser Kernel" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 2, children: "OSS Kernel (CPU)" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 3, children: "Kernel (CPU)" }), _jsx(SegmentedControl.Button, { defaultSelected: index === 4, children: "Kernel (GPU)" })] }) }), _jsxs(Box, { ml: 1, mt: 1, children: [_jsxs(Label, { children: ["Lite: ", String(notebook?.adapter?.lite)] }), _jsxs(Label, { children: ["Service Manager URL:", ' ', notebook?.adapter?.serviceManager.serverSettings.baseUrl] }), _jsxs(Label, { children: ["Service Manager is ready:", ' ', String(notebook?.adapter?.serviceManager.isReady)] }), _jsxs(Label, { children: ["Kernel ID: ", notebook?.adapter?.kernel?.id] }), _jsxs(Label, { children: ["Kernel Banner: ", notebook?.adapter?.kernel?.info?.banner] })] })] }), _jsx(Box, { children: _jsx(Text, { as: "h3", children: "Kernel Sessions" }) }), _jsx(Box, { children: sessions.map(session => {
|
|
97
|
+
return (_jsx(Box, { children: _jsxs(Text, { children: [session.name, " ", session.id, " ", _jsx(Label, { children: "Kernel" }), " clientId [", session.kernel?.clientId, ") - id ", session.kernel?.id] }) }, session.id));
|
|
98
|
+
}) }), waiting ? (_jsx(SpinnerCentered, {})) : (_jsx(Notebook, { height: "calc(100vh - 2.6rem)", id: NOTEBOOK_ID, lite: lite, nbformat: nbformat, onSessionConnection: onSessionConnection, readonly: readonly, serviceManager: serviceManager }))] }) }));
|
|
99
|
+
};
|
|
100
|
+
export default NotebookMutationsServiceManager;
|
|
101
|
+
// For standalone testing
|
|
102
|
+
if (typeof window !== 'undefined' && window.location.pathname === '/test') {
|
|
103
|
+
const div = document.createElement('div');
|
|
104
|
+
document.body.appendChild(div);
|
|
105
|
+
const root = createRoot(div);
|
|
106
|
+
root.render(_jsx(NotebookMutationsServiceManager, {}));
|
|
107
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import { BrowserRouter, Routes, Route, Link as RouterLink, NavLink, Outlet, Navigate, } from 'react-router-dom';
|
|
8
|
+
import { Box, Button, Heading, Text, TextInput } from '@primer/react';
|
|
9
|
+
import { useNavigate, useLocation, useParams, useHistory } from '../hooks';
|
|
10
|
+
/**
|
|
11
|
+
* Navigation Logger Component - Shows all navigation events
|
|
12
|
+
*/
|
|
13
|
+
const NavigationLogger = () => {
|
|
14
|
+
const [logs, setLogs] = useState([]);
|
|
15
|
+
const location = useLocation();
|
|
16
|
+
const params = useParams();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const log = `[${new Date().toLocaleTimeString()}] Navigated to ${location.pathname}${location.search}${location.hash} | Params: ${JSON.stringify(params)} | State: ${JSON.stringify(location.state)}`;
|
|
19
|
+
setLogs(prev => [...prev.slice(-9), log]);
|
|
20
|
+
}, [location, params]);
|
|
21
|
+
return (_jsxs(Box, { sx: {
|
|
22
|
+
p: 2,
|
|
23
|
+
mb: 3,
|
|
24
|
+
bg: 'canvas.subtle',
|
|
25
|
+
borderRadius: 2,
|
|
26
|
+
fontSize: 0,
|
|
27
|
+
fontFamily: 'mono',
|
|
28
|
+
maxHeight: 150,
|
|
29
|
+
overflowY: 'auto',
|
|
30
|
+
}, children: [_jsx(Text, { as: "div", sx: { fontWeight: 'bold', mb: 1 }, children: "Navigation Log:" }), logs.map((log, i) => (_jsx(Text, { as: "div", sx: { color: 'fg.muted' }, children: log }, i)))] }));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Navigation Controls - Test all navigation methods
|
|
34
|
+
*/
|
|
35
|
+
const NavigationControls = () => {
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const history = useHistory();
|
|
38
|
+
const location = useLocation();
|
|
39
|
+
const [customPath, setCustomPath] = useState('/custom');
|
|
40
|
+
const [stateValue, setStateValue] = useState('');
|
|
41
|
+
const handleNavigateWithState = () => {
|
|
42
|
+
navigate('/dashboard/analytics', {
|
|
43
|
+
state: { message: stateValue || 'Hello from navigation!' },
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const handleReplaceWithState = () => {
|
|
47
|
+
history.replace('/settings', { replaced: true, time: Date.now() });
|
|
48
|
+
};
|
|
49
|
+
const handleNavigateWithQuery = () => {
|
|
50
|
+
navigate('/search?q=react&category=framework');
|
|
51
|
+
};
|
|
52
|
+
const handleNavigateWithHash = () => {
|
|
53
|
+
navigate('/docs#installation');
|
|
54
|
+
};
|
|
55
|
+
const handleComplexNavigation = () => {
|
|
56
|
+
navigate('/products/123/reviews?sort=newest#review-42');
|
|
57
|
+
};
|
|
58
|
+
return (_jsxs(Box, { sx: {
|
|
59
|
+
p: 3,
|
|
60
|
+
borderWidth: 1,
|
|
61
|
+
borderStyle: 'solid',
|
|
62
|
+
borderColor: 'border.default',
|
|
63
|
+
borderRadius: 2,
|
|
64
|
+
mb: 3,
|
|
65
|
+
}, children: [_jsx(Heading, { as: "h3", sx: { mb: 3 }, children: "Navigation Controls" }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Text, { as: "label", sx: { display: 'block', mb: 1, fontSize: 1 }, children: "Custom Path:" }), _jsx(TextInput, { value: customPath, onChange: e => setCustomPath(e.target.value), sx: { mb: 2 } }), _jsx(Button, { onClick: () => navigate(customPath), sx: { mr: 2 }, children: "Navigate to Custom Path" })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Text, { as: "label", sx: { display: 'block', mb: 1, fontSize: 1 }, children: "State Value:" }), _jsx(TextInput, { value: stateValue, onChange: e => setStateValue(e.target.value), placeholder: "Enter state to pass", sx: { mb: 2 } }), _jsx(Button, { onClick: handleNavigateWithState, variant: "primary", children: "Navigate with State" })] }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap', mb: 3 }, children: [_jsx(Button, { onClick: () => history.back(), variant: "default", children: "\u2190 Back" }), _jsx(Button, { onClick: () => history.forward(), variant: "default", children: "Forward \u2192" }), _jsx(Button, { onClick: handleReplaceWithState, variant: "default", children: "Replace Current" }), _jsx(Button, { onClick: handleNavigateWithQuery, variant: "default", children: "Nav with Query" }), _jsx(Button, { onClick: handleNavigateWithHash, variant: "default", children: "Nav with Hash" }), _jsx(Button, { onClick: handleComplexNavigation, variant: "default", children: "Complex Navigation" })] }), _jsx(Box, { sx: { p: 2, bg: 'canvas.inset', borderRadius: 1 }, children: _jsxs(Text, { as: "div", sx: { fontSize: 0, fontFamily: 'mono' }, children: [_jsx("strong", { children: "Current Location:" }), _jsx("br", {}), "Path: ", location.pathname, _jsx("br", {}), "Search: ", location.search || '(none)', _jsx("br", {}), "Hash: ", location.hash || '(none)', _jsx("br", {}), "State: ", JSON.stringify(location.state) || '(none)'] }) })] }));
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Layout Component with Navigation Menu
|
|
69
|
+
*/
|
|
70
|
+
const Layout = () => {
|
|
71
|
+
return (_jsxs(Box, { children: [_jsx(Box, { as: "nav", sx: {
|
|
72
|
+
p: 3,
|
|
73
|
+
bg: 'canvas.subtle',
|
|
74
|
+
borderBottom: '1px solid',
|
|
75
|
+
borderColor: 'border.default',
|
|
76
|
+
mb: 3,
|
|
77
|
+
}, children: _jsxs(Box, { sx: { display: 'flex', gap: 3, flexWrap: 'wrap' }, children: [_jsx(NavLink, { to: "/", style: ({ isActive }) => ({
|
|
78
|
+
fontWeight: isActive ? 'bold' : 'normal',
|
|
79
|
+
color: isActive ? '#0969da' : 'inherit',
|
|
80
|
+
textDecoration: 'none',
|
|
81
|
+
}), children: "Home" }), _jsx(NavLink, { to: "/dashboard", style: ({ isActive }) => ({
|
|
82
|
+
fontWeight: isActive ? 'bold' : 'normal',
|
|
83
|
+
color: isActive ? '#0969da' : 'inherit',
|
|
84
|
+
textDecoration: 'none',
|
|
85
|
+
}), children: "Dashboard" }), _jsx(NavLink, { to: "/products", style: ({ isActive }) => ({
|
|
86
|
+
fontWeight: isActive ? 'bold' : 'normal',
|
|
87
|
+
color: isActive ? '#0969da' : 'inherit',
|
|
88
|
+
textDecoration: 'none',
|
|
89
|
+
}), children: "Products" }), _jsx(NavLink, { to: "/users/john-doe", style: ({ isActive }) => ({
|
|
90
|
+
fontWeight: isActive ? 'bold' : 'normal',
|
|
91
|
+
color: isActive ? '#0969da' : 'inherit',
|
|
92
|
+
textDecoration: 'none',
|
|
93
|
+
}), children: "User Profile" }), _jsx(NavLink, { to: "/settings", style: ({ isActive }) => ({
|
|
94
|
+
fontWeight: isActive ? 'bold' : 'normal',
|
|
95
|
+
color: isActive ? '#0969da' : 'inherit',
|
|
96
|
+
textDecoration: 'none',
|
|
97
|
+
}), children: "Settings" })] }) }), _jsx(NavigationLogger, {}), _jsx(NavigationControls, {}), _jsx(Box, { sx: {
|
|
98
|
+
p: 3,
|
|
99
|
+
borderWidth: 1,
|
|
100
|
+
borderStyle: 'solid',
|
|
101
|
+
borderColor: 'border.default',
|
|
102
|
+
borderRadius: 2,
|
|
103
|
+
minHeight: 200,
|
|
104
|
+
}, children: _jsx(Outlet, {}) })] }));
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Page Components
|
|
108
|
+
*/
|
|
109
|
+
const HomePage = () => (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Home Page" }), _jsx(Text, { as: "p", children: "Welcome to the comprehensive React Router example. This demonstrates:" }), _jsxs("ul", { children: [_jsx("li", { children: "Programmatic navigation with useNavigate" }), _jsx("li", { children: "Route parameters with useParams" }), _jsx("li", { children: "Query parameters and hash navigation" }), _jsx("li", { children: "Navigation state passing" }), _jsx("li", { children: "Browser history (back/forward)" }), _jsx("li", { children: "Nested routes" }), _jsx("li", { children: "Protected routes" }), _jsx("li", { children: "Active link styling" })] })] }));
|
|
110
|
+
const DashboardLayout = () => (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Dashboard" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, mb: 3 }, children: [_jsx(RouterLink, { to: "/dashboard", children: "Overview" }), _jsx(RouterLink, { to: "/dashboard/analytics", children: "Analytics" }), _jsx(RouterLink, { to: "/dashboard/reports", children: "Reports" })] }), _jsx(Outlet, {})] }));
|
|
111
|
+
const DashboardOverview = () => {
|
|
112
|
+
const location = useLocation();
|
|
113
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h2", sx: { mb: 2 }, children: "Overview" }), location.state && (_jsx(Box, { sx: { p: 2, bg: 'success.subtle', borderRadius: 1, mb: 2 }, children: _jsxs(Text, { children: ["State received: ", JSON.stringify(location.state)] }) })), _jsx(Text, { children: "Dashboard overview content here..." })] }));
|
|
114
|
+
};
|
|
115
|
+
const DashboardAnalytics = () => {
|
|
116
|
+
const location = useLocation();
|
|
117
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h2", sx: { mb: 2 }, children: "Analytics" }), location.state && (_jsx(Box, { sx: { p: 2, bg: 'success.subtle', borderRadius: 1, mb: 2 }, children: _jsxs(Text, { children: ["State received: ", JSON.stringify(location.state)] }) })), _jsx(Text, { children: "Analytics data visualization would go here..." })] }));
|
|
118
|
+
};
|
|
119
|
+
const DashboardReports = () => (_jsxs(Box, { children: [_jsx(Heading, { as: "h2", sx: { mb: 2 }, children: "Reports" }), _jsx(Text, { children: "Reports section content..." })] }));
|
|
120
|
+
const ProductList = () => {
|
|
121
|
+
const navigate = useNavigate();
|
|
122
|
+
const products = [
|
|
123
|
+
{ id: 1, name: 'Product A' },
|
|
124
|
+
{ id: 2, name: 'Product B' },
|
|
125
|
+
{ id: 3, name: 'Product C' },
|
|
126
|
+
];
|
|
127
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Products" }), _jsx(Box, { sx: { display: 'grid', gap: 2 }, children: products.map(product => (_jsxs(Button, { onClick: () => navigate(`/products/${product.id}`), variant: "default", sx: { justifyContent: 'flex-start' }, children: [product.name, " \u2192"] }, product.id))) })] }));
|
|
128
|
+
};
|
|
129
|
+
const ProductDetail = () => {
|
|
130
|
+
const params = useParams();
|
|
131
|
+
const navigate = useNavigate();
|
|
132
|
+
return (_jsxs(Box, { children: [_jsx(Button, { onClick: () => navigate('/products'), variant: "default", sx: { mb: 3 }, children: "\u2190 Back to Products" }), _jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Product Details" }), _jsxs(Text, { as: "p", children: ["Product ID: ", params.id] }), _jsxs(Text, { as: "p", children: ["All params: ", JSON.stringify(params)] }), _jsx(Box, { sx: { mt: 3 }, children: _jsx(Button, { onClick: () => navigate(`/products/${params.id}/reviews`), variant: "primary", children: "View Reviews" }) })] }));
|
|
133
|
+
};
|
|
134
|
+
const ProductReviews = () => {
|
|
135
|
+
const params = useParams();
|
|
136
|
+
const location = useLocation();
|
|
137
|
+
return (_jsxs(Box, { children: [_jsxs(Heading, { as: "h1", sx: { mb: 2 }, children: ["Reviews for Product ", params.id] }), _jsxs(Text, { as: "p", children: ["Query params: ", location.search] }), _jsxs(Text, { as: "p", children: ["Hash: ", location.hash] })] }));
|
|
138
|
+
};
|
|
139
|
+
const UserProfile = () => {
|
|
140
|
+
const params = useParams();
|
|
141
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "User Profile" }), _jsxs(Text, { children: ["Username: ", params.username] })] }));
|
|
142
|
+
};
|
|
143
|
+
const SearchPage = () => {
|
|
144
|
+
const location = useLocation();
|
|
145
|
+
const searchParams = new URLSearchParams(location.search);
|
|
146
|
+
const query = searchParams.get('q');
|
|
147
|
+
const category = searchParams.get('category');
|
|
148
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Search Results" }), _jsxs(Text, { as: "p", children: ["Query: ", query || '(none)'] }), _jsxs(Text, { as: "p", children: ["Category: ", category || '(none)'] }), _jsxs(Text, { as: "p", children: ["Full search string: ", location.search] })] }));
|
|
149
|
+
};
|
|
150
|
+
const DocsPage = () => {
|
|
151
|
+
const location = useLocation();
|
|
152
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Documentation" }), _jsxs(Text, { as: "p", children: ["Current hash: ", location.hash || '(none)'] }), location.hash === '#installation' && (_jsxs(Box, { sx: { p: 2, bg: 'attention.subtle', borderRadius: 1, mt: 2 }, children: [_jsx(Heading, { as: "h2", sx: { mb: 1 }, children: "Installation" }), _jsx(Text, { children: "Installation instructions would be here..." })] }))] }));
|
|
153
|
+
};
|
|
154
|
+
const SettingsPage = () => {
|
|
155
|
+
const location = useLocation();
|
|
156
|
+
return (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Settings" }), location.state?.replaced && (_jsxs(Box, { sx: { p: 2, bg: 'attention.subtle', borderRadius: 1, mb: 2 }, children: [_jsx(Text, { children: "This page replaced the previous history entry!" }), _jsxs(Text, { children: ["Time: ", new Date(location.state.time).toLocaleTimeString()] })] })), _jsx(Text, { children: "Settings configuration would go here..." })] }));
|
|
157
|
+
};
|
|
158
|
+
const NotFound = () => (_jsxs(Box, { children: [_jsx(Heading, { as: "h1", sx: { mb: 2, color: 'danger.fg' }, children: "404 - Not Found" }), _jsx(Text, { children: "The page you're looking for doesn't exist." })] }));
|
|
159
|
+
/**
|
|
160
|
+
* Protected Route Component
|
|
161
|
+
*/
|
|
162
|
+
const ProtectedRoute = ({ children, }) => {
|
|
163
|
+
const [isAuthenticated] = useState(true); // Simulate authentication
|
|
164
|
+
if (!isAuthenticated) {
|
|
165
|
+
return _jsx(Navigate, { to: "/", replace: true });
|
|
166
|
+
}
|
|
167
|
+
return _jsx(_Fragment, { children: children });
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Main App Component - Advanced React Router Example
|
|
171
|
+
*/
|
|
172
|
+
export const ReactRouterAdvancedExample = () => {
|
|
173
|
+
return (_jsx(BrowserRouter, { children: _jsxs(Box, { sx: { minHeight: '100vh', p: 4 }, children: [_jsxs(Box, { sx: { mb: 4, p: 3, bg: 'canvas.subtle', borderRadius: 2 }, children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Advanced React Router Navigation Example" }), _jsx(Text, { as: "p", sx: { mb: 2 }, children: "This comprehensive example demonstrates all navigation features working with our custom hooks that detect and use React Router." }), _jsx(Text, { as: "p", sx: { color: 'success.fg', fontWeight: 'bold' }, children: "\u2713 React Router detected and integrated with Datalayer SDK hooks" })] }), _jsx(Routes, { children: _jsxs(Route, { path: "/", element: _jsx(Layout, {}), children: [_jsx(Route, { index: true, element: _jsx(HomePage, {}) }), _jsxs(Route, { path: "dashboard", element: _jsx(DashboardLayout, {}), children: [_jsx(Route, { index: true, element: _jsx(DashboardOverview, {}) }), _jsx(Route, { path: "analytics", element: _jsx(DashboardAnalytics, {}) }), _jsx(Route, { path: "reports", element: _jsx(DashboardReports, {}) })] }), _jsx(Route, { path: "products/:id/reviews", element: _jsx(ProductReviews, {}) }), _jsx(Route, { path: "products/:id", element: _jsx(ProductDetail, {}) }), _jsx(Route, { path: "products", element: _jsx(ProductList, {}) }), _jsx(Route, { path: "users/:username", element: _jsx(UserProfile, {}) }), _jsx(Route, { path: "search", element: _jsx(SearchPage, {}) }), _jsx(Route, { path: "docs", element: _jsx(DocsPage, {}) }), _jsx(Route, { path: "settings", element: _jsx(ProtectedRoute, { children: _jsx(SettingsPage, {}) }) }), _jsx(Route, { path: "custom", element: _jsx(HomePage, {}) }), _jsx(Route, { path: "*", element: _jsx(NotFound, {}) })] }) })] }) }));
|
|
174
|
+
};
|
|
175
|
+
export default ReactRouterAdvancedExample;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of available examples with dynamic imports.
|
|
3
|
+
* Add new examples here to make them available in the example runner.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EXAMPLES: Record<string, () => Promise<{
|
|
6
|
+
default: React.ComponentType;
|
|
7
|
+
}>>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the list of available example names
|
|
10
|
+
*/
|
|
11
|
+
export declare function getExampleNames(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Get the selected example based on environment variable
|
|
14
|
+
* Falls back to 'NotebookExample' if not specified or invalid
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSelectedExample(): () => Promise<{
|
|
17
|
+
default: React.ComponentType;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the selected example name
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSelectedExampleName(): string;
|