@espressif/dashboard-ui-components 1.10.0 → 1.11.1
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/CHANGELOG.md +75 -0
- package/dist/_vendor/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/_vendor/@radix-ui/react-checkbox/dist/index.js +185 -0
- package/dist/_vendor/@radix-ui/react-compose-refs/dist/index.js +28 -0
- package/dist/_vendor/@radix-ui/react-context/dist/index.js +68 -0
- package/dist/_vendor/@radix-ui/react-presence/dist/index.js +127 -0
- package/dist/_vendor/@radix-ui/react-primitive/dist/index.js +42 -0
- package/dist/_vendor/@radix-ui/react-use-controllable-state/dist/index.js +55 -0
- package/dist/_vendor/@radix-ui/react-use-layout-effect/dist/index.js +5 -0
- package/dist/_vendor/@radix-ui/react-use-previous/dist/index.js +17 -0
- package/dist/_vendor/@radix-ui/react-use-size/dist/index.js +39 -0
- package/dist/_vendor/lottie-react/build/index.es.js +537 -0
- package/dist/_vendor/lottie-web/build/player/lottie.js +14149 -0
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/assets/illustrations/bulb-cloud-drawing.js +4 -0
- package/dist/assets/illustrations/rm-dashboard-update.js +4 -0
- package/dist/assets/illustrations/rm-data-download.js +4 -0
- package/dist/assets/logos/espressif/espressif-no-text.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text-dm.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text.js +4 -0
- package/dist/assets/logos/insights/insights-no-text.js +4 -0
- package/dist/assets/logos/insights/insights-with-text-dm.js +4 -0
- package/dist/assets/logos/insights/insights-with-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-no-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text-dm.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-no-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-no-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text-dm.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-no-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-no-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text.js +4 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.constants.js +18 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.js +24 -0
- package/dist/common/animated-rainmaker-logo/rainmaker-c-logo.js +50 -0
- package/dist/common/animated-rainmaker-logo/use-animated-rainmaker-logo-animation.js +85 -0
- package/dist/common/app-logo/app-logo.js +59 -0
- package/dist/common/app-logo/logo-config.js +297 -0
- package/dist/common/copyright-card/copyright-card.js +39 -0
- package/dist/common/footer-card/footer-card.js +22 -0
- package/dist/common/index.js +8 -8
- package/dist/common/my-account-menu/my-account-menu.js +32 -0
- package/dist/common/page-loader/page-loader.js +21 -0
- package/dist/common/profile-card/profile-card.js +26 -0
- package/dist/components/accordion/accordion.js +52 -0
- package/dist/components/advanced-search-box/advanced-search-box.js +106 -0
- package/dist/components/alert/alert.js +85 -0
- package/dist/components/animated-containers/pop-collection-item.js +28 -0
- package/dist/components/async-multi-select/async-multi-select.js +199 -0
- package/dist/components/avatar/avatar.js +41 -0
- package/dist/components/button/button.js +191 -0
- package/dist/components/button/flash-button.js +110 -0
- package/dist/components/button/invert-button.js +13 -0
- package/dist/components/calendar/calendar.js +105 -0
- package/dist/components/cards/animated-card/animated-card-animations.js +57 -0
- package/dist/components/cards/animated-card/animated-card.js +42 -0
- package/dist/components/cards/basic-details-card.js +46 -0
- package/dist/components/cards/collapsible-card.js +48 -0
- package/dist/components/cards/no-data-card/no-data-card.js +30 -0
- package/dist/components/cards/section-card.js +265 -0
- package/dist/components/cards/simple-card.js +24 -0
- package/dist/components/carousel/carousel.js +158 -0
- package/dist/components/chart/area-chart.js +135 -0
- package/dist/components/chart/bar-chart.js +151 -0
- package/dist/components/chart/chart-colors.js +85 -0
- package/dist/components/chart/chart-series-data.js +53 -0
- package/dist/components/chart/chart.js +147 -0
- package/dist/components/chart/chart.types.js +7 -0
- package/dist/components/chart/composed-chart.js +182 -0
- package/dist/components/chart/donut-chart.js +177 -0
- package/dist/components/chart/line-chart.js +137 -0
- package/dist/components/chart/treemap-chart.js +294 -0
- package/dist/components/circular-progress/circular-progress.js +125 -0
- package/dist/components/code-editor/code-editor.js +235 -0
- package/dist/components/code-editor/code-editor.utils.js +122 -0
- package/dist/components/code-editor/use-code-editor-keys.js +79 -0
- package/dist/components/code-editor/use-highlighted-html.js +102 -0
- package/dist/components/confirmation-dialog/confirmation-dialog.js +72 -0
- package/dist/components/content-container/content-container.js +20 -0
- package/dist/components/copiable-text/copiable-text.js +46 -0
- package/dist/components/data-table/data-table.js +186 -0
- package/dist/components/data-table/responsive-columns.js +65 -0
- package/dist/components/data-table/row-actions.js +27 -0
- package/dist/components/data-table/sticky-columns.js +71 -0
- package/dist/components/data-table/table-body.js +57 -0
- package/dist/components/data-table/table-header.js +21 -0
- package/dist/components/date-picker/date-picker.js +95 -0
- package/dist/components/date-range-picker/date-range-picker.js +301 -0
- package/dist/components/date-range-picker/presets.js +174 -0
- package/dist/components/date-time-picker/date-time-picker.js +144 -0
- package/dist/components/date-time-picker/date-time-picker.utils.js +32 -0
- package/dist/components/device-icon/device-icon.config.js +194 -0
- package/dist/components/device-icon/device-icon.js +17 -0
- package/dist/components/device-icon/icons/air-conditioner.js +22 -0
- package/dist/components/device-icon/icons/blind.js +24 -0
- package/dist/components/device-icon/icons/dimmer.js +14 -0
- package/dist/components/device-icon/icons/extension-board.js +42 -0
- package/dist/components/device-icon/icons/fan.js +14 -0
- package/dist/components/device-icon/icons/knob.js +14 -0
- package/dist/components/device-icon/icons/led-strip.js +22 -0
- package/dist/components/device-icon/icons/light.js +14 -0
- package/dist/components/device-icon/icons/refrigerator.js +18 -0
- package/dist/components/device-icon/icons/retro-switch.js +18 -0
- package/dist/components/device-icon/icons/router.js +20 -0
- package/dist/components/device-icon/icons/sensor.js +20 -0
- package/dist/components/device-icon/icons/socket.js +19 -0
- package/dist/components/device-icon/icons/switch.js +19 -0
- package/dist/components/device-icon/icons/thermostat.js +21 -0
- package/dist/components/device-icon/icons/washing-machine.js +22 -0
- package/dist/components/device-icon/match-device.js +61 -0
- package/dist/components/dynamic-list/dynamic-list.js +445 -0
- package/dist/components/error-display/full-size-error/full-size-error.js +20 -0
- package/dist/components/error-display/inline-error/inline-error.js +12 -0
- package/dist/components/file-input/file-input.js +318 -0
- package/dist/components/file-upload/file-upload.js +317 -0
- package/dist/components/filters-bar/filters-bar.js +36 -0
- package/dist/components/fullscreen-dialog/fullscreen-dialog.js +68 -0
- package/dist/components/icon-avatar/icon-avatar.js +130 -0
- package/dist/components/icon-text-action-card/icon-text-action-card.js +190 -0
- package/dist/components/illustration/illustration-registry.js +37 -0
- package/dist/components/illustration/illustration-variants.js +21 -0
- package/dist/components/illustration/illustration.js +68 -0
- package/dist/components/index.d.ts +0 -20
- package/dist/components/index.js +134 -6
- package/dist/components/key-value-manager/key-value-manager-add-popover.js +126 -0
- package/dist/components/key-value-manager/key-value-manager-field.js +47 -0
- package/dist/components/key-value-manager/key-value-manager-table.js +188 -0
- package/dist/components/key-value-manager/key-value-manager.js +111 -0
- package/dist/components/key-value-manager/key-value-manager.props.js +28 -0
- package/dist/components/key-value-manager/key-value-manager.utils.js +21 -0
- package/dist/components/link/link.js +67 -0
- package/dist/components/list/dropdown-list-item.js +60 -0
- package/dist/components/list/list-item.utils.js +76 -0
- package/dist/components/list/list.js +49 -0
- package/dist/components/list/list.props.js +27 -0
- package/dist/components/list/standard-list-item.js +66 -0
- package/dist/components/list-details/list-details-item-button.js +46 -0
- package/dist/components/list-details/list-details-item-dropdown.js +112 -0
- package/dist/components/list-details/list-details-item-strip.js +125 -0
- package/dist/components/list-details/list-details.js +148 -0
- package/dist/components/lottie-animation-container/lottie-animation-container.js +31 -0
- package/dist/components/lottie-animations/animation-data/access-denied.js +3980 -0
- package/dist/components/lottie-animations/animation-data/active.js +825 -0
- package/dist/components/lottie-animations/animation-data/bar-chart.js +610 -0
- package/dist/components/lottie-animations/animation-data/chart-loading.js +5368 -0
- package/dist/components/lottie-animations/animation-data/cloud-download.js +1660 -0
- package/dist/components/lottie-animations/animation-data/cloud-sync.js +932 -0
- package/dist/components/lottie-animations/animation-data/coud-upload.js +7060 -0
- package/dist/components/lottie-animations/animation-data/cross-throb.js +1506 -0
- package/dist/components/lottie-animations/animation-data/dashboard-loading.js +14330 -0
- package/dist/components/lottie-animations/animation-data/error-spread-out.js +5567 -0
- package/dist/components/lottie-animations/animation-data/error.js +1211 -0
- package/dist/components/lottie-animations/animation-data/green-success.js +14826 -0
- package/dist/components/lottie-animations/animation-data/inactive.js +723 -0
- package/dist/components/lottie-animations/animation-data/light.js +2678 -0
- package/dist/components/lottie-animations/animation-data/lock.js +900 -0
- package/dist/components/lottie-animations/animation-data/lock2.js +1686 -0
- package/dist/components/lottie-animations/animation-data/locked.js +641 -0
- package/dist/components/lottie-animations/animation-data/search-error.js +954 -0
- package/dist/components/lottie-animations/animation-data/security.js +4121 -0
- package/dist/components/lottie-animations/animation-data/success.js +404 -0
- package/dist/components/lottie-animations/animation-data/verification-in-progress.js +10138 -0
- package/dist/components/lottie-animations/animation-data/warning.js +843 -0
- package/dist/components/lottie-animations/verification-in-progress/verification-in-progress.js +19 -0
- package/dist/components/markdown-content/markdown-content.components.js +114 -0
- package/dist/components/markdown-content/markdown-content.js +39 -0
- package/dist/components/menu/menu.js +19 -0
- package/dist/components/monospace-content/monospace-content.js +80 -0
- package/dist/components/nav-bar/nav-bar-details-panel.js +51 -0
- package/dist/components/nav-bar/nav-bar-mobile-menu.js +105 -0
- package/dist/components/nav-bar/nav-bar.js +449 -0
- package/dist/components/nav-bar/use-nav-bar-overflow.js +74 -0
- package/dist/components/nav-bar/use-nav-bar-scroll.js +42 -0
- package/dist/components/overflow-badge-list/overflow-badge-list.js +58 -0
- package/dist/components/page-container/page-container-skeleton.js +72 -0
- package/dist/components/page-container/page-container.js +93 -0
- package/dist/components/pagination/pagination.js +96 -0
- package/dist/components/pagination/pagination.props.js +16 -0
- package/dist/components/progress-bar/progress-bar.js +106 -0
- package/dist/components/radio-group/radio-group.js +41 -0
- package/dist/components/requirement-list/requirement-list.js +83 -0
- package/dist/components/scrollable-sections/scrollable-sections.js +270 -0
- package/dist/components/search-box/search-box.js +54 -0
- package/dist/components/search-field-shell.js +24 -0
- package/dist/components/selectable-card-list/checkbox-card-list.js +85 -0
- package/dist/components/selectable-card-list/radio-card-list.js +99 -0
- package/dist/components/selectable-card-list/selectable-card-list-shared.js +135 -0
- package/dist/components/selectable-card-list/selectable-card-list.js +34 -0
- package/dist/components/sidebar/sidebar.js +344 -0
- package/dist/components/sidebar/types.js +6 -0
- package/dist/components/simple-clickable-card/simple-clickable-card-shared.js +309 -0
- package/dist/components/simple-clickable-card/simple-clickable-card.js +106 -0
- package/dist/components/simple-info-card/simple-info-card.js +154 -0
- package/dist/components/simple-list/simple-list.js +146 -0
- package/dist/components/simple-paginated-list/simple-paginated-list.js +178 -0
- package/dist/components/simplified-date/simplified-date.js +56 -0
- package/dist/components/skeletons/table-skeleton.js +16 -0
- package/dist/components/spinner/spinner.js +25 -0
- package/dist/components/stat-card/stat-card.js +206 -0
- package/dist/components/status-badge/status-badge.js +108 -0
- package/dist/components/status-card-list/status-card-list.js +282 -0
- package/dist/components/tag/tag.js +144 -0
- package/dist/components/tag-input/tag-input.js +161 -0
- package/dist/components/text-effects/glitch-effect/glitch-text.js +115 -0
- package/dist/components/text-effects/gradient-text/gradient-text.js +32 -0
- package/dist/components/text-effects/highlight-text/highlight-text.js +35 -0
- package/dist/components/text-effects/parse-text-markup.js +53 -0
- package/dist/components/text-effects/shimmer-text/shimmer-text.js +67 -0
- package/dist/components/time-picker/time-picker.js +23 -0
- package/dist/components/toast/toast.js +126 -0
- package/dist/components/togglable-items-list/togglable-items-list.js +28 -0
- package/dist/components/tooltip/tooltip.js +21 -0
- package/dist/components/transfer-list/transfer-list.js +413 -0
- package/dist/components/truncated-line-with-tooltip/truncated-line-with-tooltip.js +61 -0
- package/dist/components/typography/typography-variants.js +41 -0
- package/dist/components/typography/typography.js +15 -0
- package/dist/components/user-type-badge/user-type-badge.js +40 -0
- package/dist/components/user-type-badge/user-type-badge.registry.js +17 -0
- package/dist/components/vertical-stepper/vertical-stepper.js +171 -0
- package/dist/core/alert.js +33 -0
- package/dist/core/animate-ui/components/animate/code-header.js +30 -0
- package/dist/core/animate-ui/components/animate/code.js +35 -0
- package/dist/core/animate-ui/components/animate/tabs.js +188 -0
- package/dist/core/animate-ui/components/animate/tooltip.js +39 -0
- package/dist/core/animate-ui/components/base/preview-card.js +29 -0
- package/dist/core/animate-ui/components/base/progress.js +32 -0
- package/dist/core/animate-ui/components/base/radio.js +24 -0
- package/dist/core/animate-ui/components/buttons/copy.js +95 -0
- package/dist/core/animate-ui/components/radix/accordion.js +36 -0
- package/dist/core/animate-ui/components/radix/dialog.js +60 -0
- package/dist/core/animate-ui/components/radix/dropdown-menu.js +129 -0
- package/dist/core/animate-ui/components/radix/sheet.js +110 -0
- package/dist/core/animate-ui/components/radix/sidebar.js +416 -0
- package/dist/core/animate-ui/components/radix/switch.js +34 -0
- package/dist/core/animate-ui/components/radix/toggle-group.js +115 -0
- package/dist/core/animate-ui/components/radix/toggle.js +24 -0
- package/dist/core/animate-ui/primitives/animate/code-block.js +131 -0
- package/dist/core/animate-ui/primitives/animate/escape-html.js +7 -0
- package/dist/core/animate-ui/primitives/animate/shiki-highlighter.js +64 -0
- package/dist/core/animate-ui/primitives/animate/slot.js +39 -0
- package/dist/core/animate-ui/primitives/animate/tabs.js +202 -0
- package/dist/core/animate-ui/primitives/animate/tooltip.js +351 -0
- package/dist/core/animate-ui/primitives/base/preview-card.js +107 -0
- package/dist/core/animate-ui/primitives/base/progress.js +60 -0
- package/dist/core/animate-ui/primitives/base/radio.js +83 -0
- package/dist/core/animate-ui/primitives/buttons/button.js +16 -0
- package/dist/core/animate-ui/primitives/effects/highlight.js +407 -0
- package/dist/core/animate-ui/primitives/radix/accordion.js +76 -0
- package/dist/core/animate-ui/primitives/radix/dialog.js +136 -0
- package/dist/core/animate-ui/primitives/radix/dropdown-menu.js +305 -0
- package/dist/core/animate-ui/primitives/radix/sheet.js +165 -0
- package/dist/core/animate-ui/primitives/radix/switch.js +86 -0
- package/dist/core/animate-ui/primitives/radix/toggle-group.js +100 -0
- package/dist/core/animate-ui/primitives/texts/counting-number.js +75 -0
- package/dist/core/avatar.js +32 -0
- package/dist/core/badge.js +27 -0
- package/dist/core/breadcrumb.js +62 -0
- package/dist/core/button/button.js +43 -0
- package/dist/core/button/craft-button.js +78 -0
- package/dist/core/button-group.js +38 -0
- package/dist/core/button.js +40 -0
- package/dist/core/card.js +42 -0
- package/dist/core/carousel/carousel.js +149 -0
- package/dist/core/checkbox/motion-checkbox.js +103 -0
- package/dist/core/collapsible.js +54 -0
- package/dist/core/combobox/combobox.js +85 -0
- package/dist/core/command.js +61 -0
- package/dist/core/field-end-icons.js +36 -0
- package/dist/core/field-label-row.js +33 -0
- package/dist/core/form.js +92 -0
- package/dist/core/hooks/use-controlled-state.js +27 -0
- package/dist/core/hooks/use-data-state.js +39 -0
- package/dist/core/hooks/use-is-in-view.js +18 -0
- package/dist/core/hooks/use-mobile.js +19 -0
- package/dist/core/hooks/use-reveal-on-scroll-up.js +141 -0
- package/dist/core/hooks/use-scroll-overflow.js +50 -0
- package/dist/core/index.js +18 -52
- package/dist/core/input/input-password.js +30 -0
- package/dist/core/input/input.js +147 -0
- package/dist/core/input-otp/input-otp.js +183 -0
- package/dist/core/label.js +15 -0
- package/dist/core/popover.js +31 -0
- package/dist/core/scroll-area.js +42 -0
- package/dist/core/select.js +121 -0
- package/dist/core/separator.js +40 -0
- package/dist/core/skeleton.js +11 -0
- package/dist/core/table.js +59 -0
- package/dist/core/textarea/textarea.js +97 -0
- package/dist/core/utils/get-strict-context.js +18 -0
- package/dist/index.js +148 -9
- package/dist/layouts/entry-layout/entry-layout-bg.js +4 -0
- package/dist/layouts/entry-layout/entry-layout.js +52 -0
- package/dist/layouts/index.js +7 -6
- package/dist/layouts/workspace-layout/account-menu/account-menu.js +108 -0
- package/dist/layouts/workspace-layout/breadcrumbs/derive-breadcrumbs.js +37 -0
- package/dist/layouts/workspace-layout/breadcrumbs/workspace-breadcrumbs.js +22 -0
- package/dist/layouts/workspace-layout/footer/footer.js +15 -0
- package/dist/layouts/workspace-layout/header/header.js +54 -0
- package/dist/layouts/workspace-layout/workspace-layout.js +157 -0
- package/dist/tailwind-preset.js +3 -4
- package/dist/utils/cn.js +8 -0
- package/dist/utils/color.js +72 -0
- package/dist/utils/index.js +3 -2
- package/dist/utils/path-match.js +17 -0
- package/dist/utils/silver-shine.js +63 -0
- package/dist/utils/variant-gradient-underlay.js +45 -0
- package/dist/utils/variant.js +426 -0
- package/package.json +7 -4
- package/dist/chunk-2GDYZAKR.js +0 -505
- package/dist/chunk-ALCWXFUC.js +0 -733
- package/dist/chunk-CDHBLANU.js +0 -59
- package/dist/chunk-LUESSJAF.js +0 -70068
- package/dist/chunk-TMORRNEB.js +0 -323
- package/dist/chunk-TRTQSARU.js +0 -31
- package/dist/chunk-VU4CZ76T.js +0 -43
- package/dist/chunk-XNLCVHBC.js +0 -364
- package/dist/chunk-Z4776NRY.js +0 -4347
- package/src/assets/illustrations/add-to-group.svg +0 -32
- package/src/assets/illustrations/chip.svg +0 -51
- package/src/assets/illustrations/create-new-group.svg +0 -27
- package/src/assets/illustrations/new-ota.svg +0 -61
- package/src/assets/illustrations/secured-key.svg +0 -48
- /package/dist/assets/{entry-layout-bg-JPI7GJ42.webp → entry-layout-bg-DUM0UhT3.webp} +0 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { isPresetColor } from "../../utils/color.js";
|
|
3
|
+
import { useControlledState } from "../../core/hooks/use-controlled-state.js";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../core/animate-ui/components/radix/dropdown-menu.js";
|
|
5
|
+
import { Button } from "../../core/button.js";
|
|
6
|
+
import { useIsMobile } from "../../core/hooks/use-mobile.js";
|
|
7
|
+
import { useNavBarOverflow } from "./use-nav-bar-overflow.js";
|
|
8
|
+
import { useNavBarScroll } from "./use-nav-bar-scroll.js";
|
|
9
|
+
import { NavBarDetailsPanel } from "./nav-bar-details-panel.js";
|
|
10
|
+
import { NavBarMobileMenu } from "./nav-bar-mobile-menu.js";
|
|
11
|
+
import * as React$1 from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { ChevronDown, Menu, X } from "lucide-react";
|
|
14
|
+
import { motion } from "motion/react";
|
|
15
|
+
import { createPortal } from "react-dom";
|
|
16
|
+
//#region src/components/nav-bar/nav-bar.tsx
|
|
17
|
+
var PRESET_TEXT = {
|
|
18
|
+
primary: "text-primary",
|
|
19
|
+
secondary: "text-secondary",
|
|
20
|
+
error: "text-error",
|
|
21
|
+
info: "text-info",
|
|
22
|
+
success: "text-success",
|
|
23
|
+
warning: "text-warning",
|
|
24
|
+
disabled: "text-disabled",
|
|
25
|
+
gray: "text-gray",
|
|
26
|
+
mist: "text-mist"
|
|
27
|
+
};
|
|
28
|
+
var PRESET_HOVER_TEXT = {
|
|
29
|
+
primary: "hover:text-primary",
|
|
30
|
+
secondary: "hover:text-secondary",
|
|
31
|
+
error: "hover:text-error",
|
|
32
|
+
info: "hover:text-info",
|
|
33
|
+
success: "hover:text-success",
|
|
34
|
+
warning: "hover:text-warning",
|
|
35
|
+
disabled: "hover:text-disabled",
|
|
36
|
+
gray: "hover:text-gray",
|
|
37
|
+
mist: "hover:text-mist"
|
|
38
|
+
};
|
|
39
|
+
var PRESET_BG = {
|
|
40
|
+
primary: "bg-primary/10",
|
|
41
|
+
secondary: "bg-secondary/10",
|
|
42
|
+
error: "bg-error/10",
|
|
43
|
+
info: "bg-info/10",
|
|
44
|
+
success: "bg-success/10",
|
|
45
|
+
warning: "bg-warning/10",
|
|
46
|
+
disabled: "bg-disabled/10",
|
|
47
|
+
gray: "bg-gray/10",
|
|
48
|
+
mist: "bg-mist/10"
|
|
49
|
+
};
|
|
50
|
+
var PRESET_HOVER_BG = {
|
|
51
|
+
primary: "hover:bg-primary/5",
|
|
52
|
+
secondary: "hover:bg-secondary/5",
|
|
53
|
+
error: "hover:bg-error/5",
|
|
54
|
+
info: "hover:bg-info/5",
|
|
55
|
+
success: "hover:bg-success/5",
|
|
56
|
+
warning: "hover:bg-warning/5",
|
|
57
|
+
disabled: "hover:bg-disabled/5",
|
|
58
|
+
gray: "hover:bg-gray/5",
|
|
59
|
+
mist: "hover:bg-mist/5"
|
|
60
|
+
};
|
|
61
|
+
function resolveNavColor(color) {
|
|
62
|
+
if (isPresetColor(color)) return {
|
|
63
|
+
textClass: PRESET_TEXT[color],
|
|
64
|
+
hoverTextClass: PRESET_HOVER_TEXT[color],
|
|
65
|
+
bgClass: PRESET_BG[color],
|
|
66
|
+
hoverBgClass: PRESET_HOVER_BG[color]
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
textClass: "",
|
|
70
|
+
hoverTextClass: "",
|
|
71
|
+
bgClass: "",
|
|
72
|
+
hoverBgClass: "",
|
|
73
|
+
textStyle: { color },
|
|
74
|
+
bgStyle: { backgroundColor: `color-mix(in srgb, ${color} 10%, transparent)` }
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function NavBar({ logo, items, rightContent, activeId: activeIdProp, defaultActiveId, onActiveChange, openDetailsId: openDetailsIdProp, onDetailsPanelChange, position = "sticky", height, morphOnScroll = false, morphScrollThreshold = 50, morphScrollContainer, moreLabel = "More", linkComponent, color = "primary", mobileMenuTitle, mobileMenuTrigger, className, itemsClassName }) {
|
|
78
|
+
const isMobile = useIsMobile();
|
|
79
|
+
const resolvedColor = resolveNavColor(color);
|
|
80
|
+
const navRef = React$1.useRef(null);
|
|
81
|
+
const [activeId, setActiveId] = useControlledState({
|
|
82
|
+
value: activeIdProp,
|
|
83
|
+
defaultValue: defaultActiveId,
|
|
84
|
+
onChange: onActiveChange
|
|
85
|
+
});
|
|
86
|
+
const [openDetailsId, setOpenDetailsId] = useControlledState({
|
|
87
|
+
value: openDetailsIdProp ?? void 0,
|
|
88
|
+
defaultValue: null,
|
|
89
|
+
onChange: onDetailsPanelChange
|
|
90
|
+
});
|
|
91
|
+
const [mobileMenuOpen, setMobileMenuOpen] = React$1.useState(false);
|
|
92
|
+
const [navRect, setNavRect] = React$1.useState({
|
|
93
|
+
bottom: 0,
|
|
94
|
+
width: 0,
|
|
95
|
+
left: 0
|
|
96
|
+
});
|
|
97
|
+
const { containerRef, measureRef, moreButtonMeasureRef, visibleIds, overflowIds, showMore, measuring } = useNavBarOverflow(items);
|
|
98
|
+
const { isScrolled } = useNavBarScroll({
|
|
99
|
+
enabled: morphOnScroll && !isMobile,
|
|
100
|
+
threshold: morphScrollThreshold,
|
|
101
|
+
scrollContainerRef: morphScrollContainer
|
|
102
|
+
});
|
|
103
|
+
React$1.useEffect(() => {
|
|
104
|
+
if (!openDetailsId || !navRef.current) return;
|
|
105
|
+
const updateRect = () => {
|
|
106
|
+
if (navRef.current) {
|
|
107
|
+
const rect = navRef.current.getBoundingClientRect();
|
|
108
|
+
setNavRect({
|
|
109
|
+
bottom: rect.bottom,
|
|
110
|
+
width: rect.width,
|
|
111
|
+
left: rect.left
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
updateRect();
|
|
116
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
117
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
118
|
+
return () => {
|
|
119
|
+
window.removeEventListener("scroll", updateRect);
|
|
120
|
+
window.removeEventListener("resize", updateRect);
|
|
121
|
+
};
|
|
122
|
+
}, [openDetailsId]);
|
|
123
|
+
React$1.useEffect(() => {
|
|
124
|
+
if (!openDetailsId) return;
|
|
125
|
+
const handleKeyDown = (e) => {
|
|
126
|
+
if (e.key === "Escape") setOpenDetailsId(null);
|
|
127
|
+
};
|
|
128
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
129
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
130
|
+
}, [openDetailsId, setOpenDetailsId]);
|
|
131
|
+
React$1.useEffect(() => {
|
|
132
|
+
if (!openDetailsId) return;
|
|
133
|
+
const handleMouseDown = (e) => {
|
|
134
|
+
if (navRef.current && !navRef.current.contains(e.target)) setOpenDetailsId(null);
|
|
135
|
+
};
|
|
136
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
137
|
+
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
138
|
+
}, [openDetailsId, setOpenDetailsId]);
|
|
139
|
+
const handleItemClick = React$1.useCallback((item) => {
|
|
140
|
+
item.onClick?.();
|
|
141
|
+
setActiveId(item.id);
|
|
142
|
+
if (item.details) setOpenDetailsId(openDetailsId === item.id ? null : item.id);
|
|
143
|
+
else setOpenDetailsId(null);
|
|
144
|
+
}, [
|
|
145
|
+
openDetailsId,
|
|
146
|
+
setActiveId,
|
|
147
|
+
setOpenDetailsId
|
|
148
|
+
]);
|
|
149
|
+
React$1.useEffect(() => {
|
|
150
|
+
if (isMobile) setOpenDetailsId(null);
|
|
151
|
+
}, [isMobile, setOpenDetailsId]);
|
|
152
|
+
const resolvedHeight = height ?? "var(--espd-navbar-height)";
|
|
153
|
+
const activeDetailsItem = openDetailsId ? items.find((i) => i.id === openDetailsId) : void 0;
|
|
154
|
+
const [overflowDetailsItem, setOverflowDetailsItem] = React$1.useState(null);
|
|
155
|
+
const overflowDetailsRef = React$1.useRef(null);
|
|
156
|
+
const moreButtonRef = React$1.useRef(null);
|
|
157
|
+
const [overflowPanelPos, setOverflowPanelPos] = React$1.useState({
|
|
158
|
+
top: 0,
|
|
159
|
+
right: 0
|
|
160
|
+
});
|
|
161
|
+
React$1.useEffect(() => {
|
|
162
|
+
if (!overflowDetailsItem || !moreButtonRef.current) return;
|
|
163
|
+
const rect = moreButtonRef.current.getBoundingClientRect();
|
|
164
|
+
setOverflowPanelPos({
|
|
165
|
+
top: rect.bottom + 8,
|
|
166
|
+
right: window.innerWidth - rect.right
|
|
167
|
+
});
|
|
168
|
+
}, [overflowDetailsItem]);
|
|
169
|
+
React$1.useEffect(() => {
|
|
170
|
+
if (!overflowDetailsItem) return;
|
|
171
|
+
const handleMouseDown = (e) => {
|
|
172
|
+
if (overflowDetailsRef.current && !overflowDetailsRef.current.contains(e.target) && moreButtonRef.current && !moreButtonRef.current.contains(e.target)) setOverflowDetailsItem(null);
|
|
173
|
+
};
|
|
174
|
+
const handleKeyDown = (e) => {
|
|
175
|
+
if (e.key === "Escape") setOverflowDetailsItem(null);
|
|
176
|
+
};
|
|
177
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
178
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
179
|
+
return () => {
|
|
180
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
181
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
182
|
+
};
|
|
183
|
+
}, [overflowDetailsItem]);
|
|
184
|
+
const hasActiveOverflowItem = overflowIds.some((id) => id === activeId);
|
|
185
|
+
const navClasses = cn("relative z-50 w-full", "backdrop-blur-md supports-[backdrop-filter]:bg-background/80", position === "sticky" && "sticky", position === "fixed" && "fixed left-0", morphOnScroll && "mx-auto overflow-hidden", isScrolled && morphOnScroll ? "border border-header-border" : "border-b border-header-border", className);
|
|
186
|
+
const morphAnimateProps = morphOnScroll ? {
|
|
187
|
+
initial: false,
|
|
188
|
+
animate: {
|
|
189
|
+
maxWidth: isScrolled ? 896 : 3e3,
|
|
190
|
+
borderRadius: isScrolled ? 9999 : 0,
|
|
191
|
+
top: isScrolled ? 12 : 0,
|
|
192
|
+
boxShadow: isScrolled ? "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)" : "0 0 0 0 rgba(0,0,0,0)"
|
|
193
|
+
},
|
|
194
|
+
transition: {
|
|
195
|
+
type: "spring",
|
|
196
|
+
stiffness: 300,
|
|
197
|
+
damping: 30
|
|
198
|
+
}
|
|
199
|
+
} : { style: { top: 0 } };
|
|
200
|
+
if (isMobile) return /* @__PURE__ */ jsxs("nav", {
|
|
201
|
+
ref: navRef,
|
|
202
|
+
className: cn("relative z-50 w-full border-b border-header-border", "backdrop-blur-md supports-[backdrop-filter]:bg-background/80", position === "sticky" && "sticky top-0", position === "fixed" && "fixed top-0 left-0", className),
|
|
203
|
+
"aria-label": "Main navigation",
|
|
204
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
205
|
+
className: "flex items-center gap-3 px-4",
|
|
206
|
+
style: { height: resolvedHeight },
|
|
207
|
+
children: [
|
|
208
|
+
mobileMenuTrigger ? /* @__PURE__ */ jsx("div", {
|
|
209
|
+
onClick: () => setMobileMenuOpen(true),
|
|
210
|
+
children: mobileMenuTrigger
|
|
211
|
+
}) : /* @__PURE__ */ jsxs(Button, {
|
|
212
|
+
variant: "ghost",
|
|
213
|
+
size: "icon",
|
|
214
|
+
className: "size-10 shrink-0",
|
|
215
|
+
onClick: () => setMobileMenuOpen(true),
|
|
216
|
+
children: [/* @__PURE__ */ jsx(Menu, { className: "!size-5" }), /* @__PURE__ */ jsx("span", {
|
|
217
|
+
className: "sr-only",
|
|
218
|
+
children: "Open menu"
|
|
219
|
+
})]
|
|
220
|
+
}),
|
|
221
|
+
logo && /* @__PURE__ */ jsx("div", {
|
|
222
|
+
className: "flex-1 min-w-0",
|
|
223
|
+
children: logo
|
|
224
|
+
}),
|
|
225
|
+
rightContent && /* @__PURE__ */ jsx("div", {
|
|
226
|
+
className: "shrink-0 flex items-center gap-2",
|
|
227
|
+
children: rightContent
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
}), /* @__PURE__ */ jsx(NavBarMobileMenu, {
|
|
231
|
+
items,
|
|
232
|
+
activeId,
|
|
233
|
+
onItemClick: handleItemClick,
|
|
234
|
+
open: mobileMenuOpen,
|
|
235
|
+
onOpenChange: setMobileMenuOpen,
|
|
236
|
+
linkComponent,
|
|
237
|
+
title: mobileMenuTitle,
|
|
238
|
+
colorClasses: {
|
|
239
|
+
textClass: resolvedColor.textClass,
|
|
240
|
+
bgClass: resolvedColor.bgClass,
|
|
241
|
+
hoverBgClass: resolvedColor.hoverBgClass,
|
|
242
|
+
textStyle: resolvedColor.textStyle,
|
|
243
|
+
bgStyle: resolvedColor.bgStyle
|
|
244
|
+
}
|
|
245
|
+
})]
|
|
246
|
+
});
|
|
247
|
+
return /* @__PURE__ */ jsxs(motion.nav, {
|
|
248
|
+
ref: navRef,
|
|
249
|
+
className: navClasses,
|
|
250
|
+
...morphAnimateProps,
|
|
251
|
+
"aria-label": "Main navigation",
|
|
252
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
253
|
+
className: cn("flex items-center gap-4 mx-auto w-full py-2 transition-[padding] duration-300", isScrolled && morphOnScroll ? "px-4 md:px-6 lg:px-8" : "px-4 lg:px-6"),
|
|
254
|
+
style: { minHeight: resolvedHeight },
|
|
255
|
+
children: [
|
|
256
|
+
logo && /* @__PURE__ */ jsx("div", {
|
|
257
|
+
className: "shrink-0",
|
|
258
|
+
children: logo
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ jsxs("div", {
|
|
261
|
+
ref: containerRef,
|
|
262
|
+
className: cn("flex-1 flex items-center min-w-0", logo ? "justify-center" : "justify-start", itemsClassName),
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ jsx("ul", {
|
|
265
|
+
ref: measureRef,
|
|
266
|
+
className: "flex items-center gap-1 list-none m-0 p-0 absolute invisible h-0 overflow-hidden whitespace-nowrap pointer-events-none",
|
|
267
|
+
"aria-hidden": "true",
|
|
268
|
+
children: items.map((item) => /* @__PURE__ */ jsx("li", {
|
|
269
|
+
"data-nav-item-id": item.id,
|
|
270
|
+
className: "shrink-0",
|
|
271
|
+
children: /* @__PURE__ */ jsx(NavBarItemTrigger, {
|
|
272
|
+
item,
|
|
273
|
+
isActive: false,
|
|
274
|
+
isDetailsOpen: false,
|
|
275
|
+
onClick: () => {},
|
|
276
|
+
tabIndex: -1
|
|
277
|
+
})
|
|
278
|
+
}, item.id))
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ jsx("div", {
|
|
281
|
+
ref: moreButtonMeasureRef,
|
|
282
|
+
className: "absolute invisible h-0 overflow-hidden pointer-events-none",
|
|
283
|
+
"aria-hidden": "true",
|
|
284
|
+
children: /* @__PURE__ */ jsx(MoreButton, {
|
|
285
|
+
label: moreLabel,
|
|
286
|
+
hasActiveOverflowItem: false
|
|
287
|
+
})
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsx("ul", {
|
|
290
|
+
className: cn("flex items-center gap-1 list-none m-0 p-0", measuring && "opacity-0"),
|
|
291
|
+
role: "menubar",
|
|
292
|
+
"aria-label": "Main navigation",
|
|
293
|
+
children: items.filter((item) => visibleIds.includes(item.id)).map((item) => /* @__PURE__ */ jsx("li", {
|
|
294
|
+
role: "none",
|
|
295
|
+
className: "shrink-0",
|
|
296
|
+
children: /* @__PURE__ */ jsx(NavBarItemTrigger, {
|
|
297
|
+
item,
|
|
298
|
+
isActive: activeId === item.id,
|
|
299
|
+
isDetailsOpen: openDetailsId === item.id,
|
|
300
|
+
onClick: () => handleItemClick(item),
|
|
301
|
+
linkComponent,
|
|
302
|
+
resolvedColor,
|
|
303
|
+
isPill: isScrolled && morphOnScroll
|
|
304
|
+
})
|
|
305
|
+
}, item.id))
|
|
306
|
+
}),
|
|
307
|
+
showMore && /* @__PURE__ */ jsx("div", {
|
|
308
|
+
ref: moreButtonRef,
|
|
309
|
+
className: cn("shrink-0 ml-1", measuring && "opacity-0"),
|
|
310
|
+
children: /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
311
|
+
onOpenChange: (open) => {
|
|
312
|
+
if (open) setOverflowDetailsItem(null);
|
|
313
|
+
},
|
|
314
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
315
|
+
asChild: true,
|
|
316
|
+
children: /* @__PURE__ */ jsx(MoreButton, {
|
|
317
|
+
label: moreLabel,
|
|
318
|
+
hasActiveOverflowItem,
|
|
319
|
+
resolvedColor
|
|
320
|
+
})
|
|
321
|
+
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
322
|
+
align: "end",
|
|
323
|
+
sideOffset: 8,
|
|
324
|
+
children: items.filter((item) => overflowIds.includes(item.id)).map((item) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
325
|
+
onClick: () => {
|
|
326
|
+
item.onClick?.();
|
|
327
|
+
setActiveId(item.id);
|
|
328
|
+
setOpenDetailsId(null);
|
|
329
|
+
if (item.details) setOverflowDetailsItem(overflowDetailsItem?.id === item.id ? null : item);
|
|
330
|
+
},
|
|
331
|
+
className: cn(activeId === item.id && `${resolvedColor.textClass} ${resolvedColor.bgClass}`),
|
|
332
|
+
style: activeId === item.id && resolvedColor.textStyle ? {
|
|
333
|
+
...resolvedColor.textStyle,
|
|
334
|
+
...resolvedColor.bgStyle
|
|
335
|
+
} : void 0,
|
|
336
|
+
disabled: item.disabled,
|
|
337
|
+
children: [item.icon, item.label]
|
|
338
|
+
}, item.id))
|
|
339
|
+
})]
|
|
340
|
+
})
|
|
341
|
+
}),
|
|
342
|
+
overflowDetailsItem?.details && createPortal(/* @__PURE__ */ jsxs("div", {
|
|
343
|
+
ref: overflowDetailsRef,
|
|
344
|
+
className: cn("fixed z-50", "w-max max-w-[min(24rem,calc(100vw-2rem))]", "rounded-lg border border-border bg-background p-4 shadow-lg", "animate-in fade-in-0 zoom-in-95"),
|
|
345
|
+
style: {
|
|
346
|
+
top: overflowPanelPos.top,
|
|
347
|
+
right: overflowPanelPos.right
|
|
348
|
+
},
|
|
349
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
350
|
+
type: "button",
|
|
351
|
+
onClick: () => setOverflowDetailsItem(null),
|
|
352
|
+
className: cn("absolute top-2 right-2 p-1 rounded-md", "text-foreground/40 hover:text-foreground hover:bg-foreground/5", "transition-colors cursor-pointer"),
|
|
353
|
+
"aria-label": "Close panel",
|
|
354
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
355
|
+
}), overflowDetailsItem.details]
|
|
356
|
+
}), document.body)
|
|
357
|
+
]
|
|
358
|
+
}),
|
|
359
|
+
rightContent && /* @__PURE__ */ jsx("div", {
|
|
360
|
+
className: "shrink-0 flex items-center gap-2",
|
|
361
|
+
children: rightContent
|
|
362
|
+
})
|
|
363
|
+
]
|
|
364
|
+
}), /* @__PURE__ */ jsx(NavBarDetailsPanel, {
|
|
365
|
+
item: activeDetailsItem,
|
|
366
|
+
openDetailsId: openDetailsId ?? null,
|
|
367
|
+
onClose: () => setOpenDetailsId(null),
|
|
368
|
+
navBottomOffset: navRect.bottom,
|
|
369
|
+
navWidth: navRect.width,
|
|
370
|
+
navLeft: navRect.left
|
|
371
|
+
})]
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
var MoreButton = React$1.forwardRef(function MoreButton({ label, hasActiveOverflowItem, resolvedColor, ...props }, ref) {
|
|
375
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
376
|
+
ref,
|
|
377
|
+
type: "button",
|
|
378
|
+
className: cn("inline-flex items-center gap-1 px-3 h-8 rounded-md", "text-sm font-medium whitespace-nowrap cursor-pointer", "transition-colors duration-150", "text-foreground/80 hover:text-foreground", resolvedColor ? resolvedColor.hoverBgClass : "hover:bg-foreground/5", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", hasActiveOverflowItem && resolvedColor && `${resolvedColor.textClass} ${resolvedColor.bgClass}`),
|
|
379
|
+
style: hasActiveOverflowItem && resolvedColor?.textStyle ? {
|
|
380
|
+
...resolvedColor.textStyle,
|
|
381
|
+
...resolvedColor.bgStyle
|
|
382
|
+
} : void 0,
|
|
383
|
+
"aria-label": "More navigation items",
|
|
384
|
+
...props,
|
|
385
|
+
children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })]
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
function NavBarItemTrigger({ item, isActive, isDetailsOpen, onClick, linkComponent, tabIndex, resolvedColor, isPill }) {
|
|
389
|
+
const classes = cn("inline-flex items-center gap-1 px-3 h-8", isPill ? "rounded-full" : "rounded-md", "text-sm font-medium whitespace-nowrap cursor-pointer", "transition-colors duration-150", "text-foreground/80 hover:text-foreground", resolvedColor ? resolvedColor.hoverBgClass : "hover:bg-foreground/5", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", isActive && resolvedColor && `${resolvedColor.textClass} ${resolvedColor.bgClass}`, isDetailsOpen && resolvedColor && `${resolvedColor.textClass} ${resolvedColor.bgClass}`, item.disabled && "opacity-50 pointer-events-none");
|
|
390
|
+
const colorStyle = resolvedColor?.textStyle && (isActive || isDetailsOpen) ? {
|
|
391
|
+
...resolvedColor.textStyle,
|
|
392
|
+
...resolvedColor.bgStyle
|
|
393
|
+
} : void 0;
|
|
394
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
395
|
+
item.icon && /* @__PURE__ */ jsx("span", {
|
|
396
|
+
className: "shrink-0",
|
|
397
|
+
children: item.icon
|
|
398
|
+
}),
|
|
399
|
+
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
400
|
+
item.details && /* @__PURE__ */ jsx(ChevronDown, {
|
|
401
|
+
className: cn("size-3.5 transition-transform duration-200", isDetailsOpen && "rotate-180"),
|
|
402
|
+
"aria-hidden": "true"
|
|
403
|
+
})
|
|
404
|
+
] });
|
|
405
|
+
if (item.details) return /* @__PURE__ */ jsx("button", {
|
|
406
|
+
type: "button",
|
|
407
|
+
className: classes,
|
|
408
|
+
style: colorStyle,
|
|
409
|
+
onClick,
|
|
410
|
+
role: "menuitem",
|
|
411
|
+
"aria-expanded": isDetailsOpen,
|
|
412
|
+
"aria-haspopup": "true",
|
|
413
|
+
disabled: item.disabled,
|
|
414
|
+
tabIndex,
|
|
415
|
+
children: content
|
|
416
|
+
});
|
|
417
|
+
if (item.href) {
|
|
418
|
+
if (linkComponent) return /* @__PURE__ */ jsx(linkComponent, {
|
|
419
|
+
to: item.href,
|
|
420
|
+
className: classes,
|
|
421
|
+
style: colorStyle,
|
|
422
|
+
onClick,
|
|
423
|
+
role: "menuitem",
|
|
424
|
+
tabIndex,
|
|
425
|
+
children: content
|
|
426
|
+
});
|
|
427
|
+
return /* @__PURE__ */ jsx("a", {
|
|
428
|
+
href: item.href,
|
|
429
|
+
className: classes,
|
|
430
|
+
style: colorStyle,
|
|
431
|
+
onClick,
|
|
432
|
+
role: "menuitem",
|
|
433
|
+
tabIndex,
|
|
434
|
+
children: content
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return /* @__PURE__ */ jsx("button", {
|
|
438
|
+
type: "button",
|
|
439
|
+
className: classes,
|
|
440
|
+
style: colorStyle,
|
|
441
|
+
onClick,
|
|
442
|
+
role: "menuitem",
|
|
443
|
+
disabled: item.disabled,
|
|
444
|
+
tabIndex,
|
|
445
|
+
children: content
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
export { NavBar };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/components/nav-bar/use-nav-bar-overflow.ts
|
|
3
|
+
var ITEM_GAP = 4;
|
|
4
|
+
function useNavBarOverflow(items) {
|
|
5
|
+
const containerRef = useRef(null);
|
|
6
|
+
const measureRef = useRef(null);
|
|
7
|
+
const moreButtonMeasureRef = useRef(null);
|
|
8
|
+
const [state, setState] = useState({
|
|
9
|
+
visibleIds: items.map((i) => i.id),
|
|
10
|
+
overflowIds: []
|
|
11
|
+
});
|
|
12
|
+
const [measuring, setMeasuring] = useState(true);
|
|
13
|
+
const recalculate = useCallback(() => {
|
|
14
|
+
const container = containerRef.current;
|
|
15
|
+
const measureList = measureRef.current;
|
|
16
|
+
const moreButton = moreButtonMeasureRef.current;
|
|
17
|
+
if (!container || !measureList) return;
|
|
18
|
+
const containerWidth = container.clientWidth;
|
|
19
|
+
const moreButtonWidth = moreButton ? moreButton.getBoundingClientRect().width : 80;
|
|
20
|
+
const itemWidths = /* @__PURE__ */ new Map();
|
|
21
|
+
const measureItems = measureList.querySelectorAll("[data-nav-item-id]");
|
|
22
|
+
for (const li of measureItems) {
|
|
23
|
+
const id = li.getAttribute("data-nav-item-id");
|
|
24
|
+
if (id) itemWidths.set(id, li.getBoundingClientRect().width);
|
|
25
|
+
}
|
|
26
|
+
let totalWidth = 0;
|
|
27
|
+
for (let i = 0; i < items.length; i++) totalWidth += (itemWidths.get(items[i].id) ?? 0) + (i > 0 ? ITEM_GAP : 0);
|
|
28
|
+
if (totalWidth <= containerWidth) {
|
|
29
|
+
setState({
|
|
30
|
+
visibleIds: items.map((i) => i.id),
|
|
31
|
+
overflowIds: []
|
|
32
|
+
});
|
|
33
|
+
setMeasuring(false);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const availableWidth = containerWidth - moreButtonWidth - ITEM_GAP;
|
|
37
|
+
let accumulatedWidth = 0;
|
|
38
|
+
let cutoffIndex = 0;
|
|
39
|
+
for (let i = 0; i < items.length; i++) {
|
|
40
|
+
const w = (itemWidths.get(items[i].id) ?? 0) + (i > 0 ? ITEM_GAP : 0);
|
|
41
|
+
if (accumulatedWidth + w > availableWidth) break;
|
|
42
|
+
accumulatedWidth += w;
|
|
43
|
+
cutoffIndex = i + 1;
|
|
44
|
+
}
|
|
45
|
+
setState({
|
|
46
|
+
visibleIds: items.slice(0, cutoffIndex).map((i) => i.id),
|
|
47
|
+
overflowIds: items.slice(cutoffIndex).map((i) => i.id)
|
|
48
|
+
});
|
|
49
|
+
setMeasuring(false);
|
|
50
|
+
}, [items]);
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
recalculate();
|
|
53
|
+
}, [recalculate]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const container = containerRef.current;
|
|
56
|
+
if (!container || typeof ResizeObserver === "undefined") return;
|
|
57
|
+
const ro = new ResizeObserver(() => {
|
|
58
|
+
recalculate();
|
|
59
|
+
});
|
|
60
|
+
ro.observe(container);
|
|
61
|
+
return () => ro.disconnect();
|
|
62
|
+
}, [recalculate]);
|
|
63
|
+
return {
|
|
64
|
+
containerRef,
|
|
65
|
+
measureRef,
|
|
66
|
+
moreButtonMeasureRef,
|
|
67
|
+
visibleIds: state.visibleIds,
|
|
68
|
+
overflowIds: state.overflowIds,
|
|
69
|
+
showMore: state.overflowIds.length > 0,
|
|
70
|
+
measuring
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { useNavBarOverflow };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/components/nav-bar/use-nav-bar-scroll.ts
|
|
3
|
+
function useNavBarScroll({ enabled, threshold, scrollContainerRef }) {
|
|
4
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
5
|
+
const rafRef = useRef(null);
|
|
6
|
+
const getScrollTop = useCallback(() => {
|
|
7
|
+
if (scrollContainerRef?.current) return scrollContainerRef.current.scrollTop;
|
|
8
|
+
return window.scrollY;
|
|
9
|
+
}, [scrollContainerRef]);
|
|
10
|
+
const handleScroll = useCallback(() => {
|
|
11
|
+
if (rafRef.current !== null) return;
|
|
12
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
13
|
+
setIsScrolled(getScrollTop() > threshold);
|
|
14
|
+
rafRef.current = null;
|
|
15
|
+
});
|
|
16
|
+
}, [threshold, getScrollTop]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!enabled) {
|
|
19
|
+
setIsScrolled(false);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setIsScrolled(getScrollTop() > threshold);
|
|
23
|
+
const target = scrollContainerRef?.current ?? window;
|
|
24
|
+
target.addEventListener("scroll", handleScroll, { passive: true });
|
|
25
|
+
return () => {
|
|
26
|
+
target.removeEventListener("scroll", handleScroll);
|
|
27
|
+
if (rafRef.current !== null) {
|
|
28
|
+
cancelAnimationFrame(rafRef.current);
|
|
29
|
+
rafRef.current = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
enabled,
|
|
34
|
+
handleScroll,
|
|
35
|
+
threshold,
|
|
36
|
+
getScrollTop,
|
|
37
|
+
scrollContainerRef
|
|
38
|
+
]);
|
|
39
|
+
return { isScrolled };
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useNavBarScroll };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import Tooltip from "../tooltip/tooltip.js";
|
|
3
|
+
import { StatusBadge } from "../status-badge/status-badge.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/overflow-badge-list/overflow-badge-list.tsx
|
|
6
|
+
function resolveBadge(item, index, defaultIcon, defaultColor) {
|
|
7
|
+
if (typeof item === "string") return {
|
|
8
|
+
key: `${item}-${index}`,
|
|
9
|
+
label: item,
|
|
10
|
+
icon: index === 0 ? defaultIcon : void 0,
|
|
11
|
+
color: defaultColor
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
key: `${item.id ?? item.label}-${index}`,
|
|
15
|
+
label: item.label,
|
|
16
|
+
icon: item.icon,
|
|
17
|
+
color: item.color ?? defaultColor
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function OverflowBadgeList({ items, icon, badgeColor, badgeVariant = "outline", badgeSize = "default", maxBadgesToShow = 1, noneLabel, andMoreLabel, className }) {
|
|
21
|
+
if (items.length === 0) return /* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "text-muted-foreground",
|
|
23
|
+
children: noneLabel
|
|
24
|
+
});
|
|
25
|
+
const badges = items.map((item, index) => resolveBadge(item, index, icon, badgeColor));
|
|
26
|
+
const visibleCount = Math.min(Math.max(1, maxBadgesToShow), badges.length);
|
|
27
|
+
const visibleBadges = badges.slice(0, visibleCount);
|
|
28
|
+
const hiddenCount = badges.length - visibleCount;
|
|
29
|
+
const tooltipContent = hiddenCount > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
30
|
+
className: "max-h-48 max-w-xs list-disc space-y-1 overflow-y-auto pl-4 text-left text-sm",
|
|
31
|
+
children: badges.map((badge) => /* @__PURE__ */ jsx("li", {
|
|
32
|
+
className: "break-words",
|
|
33
|
+
children: badge.label
|
|
34
|
+
}, badge.key))
|
|
35
|
+
}) : null;
|
|
36
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
37
|
+
className: cn("flex min-w-0 flex-wrap items-center gap-2", className),
|
|
38
|
+
children: [visibleBadges.map((badge) => /* @__PURE__ */ jsx(StatusBadge, {
|
|
39
|
+
label: badge.label,
|
|
40
|
+
icon: badge.icon,
|
|
41
|
+
variant: badgeVariant,
|
|
42
|
+
color: badge.color,
|
|
43
|
+
size: badgeSize,
|
|
44
|
+
className: "max-w-[12rem]"
|
|
45
|
+
}, badge.key)), hiddenCount > 0 && tooltipContent ? /* @__PURE__ */ jsx(Tooltip, {
|
|
46
|
+
content: tooltipContent,
|
|
47
|
+
side: "top",
|
|
48
|
+
align: "start",
|
|
49
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: "cursor-default shrink-0 text-sm text-muted-foreground underline decoration-dotted underline-offset-2",
|
|
51
|
+
tabIndex: 0,
|
|
52
|
+
children: andMoreLabel
|
|
53
|
+
})
|
|
54
|
+
}) : null]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { OverflowBadgeList };
|