@epilot/spark-ui 1.0.0-alpha.2 → 1.0.0-alpha.4
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/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +7 -1
- package/dist/chunk-aJGBMT86.cjs +29 -0
- package/dist/components/accordion.cjs +57 -0
- package/dist/components/accordion.cjs.map +1 -0
- package/dist/components/accordion.d.cts +45 -0
- package/dist/components/accordion.d.ts +45 -0
- package/dist/components/accordion.js +51 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.cjs +137 -0
- package/dist/components/alert-dialog.cjs.map +1 -0
- package/dist/components/alert-dialog.d.cts +63 -0
- package/dist/components/alert-dialog.d.ts +63 -0
- package/dist/components/alert-dialog.js +123 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/attachment.cjs +119 -0
- package/dist/components/attachment.cjs.map +1 -0
- package/dist/components/attachment.d.cts +67 -0
- package/dist/components/attachment.d.ts +67 -0
- package/dist/components/attachment.js +108 -0
- package/dist/components/attachment.js.map +1 -0
- package/dist/components/badge.cjs +20 -0
- package/dist/components/badge.cjs.map +1 -0
- package/dist/components/badge.d.cts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +17 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/bar-chart.cjs +520 -0
- package/dist/components/bar-chart.cjs.map +1 -0
- package/dist/components/bar-chart.d.cts +88 -0
- package/dist/components/bar-chart.d.ts +88 -0
- package/dist/components/bar-chart.js +518 -0
- package/dist/components/bar-chart.js.map +1 -0
- package/dist/components/battery-progress-row.cjs +140 -0
- package/dist/components/battery-progress-row.cjs.map +1 -0
- package/dist/components/battery-progress-row.d.cts +78 -0
- package/dist/components/battery-progress-row.d.ts +78 -0
- package/dist/components/battery-progress-row.js +129 -0
- package/dist/components/battery-progress-row.js.map +1 -0
- package/dist/components/breadcrumbs.cjs +65 -0
- package/dist/components/breadcrumbs.cjs.map +1 -0
- package/dist/components/breadcrumbs.d.cts +44 -0
- package/dist/components/breadcrumbs.d.ts +44 -0
- package/dist/components/breadcrumbs.js +58 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bubble.cjs +84 -0
- package/dist/components/bubble.cjs.map +1 -0
- package/dist/components/bubble.d.cts +41 -0
- package/dist/components/bubble.d.ts +41 -0
- package/dist/components/bubble.js +78 -0
- package/dist/components/bubble.js.map +1 -0
- package/dist/components/button.cjs +54 -0
- package/dist/components/button.cjs.map +1 -0
- package/dist/components/button.d.cts +42 -0
- package/dist/components/button.d.ts +42 -0
- package/dist/components/button.js +50 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.cjs +58 -0
- package/dist/components/calendar.cjs.map +1 -0
- package/dist/components/calendar.d.cts +17 -0
- package/dist/components/calendar.d.ts +17 -0
- package/dist/components/calendar.js +55 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/callout.cjs +95 -0
- package/dist/components/callout.cjs.map +1 -0
- package/dist/components/callout.d.cts +39 -0
- package/dist/components/callout.d.ts +39 -0
- package/dist/components/callout.js +88 -0
- package/dist/components/callout.js.map +1 -0
- package/dist/components/card.cjs +86 -0
- package/dist/components/card.cjs.map +1 -0
- package/dist/components/card.d.cts +28 -0
- package/dist/components/card.d.ts +28 -0
- package/dist/components/card.js +76 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart.cjs +93 -0
- package/dist/components/chart.cjs.map +1 -0
- package/dist/components/chart.d.cts +83 -0
- package/dist/components/chart.d.ts +83 -0
- package/dist/components/chart.js +88 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.cjs +37 -0
- package/dist/components/checkbox.cjs.map +1 -0
- package/dist/components/checkbox.d.cts +22 -0
- package/dist/components/checkbox.d.ts +22 -0
- package/dist/components/checkbox.js +34 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/circular-gauge.cjs +74 -0
- package/dist/components/circular-gauge.cjs.map +1 -0
- package/dist/components/circular-gauge.d.cts +38 -0
- package/dist/components/circular-gauge.d.ts +38 -0
- package/dist/components/circular-gauge.js +71 -0
- package/dist/components/circular-gauge.js.map +1 -0
- package/dist/components/day-of-week-picker.cjs +123 -0
- package/dist/components/day-of-week-picker.cjs.map +1 -0
- package/dist/components/day-of-week-picker.d.cts +39 -0
- package/dist/components/day-of-week-picker.d.ts +39 -0
- package/dist/components/day-of-week-picker.js +119 -0
- package/dist/components/day-of-week-picker.js.map +1 -0
- package/dist/components/device-card.cjs +118 -0
- package/dist/components/device-card.cjs.map +1 -0
- package/dist/components/device-card.d.cts +71 -0
- package/dist/components/device-card.d.ts +71 -0
- package/dist/components/device-card.js +104 -0
- package/dist/components/device-card.js.map +1 -0
- package/dist/components/dialog.cjs +115 -0
- package/dist/components/dialog.cjs.map +1 -0
- package/dist/components/dialog.d.cts +45 -0
- package/dist/components/dialog.d.ts +45 -0
- package/dist/components/dialog.js +103 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/donut-chart.cjs +71 -0
- package/dist/components/donut-chart.cjs.map +1 -0
- package/dist/components/donut-chart.d.cts +22 -0
- package/dist/components/donut-chart.d.ts +22 -0
- package/dist/components/donut-chart.js +69 -0
- package/dist/components/donut-chart.js.map +1 -0
- package/dist/components/drawer.cjs +95 -0
- package/dist/components/drawer.cjs.map +1 -0
- package/dist/components/drawer.d.cts +46 -0
- package/dist/components/drawer.d.ts +46 -0
- package/dist/components/drawer.js +83 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.cjs +165 -0
- package/dist/components/dropdown-menu.cjs.map +1 -0
- package/dist/components/dropdown-menu.d.cts +93 -0
- package/dist/components/dropdown-menu.d.ts +93 -0
- package/dist/components/dropdown-menu.js +148 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/empty-state.cjs +35 -0
- package/dist/components/empty-state.cjs.map +1 -0
- package/dist/components/empty-state.d.cts +22 -0
- package/dist/components/empty-state.d.ts +22 -0
- package/dist/components/empty-state.js +33 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/energy-bar-chart.cjs +24 -0
- package/dist/components/energy-bar-chart.cjs.map +1 -0
- package/dist/components/energy-bar-chart.d.cts +43 -0
- package/dist/components/energy-bar-chart.d.ts +43 -0
- package/dist/components/energy-bar-chart.js +22 -0
- package/dist/components/energy-bar-chart.js.map +1 -0
- package/dist/components/energy-breakdown.cjs +81 -0
- package/dist/components/energy-breakdown.cjs.map +1 -0
- package/dist/components/energy-breakdown.d.cts +26 -0
- package/dist/components/energy-breakdown.d.ts +26 -0
- package/dist/components/energy-breakdown.js +79 -0
- package/dist/components/energy-breakdown.js.map +1 -0
- package/dist/components/energy-history-chart.cjs +64 -0
- package/dist/components/energy-history-chart.cjs.map +1 -0
- package/dist/components/energy-history-chart.d.cts +66 -0
- package/dist/components/energy-history-chart.d.ts +66 -0
- package/dist/components/energy-history-chart.js +62 -0
- package/dist/components/energy-history-chart.js.map +1 -0
- package/dist/components/feed-in-hero.cjs +56 -0
- package/dist/components/feed-in-hero.cjs.map +1 -0
- package/dist/components/feed-in-hero.d.cts +33 -0
- package/dist/components/feed-in-hero.d.ts +33 -0
- package/dist/components/feed-in-hero.js +51 -0
- package/dist/components/feed-in-hero.js.map +1 -0
- package/dist/components/field.cjs +257 -0
- package/dist/components/field.cjs.map +1 -0
- package/dist/components/field.d.cts +104 -0
- package/dist/components/field.d.ts +104 -0
- package/dist/components/field.js +243 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/icon.cjs +35 -0
- package/dist/components/icon.cjs.map +1 -0
- package/dist/components/icon.d.cts +27 -0
- package/dist/components/icon.d.ts +27 -0
- package/dist/components/icon.js +32 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/info-block.cjs +75 -0
- package/dist/components/info-block.cjs.map +1 -0
- package/dist/components/info-block.d.cts +20 -0
- package/dist/components/info-block.d.ts +20 -0
- package/dist/components/info-block.js +65 -0
- package/dist/components/info-block.js.map +1 -0
- package/dist/components/input-group.cjs +164 -0
- package/dist/components/input-group.cjs.map +1 -0
- package/dist/components/input-group.d.cts +32 -0
- package/dist/components/input-group.d.ts +32 -0
- package/dist/components/input-group.js +158 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input-otp.cjs +113 -0
- package/dist/components/input-otp.cjs.map +1 -0
- package/dist/components/input-otp.d.cts +22 -0
- package/dist/components/input-otp.d.ts +22 -0
- package/dist/components/input-otp.js +111 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/input.cjs +112 -0
- package/dist/components/input.cjs.map +1 -0
- package/dist/components/input.d.cts +21 -0
- package/dist/components/input.d.ts +21 -0
- package/dist/components/input.js +109 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.cjs +18 -0
- package/dist/components/label.cjs.map +1 -0
- package/dist/components/label.d.cts +10 -0
- package/dist/components/label.d.ts +10 -0
- package/dist/components/label.js +15 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/layout.cjs +15 -0
- package/dist/components/layout.cjs.map +1 -0
- package/dist/components/layout.d.cts +12 -0
- package/dist/components/layout.d.ts +13 -0
- package/dist/components/layout.js +14 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/line-chart.cjs +350 -0
- package/dist/components/line-chart.cjs.map +1 -0
- package/dist/components/line-chart.d.cts +78 -0
- package/dist/components/line-chart.d.ts +78 -0
- package/dist/components/line-chart.js +347 -0
- package/dist/components/line-chart.js.map +1 -0
- package/dist/components/list.cjs +132 -0
- package/dist/components/list.cjs.map +1 -0
- package/dist/components/list.d.cts +72 -0
- package/dist/components/list.d.ts +72 -0
- package/dist/components/list.js +122 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/marker.cjs +52 -0
- package/dist/components/marker.cjs.map +1 -0
- package/dist/components/marker.d.cts +29 -0
- package/dist/components/marker.d.ts +29 -0
- package/dist/components/marker.js +46 -0
- package/dist/components/marker.js.map +1 -0
- package/dist/components/message-scroller.cjs +73 -0
- package/dist/components/message-scroller.cjs.map +1 -0
- package/dist/components/message-scroller.d.cts +39 -0
- package/dist/components/message-scroller.d.ts +39 -0
- package/dist/components/message-scroller.js +62 -0
- package/dist/components/message-scroller.js.map +1 -0
- package/dist/components/message.cjs +60 -0
- package/dist/components/message.cjs.map +1 -0
- package/dist/components/message.d.cts +36 -0
- package/dist/components/message.d.ts +36 -0
- package/dist/components/message.js +52 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/metering-row.cjs +43 -0
- package/dist/components/metering-row.cjs.map +1 -0
- package/dist/components/metering-row.d.cts +32 -0
- package/dist/components/metering-row.d.ts +32 -0
- package/dist/components/metering-row.js +38 -0
- package/dist/components/metering-row.js.map +1 -0
- package/dist/components/money-saved-block.cjs +87 -0
- package/dist/components/money-saved-block.cjs.map +1 -0
- package/dist/components/money-saved-block.d.cts +57 -0
- package/dist/components/money-saved-block.d.ts +57 -0
- package/dist/components/money-saved-block.js +79 -0
- package/dist/components/money-saved-block.js.map +1 -0
- package/dist/components/number-flow.cjs +44 -0
- package/dist/components/number-flow.cjs.map +1 -0
- package/dist/components/number-flow.d.cts +4 -0
- package/dist/components/number-flow.d.ts +4 -0
- package/dist/components/number-flow.js +42 -0
- package/dist/components/number-flow.js.map +1 -0
- package/dist/components/on-off-button.cjs +36 -0
- package/dist/components/on-off-button.cjs.map +1 -0
- package/dist/components/on-off-button.d.cts +20 -0
- package/dist/components/on-off-button.d.ts +20 -0
- package/dist/components/on-off-button.js +34 -0
- package/dist/components/on-off-button.js.map +1 -0
- package/dist/components/onboarding-layout.cjs +68 -0
- package/dist/components/onboarding-layout.cjs.map +1 -0
- package/dist/components/onboarding-layout.d.cts +46 -0
- package/dist/components/onboarding-layout.d.ts +46 -0
- package/dist/components/onboarding-layout.js +60 -0
- package/dist/components/onboarding-layout.js.map +1 -0
- package/dist/components/page-header.cjs +50 -0
- package/dist/components/page-header.cjs.map +1 -0
- package/dist/components/page-header.d.cts +26 -0
- package/dist/components/page-header.d.ts +26 -0
- package/dist/components/page-header.js +44 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/page-spinner.cjs +19 -0
- package/dist/components/page-spinner.cjs.map +1 -0
- package/dist/components/page-spinner.d.cts +14 -0
- package/dist/components/page-spinner.d.ts +14 -0
- package/dist/components/page-spinner.js +17 -0
- package/dist/components/page-spinner.js.map +1 -0
- package/dist/components/period-tabs.cjs +79 -0
- package/dist/components/period-tabs.cjs.map +1 -0
- package/dist/components/period-tabs.d.cts +51 -0
- package/dist/components/period-tabs.d.ts +51 -0
- package/dist/components/period-tabs.js +73 -0
- package/dist/components/period-tabs.js.map +1 -0
- package/dist/components/popover.cjs +62 -0
- package/dist/components/popover.cjs.map +1 -0
- package/dist/components/popover.d.cts +29 -0
- package/dist/components/popover.d.ts +29 -0
- package/dist/components/popover.js +56 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/power-history-chart.cjs +335 -0
- package/dist/components/power-history-chart.cjs.map +1 -0
- package/dist/components/power-history-chart.d.cts +63 -0
- package/dist/components/power-history-chart.d.ts +63 -0
- package/dist/components/power-history-chart.js +332 -0
- package/dist/components/power-history-chart.js.map +1 -0
- package/dist/components/power-history.cjs +115 -0
- package/dist/components/power-history.cjs.map +1 -0
- package/dist/components/power-history.d.cts +42 -0
- package/dist/components/power-history.d.ts +43 -0
- package/dist/components/power-history.js +114 -0
- package/dist/components/power-history.js.map +1 -0
- package/dist/components/power-network.cjs +530 -0
- package/dist/components/power-network.cjs.map +1 -0
- package/dist/components/power-network.d.cts +77 -0
- package/dist/components/power-network.d.ts +77 -0
- package/dist/components/power-network.js +523 -0
- package/dist/components/power-network.js.map +1 -0
- package/dist/components/progress.cjs +34 -0
- package/dist/components/progress.cjs.map +1 -0
- package/dist/components/progress.d.cts +17 -0
- package/dist/components/progress.d.ts +17 -0
- package/dist/components/progress.js +31 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-card-group.cjs +69 -0
- package/dist/components/radio-card-group.cjs.map +1 -0
- package/dist/components/radio-card-group.d.cts +21 -0
- package/dist/components/radio-card-group.d.ts +21 -0
- package/dist/components/radio-card-group.js +65 -0
- package/dist/components/radio-card-group.js.map +1 -0
- package/dist/components/radio.cjs +34 -0
- package/dist/components/radio.cjs.map +1 -0
- package/dist/components/radio.d.cts +21 -0
- package/dist/components/radio.d.ts +21 -0
- package/dist/components/radio.js +30 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/reparent.cjs +55 -0
- package/dist/components/reparent.cjs.map +1 -0
- package/dist/components/reparent.d.cts +29 -0
- package/dist/components/reparent.d.ts +29 -0
- package/dist/components/reparent.js +49 -0
- package/dist/components/reparent.js.map +1 -0
- package/dist/components/sankey-chart.cjs +188 -0
- package/dist/components/sankey-chart.cjs.map +1 -0
- package/dist/components/sankey-chart.d.cts +66 -0
- package/dist/components/sankey-chart.d.ts +66 -0
- package/dist/components/sankey-chart.js +185 -0
- package/dist/components/sankey-chart.js.map +1 -0
- package/dist/components/schedule-editor.cjs +82 -0
- package/dist/components/schedule-editor.cjs.map +1 -0
- package/dist/components/schedule-editor.d.cts +25 -0
- package/dist/components/schedule-editor.d.ts +25 -0
- package/dist/components/schedule-editor.js +72 -0
- package/dist/components/schedule-editor.js.map +1 -0
- package/dist/components/schedule-list.cjs +110 -0
- package/dist/components/schedule-list.cjs.map +1 -0
- package/dist/components/schedule-list.d.cts +29 -0
- package/dist/components/schedule-list.d.ts +29 -0
- package/dist/components/schedule-list.js +99 -0
- package/dist/components/schedule-list.js.map +1 -0
- package/dist/components/scroll-area.cjs +53 -0
- package/dist/components/scroll-area.cjs.map +1 -0
- package/dist/components/scroll-area.d.cts +26 -0
- package/dist/components/scroll-area.d.ts +26 -0
- package/dist/components/scroll-area.js +44 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/segmented-control.cjs +44 -0
- package/dist/components/segmented-control.cjs.map +1 -0
- package/dist/components/segmented-control.d.cts +33 -0
- package/dist/components/segmented-control.d.ts +33 -0
- package/dist/components/segmented-control.js +40 -0
- package/dist/components/segmented-control.js.map +1 -0
- package/dist/components/select.cjs +136 -0
- package/dist/components/select.cjs.map +1 -0
- package/dist/components/select.d.cts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +124 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.cjs +38 -0
- package/dist/components/separator.cjs.map +1 -0
- package/dist/components/separator.d.cts +13 -0
- package/dist/components/separator.d.ts +13 -0
- package/dist/components/separator.js +35 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/series-legend.cjs +39 -0
- package/dist/components/series-legend.cjs.map +1 -0
- package/dist/components/series-legend.d.cts +31 -0
- package/dist/components/series-legend.d.ts +31 -0
- package/dist/components/series-legend.js +37 -0
- package/dist/components/series-legend.js.map +1 -0
- package/dist/components/sheet.cjs +102 -0
- package/dist/components/sheet.cjs.map +1 -0
- package/dist/components/sheet.d.cts +46 -0
- package/dist/components/sheet.d.ts +46 -0
- package/dist/components/sheet.js +90 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.cjs +24 -0
- package/dist/components/skeleton.cjs.map +1 -0
- package/dist/components/skeleton.d.cts +24 -0
- package/dist/components/skeleton.d.ts +24 -0
- package/dist/components/skeleton.js +21 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.cjs +276 -0
- package/dist/components/slider.cjs.map +1 -0
- package/dist/components/slider.d.cts +150 -0
- package/dist/components/slider.d.ts +150 -0
- package/dist/components/slider.js +266 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/smart-toggle-button.cjs +28 -0
- package/dist/components/smart-toggle-button.cjs.map +1 -0
- package/dist/components/smart-toggle-button.d.cts +18 -0
- package/dist/components/smart-toggle-button.d.ts +18 -0
- package/dist/components/smart-toggle-button.js +26 -0
- package/dist/components/smart-toggle-button.js.map +1 -0
- package/dist/components/solar-forecast-chart.cjs +106 -0
- package/dist/components/solar-forecast-chart.cjs.map +1 -0
- package/dist/components/solar-forecast-chart.d.cts +69 -0
- package/dist/components/solar-forecast-chart.d.ts +69 -0
- package/dist/components/solar-forecast-chart.js +100 -0
- package/dist/components/solar-forecast-chart.js.map +1 -0
- package/dist/components/sortable-list.cjs +69 -0
- package/dist/components/sortable-list.cjs.map +1 -0
- package/dist/components/sortable-list.d.cts +46 -0
- package/dist/components/sortable-list.d.ts +46 -0
- package/dist/components/sortable-list.js +67 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/spinner.cjs +42 -0
- package/dist/components/spinner.cjs.map +1 -0
- package/dist/components/spinner.d.cts +15 -0
- package/dist/components/spinner.d.ts +15 -0
- package/dist/components/spinner.js +39 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stat-card.cjs +58 -0
- package/dist/components/stat-card.cjs.map +1 -0
- package/dist/components/stat-card.d.cts +36 -0
- package/dist/components/stat-card.d.ts +36 -0
- package/dist/components/stat-card.js +50 -0
- package/dist/components/stat-card.js.map +1 -0
- package/dist/components/stepper.cjs +79 -0
- package/dist/components/stepper.cjs.map +1 -0
- package/dist/components/stepper.d.cts +33 -0
- package/dist/components/stepper.d.ts +33 -0
- package/dist/components/stepper.js +76 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.cjs +22 -0
- package/dist/components/switch.cjs.map +1 -0
- package/dist/components/switch.d.cts +28 -0
- package/dist/components/switch.d.ts +28 -0
- package/dist/components/switch.js +20 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.cjs +175 -0
- package/dist/components/tabs.cjs.map +1 -0
- package/dist/components/tabs.d.cts +45 -0
- package/dist/components/tabs.d.ts +45 -0
- package/dist/components/tabs.js +167 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/theme.cjs +6 -0
- package/dist/components/theme.d.cts +38 -0
- package/dist/components/theme.d.ts +38 -0
- package/dist/components/theme.js +4 -0
- package/dist/components/thumbnail.cjs +54 -0
- package/dist/components/thumbnail.cjs.map +1 -0
- package/dist/components/thumbnail.d.cts +34 -0
- package/dist/components/thumbnail.d.ts +34 -0
- package/dist/components/thumbnail.js +51 -0
- package/dist/components/thumbnail.js.map +1 -0
- package/dist/components/time-picker.cjs +55 -0
- package/dist/components/time-picker.cjs.map +1 -0
- package/dist/components/time-picker.d.cts +41 -0
- package/dist/components/time-picker.d.ts +41 -0
- package/dist/components/time-picker.js +51 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/toast.cjs +99 -0
- package/dist/components/toast.cjs.map +1 -0
- package/dist/components/toast.d.cts +18 -0
- package/dist/components/toast.d.ts +18 -0
- package/dist/components/toast.js +95 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.cjs +75 -0
- package/dist/components/tooltip.cjs.map +1 -0
- package/dist/components/tooltip.d.cts +47 -0
- package/dist/components/tooltip.d.ts +47 -0
- package/dist/components/tooltip.js +67 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/typography.cjs +52 -0
- package/dist/components/typography.cjs.map +1 -0
- package/dist/components/typography.d.cts +32 -0
- package/dist/components/typography.d.ts +32 -0
- package/dist/components/typography.js +45 -0
- package/dist/components/typography.js.map +1 -0
- package/dist/hooks/use-container-width.cjs +22 -0
- package/dist/hooks/use-container-width.cjs.map +1 -0
- package/dist/hooks/use-container-width.d.cts +7 -0
- package/dist/hooks/use-container-width.d.ts +7 -0
- package/dist/hooks/use-container-width.js +20 -0
- package/dist/hooks/use-container-width.js.map +1 -0
- package/dist/icons/index.cjs +7 -0
- package/dist/icons/index.d.cts +4 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +3 -0
- package/dist/icons/material-symbol.cjs +105 -0
- package/dist/icons/material-symbol.cjs.map +1 -0
- package/dist/icons/material-symbol.d.cts +23 -0
- package/dist/icons/material-symbol.d.ts +23 -0
- package/dist/icons/material-symbol.js +100 -0
- package/dist/icons/material-symbol.js.map +1 -0
- package/dist/input-box-variants-BMDdwvqg.cjs +40 -0
- package/dist/input-box-variants-BMDdwvqg.cjs.map +1 -0
- package/dist/input-box-variants-Dr1K7uYE.js +28 -0
- package/dist/input-box-variants-Dr1K7uYE.js.map +1 -0
- package/dist/number-flow-DMJouddg.d.cts +15 -0
- package/dist/number-flow-DSbucQ_K.d.ts +15 -0
- package/dist/styles/index.css +260 -0
- package/dist/styles/internal.css +5 -0
- package/dist/styles/material-symbol.css +22 -0
- package/dist/styles/spark-default.css +888 -0
- package/dist/styles/theme.css +620 -0
- package/dist/styles/utilities.css +557 -0
- package/dist/theme-C19BbKfO.js +574 -0
- package/dist/theme-C19BbKfO.js.map +1 -0
- package/dist/theme-CfFWrMEF.cjs +592 -0
- package/dist/theme-CfFWrMEF.cjs.map +1 -0
- package/dist/theme-types-DoROIXpi.d.ts +30 -0
- package/dist/theme-types-r20EJfEC.d.cts +30 -0
- package/dist/tones-DjgKOX3s.d.cts +8 -0
- package/dist/tones-DyCkL71h.d.ts +8 -0
- package/dist/utils/build-sankey-nodes.cjs +72 -0
- package/dist/utils/build-sankey-nodes.cjs.map +1 -0
- package/dist/utils/build-sankey-nodes.d.cts +27 -0
- package/dist/utils/build-sankey-nodes.d.ts +27 -0
- package/dist/utils/build-sankey-nodes.js +71 -0
- package/dist/utils/build-sankey-nodes.js.map +1 -0
- package/dist/utils/chars.cjs +18 -0
- package/dist/utils/chars.cjs.map +1 -0
- package/dist/utils/chars.d.cts +10 -0
- package/dist/utils/chars.d.ts +10 -0
- package/dist/utils/chars.js +14 -0
- package/dist/utils/chars.js.map +1 -0
- package/dist/utils/chart-scale.cjs +43 -0
- package/dist/utils/chart-scale.cjs.map +1 -0
- package/dist/utils/chart-scale.d.cts +22 -0
- package/dist/utils/chart-scale.d.ts +22 -0
- package/dist/utils/chart-scale.js +41 -0
- package/dist/utils/chart-scale.js.map +1 -0
- package/dist/utils/cn.cjs +10 -0
- package/dist/utils/cn.d.cts +4 -0
- package/dist/utils/cn.d.ts +4 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/date-mask.cjs +45 -0
- package/dist/utils/date-mask.cjs.map +1 -0
- package/dist/utils/date-mask.d.cts +17 -0
- package/dist/utils/date-mask.d.ts +17 -0
- package/dist/utils/date-mask.js +41 -0
- package/dist/utils/date-mask.js.map +1 -0
- package/dist/utils/format.cjs +57 -0
- package/dist/utils/format.cjs.map +1 -0
- package/dist/utils/format.d.cts +23 -0
- package/dist/utils/format.d.ts +23 -0
- package/dist/utils/format.js +47 -0
- package/dist/utils/format.js.map +1 -0
- package/package.json +78 -63
- package/dist/index.cjs +0 -1631
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.cts +0 -299
- package/dist/index.d.ts +0 -299
- package/dist/index.js +0 -1518
- package/dist/index.js.map +0 -1
- package/dist/styles.js +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/components/bar-chart.d.ts
|
|
4
|
+
type BarChartCategory = string | number;
|
|
5
|
+
interface BarChartSeries<TDatum> {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
color: string;
|
|
9
|
+
hoverFill?: string;
|
|
10
|
+
getValue: (datum: TDatum) => number;
|
|
11
|
+
}
|
|
12
|
+
interface BarChartLineSeries<TDatum> {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
color: string;
|
|
16
|
+
/** `null` gaps break the line (e.g. hours without a reading). */
|
|
17
|
+
getValue: (datum: TDatum) => number | null;
|
|
18
|
+
/** Own y-domain for this line (e.g. `[0, 100]` for a percentage). Defaults to the bar scale. */
|
|
19
|
+
domain?: [number, number];
|
|
20
|
+
/** Start hidden; the user can enable the line from the legend. */
|
|
21
|
+
hiddenByDefault?: boolean;
|
|
22
|
+
/** Formats this line's value in the hover tooltip. Defaults to `formatValue`. */
|
|
23
|
+
formatValue?: (value: number) => string;
|
|
24
|
+
strokeDasharray?: string;
|
|
25
|
+
}
|
|
26
|
+
interface BarChartProps<TDatum> {
|
|
27
|
+
data: TDatum[];
|
|
28
|
+
series: BarChartSeries<TDatum>[];
|
|
29
|
+
/** Line overlays drawn on top of the bars, toggleable from the legend. */
|
|
30
|
+
lines?: BarChartLineSeries<TDatum>[];
|
|
31
|
+
getCategory: (datum: TDatum) => BarChartCategory;
|
|
32
|
+
/** Full ordered set of categories on the x-axis. Defaults to `data.map(getCategory)`. */
|
|
33
|
+
categories?: BarChartCategory[];
|
|
34
|
+
/** Subset of categories that should render an x-axis label. Defaults to every category. */
|
|
35
|
+
categoryTicks?: BarChartCategory[];
|
|
36
|
+
formatCategory?: (category: BarChartCategory) => string;
|
|
37
|
+
/** Formats the hovered category in the tooltip header. Defaults to `formatCategory`. */
|
|
38
|
+
formatTooltipCategory?: (category: BarChartCategory) => string;
|
|
39
|
+
highlightedCategory?: BarChartCategory;
|
|
40
|
+
showHighlightLine?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Horizontal reference line drawn across the plot at a given y-value.
|
|
43
|
+
* Useful for thresholds (e.g. price ceiling).
|
|
44
|
+
*/
|
|
45
|
+
referenceLine?: {
|
|
46
|
+
value: number;
|
|
47
|
+
label?: string;
|
|
48
|
+
color?: string;
|
|
49
|
+
};
|
|
50
|
+
title?: string;
|
|
51
|
+
yAxisUnit?: string;
|
|
52
|
+
height?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Override how the total value (sum of focused or all categories) is
|
|
55
|
+
* rendered. `animated` is false while a bar is focused (hover), so an
|
|
56
|
+
* animated total can snap between hovered buckets instead of re-firing a
|
|
57
|
+
* tween on every bar the pointer crosses.
|
|
58
|
+
*/
|
|
59
|
+
renderTotal?: (value: number, animated: boolean) => React.ReactNode;
|
|
60
|
+
/** Format function used when `renderTotal` is not provided. */
|
|
61
|
+
formatTotal?: (value: number) => string;
|
|
62
|
+
/** Formats per-series values in the hover tooltip. Defaults to `formatTotal`. */
|
|
63
|
+
formatValue?: (value: number) => string;
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
declare function BarChart<TDatum>({
|
|
67
|
+
data,
|
|
68
|
+
series,
|
|
69
|
+
lines,
|
|
70
|
+
getCategory,
|
|
71
|
+
categories,
|
|
72
|
+
categoryTicks,
|
|
73
|
+
formatCategory,
|
|
74
|
+
formatTooltipCategory,
|
|
75
|
+
highlightedCategory,
|
|
76
|
+
showHighlightLine,
|
|
77
|
+
referenceLine,
|
|
78
|
+
title,
|
|
79
|
+
yAxisUnit,
|
|
80
|
+
height,
|
|
81
|
+
renderTotal,
|
|
82
|
+
formatTotal,
|
|
83
|
+
formatValue,
|
|
84
|
+
className
|
|
85
|
+
}: BarChartProps<TDatum>): React.ReactElement;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { BarChart, BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries };
|
|
88
|
+
//# sourceMappingURL=bar-chart.d.cts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/components/bar-chart.d.ts
|
|
4
|
+
type BarChartCategory = string | number;
|
|
5
|
+
interface BarChartSeries<TDatum> {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
color: string;
|
|
9
|
+
hoverFill?: string;
|
|
10
|
+
getValue: (datum: TDatum) => number;
|
|
11
|
+
}
|
|
12
|
+
interface BarChartLineSeries<TDatum> {
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
color: string;
|
|
16
|
+
/** `null` gaps break the line (e.g. hours without a reading). */
|
|
17
|
+
getValue: (datum: TDatum) => number | null;
|
|
18
|
+
/** Own y-domain for this line (e.g. `[0, 100]` for a percentage). Defaults to the bar scale. */
|
|
19
|
+
domain?: [number, number];
|
|
20
|
+
/** Start hidden; the user can enable the line from the legend. */
|
|
21
|
+
hiddenByDefault?: boolean;
|
|
22
|
+
/** Formats this line's value in the hover tooltip. Defaults to `formatValue`. */
|
|
23
|
+
formatValue?: (value: number) => string;
|
|
24
|
+
strokeDasharray?: string;
|
|
25
|
+
}
|
|
26
|
+
interface BarChartProps<TDatum> {
|
|
27
|
+
data: TDatum[];
|
|
28
|
+
series: BarChartSeries<TDatum>[];
|
|
29
|
+
/** Line overlays drawn on top of the bars, toggleable from the legend. */
|
|
30
|
+
lines?: BarChartLineSeries<TDatum>[];
|
|
31
|
+
getCategory: (datum: TDatum) => BarChartCategory;
|
|
32
|
+
/** Full ordered set of categories on the x-axis. Defaults to `data.map(getCategory)`. */
|
|
33
|
+
categories?: BarChartCategory[];
|
|
34
|
+
/** Subset of categories that should render an x-axis label. Defaults to every category. */
|
|
35
|
+
categoryTicks?: BarChartCategory[];
|
|
36
|
+
formatCategory?: (category: BarChartCategory) => string;
|
|
37
|
+
/** Formats the hovered category in the tooltip header. Defaults to `formatCategory`. */
|
|
38
|
+
formatTooltipCategory?: (category: BarChartCategory) => string;
|
|
39
|
+
highlightedCategory?: BarChartCategory;
|
|
40
|
+
showHighlightLine?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Horizontal reference line drawn across the plot at a given y-value.
|
|
43
|
+
* Useful for thresholds (e.g. price ceiling).
|
|
44
|
+
*/
|
|
45
|
+
referenceLine?: {
|
|
46
|
+
value: number;
|
|
47
|
+
label?: string;
|
|
48
|
+
color?: string;
|
|
49
|
+
};
|
|
50
|
+
title?: string;
|
|
51
|
+
yAxisUnit?: string;
|
|
52
|
+
height?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Override how the total value (sum of focused or all categories) is
|
|
55
|
+
* rendered. `animated` is false while a bar is focused (hover), so an
|
|
56
|
+
* animated total can snap between hovered buckets instead of re-firing a
|
|
57
|
+
* tween on every bar the pointer crosses.
|
|
58
|
+
*/
|
|
59
|
+
renderTotal?: (value: number, animated: boolean) => React.ReactNode;
|
|
60
|
+
/** Format function used when `renderTotal` is not provided. */
|
|
61
|
+
formatTotal?: (value: number) => string;
|
|
62
|
+
/** Formats per-series values in the hover tooltip. Defaults to `formatTotal`. */
|
|
63
|
+
formatValue?: (value: number) => string;
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
declare function BarChart<TDatum>({
|
|
67
|
+
data,
|
|
68
|
+
series,
|
|
69
|
+
lines,
|
|
70
|
+
getCategory,
|
|
71
|
+
categories,
|
|
72
|
+
categoryTicks,
|
|
73
|
+
formatCategory,
|
|
74
|
+
formatTooltipCategory,
|
|
75
|
+
highlightedCategory,
|
|
76
|
+
showHighlightLine,
|
|
77
|
+
referenceLine,
|
|
78
|
+
title,
|
|
79
|
+
yAxisUnit,
|
|
80
|
+
height,
|
|
81
|
+
renderTotal,
|
|
82
|
+
formatTotal,
|
|
83
|
+
formatValue,
|
|
84
|
+
className
|
|
85
|
+
}: BarChartProps<TDatum>): React.ReactElement;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { BarChart, BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries };
|
|
88
|
+
//# sourceMappingURL=bar-chart.d.ts.map
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { localeNumberFormat } from "../utils/format.js";
|
|
4
|
+
import { buildYAxisScale, formatYAxisTick } from "../utils/chart-scale.js";
|
|
5
|
+
import { ChartTooltipCard, clampTooltipPosition, useMeasuredSize } from "./chart.js";
|
|
6
|
+
import { SeriesLegend } from "./series-legend.js";
|
|
7
|
+
import { SectionTitle } from "./typography.js";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { localPoint } from "@visx/event";
|
|
11
|
+
import { Group } from "@visx/group";
|
|
12
|
+
import { scaleBand, scaleLinear, scaleOrdinal } from "@visx/scale";
|
|
13
|
+
import { BarStack } from "@visx/shape";
|
|
14
|
+
//#region src/components/bar-chart.tsx
|
|
15
|
+
const defaultTotalFormat = localeNumberFormat();
|
|
16
|
+
const PADDING_TOP = 20;
|
|
17
|
+
const PADDING_BOTTOM = 28;
|
|
18
|
+
const HOVER_FADE_MS = 200;
|
|
19
|
+
const FOCUS_TRANSITION_MS = 180;
|
|
20
|
+
const DEFAULT_HEIGHT = 220;
|
|
21
|
+
const BAR_RADIUS = 2;
|
|
22
|
+
const Y_AXIS_GUTTER = 34;
|
|
23
|
+
function buildBarPath(x, y, width, height, radius, roundTop, roundBottom) {
|
|
24
|
+
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
25
|
+
if (r === 0 || !roundTop && !roundBottom) return `M ${x} ${y} H ${x + width} V ${y + height} H ${x} Z`;
|
|
26
|
+
const tl = roundTop ? r : 0;
|
|
27
|
+
const tr = roundTop ? r : 0;
|
|
28
|
+
const br = roundBottom ? r : 0;
|
|
29
|
+
const bl = roundBottom ? r : 0;
|
|
30
|
+
return [
|
|
31
|
+
`M ${x + tl} ${y}`,
|
|
32
|
+
`H ${x + width - tr}`,
|
|
33
|
+
tr > 0 ? `Q ${x + width} ${y} ${x + width} ${y + tr}` : `L ${x + width} ${y}`,
|
|
34
|
+
`V ${y + height - br}`,
|
|
35
|
+
br > 0 ? `Q ${x + width} ${y + height} ${x + width - br} ${y + height}` : `L ${x + width} ${y + height}`,
|
|
36
|
+
`H ${x + bl}`,
|
|
37
|
+
bl > 0 ? `Q ${x} ${y + height} ${x} ${y + height - bl}` : `L ${x} ${y + height}`,
|
|
38
|
+
`V ${y + tl}`,
|
|
39
|
+
tl > 0 ? `Q ${x} ${y} ${x + tl} ${y}` : `L ${x} ${y}`,
|
|
40
|
+
"Z"
|
|
41
|
+
].join(" ");
|
|
42
|
+
}
|
|
43
|
+
function BarStackLayer({ stackData, series, seriesByKey, xScale, yScale, colorScale }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(BarStack, {
|
|
45
|
+
data: stackData,
|
|
46
|
+
keys: series.map((entry) => entry.key),
|
|
47
|
+
x: (record) => record.__category,
|
|
48
|
+
value: (record, key) => record.__values[key] ?? 0,
|
|
49
|
+
xScale,
|
|
50
|
+
yScale,
|
|
51
|
+
color: colorScale,
|
|
52
|
+
offset: "diverging",
|
|
53
|
+
children: (barStacks) => barStacks.map((barStack) => barStack.bars.map((bar) => {
|
|
54
|
+
const values = bar.bar.data.__values;
|
|
55
|
+
const segmentValue = values[barStack.key] ?? 0;
|
|
56
|
+
if (segmentValue === 0) return null;
|
|
57
|
+
const strokeColor = seriesByKey.get(barStack.key)?.color ?? bar.color;
|
|
58
|
+
const fillColor = strokeColor;
|
|
59
|
+
const positiveKeys = series.map((entry) => entry.key).filter((key) => (values[key] ?? 0) > 0);
|
|
60
|
+
const negativeKeys = series.map((entry) => entry.key).filter((key) => (values[key] ?? 0) < 0);
|
|
61
|
+
const roundTop = segmentValue > 0 && positiveKeys[positiveKeys.length - 1] === barStack.key;
|
|
62
|
+
const roundBottom = segmentValue > 0 ? positiveKeys[0] === barStack.key : negativeKeys[negativeKeys.length - 1] === barStack.key;
|
|
63
|
+
const top = bar.height < 0 ? bar.y + bar.height : bar.y;
|
|
64
|
+
const barHeight = Math.abs(bar.height);
|
|
65
|
+
return /* @__PURE__ */ jsx("path", {
|
|
66
|
+
d: buildBarPath(bar.x, top, bar.width, Math.max(0, barHeight), BAR_RADIUS, roundTop, roundBottom),
|
|
67
|
+
fill: fillColor,
|
|
68
|
+
stroke: strokeColor,
|
|
69
|
+
strokeWidth: 1,
|
|
70
|
+
style: { transition: "fill 180ms ease" }
|
|
71
|
+
}, `bar-${barStack.index}-${bar.index}`);
|
|
72
|
+
}))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function FocusBorder({ category, visible, stackData, series, xScale, yScale }) {
|
|
76
|
+
const x = xScale(category);
|
|
77
|
+
const datum = stackData.find((entry) => entry.__category === category);
|
|
78
|
+
if (x === void 0 || !datum) return null;
|
|
79
|
+
if (!series.some((entry) => (datum.__values[entry.key] ?? 0) !== 0)) return null;
|
|
80
|
+
const topY = PADDING_TOP;
|
|
81
|
+
const bottomY = yScale(series.reduce((sum, entry) => sum + Math.min(0, datum.__values[entry.key] ?? 0), 0));
|
|
82
|
+
const borderPaddingX = 4;
|
|
83
|
+
const borderPaddingY = 3;
|
|
84
|
+
const borderXRaw = x - borderPaddingX;
|
|
85
|
+
const borderY = topY - borderPaddingY;
|
|
86
|
+
const borderWidthRaw = xScale.bandwidth() + borderPaddingX * 2;
|
|
87
|
+
const [rangeStart, rangeEnd] = xScale.range();
|
|
88
|
+
const minX = Math.min(rangeStart, rangeEnd);
|
|
89
|
+
const maxX = Math.max(rangeStart, rangeEnd);
|
|
90
|
+
const borderX = Math.max(minX, borderXRaw);
|
|
91
|
+
const borderRight = Math.min(maxX, borderXRaw + borderWidthRaw);
|
|
92
|
+
const borderWidth = Math.max(0, borderRight - borderX);
|
|
93
|
+
const borderHeight = Math.max(1, bottomY - topY + borderPaddingY * 2);
|
|
94
|
+
if (borderWidth <= 0) return null;
|
|
95
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
96
|
+
x: borderX,
|
|
97
|
+
y: borderY,
|
|
98
|
+
width: borderWidth,
|
|
99
|
+
height: borderHeight,
|
|
100
|
+
rx: 6,
|
|
101
|
+
fill: "var(--spark-a2)",
|
|
102
|
+
stroke: "var(--spark-a9)",
|
|
103
|
+
strokeWidth: 2,
|
|
104
|
+
pointerEvents: "none",
|
|
105
|
+
style: {
|
|
106
|
+
opacity: visible ? 1 : 0,
|
|
107
|
+
transition: `x ${FOCUS_TRANSITION_MS}ms ease, y ${FOCUS_TRANSITION_MS}ms ease, width ${FOCUS_TRANSITION_MS}ms ease, height ${FOCUS_TRANSITION_MS}ms ease, opacity ${FOCUS_TRANSITION_MS}ms ease`
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function InteractionLayer({ xDomain, activeCategories, xScale, height, onHoverChange }) {
|
|
112
|
+
const bandwidth = xScale.bandwidth();
|
|
113
|
+
const [rangeStart, rangeEnd] = xScale.range();
|
|
114
|
+
const minX = Math.min(rangeStart, rangeEnd);
|
|
115
|
+
const maxX = Math.max(rangeStart, rangeEnd);
|
|
116
|
+
const handleMove = (event) => {
|
|
117
|
+
const point = localPoint(event);
|
|
118
|
+
if (!point) return;
|
|
119
|
+
let nearest = null;
|
|
120
|
+
let best = Infinity;
|
|
121
|
+
for (const category of xDomain) {
|
|
122
|
+
if (!activeCategories.has(category)) continue;
|
|
123
|
+
const x = xScale(category);
|
|
124
|
+
if (x === void 0) continue;
|
|
125
|
+
const distance = Math.abs(x + bandwidth / 2 - point.x);
|
|
126
|
+
if (distance < best) {
|
|
127
|
+
best = distance;
|
|
128
|
+
nearest = category;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (nearest !== null) onHoverChange(nearest);
|
|
132
|
+
};
|
|
133
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
134
|
+
x: minX,
|
|
135
|
+
y: PADDING_TOP,
|
|
136
|
+
width: Math.max(0, maxX - minX),
|
|
137
|
+
height: height - PADDING_TOP - PADDING_BOTTOM,
|
|
138
|
+
fill: "transparent",
|
|
139
|
+
onMouseMove: handleMove,
|
|
140
|
+
onMouseLeave: () => onHoverChange(null),
|
|
141
|
+
onTouchMove: handleMove,
|
|
142
|
+
onTouchEnd: () => onHoverChange(null)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function CategoryTicks({ ticks, xScale, height, formatCategory }) {
|
|
146
|
+
return /* @__PURE__ */ jsx(Fragment, { children: ticks.map((category) => {
|
|
147
|
+
const x = xScale(category);
|
|
148
|
+
if (x === void 0) return null;
|
|
149
|
+
return /* @__PURE__ */ jsx("text", {
|
|
150
|
+
x: x + xScale.bandwidth() / 2,
|
|
151
|
+
y: height - PADDING_BOTTOM + 16,
|
|
152
|
+
textAnchor: "middle",
|
|
153
|
+
fill: "var(--gray-a11)",
|
|
154
|
+
fontSize: 10,
|
|
155
|
+
children: formatCategory(category)
|
|
156
|
+
}, `tick-${String(category)}`);
|
|
157
|
+
}) });
|
|
158
|
+
}
|
|
159
|
+
function defaultFormatTotal(value) {
|
|
160
|
+
return defaultTotalFormat.format(value);
|
|
161
|
+
}
|
|
162
|
+
function BarChart({ data, series, lines, getCategory, categories, categoryTicks, formatCategory = (category) => String(category), formatTooltipCategory = formatCategory, highlightedCategory, showHighlightLine = false, referenceLine, title, yAxisUnit, height = DEFAULT_HEIGHT, renderTotal, formatTotal = defaultFormatTotal, formatValue, className }) {
|
|
163
|
+
const containerRef = useRef(null);
|
|
164
|
+
const [width, setWidth] = useState(0);
|
|
165
|
+
const [hoveredCategory, setHoveredCategory] = useState(null);
|
|
166
|
+
const [trailingHoverLabel, setTrailingHoverLabel] = useState(null);
|
|
167
|
+
const [hiddenSeries, setHiddenSeries] = useState(() => new Set((lines ?? []).filter((line) => line.hiddenByDefault).map((line) => line.key)));
|
|
168
|
+
const toggleSeries = useCallback((id) => {
|
|
169
|
+
setHiddenSeries((prev) => {
|
|
170
|
+
const next = new Set(prev);
|
|
171
|
+
if (next.has(id)) next.delete(id);
|
|
172
|
+
else next.add(id);
|
|
173
|
+
return next;
|
|
174
|
+
});
|
|
175
|
+
}, []);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
const element = containerRef.current;
|
|
178
|
+
if (!element) return;
|
|
179
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
180
|
+
const entry = entries[0];
|
|
181
|
+
if (!entry) return;
|
|
182
|
+
setWidth(entry.contentRect.width);
|
|
183
|
+
});
|
|
184
|
+
resizeObserver.observe(element);
|
|
185
|
+
return () => {
|
|
186
|
+
resizeObserver.disconnect();
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
const seriesByKey = useMemo(() => {
|
|
190
|
+
const map = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const entry of series) map.set(entry.key, entry);
|
|
192
|
+
return map;
|
|
193
|
+
}, [series]);
|
|
194
|
+
const stackData = useMemo(() => data.map((datum) => {
|
|
195
|
+
const values = {};
|
|
196
|
+
for (const entry of series) values[entry.key] = hiddenSeries.has(entry.key) ? 0 : entry.getValue(datum);
|
|
197
|
+
return {
|
|
198
|
+
__category: getCategory(datum),
|
|
199
|
+
__values: values
|
|
200
|
+
};
|
|
201
|
+
}), [
|
|
202
|
+
data,
|
|
203
|
+
getCategory,
|
|
204
|
+
series,
|
|
205
|
+
hiddenSeries
|
|
206
|
+
]);
|
|
207
|
+
const yMax = useMemo(() => Math.max(1, referenceLine?.value ?? 0, ...stackData.map((record) => series.reduce((sum, entry) => sum + Math.max(0, record.__values[entry.key] ?? 0), 0))), [
|
|
208
|
+
referenceLine,
|
|
209
|
+
series,
|
|
210
|
+
stackData
|
|
211
|
+
]);
|
|
212
|
+
const yMin = useMemo(() => Math.min(0, ...stackData.map((record) => series.reduce((sum, entry) => sum + Math.min(0, record.__values[entry.key] ?? 0), 0))), [series, stackData]);
|
|
213
|
+
const xDomain = useMemo(() => categories ?? stackData.map((record) => record.__category), [categories, stackData]);
|
|
214
|
+
const xScale = useMemo(() => scaleBand({
|
|
215
|
+
domain: xDomain,
|
|
216
|
+
range: [Y_AXIS_GUTTER, Math.max(Y_AXIS_GUTTER, width)],
|
|
217
|
+
padding: .32
|
|
218
|
+
}), [xDomain, width]);
|
|
219
|
+
const yScale = useMemo(() => scaleLinear({
|
|
220
|
+
domain: [yMin, yMax],
|
|
221
|
+
range: [height - PADDING_BOTTOM, PADDING_TOP]
|
|
222
|
+
}), [
|
|
223
|
+
height,
|
|
224
|
+
yMax,
|
|
225
|
+
yMin
|
|
226
|
+
]);
|
|
227
|
+
const colorScale = useMemo(() => scaleOrdinal({
|
|
228
|
+
domain: series.map((entry) => entry.key),
|
|
229
|
+
range: series.map((entry) => entry.color)
|
|
230
|
+
}), [series]);
|
|
231
|
+
const linePaths = useMemo(() => {
|
|
232
|
+
if (!lines || width === 0) return [];
|
|
233
|
+
return lines.filter((line) => !hiddenSeries.has(line.key)).map((line) => {
|
|
234
|
+
const lineScale = line.domain ? scaleLinear({
|
|
235
|
+
domain: line.domain,
|
|
236
|
+
range: [height - PADDING_BOTTOM, PADDING_TOP]
|
|
237
|
+
}) : yScale;
|
|
238
|
+
const segments = [];
|
|
239
|
+
let previous = null;
|
|
240
|
+
for (const datum of data) {
|
|
241
|
+
const x = xScale(getCategory(datum));
|
|
242
|
+
const value = line.getValue(datum);
|
|
243
|
+
if (x === void 0 || value === null || !Number.isFinite(value)) {
|
|
244
|
+
previous = null;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const point = {
|
|
248
|
+
x: x + xScale.bandwidth() / 2,
|
|
249
|
+
y: lineScale(value)
|
|
250
|
+
};
|
|
251
|
+
segments.push(previous === null ? `M ${point.x} ${point.y}` : `L ${point.x} ${point.y}`);
|
|
252
|
+
previous = point;
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
key: line.key,
|
|
256
|
+
d: segments.join(" "),
|
|
257
|
+
color: line.color,
|
|
258
|
+
strokeDasharray: line.strokeDasharray ?? "5 4"
|
|
259
|
+
};
|
|
260
|
+
}).filter((path) => path.d !== "");
|
|
261
|
+
}, [
|
|
262
|
+
lines,
|
|
263
|
+
hiddenSeries,
|
|
264
|
+
data,
|
|
265
|
+
getCategory,
|
|
266
|
+
xScale,
|
|
267
|
+
yScale,
|
|
268
|
+
height,
|
|
269
|
+
width
|
|
270
|
+
]);
|
|
271
|
+
const stackCategorySet = useMemo(() => new Set(stackData.map((record) => record.__category)), [stackData]);
|
|
272
|
+
const lastFocusCategoryRef = useRef(null);
|
|
273
|
+
if (hoveredCategory !== null) lastFocusCategoryRef.current = hoveredCategory;
|
|
274
|
+
const focusCategory = lastFocusCategoryRef.current;
|
|
275
|
+
const focused = useMemo(() => hoveredCategory === null ? null : stackData.find((record) => record.__category === hoveredCategory) ?? null, [hoveredCategory, stackData]);
|
|
276
|
+
const totalValue = useMemo(() => {
|
|
277
|
+
if (focused) return series.reduce((sum, entry) => sum + Math.max(0, focused.__values[entry.key] ?? 0), 0);
|
|
278
|
+
return stackData.reduce((sum, record) => sum + series.reduce((s, entry) => s + Math.max(0, record.__values[entry.key] ?? 0), 0), 0);
|
|
279
|
+
}, [
|
|
280
|
+
focused,
|
|
281
|
+
series,
|
|
282
|
+
stackData
|
|
283
|
+
]);
|
|
284
|
+
const hoverLabel = focused ? formatTooltipCategory(focused.__category) : null;
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
if (hoverLabel) {
|
|
287
|
+
setTrailingHoverLabel(hoverLabel);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const timeoutId = window.setTimeout(() => {
|
|
291
|
+
setTrailingHoverLabel(null);
|
|
292
|
+
}, HOVER_FADE_MS);
|
|
293
|
+
return () => {
|
|
294
|
+
window.clearTimeout(timeoutId);
|
|
295
|
+
};
|
|
296
|
+
}, [hoverLabel]);
|
|
297
|
+
const ticks = categoryTicks ?? xDomain;
|
|
298
|
+
const yTicks = useMemo(() => buildYAxisScale(yMin, yMax).ticks, [yMin, yMax]);
|
|
299
|
+
const highlightX = useMemo(() => {
|
|
300
|
+
if (!showHighlightLine || highlightedCategory === void 0) return null;
|
|
301
|
+
const x = xScale(highlightedCategory);
|
|
302
|
+
if (x === void 0) return null;
|
|
303
|
+
return x + xScale.bandwidth() / 2;
|
|
304
|
+
}, [
|
|
305
|
+
highlightedCategory,
|
|
306
|
+
showHighlightLine,
|
|
307
|
+
xScale
|
|
308
|
+
]);
|
|
309
|
+
const focusedDatum = useMemo(() => hoveredCategory === null ? null : data.find((datum) => getCategory(datum) === hoveredCategory) ?? null, [
|
|
310
|
+
hoveredCategory,
|
|
311
|
+
data,
|
|
312
|
+
getCategory
|
|
313
|
+
]);
|
|
314
|
+
const barStackLayer = useMemo(() => /* @__PURE__ */ jsx(BarStackLayer, {
|
|
315
|
+
stackData,
|
|
316
|
+
series,
|
|
317
|
+
seriesByKey,
|
|
318
|
+
xScale,
|
|
319
|
+
yScale,
|
|
320
|
+
colorScale
|
|
321
|
+
}), [
|
|
322
|
+
stackData,
|
|
323
|
+
series,
|
|
324
|
+
seriesByKey,
|
|
325
|
+
xScale,
|
|
326
|
+
yScale,
|
|
327
|
+
colorScale
|
|
328
|
+
]);
|
|
329
|
+
const fmtTooltipValue = formatValue ?? formatTotal;
|
|
330
|
+
const tooltipRows = focused ? [...series.filter((entry) => (focused.__values[entry.key] ?? 0) !== 0).map((entry) => ({
|
|
331
|
+
key: entry.key,
|
|
332
|
+
label: entry.label,
|
|
333
|
+
color: entry.color,
|
|
334
|
+
value: fmtTooltipValue(Math.abs(focused.__values[entry.key] ?? 0))
|
|
335
|
+
})), ...(lines ?? []).filter((line) => !hiddenSeries.has(line.key)).flatMap((line) => {
|
|
336
|
+
const value = focusedDatum === null ? null : line.getValue(focusedDatum);
|
|
337
|
+
if (value === null || !Number.isFinite(value)) return [];
|
|
338
|
+
return [{
|
|
339
|
+
key: line.key,
|
|
340
|
+
label: line.label,
|
|
341
|
+
color: line.color,
|
|
342
|
+
value: (line.formatValue ?? fmtTooltipValue)(value)
|
|
343
|
+
}];
|
|
344
|
+
})] : [];
|
|
345
|
+
const tooltipActive = tooltipRows.length > 0;
|
|
346
|
+
const anchorX = focusCategory !== null ? (xScale(focusCategory) ?? 0) + xScale.bandwidth() / 2 : 0;
|
|
347
|
+
const anchorY = yScale(totalValue);
|
|
348
|
+
const [tooltipRef, tooltipSize] = useMeasuredSize();
|
|
349
|
+
const tooltipPos = clampTooltipPosition({
|
|
350
|
+
anchorX,
|
|
351
|
+
anchorY,
|
|
352
|
+
width,
|
|
353
|
+
height,
|
|
354
|
+
tipWidth: tooltipSize.width,
|
|
355
|
+
tipHeight: tooltipSize.height
|
|
356
|
+
});
|
|
357
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
358
|
+
className: cn("flex w-full flex-col", className),
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ jsxs("div", {
|
|
361
|
+
className: "flex items-baseline justify-between",
|
|
362
|
+
children: [title && /* @__PURE__ */ jsx(SectionTitle, { children: title }), /* @__PURE__ */ jsx("span", {
|
|
363
|
+
className: "tabular-nums",
|
|
364
|
+
children: renderTotal ? renderTotal(totalValue, focused === null) : /* @__PURE__ */ jsx("span", {
|
|
365
|
+
className: "text-base font-bold text-gray tabular-nums",
|
|
366
|
+
children: formatTotal(totalValue)
|
|
367
|
+
})
|
|
368
|
+
})]
|
|
369
|
+
}),
|
|
370
|
+
/* @__PURE__ */ jsxs("div", {
|
|
371
|
+
className: "flex min-h-5 items-baseline justify-between gap-4",
|
|
372
|
+
children: [/* @__PURE__ */ jsx(SeriesLegend, {
|
|
373
|
+
items: [...series.map((entry) => ({
|
|
374
|
+
id: entry.key,
|
|
375
|
+
label: entry.label,
|
|
376
|
+
color: entry.color
|
|
377
|
+
})), ...(lines ?? []).map((line) => ({
|
|
378
|
+
id: line.key,
|
|
379
|
+
label: line.label,
|
|
380
|
+
color: line.color,
|
|
381
|
+
marker: "dashed-line"
|
|
382
|
+
}))],
|
|
383
|
+
hiddenIds: hiddenSeries,
|
|
384
|
+
onToggle: toggleSeries,
|
|
385
|
+
className: "gap-y-1"
|
|
386
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
387
|
+
className: cn("text-xs text-gray-light transition-opacity duration-200", hoverLabel ? "opacity-100" : "opacity-0"),
|
|
388
|
+
children: trailingHoverLabel ?? " "
|
|
389
|
+
})]
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ jsxs("div", {
|
|
392
|
+
ref: containerRef,
|
|
393
|
+
className: "relative mt-2 w-full",
|
|
394
|
+
style: { height },
|
|
395
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
396
|
+
ref: tooltipRef,
|
|
397
|
+
className: "pointer-events-none absolute z-10",
|
|
398
|
+
style: {
|
|
399
|
+
left: tooltipPos.left,
|
|
400
|
+
top: tooltipPos.top,
|
|
401
|
+
opacity: tooltipActive ? 1 : 0,
|
|
402
|
+
transition: "left 140ms ease-out, top 140ms ease-out, opacity 140ms ease-out"
|
|
403
|
+
},
|
|
404
|
+
children: focusCategory !== null && /* @__PURE__ */ jsx(ChartTooltipCard, {
|
|
405
|
+
label: formatTooltipCategory(focusCategory),
|
|
406
|
+
rows: tooltipRows
|
|
407
|
+
})
|
|
408
|
+
}), width > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
409
|
+
width,
|
|
410
|
+
height,
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsx("line", {
|
|
413
|
+
x1: Y_AXIS_GUTTER,
|
|
414
|
+
x2: Y_AXIS_GUTTER,
|
|
415
|
+
y1: PADDING_TOP,
|
|
416
|
+
y2: height - PADDING_BOTTOM,
|
|
417
|
+
stroke: "var(--gray-a6)",
|
|
418
|
+
strokeWidth: 1
|
|
419
|
+
}),
|
|
420
|
+
yTicks.map((tick, index) => {
|
|
421
|
+
const y = yScale(tick);
|
|
422
|
+
const hideTickLabel = yAxisUnit !== void 0 && index === yTicks.length - 1;
|
|
423
|
+
return /* @__PURE__ */ jsxs("g", { children: [!hideTickLabel && /* @__PURE__ */ jsx("line", {
|
|
424
|
+
x1: Y_AXIS_GUTTER - 4,
|
|
425
|
+
x2: Y_AXIS_GUTTER,
|
|
426
|
+
y1: y,
|
|
427
|
+
y2: y,
|
|
428
|
+
stroke: "var(--gray-a8)",
|
|
429
|
+
strokeWidth: 1
|
|
430
|
+
}), !hideTickLabel && /* @__PURE__ */ jsx("text", {
|
|
431
|
+
x: Y_AXIS_GUTTER - 7,
|
|
432
|
+
y: y + 3,
|
|
433
|
+
textAnchor: "end",
|
|
434
|
+
fill: "var(--gray-a11)",
|
|
435
|
+
fontSize: 10,
|
|
436
|
+
children: formatYAxisTick(tick)
|
|
437
|
+
})] }, `y-tick-${tick}`);
|
|
438
|
+
}),
|
|
439
|
+
yAxisUnit && /* @__PURE__ */ jsx("text", {
|
|
440
|
+
x: 0,
|
|
441
|
+
y: PADDING_TOP - 6,
|
|
442
|
+
textAnchor: "start",
|
|
443
|
+
fill: "var(--gray-a11)",
|
|
444
|
+
fontSize: 10,
|
|
445
|
+
fontWeight: 600,
|
|
446
|
+
children: yAxisUnit
|
|
447
|
+
}),
|
|
448
|
+
highlightX !== null && /* @__PURE__ */ jsx("line", {
|
|
449
|
+
x1: highlightX,
|
|
450
|
+
x2: highlightX,
|
|
451
|
+
y1: PADDING_TOP,
|
|
452
|
+
y2: height - PADDING_BOTTOM,
|
|
453
|
+
stroke: "var(--spark-a9)",
|
|
454
|
+
strokeWidth: 1.5,
|
|
455
|
+
strokeDasharray: "5 4",
|
|
456
|
+
pointerEvents: "none"
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ jsx("line", {
|
|
459
|
+
x1: Y_AXIS_GUTTER,
|
|
460
|
+
x2: width,
|
|
461
|
+
y1: yScale(0),
|
|
462
|
+
y2: yScale(0),
|
|
463
|
+
stroke: "var(--gray-a5)",
|
|
464
|
+
strokeWidth: 1
|
|
465
|
+
}),
|
|
466
|
+
/* @__PURE__ */ jsxs(Group, { children: [
|
|
467
|
+
focusCategory !== null && /* @__PURE__ */ jsx(FocusBorder, {
|
|
468
|
+
category: focusCategory,
|
|
469
|
+
visible: hoveredCategory !== null,
|
|
470
|
+
stackData,
|
|
471
|
+
series,
|
|
472
|
+
xScale,
|
|
473
|
+
yScale
|
|
474
|
+
}),
|
|
475
|
+
barStackLayer,
|
|
476
|
+
referenceLine && /* @__PURE__ */ jsx("line", {
|
|
477
|
+
x1: Y_AXIS_GUTTER,
|
|
478
|
+
x2: width,
|
|
479
|
+
y1: yScale(referenceLine.value),
|
|
480
|
+
y2: yScale(referenceLine.value),
|
|
481
|
+
stroke: referenceLine.color ?? "var(--gray-a11)",
|
|
482
|
+
strokeWidth: 1.5,
|
|
483
|
+
pointerEvents: "none"
|
|
484
|
+
}),
|
|
485
|
+
linePaths.map((path) => /* @__PURE__ */ jsx("path", {
|
|
486
|
+
d: path.d,
|
|
487
|
+
fill: "none",
|
|
488
|
+
stroke: path.color,
|
|
489
|
+
strokeWidth: 1.5,
|
|
490
|
+
strokeDasharray: path.strokeDasharray,
|
|
491
|
+
strokeLinecap: "round",
|
|
492
|
+
strokeLinejoin: "round",
|
|
493
|
+
pointerEvents: "none"
|
|
494
|
+
}, `line-${path.key}`))
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ jsx(InteractionLayer, {
|
|
497
|
+
xDomain,
|
|
498
|
+
activeCategories: stackCategorySet,
|
|
499
|
+
xScale,
|
|
500
|
+
height,
|
|
501
|
+
onHoverChange: setHoveredCategory
|
|
502
|
+
}),
|
|
503
|
+
/* @__PURE__ */ jsx(CategoryTicks, {
|
|
504
|
+
ticks,
|
|
505
|
+
xScale,
|
|
506
|
+
height,
|
|
507
|
+
formatCategory
|
|
508
|
+
})
|
|
509
|
+
]
|
|
510
|
+
})]
|
|
511
|
+
})
|
|
512
|
+
]
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
export { BarChart };
|
|
517
|
+
|
|
518
|
+
//# sourceMappingURL=bar-chart.js.map
|