@espressif/dashboard-ui-components 1.10.0 → 1.11.0
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 +65 -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 +15 -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,270 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../core/select.js";
|
|
4
|
+
import { Tabs, TabsList, TabsTrigger } from "../../core/animate-ui/components/animate/tabs.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/scrollable-sections/scrollable-sections.tsx
|
|
8
|
+
function extractTextLabel(children) {
|
|
9
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
10
|
+
if (Array.isArray(children)) return children.map(extractTextLabel).join("");
|
|
11
|
+
if (React$1.isValidElement(children) && children.props && typeof children.props === "object" && children.props !== null && "children" in children.props) return extractTextLabel(children.props.children);
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
function isTabElement(node) {
|
|
15
|
+
return React$1.isValidElement(node) && node.type === ScrollableSectionsTab;
|
|
16
|
+
}
|
|
17
|
+
function partitionChildren(children) {
|
|
18
|
+
let tabsEl = null;
|
|
19
|
+
const contentEls = [];
|
|
20
|
+
React$1.Children.forEach(children, (child) => {
|
|
21
|
+
if (!React$1.isValidElement(child)) return;
|
|
22
|
+
if (child.type === ScrollableSectionsTabs) tabsEl = child;
|
|
23
|
+
else if (child.type === ScrollableSectionsContent) contentEls.push(child);
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
tabsEl,
|
|
27
|
+
contentEls
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var ScrollableSectionsContext = React$1.createContext(null);
|
|
31
|
+
function useScrollableSections() {
|
|
32
|
+
const ctx = React$1.useContext(ScrollableSectionsContext);
|
|
33
|
+
if (!ctx) throw new Error("ScrollableSections subcomponents must be used within ScrollableSections.");
|
|
34
|
+
return ctx;
|
|
35
|
+
}
|
|
36
|
+
var SPY_IGNORE_MS = 480;
|
|
37
|
+
var SPY_TOP_LEEWAY_PX = 12;
|
|
38
|
+
function isVerticallyScrollable(el) {
|
|
39
|
+
const { overflowY } = window.getComputedStyle(el);
|
|
40
|
+
if (overflowY !== "auto" && overflowY !== "scroll" && overflowY !== "overlay") return false;
|
|
41
|
+
return el.scrollHeight > el.clientHeight + 1;
|
|
42
|
+
}
|
|
43
|
+
/** Nearest scrollports upward from `start` (inclusive), for scroll-spy listeners. */
|
|
44
|
+
function getScrollableAncestors(start) {
|
|
45
|
+
const out = [];
|
|
46
|
+
let cur = start;
|
|
47
|
+
while (cur) {
|
|
48
|
+
if (isVerticallyScrollable(cur)) out.push(cur);
|
|
49
|
+
cur = cur.parentElement;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function dedupeScrollRoots(roots) {
|
|
54
|
+
const seen = /* @__PURE__ */ new Set();
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const r of roots) {
|
|
57
|
+
if (seen.has(r)) continue;
|
|
58
|
+
seen.add(r);
|
|
59
|
+
out.push(r);
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
var DEFAULT_STICKY_TOP = "1rem";
|
|
64
|
+
function ScrollableSectionsRoot({ className, children, defaultValue, scrollRootRef, stickyTop = DEFAULT_STICKY_TOP, style, ...rest }) {
|
|
65
|
+
const { tabsEl, contentEls } = partitionChildren(children);
|
|
66
|
+
const [tabsItems, setTabsItems] = React$1.useState([]);
|
|
67
|
+
const [sectionsVersion, bumpSections] = React$1.useReducer((n) => n + 1, 0);
|
|
68
|
+
const sectionsRef = React$1.useRef(/* @__PURE__ */ new Map());
|
|
69
|
+
const containerRef = React$1.useRef(null);
|
|
70
|
+
const mobileNavRef = React$1.useRef(null);
|
|
71
|
+
const ignoreSpyUntil = React$1.useRef(0);
|
|
72
|
+
const prefersReducedMotionRef = React$1.useRef(false);
|
|
73
|
+
const didDefaultScrollRef = React$1.useRef(false);
|
|
74
|
+
const [activeId, setActiveId] = React$1.useState(() => defaultValue ?? "");
|
|
75
|
+
React$1.useEffect(() => {
|
|
76
|
+
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
77
|
+
prefersReducedMotionRef.current = mq.matches;
|
|
78
|
+
const onChange = () => {
|
|
79
|
+
prefersReducedMotionRef.current = mq.matches;
|
|
80
|
+
};
|
|
81
|
+
mq.addEventListener("change", onChange);
|
|
82
|
+
return () => mq.removeEventListener("change", onChange);
|
|
83
|
+
}, []);
|
|
84
|
+
const safeActiveId = activeId && tabsItems.some((t) => t.id === activeId) ? activeId : tabsItems[0]?.id ?? "";
|
|
85
|
+
const selectSection = React$1.useCallback((id) => {
|
|
86
|
+
const el = sectionsRef.current.get(id);
|
|
87
|
+
if (!el) return;
|
|
88
|
+
const smooth = !prefersReducedMotionRef.current;
|
|
89
|
+
el.scrollIntoView({
|
|
90
|
+
behavior: smooth ? "smooth" : "auto",
|
|
91
|
+
block: "start"
|
|
92
|
+
});
|
|
93
|
+
setActiveId(id);
|
|
94
|
+
ignoreSpyUntil.current = Date.now() + SPY_IGNORE_MS;
|
|
95
|
+
}, []);
|
|
96
|
+
const registerSection = React$1.useCallback((id, el) => {
|
|
97
|
+
if (el) sectionsRef.current.set(id, el);
|
|
98
|
+
else sectionsRef.current.delete(id);
|
|
99
|
+
bumpSections();
|
|
100
|
+
}, []);
|
|
101
|
+
const setTabsItemsStable = React$1.useCallback((items) => {
|
|
102
|
+
setTabsItems(items);
|
|
103
|
+
setActiveId((prev) => {
|
|
104
|
+
if (items.length === 0) return prev;
|
|
105
|
+
if (prev && items.some((t) => t.id === prev)) return prev;
|
|
106
|
+
if (defaultValue && items.some((t) => t.id === defaultValue)) return defaultValue;
|
|
107
|
+
return items[0].id;
|
|
108
|
+
});
|
|
109
|
+
}, [defaultValue]);
|
|
110
|
+
React$1.useLayoutEffect(() => {
|
|
111
|
+
if (!defaultValue || didDefaultScrollRef.current) return;
|
|
112
|
+
const el = sectionsRef.current.get(defaultValue);
|
|
113
|
+
if (!el) return;
|
|
114
|
+
didDefaultScrollRef.current = true;
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
el.scrollIntoView({
|
|
117
|
+
block: "start",
|
|
118
|
+
behavior: "auto"
|
|
119
|
+
});
|
|
120
|
+
setActiveId(defaultValue);
|
|
121
|
+
});
|
|
122
|
+
}, [defaultValue, sectionsVersion]);
|
|
123
|
+
React$1.useEffect(() => {
|
|
124
|
+
const orderedIds = tabsItems.map((t) => t.id);
|
|
125
|
+
if (orderedIds.length === 0) return;
|
|
126
|
+
const updateActive = () => {
|
|
127
|
+
if (Date.now() < ignoreSpyUntil.current) return;
|
|
128
|
+
const bar = mobileNavRef.current;
|
|
129
|
+
const threshold = (bar && bar.offsetHeight > 0 ? bar.getBoundingClientRect().bottom : 0) + SPY_TOP_LEEWAY_PX;
|
|
130
|
+
let next = orderedIds[0];
|
|
131
|
+
for (const id of orderedIds) {
|
|
132
|
+
const el = sectionsRef.current.get(id);
|
|
133
|
+
if (!el) continue;
|
|
134
|
+
if (el.getBoundingClientRect().top <= threshold) next = id;
|
|
135
|
+
}
|
|
136
|
+
setActiveId((prev) => prev === next ? prev : next);
|
|
137
|
+
};
|
|
138
|
+
const scrollRoots = scrollRootRef ? [scrollRootRef.current ?? window] : dedupeScrollRoots([...getScrollableAncestors(containerRef.current), window]);
|
|
139
|
+
for (const target of scrollRoots) target.addEventListener("scroll", updateActive, { passive: true });
|
|
140
|
+
window.addEventListener("resize", updateActive, { passive: true });
|
|
141
|
+
updateActive();
|
|
142
|
+
return () => {
|
|
143
|
+
for (const target of scrollRoots) target.removeEventListener("scroll", updateActive);
|
|
144
|
+
window.removeEventListener("resize", updateActive);
|
|
145
|
+
};
|
|
146
|
+
}, [
|
|
147
|
+
tabsItems,
|
|
148
|
+
scrollRootRef,
|
|
149
|
+
sectionsVersion
|
|
150
|
+
]);
|
|
151
|
+
const contextValue = React$1.useMemo(() => ({
|
|
152
|
+
activeId: safeActiveId,
|
|
153
|
+
selectSection,
|
|
154
|
+
registerSection,
|
|
155
|
+
setTabsItems: setTabsItemsStable
|
|
156
|
+
}), [
|
|
157
|
+
safeActiveId,
|
|
158
|
+
selectSection,
|
|
159
|
+
registerSection,
|
|
160
|
+
setTabsItemsStable
|
|
161
|
+
]);
|
|
162
|
+
return /* @__PURE__ */ jsx(ScrollableSectionsContext.Provider, {
|
|
163
|
+
value: contextValue,
|
|
164
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
165
|
+
ref: containerRef,
|
|
166
|
+
className: cn("flex flex-col gap-4 md:flex-row md:items-stretch md:gap-6", className),
|
|
167
|
+
style: {
|
|
168
|
+
...style,
|
|
169
|
+
"--espd-ss-sticky-top": stickyTop
|
|
170
|
+
},
|
|
171
|
+
...rest,
|
|
172
|
+
children: [tabsEl ? /* @__PURE__ */ jsx("div", {
|
|
173
|
+
className: "hidden md:flex md:w-[30%] md:max-w-[30%] md:shrink-0 md:flex-col md:items-start",
|
|
174
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
175
|
+
className: "md:sticky w-full max-w-full",
|
|
176
|
+
style: { top: stickyTop },
|
|
177
|
+
children: tabsEl
|
|
178
|
+
})
|
|
179
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
180
|
+
className: "flex min-w-0 flex-1 flex-col gap-4 md:w-[70%]",
|
|
181
|
+
children: [tabsItems.length > 0 && safeActiveId ? /* @__PURE__ */ jsx("div", {
|
|
182
|
+
ref: mobileNavRef,
|
|
183
|
+
className: "sticky z-10 bg-background pb-2 md:hidden",
|
|
184
|
+
style: { top: stickyTop },
|
|
185
|
+
children: /* @__PURE__ */ jsxs(Select, {
|
|
186
|
+
value: safeActiveId,
|
|
187
|
+
onValueChange: selectSection,
|
|
188
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
189
|
+
className: "w-full text-sm font-medium",
|
|
190
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Section" })
|
|
191
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: tabsItems.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
192
|
+
value: item.id,
|
|
193
|
+
children: item.label
|
|
194
|
+
}, item.id)) })]
|
|
195
|
+
})
|
|
196
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
197
|
+
className: "flex flex-col gap-8",
|
|
198
|
+
children: contentEls
|
|
199
|
+
})]
|
|
200
|
+
})]
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function ScrollableSectionsTabs({ className, children, ...rest }) {
|
|
205
|
+
const { activeId, selectSection, setTabsItems } = useScrollableSections();
|
|
206
|
+
const tabNodes = React$1.useMemo(() => React$1.Children.toArray(children).filter(isTabElement), [children]);
|
|
207
|
+
const items = React$1.useMemo(() => tabNodes.map((node) => {
|
|
208
|
+
const { id, label, children: tabChildren } = node.props;
|
|
209
|
+
return {
|
|
210
|
+
id,
|
|
211
|
+
label: label?.trim() || extractTextLabel(tabChildren).trim() || id
|
|
212
|
+
};
|
|
213
|
+
}), [tabNodes]);
|
|
214
|
+
React$1.useLayoutEffect(() => {
|
|
215
|
+
setTabsItems(items);
|
|
216
|
+
}, [items, setTabsItems]);
|
|
217
|
+
if (tabNodes.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
218
|
+
className: cn("rounded-lg border border-border p-2", className),
|
|
219
|
+
...rest
|
|
220
|
+
});
|
|
221
|
+
const tabValue = activeId && items.some((i) => i.id === activeId) ? activeId : items[0]?.id ?? "";
|
|
222
|
+
return /* @__PURE__ */ jsx("div", {
|
|
223
|
+
className: cn("rounded-lg border border-border p-2", className),
|
|
224
|
+
...rest,
|
|
225
|
+
children: /* @__PURE__ */ jsx(Tabs, {
|
|
226
|
+
value: tabValue,
|
|
227
|
+
onValueChange: selectSection,
|
|
228
|
+
className: "gap-0",
|
|
229
|
+
children: /* @__PURE__ */ jsx(TabsList, {
|
|
230
|
+
className: cn("flex h-auto w-full flex-col items-stretch gap-2 rounded-md border-0 bg-transparent p-0"),
|
|
231
|
+
"aria-orientation": "vertical",
|
|
232
|
+
children: tabNodes.map((node) => {
|
|
233
|
+
const { id, label, className: tabClassName, children: tabChildren } = node.props;
|
|
234
|
+
const text = label?.trim() || extractTextLabel(tabChildren).trim() || id;
|
|
235
|
+
return /* @__PURE__ */ jsx(TabsTrigger, {
|
|
236
|
+
value: id,
|
|
237
|
+
type: "button",
|
|
238
|
+
className: cn("h-auto min-h-9 w-full min-w-0 flex-none justify-start py-2 text-left whitespace-normal", tabClassName),
|
|
239
|
+
children: tabChildren != null ? tabChildren : text
|
|
240
|
+
}, id);
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function ScrollableSectionsTab(_props) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
function ScrollableSectionsContent({ id, className, children, ...rest }) {
|
|
250
|
+
const { registerSection } = useScrollableSections();
|
|
251
|
+
return /* @__PURE__ */ jsx("div", {
|
|
252
|
+
ref: React$1.useCallback((node) => {
|
|
253
|
+
registerSection(id, node);
|
|
254
|
+
}, [id, registerSection]),
|
|
255
|
+
id,
|
|
256
|
+
className: cn("scroll-mt-[calc(var(--espd-ss-sticky-top,1rem)+3rem)] md:scroll-mt-4", className),
|
|
257
|
+
...rest,
|
|
258
|
+
children
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
ScrollableSectionsTab.displayName = "ScrollableSections.Tab";
|
|
262
|
+
ScrollableSectionsTabs.displayName = "ScrollableSections.Tabs";
|
|
263
|
+
ScrollableSectionsContent.displayName = "ScrollableSections.Content";
|
|
264
|
+
var ScrollableSections = Object.assign(ScrollableSectionsRoot, {
|
|
265
|
+
Tabs: ScrollableSectionsTabs,
|
|
266
|
+
Tab: ScrollableSectionsTab,
|
|
267
|
+
Content: ScrollableSectionsContent
|
|
268
|
+
});
|
|
269
|
+
//#endregion
|
|
270
|
+
export { ScrollableSections };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { outlineSearchShellClasses, searchFieldContainerSizeClasses, searchFieldIconSizeClasses, searchFieldInputTextClasses } from "../search-field-shell.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Search, X } from "lucide-react";
|
|
7
|
+
//#region src/components/search-box/search-box.tsx
|
|
8
|
+
function SearchBox({ placeholder, onSearch, onClear, onValueChange, size = "default", className }) {
|
|
9
|
+
const [value, setValue] = useState("");
|
|
10
|
+
const handleKeyDown = (e) => {
|
|
11
|
+
if (e.key === "Enter") onSearch(value.trim());
|
|
12
|
+
};
|
|
13
|
+
const handleClear = () => {
|
|
14
|
+
setValue("");
|
|
15
|
+
onValueChange?.("");
|
|
16
|
+
onClear();
|
|
17
|
+
};
|
|
18
|
+
const handleValueChange = (nextValue) => {
|
|
19
|
+
setValue(nextValue);
|
|
20
|
+
onValueChange?.(nextValue);
|
|
21
|
+
};
|
|
22
|
+
const iconSize = searchFieldIconSizeClasses[size];
|
|
23
|
+
const trailingBtnClass = "h-auto w-auto p-0 m-0 shrink-0";
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
25
|
+
className: cn(outlineSearchShellClasses, "flex w-full items-center gap-2 rounded-md", "focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 ring-offset-background", searchFieldContainerSizeClasses[size], className),
|
|
26
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
27
|
+
type: "text",
|
|
28
|
+
value,
|
|
29
|
+
onChange: (e) => handleValueChange(e.target.value),
|
|
30
|
+
onKeyDown: handleKeyDown,
|
|
31
|
+
placeholder,
|
|
32
|
+
className: cn("flex-1 min-w-0 bg-transparent outline-none placeholder:text-muted-foreground", searchFieldInputTextClasses[size])
|
|
33
|
+
}), value ? /* @__PURE__ */ jsx(Button, {
|
|
34
|
+
type: "button",
|
|
35
|
+
variant: "ghost",
|
|
36
|
+
size,
|
|
37
|
+
fullWidth: false,
|
|
38
|
+
onClick: handleClear,
|
|
39
|
+
"aria-label": "Clear search",
|
|
40
|
+
startIcon: /* @__PURE__ */ jsx(X, { className: iconSize }),
|
|
41
|
+
className: trailingBtnClass
|
|
42
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
43
|
+
type: "button",
|
|
44
|
+
variant: "ghost",
|
|
45
|
+
size,
|
|
46
|
+
fullWidth: false,
|
|
47
|
+
disabled: true,
|
|
48
|
+
startIcon: /* @__PURE__ */ jsx(Search, { className: cn(iconSize, "text-muted-foreground") }),
|
|
49
|
+
className: trailingBtnClass
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { SearchBox as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/components/search-field-shell.ts
|
|
2
|
+
/** Matches `buttonVariants` outline surface (border, bg, shadow, hover). */
|
|
3
|
+
var outlineSearchShellClasses = "border border-input bg-background transition-colors hover:bg-accent hover:text-accent-foreground";
|
|
4
|
+
var searchFieldContainerSizeClasses = {
|
|
5
|
+
default: "h-9 px-4 py-2 text-sm",
|
|
6
|
+
sm: "h-8 px-3 text-xs",
|
|
7
|
+
lg: "h-10 px-8 text-sm"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Text size of the search `<input>` itself. 16px below `md`, like `Input`: iOS Safari zooms the
|
|
11
|
+
* page into any focused field whose text is smaller than 16px.
|
|
12
|
+
*/
|
|
13
|
+
var searchFieldInputTextClasses = {
|
|
14
|
+
default: "text-base md:text-sm",
|
|
15
|
+
sm: "text-base md:text-xs",
|
|
16
|
+
lg: "text-base md:text-sm"
|
|
17
|
+
};
|
|
18
|
+
var searchFieldIconSizeClasses = {
|
|
19
|
+
default: "h-4 w-4",
|
|
20
|
+
sm: "h-3 w-3",
|
|
21
|
+
lg: "h-4 w-4"
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { outlineSearchShellClasses, searchFieldContainerSizeClasses, searchFieldIconSizeClasses, searchFieldInputTextClasses };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { TooltipProvider } from "../../core/animate-ui/components/animate/tooltip.js";
|
|
4
|
+
import { Checkbox } from "../../core/checkbox/motion-checkbox.js";
|
|
5
|
+
import { FormFieldMirrors, SelectableCardListElementIndicator, SelectableCardListRowContent, controlAriaLabel, sizeStyles } from "./selectable-card-list-shared.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/selectable-card-list/checkbox-card-list.tsx
|
|
8
|
+
function CheckboxCardList(props) {
|
|
9
|
+
const { data, value, onChange, size, className, ariaLabel, ariaLabelledBy, name, form, element = "auto" } = props;
|
|
10
|
+
const s = sizeStyles[size];
|
|
11
|
+
const useNativeControl = element === "auto";
|
|
12
|
+
const isRowSelected = (id) => value.includes(id);
|
|
13
|
+
const handleChecked = (id, state) => {
|
|
14
|
+
const on = state === true;
|
|
15
|
+
const cur = new Set(value);
|
|
16
|
+
if (on) cur.add(id);
|
|
17
|
+
else cur.delete(id);
|
|
18
|
+
onChange([...cur]);
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(TooltipProvider, {
|
|
21
|
+
openDelay: 300,
|
|
22
|
+
closeDelay: 100,
|
|
23
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
role: "group",
|
|
25
|
+
className: cn("flex flex-col", s.listGap, className),
|
|
26
|
+
"aria-label": ariaLabel,
|
|
27
|
+
"aria-labelledby": ariaLabelledBy,
|
|
28
|
+
children: [/* @__PURE__ */ jsx(FormFieldMirrors, {
|
|
29
|
+
name,
|
|
30
|
+
form,
|
|
31
|
+
value,
|
|
32
|
+
multiple: true
|
|
33
|
+
}), data.map((item) => {
|
|
34
|
+
const selected = isRowSelected(item.id);
|
|
35
|
+
const aria = controlAriaLabel(item);
|
|
36
|
+
const rowClassName = cn("flex cursor-pointer items-center rounded-lg border-2 bg-card text-left transition-colors", selected ? "border-primary" : "border-border", s.rowPad, s.gap, item.disabled && "cursor-not-allowed opacity-50", !item.disabled && !selected && "hover:bg-accent/10 hover:border-primary/20");
|
|
37
|
+
const rowContent = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: cn("flex min-w-0 flex-1 items-center", s.gap),
|
|
39
|
+
children: /* @__PURE__ */ jsx(SelectableCardListRowContent, {
|
|
40
|
+
item,
|
|
41
|
+
selected,
|
|
42
|
+
s
|
|
43
|
+
})
|
|
44
|
+
}), useNativeControl ? /* @__PURE__ */ jsx(Checkbox, {
|
|
45
|
+
checked: selected,
|
|
46
|
+
disabled: item.disabled,
|
|
47
|
+
onCheckedChange: (c) => handleChecked(item.id, c),
|
|
48
|
+
"aria-label": aria,
|
|
49
|
+
className: cn("shrink-0", s.indicator)
|
|
50
|
+
}) : /* @__PURE__ */ jsx(SelectableCardListElementIndicator, {
|
|
51
|
+
element,
|
|
52
|
+
selected,
|
|
53
|
+
size,
|
|
54
|
+
disabled: item.disabled
|
|
55
|
+
})] });
|
|
56
|
+
if (useNativeControl) return /* @__PURE__ */ jsx("label", {
|
|
57
|
+
className: rowClassName,
|
|
58
|
+
children: rowContent
|
|
59
|
+
}, item.id);
|
|
60
|
+
return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
role: "checkbox",
|
|
62
|
+
"aria-checked": selected,
|
|
63
|
+
"aria-disabled": item.disabled ? true : void 0,
|
|
64
|
+
"aria-label": aria,
|
|
65
|
+
tabIndex: item.disabled ? -1 : 0,
|
|
66
|
+
className: rowClassName,
|
|
67
|
+
onClick: () => {
|
|
68
|
+
if (item.disabled) return;
|
|
69
|
+
handleChecked(item.id, !selected);
|
|
70
|
+
},
|
|
71
|
+
onKeyDown: (e) => {
|
|
72
|
+
if (item.disabled) return;
|
|
73
|
+
if (e.key === " " || e.key === "Enter") {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
handleChecked(item.id, !selected);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
children: rowContent
|
|
79
|
+
}, item.id);
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { CheckboxCardList };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { TooltipProvider } from "../../core/animate-ui/components/animate/tooltip.js";
|
|
4
|
+
import { Radio, RadioGroup } from "../../core/animate-ui/components/base/radio.js";
|
|
5
|
+
import { FormFieldMirrors, SelectableCardListElementIndicator, SelectableCardListRowContent, controlAriaLabel, sizeStyles } from "./selectable-card-list-shared.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/selectable-card-list/radio-card-list.tsx
|
|
8
|
+
function RadioCardListRows({ data, value, onChange, size, element, s }) {
|
|
9
|
+
const useNativeControl = element === "auto";
|
|
10
|
+
return data.map((item) => {
|
|
11
|
+
const selected = value === item.id;
|
|
12
|
+
const aria = controlAriaLabel(item);
|
|
13
|
+
const rowClassName = cn("flex cursor-pointer items-center rounded-lg border-2 bg-card text-left transition-colors", selected ? "border-primary" : "border-border", s.rowPad, s.gap, item.disabled && "cursor-not-allowed opacity-50", !item.disabled && !selected && "hover:bg-accent/10 hover:border-primary/20");
|
|
14
|
+
const rowContent = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: cn("flex min-w-0 flex-1 items-center", s.gap),
|
|
16
|
+
children: /* @__PURE__ */ jsx(SelectableCardListRowContent, {
|
|
17
|
+
item,
|
|
18
|
+
selected,
|
|
19
|
+
s
|
|
20
|
+
})
|
|
21
|
+
}), useNativeControl ? /* @__PURE__ */ jsx(Radio, {
|
|
22
|
+
value: item.id,
|
|
23
|
+
disabled: item.disabled,
|
|
24
|
+
className: cn("shrink-0", s.indicator),
|
|
25
|
+
"aria-label": aria
|
|
26
|
+
}) : /* @__PURE__ */ jsx(SelectableCardListElementIndicator, {
|
|
27
|
+
element,
|
|
28
|
+
selected,
|
|
29
|
+
size,
|
|
30
|
+
disabled: item.disabled
|
|
31
|
+
})] });
|
|
32
|
+
if (useNativeControl) return /* @__PURE__ */ jsx("label", {
|
|
33
|
+
className: rowClassName,
|
|
34
|
+
children: rowContent
|
|
35
|
+
}, item.id);
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
role: "radio",
|
|
38
|
+
"aria-checked": selected,
|
|
39
|
+
"aria-disabled": item.disabled ? true : void 0,
|
|
40
|
+
"aria-label": aria,
|
|
41
|
+
tabIndex: item.disabled ? -1 : 0,
|
|
42
|
+
className: rowClassName,
|
|
43
|
+
onClick: () => {
|
|
44
|
+
if (item.disabled) return;
|
|
45
|
+
onChange(item.id);
|
|
46
|
+
},
|
|
47
|
+
onKeyDown: (e) => {
|
|
48
|
+
if (item.disabled) return;
|
|
49
|
+
if (e.key === " " || e.key === "Enter") {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
onChange(item.id);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
children: rowContent
|
|
55
|
+
}, item.id);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function RadioCardList({ data, value, onChange, size, className, ariaLabel, ariaLabelledBy, name, form, element = "auto" }) {
|
|
59
|
+
const s = sizeStyles[size];
|
|
60
|
+
return /* @__PURE__ */ jsx(TooltipProvider, {
|
|
61
|
+
openDelay: 300,
|
|
62
|
+
closeDelay: 100,
|
|
63
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormFieldMirrors, {
|
|
64
|
+
name,
|
|
65
|
+
form,
|
|
66
|
+
value,
|
|
67
|
+
multiple: false
|
|
68
|
+
}), element === "auto" ? /* @__PURE__ */ jsx(RadioGroup, {
|
|
69
|
+
value,
|
|
70
|
+
onValueChange: (v) => onChange(String(v)),
|
|
71
|
+
"aria-label": ariaLabel,
|
|
72
|
+
"aria-labelledby": ariaLabelledBy,
|
|
73
|
+
className: cn("flex flex-col", s.listGap, className),
|
|
74
|
+
children: /* @__PURE__ */ jsx(RadioCardListRows, {
|
|
75
|
+
data,
|
|
76
|
+
value,
|
|
77
|
+
onChange,
|
|
78
|
+
size,
|
|
79
|
+
element,
|
|
80
|
+
s
|
|
81
|
+
})
|
|
82
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
83
|
+
role: "radiogroup",
|
|
84
|
+
"aria-label": ariaLabel,
|
|
85
|
+
"aria-labelledby": ariaLabelledBy,
|
|
86
|
+
className: cn("flex flex-col", s.listGap, className),
|
|
87
|
+
children: /* @__PURE__ */ jsx(RadioCardListRows, {
|
|
88
|
+
data,
|
|
89
|
+
value,
|
|
90
|
+
onChange,
|
|
91
|
+
size,
|
|
92
|
+
element,
|
|
93
|
+
s
|
|
94
|
+
})
|
|
95
|
+
})] })
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { RadioCardList };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { IconAvatar } from "../icon-avatar/icon-avatar.js";
|
|
4
|
+
import { TruncatedLineWithTooltip } from "../truncated-line-with-tooltip/truncated-line-with-tooltip.js";
|
|
5
|
+
import { cloneElement, isValidElement } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Check, X } from "lucide-react";
|
|
8
|
+
//#region src/components/selectable-card-list/selectable-card-list-shared.tsx
|
|
9
|
+
var sizeStyles = {
|
|
10
|
+
sm: {
|
|
11
|
+
rowPad: "p-3",
|
|
12
|
+
gap: "gap-2",
|
|
13
|
+
primary: "text-xs font-semibold text-foreground",
|
|
14
|
+
secondary: "text-xs text-muted-foreground",
|
|
15
|
+
icon: "h-[18px] w-[18px] shrink-0 items-center justify-center",
|
|
16
|
+
indicator: "size-3.5",
|
|
17
|
+
avatar: 36,
|
|
18
|
+
listGap: "gap-3"
|
|
19
|
+
},
|
|
20
|
+
default: {
|
|
21
|
+
rowPad: "p-4",
|
|
22
|
+
gap: "gap-3",
|
|
23
|
+
primary: "text-sm font-semibold text-foreground",
|
|
24
|
+
secondary: "text-sm text-muted-foreground",
|
|
25
|
+
icon: "h-6 w-6 shrink-0 items-center justify-center",
|
|
26
|
+
indicator: "size-4",
|
|
27
|
+
avatar: 44,
|
|
28
|
+
listGap: "gap-4"
|
|
29
|
+
},
|
|
30
|
+
lg: {
|
|
31
|
+
rowPad: "p-6",
|
|
32
|
+
gap: "gap-4",
|
|
33
|
+
primary: "text-base font-semibold text-foreground",
|
|
34
|
+
secondary: "text-sm text-muted-foreground",
|
|
35
|
+
icon: "h-8 w-8 shrink-0 items-center justify-center",
|
|
36
|
+
indicator: "size-5",
|
|
37
|
+
avatar: 52,
|
|
38
|
+
listGap: "gap-5"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function primaryTooltipContent(item) {
|
|
42
|
+
if (typeof item.primaryText === "string") return item.primaryText;
|
|
43
|
+
if ("ariaLabel" in item) return item.ariaLabel;
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function iconSized(icon, iconClass) {
|
|
47
|
+
if (icon == null) return null;
|
|
48
|
+
if (isValidElement(icon)) {
|
|
49
|
+
const el = icon;
|
|
50
|
+
return cloneElement(el, { className: cn(el.props.className, iconClass) });
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: cn("inline-flex items-center justify-center", iconClass),
|
|
54
|
+
children: icon
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function controlAriaLabel(item) {
|
|
58
|
+
if ("ariaLabel" in item) return item.ariaLabel;
|
|
59
|
+
}
|
|
60
|
+
/** ~25% larger than `sizeStyles[*].indicator` (3.5 / 4 / 5 → 17.5px / 20px / 25px). */
|
|
61
|
+
var iconIndicatorClass = {
|
|
62
|
+
sm: "size-[17.5px]",
|
|
63
|
+
default: "size-5",
|
|
64
|
+
lg: "size-[25px]"
|
|
65
|
+
};
|
|
66
|
+
/** Decorative switch for selectable rows — not interactive; row `onClick` / keyboard toggles selection. */
|
|
67
|
+
function SelectableCardSwitchVisual({ checked, disabled, className }) {
|
|
68
|
+
return /* @__PURE__ */ jsx("span", {
|
|
69
|
+
"aria-hidden": true,
|
|
70
|
+
"data-state": checked ? "checked" : "unchecked",
|
|
71
|
+
className: cn("pointer-events-none relative inline-flex h-5 w-8 shrink-0 items-center rounded-full border border-transparent px-px shadow-xs", checked ? "justify-end bg-primary" : "justify-start bg-input dark:bg-input/80", disabled && "opacity-50", className),
|
|
72
|
+
children: /* @__PURE__ */ jsx("span", { className: cn("pointer-events-none block size-4 rounded-full bg-background ring-0", checked ? "dark:bg-primary-foreground" : "dark:bg-foreground") })
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function SelectableCardListElementIndicator({ element, selected, size, disabled }) {
|
|
76
|
+
if (element === "switch") return /* @__PURE__ */ jsx(SelectableCardSwitchVisual, {
|
|
77
|
+
checked: selected,
|
|
78
|
+
disabled
|
|
79
|
+
});
|
|
80
|
+
const Icon = selected ? Check : X;
|
|
81
|
+
return /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: cn("inline-flex shrink-0 items-center justify-center", selected ? "text-success" : "text-error", iconIndicatorClass[size]),
|
|
83
|
+
"aria-hidden": true,
|
|
84
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
85
|
+
className: "size-full",
|
|
86
|
+
strokeWidth: 2.5
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function FormFieldMirrors({ name, form, value, multiple }) {
|
|
91
|
+
if (name == null || name === "") return null;
|
|
92
|
+
if (multiple) return /* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: "hidden",
|
|
94
|
+
"aria-hidden": true,
|
|
95
|
+
children: value.map((id) => /* @__PURE__ */ jsx("input", {
|
|
96
|
+
type: "hidden",
|
|
97
|
+
name,
|
|
98
|
+
value: id,
|
|
99
|
+
form
|
|
100
|
+
}, id))
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "hidden",
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
106
|
+
type: "hidden",
|
|
107
|
+
name,
|
|
108
|
+
value,
|
|
109
|
+
form
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function SelectableCardListRowContent({ item, selected, s }) {
|
|
114
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
115
|
+
className: "flex shrink-0 items-center justify-center",
|
|
116
|
+
children: /* @__PURE__ */ jsx(IconAvatar, {
|
|
117
|
+
size: s.avatar,
|
|
118
|
+
color: selected ? "primary" : "gray",
|
|
119
|
+
children: iconSized(item.icon, s.icon)
|
|
120
|
+
})
|
|
121
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
122
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
123
|
+
children: [/* @__PURE__ */ jsx(TruncatedLineWithTooltip, {
|
|
124
|
+
className: s.primary,
|
|
125
|
+
tooltipContent: primaryTooltipContent(item),
|
|
126
|
+
children: item.primaryText
|
|
127
|
+
}), item.secondaryText != null ? /* @__PURE__ */ jsx(TruncatedLineWithTooltip, {
|
|
128
|
+
className: s.secondary,
|
|
129
|
+
tooltipContent: item.secondaryText,
|
|
130
|
+
children: item.secondaryText
|
|
131
|
+
}) : null]
|
|
132
|
+
})] });
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { FormFieldMirrors, SelectableCardListElementIndicator, SelectableCardListRowContent, SelectableCardSwitchVisual, controlAriaLabel, iconSized, sizeStyles };
|