@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,351 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
3
|
+
import { Slot } from "./slot.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { AnimatePresence, LayoutGroup, motion } from "motion/react";
|
|
7
|
+
import { FloatingArrow, FloatingPortal, arrow, autoUpdate, flip, offset, shift, useFloating } from "@floating-ui/react";
|
|
8
|
+
//#region src/core/animate-ui/primitives/animate/tooltip.tsx
|
|
9
|
+
var [GlobalTooltipProvider, useGlobalTooltip] = getStrictContext("GlobalTooltipProvider");
|
|
10
|
+
var [LocalTooltipProvider, useTooltip] = getStrictContext("LocalTooltipProvider");
|
|
11
|
+
function getResolvedSide(placement) {
|
|
12
|
+
if (placement.includes("-")) return placement.split("-")[0];
|
|
13
|
+
return placement;
|
|
14
|
+
}
|
|
15
|
+
function initialFromSide(side) {
|
|
16
|
+
if (side === "top") return { y: 15 };
|
|
17
|
+
if (side === "bottom") return { y: -15 };
|
|
18
|
+
if (side === "left") return { x: 15 };
|
|
19
|
+
return { x: -15 };
|
|
20
|
+
}
|
|
21
|
+
function TooltipProvider({ children, id, openDelay = 700, closeDelay = 300, transition = {
|
|
22
|
+
type: "spring",
|
|
23
|
+
stiffness: 300,
|
|
24
|
+
damping: 35
|
|
25
|
+
} }) {
|
|
26
|
+
const globalId = React$1.useId();
|
|
27
|
+
const [currentTooltip, setCurrentTooltip] = React$1.useState(null);
|
|
28
|
+
const timeoutRef = React$1.useRef(null);
|
|
29
|
+
const lastCloseTimeRef = React$1.useRef(0);
|
|
30
|
+
const referenceElRef = React$1.useRef(null);
|
|
31
|
+
const showTooltip = React$1.useCallback((data) => {
|
|
32
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
33
|
+
if (currentTooltip !== null) {
|
|
34
|
+
setCurrentTooltip(data);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const delay = Date.now() - lastCloseTimeRef.current < closeDelay ? 0 : openDelay;
|
|
38
|
+
timeoutRef.current = window.setTimeout(() => setCurrentTooltip(data), delay);
|
|
39
|
+
}, [
|
|
40
|
+
openDelay,
|
|
41
|
+
closeDelay,
|
|
42
|
+
currentTooltip
|
|
43
|
+
]);
|
|
44
|
+
const hideTooltip = React$1.useCallback(() => {
|
|
45
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
46
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
47
|
+
setCurrentTooltip(null);
|
|
48
|
+
lastCloseTimeRef.current = Date.now();
|
|
49
|
+
}, closeDelay);
|
|
50
|
+
}, [closeDelay]);
|
|
51
|
+
const hideImmediate = React$1.useCallback(() => {
|
|
52
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
53
|
+
setCurrentTooltip(null);
|
|
54
|
+
lastCloseTimeRef.current = Date.now();
|
|
55
|
+
}, []);
|
|
56
|
+
const setReferenceEl = React$1.useCallback((el) => {
|
|
57
|
+
referenceElRef.current = el;
|
|
58
|
+
}, []);
|
|
59
|
+
React$1.useEffect(() => {
|
|
60
|
+
const onKeyDown = (e) => {
|
|
61
|
+
if (e.key === "Escape") hideImmediate();
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
64
|
+
window.addEventListener("scroll", hideImmediate, true);
|
|
65
|
+
window.addEventListener("resize", hideImmediate, true);
|
|
66
|
+
return () => {
|
|
67
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
68
|
+
window.removeEventListener("scroll", hideImmediate, true);
|
|
69
|
+
window.removeEventListener("resize", hideImmediate, true);
|
|
70
|
+
};
|
|
71
|
+
}, [hideImmediate]);
|
|
72
|
+
return /* @__PURE__ */ jsxs(GlobalTooltipProvider, {
|
|
73
|
+
value: {
|
|
74
|
+
showTooltip,
|
|
75
|
+
hideTooltip,
|
|
76
|
+
hideImmediate,
|
|
77
|
+
currentTooltip,
|
|
78
|
+
transition,
|
|
79
|
+
globalId: id ?? globalId,
|
|
80
|
+
setReferenceEl,
|
|
81
|
+
referenceElRef
|
|
82
|
+
},
|
|
83
|
+
children: [/* @__PURE__ */ jsx(LayoutGroup, { children }), /* @__PURE__ */ jsx(TooltipOverlay, {})]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
var [RenderedTooltipProvider, useRenderedTooltip] = getStrictContext("RenderedTooltipContext");
|
|
87
|
+
var [FloatingProvider, useFloatingContext] = getStrictContext("FloatingContext");
|
|
88
|
+
var MotionTooltipArrow = motion.create(FloatingArrow);
|
|
89
|
+
function TooltipArrow({ ref, withTransition = true, ...props }) {
|
|
90
|
+
const { side, align, open } = useRenderedTooltip();
|
|
91
|
+
const { context, arrowRef } = useFloatingContext();
|
|
92
|
+
const { transition, globalId } = useGlobalTooltip();
|
|
93
|
+
React$1.useImperativeHandle(ref, () => arrowRef.current);
|
|
94
|
+
const deg = {
|
|
95
|
+
top: 0,
|
|
96
|
+
right: 90,
|
|
97
|
+
bottom: 180,
|
|
98
|
+
left: -90
|
|
99
|
+
}[side];
|
|
100
|
+
return /* @__PURE__ */ jsx(MotionTooltipArrow, {
|
|
101
|
+
ref: arrowRef,
|
|
102
|
+
context,
|
|
103
|
+
"data-state": open ? "open" : "closed",
|
|
104
|
+
"data-side": side,
|
|
105
|
+
"data-align": align,
|
|
106
|
+
"data-slot": "tooltip-arrow",
|
|
107
|
+
style: { rotate: deg },
|
|
108
|
+
layoutId: withTransition ? `tooltip-arrow-${globalId}` : void 0,
|
|
109
|
+
transition: withTransition ? transition : void 0,
|
|
110
|
+
...props
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function TooltipPortal(props) {
|
|
114
|
+
return /* @__PURE__ */ jsx(FloatingPortal, { ...props });
|
|
115
|
+
}
|
|
116
|
+
function TooltipOverlay() {
|
|
117
|
+
const { currentTooltip, transition, globalId, referenceElRef } = useGlobalTooltip();
|
|
118
|
+
const [rendered, setRendered] = React$1.useState({
|
|
119
|
+
data: null,
|
|
120
|
+
open: false
|
|
121
|
+
});
|
|
122
|
+
const arrowRef = React$1.useRef(null);
|
|
123
|
+
const side = rendered.data?.side ?? "top";
|
|
124
|
+
const align = rendered.data?.align ?? "center";
|
|
125
|
+
const { refs, x, y, strategy, context, update } = useFloating({
|
|
126
|
+
placement: align === "center" ? side : `${side}-${align}`,
|
|
127
|
+
whileElementsMounted: autoUpdate,
|
|
128
|
+
middleware: [
|
|
129
|
+
offset({
|
|
130
|
+
mainAxis: rendered.data?.sideOffset ?? 0,
|
|
131
|
+
crossAxis: rendered.data?.alignOffset ?? 0
|
|
132
|
+
}),
|
|
133
|
+
flip(),
|
|
134
|
+
shift({ padding: 8 }),
|
|
135
|
+
arrow({ element: arrowRef })
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
React$1.useEffect(() => {
|
|
139
|
+
if (currentTooltip) setRendered({
|
|
140
|
+
data: currentTooltip,
|
|
141
|
+
open: true
|
|
142
|
+
});
|
|
143
|
+
else setRendered((p) => p.data ? {
|
|
144
|
+
...p,
|
|
145
|
+
open: false
|
|
146
|
+
} : p);
|
|
147
|
+
}, [currentTooltip]);
|
|
148
|
+
React$1.useLayoutEffect(() => {
|
|
149
|
+
if (referenceElRef.current) {
|
|
150
|
+
refs.setReference(referenceElRef.current);
|
|
151
|
+
update();
|
|
152
|
+
}
|
|
153
|
+
}, [
|
|
154
|
+
referenceElRef,
|
|
155
|
+
refs,
|
|
156
|
+
update,
|
|
157
|
+
rendered.data
|
|
158
|
+
]);
|
|
159
|
+
const ready = x != null && y != null;
|
|
160
|
+
const Component = rendered.data?.contentAsChild ? Slot : motion.div;
|
|
161
|
+
const resolvedSide = getResolvedSide(context.placement);
|
|
162
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
163
|
+
mode: "wait",
|
|
164
|
+
children: rendered.data && ready && /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx("div", {
|
|
165
|
+
ref: refs.setFloating,
|
|
166
|
+
"data-slot": "tooltip-overlay",
|
|
167
|
+
"data-side": resolvedSide,
|
|
168
|
+
"data-align": rendered.data.align,
|
|
169
|
+
"data-state": rendered.open ? "open" : "closed",
|
|
170
|
+
style: {
|
|
171
|
+
position: strategy,
|
|
172
|
+
top: 0,
|
|
173
|
+
left: 0,
|
|
174
|
+
zIndex: 50,
|
|
175
|
+
transform: `translate3d(${x}px, ${y}px, 0)`
|
|
176
|
+
},
|
|
177
|
+
children: /* @__PURE__ */ jsx(FloatingProvider, {
|
|
178
|
+
value: {
|
|
179
|
+
context,
|
|
180
|
+
arrowRef
|
|
181
|
+
},
|
|
182
|
+
children: /* @__PURE__ */ jsx(RenderedTooltipProvider, {
|
|
183
|
+
value: {
|
|
184
|
+
side: resolvedSide,
|
|
185
|
+
align: rendered.data.align,
|
|
186
|
+
open: rendered.open
|
|
187
|
+
},
|
|
188
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
189
|
+
"data-slot": "tooltip-content",
|
|
190
|
+
"data-side": resolvedSide,
|
|
191
|
+
"data-align": rendered.data.align,
|
|
192
|
+
"data-state": rendered.open ? "open" : "closed",
|
|
193
|
+
layoutId: `tooltip-content-${globalId}`,
|
|
194
|
+
initial: {
|
|
195
|
+
opacity: 0,
|
|
196
|
+
scale: 0,
|
|
197
|
+
...initialFromSide(rendered.data.side)
|
|
198
|
+
},
|
|
199
|
+
animate: rendered.open ? {
|
|
200
|
+
opacity: 1,
|
|
201
|
+
scale: 1,
|
|
202
|
+
x: 0,
|
|
203
|
+
y: 0
|
|
204
|
+
} : {
|
|
205
|
+
opacity: 0,
|
|
206
|
+
scale: 0,
|
|
207
|
+
...initialFromSide(rendered.data.side)
|
|
208
|
+
},
|
|
209
|
+
exit: {
|
|
210
|
+
opacity: 0,
|
|
211
|
+
scale: 0,
|
|
212
|
+
...initialFromSide(rendered.data.side)
|
|
213
|
+
},
|
|
214
|
+
onAnimationComplete: () => {
|
|
215
|
+
if (!rendered.open) setRendered({
|
|
216
|
+
data: null,
|
|
217
|
+
open: false
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
transition,
|
|
221
|
+
...rendered.data.contentProps,
|
|
222
|
+
style: {
|
|
223
|
+
position: "relative",
|
|
224
|
+
...rendered.data.contentProps?.style || {}
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
}) })
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function Tooltip({ children, side = "top", sideOffset = 0, align = "center", alignOffset = 0 }) {
|
|
233
|
+
const id = React$1.useId();
|
|
234
|
+
const [props, setProps] = React$1.useState({});
|
|
235
|
+
const [asChild, setAsChild] = React$1.useState(false);
|
|
236
|
+
return /* @__PURE__ */ jsx(LocalTooltipProvider, {
|
|
237
|
+
value: {
|
|
238
|
+
props,
|
|
239
|
+
setProps,
|
|
240
|
+
asChild,
|
|
241
|
+
setAsChild,
|
|
242
|
+
side,
|
|
243
|
+
sideOffset,
|
|
244
|
+
align,
|
|
245
|
+
alignOffset,
|
|
246
|
+
id
|
|
247
|
+
},
|
|
248
|
+
children
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function shallowEqualWithoutChildren(a, b) {
|
|
252
|
+
if (a === b) return true;
|
|
253
|
+
if (!a || !b) return false;
|
|
254
|
+
const keysA = Object.keys(a).filter((k) => k !== "children");
|
|
255
|
+
const keysB = Object.keys(b).filter((k) => k !== "children");
|
|
256
|
+
if (keysA.length !== keysB.length) return false;
|
|
257
|
+
for (const k of keysA) if (a[k] !== b[k]) return false;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
function TooltipContent({ asChild = false, ...props }) {
|
|
261
|
+
const { setProps, setAsChild } = useTooltip();
|
|
262
|
+
const lastPropsRef = React$1.useRef(void 0);
|
|
263
|
+
React$1.useEffect(() => {
|
|
264
|
+
if (!shallowEqualWithoutChildren(lastPropsRef.current, props)) {
|
|
265
|
+
lastPropsRef.current = props;
|
|
266
|
+
setProps(props);
|
|
267
|
+
}
|
|
268
|
+
}, [props, setProps]);
|
|
269
|
+
React$1.useEffect(() => {
|
|
270
|
+
setAsChild(asChild);
|
|
271
|
+
}, [asChild, setAsChild]);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
function TooltipTrigger({ ref, onMouseEnter, onMouseLeave, onFocus, onBlur, onPointerDown, asChild = false, ...props }) {
|
|
275
|
+
const { props: contentProps, asChild: contentAsChild, side, sideOffset, align, alignOffset, id } = useTooltip();
|
|
276
|
+
const { showTooltip, hideTooltip, hideImmediate, currentTooltip, setReferenceEl } = useGlobalTooltip();
|
|
277
|
+
const triggerRef = React$1.useRef(null);
|
|
278
|
+
React$1.useImperativeHandle(ref, () => triggerRef.current);
|
|
279
|
+
const suppressNextFocusRef = React$1.useRef(false);
|
|
280
|
+
const handleOpen = React$1.useCallback(() => {
|
|
281
|
+
if (!triggerRef.current) return;
|
|
282
|
+
setReferenceEl(triggerRef.current);
|
|
283
|
+
showTooltip({
|
|
284
|
+
contentProps,
|
|
285
|
+
contentAsChild,
|
|
286
|
+
rect: triggerRef.current.getBoundingClientRect(),
|
|
287
|
+
side,
|
|
288
|
+
sideOffset,
|
|
289
|
+
align,
|
|
290
|
+
alignOffset,
|
|
291
|
+
id
|
|
292
|
+
});
|
|
293
|
+
}, [
|
|
294
|
+
showTooltip,
|
|
295
|
+
setReferenceEl,
|
|
296
|
+
contentProps,
|
|
297
|
+
contentAsChild,
|
|
298
|
+
side,
|
|
299
|
+
sideOffset,
|
|
300
|
+
align,
|
|
301
|
+
alignOffset,
|
|
302
|
+
id
|
|
303
|
+
]);
|
|
304
|
+
const handlePointerDown = React$1.useCallback((e) => {
|
|
305
|
+
onPointerDown?.(e);
|
|
306
|
+
if (currentTooltip?.id === id) {
|
|
307
|
+
suppressNextFocusRef.current = true;
|
|
308
|
+
hideImmediate();
|
|
309
|
+
Promise.resolve().then(() => {
|
|
310
|
+
suppressNextFocusRef.current = false;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}, [
|
|
314
|
+
onPointerDown,
|
|
315
|
+
currentTooltip?.id,
|
|
316
|
+
id,
|
|
317
|
+
hideImmediate
|
|
318
|
+
]);
|
|
319
|
+
const handleMouseEnter = React$1.useCallback((e) => {
|
|
320
|
+
onMouseEnter?.(e);
|
|
321
|
+
handleOpen();
|
|
322
|
+
}, [handleOpen, onMouseEnter]);
|
|
323
|
+
const handleMouseLeave = React$1.useCallback((e) => {
|
|
324
|
+
onMouseLeave?.(e);
|
|
325
|
+
hideTooltip();
|
|
326
|
+
}, [hideTooltip, onMouseLeave]);
|
|
327
|
+
const handleFocus = React$1.useCallback((e) => {
|
|
328
|
+
onFocus?.(e);
|
|
329
|
+
if (suppressNextFocusRef.current) return;
|
|
330
|
+
handleOpen();
|
|
331
|
+
}, [handleOpen, onFocus]);
|
|
332
|
+
const handleBlur = React$1.useCallback((e) => {
|
|
333
|
+
onBlur?.(e);
|
|
334
|
+
hideTooltip();
|
|
335
|
+
}, [hideTooltip, onBlur]);
|
|
336
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : motion.div, {
|
|
337
|
+
ref: triggerRef,
|
|
338
|
+
onPointerDown: handlePointerDown,
|
|
339
|
+
onMouseEnter: handleMouseEnter,
|
|
340
|
+
onMouseLeave: handleMouseLeave,
|
|
341
|
+
onFocus: handleFocus,
|
|
342
|
+
onBlur: handleBlur,
|
|
343
|
+
"data-slot": "tooltip-trigger",
|
|
344
|
+
"data-side": side,
|
|
345
|
+
"data-align": align,
|
|
346
|
+
"data-state": currentTooltip?.id === id ? "open" : "closed",
|
|
347
|
+
...props
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
export { Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, useGlobalTooltip, useTooltip };
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { AnimatePresence, motion, useMotionValue, useSpring } from "motion/react";
|
|
7
|
+
import { PreviewCard } from "@base-ui-components/react/preview-card";
|
|
8
|
+
//#region src/core/animate-ui/primitives/base/preview-card.tsx
|
|
9
|
+
var [PreviewCardProvider, usePreviewCard] = getStrictContext("PreviewCardContext");
|
|
10
|
+
function PreviewCard$1({ followCursor = false, followCursorSpringOptions = {
|
|
11
|
+
stiffness: 200,
|
|
12
|
+
damping: 17
|
|
13
|
+
}, ...props }) {
|
|
14
|
+
const [isOpen, setIsOpen] = useControlledState({
|
|
15
|
+
value: props?.open,
|
|
16
|
+
defaultValue: props?.defaultOpen,
|
|
17
|
+
onChange: props?.onOpenChange
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsx(PreviewCardProvider, {
|
|
20
|
+
value: {
|
|
21
|
+
isOpen,
|
|
22
|
+
setIsOpen,
|
|
23
|
+
x: useMotionValue(0),
|
|
24
|
+
y: useMotionValue(0),
|
|
25
|
+
followCursor,
|
|
26
|
+
followCursorSpringOptions
|
|
27
|
+
},
|
|
28
|
+
children: /* @__PURE__ */ jsx(PreviewCard.Root, {
|
|
29
|
+
"data-slot": "preview-card",
|
|
30
|
+
...props,
|
|
31
|
+
onOpenChange: setIsOpen
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function PreviewCardTrigger({ onMouseMove, ...props }) {
|
|
36
|
+
const { x, y, followCursor } = usePreviewCard();
|
|
37
|
+
const handleMouseMove = (event) => {
|
|
38
|
+
onMouseMove?.(event);
|
|
39
|
+
const target = event.currentTarget.getBoundingClientRect();
|
|
40
|
+
if (followCursor === "x" || followCursor === true) {
|
|
41
|
+
const offsetXFromCenter = (event.clientX - target.left - target.width / 2) / 2;
|
|
42
|
+
x.set(offsetXFromCenter);
|
|
43
|
+
}
|
|
44
|
+
if (followCursor === "y" || followCursor === true) {
|
|
45
|
+
const offsetYFromCenter = (event.clientY - target.top - target.height / 2) / 2;
|
|
46
|
+
y.set(offsetYFromCenter);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ jsx(PreviewCard.Trigger, {
|
|
50
|
+
"data-slot": "preview-card-trigger",
|
|
51
|
+
onMouseMove: handleMouseMove,
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function PreviewCardPortal(props) {
|
|
56
|
+
const { isOpen } = usePreviewCard();
|
|
57
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(PreviewCard.Portal, {
|
|
58
|
+
keepMounted: true,
|
|
59
|
+
"data-slot": "preview-card-portal",
|
|
60
|
+
...props
|
|
61
|
+
}) });
|
|
62
|
+
}
|
|
63
|
+
function PreviewCardPositioner(props) {
|
|
64
|
+
return /* @__PURE__ */ jsx(PreviewCard.Positioner, {
|
|
65
|
+
"data-slot": "preview-card-positioner",
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function PreviewCardPopup({ transition = {
|
|
70
|
+
type: "spring",
|
|
71
|
+
stiffness: 300,
|
|
72
|
+
damping: 25
|
|
73
|
+
}, style, ...props }) {
|
|
74
|
+
const { x, y, followCursor, followCursorSpringOptions } = usePreviewCard();
|
|
75
|
+
const translateX = useSpring(x, followCursorSpringOptions);
|
|
76
|
+
const translateY = useSpring(y, followCursorSpringOptions);
|
|
77
|
+
return /* @__PURE__ */ jsx(PreviewCard.Popup, { render: /* @__PURE__ */ jsx(motion.div, {
|
|
78
|
+
"data-slot": "preview-card-popup",
|
|
79
|
+
initial: {
|
|
80
|
+
opacity: 0,
|
|
81
|
+
scale: .5
|
|
82
|
+
},
|
|
83
|
+
animate: {
|
|
84
|
+
opacity: 1,
|
|
85
|
+
scale: 1
|
|
86
|
+
},
|
|
87
|
+
exit: {
|
|
88
|
+
opacity: 0,
|
|
89
|
+
scale: .5
|
|
90
|
+
},
|
|
91
|
+
transition,
|
|
92
|
+
style: {
|
|
93
|
+
x: followCursor === "x" || followCursor === true ? translateX : void 0,
|
|
94
|
+
y: followCursor === "y" || followCursor === true ? translateY : void 0,
|
|
95
|
+
...style
|
|
96
|
+
},
|
|
97
|
+
...props
|
|
98
|
+
}, "preview-card-popup") });
|
|
99
|
+
}
|
|
100
|
+
function PreviewCardBackdrop(props) {
|
|
101
|
+
return /* @__PURE__ */ jsx(PreviewCard.Backdrop, {
|
|
102
|
+
"data-slot": "preview-card-backdrop",
|
|
103
|
+
...props
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { PreviewCard$1 as PreviewCard, PreviewCardBackdrop, PreviewCardPopup, PreviewCardPortal, PreviewCardPositioner, PreviewCardTrigger, usePreviewCard };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getStrictContext } from "../../../utils/get-strict-context.js";
|
|
3
|
+
import { CountingNumber } from "../texts/counting-number.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { motion } from "motion/react";
|
|
7
|
+
import { Progress } from "@base-ui-components/react/progress";
|
|
8
|
+
//#region src/core/animate-ui/primitives/base/progress.tsx
|
|
9
|
+
var [ProgressProvider, useProgress] = getStrictContext("ProgressContext");
|
|
10
|
+
var Progress$1 = (props) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(ProgressProvider, {
|
|
12
|
+
value: { value: props.value ?? 0 },
|
|
13
|
+
children: /* @__PURE__ */ jsx(Progress.Root, {
|
|
14
|
+
"data-slot": "progress",
|
|
15
|
+
...props
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var MotionProgressIndicator = motion.create(Progress.Indicator);
|
|
20
|
+
function ProgressIndicator({ transition = {
|
|
21
|
+
type: "spring",
|
|
22
|
+
stiffness: 100,
|
|
23
|
+
damping: 30
|
|
24
|
+
}, ...props }) {
|
|
25
|
+
const { value } = useProgress();
|
|
26
|
+
return /* @__PURE__ */ jsx(MotionProgressIndicator, {
|
|
27
|
+
"data-slot": "progress-indicator",
|
|
28
|
+
animate: { width: `${value}%` },
|
|
29
|
+
transition,
|
|
30
|
+
...props
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function ProgressTrack(props) {
|
|
34
|
+
return /* @__PURE__ */ jsx(Progress.Track, {
|
|
35
|
+
"data-slot": "progress-track",
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function ProgressLabel(props) {
|
|
40
|
+
return /* @__PURE__ */ jsx(Progress.Label, {
|
|
41
|
+
"data-slot": "progress-label",
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function ProgressValue({ transition = {
|
|
46
|
+
stiffness: 80,
|
|
47
|
+
damping: 20
|
|
48
|
+
}, ...props }) {
|
|
49
|
+
const { value } = useProgress();
|
|
50
|
+
return /* @__PURE__ */ jsx(Progress.Value, {
|
|
51
|
+
"data-slot": "progress-value",
|
|
52
|
+
render: /* @__PURE__ */ jsx(CountingNumber, {
|
|
53
|
+
number: value ?? 0,
|
|
54
|
+
transition,
|
|
55
|
+
...props
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { Progress$1 as Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, useProgress };
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { AnimatePresence, motion } from "motion/react";
|
|
7
|
+
import { RadioGroup } from "@base-ui-components/react/radio-group";
|
|
8
|
+
import { Radio } from "@base-ui-components/react/radio";
|
|
9
|
+
//#region src/core/animate-ui/primitives/base/radio.tsx
|
|
10
|
+
var [RadioGroupProvider, useRadioGroup] = getStrictContext("RadioGroupContext");
|
|
11
|
+
var [RadioProvider, useRadio] = getStrictContext("RadioContext");
|
|
12
|
+
function RadioGroup$1(props) {
|
|
13
|
+
const [value, setValue] = useControlledState({
|
|
14
|
+
value: props.value ?? void 0,
|
|
15
|
+
defaultValue: props.defaultValue,
|
|
16
|
+
onChange: props.onValueChange
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ jsx(RadioGroupProvider, {
|
|
19
|
+
value: {
|
|
20
|
+
value,
|
|
21
|
+
setValue
|
|
22
|
+
},
|
|
23
|
+
children: /* @__PURE__ */ jsx(RadioGroup, {
|
|
24
|
+
"data-slot": "radio-group",
|
|
25
|
+
...props,
|
|
26
|
+
onValueChange: setValue
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function RadioIndicator({ transition = {
|
|
31
|
+
type: "spring",
|
|
32
|
+
stiffness: 200,
|
|
33
|
+
damping: 16
|
|
34
|
+
}, ...props }) {
|
|
35
|
+
const { isChecked } = useRadio();
|
|
36
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isChecked && /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
37
|
+
"data-slot": "radio-group-indicator",
|
|
38
|
+
keepMounted: true,
|
|
39
|
+
render: /* @__PURE__ */ jsx(motion.div, {
|
|
40
|
+
"data-slot": "radio-group-indicator-circle",
|
|
41
|
+
initial: {
|
|
42
|
+
opacity: 0,
|
|
43
|
+
scale: 0
|
|
44
|
+
},
|
|
45
|
+
animate: {
|
|
46
|
+
opacity: 1,
|
|
47
|
+
scale: 1
|
|
48
|
+
},
|
|
49
|
+
exit: {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
scale: 0
|
|
52
|
+
},
|
|
53
|
+
transition,
|
|
54
|
+
...props
|
|
55
|
+
}, "radio-group-indicator-circle")
|
|
56
|
+
}) });
|
|
57
|
+
}
|
|
58
|
+
function Radio$1({ value: valueProps, disabled, required, ...props }) {
|
|
59
|
+
const { value } = useRadioGroup();
|
|
60
|
+
const [isChecked, setIsChecked] = React$1.useState(value === valueProps);
|
|
61
|
+
React$1.useEffect(() => {
|
|
62
|
+
setIsChecked(value === valueProps);
|
|
63
|
+
}, [value, valueProps]);
|
|
64
|
+
return /* @__PURE__ */ jsx(RadioProvider, {
|
|
65
|
+
value: {
|
|
66
|
+
isChecked,
|
|
67
|
+
setIsChecked
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ jsx(Radio.Root, {
|
|
70
|
+
value: valueProps,
|
|
71
|
+
disabled,
|
|
72
|
+
required,
|
|
73
|
+
render: /* @__PURE__ */ jsx(motion.button, {
|
|
74
|
+
"data-slot": "radio-group-item",
|
|
75
|
+
whileHover: { scale: 1.05 },
|
|
76
|
+
whileTap: { scale: .95 },
|
|
77
|
+
...props
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioIndicator, useRadio, useRadioGroup };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slot } from "../animate/slot.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { motion } from "motion/react";
|
|
6
|
+
//#region src/core/animate-ui/primitives/buttons/button.tsx
|
|
7
|
+
function Button({ hoverScale = 1.05, tapScale = .95, asChild = false, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : motion.button, {
|
|
9
|
+
whileTap: { scale: tapScale },
|
|
10
|
+
whileHover: { scale: hoverScale },
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Button };
|