@espressif/dashboard-ui-components 1.9.1 → 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 +179 -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 +159 -63
- 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.d.ts +1 -1
- 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-ABBHGIFI.js +0 -733
- package/dist/chunk-HIUBSBAP.js +0 -59
- package/dist/chunk-OKB2WTX7.js +0 -363
- package/dist/chunk-P6F6UWV2.js +0 -323
- package/dist/chunk-TRTQSARU.js +0 -31
- package/dist/chunk-VU4CZ76T.js +0 -43
- package/dist/chunk-XFYL5IZU.js +0 -69604
- package/dist/chunk-XW6Z6VO4.js +0 -505
- package/dist/chunk-ZFYUONPY.js +0 -4321
- 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,108 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Badge } from "../../core/badge.js";
|
|
3
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
//#region src/components/status-badge/status-badge.tsx
|
|
8
|
+
function renderStatusBadgeIcon(icon, px) {
|
|
9
|
+
if (!icon) return null;
|
|
10
|
+
if (React$1.isValidElement(icon)) return icon;
|
|
11
|
+
return /* @__PURE__ */ jsx(icon, {
|
|
12
|
+
size: px,
|
|
13
|
+
"aria-hidden": true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Size-specific class + pixel tokens for the icon slot. Keeps the JSX free of
|
|
18
|
+
* ternaries and lines up with the icon size scale used by `UserTypeBadge`.
|
|
19
|
+
*/
|
|
20
|
+
var ICON_PX = {
|
|
21
|
+
sm: 14,
|
|
22
|
+
default: 16,
|
|
23
|
+
lg: 18
|
|
24
|
+
};
|
|
25
|
+
var statusBadgeSizeVariants = cva("rounded-full font-normal [&_svg]:shrink-0", {
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
sm: "gap-1 py-0.5 text-xs",
|
|
29
|
+
default: "gap-1.5 py-0.5 text-xs",
|
|
30
|
+
lg: "gap-1.5 py-1 text-sm"
|
|
31
|
+
},
|
|
32
|
+
hasIcon: {
|
|
33
|
+
true: "",
|
|
34
|
+
false: ""
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
compoundVariants: [
|
|
38
|
+
{
|
|
39
|
+
size: "sm",
|
|
40
|
+
hasIcon: true,
|
|
41
|
+
class: "pl-0.5 pr-1.5"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
size: "sm",
|
|
45
|
+
hasIcon: false,
|
|
46
|
+
class: "px-1.5"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
size: "default",
|
|
50
|
+
hasIcon: true,
|
|
51
|
+
class: "pl-0.5 pr-1.75"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
size: "default",
|
|
55
|
+
hasIcon: false,
|
|
56
|
+
class: "px-1.75"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
size: "lg",
|
|
60
|
+
hasIcon: true,
|
|
61
|
+
class: "pl-1 pr-2.25"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
size: "lg",
|
|
65
|
+
hasIcon: false,
|
|
66
|
+
class: "px-2.25"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
size: "default",
|
|
71
|
+
hasIcon: false
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Shared icon+label status chip. Consumers resolve their per-status
|
|
76
|
+
* presentation (icon, colour, translated label) and hand the results in here,
|
|
77
|
+
* so every status badge across apps stays visually consistent.
|
|
78
|
+
*
|
|
79
|
+
* The primitive stays i18n-free and registry-free — the per-status mapping
|
|
80
|
+
* belongs in the consuming app's domain layer.
|
|
81
|
+
*/
|
|
82
|
+
var StatusBadge = React$1.forwardRef(({ label, icon: Icon, color, variant = "soft", size = "default", isLoading = false, className, labelClassName, ...props }, ref) => {
|
|
83
|
+
const iconPx = ICON_PX[size];
|
|
84
|
+
const showIcon = isLoading || !!Icon;
|
|
85
|
+
return /* @__PURE__ */ jsx("div", {
|
|
86
|
+
ref,
|
|
87
|
+
className: "inline-flex align-middle",
|
|
88
|
+
...props,
|
|
89
|
+
children: /* @__PURE__ */ jsxs(Badge, {
|
|
90
|
+
color,
|
|
91
|
+
variant,
|
|
92
|
+
className: cn(statusBadgeSizeVariants({
|
|
93
|
+
size,
|
|
94
|
+
hasIcon: showIcon
|
|
95
|
+
}), className),
|
|
96
|
+
children: [isLoading ? /* @__PURE__ */ jsx(Spinner, {
|
|
97
|
+
size: iconPx,
|
|
98
|
+
"aria-hidden": true
|
|
99
|
+
}) : renderStatusBadgeIcon(Icon, iconPx), /* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: cn("min-w-0 truncate", labelClassName),
|
|
101
|
+
children: label
|
|
102
|
+
})]
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
StatusBadge.displayName = "StatusBadge";
|
|
107
|
+
//#endregion
|
|
108
|
+
export { StatusBadge, statusBadgeSizeVariants };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../core/animate-ui/components/animate/tooltip.js";
|
|
4
|
+
import { IconAvatar } from "../icon-avatar/icon-avatar.js";
|
|
5
|
+
import { cloneElement, isValidElement, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { CheckCircle2, Clock, LoaderCircle, TriangleAlert, XCircle } from "lucide-react";
|
|
8
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
9
|
+
//#region src/components/status-card-list/status-card-list.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Text / icons: Alert soft `colorStyles.*.filled` + `.description`.
|
|
12
|
+
* Card fill + border: same tokens, driven through `motion.li` for smooth state transitions.
|
|
13
|
+
*/
|
|
14
|
+
var stateVisuals = {
|
|
15
|
+
success: {
|
|
16
|
+
avatarColor: "success",
|
|
17
|
+
endIconClass: "text-success",
|
|
18
|
+
titleClass: "text-success",
|
|
19
|
+
descriptionClass: "text-success/80"
|
|
20
|
+
},
|
|
21
|
+
warning: {
|
|
22
|
+
avatarColor: "warning",
|
|
23
|
+
endIconClass: "text-warning",
|
|
24
|
+
titleClass: "text-warning",
|
|
25
|
+
descriptionClass: "text-warning/80"
|
|
26
|
+
},
|
|
27
|
+
error: {
|
|
28
|
+
avatarColor: "error",
|
|
29
|
+
endIconClass: "text-error",
|
|
30
|
+
titleClass: "text-error",
|
|
31
|
+
descriptionClass: "text-error/80"
|
|
32
|
+
},
|
|
33
|
+
in_progress: {
|
|
34
|
+
avatarColor: "primary",
|
|
35
|
+
endIconClass: "text-primary",
|
|
36
|
+
titleClass: "text-primary",
|
|
37
|
+
descriptionClass: "text-primary/80"
|
|
38
|
+
},
|
|
39
|
+
not_started: {
|
|
40
|
+
avatarColor: "gray",
|
|
41
|
+
endIconClass: "text-gray",
|
|
42
|
+
titleClass: "text-gray",
|
|
43
|
+
descriptionClass: "text-gray/80"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/** Theme vars from `colors.css` @theme — card fill/border at 5% mix (Tailwind `bg-* /5`, `border-* /5`). */
|
|
47
|
+
var stateSurfaceCssVar = {
|
|
48
|
+
success: "--color-success",
|
|
49
|
+
warning: "--color-warning",
|
|
50
|
+
error: "--color-error",
|
|
51
|
+
in_progress: "--color-primary",
|
|
52
|
+
not_started: "--color-gray"
|
|
53
|
+
};
|
|
54
|
+
function stateSurfaceMotion(state) {
|
|
55
|
+
const v = stateSurfaceCssVar[state];
|
|
56
|
+
return {
|
|
57
|
+
backgroundColor: `color-mix(in srgb, var(${v}) 5%, transparent)`,
|
|
58
|
+
borderColor: `color-mix(in srgb, var(${v}) 5%, transparent)`
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var cardMotionTransition = {
|
|
62
|
+
duration: .38,
|
|
63
|
+
ease: [
|
|
64
|
+
.22,
|
|
65
|
+
1,
|
|
66
|
+
.36,
|
|
67
|
+
1
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
var endIconPresenceTransition = {
|
|
71
|
+
duration: .22,
|
|
72
|
+
ease: [
|
|
73
|
+
.22,
|
|
74
|
+
1,
|
|
75
|
+
.36,
|
|
76
|
+
1
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
var colorTransitionClass = "transition-colors duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]";
|
|
80
|
+
var sizeStyles = {
|
|
81
|
+
sm: {
|
|
82
|
+
rowPad: "p-3",
|
|
83
|
+
gap: "gap-2",
|
|
84
|
+
primary: "text-xs font-semibold",
|
|
85
|
+
secondary: "text-xs",
|
|
86
|
+
icon: "h-[18px] w-[18px] shrink-0",
|
|
87
|
+
endIcon: "size-5 shrink-0",
|
|
88
|
+
avatar: 36,
|
|
89
|
+
listGap: "gap-3"
|
|
90
|
+
},
|
|
91
|
+
default: {
|
|
92
|
+
rowPad: "p-4",
|
|
93
|
+
gap: "gap-3",
|
|
94
|
+
primary: "text-sm font-semibold",
|
|
95
|
+
secondary: "text-sm",
|
|
96
|
+
icon: "h-6 w-6 shrink-0",
|
|
97
|
+
endIcon: "size-6 shrink-0",
|
|
98
|
+
avatar: 44,
|
|
99
|
+
listGap: "gap-4"
|
|
100
|
+
},
|
|
101
|
+
lg: {
|
|
102
|
+
rowPad: "p-6",
|
|
103
|
+
gap: "gap-4",
|
|
104
|
+
primary: "text-base font-semibold",
|
|
105
|
+
secondary: "text-sm",
|
|
106
|
+
icon: "h-8 w-8 shrink-0",
|
|
107
|
+
endIcon: "size-7 shrink-0",
|
|
108
|
+
avatar: 52,
|
|
109
|
+
listGap: "gap-5"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function hasTooltipContent(content) {
|
|
113
|
+
if (content == null) return false;
|
|
114
|
+
if (typeof content === "string") return content.length > 0;
|
|
115
|
+
if (typeof content === "number") return true;
|
|
116
|
+
if (typeof content === "boolean") return false;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
function iconSized(icon, iconClass) {
|
|
120
|
+
if (icon == null) return null;
|
|
121
|
+
if (isValidElement(icon)) {
|
|
122
|
+
const el = icon;
|
|
123
|
+
return cloneElement(el, { className: cn(el.props.className, iconClass) });
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: cn("inline-flex items-center justify-center", iconClass),
|
|
127
|
+
children: icon
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function TruncatedLineWithTooltip({ className, tooltipContent, children }) {
|
|
131
|
+
const textRef = useRef(null);
|
|
132
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
133
|
+
const measure = useCallback(() => {
|
|
134
|
+
const el = textRef.current;
|
|
135
|
+
if (!el) return;
|
|
136
|
+
setIsTruncated(el.scrollWidth > el.clientWidth + 1);
|
|
137
|
+
}, []);
|
|
138
|
+
useLayoutEffect(() => {
|
|
139
|
+
measure();
|
|
140
|
+
}, [
|
|
141
|
+
measure,
|
|
142
|
+
children,
|
|
143
|
+
tooltipContent
|
|
144
|
+
]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
147
|
+
const el = textRef.current;
|
|
148
|
+
const ro = new ResizeObserver(measure);
|
|
149
|
+
if (el) ro.observe(el);
|
|
150
|
+
return () => ro.disconnect();
|
|
151
|
+
}, [measure]);
|
|
152
|
+
const line = /* @__PURE__ */ jsx("span", {
|
|
153
|
+
ref: textRef,
|
|
154
|
+
className: cn("block min-w-0 truncate", className),
|
|
155
|
+
children
|
|
156
|
+
});
|
|
157
|
+
if (!(isTruncated && hasTooltipContent(tooltipContent))) return line;
|
|
158
|
+
return /* @__PURE__ */ jsxs(Tooltip, {
|
|
159
|
+
side: "top",
|
|
160
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
161
|
+
className: "block min-w-0 w-full cursor-inherit text-left",
|
|
162
|
+
children: line
|
|
163
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
164
|
+
className: "max-w-sm",
|
|
165
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
166
|
+
className: "break-words",
|
|
167
|
+
children: tooltipContent
|
|
168
|
+
})
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function StatusEndIndicator({ state, endIconClass, endIconSizeClass }) {
|
|
173
|
+
const cls = cn(endIconSizeClass, endIconClass);
|
|
174
|
+
switch (state) {
|
|
175
|
+
case "success": return /* @__PURE__ */ jsx(CheckCircle2, {
|
|
176
|
+
className: cls,
|
|
177
|
+
"aria-hidden": true
|
|
178
|
+
});
|
|
179
|
+
case "warning": return /* @__PURE__ */ jsx(TriangleAlert, {
|
|
180
|
+
className: cls,
|
|
181
|
+
"aria-hidden": true
|
|
182
|
+
});
|
|
183
|
+
case "error": return /* @__PURE__ */ jsx(XCircle, {
|
|
184
|
+
className: cls,
|
|
185
|
+
"aria-hidden": true
|
|
186
|
+
});
|
|
187
|
+
case "in_progress": return /* @__PURE__ */ jsx(LoaderCircle, {
|
|
188
|
+
className: cn(cls, "animate-spin"),
|
|
189
|
+
"aria-hidden": true
|
|
190
|
+
});
|
|
191
|
+
case "not_started": return /* @__PURE__ */ jsx(Clock, {
|
|
192
|
+
className: cls,
|
|
193
|
+
"aria-hidden": true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function StatusCardListRow({ item, s }) {
|
|
198
|
+
const visuals = stateVisuals[item.state];
|
|
199
|
+
return /* @__PURE__ */ jsxs(motion.li, {
|
|
200
|
+
layout: true,
|
|
201
|
+
initial: false,
|
|
202
|
+
animate: stateSurfaceMotion(item.state),
|
|
203
|
+
transition: cardMotionTransition,
|
|
204
|
+
className: cn("flex items-center rounded-lg border border-solid text-left", s.rowPad, s.gap),
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
207
|
+
layout: "position",
|
|
208
|
+
className: "flex shrink-0 items-center justify-center",
|
|
209
|
+
children: /* @__PURE__ */ jsx(IconAvatar, {
|
|
210
|
+
size: s.avatar,
|
|
211
|
+
color: visuals.avatarColor,
|
|
212
|
+
ring: {
|
|
213
|
+
show: true,
|
|
214
|
+
color: visuals.avatarColor
|
|
215
|
+
},
|
|
216
|
+
children: iconSized(item.icon, cn(s.icon, visuals.titleClass, colorTransitionClass))
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
/* @__PURE__ */ jsxs(motion.span, {
|
|
220
|
+
layout: "position",
|
|
221
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
222
|
+
children: [/* @__PURE__ */ jsx(TruncatedLineWithTooltip, {
|
|
223
|
+
className: cn(s.primary, visuals.titleClass, colorTransitionClass),
|
|
224
|
+
tooltipContent: item.title,
|
|
225
|
+
children: item.title
|
|
226
|
+
}), item.description != null ? /* @__PURE__ */ jsx(TruncatedLineWithTooltip, {
|
|
227
|
+
className: cn(s.secondary, visuals.descriptionClass, colorTransitionClass),
|
|
228
|
+
tooltipContent: item.description,
|
|
229
|
+
children: item.description
|
|
230
|
+
}) : null]
|
|
231
|
+
}),
|
|
232
|
+
/* @__PURE__ */ jsxs(motion.span, {
|
|
233
|
+
layout: "position",
|
|
234
|
+
className: cn("flex shrink-0 items-center justify-end gap-2"),
|
|
235
|
+
children: [item.action != null ? /* @__PURE__ */ jsx("span", {
|
|
236
|
+
className: "flex shrink-0 items-center",
|
|
237
|
+
children: item.action
|
|
238
|
+
}) : null, /* @__PURE__ */ jsx(AnimatePresence, {
|
|
239
|
+
initial: false,
|
|
240
|
+
mode: "wait",
|
|
241
|
+
children: /* @__PURE__ */ jsx(motion.span, {
|
|
242
|
+
className: "inline-flex shrink-0 items-center justify-center",
|
|
243
|
+
initial: {
|
|
244
|
+
opacity: 0,
|
|
245
|
+
scale: .88
|
|
246
|
+
},
|
|
247
|
+
animate: {
|
|
248
|
+
opacity: 1,
|
|
249
|
+
scale: 1
|
|
250
|
+
},
|
|
251
|
+
exit: {
|
|
252
|
+
opacity: 0,
|
|
253
|
+
scale: .88
|
|
254
|
+
},
|
|
255
|
+
transition: endIconPresenceTransition,
|
|
256
|
+
children: /* @__PURE__ */ jsx(StatusEndIndicator, {
|
|
257
|
+
state: item.state,
|
|
258
|
+
endIconClass: cn(visuals.endIconClass, colorTransitionClass),
|
|
259
|
+
endIconSizeClass: s.endIcon
|
|
260
|
+
})
|
|
261
|
+
}, item.state)
|
|
262
|
+
})]
|
|
263
|
+
})
|
|
264
|
+
]
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function StatusCardList({ data, size = "default", className }) {
|
|
268
|
+
const s = sizeStyles[size];
|
|
269
|
+
return /* @__PURE__ */ jsx(TooltipProvider, {
|
|
270
|
+
openDelay: 300,
|
|
271
|
+
closeDelay: 100,
|
|
272
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
273
|
+
className: cn("flex flex-col min-w-0", s.listGap, className),
|
|
274
|
+
children: data.map((item) => /* @__PURE__ */ jsx(StatusCardListRow, {
|
|
275
|
+
item,
|
|
276
|
+
s
|
|
277
|
+
}, item.id))
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
export { StatusCardList };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { buttonVariants } from "../../core/button.js";
|
|
3
|
+
import Tooltip from "../tooltip/tooltip.js";
|
|
4
|
+
import { Badge } from "../../core/badge.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Tag, X } from "lucide-react";
|
|
8
|
+
import { cva } from "class-variance-authority";
|
|
9
|
+
//#region src/components/tag/tag.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Per-variant tint applied to the inner name chip so it stays visually distinct
|
|
12
|
+
* from the surrounding Badge surface across all four variants.
|
|
13
|
+
*
|
|
14
|
+
* - `soft`: chip uses a light `color/10` tint to stay distinct from value text.
|
|
15
|
+
* - `outline` / `gradient`: badge has no fill, so chip uses a `color/15` patch.
|
|
16
|
+
* - `solid`: badge is saturated; chip uses a translucent dark patch for contrast.
|
|
17
|
+
*/
|
|
18
|
+
var NAME_CHIP_TINT = {
|
|
19
|
+
soft: {
|
|
20
|
+
primary: "bg-primary/10",
|
|
21
|
+
secondary: "bg-secondary/10",
|
|
22
|
+
error: "bg-error/10",
|
|
23
|
+
info: "bg-info/10",
|
|
24
|
+
success: "bg-success/10",
|
|
25
|
+
warning: "bg-warning/10",
|
|
26
|
+
disabled: "bg-disabled/10",
|
|
27
|
+
gray: "bg-gray/10",
|
|
28
|
+
mist: "bg-mist-border/70"
|
|
29
|
+
},
|
|
30
|
+
outline: {
|
|
31
|
+
primary: "bg-primary/15",
|
|
32
|
+
secondary: "bg-secondary/15",
|
|
33
|
+
error: "bg-error/15",
|
|
34
|
+
info: "bg-info/15",
|
|
35
|
+
success: "bg-success/15",
|
|
36
|
+
warning: "bg-warning/15",
|
|
37
|
+
disabled: "bg-disabled/15",
|
|
38
|
+
gray: "bg-gray/15",
|
|
39
|
+
mist: "bg-mist-border"
|
|
40
|
+
},
|
|
41
|
+
gradient: {
|
|
42
|
+
primary: "bg-primary/15",
|
|
43
|
+
secondary: "bg-secondary/15",
|
|
44
|
+
error: "bg-error/15",
|
|
45
|
+
info: "bg-info/15",
|
|
46
|
+
success: "bg-success/15",
|
|
47
|
+
warning: "bg-warning/15",
|
|
48
|
+
disabled: "bg-disabled/15",
|
|
49
|
+
gray: "bg-gray/15",
|
|
50
|
+
mist: "bg-mist-border"
|
|
51
|
+
},
|
|
52
|
+
solid: {
|
|
53
|
+
primary: "bg-black/25 text-primary-foreground",
|
|
54
|
+
secondary: "bg-black/15 text-secondary-foreground",
|
|
55
|
+
error: "bg-black/25 text-error-foreground",
|
|
56
|
+
info: "bg-black/25 text-info-foreground",
|
|
57
|
+
success: "bg-black/25 text-success-foreground",
|
|
58
|
+
warning: "bg-black/25 text-warning-foreground",
|
|
59
|
+
disabled: "bg-black/20 text-disabled-foreground",
|
|
60
|
+
gray: "bg-black/20 text-gray-foreground",
|
|
61
|
+
mist: "bg-black/10 text-mist-foreground"
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/** `"silver"` chip tints follow the gray family with slightly extra contrast for the metallic surface. */
|
|
65
|
+
var SILVER_NAME_CHIP_TINT = {
|
|
66
|
+
soft: "bg-gray/10",
|
|
67
|
+
outline: "bg-gray/15",
|
|
68
|
+
gradient: "bg-gray/15",
|
|
69
|
+
solid: "bg-black/20 text-gray-foreground"
|
|
70
|
+
};
|
|
71
|
+
function getNameChipTint(variant, color) {
|
|
72
|
+
if (color === "silver") return SILVER_NAME_CHIP_TINT[variant];
|
|
73
|
+
return NAME_CHIP_TINT[variant][color];
|
|
74
|
+
}
|
|
75
|
+
var tagSizeVariants = cva("inline-flex min-w-0 max-w-full items-center shadow-none transition-shadow duration-200 ease-out hover:shadow-sm [&_svg]:shrink-0", {
|
|
76
|
+
variants: { size: {
|
|
77
|
+
sm: "gap-1 px-1.5 py-0.5 text-xs [&_svg]:size-3",
|
|
78
|
+
default: "gap-1.5 px-2 py-1 text-sm [&_svg]:size-3.5",
|
|
79
|
+
lg: "gap-2 px-2.5 py-1.5 text-base [&_svg]:size-4"
|
|
80
|
+
} },
|
|
81
|
+
defaultVariants: { size: "default" }
|
|
82
|
+
});
|
|
83
|
+
var deleteButtonSizeClasses = {
|
|
84
|
+
sm: "h-5 w-5 [&_svg]:size-3",
|
|
85
|
+
default: "h-6 w-6 [&_svg]:size-3.5",
|
|
86
|
+
lg: "h-7 w-7 [&_svg]:size-4"
|
|
87
|
+
};
|
|
88
|
+
var deleteButtonVariantClasses = {
|
|
89
|
+
soft: "bg-error/10 text-error hover:bg-error/15 hover:text-error",
|
|
90
|
+
outline: "bg-error/10 text-error hover:bg-error/15 hover:text-error",
|
|
91
|
+
gradient: "bg-error/10 text-error hover:bg-error/15 hover:text-error",
|
|
92
|
+
solid: "bg-error/20 text-error-foreground hover:bg-error/30 hover:text-error-foreground"
|
|
93
|
+
};
|
|
94
|
+
var Tag$1 = React$1.forwardRef(({ name, value, nameTooltip, valueTooltip, size = "default", color = "secondary", variant = "soft", rounded = false, onDelete, className, ...rest }, ref) => {
|
|
95
|
+
const nameTip = nameTooltip ?? name;
|
|
96
|
+
const valueTip = value !== void 0 ? valueTooltip ?? value : void 0;
|
|
97
|
+
const removeLabel = value !== void 0 ? `${nameTooltip ?? name}: ${valueTooltip ?? value}` : nameTooltip ?? name;
|
|
98
|
+
return /* @__PURE__ */ jsx("div", {
|
|
99
|
+
ref,
|
|
100
|
+
className: "inline-block max-w-full",
|
|
101
|
+
...rest,
|
|
102
|
+
children: /* @__PURE__ */ jsxs(Badge, {
|
|
103
|
+
variant,
|
|
104
|
+
color,
|
|
105
|
+
className: cn(tagSizeVariants({ size }), rounded && "rounded-full", className),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(Tag, {
|
|
108
|
+
"aria-hidden": true,
|
|
109
|
+
className: "opacity-70"
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
112
|
+
content: nameTip,
|
|
113
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: cn("min-w-0 truncate px-1.5 py-0.5 font-medium", rounded ? "rounded-full" : "rounded-sm", getNameChipTint(variant, color)),
|
|
115
|
+
children: name
|
|
116
|
+
})
|
|
117
|
+
}),
|
|
118
|
+
value !== void 0 ? /* @__PURE__ */ jsx(Tooltip, {
|
|
119
|
+
content: valueTip,
|
|
120
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
121
|
+
className: "min-w-0 truncate font-normal",
|
|
122
|
+
children: value
|
|
123
|
+
})
|
|
124
|
+
}) : null,
|
|
125
|
+
onDelete ? /* @__PURE__ */ jsx("button", {
|
|
126
|
+
type: "button",
|
|
127
|
+
"aria-label": `Remove ${removeLabel}`,
|
|
128
|
+
className: cn(buttonVariants({
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
size: "icon"
|
|
131
|
+
}), deleteButtonSizeClasses[size], "shrink-0", rounded && "rounded-full", deleteButtonVariantClasses[variant]),
|
|
132
|
+
onClick: onDelete,
|
|
133
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
134
|
+
"aria-hidden": true,
|
|
135
|
+
strokeWidth: 2
|
|
136
|
+
})
|
|
137
|
+
}) : null
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
Tag$1.displayName = "Tag";
|
|
143
|
+
//#endregion
|
|
144
|
+
export { Tag$1 as Tag };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Tag } from "../tag/tag.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/tag-input/tag-input.tsx
|
|
6
|
+
var labelClasses = "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50";
|
|
7
|
+
var controlSizeClasses = {
|
|
8
|
+
sm: "min-h-8 gap-1 px-2 py-1 text-xs",
|
|
9
|
+
default: "min-h-10 gap-1.5 px-3 py-2 text-base md:text-sm",
|
|
10
|
+
lg: "min-h-12 gap-2 px-4 py-2 text-lg"
|
|
11
|
+
};
|
|
12
|
+
var inputTextSizeClasses = {
|
|
13
|
+
sm: "text-xs",
|
|
14
|
+
default: "text-base md:text-sm",
|
|
15
|
+
lg: "text-lg"
|
|
16
|
+
};
|
|
17
|
+
function truncateDisplay(text, maxLen) {
|
|
18
|
+
if (text.length <= maxLen) return text;
|
|
19
|
+
return `${text.slice(0, maxLen)}…`;
|
|
20
|
+
}
|
|
21
|
+
/** First colon separates name and value; both sides must be non-empty. */
|
|
22
|
+
function parseNameValueTag(tag) {
|
|
23
|
+
const i = tag.indexOf(":");
|
|
24
|
+
if (i <= 0 || i >= tag.length - 1) return null;
|
|
25
|
+
return {
|
|
26
|
+
name: tag.slice(0, i),
|
|
27
|
+
value: tag.slice(i + 1)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var TagInput = React$1.forwardRef(({ tags, onTagsChange, label, required, size, rounded, startHelperContent, endHelperContent, hintContent, error, errorContent, validatorRegex, onInvalidTag, allowDuplicates = false, maxTagDisplayLength = 10, nameValueTags = false, className, id, disabled, readOnly, placeholder, onKeyDown, onBlur, ...restInputProps }, ref) => {
|
|
31
|
+
const autoId = React$1.useId();
|
|
32
|
+
const inputId = id ?? autoId;
|
|
33
|
+
const rootRef = React$1.useRef(null);
|
|
34
|
+
const [draft, setDraft] = React$1.useState("");
|
|
35
|
+
const effectiveSize = size ?? "default";
|
|
36
|
+
const hasError = error || !!errorContent;
|
|
37
|
+
const tryCommitDraft = React$1.useCallback(() => {
|
|
38
|
+
if (disabled || readOnly) return;
|
|
39
|
+
const trimmed = draft.trim();
|
|
40
|
+
if (!trimmed) return;
|
|
41
|
+
if (validatorRegex && !validatorRegex.test(trimmed)) {
|
|
42
|
+
onInvalidTag?.(trimmed);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!allowDuplicates && tags.includes(trimmed)) return;
|
|
46
|
+
onTagsChange([...tags, trimmed]);
|
|
47
|
+
setDraft("");
|
|
48
|
+
}, [
|
|
49
|
+
draft,
|
|
50
|
+
disabled,
|
|
51
|
+
readOnly,
|
|
52
|
+
validatorRegex,
|
|
53
|
+
onInvalidTag,
|
|
54
|
+
allowDuplicates,
|
|
55
|
+
tags,
|
|
56
|
+
onTagsChange
|
|
57
|
+
]);
|
|
58
|
+
const removeAt = (index) => {
|
|
59
|
+
if (disabled || readOnly) return;
|
|
60
|
+
onTagsChange(tags.filter((_, i) => i !== index));
|
|
61
|
+
};
|
|
62
|
+
const handleKeyDown = (e) => {
|
|
63
|
+
onKeyDown?.(e);
|
|
64
|
+
if (e.defaultPrevented) return;
|
|
65
|
+
if (e.key === "Enter") {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
tryCommitDraft();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (e.key === "Backspace" && draft === "" && tags.length > 0) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
removeAt(tags.length - 1);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handleBlur = (e) => {
|
|
76
|
+
onBlur?.(e);
|
|
77
|
+
const next = e.relatedTarget;
|
|
78
|
+
if (next instanceof Node && rootRef.current?.contains(next)) return;
|
|
79
|
+
tryCommitDraft();
|
|
80
|
+
};
|
|
81
|
+
const controlClasses = cn("peer flex w-full flex-wrap items-center border border-input bg-background ring-offset-background transition-[box-shadow,border-color] duration-200 ease-in-out focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2", controlSizeClasses[effectiveSize], rounded ? "rounded-full" : "rounded-md", hasError && "border-destructive focus-within:ring-destructive", disabled && "pointer-events-none opacity-50", readOnly && "bg-muted", className);
|
|
82
|
+
const inputClasses = cn("min-w-[6rem] flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed read-only:cursor-default", inputTextSizeClasses[effectiveSize]);
|
|
83
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
84
|
+
ref: rootRef,
|
|
85
|
+
className: "group flex flex-1 flex-col space-y-2",
|
|
86
|
+
"data-disabled": disabled ? true : void 0,
|
|
87
|
+
children: [
|
|
88
|
+
label ? /* @__PURE__ */ jsxs("div", {
|
|
89
|
+
className: "flex items-center justify-between",
|
|
90
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
91
|
+
htmlFor: inputId,
|
|
92
|
+
className: labelClasses,
|
|
93
|
+
children: [label, required ? /* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: "text-destructive",
|
|
95
|
+
children: "*"
|
|
96
|
+
}) : null]
|
|
97
|
+
}), hintContent ? /* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: "text-sm text-muted-foreground",
|
|
99
|
+
children: hintContent
|
|
100
|
+
}) : null]
|
|
101
|
+
}) : null,
|
|
102
|
+
!label && hintContent ? /* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "text-sm text-muted-foreground",
|
|
104
|
+
children: hintContent
|
|
105
|
+
}) : null,
|
|
106
|
+
/* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: controlClasses,
|
|
108
|
+
children: [tags.map((tag, index) => {
|
|
109
|
+
const parsed = nameValueTags ? parseNameValueTag(tag) : null;
|
|
110
|
+
if (parsed) return /* @__PURE__ */ jsx(Tag, {
|
|
111
|
+
name: truncateDisplay(parsed.name, maxTagDisplayLength),
|
|
112
|
+
nameTooltip: parsed.name,
|
|
113
|
+
value: truncateDisplay(parsed.value, maxTagDisplayLength),
|
|
114
|
+
valueTooltip: parsed.value,
|
|
115
|
+
size: effectiveSize,
|
|
116
|
+
onDelete: disabled || readOnly ? void 0 : () => removeAt(index)
|
|
117
|
+
}, `${tag}-${index}`);
|
|
118
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
119
|
+
name: truncateDisplay(tag, maxTagDisplayLength),
|
|
120
|
+
nameTooltip: tag,
|
|
121
|
+
size: effectiveSize,
|
|
122
|
+
onDelete: disabled || readOnly ? void 0 : () => removeAt(index)
|
|
123
|
+
}, `${tag}-${index}`);
|
|
124
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
125
|
+
ref,
|
|
126
|
+
id: inputId,
|
|
127
|
+
type: "text",
|
|
128
|
+
className: inputClasses,
|
|
129
|
+
disabled,
|
|
130
|
+
readOnly,
|
|
131
|
+
placeholder,
|
|
132
|
+
value: draft,
|
|
133
|
+
onChange: (e) => setDraft(e.target.value),
|
|
134
|
+
onKeyDown: handleKeyDown,
|
|
135
|
+
onBlur: handleBlur,
|
|
136
|
+
"aria-invalid": hasError || void 0,
|
|
137
|
+
"aria-describedby": errorContent ? `${inputId}-error` : startHelperContent || endHelperContent ? `${inputId}-helper` : void 0,
|
|
138
|
+
...restInputProps
|
|
139
|
+
})]
|
|
140
|
+
}),
|
|
141
|
+
errorContent ? /* @__PURE__ */ jsx("div", {
|
|
142
|
+
id: `${inputId}-error`,
|
|
143
|
+
className: "text-sm text-destructive",
|
|
144
|
+
children: errorContent
|
|
145
|
+
}) : null,
|
|
146
|
+
startHelperContent && !errorContent ? /* @__PURE__ */ jsx("div", {
|
|
147
|
+
id: `${inputId}-helper`,
|
|
148
|
+
className: "text-sm text-muted-foreground",
|
|
149
|
+
children: startHelperContent
|
|
150
|
+
}) : null,
|
|
151
|
+
endHelperContent && !errorContent ? /* @__PURE__ */ jsx("div", {
|
|
152
|
+
id: `${inputId}-helper`,
|
|
153
|
+
className: "text-end text-sm text-muted-foreground",
|
|
154
|
+
children: endHelperContent
|
|
155
|
+
}) : null
|
|
156
|
+
]
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
TagInput.displayName = "TagInput";
|
|
160
|
+
//#endregion
|
|
161
|
+
export { TagInput };
|