@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
|
@@ -3,22 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs } 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
6
|
import { useCallback, useMemo, useState } from 'react';
|
|
12
7
|
import { nullTranslator } from '@jupyterlab/translation';
|
|
13
8
|
import { FormControl, Select, Text } from '@primer/react';
|
|
14
|
-
import { Box } from
|
|
9
|
+
import { Box } from '@datalayer/primer-addons';
|
|
15
10
|
import { Dialog } from '@primer/react/experimental';
|
|
16
11
|
import { Markdown } from '../display';
|
|
17
12
|
/**
|
|
18
13
|
* Dialog to inject snippet in a cell.
|
|
19
14
|
*/
|
|
20
15
|
export function SnippetDialog(props) {
|
|
21
|
-
const { model, onClose, language, snippets, markdownParser, sanitizer, translator } = props;
|
|
16
|
+
const { model, onClose, language, snippets, markdownParser, sanitizer, translator, } = props;
|
|
22
17
|
const [selection, setSelection] = useState(snippets[0]);
|
|
23
18
|
const trans = useMemo(() => (translator ?? nullTranslator).load('jupyterlab'), [translator]);
|
|
24
19
|
const onSelectionChange = useCallback((e) => {
|
|
@@ -34,14 +29,14 @@ export function SnippetDialog(props) {
|
|
|
34
29
|
{
|
|
35
30
|
buttonType: 'default',
|
|
36
31
|
content: trans.__('Cancel'),
|
|
37
|
-
onClick: onClose
|
|
32
|
+
onClick: onClose,
|
|
38
33
|
},
|
|
39
34
|
{
|
|
40
35
|
buttonType: 'primary',
|
|
41
36
|
content: trans.__('Inject snippet'),
|
|
42
37
|
onClick: injectSnippet,
|
|
43
|
-
autoFocus: true
|
|
44
|
-
}
|
|
38
|
+
autoFocus: true,
|
|
39
|
+
},
|
|
45
40
|
], children: _jsx(Box, { as: "form", children: _jsxs(FormControl, { children: [_jsx(FormControl.Label, {}), _jsx(Select, { block: true, onChange: onSelectionChange, children: snippets.map((snippet, index) => (_jsx(Select.Option, { value: `${index}`, children: snippet.title }, index))) }), _jsxs(FormControl.Caption, { children: [selection.description && (_jsx(Text, { as: "p", children: selection.description })), markdownParser ? (_jsx(Markdown, { markdownParser: markdownParser, sanitizer: sanitizer, text: `\`\`\`${language}\n${selection.code}\`\`\`` })) : (_jsx("code", { children: selection.code }))] })] }) }) }));
|
|
46
41
|
}
|
|
47
42
|
export default SnippetDialog;
|
|
@@ -3,22 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
8
|
-
*
|
|
9
|
-
* Datalayer License
|
|
10
|
-
*/
|
|
11
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
12
7
|
import { PathExt } from '@jupyterlab/coreutils';
|
|
13
8
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
14
|
-
import { ActionList, ActionMenu, Heading, IconButton, Spinner, TreeView } from '@primer/react';
|
|
15
|
-
import { Box } from
|
|
9
|
+
import { ActionList, ActionMenu, Heading, IconButton, Spinner, TreeView, } from '@primer/react';
|
|
10
|
+
import { Box } from '@datalayer/primer-addons';
|
|
16
11
|
import { Blankslate, Dialog } from '@primer/react/experimental';
|
|
17
12
|
import { CounterClockWiseIcon } from '@datalayer/icons-react';
|
|
18
13
|
import { useIsMounted } from 'usehooks-ts';
|
|
19
14
|
import { useToast } from '../../hooks';
|
|
20
15
|
import { UploadIconButton } from '../buttons';
|
|
21
|
-
import { DirectoryItem, TreeItem, modelToView } from './ContentsItems';
|
|
16
|
+
import { DirectoryItem, TreeItem, modelToView, } from './ContentsItems';
|
|
22
17
|
/**
|
|
23
18
|
* The maximum upload size (in bytes) for notebook version < 5.1.0
|
|
24
19
|
*/
|
|
@@ -41,7 +36,8 @@ export function ContentsBrowser(props) {
|
|
|
41
36
|
const [openDeleteConfirmation, setOpenDeleteConfirmation] = useState(false);
|
|
42
37
|
const [copyToLocalConfirmation, setCopyToLocalConfirmation] = useState(false);
|
|
43
38
|
const refresh = useCallback(() => {
|
|
44
|
-
contents
|
|
39
|
+
contents
|
|
40
|
+
.get('')
|
|
45
41
|
.then(model => {
|
|
46
42
|
setIsLoading(false);
|
|
47
43
|
setChildren(modelToView(model.content, documentRegistry));
|
|
@@ -103,10 +99,10 @@ export function ContentsBrowser(props) {
|
|
|
103
99
|
const msg = `Failed to upload ${file.name}.`;
|
|
104
100
|
console.error(msg, reason);
|
|
105
101
|
return msg;
|
|
106
|
-
}
|
|
102
|
+
},
|
|
107
103
|
},
|
|
108
104
|
pending: { message: `Uploading ${file.name}…` },
|
|
109
|
-
success: { message: () => `${file.name} uploaded.` }
|
|
105
|
+
success: { message: () => `${file.name} uploaded.` },
|
|
110
106
|
};
|
|
111
107
|
if (chunked) {
|
|
112
108
|
const task = new PromiseDelegate();
|
|
@@ -123,7 +119,12 @@ export function ContentsBrowser(props) {
|
|
|
123
119
|
task.resolve(finalModel);
|
|
124
120
|
}
|
|
125
121
|
}
|
|
126
|
-
|
|
122
|
+
if (selectedItem) {
|
|
123
|
+
selectedItem.refresh();
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
refresh();
|
|
127
|
+
}
|
|
127
128
|
return finalModel;
|
|
128
129
|
}
|
|
129
130
|
catch (error) {
|
|
@@ -135,7 +136,12 @@ export function ContentsBrowser(props) {
|
|
|
135
136
|
const task = uploadChunk(file);
|
|
136
137
|
trackAsyncTask(task, toastOptions);
|
|
137
138
|
task.then(() => {
|
|
138
|
-
|
|
139
|
+
if (selectedItem) {
|
|
140
|
+
selectedItem.refresh();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
refresh();
|
|
144
|
+
}
|
|
139
145
|
});
|
|
140
146
|
return task;
|
|
141
147
|
}
|
|
@@ -157,11 +163,12 @@ export function ContentsBrowser(props) {
|
|
|
157
163
|
trackAsyncTask(task, {
|
|
158
164
|
success: { message: () => `${selectedItem.path} deleted.` },
|
|
159
165
|
pending: { message: `Deleting ${selectedItem.path}…` },
|
|
160
|
-
error: {
|
|
166
|
+
error: {
|
|
167
|
+
message: reason => {
|
|
161
168
|
const msg = `Failed to delete ${selectedItem.path}.`;
|
|
162
169
|
console.error(msg, reason);
|
|
163
170
|
return msg;
|
|
164
|
-
}
|
|
171
|
+
},
|
|
165
172
|
},
|
|
166
173
|
});
|
|
167
174
|
task.finally(() => {
|
|
@@ -175,16 +182,17 @@ export function ContentsBrowser(props) {
|
|
|
175
182
|
}, []);
|
|
176
183
|
const copyToLocal = useCallback(() => {
|
|
177
184
|
if (selectedItem && localContents) {
|
|
178
|
-
contents.get(selectedItem.path).then(
|
|
185
|
+
contents.get(selectedItem.path).then(model => {
|
|
179
186
|
const copyTask = localContents?.save(model.path, model);
|
|
180
187
|
trackAsyncTask(copyTask, {
|
|
181
188
|
success: { message: () => `${selectedItem.path} copied to local.` },
|
|
182
189
|
pending: { message: `Copying to local ${selectedItem.path}…` },
|
|
183
|
-
error: {
|
|
190
|
+
error: {
|
|
191
|
+
message: reason => {
|
|
184
192
|
const msg = `Failed to copy to local ${selectedItem.path}.`;
|
|
185
193
|
console.error(msg, reason);
|
|
186
194
|
return msg;
|
|
187
|
-
}
|
|
195
|
+
},
|
|
188
196
|
},
|
|
189
197
|
});
|
|
190
198
|
copyTask.finally(() => {
|
|
@@ -201,50 +209,54 @@ export function ContentsBrowser(props) {
|
|
|
201
209
|
fontSize: 'var(--text-title-size-small)',
|
|
202
210
|
lineHeight: 'var(--text-title-lineHeight-medium)',
|
|
203
211
|
fontWeight: 'var(--text-title-weight-medium)',
|
|
204
|
-
flex: '1 1 auto'
|
|
205
|
-
}, children: "Contents Browser" }), _jsxs(Box, { children: [_jsx(IconButton, { variant: "invisible", "aria-label": 'Refresh contents browser.', title: 'Refresh contents browser.', icon: CounterClockWiseIcon, onClick: refresh }), _jsx(UploadIconButton, { label: 'Upload a file', multiple: true, upload: upload })] })] }), isLoading ?
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
212
|
+
flex: '1 1 auto',
|
|
213
|
+
}, children: "Contents Browser" }), _jsxs(Box, { children: [_jsx(IconButton, { variant: "invisible", "aria-label": 'Refresh contents browser.', title: 'Refresh contents browser.', icon: CounterClockWiseIcon, onClick: refresh }), _jsx(UploadIconButton, { label: 'Upload a file', multiple: true, upload: upload })] })] }), isLoading ? (_jsx(Box, { sx: {
|
|
214
|
+
gridArea: 'content',
|
|
215
|
+
display: 'flex',
|
|
216
|
+
alignItems: 'center',
|
|
217
|
+
justifyContent: 'center',
|
|
218
|
+
minHeight: '40px',
|
|
219
|
+
height: '100vh',
|
|
220
|
+
}, children: _jsx(Spinner, {}) })) : (_jsx(Box, { sx: { gridArea: 'content' }, children: children ? (_jsxs(_Fragment, { children: [_jsx(TreeView, { children: children?.map(child => {
|
|
221
|
+
return child.type === 'directory' ? (_jsx(DirectoryItem, { item: child, contents: contents, current: selectedItem, documentRegistry: documentRegistry, onContextMenu: onContextMenu, onSelect: onSelect }, child.name)) : (_jsx(TreeItem, { item: child, current: selectedItem?.path === child.path, onSelect: item => {
|
|
222
|
+
onSelect(item, refresh);
|
|
223
|
+
}, onContextMenu: onContextMenu }, child.name));
|
|
224
|
+
}) }), _jsx(ActionMenu, { anchorRef: contextMenuAnchor ?? undefined, open: contextMenuAnchor?.current !== null, onOpenChange: () => {
|
|
225
|
+
setContextMenuAnchor(null);
|
|
226
|
+
}, children: _jsx(ActionMenu.Overlay, { children: _jsxs(ActionList, { children: [_jsx(ActionList.Item, { title: "Delete the active item.", onSelect: onSelectDelete, children: "Delete\u2026" }), localContents && (_jsx(ActionList.Item, { title: "Copy the active item to the local drive.", onSelect: onSelectCopyToLocal, children: "Copy to local drive\u2026" }))] }) }) }), openDeleteConfirmation && (_jsx(Dialog, { title: "Confirm deletion", onClose: () => {
|
|
227
|
+
setOpenDeleteConfirmation(false);
|
|
228
|
+
}, footerButtons: [
|
|
229
|
+
{
|
|
230
|
+
buttonType: 'default',
|
|
231
|
+
content: 'Cancel',
|
|
232
|
+
onClick: () => {
|
|
233
|
+
setOpenDeleteConfirmation(false);
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
buttonType: 'danger',
|
|
238
|
+
content: 'Delete',
|
|
239
|
+
onClick: () => {
|
|
240
|
+
deleteItem();
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
], children: `Are you sure you want to delete ${selectedItem?.path}?` })), copyToLocalConfirmation && (_jsx(Dialog, { title: "Confirm copy to local", onClose: () => {
|
|
244
|
+
setCopyToLocalConfirmation(false);
|
|
245
|
+
}, footerButtons: [
|
|
246
|
+
{
|
|
247
|
+
buttonType: 'default',
|
|
248
|
+
content: 'Cancel',
|
|
249
|
+
onClick: () => {
|
|
250
|
+
setCopyToLocalConfirmation(false);
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
buttonType: 'danger',
|
|
255
|
+
content: 'Copy to local',
|
|
256
|
+
onClick: () => {
|
|
257
|
+
copyToLocal();
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
], children: `Are you sure you want to copy to local ${selectedItem?.path}?` }))] })) : (_jsx(Blankslate, { children: _jsx(Blankslate.Heading, { children: "No contents" }) })) }))] }));
|
|
249
261
|
}
|
|
250
262
|
export default ContentsBrowser;
|
|
@@ -3,18 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } 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
6
|
import { useCallback, useRef, useState } from 'react';
|
|
12
7
|
import { TreeView } from '@primer/react';
|
|
13
8
|
import { FileIcon } from '@primer/octicons-react';
|
|
14
9
|
export function modelToView(models, docRegistry) {
|
|
15
10
|
let items = models.map(model => ({
|
|
16
11
|
...model,
|
|
17
|
-
fileType: docRegistry?.getFileTypeForModel(model)
|
|
12
|
+
fileType: docRegistry?.getFileTypeForModel(model),
|
|
18
13
|
}));
|
|
19
14
|
items = items.filter(model => !model.name.startsWith('.'));
|
|
20
15
|
items.sort((a, b) => {
|
|
@@ -38,7 +33,8 @@ export function DirectoryItem(props) {
|
|
|
38
33
|
const [isLoading, setIsLoading] = useState(false);
|
|
39
34
|
const refresh = useCallback(() => {
|
|
40
35
|
setIsLoading(true);
|
|
41
|
-
contents
|
|
36
|
+
contents
|
|
37
|
+
.get(item.path)
|
|
42
38
|
.then(model => {
|
|
43
39
|
setIsLoading(false);
|
|
44
40
|
setChildren(modelToView(model.content, documentRegistry));
|
|
@@ -52,7 +48,9 @@ export function DirectoryItem(props) {
|
|
|
52
48
|
refresh();
|
|
53
49
|
}
|
|
54
50
|
}, [children, item, contents]);
|
|
55
|
-
return (_jsxs(TreeView.Item, { ref: ref, id: `${item.type}-${item.name}`, onExpandedChange: onExpandedChange, onSelect: () => {
|
|
51
|
+
return (_jsxs(TreeView.Item, { ref: ref, id: `${item.type}-${item.name}`, onExpandedChange: onExpandedChange, onSelect: () => {
|
|
52
|
+
onSelect(item, refresh);
|
|
53
|
+
}, current: item.path === current?.path, children: [_jsx(TreeView.LeadingVisual, { children: _jsx(TreeView.DirectoryIcon, {}) }), _jsx("span", { onContextMenu: event => {
|
|
56
54
|
event.preventDefault();
|
|
57
55
|
if (current?.path !== item.path) {
|
|
58
56
|
onSelect(item, refresh);
|
|
@@ -63,17 +61,16 @@ export function DirectoryItem(props) {
|
|
|
63
61
|
: (children?.length ?? -1) >= 0
|
|
64
62
|
? 'done'
|
|
65
63
|
: 'initial', children: children?.map(child => {
|
|
66
|
-
return child.type === 'directory' ?
|
|
67
|
-
_jsx(DirectoryItem, { item: child, contents: contents, current: current, documentRegistry: documentRegistry, onContextMenu: onContextMenu, onSelect: onSelect }, child.name)
|
|
68
|
-
:
|
|
69
|
-
_jsx(TreeItem, { item: child, current: child.path === current?.path, onSelect: item => onSelect(item, refresh), onContextMenu: onContextMenu }, child.name);
|
|
64
|
+
return child.type === 'directory' ? (_jsx(DirectoryItem, { item: child, contents: contents, current: current, documentRegistry: documentRegistry, onContextMenu: onContextMenu, onSelect: onSelect }, child.name)) : (_jsx(TreeItem, { item: child, current: child.path === current?.path, onSelect: item => onSelect(item, refresh), onContextMenu: onContextMenu }, child.name));
|
|
70
65
|
}) })] }));
|
|
71
66
|
}
|
|
72
67
|
export function TreeItem(props) {
|
|
73
68
|
const { item, current, onSelect, onContextMenu } = props;
|
|
74
69
|
const ref = useRef(null);
|
|
75
70
|
const icon = item.fileType?.icon;
|
|
76
|
-
return (_jsxs(TreeView.Item, { ref: ref, id: `${item.type}-${item.name}`, current: current, onSelect: () => {
|
|
71
|
+
return (_jsxs(TreeView.Item, { ref: ref, id: `${item.type}-${item.name}`, current: current, onSelect: () => {
|
|
72
|
+
onSelect(item);
|
|
73
|
+
}, children: [_jsx(TreeView.LeadingVisual, { children: icon ? _jsx(icon.react, { tag: 'span' }) : _jsx(FileIcon, {}) }), _jsx("span", { onContextMenu: event => {
|
|
77
74
|
event.preventDefault();
|
|
78
75
|
if (!current) {
|
|
79
76
|
onSelect(item);
|
|
@@ -2,10 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
-
*
|
|
8
|
-
* Datalayer License
|
|
9
|
-
*/
|
|
10
5
|
export * from './ContentsBrowser';
|
|
11
6
|
export * from './ContentsItems';
|
|
@@ -3,14 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Datalayer License
|
|
10
|
-
*/
|
|
11
|
-
import { useMemo } from "react";
|
|
12
|
-
import { useTheme, Tooltip, Button } from "@primer/react";
|
|
13
|
-
import { Box } from "@datalayer/primer-addons";
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { useTheme, Tooltip, Button } from '@primer/react';
|
|
8
|
+
import { Box } from '@datalayer/primer-addons';
|
|
14
9
|
const getExercisePoints = (studentItem) => {
|
|
15
10
|
if (studentItem && studentItem.points) {
|
|
16
11
|
return studentItem.points;
|
|
@@ -24,22 +19,44 @@ export const StudentItemStatus = (props) => {
|
|
|
24
19
|
const nokColor = useMemo(() => theme?.colorSchemes.light.colors.severe.muted, []);
|
|
25
20
|
if (student && studentItem) {
|
|
26
21
|
switch (studentItem.itemType) {
|
|
27
|
-
case
|
|
22
|
+
case 'dataset': {
|
|
28
23
|
const datasetColor = studentItem?.completed ? okColor : nokColor;
|
|
29
|
-
return _jsx(Box, { sx: {
|
|
30
|
-
|
|
24
|
+
return (_jsx(Box, { sx: {
|
|
25
|
+
backgroundColor: datasetColor,
|
|
26
|
+
width: '14px',
|
|
27
|
+
height: '14px',
|
|
28
|
+
borderRadius: 3,
|
|
29
|
+
}, ml: 1 }));
|
|
30
|
+
}
|
|
31
|
+
case 'lesson': {
|
|
31
32
|
const lessonColor = studentItem?.completed ? okColor : nokColor;
|
|
32
|
-
return _jsx(Box, { sx: {
|
|
33
|
-
|
|
33
|
+
return (_jsx(Box, { sx: {
|
|
34
|
+
backgroundColor: lessonColor,
|
|
35
|
+
width: '14px',
|
|
36
|
+
height: '14px',
|
|
37
|
+
borderRadius: 3,
|
|
38
|
+
}, ml: 1 }));
|
|
39
|
+
}
|
|
40
|
+
case 'exercise': {
|
|
34
41
|
const exerciseColor = getExercisePoints(studentItem) > 0 ? okColor : nokColor;
|
|
35
|
-
return _jsx(Box, { sx: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
return (_jsx(Box, { sx: {
|
|
43
|
+
backgroundColor: exerciseColor,
|
|
44
|
+
width: '14px',
|
|
45
|
+
height: '14px',
|
|
46
|
+
borderRadius: 3,
|
|
47
|
+
}, ml: 1 }));
|
|
48
|
+
}
|
|
49
|
+
case 'assignment':
|
|
50
|
+
return (_jsxs(Box, { display: "flex", children: [studentItem.nbgradesTotalScore !== undefined &&
|
|
51
|
+
studentItem.nbgradesTotalPoints !== undefined && (_jsxs(Box, { children: [studentItem.nbgradesTotalScore, " /", ' ', studentItem.nbgradesTotalPoints] })), studentItem.nbgrades && (_jsx(Box, { display: "flex", ml: 3, children: studentItem?.nbgrades.map(grade => {
|
|
52
|
+
const gradeColor = grade.score_f === grade.points_f ? okColor : nokColor;
|
|
53
|
+
return (_jsx(Tooltip, { text: grade.grade_id_s, children: _jsx(Button, { variant: "invisible", children: _jsx(Box, { sx: {
|
|
54
|
+
backgroundColor: gradeColor,
|
|
55
|
+
width: '14px',
|
|
56
|
+
height: '14px',
|
|
57
|
+
borderRadius: 3,
|
|
58
|
+
}, ml: 1 }) }) }));
|
|
59
|
+
}) }))] }));
|
|
43
60
|
default:
|
|
44
61
|
return _jsx(_Fragment, {});
|
|
45
62
|
}
|
|
@@ -34,7 +34,7 @@ type SubNavLinkProps = {
|
|
|
34
34
|
type SubMenuProps = {
|
|
35
35
|
variant?: SubMenuVariants;
|
|
36
36
|
} & React.HTMLAttributes<HTMLUListElement> & BaseProps<HTMLUListElement>;
|
|
37
|
-
declare function
|
|
37
|
+
declare function SubMenu({ children, className, variant, ...props }: SubMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
38
38
|
type SubNavActionProps = {
|
|
39
39
|
/**
|
|
40
40
|
* Required path or location for the action button to link to.
|
|
@@ -65,12 +65,12 @@ export declare const SubNav: React.NamedExoticComponent<{
|
|
|
65
65
|
} & BaseProps<HTMLElement> & {
|
|
66
66
|
children?: ReactNode | undefined;
|
|
67
67
|
}> & {
|
|
68
|
-
readonly type: ({ id, children, className, "data-testid": testId, fullWidth, hasShadow }: SubNavProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
readonly type: ({ id, children, className, "data-testid": testId, fullWidth, hasShadow, }: SubNavProps) => import("react/jsx-runtime").JSX.Element;
|
|
69
69
|
} & {
|
|
70
70
|
Heading: ({ href, children, className, "data-testid": testID, ...props }: SubNavHeadingProps) => import("react/jsx-runtime").JSX.Element;
|
|
71
71
|
Link: React.ForwardRefExoticComponent<Omit<SubNavLinkProps, "ref"> & React.RefAttributes<HTMLDivElement | HTMLAnchorElement>>;
|
|
72
72
|
Action: typeof _SubNavAction;
|
|
73
|
-
SubMenu: typeof
|
|
73
|
+
SubMenu: typeof SubMenu;
|
|
74
74
|
testIds: {
|
|
75
75
|
root: string;
|
|
76
76
|
readonly button: string;
|
|
@@ -3,18 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } 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
6
|
import React, { Children, createContext, forwardRef, isValidElement, memo, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
12
7
|
import { createPortal } from 'react-dom';
|
|
13
|
-
import { Button, ButtonGroup, Text, ThemeProvider, useWindowSize } from '@primer/react-brand';
|
|
8
|
+
import { Button, ButtonGroup, Text, ThemeProvider, useWindowSize, } from '@primer/react-brand';
|
|
14
9
|
import { ChevronDownIcon, ChevronUpIcon } from '@primer/octicons-react';
|
|
15
10
|
import { default as clsx } from 'clsx';
|
|
16
11
|
import { useId } from '../../hooks';
|
|
17
|
-
import { useKeyboardEscape, useOnClickOutside, useProvidedRefOrCreate, useContainsFocus } from '../../hooks';
|
|
12
|
+
import { useKeyboardEscape, useOnClickOutside, useProvidedRefOrCreate, useContainsFocus, } from '../../hooks';
|
|
18
13
|
/**
|
|
19
14
|
* Design tokens
|
|
20
15
|
*/
|
|
@@ -74,7 +69,7 @@ function SubNavProvider({ children }) {
|
|
|
74
69
|
}, []);
|
|
75
70
|
return (_jsxs(SubNavContext.Provider, { value: value, children: [children, _jsx("div", { className: styles['SubNav__anchor-menu-outer-container'], ref: anchoredNavOuterPortalRef, children: _jsx("div", { className: clsx(styles['SubNav__anchor-menu-container']), ref: anchoredNavPortalRef }) })] }));
|
|
76
71
|
}
|
|
77
|
-
const _SubNavRoot = memo(({ id, children, className, 'data-testid': testId, fullWidth, hasShadow }) => {
|
|
72
|
+
const _SubNavRoot = memo(({ id, children, className, 'data-testid': testId, fullWidth, hasShadow, }) => {
|
|
78
73
|
const rootRef = React.useRef(null);
|
|
79
74
|
const navRef = React.useRef(null);
|
|
80
75
|
const overlayRef = React.useRef(null);
|
|
@@ -130,12 +125,16 @@ const _SubNavRoot = memo(({ id, children, className, 'data-testid': testId, full
|
|
|
130
125
|
if (subMenu?.props?.variant === 'anchor') {
|
|
131
126
|
acc.links.push(React.cloneElement(child, {
|
|
132
127
|
children: [link],
|
|
133
|
-
onClick: child.props['aria-current']
|
|
128
|
+
onClick: child.props['aria-current']
|
|
129
|
+
? closeMenuCallback
|
|
130
|
+
: child.props.onClick,
|
|
134
131
|
}));
|
|
135
132
|
}
|
|
136
133
|
else {
|
|
137
134
|
acc.links.push(React.cloneElement(child, {
|
|
138
|
-
onClick: child.props['aria-current']
|
|
135
|
+
onClick: child.props['aria-current']
|
|
136
|
+
? closeMenuCallback
|
|
137
|
+
: child.props.onClick,
|
|
139
138
|
}));
|
|
140
139
|
}
|
|
141
140
|
}
|
|
@@ -145,13 +144,16 @@ const _SubNavRoot = memo(({ id, children, className, 'data-testid': testId, full
|
|
|
145
144
|
}
|
|
146
145
|
return acc;
|
|
147
146
|
}, { heading: undefined, links: [], action: undefined });
|
|
148
|
-
const activeLinklabel = typeof activeLink?.props.children === 'string'
|
|
147
|
+
const activeLinklabel = typeof activeLink?.props.children === 'string'
|
|
148
|
+
? activeLink.props.children
|
|
149
|
+
: activeLink?.props.children[0];
|
|
149
150
|
// needed to prevent rendering of anchor subnav inside the narrow <Button variant="invisible"> element
|
|
150
|
-
const MaybeSubNav = activeLink?.props.children?.[1]?.props?.variant === 'anchor' &&
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
const MaybeSubNav = activeLink?.props.children?.[1]?.props?.variant === 'anchor' &&
|
|
152
|
+
activeLink.props.children?.[1];
|
|
153
|
+
return (_jsx("div", { className: clsx(styles['SubNav__container'], hasAnchoredNav && styles['SubNav__container--with-anchor-nav']), children: _jsx(SubNavProvider, { children: _jsx("nav", { ref: navRef, id: id, className: clsx(styles.SubNav, isOpenAtNarrow && styles['SubNav--open'], hasShadow && styles['SubNav--has-shadow'], fullWidth && styles['SubNav--full-width'], className), "data-testid": testId || testIds.root, children: _jsxs("div", { ref: rootRef, className: styles['SubNav--header-container-outer'], children: [_jsxs("div", { className: styles['SubNav__header-container'], children: [HeadingChild && (_jsx("div", { className: styles['SubNav__heading-container'], children: HeadingChild })), !isLarge && (_jsxs("button", { className: clsx(styles['SubNav__overlay-toggle'], isOpenAtNarrow && styles['SubNav__overlay-toggle--open']), "data-testid": testIds.button, onClick: isOpenAtNarrow ? closeMenuCallback : handleMenuToggle, "aria-expanded": isOpenAtNarrow ? 'true' : 'false', "aria-controls": idForLinkContainer, children: [activeLinklabel && (_jsxs("span", { className: "visually-hidden", children: ["Navigation menu. Current page:", ' '] })), _jsxs("span", { className: clsx(styles['SubNav__overlay-toggle-content'], !activeLinklabel &&
|
|
154
|
+
styles['SubNav__overlay-toggle-content--end']), children: [activeLinklabel && (_jsx(Text, { as: "span", size: "200", children: activeLinklabel })), isOpenAtNarrow ? (_jsx(ChevronUpIcon, { className: styles['SubNav__overlay-toggle-icon'], size: 24 })) : (_jsx(ChevronDownIcon, { className: styles['SubNav__overlay-toggle-icon'], size: 24 }))] })] })), MaybeSubNav && MaybeSubNav] }), LinkChildren.length && (_jsxs("ul", { ref: overlayRef, id: idForLinkContainer, className: clsx(styles['SubNav__links-overlay'], isOpenAtNarrow && styles['SubNav__links-overlay--open']), "data-testid": testIds.overlay, children: [ActionChild ? (_jsx("li", { className: styles['SubNav__action-container'], children: ActionChild })) : (_jsx("li", { className: styles['SubNav__action-container'] })), LinkChildren, _jsx(ButtonGroup, { buttonSize: "small", children: _jsx(Button, { href: "#", onClick: e => {
|
|
155
|
+
window.location.assign('https://datalayer.app');
|
|
156
|
+
}, hasArrow: true, variant: "subtle", children: "Login" }) })] }))] }) }) }) }));
|
|
155
157
|
});
|
|
156
158
|
const SubNavHeading = ({ href, children, className, 'data-testid': testID, ...props }) => {
|
|
157
159
|
return (_jsx("a", { href: href, className: clsx(styles['SubNav__heading'], className), "data-testid": testIds.heading || testID, ...props, children: children }));
|
|
@@ -175,14 +177,16 @@ const SubNavLinkWithSubmenu = forwardRef(({ children, href, 'aria-current': aria
|
|
|
175
177
|
* onFocus and onBlur need to be defined to keep the jsx-a11y/mouse-events-have-key-events
|
|
176
178
|
* eslint rule happy. The focus/blur behaviour is handled by useContainsFocus
|
|
177
179
|
*/
|
|
178
|
-
onFocus: () => null, onBlur: () => null, children: [_jsx("a", { href: href, className: clsx(styles['SubNav__link'], ariaCurrent && styles['SubNav__link--active'], className), "aria-current": ariaCurrent, ...props, children: _jsx(Text, { as: "span", size: "200", weight: "semibold", className: styles['SubNav__link-label'], variant: ariaCurrent === 'page' || variant === 'default'
|
|
180
|
+
onFocus: () => null, onBlur: () => null, children: [_jsx("a", { href: href, className: clsx(styles['SubNav__link'], ariaCurrent && styles['SubNav__link--active'], className), "aria-current": ariaCurrent, ...props, children: _jsx(Text, { as: "span", size: "200", weight: "semibold", className: styles['SubNav__link-label'], variant: ariaCurrent === 'page' || variant === 'default'
|
|
181
|
+
? 'default'
|
|
182
|
+
: 'muted', children: label }) }), isLarge && (_jsx("button", { className: styles['SubNav__sub-menu-toggle'], onClick: handleOnClick, "aria-expanded": isExpanded ? 'true' : 'false', "aria-controls": submenuId, "aria-label": `${isExpanded ? 'Close' : 'Open'} submenu`, children: _jsx(ChevronDownIcon, { className: styles['SubNav__sub-menu-icon'], size: 16 }) })), _jsx("div", { id: submenuId, className: styles['SubNav__sub-menu-children'], children: SubMenuChildren })] }));
|
|
179
183
|
});
|
|
180
184
|
const SubNavLink = forwardRef((props, ref) => {
|
|
181
185
|
const [isInView, setIsInView] = useState(false);
|
|
182
186
|
const childrenArr = Children.toArray(props.children);
|
|
183
187
|
const hasSubMenu = childrenArr.some(child => {
|
|
184
188
|
if (isValidElement(child)) {
|
|
185
|
-
return child.type ===
|
|
189
|
+
return child.type === SubMenu;
|
|
186
190
|
}
|
|
187
191
|
});
|
|
188
192
|
useEffect(() => {
|
|
@@ -193,8 +197,12 @@ const SubNavLink = forwardRef((props, ref) => {
|
|
|
193
197
|
if (!target)
|
|
194
198
|
return;
|
|
195
199
|
const topOfWindow = '0px 0px -100%';
|
|
196
|
-
const observerParams = {
|
|
197
|
-
|
|
200
|
+
const observerParams = {
|
|
201
|
+
threshold: 0,
|
|
202
|
+
root: null,
|
|
203
|
+
rootMargin: topOfWindow,
|
|
204
|
+
};
|
|
205
|
+
const handleIntersectionUpdate = ([entry,]) => {
|
|
198
206
|
setIsInView(entry.isIntersecting);
|
|
199
207
|
};
|
|
200
208
|
const observer = new IntersectionObserver(handleIntersectionUpdate, observerParams);
|
|
@@ -204,15 +212,17 @@ const SubNavLink = forwardRef((props, ref) => {
|
|
|
204
212
|
if (hasSubMenu) {
|
|
205
213
|
const isAnchorVariantSubMenu = childrenArr.some(child => {
|
|
206
214
|
if (isValidElement(child)) {
|
|
207
|
-
return child.type ===
|
|
215
|
+
return child.type === SubMenu && child.props.variant === 'anchor';
|
|
208
216
|
}
|
|
209
217
|
});
|
|
210
218
|
return (_jsx("li", { children: _jsx(SubNavLinkWithSubmenu, { ...props, ref: ref, _subMenuVariant: isAnchorVariantSubMenu ? 'anchor' : undefined }) }));
|
|
211
219
|
}
|
|
212
220
|
const { children, href, 'aria-current': ariaCurrent, 'data-testid': testId, variant, className, ...rest } = props;
|
|
213
|
-
return (_jsx("li", { children: _jsx("a", { href: href, className: clsx(styles['SubNav__link'], ariaCurrent && styles['SubNav__link--active'], isInView && styles['SubNav__link--is-in-view'], className), "aria-current": ariaCurrent, "data-testid": testId || testIds.link, ref: ref, ...rest, children: _jsx(Text, { as: "span", size: "100", weight: "semibold", className: styles['SubNav__link-label'], variant: ariaCurrent === 'page' || variant === 'default'
|
|
221
|
+
return (_jsx("li", { children: _jsx("a", { href: href, className: clsx(styles['SubNav__link'], ariaCurrent && styles['SubNav__link--active'], isInView && styles['SubNav__link--is-in-view'], className), "aria-current": ariaCurrent, "data-testid": testId || testIds.link, ref: ref, ...rest, children: _jsx(Text, { as: "span", size: "100", weight: "semibold", className: styles['SubNav__link-label'], variant: ariaCurrent === 'page' || variant === 'default'
|
|
222
|
+
? 'default'
|
|
223
|
+
: 'muted', children: children }) }) }));
|
|
214
224
|
});
|
|
215
|
-
function
|
|
225
|
+
function SubMenu({ children, className, variant = 'dropdown', ...props }) {
|
|
216
226
|
const context = React.useContext(SubNavContext);
|
|
217
227
|
const navRef = useRef(null);
|
|
218
228
|
const { isLarge } = useWindowSize();
|
|
@@ -265,6 +275,6 @@ export const SubNav = Object.assign(_SubNavRoot, {
|
|
|
265
275
|
Heading: SubNavHeading,
|
|
266
276
|
Link: SubNavLink,
|
|
267
277
|
Action: _SubNavAction,
|
|
268
|
-
SubMenu:
|
|
278
|
+
SubMenu: SubMenu,
|
|
269
279
|
testIds,
|
|
270
280
|
});
|