@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,85 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { isPresetColor } from "../../utils/color.js";
|
|
3
|
+
import { buttonVariants } from "../../core/button.js";
|
|
4
|
+
import { IconTextActionCard } from "../icon-text-action-card/icon-text-action-card.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { CheckCheck, CircleAlert, CircleX, Info, TriangleAlert, X } from "lucide-react";
|
|
8
|
+
//#region src/components/alert/alert.tsx
|
|
9
|
+
var typeIconMap = {
|
|
10
|
+
error: /* @__PURE__ */ jsx(CircleX, { className: "h-4 w-4" }),
|
|
11
|
+
info: /* @__PURE__ */ jsx(Info, { className: "h-4 w-4" }),
|
|
12
|
+
warning: /* @__PURE__ */ jsx(TriangleAlert, { className: "h-4 w-4" }),
|
|
13
|
+
success: /* @__PURE__ */ jsx(CheckCheck, { className: "h-4 w-4" })
|
|
14
|
+
};
|
|
15
|
+
var typeColorMap = {
|
|
16
|
+
error: "error",
|
|
17
|
+
info: "info",
|
|
18
|
+
warning: "warning",
|
|
19
|
+
success: "success"
|
|
20
|
+
};
|
|
21
|
+
var SEMANTIC_COLOR_TO_TYPE = {
|
|
22
|
+
error: "error",
|
|
23
|
+
info: "info",
|
|
24
|
+
warning: "warning",
|
|
25
|
+
success: "success"
|
|
26
|
+
};
|
|
27
|
+
function defaultIconFromColor(color) {
|
|
28
|
+
if (!isPresetColor(color)) return void 0;
|
|
29
|
+
const t = SEMANTIC_COLOR_TO_TYPE[color];
|
|
30
|
+
return t != null ? typeIconMap[t] : void 0;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The close button tracks the alert `size` instead of `buttonVariants`' `h-9 w-9`,
|
|
34
|
+
* which would tower over an `sm` alert row.
|
|
35
|
+
*/
|
|
36
|
+
var dismissButtonSizeClasses = {
|
|
37
|
+
sm: "size-6 [&_svg]:size-3.5",
|
|
38
|
+
default: "size-7 [&_svg]:size-4",
|
|
39
|
+
lg: "size-8 [&_svg]:size-4"
|
|
40
|
+
};
|
|
41
|
+
var Alert = React$1.forwardRef(({ icon, title, description, children, type, color, iconAvatarVariant = "solid", size = "sm", variant = "gradient", hideIcon = false, action, actions, actionsPlacement, dismissible = false, onDismiss, dismissLabel = "Close alert", className }, ref) => {
|
|
42
|
+
const [dismissed, setDismissed] = React$1.useState(false);
|
|
43
|
+
const handleDismiss = React$1.useCallback(() => {
|
|
44
|
+
setDismissed(true);
|
|
45
|
+
onDismiss?.();
|
|
46
|
+
}, [onDismiss]);
|
|
47
|
+
const resolvedColor = color ?? (type != null ? typeColorMap[type] : void 0) ?? "primary";
|
|
48
|
+
const resolvedDescription = description != null && children != null ? /* @__PURE__ */ jsxs(Fragment$1, { children: [description, children] }) : description ?? children;
|
|
49
|
+
const resolvedIcon = hideIcon ? void 0 : icon ?? (type != null ? typeIconMap[type] : void 0) ?? defaultIconFromColor(resolvedColor) ?? /* @__PURE__ */ jsx(CircleAlert, { className: "h-4 w-4" });
|
|
50
|
+
const dismissButton = dismissible ? /* @__PURE__ */ jsx("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
"aria-label": dismissLabel,
|
|
53
|
+
onClick: handleDismiss,
|
|
54
|
+
className: cn(buttonVariants({
|
|
55
|
+
variant: "ghost",
|
|
56
|
+
size: "icon"
|
|
57
|
+
}), dismissButtonSizeClasses[size], "shrink-0 text-current opacity-70 hover:bg-current/10 hover:text-current hover:opacity-100"),
|
|
58
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
59
|
+
"aria-hidden": true,
|
|
60
|
+
strokeWidth: 2
|
|
61
|
+
})
|
|
62
|
+
}) : null;
|
|
63
|
+
const providedActions = actions ?? action;
|
|
64
|
+
const resolvedActions = dismissButton == null ? providedActions : providedActions == null ? dismissButton : /* @__PURE__ */ jsxs("span", {
|
|
65
|
+
className: "inline-flex items-center gap-1",
|
|
66
|
+
children: [providedActions, dismissButton]
|
|
67
|
+
});
|
|
68
|
+
if (dismissed) return null;
|
|
69
|
+
return /* @__PURE__ */ jsx(IconTextActionCard, {
|
|
70
|
+
ref,
|
|
71
|
+
title,
|
|
72
|
+
description: resolvedDescription,
|
|
73
|
+
icon: resolvedIcon,
|
|
74
|
+
color: resolvedColor,
|
|
75
|
+
iconAvatarVariant,
|
|
76
|
+
size,
|
|
77
|
+
variant,
|
|
78
|
+
actions: resolvedActions,
|
|
79
|
+
actionsPlacement,
|
|
80
|
+
className
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
Alert.displayName = "Alert";
|
|
84
|
+
//#endregion
|
|
85
|
+
export { Alert };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
//#region src/components/animated-containers/pop-collection-item.tsx
|
|
4
|
+
function PopCollectionItem({ index, children, layout = true, delayMultiplier = .1, transition }) {
|
|
5
|
+
const defaultTransition = {
|
|
6
|
+
duration: .2,
|
|
7
|
+
delay: index * delayMultiplier
|
|
8
|
+
};
|
|
9
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
10
|
+
layout,
|
|
11
|
+
initial: {
|
|
12
|
+
opacity: 0,
|
|
13
|
+
y: 8
|
|
14
|
+
},
|
|
15
|
+
animate: {
|
|
16
|
+
opacity: 1,
|
|
17
|
+
y: 0
|
|
18
|
+
},
|
|
19
|
+
exit: {
|
|
20
|
+
opacity: 0,
|
|
21
|
+
scale: .97
|
|
22
|
+
},
|
|
23
|
+
transition: transition ?? defaultTransition,
|
|
24
|
+
children
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { PopCollectionItem };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../core/popover.js";
|
|
4
|
+
import { Badge } from "../../core/badge.js";
|
|
5
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../../core/command.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Check, ChevronDown, X } from "lucide-react";
|
|
9
|
+
//#region src/components/async-multi-select/async-multi-select.tsx
|
|
10
|
+
var triggerSizeClasses = {
|
|
11
|
+
sm: "min-h-8 px-3 text-xs",
|
|
12
|
+
default: "min-h-10 px-3.5 py-2 text-base md:text-sm",
|
|
13
|
+
lg: "min-h-12 px-5 text-lg"
|
|
14
|
+
};
|
|
15
|
+
var chevronSizeClasses = {
|
|
16
|
+
sm: "size-3.5",
|
|
17
|
+
default: "size-4",
|
|
18
|
+
lg: "size-5"
|
|
19
|
+
};
|
|
20
|
+
function normalizeValue(value, multiple) {
|
|
21
|
+
if (value == null) return [];
|
|
22
|
+
if (Array.isArray(value)) return value;
|
|
23
|
+
return multiple ? [value] : [value];
|
|
24
|
+
}
|
|
25
|
+
function AsyncMultiSelect({ options, multiple = true, value, onValueChange, onSearchChange, hasMore = false, onLoadMore, isLoading = false, disabled = false, placeholder = "Select...", emptyText = "No results.", searchPlaceholder = "Search...", label, required, size = "default", className, clearable = false, maxDisplayedBadges = 3, portal = true, renderOption }) {
|
|
26
|
+
const [open, setOpen] = React$1.useState(false);
|
|
27
|
+
const [inputValue, setInputValue] = React$1.useState("");
|
|
28
|
+
const listRef = React$1.useRef(null);
|
|
29
|
+
const sentinelRef = React$1.useRef(null);
|
|
30
|
+
const selected = normalizeValue(value, multiple);
|
|
31
|
+
const selectedOptions = React$1.useMemo(() => {
|
|
32
|
+
const map = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const opt of options) map.set(opt.value, opt);
|
|
34
|
+
return selected.map((v) => map.get(v) ?? {
|
|
35
|
+
value: v,
|
|
36
|
+
label: v
|
|
37
|
+
});
|
|
38
|
+
}, [options, selected]);
|
|
39
|
+
React$1.useEffect(() => {
|
|
40
|
+
const sentinel = sentinelRef.current;
|
|
41
|
+
if (!open || !hasMore || !onLoadMore || !sentinel) return;
|
|
42
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
43
|
+
if (entry.isIntersecting && !isLoading) onLoadMore();
|
|
44
|
+
}, {
|
|
45
|
+
root: listRef.current,
|
|
46
|
+
threshold: .1
|
|
47
|
+
});
|
|
48
|
+
observer.observe(sentinel);
|
|
49
|
+
return () => observer.disconnect();
|
|
50
|
+
}, [
|
|
51
|
+
hasMore,
|
|
52
|
+
onLoadMore,
|
|
53
|
+
isLoading,
|
|
54
|
+
open
|
|
55
|
+
]);
|
|
56
|
+
const handleSelect = (optionValue) => {
|
|
57
|
+
if (multiple) {
|
|
58
|
+
const next = selected.includes(optionValue) ? selected.filter((v) => v !== optionValue) : [...selected, optionValue];
|
|
59
|
+
onValueChange?.(next.length > 0 ? next : void 0);
|
|
60
|
+
} else {
|
|
61
|
+
const next = selected[0] === optionValue && clearable ? void 0 : optionValue;
|
|
62
|
+
onValueChange?.(next);
|
|
63
|
+
setOpen(false);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const handleRemove = (optionValue, e) => {
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
const next = selected.filter((v) => v !== optionValue);
|
|
69
|
+
onValueChange?.(multiple ? next.length > 0 ? next : void 0 : void 0);
|
|
70
|
+
};
|
|
71
|
+
const handleSearchChange = React$1.useCallback((q) => {
|
|
72
|
+
setInputValue(q);
|
|
73
|
+
onSearchChange?.(q);
|
|
74
|
+
}, [onSearchChange]);
|
|
75
|
+
const renderTriggerContent = () => {
|
|
76
|
+
if (multiple && selected.length > 0) {
|
|
77
|
+
const visible = selectedOptions.slice(0, maxDisplayedBadges);
|
|
78
|
+
const remaining = selected.length - maxDisplayedBadges;
|
|
79
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
80
|
+
className: "flex flex-wrap items-center gap-1",
|
|
81
|
+
children: [visible.map((opt) => /* @__PURE__ */ jsxs(Badge, {
|
|
82
|
+
variant: "soft",
|
|
83
|
+
color: "primary",
|
|
84
|
+
className: "gap-1 pr-1",
|
|
85
|
+
children: [opt.label, /* @__PURE__ */ jsx("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "ml-0.5 rounded-sm opacity-70 hover:opacity-100 focus:outline-none",
|
|
88
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
89
|
+
onClick: (e) => handleRemove(opt.value, e),
|
|
90
|
+
onKeyDown: (e) => {
|
|
91
|
+
if (e.key === "Enter" || e.key === " ") handleRemove(opt.value, e);
|
|
92
|
+
},
|
|
93
|
+
"aria-label": `Remove ${opt.label}`,
|
|
94
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3" })
|
|
95
|
+
})]
|
|
96
|
+
}, opt.value)), remaining > 0 && /* @__PURE__ */ jsxs("span", {
|
|
97
|
+
className: "text-xs text-muted-foreground",
|
|
98
|
+
children: [
|
|
99
|
+
"+",
|
|
100
|
+
remaining,
|
|
101
|
+
" more"
|
|
102
|
+
]
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!multiple && selected.length === 1) return /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "truncate line-clamp-1",
|
|
108
|
+
children: selectedOptions[0]?.label ?? selected[0]
|
|
109
|
+
});
|
|
110
|
+
return /* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "text-muted-foreground",
|
|
112
|
+
children: placeholder
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
className: "group space-y-2 flex-1",
|
|
117
|
+
"data-disabled": disabled || void 0,
|
|
118
|
+
children: [label != null && /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: "flex items-center justify-between",
|
|
120
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
121
|
+
className: "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",
|
|
122
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
123
|
+
className: "text-destructive",
|
|
124
|
+
children: "*"
|
|
125
|
+
})]
|
|
126
|
+
})
|
|
127
|
+
}), /* @__PURE__ */ jsxs(Popover, {
|
|
128
|
+
open,
|
|
129
|
+
onOpenChange: setOpen,
|
|
130
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
131
|
+
asChild: true,
|
|
132
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
133
|
+
type: "button",
|
|
134
|
+
role: "combobox",
|
|
135
|
+
"aria-expanded": open,
|
|
136
|
+
disabled,
|
|
137
|
+
className: cn("flex w-full items-center justify-between rounded-md border border-input bg-transparent ring-offset-background transition-[box-shadow,border-color] duration-200 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", !multiple && "whitespace-nowrap [&>span]:line-clamp-1", triggerSizeClasses[size], className),
|
|
138
|
+
children: [renderTriggerContent(), /* @__PURE__ */ jsx(ChevronDown, { className: cn("ml-2 shrink-0 opacity-50", chevronSizeClasses[size]) })]
|
|
139
|
+
})
|
|
140
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
141
|
+
portal,
|
|
142
|
+
className: "w-[var(--radix-popover-trigger-width)] min-w-[8rem] !px-1.5 !py-2 will-change-[opacity,transform] select-none",
|
|
143
|
+
align: "start",
|
|
144
|
+
children: /* @__PURE__ */ jsxs(Command, {
|
|
145
|
+
shouldFilter: false,
|
|
146
|
+
children: [/* @__PURE__ */ jsx(CommandInput, {
|
|
147
|
+
placeholder: searchPlaceholder,
|
|
148
|
+
value: inputValue,
|
|
149
|
+
onValueChange: handleSearchChange
|
|
150
|
+
}), /* @__PURE__ */ jsxs(CommandList, {
|
|
151
|
+
ref: listRef,
|
|
152
|
+
className: "overscroll-contain",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: isLoading ? /* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: "flex items-center justify-center py-6",
|
|
156
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
157
|
+
}) : emptyText }),
|
|
158
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
159
|
+
className: "p-0",
|
|
160
|
+
children: options.map((opt) => {
|
|
161
|
+
const isSelected = selected.includes(opt.value);
|
|
162
|
+
const desc = opt.description?.trim();
|
|
163
|
+
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
164
|
+
value: opt.value,
|
|
165
|
+
onSelect: () => handleSelect(opt.value),
|
|
166
|
+
className: "relative w-full py-2 pl-2.5 pr-9",
|
|
167
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
168
|
+
className: "absolute right-2.5 flex h-3.5 w-3.5 items-center justify-center",
|
|
169
|
+
children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4", isSelected ? "opacity-100" : "opacity-0") })
|
|
170
|
+
}), renderOption ? renderOption(opt) : desc ? /* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: "flex min-w-0 flex-col gap-0.5",
|
|
172
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
173
|
+
className: "font-medium leading-relaxed",
|
|
174
|
+
children: opt.label
|
|
175
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
176
|
+
className: "truncate text-xs font-normal text-muted-foreground",
|
|
177
|
+
children: desc
|
|
178
|
+
})]
|
|
179
|
+
}) : opt.label]
|
|
180
|
+
}, opt.value);
|
|
181
|
+
})
|
|
182
|
+
}),
|
|
183
|
+
hasMore && /* @__PURE__ */ jsx("div", {
|
|
184
|
+
ref: sentinelRef,
|
|
185
|
+
className: "h-px"
|
|
186
|
+
}),
|
|
187
|
+
isLoading && options.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
188
|
+
className: "flex items-center justify-center py-3",
|
|
189
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent" })
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
})]
|
|
193
|
+
})
|
|
194
|
+
})]
|
|
195
|
+
})]
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { AsyncMultiSelect };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { resolveColor } from "../../utils/color.js";
|
|
3
|
+
import { Avatar as Avatar$1, AvatarBadge, AvatarFallback, AvatarImage } from "../../core/avatar.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { User } from "lucide-react";
|
|
6
|
+
//#region src/components/avatar/avatar.tsx
|
|
7
|
+
var sizeClasses = {
|
|
8
|
+
sm: "h-5 w-5 text-[10px]",
|
|
9
|
+
default: "h-7 w-7 text-xs",
|
|
10
|
+
lg: "h-10 w-10 text-sm"
|
|
11
|
+
};
|
|
12
|
+
function Avatar({ name, imageUrl, size = "default", className, badgeColor, badgeIcon }) {
|
|
13
|
+
const displayInitial = name ? name.charAt(0).toUpperCase() : null;
|
|
14
|
+
const showIconBadge = badgeIcon != null && badgeIcon !== false;
|
|
15
|
+
const colorResolved = !showIconBadge && badgeColor != null ? resolveColor(badgeColor, "bg") : void 0;
|
|
16
|
+
const hasBadge = showIconBadge || Boolean(colorResolved);
|
|
17
|
+
const avatar = /* @__PURE__ */ jsxs(Avatar$1, {
|
|
18
|
+
className: cn(sizeClasses[size], className),
|
|
19
|
+
children: [imageUrl && /* @__PURE__ */ jsx(AvatarImage, {
|
|
20
|
+
src: imageUrl,
|
|
21
|
+
alt: name ?? "User avatar"
|
|
22
|
+
}), /* @__PURE__ */ jsx(AvatarFallback, {
|
|
23
|
+
className: cn("bg-primary text-primary-foreground font-medium", sizeClasses[size], className),
|
|
24
|
+
children: displayInitial ?? /* @__PURE__ */ jsx(User, { className: "h-3/5 w-3/5" })
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
27
|
+
if (!hasBadge) return avatar;
|
|
28
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
29
|
+
className: "relative inline-flex shrink-0",
|
|
30
|
+
children: [avatar, showIconBadge ? /* @__PURE__ */ jsx(AvatarBadge, {
|
|
31
|
+
variant: "icon",
|
|
32
|
+
children: badgeIcon
|
|
33
|
+
}) : colorResolved ? /* @__PURE__ */ jsx(AvatarBadge, {
|
|
34
|
+
variant: "dot",
|
|
35
|
+
className: cn(colorResolved.className),
|
|
36
|
+
style: colorResolved.style
|
|
37
|
+
}) : null]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Avatar as default };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { Button as Button$1, buttonVariants } from "../../core/button.js";
|
|
3
|
+
import Tooltip from "../tooltip/tooltip.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { LoaderCircle } from "lucide-react";
|
|
7
|
+
import { motion } from "framer-motion";
|
|
8
|
+
//#region src/components/button/button.tsx
|
|
9
|
+
var presetButtonColors = {
|
|
10
|
+
primary: {
|
|
11
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
12
|
+
outline: "border-primary/30 text-primary hover:bg-primary/5 hover:border-primary",
|
|
13
|
+
ghost: "text-primary hover:bg-primary/10",
|
|
14
|
+
link: "text-primary"
|
|
15
|
+
},
|
|
16
|
+
secondary: {
|
|
17
|
+
default: "bg-secondary text-secondary-foreground hover:bg-secondary/90",
|
|
18
|
+
outline: "border-secondary/30 text-secondary hover:bg-secondary/5 hover:border-secondary",
|
|
19
|
+
ghost: "text-secondary hover:bg-secondary/10",
|
|
20
|
+
link: "text-secondary"
|
|
21
|
+
},
|
|
22
|
+
error: {
|
|
23
|
+
default: "bg-error text-error-foreground hover:bg-error/90",
|
|
24
|
+
outline: "border-error/30 text-error hover:bg-error/5 hover:border-error",
|
|
25
|
+
ghost: "text-error hover:bg-error/10",
|
|
26
|
+
link: "text-error"
|
|
27
|
+
},
|
|
28
|
+
info: {
|
|
29
|
+
default: "bg-info text-info-foreground hover:bg-info/90",
|
|
30
|
+
outline: "border-info/30 text-info hover:bg-info/5 hover:border-info",
|
|
31
|
+
ghost: "text-info hover:bg-info/10",
|
|
32
|
+
link: "text-info"
|
|
33
|
+
},
|
|
34
|
+
success: {
|
|
35
|
+
default: "bg-success text-success-foreground hover:bg-success/90",
|
|
36
|
+
outline: "border-success/30 text-success hover:bg-success/5 hover:border-success",
|
|
37
|
+
ghost: "text-success hover:bg-success/10",
|
|
38
|
+
link: "text-success"
|
|
39
|
+
},
|
|
40
|
+
warning: {
|
|
41
|
+
default: "bg-warning text-warning-foreground hover:bg-warning/90",
|
|
42
|
+
outline: "border-warning/30 text-warning hover:bg-warning/5 hover:border-warning",
|
|
43
|
+
ghost: "text-warning hover:bg-warning/10",
|
|
44
|
+
link: "text-warning"
|
|
45
|
+
},
|
|
46
|
+
disabled: {
|
|
47
|
+
default: "bg-disabled text-disabled-foreground",
|
|
48
|
+
outline: "border-disabled/30 text-disabled",
|
|
49
|
+
ghost: "text-disabled",
|
|
50
|
+
link: "text-disabled"
|
|
51
|
+
},
|
|
52
|
+
gray: {
|
|
53
|
+
default: "bg-gray text-gray-foreground hover:bg-gray/90",
|
|
54
|
+
outline: "border-input text-gray hover:bg-gray/5 hover:border-gray",
|
|
55
|
+
ghost: "text-gray hover:bg-gray/10",
|
|
56
|
+
link: "text-gray"
|
|
57
|
+
},
|
|
58
|
+
mist: {
|
|
59
|
+
default: "bg-mist text-mist-foreground hover:bg-mist/90",
|
|
60
|
+
outline: "border-mist-border text-mist-foreground hover:bg-mist hover:border-mist-border",
|
|
61
|
+
ghost: "text-mist-foreground hover:bg-mist",
|
|
62
|
+
link: "text-mist-foreground"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var primaryHoverRingClasses = "hover:ring-primary/90 focus-visible:ring-primary/90";
|
|
66
|
+
var presetRingColors = {
|
|
67
|
+
primary: "hover:ring-primary/90 focus-visible:ring-primary/90",
|
|
68
|
+
secondary: "hover:ring-secondary/90 focus-visible:ring-secondary/90",
|
|
69
|
+
error: "hover:ring-error/90 focus-visible:ring-error/90",
|
|
70
|
+
info: "hover:ring-info/90 focus-visible:ring-info/90",
|
|
71
|
+
success: "hover:ring-success/90 focus-visible:ring-success/90",
|
|
72
|
+
warning: "hover:ring-warning/90 focus-visible:ring-warning/90",
|
|
73
|
+
disabled: "hover:ring-disabled/90 focus-visible:ring-disabled/90",
|
|
74
|
+
gray: "hover:ring-gray/90 focus-visible:ring-gray/90",
|
|
75
|
+
mist: "hover:ring-mist-border focus-visible:ring-mist-border"
|
|
76
|
+
};
|
|
77
|
+
/** `hideRingOnHover` still shows keyboard focus; only the hover ring is suppressed. */
|
|
78
|
+
var presetFocusVisibleRingColors = {
|
|
79
|
+
primary: "focus-visible:ring-primary/90",
|
|
80
|
+
secondary: "focus-visible:ring-secondary/90",
|
|
81
|
+
error: "focus-visible:ring-error/90",
|
|
82
|
+
info: "focus-visible:ring-info/90",
|
|
83
|
+
success: "focus-visible:ring-success/90",
|
|
84
|
+
warning: "focus-visible:ring-warning/90",
|
|
85
|
+
disabled: "focus-visible:ring-disabled/90",
|
|
86
|
+
gray: "focus-visible:ring-gray/90",
|
|
87
|
+
mist: "focus-visible:ring-mist-border"
|
|
88
|
+
};
|
|
89
|
+
var iconOnlyLabelClasses = {
|
|
90
|
+
sm: "max-sm:sr-only",
|
|
91
|
+
md: "max-md:sr-only"
|
|
92
|
+
};
|
|
93
|
+
/** Square with only a start icon; tighter padding when a trailing icon (e.g. a chevron) stays. */
|
|
94
|
+
var iconOnlyButtonClasses = {
|
|
95
|
+
sm: {
|
|
96
|
+
square: "max-sm:w-9 max-sm:gap-0 max-sm:px-0",
|
|
97
|
+
squareLarge: "max-sm:w-10 max-sm:gap-0 max-sm:px-0",
|
|
98
|
+
withEndIcon: "max-sm:px-2"
|
|
99
|
+
},
|
|
100
|
+
md: {
|
|
101
|
+
square: "max-md:w-9 max-md:gap-0 max-md:px-0",
|
|
102
|
+
squareLarge: "max-md:w-10 max-md:gap-0 max-md:px-0",
|
|
103
|
+
withEndIcon: "max-md:px-2"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function getIconOnlyButtonClasses(breakpoint, size, hasEndIcon) {
|
|
107
|
+
if (!breakpoint || size === "icon") return void 0;
|
|
108
|
+
const classes = iconOnlyButtonClasses[breakpoint];
|
|
109
|
+
if (hasEndIcon) return classes.withEndIcon;
|
|
110
|
+
if (size === "lg") return classes.squareLarge;
|
|
111
|
+
return classes.square;
|
|
112
|
+
}
|
|
113
|
+
function ProgressBarOverlay() {
|
|
114
|
+
const [progress, setProgress] = React$1.useState(10);
|
|
115
|
+
React$1.useEffect(() => {
|
|
116
|
+
if (progress >= 90) return;
|
|
117
|
+
const timeout = setTimeout(() => {
|
|
118
|
+
const increment = Math.random() * 15 + 5;
|
|
119
|
+
setProgress((prev) => Math.min(prev + increment, 90));
|
|
120
|
+
}, Math.random() * 800 + 200);
|
|
121
|
+
return () => clearTimeout(timeout);
|
|
122
|
+
}, [progress]);
|
|
123
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
124
|
+
className: "absolute inset-y-0 left-0 bg-black/20 pointer-events-none rounded-[inherit]",
|
|
125
|
+
initial: { width: "10%" },
|
|
126
|
+
animate: { width: `${progress}%` },
|
|
127
|
+
transition: {
|
|
128
|
+
duration: .4,
|
|
129
|
+
ease: "easeOut"
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
var iconAnimateClasses = "transition-transform duration-200";
|
|
134
|
+
var Button = React$1.forwardRef(({ children, color = "primary", startIcon, endIcon, fullWidth = true, loading = false, loadingIndicator = "spinner", animateStartIconOnHover = false, animateEndIconOnHover = false, hideRingOnHover = false, usePrimaryColorOnHover = false, tooltip, iconOnlyBelow, disabled, className, variant = "default", size, ...props }, ref) => {
|
|
135
|
+
const needsGroup = animateStartIconOnHover || animateEndIconOnHover;
|
|
136
|
+
const isProgressBar = loading && loadingIndicator === "progress-bar";
|
|
137
|
+
const isSpinner = loading && loadingIndicator === "spinner";
|
|
138
|
+
const resolvedVariant = variant ?? "default";
|
|
139
|
+
const colorClasses = presetButtonColors[color]?.[resolvedVariant] ?? "";
|
|
140
|
+
const ringClasses = presetRingColors[color] ?? "";
|
|
141
|
+
const primaryHoverSurface = usePrimaryColorOnHover && (resolvedVariant === "outline" || resolvedVariant === "ghost");
|
|
142
|
+
const primaryHoverLink = usePrimaryColorOnHover && resolvedVariant === "link";
|
|
143
|
+
const label = iconOnlyBelow && children != null ? /* @__PURE__ */ jsx("span", {
|
|
144
|
+
className: iconOnlyLabelClasses[iconOnlyBelow],
|
|
145
|
+
children
|
|
146
|
+
}) : children;
|
|
147
|
+
const wrapIcon = (icon, direction) => {
|
|
148
|
+
if (!icon) return null;
|
|
149
|
+
if (!(direction === "start" ? animateStartIconOnHover : animateEndIconOnHover)) return icon;
|
|
150
|
+
return /* @__PURE__ */ jsx("span", {
|
|
151
|
+
className: cn(iconAnimateClasses, direction === "start" ? "group-hover:-translate-x-0.5" : "group-hover:translate-x-0.5"),
|
|
152
|
+
children: icon
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const button = /* @__PURE__ */ jsxs(Button$1, {
|
|
156
|
+
ref,
|
|
157
|
+
variant,
|
|
158
|
+
size,
|
|
159
|
+
disabled: disabled || loading,
|
|
160
|
+
className: cn(colorClasses, primaryHoverSurface && "hover:bg-primary/10", primaryHoverLink && "hover:text-primary", fullWidth && size !== "icon" && "w-full", needsGroup && "group", isProgressBar && "relative overflow-hidden", !hideRingOnHover && variant !== "link" && [
|
|
161
|
+
"ring-offset-background transition-all duration-300",
|
|
162
|
+
"hover:ring-2 hover:ring-offset-2 focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
163
|
+
primaryHoverSurface ? primaryHoverRingClasses : ringClasses
|
|
164
|
+
], hideRingOnHover && variant !== "link" && [
|
|
165
|
+
"ring-offset-background transition-all duration-300",
|
|
166
|
+
"hover:ring-0 focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
167
|
+
primaryHoverSurface ? "focus-visible:ring-primary/90" : presetFocusVisibleRingColors[color]
|
|
168
|
+
], variant === "link" && "hover:ring-0 focus-visible:underline", "shadow-none", getIconOnlyButtonClasses(iconOnlyBelow, size, Boolean(endIcon)), className),
|
|
169
|
+
...props,
|
|
170
|
+
children: [isProgressBar && /* @__PURE__ */ jsx(ProgressBarOverlay, {}), isProgressBar ? /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsxs("span", {
|
|
171
|
+
className: "relative z-10 inline-flex items-center gap-2",
|
|
172
|
+
children: [
|
|
173
|
+
wrapIcon(startIcon, "start"),
|
|
174
|
+
label,
|
|
175
|
+
wrapIcon(endIcon, "end")
|
|
176
|
+
]
|
|
177
|
+
}) }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
178
|
+
isSpinner ? /* @__PURE__ */ jsx(LoaderCircle, { className: "animate-spin" }) : wrapIcon(startIcon, "start"),
|
|
179
|
+
label,
|
|
180
|
+
!isSpinner && wrapIcon(endIcon, "end")
|
|
181
|
+
] })]
|
|
182
|
+
});
|
|
183
|
+
if (!tooltip) return button;
|
|
184
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
185
|
+
content: tooltip,
|
|
186
|
+
children: button
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
Button.displayName = "Button";
|
|
190
|
+
//#endregion
|
|
191
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { Button } from "../../core/button/button.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ZapIcon } from "lucide-react";
|
|
7
|
+
import { useAnimate } from "motion/react";
|
|
8
|
+
//#region src/components/button/flash-button.tsx
|
|
9
|
+
/** Resting bg + text; hover transitions to bg-background (invert). */
|
|
10
|
+
var flashButtonBgClasses = {
|
|
11
|
+
primary: "bg-primary hover:bg-background text-primary-foreground",
|
|
12
|
+
secondary: "bg-secondary hover:bg-background text-secondary-foreground",
|
|
13
|
+
error: "bg-error hover:bg-background text-error-foreground",
|
|
14
|
+
info: "bg-info hover:bg-background text-info-foreground",
|
|
15
|
+
success: "bg-success hover:bg-background text-success-foreground",
|
|
16
|
+
warning: "bg-warning hover:bg-background text-warning-foreground",
|
|
17
|
+
disabled: "bg-disabled hover:bg-background text-disabled-foreground",
|
|
18
|
+
gray: "bg-gray hover:bg-background text-gray-foreground",
|
|
19
|
+
mist: "bg-mist hover:bg-background text-mist-foreground"
|
|
20
|
+
};
|
|
21
|
+
/** Flash overlay colour (the colour that blinks back in on hover). */
|
|
22
|
+
var flashOverlayClasses = {
|
|
23
|
+
primary: "bg-primary",
|
|
24
|
+
secondary: "bg-secondary",
|
|
25
|
+
error: "bg-error",
|
|
26
|
+
info: "bg-info",
|
|
27
|
+
success: "bg-success",
|
|
28
|
+
warning: "bg-warning",
|
|
29
|
+
disabled: "bg-disabled",
|
|
30
|
+
gray: "bg-gray",
|
|
31
|
+
mist: "bg-mist"
|
|
32
|
+
};
|
|
33
|
+
/** Dark-mode hover border per colour. */
|
|
34
|
+
var flashButtonDarkBorderClasses = {
|
|
35
|
+
primary: "dark:hover:border-primary/30",
|
|
36
|
+
secondary: "dark:hover:border-secondary/30",
|
|
37
|
+
error: "dark:hover:border-error/30",
|
|
38
|
+
info: "dark:hover:border-info/30",
|
|
39
|
+
success: "dark:hover:border-success/30",
|
|
40
|
+
warning: "dark:hover:border-warning/30",
|
|
41
|
+
disabled: "dark:hover:border-disabled/30",
|
|
42
|
+
gray: "dark:hover:border-gray/30",
|
|
43
|
+
mist: "dark:hover:border-mist-border/30"
|
|
44
|
+
};
|
|
45
|
+
function FlashButton({ label, icon, iconPosition = "end", hideIcon = false, size, color = "primary", className, onMouseEnter, onMouseLeave, ...props }) {
|
|
46
|
+
const [scope, animate] = useAnimate();
|
|
47
|
+
const isHovering = React$1.useRef(false);
|
|
48
|
+
const flashLoop = React$1.useCallback(async () => {
|
|
49
|
+
while (isHovering.current && scope.current) {
|
|
50
|
+
const peakOpacity = .5 + Math.random() * .5;
|
|
51
|
+
try {
|
|
52
|
+
await animate(scope.current, { opacity: [
|
|
53
|
+
0,
|
|
54
|
+
peakOpacity,
|
|
55
|
+
0
|
|
56
|
+
] }, {
|
|
57
|
+
duration: .08 + Math.random() * .14,
|
|
58
|
+
ease: "easeOut"
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if (!isHovering.current) break;
|
|
64
|
+
const pause = 60 + Math.random() * 250;
|
|
65
|
+
await new Promise((r) => setTimeout(r, pause));
|
|
66
|
+
}
|
|
67
|
+
}, [animate, scope]);
|
|
68
|
+
const handleMouseEnter = React$1.useCallback((e) => {
|
|
69
|
+
isHovering.current = true;
|
|
70
|
+
flashLoop();
|
|
71
|
+
onMouseEnter?.(e);
|
|
72
|
+
}, [flashLoop, onMouseEnter]);
|
|
73
|
+
const handleMouseLeave = React$1.useCallback((e) => {
|
|
74
|
+
isHovering.current = false;
|
|
75
|
+
if (scope.current) animate(scope.current, { opacity: 0 }, { duration: .05 });
|
|
76
|
+
onMouseLeave?.(e);
|
|
77
|
+
}, [
|
|
78
|
+
animate,
|
|
79
|
+
scope,
|
|
80
|
+
onMouseLeave
|
|
81
|
+
]);
|
|
82
|
+
const iconSize = size === "lg" ? "size-4" : size === "sm" ? "size-2.5" : "size-3";
|
|
83
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
84
|
+
size,
|
|
85
|
+
className: cn(flashButtonBgClasses[color], "group relative cursor-pointer gap-1.5 overflow-hidden rounded-full transition-all duration-500 hover:shadow-md dark:border dark:border-transparent", flashButtonDarkBorderClasses[color], className),
|
|
86
|
+
onMouseEnter: handleMouseEnter,
|
|
87
|
+
onMouseLeave: handleMouseLeave,
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("span", {
|
|
91
|
+
ref: scope,
|
|
92
|
+
className: cn("pointer-events-none absolute inset-0 z-0 rounded-[inherit] opacity-0", flashOverlayClasses[color])
|
|
93
|
+
}),
|
|
94
|
+
!hideIcon && iconPosition === "start" && /* @__PURE__ */ jsx("span", {
|
|
95
|
+
className: "relative z-[1]",
|
|
96
|
+
children: icon ?? /* @__PURE__ */ jsx(ZapIcon, { className: cn(iconSize, "stroke-2 transition-all duration-500 group-hover:scale-110 group-hover:text-foreground") })
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: "relative z-[1] transition-colors duration-500 group-hover:text-foreground",
|
|
100
|
+
children: label
|
|
101
|
+
}),
|
|
102
|
+
!hideIcon && iconPosition === "end" && /* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "relative z-[1]",
|
|
104
|
+
children: icon ?? /* @__PURE__ */ jsx(ZapIcon, { className: cn(iconSize, "stroke-2 transition-all duration-500 group-hover:scale-110 group-hover:text-foreground") })
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { FlashButton };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CraftButton, CraftButtonIcon, CraftButtonLabel } from "../../core/button/craft-button.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { ArrowUpRightIcon } from "lucide-react";
|
|
5
|
+
//#region src/components/button/invert-button.tsx
|
|
6
|
+
function InvertButton({ label, icon, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(CraftButton, {
|
|
8
|
+
...props,
|
|
9
|
+
children: [/* @__PURE__ */ jsx(CraftButtonLabel, { children: label }), /* @__PURE__ */ jsx(CraftButtonIcon, { children: icon ?? /* @__PURE__ */ jsx(ArrowUpRightIcon, { className: "size-3 stroke-2 transition-transform duration-500 group-hover:rotate-45" }) })]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { InvertButton };
|