@datalayer/core 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -7
- package/lib/App.css +47 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +21 -5
- package/lib/__tests__/App.test.d.ts +1 -0
- package/lib/__tests__/App.test.js +17 -0
- package/lib/__tests__/hooks.test.d.ts +1 -0
- package/lib/__tests__/hooks.test.js +19 -0
- package/lib/__tests__/index.test.d.ts +1 -0
- package/lib/__tests__/index.test.js +27 -0
- package/lib/__tests__/integration.test.d.ts +1 -0
- package/lib/__tests__/integration.test.js +57 -0
- package/lib/__tests__/utils.test.d.ts +1 -0
- package/lib/__tests__/utils.test.js +59 -0
- package/lib/api/DatalayerApi.d.ts +75 -0
- package/lib/api/DatalayerApi.js +145 -0
- package/lib/api/index.d.ts +3 -0
- package/lib/api/index.js +7 -0
- package/lib/api/jupyter/exec/Python.d.ts +5 -0
- package/lib/api/jupyter/exec/Python.js +100 -0
- package/lib/api/jupyter/exec/Snippets.d.ts +145 -0
- package/lib/api/jupyter/exec/Snippets.js +120 -0
- package/lib/api/jupyter/exec/index.d.ts +2 -0
- package/lib/api/jupyter/exec/index.js +6 -0
- package/lib/api/jupyter/index.d.ts +2 -0
- package/lib/api/jupyter/index.js +6 -0
- package/lib/api/jupyter/kernelsHandler.d.ts +8 -0
- package/lib/api/jupyter/kernelsHandler.js +39 -0
- package/lib/api/runtimes/actions.d.ts +102 -0
- package/lib/api/runtimes/actions.js +264 -0
- package/lib/api/runtimes/apis.d.ts +273 -0
- package/lib/api/runtimes/apis.js +5 -0
- package/lib/api/runtimes/index.d.ts +5 -0
- package/lib/api/runtimes/index.js +9 -0
- package/lib/api/runtimes/settings.d.ts +15 -0
- package/lib/api/runtimes/settings.js +31 -0
- package/lib/api/runtimes/snapshots.d.ts +25 -0
- package/lib/api/runtimes/snapshots.js +150 -0
- package/lib/api/runtimes/utils.d.ts +7 -0
- package/lib/api/runtimes/utils.js +17 -0
- package/lib/assets/react.svg +1 -0
- package/lib/components/avatars/BoringAvatar.d.ts +19 -0
- package/lib/components/avatars/BoringAvatar.js +44 -0
- package/lib/components/avatars/BoringAvatar.stories.d.ts +27 -0
- package/lib/components/avatars/BoringAvatar.stories.js +23 -0
- package/lib/components/avatars/UserProfileAvatar.d.ts +13 -0
- package/lib/components/avatars/UserProfileAvatar.js +32 -0
- package/lib/components/avatars/index.d.ts +2 -0
- package/lib/components/avatars/index.js +6 -0
- package/lib/components/banners/NoAutomationBanner.d.ts +2 -0
- package/lib/components/banners/NoAutomationBanner.js +13 -0
- package/lib/components/banners/index.d.ts +1 -0
- package/lib/components/banners/index.js +5 -0
- package/lib/components/buttons/DownloadCSVButton.d.ts +13 -0
- package/lib/components/buttons/DownloadCSVButton.js +16 -0
- package/lib/components/buttons/DownloadJsonButton.d.ts +16 -0
- package/lib/components/buttons/DownloadJsonButton.js +18 -0
- package/lib/components/buttons/LongActionButton.d.ts +28 -0
- package/lib/components/buttons/LongActionButton.js +24 -0
- package/lib/components/buttons/UploadButton.d.ts +37 -0
- package/lib/components/buttons/UploadButton.js +43 -0
- package/lib/components/buttons/VariantType.d.ts +1 -0
- package/lib/components/buttons/VariantType.js +5 -0
- package/lib/components/buttons/index.d.ts +5 -0
- package/lib/components/buttons/index.js +9 -0
- package/lib/components/checkout/StripeCheckout.d.ts +32 -0
- package/lib/components/checkout/StripeCheckout.js +95 -0
- package/lib/components/checkout/index.d.ts +1 -0
- package/lib/components/checkout/index.js +5 -0
- package/lib/components/confetti/ConfettiSuccess.d.ts +2 -0
- package/lib/components/confetti/ConfettiSuccess.js +12 -0
- package/lib/components/confetti/index.d.ts +1 -0
- package/lib/components/confetti/index.js +5 -0
- package/lib/components/context/OrganizationSelect.d.ts +2 -0
- package/lib/components/context/OrganizationSelect.js +35 -0
- package/lib/components/context/SpaceSelect.d.ts +2 -0
- package/lib/components/context/SpaceSelect.js +43 -0
- package/lib/components/context/index.d.ts +2 -0
- package/lib/components/context/index.js +6 -0
- package/lib/components/display/AvatarSkeleton.d.ts +5 -0
- package/lib/components/display/AvatarSkeleton.js +11 -0
- package/lib/components/display/CenteredSpinner.d.ts +14 -0
- package/lib/components/display/CenteredSpinner.js +20 -0
- package/lib/components/display/CodePreview.d.ts +4 -0
- package/lib/components/display/CodePreview.js +15 -0
- package/lib/components/display/DatalayerBox.d.ts +8 -0
- package/lib/components/display/DatalayerBox.js +28 -0
- package/lib/components/display/HorizontalCenter.d.ts +9 -0
- package/lib/components/display/HorizontalCenter.js +14 -0
- package/lib/components/display/JupyterDialog.d.ts +69 -0
- package/lib/components/display/JupyterDialog.js +115 -0
- package/lib/components/display/Markdown.d.ts +23 -0
- package/lib/components/display/Markdown.js +20 -0
- package/lib/components/display/NavLink.d.ts +9 -0
- package/lib/components/display/NavLink.js +17 -0
- package/lib/components/display/NotebookSkeleton.d.ts +2 -0
- package/lib/components/display/NotebookSkeleton.js +11 -0
- package/lib/components/display/Placeholder.d.ts +2 -0
- package/lib/components/display/Placeholder.js +9 -0
- package/lib/components/display/ToTopBranded.d.ts +2 -0
- package/lib/components/display/ToTopBranded.js +11 -0
- package/lib/components/display/VisuallyHidden.d.ts +5 -0
- package/lib/components/display/VisuallyHidden.js +24 -0
- package/lib/components/display/index.d.ts +12 -0
- package/lib/components/display/index.js +16 -0
- package/lib/components/echarts/EChartsReact.d.ts +11 -0
- package/lib/components/echarts/EChartsReact.js +53 -0
- package/lib/components/echarts/index.d.ts +1 -0
- package/lib/components/echarts/index.js +5 -0
- package/lib/components/flashes/FlashClosable.d.ts +22 -0
- package/lib/components/flashes/FlashClosable.js +64 -0
- package/lib/components/flashes/FlashDisclaimer.d.ts +2 -0
- package/lib/components/flashes/FlashDisclaimer.js +18 -0
- package/lib/components/flashes/FlashGuest.d.ts +2 -0
- package/lib/components/flashes/FlashGuest.js +30 -0
- package/lib/components/flashes/FlashSurveys.d.ts +6 -0
- package/lib/components/flashes/FlashSurveys.js +36 -0
- package/lib/components/flashes/FlashUnauthorized.d.ts +2 -0
- package/lib/components/flashes/FlashUnauthorized.js +18 -0
- package/lib/components/flashes/index.d.ts +6 -0
- package/lib/components/flashes/index.js +10 -0
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +3 -0
- package/lib/components/flashes/surveys/Survey2025_1.js +129 -0
- package/lib/components/flashes/surveys/SurveyProps.d.ts +6 -0
- package/lib/components/flashes/surveys/SurveyProps.js +5 -0
- package/lib/components/flashes/surveys/index.d.ts +2 -0
- package/lib/components/flashes/surveys/index.js +6 -0
- package/lib/components/iam/ExternalTokenSilentLogin.d.ts +5 -0
- package/lib/components/iam/ExternalTokenSilentLogin.js +33 -0
- package/lib/components/iam/index.d.ts +1 -0
- package/lib/components/iam/index.js +5 -0
- package/lib/components/icons/ArtifactIcon.d.ts +10 -0
- package/lib/components/icons/ArtifactIcon.js +58 -0
- package/lib/components/icons/index.d.ts +1 -0
- package/lib/components/icons/index.js +5 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +5 -0
- package/lib/components/labels/VisibilityLabel.d.ts +4 -0
- package/lib/components/labels/VisibilityLabel.js +17 -0
- package/lib/components/labels/index.d.ts +1 -0
- package/lib/components/labels/index.js +5 -0
- package/lib/components/landings/StepBlock.d.ts +11 -0
- package/lib/components/landings/StepBlock.js +12 -0
- package/lib/components/landings/index.d.ts +1 -0
- package/lib/components/landings/index.js +5 -0
- package/lib/components/navbar/NavigationVisbilityObserver.d.ts +5 -0
- package/lib/components/navbar/NavigationVisbilityObserver.js +58 -0
- package/lib/components/navbar/SubdomainNavBar.d.ts +81 -0
- package/lib/components/navbar/SubdomainNavBar.js +235 -0
- package/lib/components/navbar/SubdomainNavBar.module.css +718 -0
- package/lib/components/navbar/index.d.ts +2 -0
- package/lib/components/navbar/index.js +6 -0
- package/lib/components/nbgrader/NbGradesDetails.d.ts +5 -0
- package/lib/components/nbgrader/NbGradesDetails.js +17 -0
- package/lib/components/nbgrader/index.d.ts +1 -0
- package/lib/components/nbgrader/index.js +5 -0
- package/lib/components/notebooks/JupyterNotebook.d.ts +12 -0
- package/lib/components/notebooks/JupyterNotebook.js +36 -0
- package/lib/components/notebooks/JupyterNotebookToolbar.d.ts +2 -0
- package/lib/components/notebooks/JupyterNotebookToolbar.js +39 -0
- package/lib/components/notebooks/index.d.ts +2 -0
- package/lib/components/notebooks/index.js +6 -0
- package/lib/components/primer/Helper.d.ts +32 -0
- package/lib/components/primer/Helper.js +19 -0
- package/lib/components/primer/Portals.d.ts +9 -0
- package/lib/components/primer/Portals.js +26 -0
- package/lib/components/primer/Styles.d.ts +2 -0
- package/lib/components/primer/Styles.js +11 -0
- package/lib/components/primer/index.d.ts +2 -0
- package/lib/components/primer/index.js +6 -0
- package/lib/components/progress/ConsumptionBar.d.ts +40 -0
- package/lib/components/progress/ConsumptionBar.js +49 -0
- package/lib/components/progress/CreditsIndicator.d.ts +27 -0
- package/lib/components/progress/CreditsIndicator.js +24 -0
- package/lib/components/progress/ProgressBar.d.ts +2 -0
- package/lib/components/progress/ProgressBar.js +21 -0
- package/lib/components/progress/ProgressRing.d.ts +36 -0
- package/lib/components/progress/ProgressRing.js +31 -0
- package/lib/components/progress/Timer.d.ts +9 -0
- package/lib/components/progress/Timer.js +28 -0
- package/lib/components/progress/index.d.ts +5 -0
- package/lib/components/progress/index.js +9 -0
- package/lib/components/runtimes/RuntimeCellVariables.d.ts +39 -0
- package/lib/components/runtimes/RuntimeCellVariables.js +172 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.d.ts +37 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +101 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +53 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.js +250 -0
- package/lib/components/runtimes/RuntimePickerBase.d.ts +69 -0
- package/lib/components/runtimes/RuntimePickerBase.js +109 -0
- package/lib/components/runtimes/RuntimePickerCell.d.ts +34 -0
- package/lib/components/runtimes/RuntimePickerCell.js +106 -0
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +42 -0
- package/lib/components/runtimes/RuntimePickerNotebook.js +168 -0
- package/lib/components/runtimes/RuntimeReservationControl.d.ts +47 -0
- package/lib/components/runtimes/RuntimeReservationControl.js +38 -0
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +34 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +156 -0
- package/lib/components/runtimes/RuntimeTransfer.d.ts +16 -0
- package/lib/components/runtimes/RuntimeTransfer.js +5 -0
- package/lib/components/runtimes/RuntimeUtils.d.ts +17 -0
- package/lib/components/runtimes/RuntimeUtils.js +168 -0
- package/lib/components/runtimes/RuntimeVariables.d.ts +38 -0
- package/lib/components/runtimes/RuntimeVariables.js +75 -0
- package/lib/components/runtimes/index.d.ts +11 -0
- package/lib/components/runtimes/index.js +15 -0
- package/lib/components/screenshot/ScreenCapture.d.ts +38 -0
- package/lib/components/screenshot/ScreenCapture.js +174 -0
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +3 -0
- package/lib/components/screenshot/ScreenCaptureButton.js +21 -0
- package/lib/components/screenshot/index.d.ts +2 -0
- package/lib/components/screenshot/index.js +6 -0
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +36 -0
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +164 -0
- package/lib/components/snapshots/index.d.ts +1 -0
- package/lib/components/snapshots/index.js +5 -0
- package/lib/components/snippets/SnippetDialog.d.ts +42 -0
- package/lib/components/snippets/SnippetDialog.js +42 -0
- package/lib/components/snippets/index.d.ts +1 -0
- package/lib/components/snippets/index.js +5 -0
- package/lib/components/storage/ContentsBrowser.d.ts +32 -0
- package/lib/components/storage/ContentsBrowser.js +255 -0
- package/lib/components/storage/ContentsItems.d.ts +58 -0
- package/lib/components/storage/ContentsItems.js +78 -0
- package/lib/components/storage/index.d.ts +2 -0
- package/lib/components/storage/index.js +6 -0
- package/lib/components/students/StudentItemStatus.d.ts +7 -0
- package/lib/components/students/StudentItemStatus.js +47 -0
- package/lib/components/students/index.d.ts +1 -0
- package/lib/components/students/index.js +5 -0
- package/lib/components/subnav/SubNav.d.ts +84 -0
- package/lib/components/subnav/SubNav.js +265 -0
- package/lib/components/subnav/SubNav.module.css +683 -0
- package/lib/components/subnav/index.d.ts +1 -0
- package/lib/components/subnav/index.js +5 -0
- package/lib/components/tables/DataTable.d.ts +5 -0
- package/lib/components/tables/DataTable.js +19 -0
- package/lib/components/tables/index.d.ts +1 -0
- package/lib/components/tables/index.js +5 -0
- package/lib/components/text-reveal/TextRevealAnimation.d.ts +6 -0
- package/lib/components/text-reveal/TextRevealAnimation.js +49 -0
- package/lib/components/text-reveal/TextRevealAnimation.module.css +43 -0
- package/lib/components/text-reveal/index.d.ts +1 -0
- package/lib/components/text-reveal/index.js +5 -0
- package/lib/components/text-reveal/useTextRevealAnimationLines.d.ts +4 -0
- package/lib/components/text-reveal/useTextRevealAnimationLines.js +47 -0
- package/lib/components/tokens/SpaceVariantToken.d.ts +5 -0
- package/lib/components/tokens/SpaceVariantToken.js +20 -0
- package/lib/components/tokens/index.d.ts +1 -0
- package/lib/components/tokens/index.js +5 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +4 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.js +18 -0
- package/lib/components/toolbars/DocumentEditorToolbar.d.ts +2 -0
- package/lib/components/toolbars/DocumentEditorToolbar.js +12 -0
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +29 -0
- package/lib/components/toolbars/NotebookEditorToolbar.js +30 -0
- package/lib/components/toolbars/index.d.ts +3 -0
- package/lib/components/toolbars/index.js +7 -0
- package/lib/components/users/PeerIndicator.d.ts +18 -0
- package/lib/components/users/PeerIndicator.js +100 -0
- package/lib/components/users/index.d.ts +1 -0
- package/lib/components/users/index.js +5 -0
- package/lib/config/Configuration.d.ts +111 -0
- package/lib/config/Configuration.js +25 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.js +6 -0
- package/lib/config/integrations/Loom.d.ts +1 -0
- package/lib/config/integrations/Loom.js +16 -0
- package/lib/config/integrations/index.d.ts +1 -0
- package/lib/config/integrations/index.js +5 -0
- package/lib/examples/CellExample.d.ts +6 -0
- package/lib/examples/CellExample.js +24 -0
- package/lib/examples/NotebookExample.d.ts +8 -0
- package/lib/examples/NotebookExample.js +22 -0
- package/lib/examples/NotebookExample1.ipynb.json +136 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +19 -0
- package/lib/hooks/assets/OutputshotPlaceholders.js +23 -0
- package/lib/hooks/assets/index.d.ts +1 -0
- package/lib/hooks/assets/index.js +5 -0
- package/lib/hooks/index.d.ts +28 -0
- package/lib/hooks/index.js +33 -0
- package/lib/hooks/layouts/LayoutBackdrop.d.ts +2 -0
- package/lib/hooks/layouts/LayoutBackdrop.js +30 -0
- package/lib/hooks/layouts/LayoutScreenshot.css +58 -0
- package/lib/hooks/layouts/LayoutScreenshot.d.ts +3 -0
- package/lib/hooks/layouts/LayoutScreenshot.js +44 -0
- package/lib/hooks/layouts/index.d.ts +2 -0
- package/lib/hooks/layouts/index.js +6 -0
- package/lib/hooks/useAIAgents.d.ts +13 -0
- package/lib/hooks/useAIAgents.js +72 -0
- package/lib/hooks/useAuthorization.d.ts +19 -0
- package/lib/hooks/useAuthorization.js +124 -0
- package/lib/hooks/useBackdrop.d.ts +28 -0
- package/lib/hooks/useBackdrop.js +100 -0
- package/lib/hooks/useBackdropJupyterLab.d.ts +15 -0
- package/lib/hooks/useBackdropJupyterLab.js +51 -0
- package/lib/hooks/useCache.d.ts +306 -0
- package/lib/hooks/useCache.js +3098 -0
- package/lib/hooks/useCellOutputshot.d.ts +4 -0
- package/lib/hooks/useCellOutputshot.js +28 -0
- package/lib/hooks/useContainsFocus.d.ts +9 -0
- package/lib/hooks/useContainsFocus.js +43 -0
- package/lib/hooks/useDatalayer.d.ts +21 -0
- package/lib/hooks/useDatalayer.js +81 -0
- package/lib/hooks/useError.d.ts +9 -0
- package/lib/hooks/useError.js +26 -0
- package/lib/hooks/useExternalScript.d.ts +2 -0
- package/lib/hooks/useExternalScript.js +17 -0
- package/lib/hooks/useFocusTrap.d.ts +30 -0
- package/lib/hooks/useFocusTrap.js +48 -0
- package/lib/hooks/useIAM.d.ts +14 -0
- package/lib/hooks/useIAM.js +93 -0
- package/lib/hooks/useId.d.ts +19 -0
- package/lib/hooks/useId.js +100 -0
- package/lib/hooks/useIsomorphicLayoutEffect.d.ts +3 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js +11 -0
- package/lib/hooks/useJupyterLabTheme.d.ts +6 -0
- package/lib/hooks/useJupyterLabTheme.js +24 -0
- package/lib/hooks/useKeyboardEscape.d.ts +1 -0
- package/lib/hooks/useKeyboardEscape.js +18 -0
- package/lib/hooks/useLocationHandles.d.ts +10 -0
- package/lib/hooks/useLocationHandles.js +22 -0
- package/lib/hooks/useNavigate.d.ts +2 -0
- package/lib/hooks/useNavigate.js +24 -0
- package/lib/hooks/useNotebookAIAgent.d.ts +8 -0
- package/lib/hooks/useNotebookAIAgent.js +54 -0
- package/lib/hooks/useOnClickOutside.d.ts +1 -0
- package/lib/hooks/useOnClickOutside.js +29 -0
- package/lib/hooks/useRef.d.ts +10 -0
- package/lib/hooks/useRef.js +17 -0
- package/lib/hooks/useRuntimes.d.ts +5 -0
- package/lib/hooks/useRuntimes.js +34 -0
- package/lib/hooks/useScreenshot.d.ts +21 -0
- package/lib/hooks/useScreenshot.js +60 -0
- package/lib/hooks/useToast.d.ts +42 -0
- package/lib/hooks/useToast.js +141 -0
- package/lib/hooks/useUpload.d.ts +7 -0
- package/lib/hooks/useUpload.js +46 -0
- package/lib/hooks/useUser.d.ts +3 -0
- package/lib/hooks/useUser.js +22 -0
- package/lib/hooks/useVisibilityObserver.d.ts +5 -0
- package/lib/hooks/useVisibilityObserver.js +42 -0
- package/lib/hooks/useWindowSize.d.ts +21 -0
- package/lib/hooks/useWindowSize.js +74 -0
- package/lib/i18n/Labels.d.ts +1 -0
- package/lib/i18n/Labels.js +5 -0
- package/lib/i18n/index.d.ts +1 -0
- package/lib/i18n/index.js +5 -0
- package/lib/index.css +73 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +5 -2
- package/lib/mocks/components/FlashMock.d.ts +2 -0
- package/lib/mocks/components/FlashMock.js +13 -0
- package/lib/mocks/components/index.d.ts +1 -0
- package/lib/mocks/components/index.js +5 -0
- package/lib/mocks/hooks/index.d.ts +1 -0
- package/lib/mocks/hooks/index.js +5 -0
- package/lib/mocks/hooks/rests/index.d.ts +1 -0
- package/lib/mocks/hooks/rests/index.js +5 -0
- package/lib/mocks/hooks/rests/rests.d.ts +22 -0
- package/lib/mocks/hooks/rests/rests.js +32 -0
- package/lib/mocks/hooks/useDatalayerMock.d.ts +6 -0
- package/lib/mocks/hooks/useDatalayerMock.js +78 -0
- package/lib/mocks/index.d.ts +4 -0
- package/lib/mocks/index.js +9 -0
- package/lib/mocks/jupyter/index.d.ts +1 -0
- package/lib/mocks/jupyter/index.js +5 -0
- package/lib/mocks/models/CodeBlockMock.d.ts +1 -0
- package/lib/mocks/models/CodeBlockMock.js +5 -0
- package/lib/mocks/models/CodelineMock.d.ts +1 -0
- package/lib/mocks/models/CodelineMock.js +5 -0
- package/lib/mocks/models/CourseMock.d.ts +6 -0
- package/lib/mocks/models/CourseMock.js +29 -0
- package/lib/mocks/models/InviteMock.d.ts +6 -0
- package/lib/mocks/models/InviteMock.js +22 -0
- package/lib/mocks/models/JupyterLabUserMock.d.ts +2 -0
- package/lib/mocks/models/JupyterLabUserMock.js +17 -0
- package/lib/mocks/models/OrganisationMock.d.ts +5 -0
- package/lib/mocks/models/OrganisationMock.js +24 -0
- package/lib/mocks/models/SchoolMock.d.ts +6 -0
- package/lib/mocks/models/SchoolMock.js +25 -0
- package/lib/mocks/models/SpaceMock.d.ts +6 -0
- package/lib/mocks/models/SpaceMock.js +25 -0
- package/lib/mocks/models/TeamMock.d.ts +5 -0
- package/lib/mocks/models/TeamMock.js +26 -0
- package/lib/mocks/models/UserMock.d.ts +2 -0
- package/lib/mocks/models/UserMock.js +29 -0
- package/lib/mocks/models/index.d.ts +9 -0
- package/lib/mocks/models/index.js +13 -0
- package/lib/mocks/views/ActionMenuMock.d.ts +5 -0
- package/lib/mocks/views/ActionMenuMock.js +12 -0
- package/lib/mocks/views/ChartMock.d.ts +5 -0
- package/lib/mocks/views/ChartMock.js +15 -0
- package/lib/mocks/views/ChartMockOptions.d.ts +92 -0
- package/lib/mocks/views/ChartMockOptions.js +102 -0
- package/lib/mocks/views/DashboardMock.d.ts +2 -0
- package/lib/mocks/views/DashboardMock.js +118 -0
- package/lib/mocks/views/FormMock.d.ts +5 -0
- package/lib/mocks/views/FormMock.js +28 -0
- package/lib/mocks/views/TableMock.d.ts +5 -0
- package/lib/mocks/views/TableMock.js +155 -0
- package/lib/mocks/views/WipMock.d.ts +5 -0
- package/lib/mocks/views/WipMock.js +12 -0
- package/lib/mocks/views/index.d.ts +7 -0
- package/lib/mocks/views/index.js +11 -0
- package/lib/models/AIAgent.d.ts +17 -0
- package/lib/models/AIAgent.js +5 -0
- package/lib/models/Account.d.ts +4 -0
- package/lib/models/Account.js +5 -0
- package/lib/models/Assignment.d.ts +7 -0
- package/lib/models/Assignment.js +5 -0
- package/lib/models/Base.d.ts +16 -0
- package/lib/models/Base.js +5 -0
- package/lib/models/Cell.d.ts +8 -0
- package/lib/models/Cell.js +5 -0
- package/lib/models/CodeBlock.d.ts +10 -0
- package/lib/models/CodeBlock.js +5 -0
- package/lib/models/CodefeedBlocks.d.ts +7 -0
- package/lib/models/CodefeedBlocks.js +5 -0
- package/lib/models/Contact.d.ts +73 -0
- package/lib/models/Contact.js +90 -0
- package/lib/models/ContactEvent.d.ts +10 -0
- package/lib/models/ContactEvent.js +14 -0
- package/lib/models/ContactIAMProvider.d.ts +12 -0
- package/lib/models/ContactIAMProvider.js +20 -0
- package/lib/models/ContactTags.d.ts +23 -0
- package/lib/models/ContactTags.js +73 -0
- package/lib/models/Content.d.ts +5 -0
- package/lib/models/Content.js +5 -0
- package/lib/models/Course.d.ts +17 -0
- package/lib/models/Course.js +5 -0
- package/lib/models/Credits.d.ts +76 -0
- package/lib/models/Credits.js +11 -0
- package/lib/models/Dataset.d.ts +16 -0
- package/lib/models/Dataset.js +5 -0
- package/lib/models/Datasource.d.ts +11 -0
- package/lib/models/Datasource.js +14 -0
- package/lib/models/Dean.d.ts +3 -0
- package/lib/models/Dean.js +5 -0
- package/lib/models/Document.d.ts +8 -0
- package/lib/models/Document.js +5 -0
- package/lib/models/Environment.d.ts +82 -0
- package/lib/models/Environment.js +5 -0
- package/lib/models/Errors.d.ts +6 -0
- package/lib/models/Errors.js +13 -0
- package/lib/models/Exercise.d.ts +16 -0
- package/lib/models/Exercise.js +5 -0
- package/lib/models/GrowthKPI.d.ts +5 -0
- package/lib/models/GrowthKPI.js +9 -0
- package/lib/models/IAMProviderLinked.d.ts +9 -0
- package/lib/models/IAMProviderLinked.js +13 -0
- package/lib/models/IAMProviderPost.d.ts +8 -0
- package/lib/models/IAMProviderPost.js +22 -0
- package/lib/models/IAMProviderUsers.d.ts +49 -0
- package/lib/models/IAMProviderUsers.js +29 -0
- package/lib/models/IAMProvidersSpecs.d.ts +22 -0
- package/lib/models/IAMProvidersSpecs.js +72 -0
- package/lib/models/IAMToken.d.ts +11 -0
- package/lib/models/IAMToken.js +14 -0
- package/lib/models/Inbound.d.ts +25 -0
- package/lib/models/Inbound.js +29 -0
- package/lib/models/Instructor.d.ts +3 -0
- package/lib/models/Instructor.js +5 -0
- package/lib/models/Invite.d.ts +14 -0
- package/lib/models/Invite.js +24 -0
- package/lib/models/Item.d.ts +20 -0
- package/lib/models/Item.js +5 -0
- package/lib/models/ItemType.d.ts +2 -0
- package/lib/models/ItemType.js +5 -0
- package/lib/models/LandingRoles.d.ts +3 -0
- package/lib/models/LandingRoles.js +27 -0
- package/lib/models/Lesson.d.ts +5 -0
- package/lib/models/Lesson.js +5 -0
- package/lib/models/Library.d.ts +10 -0
- package/lib/models/Library.js +5 -0
- package/lib/models/Member.d.ts +3 -0
- package/lib/models/Member.js +5 -0
- package/lib/models/Notebook.d.ts +11 -0
- package/lib/models/Notebook.js +5 -0
- package/lib/models/Organization.d.ts +27 -0
- package/lib/models/Organization.js +36 -0
- package/lib/models/OrganizationMember.d.ts +6 -0
- package/lib/models/OrganizationMember.js +5 -0
- package/lib/models/Outbound.d.ts +41 -0
- package/lib/models/Outbound.js +45 -0
- package/lib/models/Page.d.ts +36 -0
- package/lib/models/Page.js +23 -0
- package/lib/models/PageTag.d.ts +19 -0
- package/lib/models/PageTag.js +26 -0
- package/lib/models/Profile.d.ts +1 -0
- package/lib/models/Profile.js +5 -0
- package/lib/models/Role.d.ts +9 -0
- package/lib/models/Role.js +5 -0
- package/lib/models/RolesOrganization.d.ts +9 -0
- package/lib/models/RolesOrganization.js +58 -0
- package/lib/models/RolesPlatform.d.ts +16 -0
- package/lib/models/RolesPlatform.js +142 -0
- package/lib/models/RolesTeam.d.ts +7 -0
- package/lib/models/RolesTeam.js +34 -0
- package/lib/models/Runtime.d.ts +123 -0
- package/lib/models/Runtime.js +18 -0
- package/lib/models/RuntimeSnapshot.d.ts +92 -0
- package/lib/models/RuntimeSnapshot.js +13 -0
- package/lib/models/School.d.ts +11 -0
- package/lib/models/School.js +5 -0
- package/lib/models/Secret.d.ts +10 -0
- package/lib/models/Secret.js +13 -0
- package/lib/models/Space.d.ts +34 -0
- package/lib/models/Space.js +39 -0
- package/lib/models/SpaceItem.d.ts +10 -0
- package/lib/models/SpaceItem.js +5 -0
- package/lib/models/SpaceMember.d.ts +6 -0
- package/lib/models/SpaceMember.js +5 -0
- package/lib/models/Student.d.ts +6 -0
- package/lib/models/Student.js +5 -0
- package/lib/models/StudentItem.d.ts +21 -0
- package/lib/models/StudentItem.js +5 -0
- package/lib/models/Survey.d.ts +20 -0
- package/lib/models/Survey.js +14 -0
- package/lib/models/Team.d.ts +22 -0
- package/lib/models/Team.js +32 -0
- package/lib/models/TeamMember.d.ts +6 -0
- package/lib/models/TeamMember.js +5 -0
- package/lib/models/URN.d.ts +63 -0
- package/lib/models/URN.js +40 -0
- package/lib/models/Usage.d.ts +46 -0
- package/lib/models/Usage.js +21 -0
- package/lib/models/User.d.ts +71 -0
- package/lib/models/User.js +98 -0
- package/lib/models/UserEvent.d.ts +10 -0
- package/lib/models/UserEvent.js +14 -0
- package/lib/models/UserOnboarding.d.ts +14 -0
- package/lib/models/UserOnboarding.js +19 -0
- package/lib/models/UserSettings.d.ts +16 -0
- package/lib/models/UserSettings.js +27 -0
- package/lib/models/WaitingListFormData.d.ts +6 -0
- package/lib/models/WaitingListFormData.js +5 -0
- package/lib/models/index.d.ts +65 -0
- package/lib/models/index.js +69 -0
- package/lib/routes/Routes.d.ts +3 -0
- package/lib/routes/Routes.js +7 -0
- package/lib/routes/index.d.ts +1 -0
- package/lib/routes/index.js +5 -0
- package/lib/state/State.d.ts +33 -0
- package/lib/state/State.js +44 -0
- package/lib/state/index.d.ts +3 -0
- package/lib/state/index.js +7 -0
- package/lib/state/storage/IAMStorage.d.ts +33 -0
- package/lib/state/storage/IAMStorage.js +76 -0
- package/lib/state/storage/index.d.ts +1 -0
- package/lib/state/storage/index.js +5 -0
- package/lib/state/substates/AIAgentState.d.ts +11 -0
- package/lib/state/substates/AIAgentState.js +40 -0
- package/lib/state/substates/CellState.d.ts +12 -0
- package/lib/state/substates/CellState.js +21 -0
- package/lib/state/substates/CoreState.d.ts +25 -0
- package/lib/state/substates/CoreState.js +88 -0
- package/lib/state/substates/DatasourceState.d.ts +11 -0
- package/lib/state/substates/DatasourceState.js +16 -0
- package/lib/state/substates/DocumentState.d.ts +10 -0
- package/lib/state/substates/DocumentState.js +14 -0
- package/lib/state/substates/GradeState.d.ts +10 -0
- package/lib/state/substates/GradeState.js +14 -0
- package/lib/state/substates/IAMState.d.ts +75 -0
- package/lib/state/substates/IAMState.js +291 -0
- package/lib/state/substates/JupyterLabState.d.ts +16 -0
- package/lib/state/substates/JupyterLabState.js +17 -0
- package/lib/state/substates/LayoutState.d.ts +62 -0
- package/lib/state/substates/LayoutState.js +74 -0
- package/lib/state/substates/NbformatState.d.ts +13 -0
- package/lib/state/substates/NbformatState.js +16 -0
- package/lib/state/substates/OrganizationState.d.ts +11 -0
- package/lib/state/substates/OrganizationState.js +16 -0
- package/lib/state/substates/RuntimesState.d.ts +88 -0
- package/lib/state/substates/RuntimesState.js +178 -0
- package/lib/state/substates/SpaceState.d.ts +11 -0
- package/lib/state/substates/SpaceState.js +16 -0
- package/lib/state/substates/SurveysState.d.ts +14 -0
- package/lib/state/substates/SurveysState.js +98 -0
- package/lib/state/substates/TeamState.d.ts +11 -0
- package/lib/state/substates/TeamState.js +17 -0
- package/lib/state/substates/index.d.ts +15 -0
- package/lib/state/substates/index.js +19 -0
- package/lib/stories/assets/accessibility.png +0 -0
- package/lib/stories/assets/accessibility.svg +1 -0
- package/lib/stories/assets/addon-library.png +0 -0
- package/lib/stories/assets/assets.png +0 -0
- package/lib/stories/assets/context.png +0 -0
- package/lib/stories/assets/discord.svg +1 -0
- package/lib/stories/assets/docs.png +0 -0
- package/lib/stories/assets/figma-plugin.png +0 -0
- package/lib/stories/assets/github.svg +1 -0
- package/lib/stories/assets/share.png +0 -0
- package/lib/stories/assets/styling.png +0 -0
- package/lib/stories/assets/testing.png +0 -0
- package/lib/stories/assets/theming.png +0 -0
- package/lib/stories/assets/tutorials.svg +1 -0
- package/lib/stories/assets/youtube.svg +1 -0
- package/lib/stories/button.css +35 -0
- package/lib/stories/header.css +37 -0
- package/lib/stories/page.css +73 -0
- package/lib/test-setup.d.ts +1 -0
- package/lib/test-setup.js +57 -0
- package/lib/theme/DatalayerTheme.d.ts +37 -0
- package/lib/theme/DatalayerTheme.js +62 -0
- package/lib/theme/DatalayerThemeProvider.d.ts +17 -0
- package/lib/theme/DatalayerThemeProvider.js +69 -0
- package/lib/theme/Palette.d.ts +5 -0
- package/lib/theme/Palette.js +22 -0
- package/lib/theme/index.d.ts +3 -0
- package/lib/theme/index.js +7 -0
- package/lib/utils/Array.d.ts +2 -0
- package/lib/utils/Array.js +16 -0
- package/lib/utils/Avatar.d.ts +9 -0
- package/lib/utils/Avatar.js +34 -0
- package/lib/utils/Browser.d.ts +3 -0
- package/lib/utils/Browser.js +63 -0
- package/lib/utils/Cells.d.ts +2 -0
- package/lib/utils/Cells.js +28 -0
- package/lib/utils/Cookie.d.ts +12 -0
- package/lib/utils/Cookie.js +48 -0
- package/lib/utils/Date.d.ts +2 -0
- package/lib/utils/Date.js +60 -0
- package/lib/utils/Download.d.ts +3 -0
- package/lib/utils/Download.js +48 -0
- package/lib/utils/DownloadFile.d.ts +10 -0
- package/lib/utils/DownloadFile.js +36 -0
- package/lib/utils/Env.d.ts +1 -0
- package/lib/utils/Env.js +7 -0
- package/lib/utils/File.d.ts +7 -0
- package/lib/utils/File.js +16 -0
- package/lib/utils/Format.d.ts +17 -0
- package/lib/utils/Format.js +54 -0
- package/lib/utils/Ids.d.ts +2 -0
- package/lib/utils/Ids.js +12 -0
- package/lib/utils/Jupyter.d.ts +1 -0
- package/lib/utils/Jupyter.js +12 -0
- package/lib/utils/Lazy.d.ts +8 -0
- package/lib/utils/Lazy.js +23 -0
- package/lib/utils/Msc.d.ts +16 -0
- package/lib/utils/Msc.js +28 -0
- package/lib/utils/Name.d.ts +7 -0
- package/lib/utils/Name.js +34 -0
- package/lib/utils/Notebook.d.ts +19 -0
- package/lib/utils/Notebook.js +37 -0
- package/lib/utils/Number.d.ts +1 -0
- package/lib/utils/Number.js +21 -0
- package/lib/utils/Plots.d.ts +16 -0
- package/lib/utils/Plots.js +56 -0
- package/lib/utils/Random.d.ts +1 -0
- package/lib/utils/Random.js +7 -0
- package/lib/utils/Screenshot.d.ts +1 -0
- package/lib/utils/Screenshot.js +27 -0
- package/lib/utils/Scroll.d.ts +2 -0
- package/lib/utils/Scroll.js +32 -0
- package/lib/utils/Sleep.d.ts +2 -0
- package/lib/utils/Sleep.js +8 -0
- package/lib/utils/Snapshot.d.ts +7 -0
- package/lib/utils/Snapshot.js +21 -0
- package/lib/utils/String.d.ts +1 -0
- package/lib/utils/String.js +13 -0
- package/lib/utils/Uri.d.ts +2 -0
- package/lib/utils/Uri.js +26 -0
- package/lib/utils/Validator.d.ts +12 -0
- package/lib/utils/Validator.js +44 -0
- package/lib/utils/WithSuspense.d.ts +2 -0
- package/lib/utils/WithSuspense.js +21 -0
- package/lib/utils/index.d.ts +26 -0
- package/lib/utils/index.js +31 -0
- package/package.json +86 -17
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +62 -3
- package/style/index.css +2 -3
- package/style/index.js +0 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Icon } from "@primer/octicons-react";
|
|
2
|
+
import { IAnyItem, IItemType } from "../../models";
|
|
3
|
+
type IArtifactIconClassProp = {
|
|
4
|
+
item?: IAnyItem;
|
|
5
|
+
type?: IItemType;
|
|
6
|
+
size?: number | 'small' | 'medium' | 'large';
|
|
7
|
+
};
|
|
8
|
+
export declare const ArtifactIconClass: (props: IArtifactIconClassProp) => Icon;
|
|
9
|
+
export declare function ArtifactIcon(props: IArtifactIconClassProp): JSX.Element;
|
|
10
|
+
export default ArtifactIcon;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { createElement } from "react";
|
|
6
|
+
import { DatabaseIcon, RowsIcon, BookIcon, DiffModifiedIcon, PencilIcon, FeedIssueDraftIcon, FeedRocketIcon, MilestoneIcon, OrganizationIcon, PeopleIcon, RocketIcon, FileIcon, StackIcon, GearIcon, GraphIcon, NumberIcon, PaperAirplaneIcon, ArchiveIcon, TagIcon, MortarBoardIcon, ContainerIcon, HomeIcon, ShareIcon, FileDirectoryIcon, TrophyIcon, QuestionIcon, PersonIcon, MailIcon, ZapIcon, } from "@primer/octicons-react";
|
|
7
|
+
import { GalileoIcon, CircleWhiteIcon, BookOpenIcon, CameraIcon, CellIcon, NotebookOutlineIcon } from '@datalayer/icons-react';
|
|
8
|
+
const ARTIFACT_ICONS = new Map([
|
|
9
|
+
["assignment", MilestoneIcon],
|
|
10
|
+
["authoring", PencilIcon],
|
|
11
|
+
["cell", CellIcon],
|
|
12
|
+
["content", ArchiveIcon],
|
|
13
|
+
["credits", NumberIcon],
|
|
14
|
+
["dataset", StackIcon],
|
|
15
|
+
["datasource", DatabaseIcon],
|
|
16
|
+
["document", FileIcon],
|
|
17
|
+
["documentation", BookOpenIcon],
|
|
18
|
+
["environment", ContainerIcon],
|
|
19
|
+
["exercise", DiffModifiedIcon],
|
|
20
|
+
["growth", FeedRocketIcon],
|
|
21
|
+
["home", HomeIcon],
|
|
22
|
+
["invite", PaperAirplaneIcon],
|
|
23
|
+
["runtime", RocketIcon],
|
|
24
|
+
["runtime-snapshot", CameraIcon],
|
|
25
|
+
["library", BookIcon],
|
|
26
|
+
["lesson", MortarBoardIcon],
|
|
27
|
+
["mail", MailIcon],
|
|
28
|
+
["management", FeedIssueDraftIcon],
|
|
29
|
+
["notebook", RowsIcon],
|
|
30
|
+
["organization", OrganizationIcon],
|
|
31
|
+
["onboarding", ZapIcon],
|
|
32
|
+
["page", NotebookOutlineIcon],
|
|
33
|
+
["settings", GearIcon],
|
|
34
|
+
["share", ShareIcon],
|
|
35
|
+
["space", GalileoIcon],
|
|
36
|
+
["success", TrophyIcon],
|
|
37
|
+
["support", QuestionIcon],
|
|
38
|
+
["storage", FileDirectoryIcon],
|
|
39
|
+
["tag", TagIcon],
|
|
40
|
+
["team", PeopleIcon],
|
|
41
|
+
["usage", GraphIcon],
|
|
42
|
+
["user", PersonIcon],
|
|
43
|
+
["undefined", CircleWhiteIcon],
|
|
44
|
+
]);
|
|
45
|
+
export const ArtifactIconClass = (props) => {
|
|
46
|
+
const { item, type } = props;
|
|
47
|
+
const itemType = item?.type ?? type ?? "undefined";
|
|
48
|
+
const icon = ARTIFACT_ICONS.get(itemType);
|
|
49
|
+
return icon ?? CircleWhiteIcon;
|
|
50
|
+
};
|
|
51
|
+
export function ArtifactIcon(props) {
|
|
52
|
+
const { size } = props;
|
|
53
|
+
const artifactIconClass = ArtifactIconClass(props);
|
|
54
|
+
return createElement(artifactIconClass, {
|
|
55
|
+
size: size ?? 16,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export default ArtifactIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ArtifactIcon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { Label } from "@primer/react";
|
|
7
|
+
export const VisibilityLabel = (props) => {
|
|
8
|
+
const { isPublic } = props;
|
|
9
|
+
if (isPublic === undefined) {
|
|
10
|
+
return _jsx(_Fragment, {});
|
|
11
|
+
}
|
|
12
|
+
return (isPublic ?
|
|
13
|
+
_jsx(Label, { variant: "success", sx: { marginLeft: 3 }, children: "Public" })
|
|
14
|
+
:
|
|
15
|
+
_jsx(Label, { variant: "danger", sx: { marginLeft: 3 }, children: "Private" }));
|
|
16
|
+
};
|
|
17
|
+
export default VisibilityLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './VisibilityLabel';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IconProps } from "@primer/octicons-react";
|
|
2
|
+
type IStepBlockProps = {
|
|
3
|
+
date: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
StepIcon: React.FC<IconProps & {
|
|
7
|
+
colored?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export declare const StepBlock: (props: IStepBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default StepBlock;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, 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 { AnimationProvider, Stack, Heading, Text, Animate, Prose } from "@primer/react-brand";
|
|
7
|
+
import styles from './../../../style/animation/Animation.module.css';
|
|
8
|
+
export const StepBlock = (props) => {
|
|
9
|
+
const { date, title, description, StepIcon: BlockIcon } = props;
|
|
10
|
+
return (_jsx(AnimationProvider, { staggerDelayIncrement: 200, children: _jsx("div", { className: styles.TimelineBarExample, children: _jsxs(Stack, { direction: "horizontal", padding: "none", justifyContent: "center", children: [_jsxs(Stack, { direction: "vertical", className: styles.TimelineBarExample__end, children: [_jsx(Heading, { as: "h1", size: "6", animate: "slide-in-right", children: date }), _jsxs(Text, { className: styles.TimelineBarExample__text, as: "p", size: "600", animate: "slide-in-right", children: [_jsx(Text, { className: styles.TimelineBarExample__highlightedText, size: "600", children: title }), ' ', _jsx(Prose, { html: description })] }), _jsx(BlockIcon, { size: 100, colored: true })] }), _jsxs("div", { className: styles.TimelineBarExample__start, children: [_jsx(Animate, { className: styles.TimelineBarExample__line, animate: { variant: 'fill-in-top' } }), _jsx("span", { className: styles.TimelineBarExample__icon, children: _jsx(BlockIcon, { size: 24, fill: "white" }) })] })] }) }) }));
|
|
11
|
+
};
|
|
12
|
+
export default StepBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StepBlock';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, 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 React, { useCallback, useRef, useState } from 'react';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { ChevronDownIcon } from '@primer/octicons-react';
|
|
9
|
+
import { useVisibilityObserver } from '../../hooks/useVisibilityObserver';
|
|
10
|
+
import { useOnClickOutside } from '../../hooks/useOnClickOutside';
|
|
11
|
+
import { useKeyboardEscape } from '../../hooks/useKeyboardEscape';
|
|
12
|
+
import { useWindowSize } from '../../hooks/useWindowSize';
|
|
13
|
+
import styles from './SubdomainNavBar.module.css';
|
|
14
|
+
export function NavigationVisbilityObserver({ children, className, ...rest }) {
|
|
15
|
+
const navRef = useRef(null);
|
|
16
|
+
const [visibilityMap] = useVisibilityObserver(navRef, children);
|
|
17
|
+
const { isMedium } = useWindowSize();
|
|
18
|
+
const showOverflow = Object.values(visibilityMap).includes(false);
|
|
19
|
+
return (_jsxs("ul", { className: clsx(styles['SubdomainNavBar-primary-nav-list'], className), ref: navRef, ...rest, children: [React.Children.map(children, child => {
|
|
20
|
+
return React.cloneElement(child, {
|
|
21
|
+
className: clsx(child.props.className, isMedium &&
|
|
22
|
+
!!visibilityMap[child.props['data-navitemid']] &&
|
|
23
|
+
styles['SubdomainNavBar-primary-nav-list-item--visible'], isMedium &&
|
|
24
|
+
!visibilityMap[child.props['data-navitemid']] &&
|
|
25
|
+
styles['SubdomainNavBar-primary-nav-list-item--invisible']),
|
|
26
|
+
});
|
|
27
|
+
}), showOverflow && _jsx(AnchoredOverlay, { visibilityMap: visibilityMap, children: children })] }));
|
|
28
|
+
}
|
|
29
|
+
function AnchoredOverlay({ children, className, visibilityMap }) {
|
|
30
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
31
|
+
const ref = useRef(null);
|
|
32
|
+
useOnClickOutside(ref, () => handleClose());
|
|
33
|
+
const open = Boolean(anchorEl);
|
|
34
|
+
const handleClick = event => {
|
|
35
|
+
if (anchorEl) {
|
|
36
|
+
handleClose();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setAnchorEl(event.currentTarget);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleClose = useCallback(() => {
|
|
43
|
+
setAnchorEl(null);
|
|
44
|
+
}, []);
|
|
45
|
+
useKeyboardEscape(handleClose);
|
|
46
|
+
return (_jsxs("li", { className: clsx(styles['SubdomainNavBar-primary-nav-list-item--overflow'], className), ref: ref, children: [_jsxs("button", { "aria-expanded": open ? 'true' : 'false', "aria-controls": "more-navigation", "aria-haspopup": "true", onClick: handleClick, className: clsx(styles['SubdomainNavBar-link'], styles['SubdomainNavBar-more-link']), children: ["More", _jsx(ChevronDownIcon, {})] }), _jsx("div", { id: "more-navigation", style: { display: open ? 'block' : 'none' }, className: clsx(styles['SubdomainNavBar-overflow-menu']), children: _jsx("ul", { className: clsx(styles['SubdomainNavBar-overflow-menu-list']), children: React.Children.map(children, child => {
|
|
47
|
+
if (React.isValidElement(child)) {
|
|
48
|
+
const navItemChild = child.props['data-navitemid'];
|
|
49
|
+
if (!visibilityMap[navItemChild]) {
|
|
50
|
+
return (_jsx(React.Fragment, { children: React.cloneElement(child, {
|
|
51
|
+
onClick: handleClose,
|
|
52
|
+
className: clsx(styles['SubdomainNavBar-overflow-menu-item'], child.props.className),
|
|
53
|
+
}) }));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}) }) })] }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Design tokens
|
|
4
|
+
*/
|
|
5
|
+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes.css';
|
|
6
|
+
export type SubdomainNavBarProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Valid child elements are `SubdomainNavBar.Link`, `SubdomainNavBar.PrimaryAction`,
|
|
9
|
+
* `SubdomainNavBar.SecondaryAction` and `SubdomainNavBar.Search`
|
|
10
|
+
*/
|
|
11
|
+
children?: React.ReactNode | React.ReactElement<LinkProps> | React.ReactElement<SearchProps> | React.ReactElement<CTAActionProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Forward a custom HTML class attribute
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Fixes the navigation bar to the top of the viewport. Defaults to `true`.
|
|
18
|
+
*/
|
|
19
|
+
fixed?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Fill the maximum width of the parent container. Defaults to `false`.
|
|
22
|
+
*/
|
|
23
|
+
fullWidth?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The title or name of the subdomain. Appears adjacent to the logo and is required for communicating content to assisitive technologies.
|
|
26
|
+
*/
|
|
27
|
+
title: string;
|
|
28
|
+
/**
|
|
29
|
+
* The URL for the site. Typically used to link the titleText prop value to the site root.
|
|
30
|
+
*/
|
|
31
|
+
titleHref?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optionally change the URL of the logo
|
|
34
|
+
*/
|
|
35
|
+
logoHref?: string;
|
|
36
|
+
};
|
|
37
|
+
declare function Root({ children, className, fixed, fullWidth, logoHref, title, titleHref, ...rest }: SubdomainNavBarProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
type LinkProps = {
|
|
39
|
+
href: string;
|
|
40
|
+
isExternal?: boolean;
|
|
41
|
+
target?: string;
|
|
42
|
+
} & React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
|
|
43
|
+
declare function Link({ href, className, children, isExternal, target, ...rest }: PropsWithChildren<LinkProps>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export type SubdomainNavBarSearchResultProps = {
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
url: string;
|
|
48
|
+
date: string;
|
|
49
|
+
category?: string;
|
|
50
|
+
};
|
|
51
|
+
type SearchProps = {
|
|
52
|
+
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
|
|
53
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
54
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
55
|
+
active?: boolean;
|
|
56
|
+
title?: string;
|
|
57
|
+
handlerFn?: (event: MouseEvent | TouchEvent | FocusEvent) => void;
|
|
58
|
+
autoComplete?: boolean;
|
|
59
|
+
searchResults?: SubdomainNavBarSearchResultProps[];
|
|
60
|
+
searchTerm?: string;
|
|
61
|
+
};
|
|
62
|
+
type CTAActionProps = {
|
|
63
|
+
hasArrow?: boolean;
|
|
64
|
+
size?: string;
|
|
65
|
+
} & React.HTMLAttributes<HTMLAnchorElement>;
|
|
66
|
+
declare function PrimaryAction({ children, ...rest }: PropsWithChildren<CTAActionProps>): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
declare function SecondaryAction({ children, ...rest }: PropsWithChildren<CTAActionProps>): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export declare const SubdomainNavBar: typeof Root & {
|
|
69
|
+
Link: typeof Link;
|
|
70
|
+
Search: React.ForwardRefExoticComponent<Omit<SearchProps, "ref"> & React.RefAttributes<unknown>>;
|
|
71
|
+
PrimaryAction: typeof PrimaryAction;
|
|
72
|
+
SecondaryAction: typeof SecondaryAction;
|
|
73
|
+
testIds: {
|
|
74
|
+
root: string;
|
|
75
|
+
readonly innerContainer: string;
|
|
76
|
+
readonly menuButton: string;
|
|
77
|
+
readonly menuLinks: string;
|
|
78
|
+
readonly liveRegion: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,235 @@
|
|
|
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 React, { useState, useCallback, useRef, forwardRef, useMemo, useEffect } from 'react';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { SearchIcon, XIcon, LinkExternalIcon } from '@primer/octicons-react';
|
|
9
|
+
import { Button, FormControl, Text, TextInput, Label } from '@primer/react-brand';
|
|
10
|
+
import { CircleYellowIcon } from '@datalayer/icons-react';
|
|
11
|
+
import { NavigationVisbilityObserver } from './NavigationVisbilityObserver';
|
|
12
|
+
import { useCoreStore } from "../../state";
|
|
13
|
+
import { useOnClickOutside, useFocusTrap, useKeyboardEscape, useWindowSize, useNavigate } from "../../hooks";
|
|
14
|
+
import { useRunStore } from "../../state";
|
|
15
|
+
import { useId } from '../../hooks';
|
|
16
|
+
/**
|
|
17
|
+
* Design tokens
|
|
18
|
+
*/
|
|
19
|
+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes.css';
|
|
20
|
+
/** * Main Stylesheet (as a CSS Module) */
|
|
21
|
+
import styles from './SubdomainNavBar.module.css';
|
|
22
|
+
const testIds = {
|
|
23
|
+
root: 'SubdomainNavBar',
|
|
24
|
+
get innerContainer() {
|
|
25
|
+
return `${this.root}-inner-container`;
|
|
26
|
+
},
|
|
27
|
+
get menuButton() {
|
|
28
|
+
return `${this.root}-menuButton`;
|
|
29
|
+
},
|
|
30
|
+
get menuLinks() {
|
|
31
|
+
return `${this.root}-menuLinks`;
|
|
32
|
+
},
|
|
33
|
+
get liveRegion() {
|
|
34
|
+
return `${this.root}-search-live-region`;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
function Root({ children, className, fixed = true, fullWidth = false, logoHref = 'https://datalayer.app', title, titleHref = '/', ...rest }) {
|
|
38
|
+
const navigate = useNavigate();
|
|
39
|
+
const runStore = useRunStore();
|
|
40
|
+
const { configuration } = useCoreStore();
|
|
41
|
+
const { isMedium } = useWindowSize();
|
|
42
|
+
const isDev = runStore.isDev;
|
|
43
|
+
const [menuHidden, setMenuHidden] = useState(true);
|
|
44
|
+
const [searchVisible, setSearchVisible] = useState(false);
|
|
45
|
+
const [startOfContentButtonFocused, setStartOfContentButtonFocused] = useState(false);
|
|
46
|
+
const mainElRef = useRef(null);
|
|
47
|
+
const startOfContentID = useId('dla-start-of-content');
|
|
48
|
+
const handleMobileMenuClick = () => setMenuHidden(!menuHidden);
|
|
49
|
+
const handleSearchVisibility = () => setSearchVisible(!searchVisible);
|
|
50
|
+
const focusTrapRef = useRef(null);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const mainEl = document.querySelector('main');
|
|
53
|
+
if (mainEl) {
|
|
54
|
+
mainEl.id = mainEl.id || startOfContentID;
|
|
55
|
+
mainElRef.current = mainEl;
|
|
56
|
+
}
|
|
57
|
+
}, [startOfContentID]);
|
|
58
|
+
useFocusTrap({ containerRef: focusTrapRef, restoreFocusOnCleanUp: true, disabled: menuHidden });
|
|
59
|
+
useKeyboardEscape(() => {
|
|
60
|
+
setMenuHidden(true);
|
|
61
|
+
});
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (isMedium) {
|
|
64
|
+
setMenuHidden(true);
|
|
65
|
+
}
|
|
66
|
+
}, [isMedium, menuHidden]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const newOverflowState = menuHidden ? 'auto' : 'hidden';
|
|
69
|
+
document.body.style.overflow = newOverflowState;
|
|
70
|
+
}, [menuHidden]);
|
|
71
|
+
const setStartOfContentButtonFocusedTrue = useCallback(() => setStartOfContentButtonFocused(true), []);
|
|
72
|
+
const setStartOfContentButtonFocusedFalse = useCallback(() => setStartOfContentButtonFocused(false), []);
|
|
73
|
+
const hasLinks = useMemo(() => React.Children.toArray(children).filter(child => React.isValidElement(child) && typeof child.type !== 'string' && child.type === Link),
|
|
74
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
+
[]).length > 0;
|
|
76
|
+
const menuItems = useMemo(() => React.Children.toArray(children)
|
|
77
|
+
.map((child, index) => {
|
|
78
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
79
|
+
if (child.type === Link) {
|
|
80
|
+
return React.cloneElement(child, {
|
|
81
|
+
'data-navitemid': child.props.children,
|
|
82
|
+
href: child.props.href,
|
|
83
|
+
children: child.props.children,
|
|
84
|
+
style: {
|
|
85
|
+
[`--animation-order`]: index,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
.filter(Boolean), [children]);
|
|
93
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx(styles['SubdomainNavBar-outer-container'], fixed && styles['SubdomainNavBar-outer-container--fixed']), children: [_jsx(Button, { as: "a", href: `#${mainElRef.current?.id || startOfContentID}`, variant: "primary", className: clsx(styles['SubdomainNavBar-skip-to-content'], !startOfContentButtonFocused && 'visually-hidden'), onFocus: setStartOfContentButtonFocusedTrue, onBlur: setStartOfContentButtonFocusedFalse, children: "Skip to content" }), _jsx("header", { className: clsx(styles['SubdomainNavBar'], className), "data-testid": testIds.root, ...rest, children: _jsxs("div", { ref: focusTrapRef, className: clsx(styles['SubdomainNavBar-inner-container'], searchVisible && styles['SubdomainNavBar-inner-container--search-open'], !fullWidth && styles['SubdomainNavBar-inner-container--centered']), "data-testid": testIds.innerContainer, children: [_jsx("nav", { "aria-label": "global breadcrumb", children: _jsxs("ol", { className: styles['SubdomainNavBar-title-area'], children: [_jsx("li", { children: _jsx("a", { href: "javascript: return false;", "aria-label": "Datalayer Home", className: styles['SubdomainNavBar-logo-mark'], onClick: e => navigate('/', e), children: _jsx("img", { src: configuration.brand.logoUrl, style: { height: 25 } }) }) }), isDev &&
|
|
94
|
+
_jsx("li", { children: _jsx(Label, { leadingVisual: _jsx(CircleYellowIcon, {}), color: "green-blue", children: "DEV" }) })] }) }), hasLinks && (_jsx("nav", { id: "menu-navigation", "aria-label": title, className: styles['SubdomainNavBar-primary-nav'], "data-testid": testIds.menuLinks, children: _jsx(NavigationVisbilityObserver, { className: clsx(styles['SubdomainNavBar-primary-nav-list--invisible']), children: menuItems }) })), _jsxs("div", { className: clsx(styles['SubdomainNavBar-secondary-nav']), children: [React.Children.toArray(children)
|
|
95
|
+
.map(child => {
|
|
96
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
97
|
+
if (child.type === Search) {
|
|
98
|
+
return React.cloneElement(child, {
|
|
99
|
+
active: searchVisible,
|
|
100
|
+
handlerFn: handleSearchVisibility,
|
|
101
|
+
title,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.filter(Boolean), hasLinks && (_jsxs("button", { "aria-expanded": !menuHidden, "aria-label": "Menu", "aria-controls": "menu-navigation", "aria-haspopup": "true", className: clsx(styles['SubdomainNavBar-menu-button'], styles['SubdomainNavBar-mobile-menu-button'], !menuHidden && styles['SubdomainNavBar-menu-button--close']), "data-testid": testIds.menuButton, onClick: handleMobileMenuClick, children: [_jsx("div", { className: clsx(styles['SubdomainNavBar-menu-button-bar']) }), _jsx("div", { className: clsx(styles['SubdomainNavBar-menu-button-bar']) }), _jsx("div", { className: clsx(styles['SubdomainNavBar-menu-button-bar']) })] })), isMedium && (_jsx("div", { className: clsx(styles['SubdomainNavBar-button-area'], styles['SubdomainNavBar-button-area--visible']), children: _jsxs("div", { className: styles['SubdomainNavBar-button-area-inner'], children: [React.Children.toArray(children)
|
|
108
|
+
.map(child => {
|
|
109
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
110
|
+
if (child.type === PrimaryAction) {
|
|
111
|
+
return child;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
.filter(Boolean), React.Children.toArray(children)
|
|
117
|
+
.map(child => {
|
|
118
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
119
|
+
if (child.type === SecondaryAction) {
|
|
120
|
+
return child;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
.filter(Boolean)] }) })), !isMedium && (_jsxs("div", { className: clsx(styles['SubdomainNavBar-menu-wrapper'], menuHidden && styles['SubdomainNavBar-menu-wrapper--close']), children: [_jsxs("div", { children: [title && titleHref && (_jsx(Text, { as: "p", children: _jsx("a", { href: titleHref, "aria-label": `${title} home`, className: clsx(styles['SubdomainNavBar-link'], styles['SubdomainNavBar-link--title']), children: title }) })), hasLinks && !menuHidden && (_jsx(NavigationVisbilityObserver, { showOnlyOnNarrow: true, className: clsx(styles['SubdomainNavBar-primary-nav-list--visible']), children: menuItems }))] }), _jsx("div", { className: clsx(styles['SubdomainNavBar-button-area'], styles['SubdomainNavBar-button-area--visible']), children: _jsxs("div", { className: styles['SubdomainNavBar-button-area-inner'], children: [React.Children.toArray(children)
|
|
126
|
+
.map(child => {
|
|
127
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
128
|
+
if (child.type === PrimaryAction) {
|
|
129
|
+
return child;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
.filter(Boolean), React.Children.toArray(children)
|
|
135
|
+
.map(child => {
|
|
136
|
+
if (React.isValidElement(child) && typeof child.type !== 'string') {
|
|
137
|
+
if (child.type === SecondaryAction) {
|
|
138
|
+
return child;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.filter(Boolean)] }) })] }))] })] }) })] }), !mainElRef.current && _jsx("div", { id: `${startOfContentID}`, tabIndex: -1 })] }));
|
|
144
|
+
}
|
|
145
|
+
function Link({ href, className, children, isExternal, target, ...rest }) {
|
|
146
|
+
return (_jsx("li", { className: clsx(styles['SubdomainNavBar-primary-nav-list-item'], className), ...rest, children: _jsxs("a", { href: href, target: target ?? "_self", className: clsx(styles['SubdomainNavBar-link']), children: [_jsx("span", { className: clsx(styles['SubdomainNavBar-link-text']), children: children }), isExternal && _jsx(LinkExternalIcon, { size: 16, "aria-label": "External link" })] }) }));
|
|
147
|
+
}
|
|
148
|
+
const SearchInternal = ({ active, title, searchResults, searchTerm, handlerFn, onSubmit, onChange }, ref) => {
|
|
149
|
+
const dialogRef = useRef(null);
|
|
150
|
+
useFocusTrap({ containerRef: dialogRef, restoreFocusOnCleanUp: true, disabled: !active });
|
|
151
|
+
useOnClickOutside(dialogRef, handlerFn);
|
|
152
|
+
const [activeDescendant, setActiveDescendant] = useState(-1);
|
|
153
|
+
const [listboxActive, setListboxActive] = useState();
|
|
154
|
+
const [liveRegion, setLiveRegion] = useState(false);
|
|
155
|
+
const handleClose = useCallback((event = null) => {
|
|
156
|
+
if (handlerFn)
|
|
157
|
+
handlerFn(event);
|
|
158
|
+
setActiveDescendant(-1);
|
|
159
|
+
}, [handlerFn]);
|
|
160
|
+
useOnClickOutside(dialogRef, handleClose);
|
|
161
|
+
useKeyboardEscape(() => {
|
|
162
|
+
// Close the dialog if combobox is already collapsed
|
|
163
|
+
if (!listboxActive && active) {
|
|
164
|
+
handleClose();
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
setListboxActive(false);
|
|
168
|
+
setActiveDescendant(-1);
|
|
169
|
+
});
|
|
170
|
+
const handleAriaFocus = useCallback(event => {
|
|
171
|
+
const supportedKeys = ['ArrowDown', 'ArrowUp', 'Escape', 'Enter'];
|
|
172
|
+
const currentCount = activeDescendant;
|
|
173
|
+
const searchResultsLength = searchResults ? searchResults.length : 0;
|
|
174
|
+
const dialog = dialogRef.current;
|
|
175
|
+
let count;
|
|
176
|
+
// Prevent any other keys outside of supported from being prevented.
|
|
177
|
+
// Only prevent "Enter" if activeDescendant is greater than -1.
|
|
178
|
+
if (!supportedKeys.includes(event.key) || (event.key === 'Enter' && activeDescendant === -1) || !dialog) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
if (event.key === 'ArrowDown') {
|
|
183
|
+
// If count reaches last search result item, reset to -1
|
|
184
|
+
count = currentCount < searchResultsLength - 1 ? currentCount + 1 : -1;
|
|
185
|
+
setActiveDescendant(count);
|
|
186
|
+
}
|
|
187
|
+
else if (event.key === 'ArrowUp') {
|
|
188
|
+
// Reset to last search result item if
|
|
189
|
+
count = currentCount === -1 ? searchResultsLength - 1 : currentCount - 1;
|
|
190
|
+
setActiveDescendant(count);
|
|
191
|
+
}
|
|
192
|
+
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
193
|
+
dialog.querySelector(`#subdomainnavbar-search-result-${count}`)?.scrollIntoView();
|
|
194
|
+
}
|
|
195
|
+
if (event.key === 'Enter') {
|
|
196
|
+
const link = dialog.querySelector(`#subdomainnavbar-search-result-${activeDescendant} a`);
|
|
197
|
+
link.click();
|
|
198
|
+
}
|
|
199
|
+
}, [searchResults, activeDescendant]);
|
|
200
|
+
const searchLiveRegion = useCallback(() => {
|
|
201
|
+
// Adding a non-breaking space and then removing it will force screen readers to announce the text,
|
|
202
|
+
// as it thinks that there was a change within the live region.
|
|
203
|
+
setLiveRegion(true);
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
if (active)
|
|
206
|
+
setLiveRegion(false);
|
|
207
|
+
}, 200);
|
|
208
|
+
}, [active]);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
// We want to set "listboxActive" when search results are present,
|
|
211
|
+
// or the user pressed "Escape". We watch for "searchTerm", as we -
|
|
212
|
+
// want the listbox to become active if they pressed "Escape", and -
|
|
213
|
+
// adjusted their existing value.
|
|
214
|
+
const search = searchResults && searchResults.length ? true : false;
|
|
215
|
+
setListboxActive(search);
|
|
216
|
+
searchLiveRegion();
|
|
217
|
+
}, [searchResults, searchTerm, searchLiveRegion]);
|
|
218
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: clsx(styles['SubdomainNavBar-search-trigger']), children: _jsx("button", { "aria-label": "search", className: styles['SubdomainNavBar-search-button'], onClick: handlerFn, "data-testid": "toggle-search", children: _jsx(SearchIcon, {}) }) }), active && (_jsxs("div", { ref: dialogRef, role: "dialog", "aria-label": `Search ${title}`, "aria-modal": "true", tabIndex: -1, className: clsx(styles['SubdomainNavBar-search-dialog']), children: [_jsxs("div", { className: clsx(styles['SubdomainNavBar-search-dialog-control-area']), children: [_jsx("form", { className: clsx(styles['SubdomainNavBar-search-form']), onSubmit: onSubmit, role: "search", children: _jsxs(FormControl, { fullWidth: true, size: "medium", children: [_jsx(FormControl.Label, { visuallyHidden: true, children: "Search" }), _jsx(TextInput, { ref: ref, className: clsx(styles['SubdomainNavBar-search-text-input']), name: "search", role: "combobox", "aria-expanded": listboxActive, "aria-controls": "listbox-search-results", placeholder: `Search ${title}`, onChange: onChange, defaultValue: searchTerm, invisible: true, leadingVisual: _jsx(SearchIcon, { size: 16 }), "aria-activedescendant": activeDescendant === -1 ? undefined : `subdomainnavbar-search-result-${activeDescendant}`, onKeyDown: handleAriaFocus })] }) }), _jsx("button", { "aria-label": "Close", className: clsx(styles['SubdomainNavBar-menu-button'], styles['SubdomainNavBar-menu-button--close']), onClick: handleClose, children: _jsx(XIcon, { size: 24 }) })] }), _jsxs("div", { id: "listbox-search-results", children: [listboxActive && (_jsxs("div", { className: clsx(styles['SubdomainNavBar-search-results-container']), children: [_jsxs(Text, { id: "subdomainnavbar-search-results-heading", className: styles['SubdomainNavBar-search-results-heading'], children: ["Results for \u201C", searchTerm, "\u201D"] }), _jsx("ul", { role: "listbox", tabIndex: 0, "aria-labelledby": "subdomainnavbar-search-results-heading", className: clsx(styles['SubdomainNavBar-search-results']), children: searchResults?.map((result, index) => (_jsxs("li", { id: `subdomainnavbar-search-result-${index}`, className: styles['SubdomainNavBar-search-result-item'], role: "option", "aria-selected": index === activeDescendant, children: [_jsx("div", { className: styles['SubdomainNavBar-search-result-item-container'], children: _jsx("a", { href: result.url, children: result.title }) }), _jsx(Text, { as: "p", size: "200", id: `subdomainnavbar-search-result-item-desc${index}`, className: styles['SubdomainNavBar-search-result-item-desc'], children: result.description }), _jsxs("div", { children: [_jsx(Text, { size: "100", className: styles['SubdomainNavBar-search-result-item-desc'], children: result.date }), result.category && (_jsxs(_Fragment, { children: [_jsxs(Text, { size: "100", className: styles['SubdomainNavBar-search-result-item-desc'], children: [' ', "\u2022", ' '] }), _jsx(Text, { size: "100", className: styles['SubdomainNavBar-search-result-item-desc'], children: result.category })] }))] })] }, `${result.title}-${index}`))) })] })), _jsxs("div", { "aria-live": "polite", "aria-atomic": "true", "data-testid": testIds.liveRegion, className: "visually-hidden", children: [`${searchResults?.length} suggestions.`, liveRegion && _jsx("span", { children: "\u00A0" })] })] })] }))] }));
|
|
219
|
+
};
|
|
220
|
+
const Search = forwardRef(SearchInternal);
|
|
221
|
+
function PrimaryAction({ children, ...rest }) {
|
|
222
|
+
const { hasArrow = false, size = "small" } = rest;
|
|
223
|
+
return (_jsx(Button, { as: "a", href: "javascript: return false;", className: clsx(styles['SubdomainNavBar-cta-button']), variant: "primary", size: size, hasArrow: hasArrow, ...rest, children: children }));
|
|
224
|
+
}
|
|
225
|
+
function SecondaryAction({ children, ...rest }) {
|
|
226
|
+
const { hasArrow = false, size = "small" } = rest;
|
|
227
|
+
return (_jsx(Button, { as: "a", href: "javascript: return false;", className: clsx(styles['SubdomainNavBar-cta-button'], styles['SubdomainNavBar-cta-button--secondary']), size: size, hasArrow: hasArrow, ...rest, children: children }));
|
|
228
|
+
}
|
|
229
|
+
export const SubdomainNavBar = Object.assign(Root, {
|
|
230
|
+
Link,
|
|
231
|
+
Search,
|
|
232
|
+
PrimaryAction,
|
|
233
|
+
SecondaryAction,
|
|
234
|
+
testIds,
|
|
235
|
+
});
|