@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,407 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
6
|
+
//#region src/core/animate-ui/primitives/effects/highlight.tsx
|
|
7
|
+
var DEFAULT_BOUNDS_OFFSET = {
|
|
8
|
+
top: 0,
|
|
9
|
+
left: 0,
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
12
|
+
};
|
|
13
|
+
var HighlightContext = React$1.createContext(void 0);
|
|
14
|
+
function useHighlight() {
|
|
15
|
+
const context = React$1.useContext(HighlightContext);
|
|
16
|
+
if (!context) throw new Error("useHighlight must be used within a HighlightProvider");
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
function Highlight({ ref, ...props }) {
|
|
20
|
+
const { as: Component = "div", children, value, defaultValue, onValueChange, className, style, transition = {
|
|
21
|
+
type: "spring",
|
|
22
|
+
stiffness: 350,
|
|
23
|
+
damping: 35
|
|
24
|
+
}, hover = false, click = true, enabled = true, controlledItems, disabled = false, exitDelay = 200, mode = "children" } = props;
|
|
25
|
+
const localRef = React$1.useRef(null);
|
|
26
|
+
React$1.useImperativeHandle(ref, () => localRef.current);
|
|
27
|
+
const parentProps = props;
|
|
28
|
+
const boundsOffset = parentProps?.boundsOffset ?? DEFAULT_BOUNDS_OFFSET;
|
|
29
|
+
const boundsOffsetTop = boundsOffset.top ?? 0;
|
|
30
|
+
const boundsOffsetLeft = boundsOffset.left ?? 0;
|
|
31
|
+
const boundsOffsetWidth = boundsOffset.width ?? 0;
|
|
32
|
+
const boundsOffsetHeight = boundsOffset.height ?? 0;
|
|
33
|
+
const variant = parentProps?.variant;
|
|
34
|
+
const lineHeight = parentProps?.lineHeight ?? 2;
|
|
35
|
+
const boundsOffsetRef = React$1.useRef({
|
|
36
|
+
top: boundsOffsetTop,
|
|
37
|
+
left: boundsOffsetLeft,
|
|
38
|
+
width: boundsOffsetWidth,
|
|
39
|
+
height: boundsOffsetHeight,
|
|
40
|
+
variant,
|
|
41
|
+
lineHeight
|
|
42
|
+
});
|
|
43
|
+
React$1.useEffect(() => {
|
|
44
|
+
boundsOffsetRef.current = {
|
|
45
|
+
top: boundsOffsetTop,
|
|
46
|
+
left: boundsOffsetLeft,
|
|
47
|
+
width: boundsOffsetWidth,
|
|
48
|
+
height: boundsOffsetHeight,
|
|
49
|
+
variant,
|
|
50
|
+
lineHeight
|
|
51
|
+
};
|
|
52
|
+
}, [
|
|
53
|
+
boundsOffsetTop,
|
|
54
|
+
boundsOffsetLeft,
|
|
55
|
+
boundsOffsetWidth,
|
|
56
|
+
boundsOffsetHeight,
|
|
57
|
+
variant,
|
|
58
|
+
lineHeight
|
|
59
|
+
]);
|
|
60
|
+
const [activeValue, setActiveValue] = React$1.useState(value ?? defaultValue ?? null);
|
|
61
|
+
const [boundsState, setBoundsState] = React$1.useState(null);
|
|
62
|
+
const [activeClassNameState, setActiveClassNameState] = React$1.useState("");
|
|
63
|
+
const safeSetActiveValue = (id) => {
|
|
64
|
+
setActiveValue((prev) => {
|
|
65
|
+
if (prev !== id) {
|
|
66
|
+
onValueChange?.(id);
|
|
67
|
+
return id;
|
|
68
|
+
}
|
|
69
|
+
return prev;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const safeSetBoundsRef = React$1.useRef(void 0);
|
|
73
|
+
React$1.useEffect(() => {
|
|
74
|
+
safeSetBoundsRef.current = (bounds, opts) => {
|
|
75
|
+
if (!localRef.current) return;
|
|
76
|
+
const container = localRef.current;
|
|
77
|
+
const containerRect = container.getBoundingClientRect();
|
|
78
|
+
const offset = boundsOffsetRef.current;
|
|
79
|
+
const relativeTop = bounds.top - containerRect.top + container.scrollTop;
|
|
80
|
+
const relativeLeft = bounds.left - containerRect.left + container.scrollLeft;
|
|
81
|
+
const newBounds = offset.variant === "line" && offset.lineHeight != null ? {
|
|
82
|
+
top: relativeTop + bounds.height - offset.lineHeight + (offset.top ?? 0),
|
|
83
|
+
left: relativeLeft + (offset.left ?? 0),
|
|
84
|
+
width: bounds.width + (offset.width ?? 0),
|
|
85
|
+
height: offset.lineHeight
|
|
86
|
+
} : {
|
|
87
|
+
top: relativeTop + offset.top,
|
|
88
|
+
left: relativeLeft + offset.left,
|
|
89
|
+
width: bounds.width + offset.width,
|
|
90
|
+
height: bounds.height + offset.height
|
|
91
|
+
};
|
|
92
|
+
setBoundsState((prev) => {
|
|
93
|
+
if (prev && prev.top === newBounds.top && prev.left === newBounds.left && prev.width === newBounds.width && prev.height === newBounds.height) return prev;
|
|
94
|
+
return {
|
|
95
|
+
...newBounds,
|
|
96
|
+
instant: prev ? opts?.instant ?? false : false
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
const safeSetBounds = (bounds, opts) => {
|
|
102
|
+
safeSetBoundsRef.current?.(bounds, opts);
|
|
103
|
+
};
|
|
104
|
+
const clearBounds = React$1.useCallback(() => {
|
|
105
|
+
setBoundsState((prev) => prev === null ? prev : null);
|
|
106
|
+
}, []);
|
|
107
|
+
React$1.useEffect(() => {
|
|
108
|
+
if (value !== void 0) setActiveValue(value);
|
|
109
|
+
else if (defaultValue !== void 0) setActiveValue(defaultValue);
|
|
110
|
+
}, [value, defaultValue]);
|
|
111
|
+
const id = React$1.useId();
|
|
112
|
+
const getActiveElement = React$1.useCallback(() => {
|
|
113
|
+
const container = localRef.current;
|
|
114
|
+
if (mode !== "parent" || !activeValue || !container) return null;
|
|
115
|
+
return container.querySelector(`[data-value="${activeValue}"][data-highlight="true"]`);
|
|
116
|
+
}, [mode, activeValue]);
|
|
117
|
+
const measureActiveRef = React$1.useRef(void 0);
|
|
118
|
+
React$1.useEffect(() => {
|
|
119
|
+
measureActiveRef.current = (opts) => {
|
|
120
|
+
const activeEl = getActiveElement();
|
|
121
|
+
if (activeEl) safeSetBoundsRef.current?.(activeEl.getBoundingClientRect(), opts);
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
React$1.useEffect(() => {
|
|
125
|
+
if (mode !== "parent") return;
|
|
126
|
+
const container = localRef.current;
|
|
127
|
+
if (!container) return;
|
|
128
|
+
const onScroll = () => measureActiveRef.current?.();
|
|
129
|
+
container.addEventListener("scroll", onScroll, { passive: true });
|
|
130
|
+
return () => container.removeEventListener("scroll", onScroll);
|
|
131
|
+
}, [mode]);
|
|
132
|
+
/**
|
|
133
|
+
* Bounds are stored as absolute pixels, so any layout change that resizes the
|
|
134
|
+
* container or the active item leaves them stale — the highlight would keep its
|
|
135
|
+
* old box and overflow its container. Re-measure whenever either box changes;
|
|
136
|
+
* this also covers the list becoming visible (`display: none` → laid out) when a
|
|
137
|
+
* breakpoint is crossed, since that resize is reported too.
|
|
138
|
+
*/
|
|
139
|
+
React$1.useEffect(() => {
|
|
140
|
+
if (mode !== "parent") return;
|
|
141
|
+
const container = localRef.current;
|
|
142
|
+
if (!container || typeof ResizeObserver === "undefined") return;
|
|
143
|
+
const observer = new ResizeObserver(() => measureActiveRef.current?.({ instant: true }));
|
|
144
|
+
observer.observe(container);
|
|
145
|
+
const activeEl = getActiveElement();
|
|
146
|
+
if (activeEl) observer.observe(activeEl);
|
|
147
|
+
return () => observer.disconnect();
|
|
148
|
+
}, [mode, getActiveElement]);
|
|
149
|
+
React$1.useLayoutEffect(() => {
|
|
150
|
+
if (mode !== "parent" || !activeValue) return;
|
|
151
|
+
const raf = requestAnimationFrame(() => measureActiveRef.current?.());
|
|
152
|
+
return () => cancelAnimationFrame(raf);
|
|
153
|
+
}, [mode, activeValue]);
|
|
154
|
+
const render = (children) => {
|
|
155
|
+
if (mode === "parent") return /* @__PURE__ */ jsxs(Component, {
|
|
156
|
+
ref: localRef,
|
|
157
|
+
"data-slot": "motion-highlight-container",
|
|
158
|
+
style: {
|
|
159
|
+
position: "relative",
|
|
160
|
+
zIndex: 1
|
|
161
|
+
},
|
|
162
|
+
className: props?.containerClassName,
|
|
163
|
+
children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
164
|
+
initial: false,
|
|
165
|
+
mode: "wait",
|
|
166
|
+
children: boundsState && /* @__PURE__ */ jsx(motion.div, {
|
|
167
|
+
"data-slot": "motion-highlight",
|
|
168
|
+
animate: {
|
|
169
|
+
top: boundsState.top,
|
|
170
|
+
left: boundsState.left,
|
|
171
|
+
width: boundsState.width,
|
|
172
|
+
height: boundsState.height,
|
|
173
|
+
opacity: 1
|
|
174
|
+
},
|
|
175
|
+
initial: {
|
|
176
|
+
top: boundsState.top,
|
|
177
|
+
left: boundsState.left,
|
|
178
|
+
width: boundsState.width,
|
|
179
|
+
height: boundsState.height,
|
|
180
|
+
opacity: 0
|
|
181
|
+
},
|
|
182
|
+
exit: {
|
|
183
|
+
opacity: 0,
|
|
184
|
+
transition: {
|
|
185
|
+
...transition,
|
|
186
|
+
delay: (transition?.delay ?? 0) + (exitDelay ?? 0) / 1e3
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
transition: boundsState.instant ? { duration: 0 } : transition,
|
|
190
|
+
style: {
|
|
191
|
+
position: "absolute",
|
|
192
|
+
zIndex: 0,
|
|
193
|
+
...style
|
|
194
|
+
},
|
|
195
|
+
className: cn(className, activeClassNameState)
|
|
196
|
+
})
|
|
197
|
+
}), children]
|
|
198
|
+
});
|
|
199
|
+
return children;
|
|
200
|
+
};
|
|
201
|
+
return /* @__PURE__ */ jsx(HighlightContext.Provider, {
|
|
202
|
+
value: {
|
|
203
|
+
mode,
|
|
204
|
+
activeValue,
|
|
205
|
+
setActiveValue: safeSetActiveValue,
|
|
206
|
+
id,
|
|
207
|
+
hover,
|
|
208
|
+
click,
|
|
209
|
+
className,
|
|
210
|
+
style,
|
|
211
|
+
transition,
|
|
212
|
+
disabled,
|
|
213
|
+
enabled,
|
|
214
|
+
exitDelay,
|
|
215
|
+
setBounds: safeSetBounds,
|
|
216
|
+
clearBounds,
|
|
217
|
+
activeClassName: activeClassNameState,
|
|
218
|
+
setActiveClassName: setActiveClassNameState,
|
|
219
|
+
forceUpdateBounds: props?.forceUpdateBounds
|
|
220
|
+
},
|
|
221
|
+
children: enabled ? controlledItems ? render(children) : render(React$1.Children.map(children, (child, index) => /* @__PURE__ */ jsx(HighlightItem, {
|
|
222
|
+
className: props?.itemsClassName,
|
|
223
|
+
children: child
|
|
224
|
+
}, index))) : children
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function getNonOverridingDataAttributes(element, dataAttributes) {
|
|
228
|
+
return Object.keys(dataAttributes).reduce((acc, key) => {
|
|
229
|
+
if (element.props[key] === void 0) acc[key] = dataAttributes[key];
|
|
230
|
+
return acc;
|
|
231
|
+
}, {});
|
|
232
|
+
}
|
|
233
|
+
function HighlightItem({ ref, as, children, id, value, className, style, transition, disabled = false, activeClassName, exitDelay, asChild = false, forceUpdateBounds, ...props }) {
|
|
234
|
+
const itemId = React$1.useId();
|
|
235
|
+
const { activeValue, setActiveValue, mode, setBounds, clearBounds, hover, click, enabled, className: contextClassName, style: contextStyle, transition: contextTransition, id: contextId, disabled: contextDisabled, exitDelay: contextExitDelay, forceUpdateBounds: contextForceUpdateBounds, setActiveClassName } = useHighlight();
|
|
236
|
+
const Component = as ?? "div";
|
|
237
|
+
const element = children;
|
|
238
|
+
const childValue = id ?? value ?? element.props?.["data-value"] ?? element.props?.id ?? itemId;
|
|
239
|
+
const isActive = activeValue === childValue;
|
|
240
|
+
const isDisabled = disabled === void 0 ? contextDisabled : disabled;
|
|
241
|
+
const itemTransition = transition ?? contextTransition;
|
|
242
|
+
const localRef = React$1.useRef(null);
|
|
243
|
+
React$1.useImperativeHandle(ref, () => localRef.current);
|
|
244
|
+
const refCallback = React$1.useCallback((node) => {
|
|
245
|
+
localRef.current = node;
|
|
246
|
+
}, []);
|
|
247
|
+
React$1.useEffect(() => {
|
|
248
|
+
if (mode !== "parent") return;
|
|
249
|
+
let rafId;
|
|
250
|
+
let previousBounds = null;
|
|
251
|
+
const shouldUpdateBounds = forceUpdateBounds === true || contextForceUpdateBounds && forceUpdateBounds !== false;
|
|
252
|
+
const updateBounds = () => {
|
|
253
|
+
if (!localRef.current) return;
|
|
254
|
+
const bounds = localRef.current.getBoundingClientRect();
|
|
255
|
+
if (shouldUpdateBounds) {
|
|
256
|
+
if (previousBounds && previousBounds.top === bounds.top && previousBounds.left === bounds.left && previousBounds.width === bounds.width && previousBounds.height === bounds.height) {
|
|
257
|
+
rafId = requestAnimationFrame(updateBounds);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
previousBounds = bounds;
|
|
261
|
+
rafId = requestAnimationFrame(updateBounds);
|
|
262
|
+
}
|
|
263
|
+
setBounds(bounds);
|
|
264
|
+
};
|
|
265
|
+
if (isActive) {
|
|
266
|
+
updateBounds();
|
|
267
|
+
setActiveClassName(activeClassName ?? "");
|
|
268
|
+
} else if (!activeValue) clearBounds();
|
|
269
|
+
if (shouldUpdateBounds) return () => cancelAnimationFrame(rafId);
|
|
270
|
+
}, [
|
|
271
|
+
mode,
|
|
272
|
+
isActive,
|
|
273
|
+
activeValue,
|
|
274
|
+
setBounds,
|
|
275
|
+
clearBounds,
|
|
276
|
+
activeClassName,
|
|
277
|
+
setActiveClassName,
|
|
278
|
+
forceUpdateBounds,
|
|
279
|
+
contextForceUpdateBounds
|
|
280
|
+
]);
|
|
281
|
+
if (!React$1.isValidElement(children)) return children;
|
|
282
|
+
const dataAttributes = {
|
|
283
|
+
"data-active": isActive ? "true" : "false",
|
|
284
|
+
"aria-selected": isActive,
|
|
285
|
+
"data-disabled": isDisabled,
|
|
286
|
+
"data-value": childValue,
|
|
287
|
+
"data-highlight": true
|
|
288
|
+
};
|
|
289
|
+
const incomingHandlers = props;
|
|
290
|
+
const commonHandlers = hover ? {
|
|
291
|
+
onMouseEnter: (e) => {
|
|
292
|
+
setActiveValue(childValue);
|
|
293
|
+
element.props.onMouseEnter?.(e);
|
|
294
|
+
incomingHandlers.onMouseEnter?.(e);
|
|
295
|
+
},
|
|
296
|
+
onMouseLeave: (e) => {
|
|
297
|
+
setActiveValue(null);
|
|
298
|
+
element.props.onMouseLeave?.(e);
|
|
299
|
+
incomingHandlers.onMouseLeave?.(e);
|
|
300
|
+
}
|
|
301
|
+
} : click ? { onClick: (e) => {
|
|
302
|
+
setActiveValue(childValue);
|
|
303
|
+
element.props.onClick?.(e);
|
|
304
|
+
incomingHandlers.onClick?.(e);
|
|
305
|
+
} } : {};
|
|
306
|
+
if (asChild) {
|
|
307
|
+
if (mode === "children") return React$1.cloneElement(element, {
|
|
308
|
+
key: childValue,
|
|
309
|
+
ref: refCallback,
|
|
310
|
+
className: cn("relative", element.props.className),
|
|
311
|
+
...getNonOverridingDataAttributes(element, {
|
|
312
|
+
...dataAttributes,
|
|
313
|
+
"data-slot": "motion-highlight-item-container"
|
|
314
|
+
}),
|
|
315
|
+
...commonHandlers,
|
|
316
|
+
...props
|
|
317
|
+
}, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
318
|
+
initial: false,
|
|
319
|
+
mode: "wait",
|
|
320
|
+
children: isActive && !isDisabled && /* @__PURE__ */ jsx(motion.div, {
|
|
321
|
+
layoutId: `transition-background-${contextId}`,
|
|
322
|
+
"data-slot": "motion-highlight",
|
|
323
|
+
style: {
|
|
324
|
+
position: "absolute",
|
|
325
|
+
zIndex: 0,
|
|
326
|
+
...contextStyle,
|
|
327
|
+
...style
|
|
328
|
+
},
|
|
329
|
+
className: cn(contextClassName, activeClassName),
|
|
330
|
+
transition: itemTransition,
|
|
331
|
+
initial: { opacity: 0 },
|
|
332
|
+
animate: { opacity: 1 },
|
|
333
|
+
exit: {
|
|
334
|
+
opacity: 0,
|
|
335
|
+
transition: {
|
|
336
|
+
...itemTransition,
|
|
337
|
+
delay: (itemTransition?.delay ?? 0) + (exitDelay ?? contextExitDelay ?? 0) / 1e3
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
...dataAttributes
|
|
341
|
+
})
|
|
342
|
+
}), /* @__PURE__ */ jsx(Component, {
|
|
343
|
+
"data-slot": "motion-highlight-item",
|
|
344
|
+
style: {
|
|
345
|
+
position: "relative",
|
|
346
|
+
zIndex: 1
|
|
347
|
+
},
|
|
348
|
+
className,
|
|
349
|
+
...dataAttributes,
|
|
350
|
+
children
|
|
351
|
+
})] }));
|
|
352
|
+
return React$1.cloneElement(element, {
|
|
353
|
+
ref: refCallback,
|
|
354
|
+
...getNonOverridingDataAttributes(element, {
|
|
355
|
+
...dataAttributes,
|
|
356
|
+
"data-slot": "motion-highlight-item"
|
|
357
|
+
}),
|
|
358
|
+
...commonHandlers
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return enabled ? /* @__PURE__ */ jsxs(Component, {
|
|
362
|
+
ref: localRef,
|
|
363
|
+
"data-slot": "motion-highlight-item-container",
|
|
364
|
+
className: cn(mode === "children" && "relative", className),
|
|
365
|
+
...dataAttributes,
|
|
366
|
+
...props,
|
|
367
|
+
...commonHandlers,
|
|
368
|
+
children: [mode === "children" && /* @__PURE__ */ jsx(AnimatePresence, {
|
|
369
|
+
initial: false,
|
|
370
|
+
mode: "wait",
|
|
371
|
+
children: isActive && !isDisabled && /* @__PURE__ */ jsx(motion.div, {
|
|
372
|
+
layoutId: `transition-background-${contextId}`,
|
|
373
|
+
"data-slot": "motion-highlight",
|
|
374
|
+
style: {
|
|
375
|
+
position: "absolute",
|
|
376
|
+
zIndex: 0,
|
|
377
|
+
...contextStyle,
|
|
378
|
+
...style
|
|
379
|
+
},
|
|
380
|
+
className: cn(contextClassName, activeClassName),
|
|
381
|
+
transition: itemTransition,
|
|
382
|
+
initial: { opacity: 0 },
|
|
383
|
+
animate: { opacity: 1 },
|
|
384
|
+
exit: {
|
|
385
|
+
opacity: 0,
|
|
386
|
+
transition: {
|
|
387
|
+
...itemTransition,
|
|
388
|
+
delay: (itemTransition?.delay ?? 0) + (exitDelay ?? contextExitDelay ?? 0) / 1e3
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
...dataAttributes
|
|
392
|
+
})
|
|
393
|
+
}), React$1.cloneElement(element, {
|
|
394
|
+
style: {
|
|
395
|
+
position: "relative",
|
|
396
|
+
zIndex: 1
|
|
397
|
+
},
|
|
398
|
+
className: element.props.className,
|
|
399
|
+
...getNonOverridingDataAttributes(element, {
|
|
400
|
+
...dataAttributes,
|
|
401
|
+
"data-slot": "motion-highlight-item"
|
|
402
|
+
})
|
|
403
|
+
})]
|
|
404
|
+
}, childValue) : children;
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
export { Highlight, HighlightItem, useHighlight };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { useControlledState } from "../../../hooks/use-controlled-state.js";
|
|
4
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Accordion } from "radix-ui";
|
|
8
|
+
//#region src/core/animate-ui/primitives/radix/accordion.tsx
|
|
9
|
+
var [AccordionProvider, useAccordion] = getStrictContext("AccordionContext");
|
|
10
|
+
var [AccordionItemProvider, useAccordionItem] = getStrictContext("AccordionItemContext");
|
|
11
|
+
function Accordion$1(props) {
|
|
12
|
+
const [value, setValue] = useControlledState({
|
|
13
|
+
value: props?.value,
|
|
14
|
+
defaultValue: props?.defaultValue,
|
|
15
|
+
onChange: props?.onValueChange
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ jsx(AccordionProvider, {
|
|
18
|
+
value: {
|
|
19
|
+
value,
|
|
20
|
+
setValue
|
|
21
|
+
},
|
|
22
|
+
children: /* @__PURE__ */ jsx(Accordion.Root, {
|
|
23
|
+
"data-slot": "accordion",
|
|
24
|
+
...props,
|
|
25
|
+
onValueChange: setValue
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function AccordionItem(props) {
|
|
30
|
+
const { value } = useAccordion();
|
|
31
|
+
const [isOpen, setIsOpen] = React$1.useState(value?.includes(props?.value) ?? false);
|
|
32
|
+
React$1.useEffect(() => {
|
|
33
|
+
setIsOpen(value?.includes(props?.value) ?? false);
|
|
34
|
+
}, [value, props?.value]);
|
|
35
|
+
return /* @__PURE__ */ jsx(AccordionItemProvider, {
|
|
36
|
+
value: {
|
|
37
|
+
value: props.value,
|
|
38
|
+
isOpen,
|
|
39
|
+
setIsOpen
|
|
40
|
+
},
|
|
41
|
+
children: /* @__PURE__ */ jsx(Accordion.Item, {
|
|
42
|
+
"data-slot": "accordion-item",
|
|
43
|
+
...props
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function AccordionHeader(props) {
|
|
48
|
+
return /* @__PURE__ */ jsx(Accordion.Header, {
|
|
49
|
+
"data-slot": "accordion-header",
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function AccordionTrigger(props) {
|
|
54
|
+
return /* @__PURE__ */ jsx(Accordion.Trigger, {
|
|
55
|
+
"data-slot": "accordion-trigger",
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function AccordionContent({ className: _, children, ...props }) {
|
|
60
|
+
const { isOpen } = useAccordionItem();
|
|
61
|
+
return /* @__PURE__ */ jsx(Accordion.Content, {
|
|
62
|
+
asChild: true,
|
|
63
|
+
forceMount: true,
|
|
64
|
+
"data-slot": "accordion-content",
|
|
65
|
+
...props,
|
|
66
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: cn("grid transition-[grid-template-rows,opacity] duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]", isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"),
|
|
68
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: "overflow-hidden",
|
|
70
|
+
children
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { Accordion$1 as Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, useAccordion, useAccordionItem };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControlledState } from "../../../hooks/use-controlled-state.js";
|
|
3
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Dialog } from "radix-ui";
|
|
7
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
8
|
+
//#region src/core/animate-ui/primitives/radix/dialog.tsx
|
|
9
|
+
var [DialogProvider, useDialog] = getStrictContext("DialogContext");
|
|
10
|
+
function Dialog$1(props) {
|
|
11
|
+
const [isOpen, setIsOpen] = useControlledState({
|
|
12
|
+
value: props?.open,
|
|
13
|
+
defaultValue: props?.defaultOpen,
|
|
14
|
+
onChange: props?.onOpenChange
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(DialogProvider, {
|
|
17
|
+
value: {
|
|
18
|
+
isOpen,
|
|
19
|
+
setIsOpen
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
22
|
+
"data-slot": "dialog",
|
|
23
|
+
...props,
|
|
24
|
+
onOpenChange: setIsOpen
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function DialogTrigger(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
30
|
+
"data-slot": "dialog-trigger",
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function DialogPortal(props) {
|
|
35
|
+
const { isOpen } = useDialog();
|
|
36
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(Dialog.Portal, {
|
|
37
|
+
"data-slot": "dialog-portal",
|
|
38
|
+
forceMount: true,
|
|
39
|
+
...props
|
|
40
|
+
}) });
|
|
41
|
+
}
|
|
42
|
+
function DialogOverlay({ transition = {
|
|
43
|
+
duration: .2,
|
|
44
|
+
ease: "easeInOut"
|
|
45
|
+
}, ...props }) {
|
|
46
|
+
return /* @__PURE__ */ jsx(Dialog.Overlay, {
|
|
47
|
+
"data-slot": "dialog-overlay",
|
|
48
|
+
asChild: true,
|
|
49
|
+
forceMount: true,
|
|
50
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
51
|
+
initial: {
|
|
52
|
+
opacity: 0,
|
|
53
|
+
filter: "blur(4px)"
|
|
54
|
+
},
|
|
55
|
+
animate: {
|
|
56
|
+
opacity: 1,
|
|
57
|
+
filter: "blur(0px)"
|
|
58
|
+
},
|
|
59
|
+
exit: {
|
|
60
|
+
opacity: 0,
|
|
61
|
+
filter: "blur(4px)"
|
|
62
|
+
},
|
|
63
|
+
transition,
|
|
64
|
+
...props
|
|
65
|
+
}, "dialog-overlay")
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function DialogContent({ from = "top", onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onInteractOutside, transition = {
|
|
69
|
+
type: "spring",
|
|
70
|
+
stiffness: 150,
|
|
71
|
+
damping: 25
|
|
72
|
+
}, ...props }) {
|
|
73
|
+
const initialRotation = from === "bottom" || from === "left" ? "20deg" : "-20deg";
|
|
74
|
+
const rotateAxis = from === "top" || from === "bottom" ? "rotateX" : "rotateY";
|
|
75
|
+
return /* @__PURE__ */ jsx(Dialog.Content, {
|
|
76
|
+
asChild: true,
|
|
77
|
+
forceMount: true,
|
|
78
|
+
onOpenAutoFocus,
|
|
79
|
+
onCloseAutoFocus,
|
|
80
|
+
onEscapeKeyDown,
|
|
81
|
+
onPointerDownOutside,
|
|
82
|
+
onInteractOutside,
|
|
83
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
84
|
+
"data-slot": "dialog-content",
|
|
85
|
+
initial: {
|
|
86
|
+
opacity: 0,
|
|
87
|
+
filter: "blur(4px)",
|
|
88
|
+
transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
|
|
89
|
+
},
|
|
90
|
+
animate: {
|
|
91
|
+
opacity: 1,
|
|
92
|
+
filter: "blur(0px)",
|
|
93
|
+
transform: `perspective(500px) ${rotateAxis}(0deg) scale(1)`
|
|
94
|
+
},
|
|
95
|
+
exit: {
|
|
96
|
+
opacity: 0,
|
|
97
|
+
filter: "blur(4px)",
|
|
98
|
+
transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`
|
|
99
|
+
},
|
|
100
|
+
transition,
|
|
101
|
+
...props
|
|
102
|
+
}, "dialog-content")
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function DialogClose(props) {
|
|
106
|
+
return /* @__PURE__ */ jsx(Dialog.Close, {
|
|
107
|
+
"data-slot": "dialog-close",
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function DialogHeader(props) {
|
|
112
|
+
return /* @__PURE__ */ jsx("div", {
|
|
113
|
+
"data-slot": "dialog-header",
|
|
114
|
+
...props
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function DialogFooter(props) {
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
"data-slot": "dialog-footer",
|
|
120
|
+
...props
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function DialogTitle(props) {
|
|
124
|
+
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
125
|
+
"data-slot": "dialog-title",
|
|
126
|
+
...props
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function DialogDescription(props) {
|
|
130
|
+
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
131
|
+
"data-slot": "dialog-description",
|
|
132
|
+
...props
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { Dialog$1 as Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, useDialog };
|