@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,147 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { THEMES } from "./chart.types.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import * as RechartsPrimitive from "recharts";
|
|
6
|
+
//#region src/components/chart/chart.tsx
|
|
7
|
+
var INITIAL_DIMENSION = {
|
|
8
|
+
width: 320,
|
|
9
|
+
height: 200
|
|
10
|
+
};
|
|
11
|
+
var ChartContext = React$1.createContext(null);
|
|
12
|
+
function useChart() {
|
|
13
|
+
const context = React$1.useContext(ChartContext);
|
|
14
|
+
if (!context) throw new Error("useChart must be used within a <ChartContainer />");
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
var ChartContainer = React$1.forwardRef(function ChartContainer({ id, className, children, config, initialDimension = INITIAL_DIMENSION, ...props }, ref) {
|
|
18
|
+
const uniqueId = React$1.useId();
|
|
19
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
|
|
20
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, {
|
|
21
|
+
value: { config },
|
|
22
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
23
|
+
ref,
|
|
24
|
+
"data-slot": "chart",
|
|
25
|
+
"data-chart": chartId,
|
|
26
|
+
className: cn("flex w-full min-w-0 flex-col items-stretch aspect-video text-xs [&_.recharts-responsive-container]:min-h-0 [&_.recharts-responsive-container]:w-full [&_.recharts-responsive-container]:min-w-0 [&_.recharts-responsive-container]:flex-1 [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
|
|
27
|
+
...props,
|
|
28
|
+
children: [/* @__PURE__ */ jsx(ChartStyle, {
|
|
29
|
+
id: chartId,
|
|
30
|
+
config
|
|
31
|
+
}), /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, {
|
|
32
|
+
initialDimension,
|
|
33
|
+
children
|
|
34
|
+
})]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
ChartContainer.displayName = "ChartContainer";
|
|
39
|
+
var ChartStyle = ({ id, config }) => {
|
|
40
|
+
const colorConfig = Object.entries(config).filter(([, item]) => item.theme ?? item.color);
|
|
41
|
+
if (!colorConfig.length) return null;
|
|
42
|
+
return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: Object.entries(THEMES).map(([theme, prefix]) => `
|
|
43
|
+
${prefix} [data-chart=${id}] {
|
|
44
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
45
|
+
const color = itemConfig.theme?.[theme] ?? itemConfig.color;
|
|
46
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
47
|
+
}).join("\n")}
|
|
48
|
+
}
|
|
49
|
+
`).join("\n") } });
|
|
50
|
+
};
|
|
51
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
52
|
+
function ChartTooltipContent({ active, payload, className, indicator = "dot", hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey }) {
|
|
53
|
+
const { config } = useChart();
|
|
54
|
+
const tooltipLabel = React$1.useMemo(() => {
|
|
55
|
+
if (hideLabel || !payload?.length) return null;
|
|
56
|
+
const [item] = payload;
|
|
57
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`);
|
|
58
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : itemConfig?.label;
|
|
59
|
+
if (labelFormatter) return /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: cn("font-medium", labelClassName),
|
|
61
|
+
children: labelFormatter(value, payload)
|
|
62
|
+
});
|
|
63
|
+
if (!value) return null;
|
|
64
|
+
return /* @__PURE__ */ jsx("div", {
|
|
65
|
+
className: cn("font-medium", labelClassName),
|
|
66
|
+
children: value
|
|
67
|
+
});
|
|
68
|
+
}, [
|
|
69
|
+
label,
|
|
70
|
+
labelFormatter,
|
|
71
|
+
payload,
|
|
72
|
+
hideLabel,
|
|
73
|
+
labelClassName,
|
|
74
|
+
config,
|
|
75
|
+
labelKey
|
|
76
|
+
]);
|
|
77
|
+
if (!active || !payload?.length) return null;
|
|
78
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
79
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
80
|
+
className: cn("grid min-w-[10rem] items-start gap-2.5 rounded-lg border border-border/50 bg-background px-4 py-3 text-xs shadow-xl", className),
|
|
81
|
+
children: [!nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: "grid gap-2.5",
|
|
83
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
84
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, `${nameKey ?? item.name ?? item.dataKey ?? "value"}`);
|
|
85
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color;
|
|
86
|
+
return /* @__PURE__ */ jsx("div", {
|
|
87
|
+
className: cn("flex w-full min-w-0 flex-wrap items-stretch gap-x-4 gap-y-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"),
|
|
88
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment$1, { children: [itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx("div", {
|
|
89
|
+
className: cn("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
|
|
90
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
91
|
+
"w-1": indicator === "line",
|
|
92
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
93
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
94
|
+
}),
|
|
95
|
+
style: {
|
|
96
|
+
"--color-bg": indicatorColor,
|
|
97
|
+
"--color-border": indicatorColor
|
|
98
|
+
}
|
|
99
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: cn("flex min-w-0 flex-1 justify-between gap-3 leading-snug", nestLabel ? "items-end" : "items-center"),
|
|
101
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
102
|
+
className: "grid gap-2",
|
|
103
|
+
children: [nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "text-muted-foreground",
|
|
105
|
+
children: itemConfig?.label ?? item.name
|
|
106
|
+
})]
|
|
107
|
+
}), item.value != null && /* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "font-mono font-medium text-foreground tabular-nums",
|
|
109
|
+
children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value)
|
|
110
|
+
})]
|
|
111
|
+
})] })
|
|
112
|
+
}, index);
|
|
113
|
+
})
|
|
114
|
+
})]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
118
|
+
function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }) {
|
|
119
|
+
const { config } = useChart();
|
|
120
|
+
if (!payload?.length) return null;
|
|
121
|
+
return /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: cn("flex flex-wrap items-center justify-center gap-x-4 gap-y-2", verticalAlign === "top" ? "pb-3" : "pt-3", className),
|
|
123
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
124
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, `${nameKey ?? item.dataKey ?? "value"}`);
|
|
125
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
|
|
127
|
+
children: [itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx("div", {
|
|
128
|
+
className: "h-4 w-4 shrink-0 rounded-sm",
|
|
129
|
+
style: { backgroundColor: item.color }
|
|
130
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
131
|
+
className: "text-sm font-normal",
|
|
132
|
+
children: itemConfig?.label
|
|
133
|
+
})]
|
|
134
|
+
}, index);
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
139
|
+
if (typeof payload !== "object" || payload === null) return;
|
|
140
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
141
|
+
let configLabelKey = key;
|
|
142
|
+
if (key in payload && typeof payload[key] === "string") configLabelKey = payload[key];
|
|
143
|
+
else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") configLabelKey = payloadPayload[key];
|
|
144
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "./chart.js";
|
|
3
|
+
import { buildAutoSeriesConfig, coerceSeriesValuesToNumbers, inferCategoryKey } from "./chart-series-data.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Bar, CartesianGrid, Cell, ComposedChart, Line, XAxis, YAxis } from "recharts";
|
|
7
|
+
//#region src/components/chart/composed-chart.tsx
|
|
8
|
+
var BAR_SIZE_MAP = {
|
|
9
|
+
sm: 14,
|
|
10
|
+
default: 24,
|
|
11
|
+
lg: 36
|
|
12
|
+
};
|
|
13
|
+
var STROKE_WIDTH_MAP = {
|
|
14
|
+
sm: 1.5,
|
|
15
|
+
default: 2,
|
|
16
|
+
lg: 3
|
|
17
|
+
};
|
|
18
|
+
var BAR_RADIUS = 4;
|
|
19
|
+
function resolveBarSize(size) {
|
|
20
|
+
if (size == null) return BAR_SIZE_MAP.default;
|
|
21
|
+
if (typeof size === "number") return size;
|
|
22
|
+
return BAR_SIZE_MAP[size];
|
|
23
|
+
}
|
|
24
|
+
function resolveStrokeWidth(width) {
|
|
25
|
+
if (width == null) return STROKE_WIDTH_MAP.default;
|
|
26
|
+
if (typeof width === "number") return width;
|
|
27
|
+
return STROKE_WIDTH_MAP[width];
|
|
28
|
+
}
|
|
29
|
+
function getBarRadius(index, total, stacked, rounded) {
|
|
30
|
+
if (!rounded) return [
|
|
31
|
+
0,
|
|
32
|
+
0,
|
|
33
|
+
0,
|
|
34
|
+
0
|
|
35
|
+
];
|
|
36
|
+
const r = BAR_RADIUS;
|
|
37
|
+
if (!stacked || total === 1) return [
|
|
38
|
+
r,
|
|
39
|
+
r,
|
|
40
|
+
0,
|
|
41
|
+
0
|
|
42
|
+
];
|
|
43
|
+
if (index === total - 1) return [
|
|
44
|
+
r,
|
|
45
|
+
r,
|
|
46
|
+
0,
|
|
47
|
+
0
|
|
48
|
+
];
|
|
49
|
+
return [
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
0,
|
|
53
|
+
0
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Recharts falls back to axis id `0` for a series without `yAxisId`, and throws
|
|
58
|
+
* ("Invariant failed") because the only axes declared are "left" and "right".
|
|
59
|
+
*/
|
|
60
|
+
var DEFAULT_Y_AXIS_ID = "left";
|
|
61
|
+
function buildDefaultSeries(config) {
|
|
62
|
+
return Object.keys(config).map((dataKey) => ({
|
|
63
|
+
dataKey,
|
|
64
|
+
type: "bar"
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
var ComposedChart$1 = React$1.forwardRef(function ComposedChart$2({ data, config: explicitConfig, categoryKey, series: explicitSeries, showTooltip = true, showLegend = false, showGrid = false, hideXAxis = false, hideYAxis = false, hideRightYAxis = true, xAxisTickFormatter, yAxisTickFormatter, rightYAxisTickFormatter, yAxisTickCount, rightYAxisTickCount, yAxisDomain, rightYAxisDomain, rightYAxisTicks, labelFormatter, tooltipFormatter, tooltipContent, defs, barGap, categoryGap, className, margin }, ref) {
|
|
68
|
+
const resolvedCategoryKey = React$1.useMemo(() => categoryKey ?? inferCategoryKey(data[0]), [categoryKey, data]);
|
|
69
|
+
const config = React$1.useMemo(() => buildAutoSeriesConfig(data, resolvedCategoryKey, explicitConfig), [
|
|
70
|
+
data,
|
|
71
|
+
resolvedCategoryKey,
|
|
72
|
+
explicitConfig
|
|
73
|
+
]);
|
|
74
|
+
const series = React$1.useMemo(() => explicitSeries ?? buildDefaultSeries(config), [explicitSeries, config]);
|
|
75
|
+
const seriesKeys = React$1.useMemo(() => series.map((item) => item.dataKey), [series]);
|
|
76
|
+
const chartData = React$1.useMemo(() => coerceSeriesValuesToNumbers(data, seriesKeys), [data, seriesKeys]);
|
|
77
|
+
const barSeries = React$1.useMemo(() => series.filter((item) => item.type === "bar"), [series]);
|
|
78
|
+
return /* @__PURE__ */ jsx(ChartContainer, {
|
|
79
|
+
ref,
|
|
80
|
+
config,
|
|
81
|
+
className: cn("w-full", className),
|
|
82
|
+
children: /* @__PURE__ */ jsxs(ComposedChart, {
|
|
83
|
+
accessibilityLayer: true,
|
|
84
|
+
data: chartData,
|
|
85
|
+
margin,
|
|
86
|
+
barGap,
|
|
87
|
+
barCategoryGap: categoryGap,
|
|
88
|
+
children: [
|
|
89
|
+
defs,
|
|
90
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { vertical: false }),
|
|
91
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
92
|
+
type: "category",
|
|
93
|
+
dataKey: resolvedCategoryKey,
|
|
94
|
+
hide: hideXAxis,
|
|
95
|
+
tickLine: false,
|
|
96
|
+
axisLine: false,
|
|
97
|
+
tickMargin: 8,
|
|
98
|
+
tickFormatter: xAxisTickFormatter
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
101
|
+
yAxisId: "left",
|
|
102
|
+
type: "number",
|
|
103
|
+
hide: hideYAxis,
|
|
104
|
+
tickLine: false,
|
|
105
|
+
axisLine: false,
|
|
106
|
+
tickMargin: 8,
|
|
107
|
+
tickFormatter: yAxisTickFormatter,
|
|
108
|
+
tickCount: yAxisTickCount,
|
|
109
|
+
domain: yAxisDomain
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
112
|
+
yAxisId: "right",
|
|
113
|
+
orientation: "right",
|
|
114
|
+
type: "number",
|
|
115
|
+
hide: hideRightYAxis,
|
|
116
|
+
tickLine: false,
|
|
117
|
+
axisLine: false,
|
|
118
|
+
tickMargin: 8,
|
|
119
|
+
tickFormatter: rightYAxisTickFormatter,
|
|
120
|
+
tickCount: rightYAxisTickCount,
|
|
121
|
+
domain: rightYAxisDomain,
|
|
122
|
+
ticks: rightYAxisTicks
|
|
123
|
+
}),
|
|
124
|
+
showTooltip && /* @__PURE__ */ jsx(ChartTooltip, {
|
|
125
|
+
cursor: {
|
|
126
|
+
fill: "var(--color-muted)",
|
|
127
|
+
fillOpacity: .12
|
|
128
|
+
},
|
|
129
|
+
labelFormatter,
|
|
130
|
+
content: tooltipContent ?? /* @__PURE__ */ jsx(ChartTooltipContent, { formatter: tooltipFormatter })
|
|
131
|
+
}),
|
|
132
|
+
showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
|
|
133
|
+
series.map((item) => {
|
|
134
|
+
if (item.type === "bar") {
|
|
135
|
+
const maxBarSize = resolveBarSize(item.barSize);
|
|
136
|
+
const rounded = item.rounded ?? true;
|
|
137
|
+
const stacked = Boolean(item.stackId);
|
|
138
|
+
const radius = getBarRadius(barSeries.findIndex((bar) => bar.dataKey === item.dataKey), barSeries.length, stacked, rounded);
|
|
139
|
+
return /* @__PURE__ */ jsx(Bar, {
|
|
140
|
+
dataKey: item.dataKey,
|
|
141
|
+
yAxisId: item.yAxisId ?? DEFAULT_Y_AXIS_ID,
|
|
142
|
+
stackId: item.stackId,
|
|
143
|
+
fill: `var(--color-${item.dataKey})`,
|
|
144
|
+
maxBarSize,
|
|
145
|
+
radius,
|
|
146
|
+
children: item.getCellFill && chartData.map((row, index) => {
|
|
147
|
+
const fill = item.getCellFill?.(row, index);
|
|
148
|
+
return /* @__PURE__ */ jsx(Cell, { fill: fill ?? `var(--color-${item.dataKey})` }, `${item.dataKey}-${index}`);
|
|
149
|
+
})
|
|
150
|
+
}, item.dataKey);
|
|
151
|
+
}
|
|
152
|
+
const lineCurve = item.curveType ?? "monotone";
|
|
153
|
+
const lineStrokeWidth = resolveStrokeWidth(item.strokeWidth);
|
|
154
|
+
const showDots = item.showDots ?? false;
|
|
155
|
+
const showActiveDot = item.showActiveDot ?? true;
|
|
156
|
+
return /* @__PURE__ */ jsx(Line, {
|
|
157
|
+
type: lineCurve,
|
|
158
|
+
dataKey: item.dataKey,
|
|
159
|
+
yAxisId: item.yAxisId ?? DEFAULT_Y_AXIS_ID,
|
|
160
|
+
stroke: `var(--color-${item.dataKey})`,
|
|
161
|
+
strokeWidth: lineStrokeWidth,
|
|
162
|
+
dot: showDots ? {
|
|
163
|
+
r: 3,
|
|
164
|
+
strokeWidth: 0,
|
|
165
|
+
fill: `var(--color-${item.dataKey})`
|
|
166
|
+
} : false,
|
|
167
|
+
activeDot: showActiveDot ? {
|
|
168
|
+
r: 4,
|
|
169
|
+
strokeWidth: 2,
|
|
170
|
+
stroke: "var(--color-background)",
|
|
171
|
+
fill: `var(--color-${item.dataKey})`
|
|
172
|
+
} : false,
|
|
173
|
+
isAnimationActive: true
|
|
174
|
+
}, item.dataKey);
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
ComposedChart$1.displayName = "ComposedChart";
|
|
181
|
+
//#endregion
|
|
182
|
+
export { ComposedChart$1 as ComposedChart };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "./chart.js";
|
|
3
|
+
import { buildSeriesChartConfig } from "./chart-colors.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Cell, Pie, PieChart } from "recharts";
|
|
7
|
+
//#region src/components/chart/donut-chart.tsx
|
|
8
|
+
var GRADIENT_TOP_OPACITY = 1;
|
|
9
|
+
var GRADIENT_BOTTOM_OPACITY = .82;
|
|
10
|
+
function flattenKeys(data) {
|
|
11
|
+
const keys = [];
|
|
12
|
+
for (const d of data) {
|
|
13
|
+
keys.push(d.key);
|
|
14
|
+
if (d.children) for (const c of d.children) keys.push(c.key);
|
|
15
|
+
}
|
|
16
|
+
return keys;
|
|
17
|
+
}
|
|
18
|
+
function deriveConfig(data, explicitConfig) {
|
|
19
|
+
if (explicitConfig) return explicitConfig;
|
|
20
|
+
return buildSeriesChartConfig(Array.from(new Set(flattenKeys(data))));
|
|
21
|
+
}
|
|
22
|
+
function hasChildren(data) {
|
|
23
|
+
return data.some((d) => d.children && d.children.length > 0);
|
|
24
|
+
}
|
|
25
|
+
function buildOuterRing(data) {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const d of data) if (d.children && d.children.length > 0) for (const c of d.children) out.push(c);
|
|
28
|
+
else out.push(d);
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function parseRadius(r) {
|
|
32
|
+
if (typeof r === "number") return {
|
|
33
|
+
raw: r,
|
|
34
|
+
isPct: false
|
|
35
|
+
};
|
|
36
|
+
const trimmed = r.trim();
|
|
37
|
+
const isPct = trimmed.endsWith("%");
|
|
38
|
+
return {
|
|
39
|
+
raw: Number.parseFloat(trimmed),
|
|
40
|
+
isPct
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function formatRadius(value, isPct) {
|
|
44
|
+
return isPct ? `${value}%` : value;
|
|
45
|
+
}
|
|
46
|
+
function validateChildren(data) {
|
|
47
|
+
for (const d of data) if (d.children && d.children.length > 0) {
|
|
48
|
+
const sum = d.children.reduce((s, c) => s + c.value, 0);
|
|
49
|
+
if (Math.abs(sum - d.value) > 1e-4) console.warn(`[DonutChart] children of "${d.key}" sum to ${sum}, but parent value is ${d.value}.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function resolveConfigColor(config, key) {
|
|
53
|
+
const item = config[key];
|
|
54
|
+
if (!item) return void 0;
|
|
55
|
+
if ("color" in item && item.color) return item.color;
|
|
56
|
+
if ("theme" in item && item.theme) return item.theme.light ?? item.theme.dark;
|
|
57
|
+
}
|
|
58
|
+
function DonutLegend({ config, order }) {
|
|
59
|
+
const seen = /* @__PURE__ */ new Set();
|
|
60
|
+
const items = order.filter((k) => {
|
|
61
|
+
if (seen.has(k)) return false;
|
|
62
|
+
seen.add(k);
|
|
63
|
+
return k in config;
|
|
64
|
+
}).map((k) => ({
|
|
65
|
+
key: k,
|
|
66
|
+
entry: config[k]
|
|
67
|
+
}));
|
|
68
|
+
if (items.length === 0) return null;
|
|
69
|
+
return /* @__PURE__ */ jsx("div", {
|
|
70
|
+
className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 pt-3 text-sm",
|
|
71
|
+
children: items.map(({ key, entry }) => {
|
|
72
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "flex items-center gap-1.5",
|
|
74
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
75
|
+
className: "h-3 w-3 shrink-0 rounded-sm",
|
|
76
|
+
style: { backgroundColor: resolveConfigColor(config, key) }
|
|
77
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: "font-normal text-foreground",
|
|
79
|
+
children: entry.label ?? key
|
|
80
|
+
})]
|
|
81
|
+
}, key);
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var DonutChart = React$1.forwardRef(function DonutChart({ data, config: explicitConfig, innerRadius = "55%", outerRadius = "95%", ringGap = 3, startAngle = 90, endAngle = -270, paddingAngle = 2, cornerRadius = 4, showTooltip = true, showLegend = false, gradient = true, centerLabel, className, margin }, ref) {
|
|
86
|
+
const gradientScope = React$1.useId().replace(/:/g, "");
|
|
87
|
+
const config = React$1.useMemo(() => deriveConfig(data, explicitConfig), [data, explicitConfig]);
|
|
88
|
+
const twoRing = React$1.useMemo(() => hasChildren(data), [data]);
|
|
89
|
+
const outerRing = React$1.useMemo(() => twoRing ? buildOuterRing(data) : null, [data, twoRing]);
|
|
90
|
+
React$1.useEffect(() => {
|
|
91
|
+
validateChildren(data);
|
|
92
|
+
}, [data]);
|
|
93
|
+
const inner = parseRadius(innerRadius);
|
|
94
|
+
const outer = parseRadius(outerRadius);
|
|
95
|
+
const mid = (inner.raw + outer.raw) / 2;
|
|
96
|
+
const gapHalf = ringGap / 2;
|
|
97
|
+
const innerRingOuterRadius = twoRing ? formatRadius(mid - gapHalf, inner.isPct) : outerRadius;
|
|
98
|
+
const outerRingInnerRadius = formatRadius(mid + gapHalf, outer.isPct);
|
|
99
|
+
const legendOrder = React$1.useMemo(() => flattenKeys(data), [data]);
|
|
100
|
+
const uniqueKeys = React$1.useMemo(() => Array.from(new Set(flattenKeys(data))), [data]);
|
|
101
|
+
const fillFor = (key) => gradient ? `url(#donut-grad-${gradientScope}-${key})` : `var(--color-${key})`;
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
103
|
+
ref,
|
|
104
|
+
className: cn("flex w-full flex-col", className),
|
|
105
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
106
|
+
className: "relative min-h-0 flex-1",
|
|
107
|
+
children: [/* @__PURE__ */ jsx(ChartContainer, {
|
|
108
|
+
config,
|
|
109
|
+
className: "h-full w-full",
|
|
110
|
+
children: /* @__PURE__ */ jsxs(PieChart, {
|
|
111
|
+
margin,
|
|
112
|
+
children: [
|
|
113
|
+
gradient && /* @__PURE__ */ jsx("defs", { children: uniqueKeys.map((key) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
114
|
+
id: `donut-grad-${gradientScope}-${key}`,
|
|
115
|
+
x1: "0",
|
|
116
|
+
y1: "0",
|
|
117
|
+
x2: "0",
|
|
118
|
+
y2: "1",
|
|
119
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
120
|
+
offset: "0%",
|
|
121
|
+
stopColor: `var(--color-${key})`,
|
|
122
|
+
stopOpacity: GRADIENT_TOP_OPACITY
|
|
123
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
124
|
+
offset: "100%",
|
|
125
|
+
stopColor: `var(--color-${key})`,
|
|
126
|
+
stopOpacity: GRADIENT_BOTTOM_OPACITY
|
|
127
|
+
})]
|
|
128
|
+
}, key)) }),
|
|
129
|
+
showTooltip && /* @__PURE__ */ jsx(ChartTooltip, {
|
|
130
|
+
cursor: false,
|
|
131
|
+
content: /* @__PURE__ */ jsx(ChartTooltipContent, {
|
|
132
|
+
hideLabel: true,
|
|
133
|
+
nameKey: "key"
|
|
134
|
+
})
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ jsx(Pie, {
|
|
137
|
+
data,
|
|
138
|
+
dataKey: "value",
|
|
139
|
+
nameKey: "key",
|
|
140
|
+
innerRadius,
|
|
141
|
+
outerRadius: innerRingOuterRadius,
|
|
142
|
+
startAngle,
|
|
143
|
+
endAngle,
|
|
144
|
+
paddingAngle,
|
|
145
|
+
cornerRadius,
|
|
146
|
+
stroke: "transparent",
|
|
147
|
+
isAnimationActive: true,
|
|
148
|
+
children: data.map((d) => /* @__PURE__ */ jsx(Cell, { fill: fillFor(d.key) }, d.key))
|
|
149
|
+
}),
|
|
150
|
+
twoRing && outerRing && /* @__PURE__ */ jsx(Pie, {
|
|
151
|
+
data: outerRing,
|
|
152
|
+
dataKey: "value",
|
|
153
|
+
nameKey: "key",
|
|
154
|
+
innerRadius: outerRingInnerRadius,
|
|
155
|
+
outerRadius,
|
|
156
|
+
startAngle,
|
|
157
|
+
endAngle,
|
|
158
|
+
paddingAngle,
|
|
159
|
+
cornerRadius,
|
|
160
|
+
stroke: "transparent",
|
|
161
|
+
isAnimationActive: true,
|
|
162
|
+
children: outerRing.map((d, i) => /* @__PURE__ */ jsx(Cell, { fill: fillFor(d.key) }, `${d.key}-${i}`))
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
}), centerLabel && /* @__PURE__ */ jsx("div", {
|
|
167
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-center",
|
|
168
|
+
children: centerLabel
|
|
169
|
+
})]
|
|
170
|
+
}), showLegend && /* @__PURE__ */ jsx(DonutLegend, {
|
|
171
|
+
config,
|
|
172
|
+
order: legendOrder
|
|
173
|
+
})]
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
//#endregion
|
|
177
|
+
export { DonutChart };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn.js";
|
|
2
|
+
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "./chart.js";
|
|
3
|
+
import { buildAutoSeriesConfig, coerceSeriesValuesToNumbers, inferCategoryKey } from "./chart-series-data.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Area, CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
|
7
|
+
//#region src/components/chart/line-chart.tsx
|
|
8
|
+
var STROKE_WIDTH_MAP = {
|
|
9
|
+
sm: 1.5,
|
|
10
|
+
default: 2,
|
|
11
|
+
lg: 3
|
|
12
|
+
};
|
|
13
|
+
function resolveStrokeWidth(width) {
|
|
14
|
+
if (width == null) return STROKE_WIDTH_MAP.default;
|
|
15
|
+
if (typeof width === "number") return width;
|
|
16
|
+
return STROKE_WIDTH_MAP[width];
|
|
17
|
+
}
|
|
18
|
+
var LineChart$1 = React$1.forwardRef(function LineChart$2({ data, config: explicitConfig, categoryKey, stacked = false, curveType = "monotone", strokeWidth, showDots = false, showActiveDot = true, gradientStroke: _gradientStroke = true, gradientGlow = true, showTooltip = true, showLegend = false, showGrid = false, hideXAxis = false, hideYAxis = false, xAxisTickFormatter, yAxisTickFormatter, labelFormatter, className, margin }, ref) {
|
|
19
|
+
const resolvedCategoryKey = React$1.useMemo(() => categoryKey ?? inferCategoryKey(data[0]), [categoryKey, data]);
|
|
20
|
+
const config = React$1.useMemo(() => buildAutoSeriesConfig(data, resolvedCategoryKey, explicitConfig), [
|
|
21
|
+
data,
|
|
22
|
+
resolvedCategoryKey,
|
|
23
|
+
explicitConfig
|
|
24
|
+
]);
|
|
25
|
+
const seriesKeys = React$1.useMemo(() => Object.keys(config), [config]);
|
|
26
|
+
const resolvedStrokeWidth = resolveStrokeWidth(strokeWidth);
|
|
27
|
+
const processedData = React$1.useMemo(() => {
|
|
28
|
+
const base = coerceSeriesValuesToNumbers(data, seriesKeys);
|
|
29
|
+
if (!stacked) return base;
|
|
30
|
+
return base.map((row) => {
|
|
31
|
+
const out = { ...row };
|
|
32
|
+
let cum = 0;
|
|
33
|
+
for (const key of seriesKeys) {
|
|
34
|
+
const raw = out[key];
|
|
35
|
+
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
36
|
+
cum += raw;
|
|
37
|
+
out[key] = cum;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
});
|
|
42
|
+
}, [
|
|
43
|
+
data,
|
|
44
|
+
seriesKeys,
|
|
45
|
+
stacked
|
|
46
|
+
]);
|
|
47
|
+
const glowOrderKeys = React$1.useMemo(() => stacked ? [...seriesKeys].reverse() : seriesKeys, [seriesKeys, stacked]);
|
|
48
|
+
const idPrefix = `line-${React$1.useId().replace(/:/g, "")}`;
|
|
49
|
+
const glowGradientId = (key) => `${idPrefix}-glow-${key}`;
|
|
50
|
+
return /* @__PURE__ */ jsx(ChartContainer, {
|
|
51
|
+
ref,
|
|
52
|
+
config,
|
|
53
|
+
className: cn("w-full", className),
|
|
54
|
+
children: /* @__PURE__ */ jsxs(LineChart, {
|
|
55
|
+
accessibilityLayer: true,
|
|
56
|
+
data: processedData,
|
|
57
|
+
margin,
|
|
58
|
+
children: [
|
|
59
|
+
gradientGlow && /* @__PURE__ */ jsx("defs", { children: seriesKeys.map((key) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
60
|
+
id: glowGradientId(key),
|
|
61
|
+
x1: "0",
|
|
62
|
+
y1: "0",
|
|
63
|
+
x2: "0",
|
|
64
|
+
y2: "1",
|
|
65
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
66
|
+
offset: "0%",
|
|
67
|
+
stopColor: `var(--color-${key})`,
|
|
68
|
+
stopOpacity: .18
|
|
69
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
70
|
+
offset: "100%",
|
|
71
|
+
stopColor: `var(--color-${key})`,
|
|
72
|
+
stopOpacity: 0
|
|
73
|
+
})]
|
|
74
|
+
}, key)) }),
|
|
75
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { vertical: false }),
|
|
76
|
+
/* @__PURE__ */ jsx(XAxis, {
|
|
77
|
+
type: "category",
|
|
78
|
+
dataKey: resolvedCategoryKey,
|
|
79
|
+
hide: hideXAxis,
|
|
80
|
+
tickLine: false,
|
|
81
|
+
axisLine: false,
|
|
82
|
+
tickMargin: 8,
|
|
83
|
+
tickFormatter: xAxisTickFormatter
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx(YAxis, {
|
|
86
|
+
type: "number",
|
|
87
|
+
hide: hideYAxis,
|
|
88
|
+
tickLine: false,
|
|
89
|
+
axisLine: false,
|
|
90
|
+
tickMargin: 8,
|
|
91
|
+
tickFormatter: yAxisTickFormatter
|
|
92
|
+
}),
|
|
93
|
+
showTooltip && /* @__PURE__ */ jsx(ChartTooltip, {
|
|
94
|
+
cursor: {
|
|
95
|
+
stroke: "var(--color-border)",
|
|
96
|
+
strokeWidth: 1
|
|
97
|
+
},
|
|
98
|
+
labelFormatter,
|
|
99
|
+
content: /* @__PURE__ */ jsx(ChartTooltipContent, {})
|
|
100
|
+
}),
|
|
101
|
+
showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
|
|
102
|
+
gradientGlow && glowOrderKeys.map((key) => /* @__PURE__ */ jsx(Area, {
|
|
103
|
+
type: curveType,
|
|
104
|
+
dataKey: key,
|
|
105
|
+
fill: `url(#${glowGradientId(key)})`,
|
|
106
|
+
stroke: "transparent",
|
|
107
|
+
strokeWidth: 0,
|
|
108
|
+
activeDot: false,
|
|
109
|
+
isAnimationActive: true,
|
|
110
|
+
legendType: "none",
|
|
111
|
+
tooltipType: "none"
|
|
112
|
+
}, `glow-${key}`)),
|
|
113
|
+
seriesKeys.map((key) => /* @__PURE__ */ jsx(Line, {
|
|
114
|
+
type: curveType,
|
|
115
|
+
dataKey: key,
|
|
116
|
+
stroke: `var(--color-${key})`,
|
|
117
|
+
strokeWidth: resolvedStrokeWidth,
|
|
118
|
+
dot: showDots ? {
|
|
119
|
+
r: 3,
|
|
120
|
+
strokeWidth: 0,
|
|
121
|
+
fill: `var(--color-${key})`
|
|
122
|
+
} : false,
|
|
123
|
+
activeDot: showActiveDot ? {
|
|
124
|
+
r: 4,
|
|
125
|
+
strokeWidth: 2,
|
|
126
|
+
stroke: "var(--color-background)",
|
|
127
|
+
fill: `var(--color-${key})`
|
|
128
|
+
} : false,
|
|
129
|
+
isAnimationActive: true
|
|
130
|
+
}, key))
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
LineChart$1.displayName = "LineChart";
|
|
136
|
+
//#endregion
|
|
137
|
+
export { LineChart$1 as LineChart };
|