@espressif/dashboard-ui-components 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/dist/_vendor/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/_vendor/@radix-ui/react-checkbox/dist/index.js +185 -0
- package/dist/_vendor/@radix-ui/react-compose-refs/dist/index.js +28 -0
- package/dist/_vendor/@radix-ui/react-context/dist/index.js +68 -0
- package/dist/_vendor/@radix-ui/react-presence/dist/index.js +127 -0
- package/dist/_vendor/@radix-ui/react-primitive/dist/index.js +42 -0
- package/dist/_vendor/@radix-ui/react-use-controllable-state/dist/index.js +55 -0
- package/dist/_vendor/@radix-ui/react-use-layout-effect/dist/index.js +5 -0
- package/dist/_vendor/@radix-ui/react-use-previous/dist/index.js +17 -0
- package/dist/_vendor/@radix-ui/react-use-size/dist/index.js +39 -0
- package/dist/_vendor/lottie-react/build/index.es.js +537 -0
- package/dist/_vendor/lottie-web/build/player/lottie.js +14149 -0
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/assets/illustrations/bulb-cloud-drawing.js +4 -0
- package/dist/assets/illustrations/rm-dashboard-update.js +4 -0
- package/dist/assets/illustrations/rm-data-download.js +4 -0
- package/dist/assets/logos/espressif/espressif-no-text.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text-dm.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text.js +4 -0
- package/dist/assets/logos/insights/insights-no-text.js +4 -0
- package/dist/assets/logos/insights/insights-with-text-dm.js +4 -0
- package/dist/assets/logos/insights/insights-with-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-no-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text-dm.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-no-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-no-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text-dm.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-no-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-no-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text.js +4 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.constants.js +18 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.js +24 -0
- package/dist/common/animated-rainmaker-logo/rainmaker-c-logo.js +50 -0
- package/dist/common/animated-rainmaker-logo/use-animated-rainmaker-logo-animation.js +85 -0
- package/dist/common/app-logo/app-logo.js +59 -0
- package/dist/common/app-logo/logo-config.js +297 -0
- package/dist/common/copyright-card/copyright-card.js +39 -0
- package/dist/common/footer-card/footer-card.js +22 -0
- package/dist/common/index.js +8 -8
- package/dist/common/my-account-menu/my-account-menu.js +32 -0
- package/dist/common/page-loader/page-loader.js +21 -0
- package/dist/common/profile-card/profile-card.js +26 -0
- package/dist/components/accordion/accordion.js +52 -0
- package/dist/components/advanced-search-box/advanced-search-box.js +106 -0
- package/dist/components/alert/alert.js +85 -0
- package/dist/components/animated-containers/pop-collection-item.js +28 -0
- package/dist/components/async-multi-select/async-multi-select.js +199 -0
- package/dist/components/avatar/avatar.js +41 -0
- package/dist/components/button/button.js +191 -0
- package/dist/components/button/flash-button.js +110 -0
- package/dist/components/button/invert-button.js +13 -0
- package/dist/components/calendar/calendar.js +105 -0
- package/dist/components/cards/animated-card/animated-card-animations.js +57 -0
- package/dist/components/cards/animated-card/animated-card.js +42 -0
- package/dist/components/cards/basic-details-card.js +46 -0
- package/dist/components/cards/collapsible-card.js +48 -0
- package/dist/components/cards/no-data-card/no-data-card.js +30 -0
- package/dist/components/cards/section-card.js +265 -0
- package/dist/components/cards/simple-card.js +24 -0
- package/dist/components/carousel/carousel.js +158 -0
- package/dist/components/chart/area-chart.js +135 -0
- package/dist/components/chart/bar-chart.js +151 -0
- package/dist/components/chart/chart-colors.js +85 -0
- package/dist/components/chart/chart-series-data.js +53 -0
- package/dist/components/chart/chart.js +147 -0
- package/dist/components/chart/chart.types.js +7 -0
- package/dist/components/chart/composed-chart.js +182 -0
- package/dist/components/chart/donut-chart.js +177 -0
- package/dist/components/chart/line-chart.js +137 -0
- package/dist/components/chart/treemap-chart.js +294 -0
- package/dist/components/circular-progress/circular-progress.js +125 -0
- package/dist/components/code-editor/code-editor.js +235 -0
- package/dist/components/code-editor/code-editor.utils.js +122 -0
- package/dist/components/code-editor/use-code-editor-keys.js +79 -0
- package/dist/components/code-editor/use-highlighted-html.js +102 -0
- package/dist/components/confirmation-dialog/confirmation-dialog.js +72 -0
- package/dist/components/content-container/content-container.js +20 -0
- package/dist/components/copiable-text/copiable-text.js +46 -0
- package/dist/components/data-table/data-table.js +186 -0
- package/dist/components/data-table/responsive-columns.js +65 -0
- package/dist/components/data-table/row-actions.js +27 -0
- package/dist/components/data-table/sticky-columns.js +71 -0
- package/dist/components/data-table/table-body.js +57 -0
- package/dist/components/data-table/table-header.js +21 -0
- package/dist/components/date-picker/date-picker.js +95 -0
- package/dist/components/date-range-picker/date-range-picker.js +301 -0
- package/dist/components/date-range-picker/presets.js +174 -0
- package/dist/components/date-time-picker/date-time-picker.js +144 -0
- package/dist/components/date-time-picker/date-time-picker.utils.js +32 -0
- package/dist/components/device-icon/device-icon.config.js +194 -0
- package/dist/components/device-icon/device-icon.js +17 -0
- package/dist/components/device-icon/icons/air-conditioner.js +22 -0
- package/dist/components/device-icon/icons/blind.js +24 -0
- package/dist/components/device-icon/icons/dimmer.js +14 -0
- package/dist/components/device-icon/icons/extension-board.js +42 -0
- package/dist/components/device-icon/icons/fan.js +14 -0
- package/dist/components/device-icon/icons/knob.js +14 -0
- package/dist/components/device-icon/icons/led-strip.js +22 -0
- package/dist/components/device-icon/icons/light.js +14 -0
- package/dist/components/device-icon/icons/refrigerator.js +18 -0
- package/dist/components/device-icon/icons/retro-switch.js +18 -0
- package/dist/components/device-icon/icons/router.js +20 -0
- package/dist/components/device-icon/icons/sensor.js +20 -0
- package/dist/components/device-icon/icons/socket.js +19 -0
- package/dist/components/device-icon/icons/switch.js +19 -0
- package/dist/components/device-icon/icons/thermostat.js +21 -0
- package/dist/components/device-icon/icons/washing-machine.js +22 -0
- package/dist/components/device-icon/match-device.js +61 -0
- package/dist/components/dynamic-list/dynamic-list.js +445 -0
- package/dist/components/error-display/full-size-error/full-size-error.js +20 -0
- package/dist/components/error-display/inline-error/inline-error.js +12 -0
- package/dist/components/file-input/file-input.js +318 -0
- package/dist/components/file-upload/file-upload.js +317 -0
- package/dist/components/filters-bar/filters-bar.js +36 -0
- package/dist/components/fullscreen-dialog/fullscreen-dialog.js +68 -0
- package/dist/components/icon-avatar/icon-avatar.js +130 -0
- package/dist/components/icon-text-action-card/icon-text-action-card.js +190 -0
- package/dist/components/illustration/illustration-registry.js +37 -0
- package/dist/components/illustration/illustration-variants.js +21 -0
- package/dist/components/illustration/illustration.js +68 -0
- package/dist/components/index.d.ts +0 -20
- package/dist/components/index.js +134 -6
- package/dist/components/key-value-manager/key-value-manager-add-popover.js +126 -0
- package/dist/components/key-value-manager/key-value-manager-field.js +47 -0
- package/dist/components/key-value-manager/key-value-manager-table.js +188 -0
- package/dist/components/key-value-manager/key-value-manager.js +111 -0
- package/dist/components/key-value-manager/key-value-manager.props.js +28 -0
- package/dist/components/key-value-manager/key-value-manager.utils.js +21 -0
- package/dist/components/link/link.js +67 -0
- package/dist/components/list/dropdown-list-item.js +60 -0
- package/dist/components/list/list-item.utils.js +76 -0
- package/dist/components/list/list.js +49 -0
- package/dist/components/list/list.props.js +27 -0
- package/dist/components/list/standard-list-item.js +66 -0
- package/dist/components/list-details/list-details-item-button.js +46 -0
- package/dist/components/list-details/list-details-item-dropdown.js +112 -0
- package/dist/components/list-details/list-details-item-strip.js +125 -0
- package/dist/components/list-details/list-details.js +148 -0
- package/dist/components/lottie-animation-container/lottie-animation-container.js +31 -0
- package/dist/components/lottie-animations/animation-data/access-denied.js +3980 -0
- package/dist/components/lottie-animations/animation-data/active.js +825 -0
- package/dist/components/lottie-animations/animation-data/bar-chart.js +610 -0
- package/dist/components/lottie-animations/animation-data/chart-loading.js +5368 -0
- package/dist/components/lottie-animations/animation-data/cloud-download.js +1660 -0
- package/dist/components/lottie-animations/animation-data/cloud-sync.js +932 -0
- package/dist/components/lottie-animations/animation-data/coud-upload.js +7060 -0
- package/dist/components/lottie-animations/animation-data/cross-throb.js +1506 -0
- package/dist/components/lottie-animations/animation-data/dashboard-loading.js +14330 -0
- package/dist/components/lottie-animations/animation-data/error-spread-out.js +5567 -0
- package/dist/components/lottie-animations/animation-data/error.js +1211 -0
- package/dist/components/lottie-animations/animation-data/green-success.js +14826 -0
- package/dist/components/lottie-animations/animation-data/inactive.js +723 -0
- package/dist/components/lottie-animations/animation-data/light.js +2678 -0
- package/dist/components/lottie-animations/animation-data/lock.js +900 -0
- package/dist/components/lottie-animations/animation-data/lock2.js +1686 -0
- package/dist/components/lottie-animations/animation-data/locked.js +641 -0
- package/dist/components/lottie-animations/animation-data/search-error.js +954 -0
- package/dist/components/lottie-animations/animation-data/security.js +4121 -0
- package/dist/components/lottie-animations/animation-data/success.js +404 -0
- package/dist/components/lottie-animations/animation-data/verification-in-progress.js +10138 -0
- package/dist/components/lottie-animations/animation-data/warning.js +843 -0
- package/dist/components/lottie-animations/verification-in-progress/verification-in-progress.js +19 -0
- package/dist/components/markdown-content/markdown-content.components.js +114 -0
- package/dist/components/markdown-content/markdown-content.js +39 -0
- package/dist/components/menu/menu.js +19 -0
- package/dist/components/monospace-content/monospace-content.js +80 -0
- package/dist/components/nav-bar/nav-bar-details-panel.js +51 -0
- package/dist/components/nav-bar/nav-bar-mobile-menu.js +105 -0
- package/dist/components/nav-bar/nav-bar.js +449 -0
- package/dist/components/nav-bar/use-nav-bar-overflow.js +74 -0
- package/dist/components/nav-bar/use-nav-bar-scroll.js +42 -0
- package/dist/components/overflow-badge-list/overflow-badge-list.js +58 -0
- package/dist/components/page-container/page-container-skeleton.js +72 -0
- package/dist/components/page-container/page-container.js +93 -0
- package/dist/components/pagination/pagination.js +96 -0
- package/dist/components/pagination/pagination.props.js +16 -0
- package/dist/components/progress-bar/progress-bar.js +106 -0
- package/dist/components/radio-group/radio-group.js +41 -0
- package/dist/components/requirement-list/requirement-list.js +83 -0
- package/dist/components/scrollable-sections/scrollable-sections.js +270 -0
- package/dist/components/search-box/search-box.js +54 -0
- package/dist/components/search-field-shell.js +24 -0
- package/dist/components/selectable-card-list/checkbox-card-list.js +85 -0
- package/dist/components/selectable-card-list/radio-card-list.js +99 -0
- package/dist/components/selectable-card-list/selectable-card-list-shared.js +135 -0
- package/dist/components/selectable-card-list/selectable-card-list.js +34 -0
- package/dist/components/sidebar/sidebar.js +344 -0
- package/dist/components/sidebar/types.js +6 -0
- package/dist/components/simple-clickable-card/simple-clickable-card-shared.js +309 -0
- package/dist/components/simple-clickable-card/simple-clickable-card.js +106 -0
- package/dist/components/simple-info-card/simple-info-card.js +154 -0
- package/dist/components/simple-list/simple-list.js +146 -0
- package/dist/components/simple-paginated-list/simple-paginated-list.js +178 -0
- package/dist/components/simplified-date/simplified-date.js +56 -0
- package/dist/components/skeletons/table-skeleton.js +16 -0
- package/dist/components/spinner/spinner.js +25 -0
- package/dist/components/stat-card/stat-card.js +206 -0
- package/dist/components/status-badge/status-badge.js +108 -0
- package/dist/components/status-card-list/status-card-list.js +282 -0
- package/dist/components/tag/tag.js +144 -0
- package/dist/components/tag-input/tag-input.js +161 -0
- package/dist/components/text-effects/glitch-effect/glitch-text.js +115 -0
- package/dist/components/text-effects/gradient-text/gradient-text.js +32 -0
- package/dist/components/text-effects/highlight-text/highlight-text.js +35 -0
- package/dist/components/text-effects/parse-text-markup.js +53 -0
- package/dist/components/text-effects/shimmer-text/shimmer-text.js +67 -0
- package/dist/components/time-picker/time-picker.js +23 -0
- package/dist/components/toast/toast.js +126 -0
- package/dist/components/togglable-items-list/togglable-items-list.js +28 -0
- package/dist/components/tooltip/tooltip.js +21 -0
- package/dist/components/transfer-list/transfer-list.js +413 -0
- package/dist/components/truncated-line-with-tooltip/truncated-line-with-tooltip.js +61 -0
- package/dist/components/typography/typography-variants.js +41 -0
- package/dist/components/typography/typography.js +15 -0
- package/dist/components/user-type-badge/user-type-badge.js +40 -0
- package/dist/components/user-type-badge/user-type-badge.registry.js +17 -0
- package/dist/components/vertical-stepper/vertical-stepper.js +171 -0
- package/dist/core/alert.js +33 -0
- package/dist/core/animate-ui/components/animate/code-header.js +30 -0
- package/dist/core/animate-ui/components/animate/code.js +35 -0
- package/dist/core/animate-ui/components/animate/tabs.js +188 -0
- package/dist/core/animate-ui/components/animate/tooltip.js +39 -0
- package/dist/core/animate-ui/components/base/preview-card.js +29 -0
- package/dist/core/animate-ui/components/base/progress.js +32 -0
- package/dist/core/animate-ui/components/base/radio.js +24 -0
- package/dist/core/animate-ui/components/buttons/copy.js +95 -0
- package/dist/core/animate-ui/components/radix/accordion.js +36 -0
- package/dist/core/animate-ui/components/radix/dialog.js +60 -0
- package/dist/core/animate-ui/components/radix/dropdown-menu.js +129 -0
- package/dist/core/animate-ui/components/radix/sheet.js +110 -0
- package/dist/core/animate-ui/components/radix/sidebar.js +416 -0
- package/dist/core/animate-ui/components/radix/switch.js +34 -0
- package/dist/core/animate-ui/components/radix/toggle-group.js +115 -0
- package/dist/core/animate-ui/components/radix/toggle.js +24 -0
- package/dist/core/animate-ui/primitives/animate/code-block.js +131 -0
- package/dist/core/animate-ui/primitives/animate/escape-html.js +7 -0
- package/dist/core/animate-ui/primitives/animate/shiki-highlighter.js +64 -0
- package/dist/core/animate-ui/primitives/animate/slot.js +39 -0
- package/dist/core/animate-ui/primitives/animate/tabs.js +202 -0
- package/dist/core/animate-ui/primitives/animate/tooltip.js +351 -0
- package/dist/core/animate-ui/primitives/base/preview-card.js +107 -0
- package/dist/core/animate-ui/primitives/base/progress.js +60 -0
- package/dist/core/animate-ui/primitives/base/radio.js +83 -0
- package/dist/core/animate-ui/primitives/buttons/button.js +16 -0
- package/dist/core/animate-ui/primitives/effects/highlight.js +407 -0
- package/dist/core/animate-ui/primitives/radix/accordion.js +76 -0
- package/dist/core/animate-ui/primitives/radix/dialog.js +136 -0
- package/dist/core/animate-ui/primitives/radix/dropdown-menu.js +305 -0
- package/dist/core/animate-ui/primitives/radix/sheet.js +165 -0
- package/dist/core/animate-ui/primitives/radix/switch.js +86 -0
- package/dist/core/animate-ui/primitives/radix/toggle-group.js +100 -0
- package/dist/core/animate-ui/primitives/texts/counting-number.js +75 -0
- package/dist/core/avatar.js +32 -0
- package/dist/core/badge.js +27 -0
- package/dist/core/breadcrumb.js +62 -0
- package/dist/core/button/button.js +43 -0
- package/dist/core/button/craft-button.js +78 -0
- package/dist/core/button-group.js +38 -0
- package/dist/core/button.js +40 -0
- package/dist/core/card.js +42 -0
- package/dist/core/carousel/carousel.js +149 -0
- package/dist/core/checkbox/motion-checkbox.js +103 -0
- package/dist/core/collapsible.js +54 -0
- package/dist/core/combobox/combobox.js +85 -0
- package/dist/core/command.js +61 -0
- package/dist/core/field-end-icons.js +36 -0
- package/dist/core/field-label-row.js +33 -0
- package/dist/core/form.js +92 -0
- package/dist/core/hooks/use-controlled-state.js +27 -0
- package/dist/core/hooks/use-data-state.js +39 -0
- package/dist/core/hooks/use-is-in-view.js +18 -0
- package/dist/core/hooks/use-mobile.js +19 -0
- package/dist/core/hooks/use-reveal-on-scroll-up.js +141 -0
- package/dist/core/hooks/use-scroll-overflow.js +50 -0
- package/dist/core/index.js +18 -52
- package/dist/core/input/input-password.js +30 -0
- package/dist/core/input/input.js +147 -0
- package/dist/core/input-otp/input-otp.js +183 -0
- package/dist/core/label.js +15 -0
- package/dist/core/popover.js +31 -0
- package/dist/core/scroll-area.js +42 -0
- package/dist/core/select.js +121 -0
- package/dist/core/separator.js +40 -0
- package/dist/core/skeleton.js +11 -0
- package/dist/core/table.js +59 -0
- package/dist/core/textarea/textarea.js +97 -0
- package/dist/core/utils/get-strict-context.js +18 -0
- package/dist/index.js +148 -9
- package/dist/layouts/entry-layout/entry-layout-bg.js +4 -0
- package/dist/layouts/entry-layout/entry-layout.js +52 -0
- package/dist/layouts/index.js +7 -6
- package/dist/layouts/workspace-layout/account-menu/account-menu.js +108 -0
- package/dist/layouts/workspace-layout/breadcrumbs/derive-breadcrumbs.js +37 -0
- package/dist/layouts/workspace-layout/breadcrumbs/workspace-breadcrumbs.js +22 -0
- package/dist/layouts/workspace-layout/footer/footer.js +15 -0
- package/dist/layouts/workspace-layout/header/header.js +54 -0
- package/dist/layouts/workspace-layout/workspace-layout.js +157 -0
- package/dist/tailwind-preset.js +3 -4
- package/dist/utils/cn.js +8 -0
- package/dist/utils/color.js +72 -0
- package/dist/utils/index.js +3 -2
- package/dist/utils/path-match.js +17 -0
- package/dist/utils/silver-shine.js +63 -0
- package/dist/utils/variant-gradient-underlay.js +45 -0
- package/dist/utils/variant.js +426 -0
- package/package.json +7 -4
- package/dist/chunk-2GDYZAKR.js +0 -505
- package/dist/chunk-ALCWXFUC.js +0 -733
- package/dist/chunk-CDHBLANU.js +0 -59
- package/dist/chunk-LUESSJAF.js +0 -70068
- package/dist/chunk-TMORRNEB.js +0 -323
- package/dist/chunk-TRTQSARU.js +0 -31
- package/dist/chunk-VU4CZ76T.js +0 -43
- package/dist/chunk-XNLCVHBC.js +0 -364
- package/dist/chunk-Z4776NRY.js +0 -4347
- package/src/assets/illustrations/add-to-group.svg +0 -32
- package/src/assets/illustrations/chip.svg +0 -51
- package/src/assets/illustrations/create-new-group.svg +0 -27
- package/src/assets/illustrations/new-ota.svg +0 -61
- package/src/assets/illustrations/secured-key.svg +0 -48
- /package/dist/assets/{entry-layout-bg-JPI7GJ42.webp → entry-layout-bg-DUM0UhT3.webp} +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/core/hooks/use-reveal-on-scroll-up.tsx
|
|
3
|
+
var DEFAULT_THRESHOLD = 24;
|
|
4
|
+
var OPEN_POPUP_SELECTOR = "[aria-expanded=\"true\"], [data-state=\"open\"]";
|
|
5
|
+
var STATIC = {
|
|
6
|
+
state: "static",
|
|
7
|
+
animate: false
|
|
8
|
+
};
|
|
9
|
+
function getScrollParent(element) {
|
|
10
|
+
let parent = element.parentElement;
|
|
11
|
+
while (parent) {
|
|
12
|
+
const { overflowY } = getComputedStyle(parent);
|
|
13
|
+
if (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay") return parent;
|
|
14
|
+
parent = parent.parentElement;
|
|
15
|
+
}
|
|
16
|
+
return window;
|
|
17
|
+
}
|
|
18
|
+
function useMediaMatch(query, enabled) {
|
|
19
|
+
const [matches, setMatches] = React$1.useState(false);
|
|
20
|
+
React$1.useEffect(() => {
|
|
21
|
+
if (!enabled || query === void 0) {
|
|
22
|
+
setMatches(enabled);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (typeof window.matchMedia !== "function") {
|
|
26
|
+
setMatches(false);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const mql = window.matchMedia(query);
|
|
30
|
+
const onChange = () => setMatches(mql.matches);
|
|
31
|
+
onChange();
|
|
32
|
+
mql.addEventListener("change", onChange);
|
|
33
|
+
return () => mql.removeEventListener("change", onChange);
|
|
34
|
+
}, [query, enabled]);
|
|
35
|
+
return matches;
|
|
36
|
+
}
|
|
37
|
+
function readScroll(scroller) {
|
|
38
|
+
if (scroller instanceof Window) {
|
|
39
|
+
const max = document.documentElement.scrollHeight - window.innerHeight;
|
|
40
|
+
return {
|
|
41
|
+
top: window.scrollY,
|
|
42
|
+
max,
|
|
43
|
+
viewportTop: 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
top: scroller.scrollTop,
|
|
48
|
+
max: scroller.scrollHeight - scroller.clientHeight,
|
|
49
|
+
viewportTop: scroller.getBoundingClientRect().top
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Headroom-style visibility for a page header inside a scroll container: the
|
|
54
|
+
* header scrolls away normally, slides back in pinned at the top once the user
|
|
55
|
+
* scrolls up by `threshold`, and slides away again on the next scroll down.
|
|
56
|
+
* Back at the header's natural position it returns to the normal flow.
|
|
57
|
+
*/
|
|
58
|
+
function useRevealOnScrollUp(ref, { enabled: enabledOption, mediaQuery, threshold = DEFAULT_THRESHOLD }) {
|
|
59
|
+
const enabled = useMediaMatch(mediaQuery, enabledOption);
|
|
60
|
+
const [reveal, setReveal] = React$1.useState(STATIC);
|
|
61
|
+
const stateRef = React$1.useRef("static");
|
|
62
|
+
const transition = React$1.useCallback((next) => {
|
|
63
|
+
const previous = stateRef.current;
|
|
64
|
+
if (previous === next) return;
|
|
65
|
+
stateRef.current = next;
|
|
66
|
+
setReveal({
|
|
67
|
+
state: next,
|
|
68
|
+
animate: previous !== "static" && next !== "static"
|
|
69
|
+
});
|
|
70
|
+
}, []);
|
|
71
|
+
React$1.useEffect(() => {
|
|
72
|
+
const element = ref.current;
|
|
73
|
+
if (!enabled || !element) {
|
|
74
|
+
stateRef.current = "static";
|
|
75
|
+
setReveal(STATIC);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const scroller = getScrollParent(element);
|
|
79
|
+
let lastTop = readScroll(scroller).top;
|
|
80
|
+
let upDistance = 0;
|
|
81
|
+
let naturalTop = 0;
|
|
82
|
+
let frame = 0;
|
|
83
|
+
const update = () => {
|
|
84
|
+
frame = 0;
|
|
85
|
+
const scroll = readScroll(scroller);
|
|
86
|
+
const top = Math.min(Math.max(scroll.top, 0), Math.max(scroll.max, 0));
|
|
87
|
+
const delta = top - lastTop;
|
|
88
|
+
lastTop = top;
|
|
89
|
+
const rect = element.getBoundingClientRect();
|
|
90
|
+
if (stateRef.current === "static") naturalTop = rect.top - scroll.viewportTop + top;
|
|
91
|
+
const naturalBottom = naturalTop + rect.height;
|
|
92
|
+
if (top <= naturalTop) {
|
|
93
|
+
transition("static");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (stateRef.current === "static") {
|
|
97
|
+
if (top >= naturalBottom) transition("hidden");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (delta > 0) {
|
|
101
|
+
upDistance = 0;
|
|
102
|
+
if (stateRef.current === "revealed" && element.querySelector(OPEN_POPUP_SELECTOR)) return;
|
|
103
|
+
transition(top < naturalBottom ? "static" : "hidden");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (delta < 0) {
|
|
107
|
+
upDistance -= delta;
|
|
108
|
+
if (stateRef.current !== "hidden") return;
|
|
109
|
+
if (top < naturalBottom) {
|
|
110
|
+
transition("static");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (upDistance >= threshold) transition("revealed");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const onScroll = () => {
|
|
117
|
+
if (frame === 0) frame = requestAnimationFrame(update);
|
|
118
|
+
};
|
|
119
|
+
update();
|
|
120
|
+
scroller.addEventListener("scroll", onScroll, { passive: true });
|
|
121
|
+
return () => {
|
|
122
|
+
scroller.removeEventListener("scroll", onScroll);
|
|
123
|
+
if (frame !== 0) cancelAnimationFrame(frame);
|
|
124
|
+
};
|
|
125
|
+
}, [
|
|
126
|
+
ref,
|
|
127
|
+
enabled,
|
|
128
|
+
threshold,
|
|
129
|
+
transition
|
|
130
|
+
]);
|
|
131
|
+
const revealNow = React$1.useCallback(() => {
|
|
132
|
+
if (stateRef.current === "hidden") transition("revealed");
|
|
133
|
+
}, [transition]);
|
|
134
|
+
return {
|
|
135
|
+
state: reveal.state,
|
|
136
|
+
animate: reveal.animate,
|
|
137
|
+
reveal: revealNow
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { useRevealOnScrollUp };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/core/hooks/use-scroll-overflow.tsx
|
|
3
|
+
var NO_OVERFLOW = {
|
|
4
|
+
start: false,
|
|
5
|
+
end: false
|
|
6
|
+
};
|
|
7
|
+
/** Tracks whether a horizontal scroller has content hidden on either side. */
|
|
8
|
+
function useScrollOverflow(ref, { enabled = true, getContent, onResize } = {}) {
|
|
9
|
+
const [overflow, setOverflow] = React$1.useState(NO_OVERFLOW);
|
|
10
|
+
const getContentRef = React$1.useRef(getContent);
|
|
11
|
+
const onResizeRef = React$1.useRef(onResize);
|
|
12
|
+
React$1.useEffect(() => {
|
|
13
|
+
getContentRef.current = getContent;
|
|
14
|
+
onResizeRef.current = onResize;
|
|
15
|
+
});
|
|
16
|
+
React$1.useEffect(() => {
|
|
17
|
+
const scroller = ref.current;
|
|
18
|
+
if (!enabled || !scroller) {
|
|
19
|
+
setOverflow(NO_OVERFLOW);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const update = () => {
|
|
23
|
+
const max = scroller.scrollWidth - scroller.clientWidth;
|
|
24
|
+
const pos = Math.abs(scroller.scrollLeft);
|
|
25
|
+
const start = pos > 1;
|
|
26
|
+
const end = pos < max - 1;
|
|
27
|
+
setOverflow((prev) => prev.start === start && prev.end === end ? prev : {
|
|
28
|
+
start,
|
|
29
|
+
end
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
update();
|
|
33
|
+
scroller.addEventListener("scroll", update, { passive: true });
|
|
34
|
+
if (typeof ResizeObserver === "undefined") return () => scroller.removeEventListener("scroll", update);
|
|
35
|
+
const observer = new ResizeObserver(() => {
|
|
36
|
+
update();
|
|
37
|
+
onResizeRef.current?.();
|
|
38
|
+
});
|
|
39
|
+
observer.observe(scroller);
|
|
40
|
+
const content = getContentRef.current?.(scroller);
|
|
41
|
+
if (content) observer.observe(content);
|
|
42
|
+
return () => {
|
|
43
|
+
scroller.removeEventListener("scroll", update);
|
|
44
|
+
observer.disconnect();
|
|
45
|
+
};
|
|
46
|
+
}, [ref, enabled]);
|
|
47
|
+
return overflow;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { useScrollOverflow };
|
package/dist/core/index.js
CHANGED
|
@@ -1,52 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
variant: "default"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
var Alert = React.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
24
|
-
"div",
|
|
25
|
-
{
|
|
26
|
-
ref,
|
|
27
|
-
role: "alert",
|
|
28
|
-
className: cn(alertVariants({ variant }), className),
|
|
29
|
-
...props
|
|
30
|
-
}
|
|
31
|
-
));
|
|
32
|
-
Alert.displayName = "Alert";
|
|
33
|
-
var AlertTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
34
|
-
"h5",
|
|
35
|
-
{
|
|
36
|
-
ref,
|
|
37
|
-
className: cn("mb-1 font-medium leading-none tracking-tight", className),
|
|
38
|
-
...props
|
|
39
|
-
}
|
|
40
|
-
));
|
|
41
|
-
AlertTitle.displayName = "AlertTitle";
|
|
42
|
-
var AlertDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
ref,
|
|
46
|
-
className: cn("text-sm [&_p]:leading-relaxed", className),
|
|
47
|
-
...props
|
|
48
|
-
}
|
|
49
|
-
));
|
|
50
|
-
AlertDescription.displayName = "AlertDescription";
|
|
51
|
-
|
|
52
|
-
export { Alert, AlertDescription, AlertTitle };
|
|
1
|
+
import { useControlledState } from "./hooks/use-controlled-state.js";
|
|
2
|
+
import { getStrictContext } from "./utils/get-strict-context.js";
|
|
3
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
|
|
4
|
+
import { useDataState } from "./hooks/use-data-state.js";
|
|
5
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible.js";
|
|
6
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./card.js";
|
|
7
|
+
import { Button, buttonVariants } from "./button.js";
|
|
8
|
+
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
|
+
import { useIsMobile } from "./hooks/use-mobile.js";
|
|
10
|
+
import { Separator } from "./separator.js";
|
|
11
|
+
import { Skeleton } from "./skeleton.js";
|
|
12
|
+
import { Label } from "./label.js";
|
|
13
|
+
import { Badge, badgeVariants } from "./badge.js";
|
|
14
|
+
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants } from "./button-group.js";
|
|
15
|
+
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "./breadcrumb.js";
|
|
16
|
+
import { useIsInView } from "./hooks/use-is-in-view.js";
|
|
17
|
+
import { Alert, AlertDescription, AlertTitle } from "./alert.js";
|
|
18
|
+
export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, Label, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Separator, Skeleton, badgeVariants, buttonGroupVariants, buttonVariants, getStrictContext, useControlledState, useDataState, useIsInView, useIsMobile };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { Input } from "./input.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
8
|
+
//#region src/core/input/input-password.tsx
|
|
9
|
+
var InputPassword = React$1.forwardRef(({ className, ...props }, ref) => {
|
|
10
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
11
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
12
|
+
ref,
|
|
13
|
+
type: isVisible ? "text" : "password",
|
|
14
|
+
className: cn("pr-9", className),
|
|
15
|
+
endIcon: /* @__PURE__ */ jsxs("button", {
|
|
16
|
+
type: "button",
|
|
17
|
+
onClick: () => setIsVisible((prev) => !prev),
|
|
18
|
+
className: "pointer-events-auto cursor-pointer text-muted-foreground hover:text-foreground",
|
|
19
|
+
tabIndex: -1,
|
|
20
|
+
children: [isVisible ? /* @__PURE__ */ jsx(EyeOffIcon, { size: 16 }) : /* @__PURE__ */ jsx(EyeIcon, { size: 16 }), /* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: "sr-only",
|
|
22
|
+
children: isVisible ? "Hide password" : "Show password"
|
|
23
|
+
})]
|
|
24
|
+
}),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
InputPassword.displayName = "InputPassword";
|
|
29
|
+
//#endregion
|
|
30
|
+
export { InputPassword };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { FieldLabelRow, fieldHintClassName, inputLabelClassName } from "../field-label-row.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/core/input/input.tsx
|
|
6
|
+
var sizeClasses = {
|
|
7
|
+
sm: "h-8 px-2 text-xs",
|
|
8
|
+
default: "h-10 px-3 py-2 text-base md:text-sm",
|
|
9
|
+
lg: "h-12 px-4 text-lg"
|
|
10
|
+
};
|
|
11
|
+
var Input = React$1.forwardRef(({ className, type, label, size, rounded, startHelperContent, endHelperContent, hintContent, error, errorContent, startIcon, endIcon, startAddOnContent, endAddOnContent, startAddOn, endAddOn, floatingLabel, charLimit, onChange, value, defaultValue, id, required, placeholder, ...restProps }, ref) => {
|
|
12
|
+
const autoId = React$1.useId();
|
|
13
|
+
const inputId = id || autoId;
|
|
14
|
+
const [charCount, setCharCount] = React$1.useState(() => {
|
|
15
|
+
if (charLimit === void 0) return 0;
|
|
16
|
+
if (typeof value === "string") return value.length;
|
|
17
|
+
if (typeof defaultValue === "string") return defaultValue.length;
|
|
18
|
+
return 0;
|
|
19
|
+
});
|
|
20
|
+
React$1.useEffect(() => {
|
|
21
|
+
if (charLimit !== void 0 && typeof value === "string") setCharCount(value.length);
|
|
22
|
+
}, [value, charLimit]);
|
|
23
|
+
if (!(label !== void 0 || size !== void 0 || rounded !== void 0 || startHelperContent !== void 0 || endHelperContent !== void 0 || hintContent !== void 0 || error !== void 0 || errorContent !== void 0 || startIcon !== void 0 || endIcon !== void 0 || startAddOnContent !== void 0 || endAddOnContent !== void 0 || startAddOn !== void 0 || endAddOn !== void 0 || floatingLabel !== void 0 || charLimit !== void 0)) return /* @__PURE__ */ jsx("input", {
|
|
24
|
+
type,
|
|
25
|
+
id,
|
|
26
|
+
className: cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background transition-[box-shadow,border-color] duration-200 ease-in-out file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 read-only:bg-muted md:text-sm", className),
|
|
27
|
+
ref,
|
|
28
|
+
onChange,
|
|
29
|
+
value,
|
|
30
|
+
defaultValue,
|
|
31
|
+
required,
|
|
32
|
+
placeholder,
|
|
33
|
+
...restProps
|
|
34
|
+
});
|
|
35
|
+
const effectiveSize = size || "default";
|
|
36
|
+
const hasError = error || !!errorContent;
|
|
37
|
+
const handleChange = (e) => {
|
|
38
|
+
if (charLimit !== void 0) setCharCount(e.target.value.length);
|
|
39
|
+
onChange?.(e);
|
|
40
|
+
};
|
|
41
|
+
const effectivePlaceholder = floatingLabel ? " " : placeholder;
|
|
42
|
+
const resolveAddOn = (content, text) => content != null && content !== false && content !== "" ? content : text || void 0;
|
|
43
|
+
const startAddOnNode = resolveAddOn(startAddOnContent, startAddOn);
|
|
44
|
+
const endAddOnNode = resolveAddOn(endAddOnContent, endAddOn);
|
|
45
|
+
const hasAddOn = startAddOnNode != null || endAddOnNode != null;
|
|
46
|
+
const hasOverlay = !!startIcon || !!endIcon || charLimit !== void 0 || !!floatingLabel;
|
|
47
|
+
const helperStartId = `${inputId}-helper-start`;
|
|
48
|
+
const helperEndId = `${inputId}-helper-end`;
|
|
49
|
+
const describedBy = [
|
|
50
|
+
errorContent && `${inputId}-error`,
|
|
51
|
+
startHelperContent && !errorContent && helperStartId,
|
|
52
|
+
endHelperContent && !errorContent && helperEndId
|
|
53
|
+
].filter(Boolean).join(" ") || void 0;
|
|
54
|
+
const inputElement = /* @__PURE__ */ jsx("input", {
|
|
55
|
+
type,
|
|
56
|
+
id: inputId,
|
|
57
|
+
ref,
|
|
58
|
+
className: cn("flex w-full border border-input bg-background ring-offset-background transition-[box-shadow,border-color] duration-200 ease-in-out file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 read-only:bg-muted z-10", floatingLabel ? "h-12 px-3 pt-4 pb-1 text-base md:text-sm" : sizeClasses[effectiveSize], rounded ? "rounded-full" : "rounded-md", hasError && "border-destructive focus-visible:ring-destructive", startIcon && "ps-9", endIcon && "pe-9", charLimit !== void 0 && !endIcon && "pe-14", charLimit !== void 0 && endIcon && "pe-20", startAddOnNode != null && "rounded-s-none shadow-none", endAddOnNode != null && "rounded-e-none shadow-none", "peer", floatingLabel && "placeholder:text-transparent", className),
|
|
59
|
+
required,
|
|
60
|
+
"aria-invalid": hasError || void 0,
|
|
61
|
+
"aria-describedby": describedBy,
|
|
62
|
+
onChange: handleChange,
|
|
63
|
+
value,
|
|
64
|
+
defaultValue,
|
|
65
|
+
maxLength: charLimit,
|
|
66
|
+
placeholder: effectivePlaceholder,
|
|
67
|
+
...restProps
|
|
68
|
+
});
|
|
69
|
+
let inputContainer = inputElement;
|
|
70
|
+
if (hasOverlay) inputContainer = /* @__PURE__ */ jsxs("div", {
|
|
71
|
+
className: "group relative min-w-0 flex-1",
|
|
72
|
+
children: [
|
|
73
|
+
inputElement,
|
|
74
|
+
startIcon && /* @__PURE__ */ jsx("div", {
|
|
75
|
+
className: "pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50",
|
|
76
|
+
children: startIcon
|
|
77
|
+
}),
|
|
78
|
+
(endIcon || charLimit !== void 0) && /* @__PURE__ */ jsxs("div", {
|
|
79
|
+
className: "pointer-events-none absolute inset-y-0 end-0 flex items-center justify-center gap-2 pe-3 text-muted-foreground/80 peer-disabled:opacity-50",
|
|
80
|
+
children: [charLimit !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
81
|
+
className: "text-xs tabular-nums text-muted-foreground",
|
|
82
|
+
children: [
|
|
83
|
+
charCount,
|
|
84
|
+
"/",
|
|
85
|
+
charLimit
|
|
86
|
+
]
|
|
87
|
+
}), endIcon]
|
|
88
|
+
}),
|
|
89
|
+
floatingLabel && label && /* @__PURE__ */ jsxs("label", {
|
|
90
|
+
htmlFor: inputId,
|
|
91
|
+
className: "absolute start-2 top-0 z-10 block -translate-y-1/2 bg-background px-2 text-xs font-medium text-foreground/70 transition-all peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-sm peer-placeholder-shown:font-normal peer-focus:top-0 peer-focus:text-xs peer-focus:font-medium",
|
|
92
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
93
|
+
className: "text-destructive",
|
|
94
|
+
children: " *"
|
|
95
|
+
})]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
if (hasAddOn) inputContainer = /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: "flex rounded-lg",
|
|
101
|
+
children: [
|
|
102
|
+
startAddOnNode != null && /* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "-me-px inline-flex items-center rounded-s-lg border border-input bg-background px-3 text-sm text-muted-foreground",
|
|
104
|
+
children: startAddOnNode
|
|
105
|
+
}),
|
|
106
|
+
inputContainer,
|
|
107
|
+
endAddOnNode != null && /* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "-ms-px inline-flex items-center rounded-e-lg border border-input bg-background px-3 text-sm text-muted-foreground",
|
|
109
|
+
children: endAddOnNode
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
114
|
+
className: "space-y-2 flex-1",
|
|
115
|
+
children: [
|
|
116
|
+
label && !floatingLabel && /* @__PURE__ */ jsx(FieldLabelRow, {
|
|
117
|
+
htmlFor: inputId,
|
|
118
|
+
label,
|
|
119
|
+
required,
|
|
120
|
+
hintContent
|
|
121
|
+
}),
|
|
122
|
+
!label && hintContent && /* @__PURE__ */ jsx("span", {
|
|
123
|
+
className: fieldHintClassName,
|
|
124
|
+
children: hintContent
|
|
125
|
+
}),
|
|
126
|
+
inputContainer,
|
|
127
|
+
errorContent && /* @__PURE__ */ jsx("div", {
|
|
128
|
+
id: `${inputId}-error`,
|
|
129
|
+
className: "text-sm text-destructive",
|
|
130
|
+
children: errorContent
|
|
131
|
+
}),
|
|
132
|
+
startHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
133
|
+
id: helperStartId,
|
|
134
|
+
className: "text-sm text-muted-foreground",
|
|
135
|
+
children: startHelperContent
|
|
136
|
+
}),
|
|
137
|
+
endHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
138
|
+
id: helperEndId,
|
|
139
|
+
className: "text-sm text-end text-muted-foreground",
|
|
140
|
+
children: endHelperContent
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
Input.displayName = "Input";
|
|
146
|
+
//#endregion
|
|
147
|
+
export { Input, inputLabelClassName };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { inputLabelClassName } from "../field-label-row.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { MinusIcon } from "lucide-react";
|
|
7
|
+
import { OTPInput, OTPInputContext, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp";
|
|
8
|
+
//#region src/core/input-otp/input-otp.tsx
|
|
9
|
+
var LENGTH_MIN = 2;
|
|
10
|
+
var LENGTH_MAX = 12;
|
|
11
|
+
var LENGTH_DEFAULT = 6;
|
|
12
|
+
var slotSizeClasses = {
|
|
13
|
+
sm: "h-8 w-8 text-xs",
|
|
14
|
+
default: "h-10 w-10 text-base md:text-sm",
|
|
15
|
+
lg: "h-12 w-12 text-lg"
|
|
16
|
+
};
|
|
17
|
+
/** Expanded mode: keep the height and font size but let the slot flex-grow. */
|
|
18
|
+
var slotExpandedSizeClasses = {
|
|
19
|
+
sm: "h-8 text-xs",
|
|
20
|
+
default: "h-10 text-base md:text-sm",
|
|
21
|
+
lg: "h-12 text-lg"
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Standalone visual divider used between OTP slot groups. Exported for callers
|
|
25
|
+
* that want to render their own custom slot layout; the default `InputOTP`
|
|
26
|
+
* component renders it automatically based on the `separators` prop.
|
|
27
|
+
*/
|
|
28
|
+
var InputOTPSeparator = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
29
|
+
ref,
|
|
30
|
+
role: "separator",
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
className: cn("flex items-center text-muted-foreground", className),
|
|
33
|
+
...props,
|
|
34
|
+
children: /* @__PURE__ */ jsx(MinusIcon, { size: 16 })
|
|
35
|
+
}));
|
|
36
|
+
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
37
|
+
/**
|
|
38
|
+
* Renders one slot box. Mirrors `Input`'s border/focus/error tokens so a row of
|
|
39
|
+
* slots visually lines up with an `Input` of the same `size`.
|
|
40
|
+
*/
|
|
41
|
+
var SlotBox = ({ index, size, expand, rounded, hasError, cornerClass }) => {
|
|
42
|
+
const slot = React$1.useContext(OTPInputContext).slots[index];
|
|
43
|
+
if (!slot) return null;
|
|
44
|
+
const { char, hasFakeCaret, isActive } = slot;
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
"data-active": isActive || void 0,
|
|
47
|
+
className: cn("relative flex items-center justify-center border border-input bg-background font-medium text-foreground shadow-xs", "transition-[box-shadow,border-color] duration-200 ease-in-out", "ring-offset-background", "data-[active=true]:z-10 data-[active=true]:ring-2 data-[active=true]:ring-ring data-[active=true]:ring-offset-2", hasError && "border-destructive data-[active=true]:ring-destructive", rounded ? "rounded-full" : "rounded-md", cornerClass, expand ? cn("min-w-0 flex-1", slotExpandedSizeClasses[size]) : slotSizeClasses[size]),
|
|
48
|
+
children: [char, hasFakeCaret && /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-center",
|
|
50
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-4 w-px animate-caret-blink bg-foreground duration-1000" })
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/** Splits `[0, 1, …, length-1]` into groups per `separators`. */
|
|
55
|
+
function buildGroups(length, separators) {
|
|
56
|
+
if (!separators || separators.length === 0) return [Array.from({ length }, (_, i) => i)];
|
|
57
|
+
const sum = separators.reduce((a, b) => a + b, 0);
|
|
58
|
+
if (sum !== length) {
|
|
59
|
+
console.warn(`[InputOTP] separators sum (${sum}) does not equal length (${length}); ignoring separators.`);
|
|
60
|
+
return [Array.from({ length }, (_, i) => i)];
|
|
61
|
+
}
|
|
62
|
+
const groups = [];
|
|
63
|
+
let cursor = 0;
|
|
64
|
+
for (const size of separators) {
|
|
65
|
+
groups.push(Array.from({ length: size }, (_, i) => cursor + i));
|
|
66
|
+
cursor += size;
|
|
67
|
+
}
|
|
68
|
+
return groups;
|
|
69
|
+
}
|
|
70
|
+
function clampLength(raw) {
|
|
71
|
+
if (raw === void 0) return LENGTH_DEFAULT;
|
|
72
|
+
if (!Number.isFinite(raw)) return LENGTH_DEFAULT;
|
|
73
|
+
const rounded = Math.floor(raw);
|
|
74
|
+
if (rounded < LENGTH_MIN) {
|
|
75
|
+
console.warn(`[InputOTP] length=${raw} is below the minimum ${LENGTH_MIN}; using ${LENGTH_MIN}.`);
|
|
76
|
+
return LENGTH_MIN;
|
|
77
|
+
}
|
|
78
|
+
if (rounded > LENGTH_MAX) {
|
|
79
|
+
console.warn(`[InputOTP] length=${raw} is above the maximum ${LENGTH_MAX}; using ${LENGTH_MAX}.`);
|
|
80
|
+
return LENGTH_MAX;
|
|
81
|
+
}
|
|
82
|
+
return rounded;
|
|
83
|
+
}
|
|
84
|
+
var InputOTP = React$1.forwardRef(({ length, allowAlphaNumeric, regex, separators, expand, value, defaultValue, onChange, onComplete, label, required, size, rounded, disabled, startHelperContent, endHelperContent, hintContent, error, errorContent, id, name, autoFocus, autoComplete, className, containerClassName, ...restProps }, ref) => {
|
|
85
|
+
const autoId = React$1.useId();
|
|
86
|
+
const inputId = id || autoId;
|
|
87
|
+
const effectiveLength = React$1.useMemo(() => clampLength(length), [length]);
|
|
88
|
+
const effectiveSize = size || "default";
|
|
89
|
+
const hasError = !!error || !!errorContent;
|
|
90
|
+
const isControlled = value !== void 0;
|
|
91
|
+
const [uncontrolledValue, setUncontrolledValue] = React$1.useState(typeof defaultValue === "string" ? defaultValue : "");
|
|
92
|
+
const effectiveValue = isControlled ? value : uncontrolledValue;
|
|
93
|
+
const handleChange = React$1.useCallback((next) => {
|
|
94
|
+
if (!isControlled) setUncontrolledValue(next);
|
|
95
|
+
onChange?.(next);
|
|
96
|
+
}, [isControlled, onChange]);
|
|
97
|
+
const pattern = regex && regex.length > 0 ? regex : allowAlphaNumeric ? REGEXP_ONLY_DIGITS_AND_CHARS : REGEXP_ONLY_DIGITS;
|
|
98
|
+
const groups = React$1.useMemo(() => buildGroups(effectiveLength, separators), [effectiveLength, separators]);
|
|
99
|
+
const helperStartId = `${inputId}-helper-start`;
|
|
100
|
+
const helperEndId = `${inputId}-helper-end`;
|
|
101
|
+
const describedBy = [
|
|
102
|
+
errorContent && `${inputId}-error`,
|
|
103
|
+
startHelperContent && !errorContent && helperStartId,
|
|
104
|
+
endHelperContent && !errorContent && helperEndId
|
|
105
|
+
].filter(Boolean).join(" ") || void 0;
|
|
106
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: "space-y-2 flex-1",
|
|
108
|
+
"data-disabled": disabled || void 0,
|
|
109
|
+
children: [
|
|
110
|
+
label && /* @__PURE__ */ jsxs("div", {
|
|
111
|
+
className: "flex items-center justify-between",
|
|
112
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
113
|
+
htmlFor: inputId,
|
|
114
|
+
className: inputLabelClassName,
|
|
115
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
116
|
+
className: "text-destructive",
|
|
117
|
+
children: "*"
|
|
118
|
+
})]
|
|
119
|
+
}), hintContent && /* @__PURE__ */ jsx("span", {
|
|
120
|
+
className: "text-sm text-muted-foreground",
|
|
121
|
+
children: hintContent
|
|
122
|
+
})]
|
|
123
|
+
}),
|
|
124
|
+
!label && hintContent && /* @__PURE__ */ jsx("span", {
|
|
125
|
+
className: "text-sm text-muted-foreground",
|
|
126
|
+
children: hintContent
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx(OTPInput, {
|
|
129
|
+
ref,
|
|
130
|
+
id: inputId,
|
|
131
|
+
name,
|
|
132
|
+
value: effectiveValue,
|
|
133
|
+
onChange: handleChange,
|
|
134
|
+
onComplete,
|
|
135
|
+
maxLength: effectiveLength,
|
|
136
|
+
pattern,
|
|
137
|
+
disabled,
|
|
138
|
+
required,
|
|
139
|
+
autoFocus,
|
|
140
|
+
autoComplete: autoComplete ?? "one-time-code",
|
|
141
|
+
"aria-invalid": hasError || void 0,
|
|
142
|
+
"aria-describedby": describedBy,
|
|
143
|
+
containerClassName: cn("flex items-center gap-2 has-[:disabled]:opacity-50 has-[:disabled]:cursor-not-allowed", expand && "w-full", containerClassName),
|
|
144
|
+
...restProps,
|
|
145
|
+
children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [groupIndex > 0 && /* @__PURE__ */ jsx(InputOTPSeparator, {}), /* @__PURE__ */ jsx("div", {
|
|
146
|
+
className: cn("flex items-center", className),
|
|
147
|
+
style: expand ? { flex: `${group.length} 1 0%` } : void 0,
|
|
148
|
+
children: group.map((slotIndex, positionInGroup) => {
|
|
149
|
+
const isFirst = positionInGroup === 0;
|
|
150
|
+
const isLast = positionInGroup === group.length - 1;
|
|
151
|
+
const cornerClass = cn(!isFirst && "-ms-px rounded-s-none", !isLast && "rounded-e-none");
|
|
152
|
+
return /* @__PURE__ */ jsx(SlotBox, {
|
|
153
|
+
index: slotIndex,
|
|
154
|
+
size: effectiveSize,
|
|
155
|
+
expand: !!expand,
|
|
156
|
+
rounded: !!rounded,
|
|
157
|
+
hasError,
|
|
158
|
+
cornerClass
|
|
159
|
+
}, slotIndex);
|
|
160
|
+
})
|
|
161
|
+
})] }, `g-${groupIndex}`))
|
|
162
|
+
}),
|
|
163
|
+
errorContent && /* @__PURE__ */ jsx("div", {
|
|
164
|
+
id: `${inputId}-error`,
|
|
165
|
+
className: "text-sm text-destructive",
|
|
166
|
+
children: errorContent
|
|
167
|
+
}),
|
|
168
|
+
startHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
169
|
+
id: helperStartId,
|
|
170
|
+
className: "text-sm text-muted-foreground",
|
|
171
|
+
children: startHelperContent
|
|
172
|
+
}),
|
|
173
|
+
endHelperContent && !errorContent && /* @__PURE__ */ jsx("div", {
|
|
174
|
+
id: helperEndId,
|
|
175
|
+
className: "text-sm text-end text-muted-foreground",
|
|
176
|
+
children: endHelperContent
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
InputOTP.displayName = "InputOTP";
|
|
182
|
+
//#endregion
|
|
183
|
+
export { InputOTP, InputOTPSeparator };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
6
|
+
//#region src/core/label.tsx
|
|
7
|
+
var labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
8
|
+
var Label = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, {
|
|
9
|
+
ref,
|
|
10
|
+
className: cn(labelVariants(), className),
|
|
11
|
+
...props
|
|
12
|
+
}));
|
|
13
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Label };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
|
+
//#region src/core/popover.tsx
|
|
6
|
+
var Popover = PopoverPrimitive.Root;
|
|
7
|
+
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
8
|
+
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
9
|
+
var PopoverContent = React$1.forwardRef(({ className, align = "center", sideOffset = 4, portal = true, onWheel, onTouchMove, ...props }, ref) => {
|
|
10
|
+
const handleWheel = (event) => {
|
|
11
|
+
onWheel?.(event);
|
|
12
|
+
event.stopPropagation();
|
|
13
|
+
};
|
|
14
|
+
const handleTouchMove = (event) => {
|
|
15
|
+
onTouchMove?.(event);
|
|
16
|
+
event.stopPropagation();
|
|
17
|
+
};
|
|
18
|
+
const content = /* @__PURE__ */ jsx(PopoverPrimitive.Content, {
|
|
19
|
+
ref,
|
|
20
|
+
align,
|
|
21
|
+
sideOffset,
|
|
22
|
+
onWheel: handleWheel,
|
|
23
|
+
onTouchMove: handleTouchMove,
|
|
24
|
+
className: cn("z-50 w-72 rounded-2xl border bg-popover p-4 text-popover-foreground shadow-lg outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]", className),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
return portal ? /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: content }) : content;
|
|
28
|
+
});
|
|
29
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
|