@espressif/dashboard-ui-components 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/dist/_vendor/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/_vendor/@radix-ui/react-checkbox/dist/index.js +185 -0
- package/dist/_vendor/@radix-ui/react-compose-refs/dist/index.js +28 -0
- package/dist/_vendor/@radix-ui/react-context/dist/index.js +68 -0
- package/dist/_vendor/@radix-ui/react-presence/dist/index.js +127 -0
- package/dist/_vendor/@radix-ui/react-primitive/dist/index.js +42 -0
- package/dist/_vendor/@radix-ui/react-use-controllable-state/dist/index.js +55 -0
- package/dist/_vendor/@radix-ui/react-use-layout-effect/dist/index.js +5 -0
- package/dist/_vendor/@radix-ui/react-use-previous/dist/index.js +17 -0
- package/dist/_vendor/@radix-ui/react-use-size/dist/index.js +39 -0
- package/dist/_vendor/lottie-react/build/index.es.js +537 -0
- package/dist/_vendor/lottie-web/build/player/lottie.js +14149 -0
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/assets/illustrations/bulb-cloud-drawing.js +4 -0
- package/dist/assets/illustrations/rm-dashboard-update.js +4 -0
- package/dist/assets/illustrations/rm-data-download.js +4 -0
- package/dist/assets/logos/espressif/espressif-no-text.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text-dm.js +4 -0
- package/dist/assets/logos/espressif/espressif-with-text.js +4 -0
- package/dist/assets/logos/insights/insights-no-text.js +4 -0
- package/dist/assets/logos/insights/insights-with-text-dm.js +4 -0
- package/dist/assets/logos/insights/insights-with-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-no-text.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text-dm.js +4 -0
- package/dist/assets/logos/launchpad/launchpad-with-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-no-text.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text-dm.js +4 -0
- package/dist/assets/logos/private-agents/private-agents-with-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-no-text.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker/rainmaker-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-classic/rainmaker-classic-with-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-no-text.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text-dm.js +4 -0
- package/dist/assets/logos/rainmaker-neo/rainmaker-neo-with-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-no-text.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text-dm.js +4 -0
- package/dist/assets/logos/ui-components/ui-components-with-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-no-text.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode/zerocode-with-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-no-text.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text-dm.js +4 -0
- package/dist/assets/logos/zerocode-ai/zerocode-ai-with-text.js +4 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.constants.js +18 -0
- package/dist/common/animated-rainmaker-logo/animated-rainmaker-logo.js +24 -0
- package/dist/common/animated-rainmaker-logo/rainmaker-c-logo.js +50 -0
- package/dist/common/animated-rainmaker-logo/use-animated-rainmaker-logo-animation.js +85 -0
- package/dist/common/app-logo/app-logo.js +59 -0
- package/dist/common/app-logo/logo-config.js +297 -0
- package/dist/common/copyright-card/copyright-card.js +39 -0
- package/dist/common/footer-card/footer-card.js +22 -0
- package/dist/common/index.js +8 -8
- package/dist/common/my-account-menu/my-account-menu.js +32 -0
- package/dist/common/page-loader/page-loader.js +21 -0
- package/dist/common/profile-card/profile-card.js +26 -0
- package/dist/components/accordion/accordion.js +52 -0
- package/dist/components/advanced-search-box/advanced-search-box.js +106 -0
- package/dist/components/alert/alert.js +85 -0
- package/dist/components/animated-containers/pop-collection-item.js +28 -0
- package/dist/components/async-multi-select/async-multi-select.js +199 -0
- package/dist/components/avatar/avatar.js +41 -0
- package/dist/components/button/button.js +191 -0
- package/dist/components/button/flash-button.js +110 -0
- package/dist/components/button/invert-button.js +13 -0
- package/dist/components/calendar/calendar.js +105 -0
- package/dist/components/cards/animated-card/animated-card-animations.js +57 -0
- package/dist/components/cards/animated-card/animated-card.js +42 -0
- package/dist/components/cards/basic-details-card.js +46 -0
- package/dist/components/cards/collapsible-card.js +48 -0
- package/dist/components/cards/no-data-card/no-data-card.js +30 -0
- package/dist/components/cards/section-card.js +265 -0
- package/dist/components/cards/simple-card.js +24 -0
- package/dist/components/carousel/carousel.js +158 -0
- package/dist/components/chart/area-chart.js +135 -0
- package/dist/components/chart/bar-chart.js +151 -0
- package/dist/components/chart/chart-colors.js +85 -0
- package/dist/components/chart/chart-series-data.js +53 -0
- package/dist/components/chart/chart.js +147 -0
- package/dist/components/chart/chart.types.js +7 -0
- package/dist/components/chart/composed-chart.js +182 -0
- package/dist/components/chart/donut-chart.js +177 -0
- package/dist/components/chart/line-chart.js +137 -0
- package/dist/components/chart/treemap-chart.js +294 -0
- package/dist/components/circular-progress/circular-progress.js +125 -0
- package/dist/components/code-editor/code-editor.js +235 -0
- package/dist/components/code-editor/code-editor.utils.js +122 -0
- package/dist/components/code-editor/use-code-editor-keys.js +79 -0
- package/dist/components/code-editor/use-highlighted-html.js +102 -0
- package/dist/components/confirmation-dialog/confirmation-dialog.js +72 -0
- package/dist/components/content-container/content-container.js +20 -0
- package/dist/components/copiable-text/copiable-text.js +46 -0
- package/dist/components/data-table/data-table.js +186 -0
- package/dist/components/data-table/responsive-columns.js +65 -0
- package/dist/components/data-table/row-actions.js +27 -0
- package/dist/components/data-table/sticky-columns.js +71 -0
- package/dist/components/data-table/table-body.js +57 -0
- package/dist/components/data-table/table-header.js +21 -0
- package/dist/components/date-picker/date-picker.js +95 -0
- package/dist/components/date-range-picker/date-range-picker.js +301 -0
- package/dist/components/date-range-picker/presets.js +174 -0
- package/dist/components/date-time-picker/date-time-picker.js +144 -0
- package/dist/components/date-time-picker/date-time-picker.utils.js +32 -0
- package/dist/components/device-icon/device-icon.config.js +194 -0
- package/dist/components/device-icon/device-icon.js +17 -0
- package/dist/components/device-icon/icons/air-conditioner.js +22 -0
- package/dist/components/device-icon/icons/blind.js +24 -0
- package/dist/components/device-icon/icons/dimmer.js +14 -0
- package/dist/components/device-icon/icons/extension-board.js +42 -0
- package/dist/components/device-icon/icons/fan.js +14 -0
- package/dist/components/device-icon/icons/knob.js +14 -0
- package/dist/components/device-icon/icons/led-strip.js +22 -0
- package/dist/components/device-icon/icons/light.js +14 -0
- package/dist/components/device-icon/icons/refrigerator.js +18 -0
- package/dist/components/device-icon/icons/retro-switch.js +18 -0
- package/dist/components/device-icon/icons/router.js +20 -0
- package/dist/components/device-icon/icons/sensor.js +20 -0
- package/dist/components/device-icon/icons/socket.js +19 -0
- package/dist/components/device-icon/icons/switch.js +19 -0
- package/dist/components/device-icon/icons/thermostat.js +21 -0
- package/dist/components/device-icon/icons/washing-machine.js +22 -0
- package/dist/components/device-icon/match-device.js +61 -0
- package/dist/components/dynamic-list/dynamic-list.js +445 -0
- package/dist/components/error-display/full-size-error/full-size-error.js +20 -0
- package/dist/components/error-display/inline-error/inline-error.js +12 -0
- package/dist/components/file-input/file-input.js +318 -0
- package/dist/components/file-upload/file-upload.js +317 -0
- package/dist/components/filters-bar/filters-bar.js +36 -0
- package/dist/components/fullscreen-dialog/fullscreen-dialog.js +68 -0
- package/dist/components/icon-avatar/icon-avatar.js +130 -0
- package/dist/components/icon-text-action-card/icon-text-action-card.js +190 -0
- package/dist/components/illustration/illustration-registry.js +37 -0
- package/dist/components/illustration/illustration-variants.js +21 -0
- package/dist/components/illustration/illustration.js +68 -0
- package/dist/components/index.d.ts +0 -20
- package/dist/components/index.js +134 -6
- package/dist/components/key-value-manager/key-value-manager-add-popover.js +126 -0
- package/dist/components/key-value-manager/key-value-manager-field.js +47 -0
- package/dist/components/key-value-manager/key-value-manager-table.js +188 -0
- package/dist/components/key-value-manager/key-value-manager.js +111 -0
- package/dist/components/key-value-manager/key-value-manager.props.js +28 -0
- package/dist/components/key-value-manager/key-value-manager.utils.js +21 -0
- package/dist/components/link/link.js +67 -0
- package/dist/components/list/dropdown-list-item.js +60 -0
- package/dist/components/list/list-item.utils.js +76 -0
- package/dist/components/list/list.js +49 -0
- package/dist/components/list/list.props.js +27 -0
- package/dist/components/list/standard-list-item.js +66 -0
- package/dist/components/list-details/list-details-item-button.js +46 -0
- package/dist/components/list-details/list-details-item-dropdown.js +112 -0
- package/dist/components/list-details/list-details-item-strip.js +125 -0
- package/dist/components/list-details/list-details.js +148 -0
- package/dist/components/lottie-animation-container/lottie-animation-container.js +31 -0
- package/dist/components/lottie-animations/animation-data/access-denied.js +3980 -0
- package/dist/components/lottie-animations/animation-data/active.js +825 -0
- package/dist/components/lottie-animations/animation-data/bar-chart.js +610 -0
- package/dist/components/lottie-animations/animation-data/chart-loading.js +5368 -0
- package/dist/components/lottie-animations/animation-data/cloud-download.js +1660 -0
- package/dist/components/lottie-animations/animation-data/cloud-sync.js +932 -0
- package/dist/components/lottie-animations/animation-data/coud-upload.js +7060 -0
- package/dist/components/lottie-animations/animation-data/cross-throb.js +1506 -0
- package/dist/components/lottie-animations/animation-data/dashboard-loading.js +14330 -0
- package/dist/components/lottie-animations/animation-data/error-spread-out.js +5567 -0
- package/dist/components/lottie-animations/animation-data/error.js +1211 -0
- package/dist/components/lottie-animations/animation-data/green-success.js +14826 -0
- package/dist/components/lottie-animations/animation-data/inactive.js +723 -0
- package/dist/components/lottie-animations/animation-data/light.js +2678 -0
- package/dist/components/lottie-animations/animation-data/lock.js +900 -0
- package/dist/components/lottie-animations/animation-data/lock2.js +1686 -0
- package/dist/components/lottie-animations/animation-data/locked.js +641 -0
- package/dist/components/lottie-animations/animation-data/search-error.js +954 -0
- package/dist/components/lottie-animations/animation-data/security.js +4121 -0
- package/dist/components/lottie-animations/animation-data/success.js +404 -0
- package/dist/components/lottie-animations/animation-data/verification-in-progress.js +10138 -0
- package/dist/components/lottie-animations/animation-data/warning.js +843 -0
- package/dist/components/lottie-animations/verification-in-progress/verification-in-progress.js +19 -0
- package/dist/components/markdown-content/markdown-content.components.js +114 -0
- package/dist/components/markdown-content/markdown-content.js +39 -0
- package/dist/components/menu/menu.js +19 -0
- package/dist/components/monospace-content/monospace-content.js +80 -0
- package/dist/components/nav-bar/nav-bar-details-panel.js +51 -0
- package/dist/components/nav-bar/nav-bar-mobile-menu.js +105 -0
- package/dist/components/nav-bar/nav-bar.js +449 -0
- package/dist/components/nav-bar/use-nav-bar-overflow.js +74 -0
- package/dist/components/nav-bar/use-nav-bar-scroll.js +42 -0
- package/dist/components/overflow-badge-list/overflow-badge-list.js +58 -0
- package/dist/components/page-container/page-container-skeleton.js +72 -0
- package/dist/components/page-container/page-container.js +93 -0
- package/dist/components/pagination/pagination.js +96 -0
- package/dist/components/pagination/pagination.props.js +16 -0
- package/dist/components/progress-bar/progress-bar.js +106 -0
- package/dist/components/radio-group/radio-group.js +41 -0
- package/dist/components/requirement-list/requirement-list.js +83 -0
- package/dist/components/scrollable-sections/scrollable-sections.js +270 -0
- package/dist/components/search-box/search-box.js +54 -0
- package/dist/components/search-field-shell.js +24 -0
- package/dist/components/selectable-card-list/checkbox-card-list.js +85 -0
- package/dist/components/selectable-card-list/radio-card-list.js +99 -0
- package/dist/components/selectable-card-list/selectable-card-list-shared.js +135 -0
- package/dist/components/selectable-card-list/selectable-card-list.js +34 -0
- package/dist/components/sidebar/sidebar.js +344 -0
- package/dist/components/sidebar/types.js +6 -0
- package/dist/components/simple-clickable-card/simple-clickable-card-shared.js +309 -0
- package/dist/components/simple-clickable-card/simple-clickable-card.js +106 -0
- package/dist/components/simple-info-card/simple-info-card.js +154 -0
- package/dist/components/simple-list/simple-list.js +146 -0
- package/dist/components/simple-paginated-list/simple-paginated-list.js +178 -0
- package/dist/components/simplified-date/simplified-date.js +56 -0
- package/dist/components/skeletons/table-skeleton.js +16 -0
- package/dist/components/spinner/spinner.js +25 -0
- package/dist/components/stat-card/stat-card.js +206 -0
- package/dist/components/status-badge/status-badge.js +108 -0
- package/dist/components/status-card-list/status-card-list.js +282 -0
- package/dist/components/tag/tag.js +144 -0
- package/dist/components/tag-input/tag-input.js +161 -0
- package/dist/components/text-effects/glitch-effect/glitch-text.js +115 -0
- package/dist/components/text-effects/gradient-text/gradient-text.js +32 -0
- package/dist/components/text-effects/highlight-text/highlight-text.js +35 -0
- package/dist/components/text-effects/parse-text-markup.js +53 -0
- package/dist/components/text-effects/shimmer-text/shimmer-text.js +67 -0
- package/dist/components/time-picker/time-picker.js +23 -0
- package/dist/components/toast/toast.js +126 -0
- package/dist/components/togglable-items-list/togglable-items-list.js +28 -0
- package/dist/components/tooltip/tooltip.js +21 -0
- package/dist/components/transfer-list/transfer-list.js +413 -0
- package/dist/components/truncated-line-with-tooltip/truncated-line-with-tooltip.js +61 -0
- package/dist/components/typography/typography-variants.js +41 -0
- package/dist/components/typography/typography.js +15 -0
- package/dist/components/user-type-badge/user-type-badge.js +40 -0
- package/dist/components/user-type-badge/user-type-badge.registry.js +17 -0
- package/dist/components/vertical-stepper/vertical-stepper.js +171 -0
- package/dist/core/alert.js +33 -0
- package/dist/core/animate-ui/components/animate/code-header.js +30 -0
- package/dist/core/animate-ui/components/animate/code.js +35 -0
- package/dist/core/animate-ui/components/animate/tabs.js +188 -0
- package/dist/core/animate-ui/components/animate/tooltip.js +39 -0
- package/dist/core/animate-ui/components/base/preview-card.js +29 -0
- package/dist/core/animate-ui/components/base/progress.js +32 -0
- package/dist/core/animate-ui/components/base/radio.js +24 -0
- package/dist/core/animate-ui/components/buttons/copy.js +95 -0
- package/dist/core/animate-ui/components/radix/accordion.js +36 -0
- package/dist/core/animate-ui/components/radix/dialog.js +60 -0
- package/dist/core/animate-ui/components/radix/dropdown-menu.js +129 -0
- package/dist/core/animate-ui/components/radix/sheet.js +110 -0
- package/dist/core/animate-ui/components/radix/sidebar.js +416 -0
- package/dist/core/animate-ui/components/radix/switch.js +34 -0
- package/dist/core/animate-ui/components/radix/toggle-group.js +115 -0
- package/dist/core/animate-ui/components/radix/toggle.js +24 -0
- package/dist/core/animate-ui/primitives/animate/code-block.js +131 -0
- package/dist/core/animate-ui/primitives/animate/escape-html.js +7 -0
- package/dist/core/animate-ui/primitives/animate/shiki-highlighter.js +64 -0
- package/dist/core/animate-ui/primitives/animate/slot.js +39 -0
- package/dist/core/animate-ui/primitives/animate/tabs.js +202 -0
- package/dist/core/animate-ui/primitives/animate/tooltip.js +351 -0
- package/dist/core/animate-ui/primitives/base/preview-card.js +107 -0
- package/dist/core/animate-ui/primitives/base/progress.js +60 -0
- package/dist/core/animate-ui/primitives/base/radio.js +83 -0
- package/dist/core/animate-ui/primitives/buttons/button.js +15 -0
- package/dist/core/animate-ui/primitives/effects/highlight.js +407 -0
- package/dist/core/animate-ui/primitives/radix/accordion.js +76 -0
- package/dist/core/animate-ui/primitives/radix/dialog.js +136 -0
- package/dist/core/animate-ui/primitives/radix/dropdown-menu.js +305 -0
- package/dist/core/animate-ui/primitives/radix/sheet.js +165 -0
- package/dist/core/animate-ui/primitives/radix/switch.js +86 -0
- package/dist/core/animate-ui/primitives/radix/toggle-group.js +100 -0
- package/dist/core/animate-ui/primitives/texts/counting-number.js +75 -0
- package/dist/core/avatar.js +32 -0
- package/dist/core/badge.js +27 -0
- package/dist/core/breadcrumb.js +62 -0
- package/dist/core/button/button.js +43 -0
- package/dist/core/button/craft-button.js +78 -0
- package/dist/core/button-group.js +38 -0
- package/dist/core/button.js +40 -0
- package/dist/core/card.js +42 -0
- package/dist/core/carousel/carousel.js +149 -0
- package/dist/core/checkbox/motion-checkbox.js +103 -0
- package/dist/core/collapsible.js +54 -0
- package/dist/core/combobox/combobox.js +85 -0
- package/dist/core/command.js +61 -0
- package/dist/core/field-end-icons.js +36 -0
- package/dist/core/field-label-row.js +33 -0
- package/dist/core/form.js +92 -0
- package/dist/core/hooks/use-controlled-state.js +27 -0
- package/dist/core/hooks/use-data-state.js +39 -0
- package/dist/core/hooks/use-is-in-view.js +18 -0
- package/dist/core/hooks/use-mobile.js +19 -0
- package/dist/core/hooks/use-reveal-on-scroll-up.js +141 -0
- package/dist/core/hooks/use-scroll-overflow.js +50 -0
- package/dist/core/index.js +18 -52
- package/dist/core/input/input-password.js +30 -0
- package/dist/core/input/input.js +147 -0
- package/dist/core/input-otp/input-otp.js +183 -0
- package/dist/core/label.js +15 -0
- package/dist/core/popover.js +31 -0
- package/dist/core/scroll-area.js +42 -0
- package/dist/core/select.js +121 -0
- package/dist/core/separator.js +40 -0
- package/dist/core/skeleton.js +11 -0
- package/dist/core/table.js +59 -0
- package/dist/core/textarea/textarea.js +97 -0
- package/dist/core/utils/get-strict-context.js +18 -0
- package/dist/index.js +148 -9
- package/dist/layouts/entry-layout/entry-layout-bg.js +4 -0
- package/dist/layouts/entry-layout/entry-layout.js +52 -0
- package/dist/layouts/index.js +7 -6
- package/dist/layouts/workspace-layout/account-menu/account-menu.js +108 -0
- package/dist/layouts/workspace-layout/breadcrumbs/derive-breadcrumbs.js +37 -0
- package/dist/layouts/workspace-layout/breadcrumbs/workspace-breadcrumbs.js +22 -0
- package/dist/layouts/workspace-layout/footer/footer.js +15 -0
- package/dist/layouts/workspace-layout/header/header.js +54 -0
- package/dist/layouts/workspace-layout/workspace-layout.js +157 -0
- package/dist/tailwind-preset.js +3 -4
- package/dist/utils/cn.js +8 -0
- package/dist/utils/color.js +72 -0
- package/dist/utils/index.js +3 -2
- package/dist/utils/path-match.js +17 -0
- package/dist/utils/silver-shine.js +63 -0
- package/dist/utils/variant-gradient-underlay.js +45 -0
- package/dist/utils/variant.js +426 -0
- package/package.json +7 -4
- package/dist/chunk-2GDYZAKR.js +0 -505
- package/dist/chunk-ALCWXFUC.js +0 -733
- package/dist/chunk-CDHBLANU.js +0 -59
- package/dist/chunk-LUESSJAF.js +0 -70068
- package/dist/chunk-TMORRNEB.js +0 -323
- package/dist/chunk-TRTQSARU.js +0 -31
- package/dist/chunk-VU4CZ76T.js +0 -43
- package/dist/chunk-XNLCVHBC.js +0 -364
- package/dist/chunk-Z4776NRY.js +0 -4347
- package/src/assets/illustrations/add-to-group.svg +0 -32
- package/src/assets/illustrations/chip.svg +0 -51
- package/src/assets/illustrations/create-new-group.svg +0 -27
- package/src/assets/illustrations/new-ota.svg +0 -61
- package/src/assets/illustrations/secured-key.svg +0 -48
- /package/dist/assets/{entry-layout-bg-JPI7GJ42.webp → entry-layout-bg-DUM0UhT3.webp} +0 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControlledState } from "../../../hooks/use-controlled-state.js";
|
|
3
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
4
|
+
import { Highlight, HighlightItem } from "../effects/highlight.js";
|
|
5
|
+
import { useDataState } from "../../../hooks/use-data-state.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { DropdownMenu } from "radix-ui";
|
|
9
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
10
|
+
//#region src/core/animate-ui/primitives/radix/dropdown-menu.tsx
|
|
11
|
+
var [DropdownMenuProvider, useDropdownMenu] = getStrictContext("DropdownMenuContext");
|
|
12
|
+
var [DropdownMenuSubProvider, useDropdownMenuSub] = getStrictContext("DropdownMenuSubContext");
|
|
13
|
+
function DropdownMenu$1(props) {
|
|
14
|
+
const [isOpen, setIsOpen] = useControlledState({
|
|
15
|
+
value: props?.open,
|
|
16
|
+
defaultValue: props?.defaultOpen,
|
|
17
|
+
onChange: props?.onOpenChange
|
|
18
|
+
});
|
|
19
|
+
const [highlightedValue, setHighlightedValue] = React$1.useState(null);
|
|
20
|
+
return /* @__PURE__ */ jsx(DropdownMenuProvider, {
|
|
21
|
+
value: {
|
|
22
|
+
isOpen,
|
|
23
|
+
setIsOpen,
|
|
24
|
+
highlightedValue,
|
|
25
|
+
setHighlightedValue
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Root, {
|
|
28
|
+
"data-slot": "dropdown-menu",
|
|
29
|
+
...props,
|
|
30
|
+
onOpenChange: setIsOpen
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function DropdownMenuTrigger(props) {
|
|
35
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Trigger, {
|
|
36
|
+
"data-slot": "dropdown-menu-trigger",
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function DropdownMenuPortal(props) {
|
|
41
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Portal, {
|
|
42
|
+
"data-slot": "dropdown-menu-portal",
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function DropdownMenuGroup(props) {
|
|
47
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Group, {
|
|
48
|
+
"data-slot": "dropdown-menu-group",
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function DropdownMenuSub(props) {
|
|
53
|
+
const [isOpen, setIsOpen] = useControlledState({
|
|
54
|
+
value: props?.open,
|
|
55
|
+
defaultValue: props?.defaultOpen,
|
|
56
|
+
onChange: props?.onOpenChange
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ jsx(DropdownMenuSubProvider, {
|
|
59
|
+
value: {
|
|
60
|
+
isOpen,
|
|
61
|
+
setIsOpen
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Sub, {
|
|
64
|
+
"data-slot": "dropdown-menu-sub",
|
|
65
|
+
...props,
|
|
66
|
+
onOpenChange: setIsOpen
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function DropdownMenuRadioGroup(props) {
|
|
71
|
+
return /* @__PURE__ */ jsx(DropdownMenu.RadioGroup, {
|
|
72
|
+
"data-slot": "dropdown-menu-radio-group",
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function DropdownMenuSubTrigger({ disabled, textValue, ...props }) {
|
|
77
|
+
const { setHighlightedValue } = useDropdownMenu();
|
|
78
|
+
const [, highlightedRef] = useDataState("highlighted", void 0, (value) => {
|
|
79
|
+
if (value === true) {
|
|
80
|
+
const el = highlightedRef.current;
|
|
81
|
+
const v = el?.dataset.value || el?.id || null;
|
|
82
|
+
if (v) setHighlightedValue(v);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return /* @__PURE__ */ jsx(DropdownMenu.SubTrigger, {
|
|
86
|
+
ref: highlightedRef,
|
|
87
|
+
disabled,
|
|
88
|
+
textValue,
|
|
89
|
+
asChild: true,
|
|
90
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
91
|
+
"data-slot": "dropdown-menu-sub-trigger",
|
|
92
|
+
"data-disabled": disabled,
|
|
93
|
+
...props
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function DropdownMenuSubContent({ loop, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, sideOffset, alignOffset, avoidCollisions, collisionBoundary, collisionPadding, arrowPadding, sticky, hideWhenDetached, transition = { duration: .2 }, style, container, ...props }) {
|
|
98
|
+
const { isOpen } = useDropdownMenuSub();
|
|
99
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(DropdownMenuPortal, {
|
|
100
|
+
forceMount: true,
|
|
101
|
+
container,
|
|
102
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.SubContent, {
|
|
103
|
+
asChild: true,
|
|
104
|
+
forceMount: true,
|
|
105
|
+
loop,
|
|
106
|
+
onEscapeKeyDown,
|
|
107
|
+
onPointerDownOutside,
|
|
108
|
+
onFocusOutside,
|
|
109
|
+
onInteractOutside,
|
|
110
|
+
sideOffset,
|
|
111
|
+
alignOffset,
|
|
112
|
+
avoidCollisions,
|
|
113
|
+
collisionBoundary,
|
|
114
|
+
collisionPadding,
|
|
115
|
+
arrowPadding,
|
|
116
|
+
sticky,
|
|
117
|
+
hideWhenDetached,
|
|
118
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
119
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
120
|
+
initial: {
|
|
121
|
+
opacity: 0,
|
|
122
|
+
scale: .95
|
|
123
|
+
},
|
|
124
|
+
animate: {
|
|
125
|
+
opacity: 1,
|
|
126
|
+
scale: 1
|
|
127
|
+
},
|
|
128
|
+
exit: {
|
|
129
|
+
opacity: 0,
|
|
130
|
+
scale: .95
|
|
131
|
+
},
|
|
132
|
+
transition,
|
|
133
|
+
style: {
|
|
134
|
+
willChange: "opacity, transform",
|
|
135
|
+
...style
|
|
136
|
+
},
|
|
137
|
+
...props
|
|
138
|
+
}, "dropdown-menu-sub-content")
|
|
139
|
+
})
|
|
140
|
+
}) });
|
|
141
|
+
}
|
|
142
|
+
function DropdownMenuHighlight({ transition = {
|
|
143
|
+
type: "spring",
|
|
144
|
+
stiffness: 350,
|
|
145
|
+
damping: 35
|
|
146
|
+
}, ...props }) {
|
|
147
|
+
const { highlightedValue } = useDropdownMenu();
|
|
148
|
+
return /* @__PURE__ */ jsx(Highlight, {
|
|
149
|
+
"data-slot": "dropdown-menu-highlight",
|
|
150
|
+
click: false,
|
|
151
|
+
controlledItems: true,
|
|
152
|
+
transition,
|
|
153
|
+
value: highlightedValue,
|
|
154
|
+
...props
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function DropdownMenuContent({ loop, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, side, sideOffset, align, alignOffset, avoidCollisions, collisionBoundary, collisionPadding, arrowPadding, sticky, hideWhenDetached, transition = { duration: .2 }, style, container, ...props }) {
|
|
158
|
+
const { isOpen } = useDropdownMenu();
|
|
159
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(DropdownMenuPortal, {
|
|
160
|
+
forceMount: true,
|
|
161
|
+
container,
|
|
162
|
+
children: /* @__PURE__ */ jsx(DropdownMenu.Content, {
|
|
163
|
+
asChild: true,
|
|
164
|
+
loop,
|
|
165
|
+
onCloseAutoFocus,
|
|
166
|
+
onEscapeKeyDown,
|
|
167
|
+
onPointerDownOutside,
|
|
168
|
+
onFocusOutside,
|
|
169
|
+
onInteractOutside,
|
|
170
|
+
side,
|
|
171
|
+
sideOffset,
|
|
172
|
+
align,
|
|
173
|
+
alignOffset,
|
|
174
|
+
avoidCollisions,
|
|
175
|
+
collisionBoundary,
|
|
176
|
+
collisionPadding,
|
|
177
|
+
arrowPadding,
|
|
178
|
+
sticky,
|
|
179
|
+
hideWhenDetached,
|
|
180
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
181
|
+
"data-slot": "dropdown-menu-content",
|
|
182
|
+
initial: {
|
|
183
|
+
opacity: 0,
|
|
184
|
+
scale: .95
|
|
185
|
+
},
|
|
186
|
+
animate: {
|
|
187
|
+
opacity: 1,
|
|
188
|
+
scale: 1
|
|
189
|
+
},
|
|
190
|
+
exit: {
|
|
191
|
+
opacity: 0,
|
|
192
|
+
scale: .95
|
|
193
|
+
},
|
|
194
|
+
transition,
|
|
195
|
+
style: {
|
|
196
|
+
willChange: "opacity, transform",
|
|
197
|
+
...style
|
|
198
|
+
},
|
|
199
|
+
...props
|
|
200
|
+
}, "dropdown-menu-content")
|
|
201
|
+
})
|
|
202
|
+
}) });
|
|
203
|
+
}
|
|
204
|
+
function DropdownMenuHighlightItem(props) {
|
|
205
|
+
return /* @__PURE__ */ jsx(HighlightItem, {
|
|
206
|
+
"data-slot": "dropdown-menu-highlight-item",
|
|
207
|
+
...props
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function DropdownMenuItem({ disabled, onSelect, textValue, ...props }) {
|
|
211
|
+
const { setHighlightedValue } = useDropdownMenu();
|
|
212
|
+
const [, highlightedRef] = useDataState("highlighted", void 0, (value) => {
|
|
213
|
+
if (value === true) {
|
|
214
|
+
const el = highlightedRef.current;
|
|
215
|
+
const v = el?.dataset.value || el?.id || null;
|
|
216
|
+
if (v) setHighlightedValue(v);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Item, {
|
|
220
|
+
ref: highlightedRef,
|
|
221
|
+
disabled,
|
|
222
|
+
onSelect,
|
|
223
|
+
textValue,
|
|
224
|
+
asChild: true,
|
|
225
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
226
|
+
"data-slot": "dropdown-menu-item",
|
|
227
|
+
"data-disabled": disabled,
|
|
228
|
+
...props
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function DropdownMenuCheckboxItem({ checked, onCheckedChange, disabled, onSelect, textValue, ...props }) {
|
|
233
|
+
const { setHighlightedValue } = useDropdownMenu();
|
|
234
|
+
const [, highlightedRef] = useDataState("highlighted", void 0, (value) => {
|
|
235
|
+
if (value === true) {
|
|
236
|
+
const el = highlightedRef.current;
|
|
237
|
+
const v = el?.dataset.value || el?.id || null;
|
|
238
|
+
if (v) setHighlightedValue(v);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return /* @__PURE__ */ jsx(DropdownMenu.CheckboxItem, {
|
|
242
|
+
ref: highlightedRef,
|
|
243
|
+
checked,
|
|
244
|
+
onCheckedChange,
|
|
245
|
+
disabled,
|
|
246
|
+
onSelect,
|
|
247
|
+
textValue,
|
|
248
|
+
asChild: true,
|
|
249
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
250
|
+
"data-slot": "dropdown-menu-checkbox-item",
|
|
251
|
+
"data-disabled": disabled,
|
|
252
|
+
...props
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function DropdownMenuRadioItem({ value, disabled, onSelect, textValue, ...props }) {
|
|
257
|
+
const { setHighlightedValue } = useDropdownMenu();
|
|
258
|
+
const [, highlightedRef] = useDataState("highlighted", void 0, (value) => {
|
|
259
|
+
if (value === true) {
|
|
260
|
+
const el = highlightedRef.current;
|
|
261
|
+
const v = el?.dataset.value || el?.id || null;
|
|
262
|
+
if (v) setHighlightedValue(v);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return /* @__PURE__ */ jsx(DropdownMenu.RadioItem, {
|
|
266
|
+
ref: highlightedRef,
|
|
267
|
+
value,
|
|
268
|
+
disabled,
|
|
269
|
+
onSelect,
|
|
270
|
+
textValue,
|
|
271
|
+
asChild: true,
|
|
272
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
273
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
274
|
+
"data-disabled": disabled,
|
|
275
|
+
...props
|
|
276
|
+
})
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function DropdownMenuLabel(props) {
|
|
280
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Label, {
|
|
281
|
+
"data-slot": "dropdown-menu-label",
|
|
282
|
+
...props
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function DropdownMenuSeparator(props) {
|
|
286
|
+
return /* @__PURE__ */ jsx(DropdownMenu.Separator, {
|
|
287
|
+
"data-slot": "dropdown-menu-separator",
|
|
288
|
+
...props
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function DropdownMenuShortcut(props) {
|
|
292
|
+
return /* @__PURE__ */ jsx("span", {
|
|
293
|
+
"data-slot": "dropdown-menu-shortcut",
|
|
294
|
+
...props
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function DropdownMenuItemIndicator(props) {
|
|
298
|
+
return /* @__PURE__ */ jsx(DropdownMenu.ItemIndicator, {
|
|
299
|
+
"data-slot": "dropdown-menu-item-indicator",
|
|
300
|
+
asChild: true,
|
|
301
|
+
children: /* @__PURE__ */ jsx(motion.div, { ...props })
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
export { DropdownMenu$1 as DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuHighlight, DropdownMenuHighlightItem, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, useDropdownMenu, useDropdownMenuSub };
|
|
@@ -0,0 +1,165 @@
|
|
|
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/sheet.tsx
|
|
9
|
+
var [SheetProvider, useSheet] = getStrictContext("SheetContext");
|
|
10
|
+
function Sheet(props) {
|
|
11
|
+
const [isOpen, setIsOpen] = useControlledState({
|
|
12
|
+
value: props.open,
|
|
13
|
+
defaultValue: props.defaultOpen,
|
|
14
|
+
onChange: props.onOpenChange
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(SheetProvider, {
|
|
17
|
+
value: {
|
|
18
|
+
isOpen,
|
|
19
|
+
setIsOpen
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ jsx(Dialog.Root, {
|
|
22
|
+
"data-slot": "sheet",
|
|
23
|
+
...props,
|
|
24
|
+
onOpenChange: setIsOpen
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function SheetTrigger(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
30
|
+
"data-slot": "sheet-trigger",
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function SheetClose(props) {
|
|
35
|
+
return /* @__PURE__ */ jsx(Dialog.Close, {
|
|
36
|
+
"data-slot": "sheet-close",
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function SheetPortal(props) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, {
|
|
42
|
+
forceMount: true,
|
|
43
|
+
"data-slot": "sheet-portal",
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function SheetOverlay({ transition = {
|
|
48
|
+
duration: .2,
|
|
49
|
+
ease: "easeInOut"
|
|
50
|
+
}, ...props }) {
|
|
51
|
+
const { isOpen } = useSheet();
|
|
52
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(Dialog.Overlay, {
|
|
53
|
+
asChild: true,
|
|
54
|
+
forceMount: true,
|
|
55
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
56
|
+
"data-slot": "sheet-overlay",
|
|
57
|
+
initial: {
|
|
58
|
+
opacity: 0,
|
|
59
|
+
filter: "blur(4px)"
|
|
60
|
+
},
|
|
61
|
+
animate: {
|
|
62
|
+
opacity: 1,
|
|
63
|
+
filter: "blur(0px)"
|
|
64
|
+
},
|
|
65
|
+
exit: {
|
|
66
|
+
opacity: 0,
|
|
67
|
+
filter: "blur(4px)"
|
|
68
|
+
},
|
|
69
|
+
transition,
|
|
70
|
+
...props
|
|
71
|
+
}, "sheet-overlay")
|
|
72
|
+
}) });
|
|
73
|
+
}
|
|
74
|
+
function SheetContent({ side = "right", transition = {
|
|
75
|
+
type: "spring",
|
|
76
|
+
stiffness: 150,
|
|
77
|
+
damping: 22
|
|
78
|
+
}, style, children, ...props }) {
|
|
79
|
+
const { isOpen } = useSheet();
|
|
80
|
+
const axis = side === "left" || side === "right" ? "x" : "y";
|
|
81
|
+
const offscreen = {
|
|
82
|
+
right: {
|
|
83
|
+
x: "100%",
|
|
84
|
+
opacity: 0
|
|
85
|
+
},
|
|
86
|
+
left: {
|
|
87
|
+
x: "-100%",
|
|
88
|
+
opacity: 0
|
|
89
|
+
},
|
|
90
|
+
top: {
|
|
91
|
+
y: "-100%",
|
|
92
|
+
opacity: 0
|
|
93
|
+
},
|
|
94
|
+
bottom: {
|
|
95
|
+
y: "100%",
|
|
96
|
+
opacity: 0
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const positionStyle = {
|
|
100
|
+
right: {
|
|
101
|
+
insetBlock: 0,
|
|
102
|
+
right: 0
|
|
103
|
+
},
|
|
104
|
+
left: {
|
|
105
|
+
insetBlock: 0,
|
|
106
|
+
left: 0
|
|
107
|
+
},
|
|
108
|
+
top: {
|
|
109
|
+
insetInline: 0,
|
|
110
|
+
top: 0
|
|
111
|
+
},
|
|
112
|
+
bottom: {
|
|
113
|
+
insetInline: 0,
|
|
114
|
+
bottom: 0
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(Dialog.Content, {
|
|
118
|
+
asChild: true,
|
|
119
|
+
forceMount: true,
|
|
120
|
+
...props,
|
|
121
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
122
|
+
"data-slot": "sheet-content",
|
|
123
|
+
"data-side": side,
|
|
124
|
+
initial: offscreen[side],
|
|
125
|
+
animate: {
|
|
126
|
+
[axis]: 0,
|
|
127
|
+
opacity: 1
|
|
128
|
+
},
|
|
129
|
+
exit: offscreen[side],
|
|
130
|
+
style: {
|
|
131
|
+
position: "fixed",
|
|
132
|
+
...positionStyle[side],
|
|
133
|
+
...style
|
|
134
|
+
},
|
|
135
|
+
transition,
|
|
136
|
+
children
|
|
137
|
+
}, "sheet-content")
|
|
138
|
+
}) });
|
|
139
|
+
}
|
|
140
|
+
function SheetHeader(props) {
|
|
141
|
+
return /* @__PURE__ */ jsx("div", {
|
|
142
|
+
"data-slot": "sheet-header",
|
|
143
|
+
...props
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function SheetFooter(props) {
|
|
147
|
+
return /* @__PURE__ */ jsx("div", {
|
|
148
|
+
"data-slot": "sheet-footer",
|
|
149
|
+
...props
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function SheetTitle(props) {
|
|
153
|
+
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
154
|
+
"data-slot": "sheet-title",
|
|
155
|
+
...props
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function SheetDescription(props) {
|
|
159
|
+
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
160
|
+
"data-slot": "sheet-description",
|
|
161
|
+
...props
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, useSheet };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControlledState } from "../../../hooks/use-controlled-state.js";
|
|
3
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Switch } from "radix-ui";
|
|
7
|
+
import { motion } from "motion/react";
|
|
8
|
+
//#region src/core/animate-ui/primitives/radix/switch.tsx
|
|
9
|
+
var [SwitchProvider, useSwitch] = getStrictContext("SwitchContext");
|
|
10
|
+
function Switch$1(props) {
|
|
11
|
+
const [isPressed, setIsPressed] = React$1.useState(false);
|
|
12
|
+
const { checked, defaultChecked, onCheckedChange, children, ...rootProps } = props;
|
|
13
|
+
const [isChecked, setIsChecked] = useControlledState({
|
|
14
|
+
value: checked,
|
|
15
|
+
defaultValue: defaultChecked,
|
|
16
|
+
onChange: onCheckedChange
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ jsx(SwitchProvider, {
|
|
19
|
+
value: {
|
|
20
|
+
isChecked,
|
|
21
|
+
setIsChecked,
|
|
22
|
+
isPressed,
|
|
23
|
+
setIsPressed
|
|
24
|
+
},
|
|
25
|
+
children: /* @__PURE__ */ jsx(Switch.Root, {
|
|
26
|
+
checked,
|
|
27
|
+
defaultChecked,
|
|
28
|
+
onCheckedChange: setIsChecked,
|
|
29
|
+
asChild: true,
|
|
30
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
31
|
+
"data-slot": "switch",
|
|
32
|
+
whileTap: "tap",
|
|
33
|
+
initial: false,
|
|
34
|
+
onTapStart: () => setIsPressed(true),
|
|
35
|
+
onTapCancel: () => setIsPressed(false),
|
|
36
|
+
onTap: () => setIsPressed(false),
|
|
37
|
+
...rootProps,
|
|
38
|
+
children
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function SwitchThumb({ pressedAnimation, transition = {
|
|
44
|
+
type: "spring",
|
|
45
|
+
stiffness: 300,
|
|
46
|
+
damping: 25
|
|
47
|
+
}, ...props }) {
|
|
48
|
+
const { isPressed } = useSwitch();
|
|
49
|
+
return /* @__PURE__ */ jsx(Switch.Thumb, {
|
|
50
|
+
asChild: true,
|
|
51
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
52
|
+
"data-slot": "switch-thumb",
|
|
53
|
+
whileTap: "tab",
|
|
54
|
+
layout: true,
|
|
55
|
+
transition,
|
|
56
|
+
animate: isPressed ? pressedAnimation : void 0,
|
|
57
|
+
...props
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function SwitchIcon({ position, transition = {
|
|
62
|
+
type: "spring",
|
|
63
|
+
bounce: 0
|
|
64
|
+
}, ...props }) {
|
|
65
|
+
const { isChecked } = useSwitch();
|
|
66
|
+
const isAnimated = React$1.useMemo(() => {
|
|
67
|
+
if (position === "right") return !isChecked;
|
|
68
|
+
if (position === "left") return isChecked;
|
|
69
|
+
if (position === "thumb") return true;
|
|
70
|
+
return false;
|
|
71
|
+
}, [position, isChecked]);
|
|
72
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
73
|
+
"data-slot": `switch-${position}-icon`,
|
|
74
|
+
animate: isAnimated ? {
|
|
75
|
+
scale: 1,
|
|
76
|
+
opacity: 1
|
|
77
|
+
} : {
|
|
78
|
+
scale: 0,
|
|
79
|
+
opacity: 0
|
|
80
|
+
},
|
|
81
|
+
transition,
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { Switch$1 as Switch, SwitchIcon, SwitchThumb, useSwitch };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControlledState } from "../../../hooks/use-controlled-state.js";
|
|
3
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
4
|
+
import { Highlight, HighlightItem } from "../effects/highlight.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ToggleGroup } from "radix-ui";
|
|
8
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
9
|
+
//#region src/core/animate-ui/primitives/radix/toggle-group.tsx
|
|
10
|
+
var [ToggleGroupProvider, useToggleGroup] = getStrictContext("ToggleGroupContext");
|
|
11
|
+
function ToggleGroup$1(props) {
|
|
12
|
+
const [value, setValue] = useControlledState({
|
|
13
|
+
value: props.value,
|
|
14
|
+
defaultValue: props.defaultValue,
|
|
15
|
+
onChange: props.onValueChange
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ jsx(ToggleGroupProvider, {
|
|
18
|
+
value: {
|
|
19
|
+
value,
|
|
20
|
+
setValue,
|
|
21
|
+
type: props.type
|
|
22
|
+
},
|
|
23
|
+
children: /* @__PURE__ */ jsx(ToggleGroup.Root, {
|
|
24
|
+
"data-slot": "toggle-group",
|
|
25
|
+
...props,
|
|
26
|
+
onValueChange: setValue
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function ToggleGroupItem({ value, disabled, ...props }) {
|
|
31
|
+
return /* @__PURE__ */ jsx(ToggleGroup.Item, {
|
|
32
|
+
value,
|
|
33
|
+
disabled,
|
|
34
|
+
asChild: true,
|
|
35
|
+
children: /* @__PURE__ */ jsx(motion.button, {
|
|
36
|
+
"data-slot": "toggle-group-item",
|
|
37
|
+
whileTap: { scale: .95 },
|
|
38
|
+
...props
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function ToggleGroupHighlight({ transition = {
|
|
43
|
+
type: "spring",
|
|
44
|
+
stiffness: 200,
|
|
45
|
+
damping: 25
|
|
46
|
+
}, ...props }) {
|
|
47
|
+
const { value } = useToggleGroup();
|
|
48
|
+
return /* @__PURE__ */ jsx(Highlight, {
|
|
49
|
+
"data-slot": "toggle-group-highlight",
|
|
50
|
+
controlledItems: true,
|
|
51
|
+
value: typeof value === "string" ? value : null,
|
|
52
|
+
exitDelay: 0,
|
|
53
|
+
transition,
|
|
54
|
+
...props
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function ToggleGroupHighlightItem({ children, style, ...props }) {
|
|
58
|
+
const { type, value } = useToggleGroup();
|
|
59
|
+
if (type === "single") return /* @__PURE__ */ jsx(HighlightItem, {
|
|
60
|
+
"data-slot": "toggle-group-highlight-item",
|
|
61
|
+
style: {
|
|
62
|
+
inset: 0,
|
|
63
|
+
...style
|
|
64
|
+
},
|
|
65
|
+
...props,
|
|
66
|
+
children
|
|
67
|
+
});
|
|
68
|
+
if (type === "multiple" && React$1.isValidElement(children)) {
|
|
69
|
+
const isActive = props.value && value && value.includes(props.value);
|
|
70
|
+
const element = children;
|
|
71
|
+
return React$1.cloneElement(children, {
|
|
72
|
+
style: {
|
|
73
|
+
...element.props.style,
|
|
74
|
+
position: "relative"
|
|
75
|
+
},
|
|
76
|
+
...element.props
|
|
77
|
+
}, /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AnimatePresence, { children: isActive && /* @__PURE__ */ jsx(motion.div, {
|
|
78
|
+
"data-slot": "toggle-group-highlight-item",
|
|
79
|
+
style: {
|
|
80
|
+
position: "absolute",
|
|
81
|
+
inset: 0,
|
|
82
|
+
zIndex: 0,
|
|
83
|
+
...style
|
|
84
|
+
},
|
|
85
|
+
initial: { opacity: 0 },
|
|
86
|
+
animate: { opacity: 1 },
|
|
87
|
+
exit: { opacity: 0 },
|
|
88
|
+
...props
|
|
89
|
+
}) }), /* @__PURE__ */ jsx("div", {
|
|
90
|
+
style: {
|
|
91
|
+
position: "relative",
|
|
92
|
+
zIndex: 1
|
|
93
|
+
},
|
|
94
|
+
children: element.props.children
|
|
95
|
+
})] }));
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { ToggleGroup$1 as ToggleGroup, ToggleGroupHighlight, ToggleGroupHighlightItem, ToggleGroupItem, useToggleGroup };
|