@epilot/spark-ui 1.0.0-alpha.1 → 1.0.0-alpha.3
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 +519 -0
- package/dist/components/bar-chart.cjs.map +1 -0
- package/dist/components/bar-chart.d.cts +83 -0
- package/dist/components/bar-chart.d.ts +83 -0
- package/dist/components/bar-chart.js +517 -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 +34 -0
- package/dist/components/button.d.ts +34 -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 +23 -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 +21 -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 +56 -0
- package/dist/components/energy-history-chart.cjs.map +1 -0
- package/dist/components/energy-history-chart.d.cts +58 -0
- package/dist/components/energy-history-chart.d.ts +58 -0
- package/dist/components/energy-history-chart.js +54 -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 +310 -0
- package/dist/components/line-chart.cjs.map +1 -0
- package/dist/components/line-chart.d.cts +71 -0
- package/dist/components/line-chart.d.ts +71 -0
- package/dist/components/line-chart.js +307 -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 +358 -0
- package/dist/components/power-history-chart.cjs.map +1 -0
- package/dist/components/power-history-chart.d.cts +54 -0
- package/dist/components/power-history-chart.d.ts +54 -0
- package/dist/components/power-history-chart.js +355 -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 +221 -0
- package/dist/components/sankey-chart.cjs.map +1 -0
- package/dist/components/sankey-chart.d.cts +58 -0
- package/dist/components/sankey-chart.d.ts +58 -0
- package/dist/components/sankey-chart.js +218 -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/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 +105 -0
- package/dist/components/solar-forecast-chart.cjs.map +1 -0
- package/dist/components/solar-forecast-chart.d.cts +66 -0
- package/dist/components/solar-forecast-chart.d.ts +66 -0
- package/dist/components/solar-forecast-chart.js +99 -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 +223 -0
- package/dist/styles/internal.css +5 -0
- package/dist/styles/material-symbol.css +22 -0
- package/dist/styles/spark-default.css +883 -0
- package/dist/styles/theme.css +542 -0
- package/dist/styles/utilities.css +557 -0
- package/dist/theme-B3WtiByA.js +574 -0
- package/dist/theme-B3WtiByA.js.map +1 -0
- package/dist/theme-C9_OSe0S.cjs +592 -0
- package/dist/theme-C9_OSe0S.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 +59 -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 +58 -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/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 +79 -49
- package/dist/index.cjs +0 -303
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.cts +0 -75
- package/dist/index.d.ts +0 -75
- package/dist/index.js +0 -255
- package/dist/index.js.map +0 -1
- package/dist/styles.js +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContainerWidth } from "../hooks/use-container-width.js";
|
|
3
|
+
import "../utils/chars.js";
|
|
4
|
+
import { oneDecimalFormat } from "../utils/format.js";
|
|
5
|
+
import { SeriesLegend } from "./series-legend.js";
|
|
6
|
+
import { SectionTitle } from "./typography.js";
|
|
7
|
+
import { LineChart } from "./line-chart.js";
|
|
8
|
+
import { useCallback, useMemo, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/power-history.tsx
|
|
11
|
+
/** Visual config (colors/classes) per series, independent of labels. */
|
|
12
|
+
const SERIES_STYLE = [
|
|
13
|
+
{
|
|
14
|
+
id: "production",
|
|
15
|
+
color: "var(--orange-a9)",
|
|
16
|
+
strokeClass: "stroke-orange-a9"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "feedin",
|
|
20
|
+
color: "var(--green-a9)",
|
|
21
|
+
strokeClass: "stroke-green-a9"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "grid",
|
|
25
|
+
color: "var(--blue-11)",
|
|
26
|
+
strokeClass: "stroke-blue-11"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "consumption",
|
|
30
|
+
color: "var(--gray-a7)",
|
|
31
|
+
strokeClass: "stroke-gray-a7"
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
function PowerHistory({ solar, consumption, feedIn, grid, formatDate, title = "Power history", seriesLabels }) {
|
|
35
|
+
const [chartContainerRef, chartWidth] = useContainerWidth();
|
|
36
|
+
const [hiddenSeries, setHiddenSeries] = useState(() => /* @__PURE__ */ new Set());
|
|
37
|
+
const toggleSeries = useCallback((id) => {
|
|
38
|
+
setHiddenSeries((prev) => {
|
|
39
|
+
const next = new Set(prev);
|
|
40
|
+
if (next.has(id)) next.delete(id);
|
|
41
|
+
else next.add(id);
|
|
42
|
+
return next;
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
|
+
const dataById = useMemo(() => ({
|
|
46
|
+
production: solar,
|
|
47
|
+
feedin: feedIn,
|
|
48
|
+
grid,
|
|
49
|
+
consumption
|
|
50
|
+
}), [
|
|
51
|
+
consumption,
|
|
52
|
+
feedIn,
|
|
53
|
+
grid,
|
|
54
|
+
solar
|
|
55
|
+
]);
|
|
56
|
+
const labelById = useMemo(() => ({
|
|
57
|
+
production: seriesLabels?.production ?? "Production",
|
|
58
|
+
feedin: seriesLabels?.feedIn ?? "Feed in",
|
|
59
|
+
grid: seriesLabels?.grid ?? "Grid",
|
|
60
|
+
consumption: seriesLabels?.consumption ?? "Consumption"
|
|
61
|
+
}), [seriesLabels]);
|
|
62
|
+
const legendItems = useMemo(() => SERIES_STYLE.map((entry) => ({
|
|
63
|
+
id: entry.id,
|
|
64
|
+
label: labelById[entry.id],
|
|
65
|
+
color: entry.color
|
|
66
|
+
})), [labelById]);
|
|
67
|
+
const visibleSeries = useMemo(() => SERIES_STYLE.filter((entry) => !hiddenSeries.has(entry.id)).map((entry) => ({
|
|
68
|
+
id: entry.id,
|
|
69
|
+
data: dataById[entry.id],
|
|
70
|
+
curve: "monotone",
|
|
71
|
+
className: entry.strokeClass
|
|
72
|
+
})), [dataById, hiddenSeries]);
|
|
73
|
+
if (solar.every((s) => s.value === 0) && consumption.every((c) => c.value === 0) && feedIn.every((f) => f.value === 0) && grid.every((g) => g.value === 0)) return null;
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
75
|
+
className: "flex flex-col gap-3",
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx("div", {
|
|
78
|
+
className: "flex items-center justify-between",
|
|
79
|
+
children: /* @__PURE__ */ jsx(SectionTitle, { children: title })
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsx(SeriesLegend, {
|
|
82
|
+
items: legendItems,
|
|
83
|
+
hiddenIds: hiddenSeries,
|
|
84
|
+
onToggle: toggleSeries
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ jsx("div", {
|
|
87
|
+
ref: chartContainerRef,
|
|
88
|
+
className: "w-full",
|
|
89
|
+
style: { minHeight: 200 },
|
|
90
|
+
children: chartWidth > 0 && visibleSeries.length > 0 && /* @__PURE__ */ jsx(LineChart, {
|
|
91
|
+
width: chartWidth,
|
|
92
|
+
height: 200,
|
|
93
|
+
margin: {
|
|
94
|
+
top: 8,
|
|
95
|
+
right: 8,
|
|
96
|
+
bottom: 28,
|
|
97
|
+
left: 8
|
|
98
|
+
},
|
|
99
|
+
series: visibleSeries,
|
|
100
|
+
showGrid: true,
|
|
101
|
+
showTooltip: true,
|
|
102
|
+
xTickCount: 5,
|
|
103
|
+
yTickCount: 4,
|
|
104
|
+
formatDate,
|
|
105
|
+
formatValue: (v) => `${oneDecimalFormat.format(v / 1e3)} kW`
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { PowerHistory as default };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=power-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"power-history.js","names":["kwFormat"],"sources":["../../src/components/power-history.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport { useContainerWidth } from '../hooks/use-container-width'\nimport { NARROW_NBSP } from '../utils/chars'\nimport { oneDecimalFormat as kwFormat } from '../utils/format'\nimport { LineChart } from './line-chart'\nimport { SeriesLegend, type SeriesLegendItem } from './series-legend'\nimport { SectionTitle } from './typography'\n\ninterface PowerHistorySeries {\n id: string\n label: string\n /** CSS color value (e.g. `var(--orange-a9)`). */\n color: string\n /** Tailwind stroke class applied to the line (e.g. `stroke-orange-a9`). */\n strokeClass: string\n data: { date: Date; value: number }[]\n}\n\n/** Visual config (colors/classes) per series, independent of labels. */\nconst SERIES_STYLE: ReadonlyArray<\n Pick<PowerHistorySeries, 'id' | 'color' | 'strokeClass'>\n> = [\n {\n id: 'production',\n color: 'var(--orange-a9)',\n strokeClass: 'stroke-orange-a9',\n },\n {\n id: 'feedin',\n color: 'var(--green-a9)',\n strokeClass: 'stroke-green-a9',\n },\n {\n id: 'grid',\n color: 'var(--blue-11)',\n strokeClass: 'stroke-blue-11',\n },\n {\n id: 'consumption',\n color: 'var(--gray-a7)',\n strokeClass: 'stroke-gray-a7',\n },\n]\n\ninterface PowerHistorySeriesLabels {\n production?: React.ReactNode\n feedIn?: React.ReactNode\n grid?: React.ReactNode\n consumption?: React.ReactNode\n}\n\nexport default function PowerHistory({\n solar,\n consumption,\n feedIn,\n grid,\n formatDate,\n title = 'Power history',\n seriesLabels,\n}: {\n solar: { date: Date; value: number }[]\n consumption: { date: Date; value: number }[]\n feedIn: { date: Date; value: number }[]\n grid: { date: Date; value: number }[]\n formatDate: (date: Date) => string\n /** Override the section title. Defaults to `\"Power history\"`. */\n title?: React.ReactNode\n /** Override the legend labels for each series. Each defaults to its English name. */\n seriesLabels?: PowerHistorySeriesLabels\n}) {\n const [chartContainerRef, chartWidth] = useContainerWidth<HTMLDivElement>()\n const [hiddenSeries, setHiddenSeries] = useState<ReadonlySet<string>>(\n () => new Set(),\n )\n\n const toggleSeries = useCallback((id: string) => {\n setHiddenSeries((prev) => {\n const next = new Set(prev)\n if (next.has(id)) {\n next.delete(id)\n } else {\n next.add(id)\n }\n return next\n })\n }, [])\n\n const dataById = useMemo(\n () => ({\n production: solar,\n feedin: feedIn,\n grid,\n consumption,\n }),\n [consumption, feedIn, grid, solar],\n )\n\n const labelById = useMemo<Record<string, React.ReactNode>>(\n () => ({\n production: seriesLabels?.production ?? 'Production',\n feedin: seriesLabels?.feedIn ?? 'Feed in',\n grid: seriesLabels?.grid ?? 'Grid',\n consumption: seriesLabels?.consumption ?? 'Consumption',\n }),\n [seriesLabels],\n )\n\n const legendItems: SeriesLegendItem[] = useMemo(\n () =>\n SERIES_STYLE.map((entry) => ({\n id: entry.id,\n label: labelById[entry.id] as string,\n color: entry.color,\n })),\n [labelById],\n )\n\n const visibleSeries = useMemo(\n () =>\n SERIES_STYLE.filter((entry) => !hiddenSeries.has(entry.id)).map(\n (entry) => ({\n id: entry.id,\n data: dataById[entry.id as keyof typeof dataById],\n curve: 'monotone' as const,\n className: entry.strokeClass,\n }),\n ),\n [dataById, hiddenSeries],\n )\n\n const dataEmpty =\n solar.every((s) => s.value === 0) &&\n consumption.every((c) => c.value === 0) &&\n feedIn.every((f) => f.value === 0) &&\n grid.every((g) => g.value === 0)\n\n if (dataEmpty) return null\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-center justify-between\">\n <SectionTitle>{title}</SectionTitle>\n </div>\n\n <SeriesLegend\n items={legendItems}\n hiddenIds={hiddenSeries}\n onToggle={toggleSeries}\n />\n\n <div\n ref={chartContainerRef}\n className=\"w-full\"\n style={{ minHeight: 200 }}\n >\n {chartWidth > 0 && visibleSeries.length > 0 && (\n <LineChart\n width={chartWidth}\n height={200}\n margin={{ top: 8, right: 8, bottom: 28, left: 8 }}\n series={visibleSeries}\n showGrid\n showTooltip\n xTickCount={5}\n yTickCount={4}\n formatDate={formatDate}\n formatValue={(v) => `${kwFormat.format(v / 1000)}${NARROW_NBSP}kW`}\n />\n )}\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,eAEF;CACF;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACd;CACD;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACd;CACD;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACd;CACD;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACd;CACF;AASD,SAAwB,aAAa,EACnC,OACA,aACA,QACA,MACA,YACA,QAAQ,iBACR,gBAWC;CACD,MAAM,CAAC,mBAAmB,cAAc,mBAAmC;CAC3E,MAAM,CAAC,cAAc,mBAAmB,+BAChC,IAAI,KAAK,CAChB;CAED,MAAM,eAAe,aAAa,OAAe;AAC/C,mBAAiB,SAAS;GACxB,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,OAAI,KAAK,IAAI,GAAG,CACd,MAAK,OAAO,GAAG;OAEf,MAAK,IAAI,GAAG;AAEd,UAAO;IACP;IACD,EAAE,CAAC;CAEN,MAAM,WAAW,eACR;EACL,YAAY;EACZ,QAAQ;EACR;EACA;EACD,GACD;EAAC;EAAa;EAAQ;EAAM;EAAM,CACnC;CAED,MAAM,YAAY,eACT;EACL,YAAY,cAAc,cAAc;EACxC,QAAQ,cAAc,UAAU;EAChC,MAAM,cAAc,QAAQ;EAC5B,aAAa,cAAc,eAAe;EAC3C,GACD,CAAC,aAAa,CACf;CAED,MAAM,cAAkC,cAEpC,aAAa,KAAK,WAAW;EAC3B,IAAI,MAAM;EACV,OAAO,UAAU,MAAM;EACvB,OAAO,MAAM;EACd,EAAE,EACL,CAAC,UAAU,CACZ;CAED,MAAM,gBAAgB,cAElB,aAAa,QAAQ,UAAU,CAAC,aAAa,IAAI,MAAM,GAAG,CAAC,CAAC,KACzD,WAAW;EACV,IAAI,MAAM;EACV,MAAM,SAAS,MAAM;EACrB,OAAO;EACP,WAAW,MAAM;EAClB,EACF,EACH,CAAC,UAAU,aAAa,CACzB;AAQD,KALE,MAAM,OAAO,MAAM,EAAE,UAAU,EAAE,IACjC,YAAY,OAAO,MAAM,EAAE,UAAU,EAAE,IACvC,OAAO,OAAO,MAAM,EAAE,UAAU,EAAE,IAClC,KAAK,OAAO,MAAM,EAAE,UAAU,EAAE,CAEnB,QAAO;AAEtB,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf;GACE,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,cAAD,EAAA,UAAe,OAAqB,CAAA;IAChC,CAAA;GAEN,oBAAC,cAAD;IACE,OAAO;IACP,WAAW;IACX,UAAU;IACV,CAAA;GAEF,oBAAC,OAAD;IACE,KAAK;IACL,WAAU;IACV,OAAO,EAAE,WAAW,KAAK;cAExB,aAAa,KAAK,cAAc,SAAS,KACxC,oBAAC,WAAD;KACE,OAAO;KACP,QAAQ;KACR,QAAQ;MAAE,KAAK;MAAG,OAAO;MAAG,QAAQ;MAAI,MAAM;MAAG;KACjD,QAAQ;KACR,UAAA;KACA,aAAA;KACA,YAAY;KACZ,YAAY;KACA;KACZ,cAAc,MAAM,GAAGA,iBAAS,OAAO,IAAI,IAAK;KAChD,CAAA;IAEA,CAAA;GACF"}
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../chunk-aJGBMT86.cjs");
|
|
4
|
+
const require_icons_material_symbol = require("../icons/material-symbol.cjs");
|
|
5
|
+
const require_components_typography = require("./typography.cjs");
|
|
6
|
+
const require_components_number_flow = require("./number-flow.cjs");
|
|
7
|
+
const require_components_skeleton = require("./skeleton.cjs");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let cnfast = require("cnfast");
|
|
11
|
+
//#region src/components/power-network.tsx
|
|
12
|
+
const SOURCE_VARIANTS = {
|
|
13
|
+
grid: {
|
|
14
|
+
activeClassName: "border-blue-a9 bg-blue-a1 shadow-blue-a4",
|
|
15
|
+
flowStroke: "var(--blue-11)",
|
|
16
|
+
initialDashGap: 10
|
|
17
|
+
},
|
|
18
|
+
solar: {
|
|
19
|
+
activeClassName: "border-orange-a9 bg-orange-a1 shadow-orange-a3",
|
|
20
|
+
flowStroke: "var(--orange-a9)",
|
|
21
|
+
initialDashGap: 5
|
|
22
|
+
},
|
|
23
|
+
battery: {
|
|
24
|
+
activeClassName: "border-green-a9 bg-green-a1 shadow-green-a3",
|
|
25
|
+
flowStroke: "var(--green-a9)",
|
|
26
|
+
initialDashGap: 7
|
|
27
|
+
},
|
|
28
|
+
neutral: {
|
|
29
|
+
activeClassName: "border-slate-a9 bg-slate-a1 shadow-slate-a3",
|
|
30
|
+
flowStroke: "var(--slate-a9)",
|
|
31
|
+
initialDashGap: 9
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const DEVICE_FLOW_STROKE = "var(--slate-a9)";
|
|
35
|
+
const DEVICE_INITIAL_DASH_GAP = 9;
|
|
36
|
+
const SKELETON_STROKE = "var(--gray-a6)";
|
|
37
|
+
const STROKE_WIDTH = 2;
|
|
38
|
+
const STRAIGHT_TOLERANCE_PX = 3;
|
|
39
|
+
const SOURCE_HOME_OFFSET_STEP_PX = 10;
|
|
40
|
+
const DEVICE_HOME_OFFSET_STEP_PX = 10;
|
|
41
|
+
const FLOW_DASH_SOLID = 1;
|
|
42
|
+
const FLOW_GAP_MAX = 14;
|
|
43
|
+
const FLOW_GAP_MIN = 5;
|
|
44
|
+
const FLOW_SPEED_MIN = 10;
|
|
45
|
+
const FLOW_SPEED_MAX = 56;
|
|
46
|
+
const FLOW_SMOOTHING = 5.5;
|
|
47
|
+
const PowerNetworkContext = (0, react.createContext)(null);
|
|
48
|
+
function usePowerNetwork() {
|
|
49
|
+
const ctx = (0, react.useContext)(PowerNetworkContext);
|
|
50
|
+
if (!ctx) throw new Error("Power network sub-components must be used inside <PowerNetworkDiagram>.");
|
|
51
|
+
return ctx;
|
|
52
|
+
}
|
|
53
|
+
function anchorTop(rect, containerRect) {
|
|
54
|
+
return {
|
|
55
|
+
x: rect.left + rect.width / 2 - containerRect.left,
|
|
56
|
+
y: rect.top - containerRect.top
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function anchorBottom(rect, containerRect) {
|
|
60
|
+
return {
|
|
61
|
+
x: rect.left + rect.width / 2 - containerRect.left,
|
|
62
|
+
y: rect.bottom - containerRect.top
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function buildAdaptivePath(from, to) {
|
|
66
|
+
if (Math.abs(from.x - to.x) < STRAIGHT_TOLERANCE_PX) return `M ${from.x} ${from.y} L ${to.x} ${to.y}`;
|
|
67
|
+
const dy = to.y - from.y;
|
|
68
|
+
const c1y = from.y + dy * .56;
|
|
69
|
+
const c2y = to.y - dy * .58;
|
|
70
|
+
return `M ${from.x} ${from.y} C ${from.x} ${c1y} ${to.x} ${c2y} ${to.x} ${to.y}`;
|
|
71
|
+
}
|
|
72
|
+
function connectorPathsEqual(a, b) {
|
|
73
|
+
if (a.length !== b.length) return false;
|
|
74
|
+
for (let i = 0; i < a.length; i++) {
|
|
75
|
+
const ap = a[i];
|
|
76
|
+
const bp = b[i];
|
|
77
|
+
if (!ap || !bp) return false;
|
|
78
|
+
if (ap.id !== bp.id || ap.d !== bp.d || ap.variant !== bp.variant || ap.kind !== bp.kind || ap.reversed !== bp.reversed) return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function PowerNetworkDiagram({ title, loading = false, className, children }) {
|
|
83
|
+
const containerRef = (0, react.useRef)(null);
|
|
84
|
+
const [nodes, setNodes] = (0, react.useState)(() => /* @__PURE__ */ new Map());
|
|
85
|
+
const [connectorPaths, setConnectorPaths] = (0, react.useState)([]);
|
|
86
|
+
const connectorPathsRef = (0, react.useRef)([]);
|
|
87
|
+
const flowPathRefs = (0, react.useRef)({});
|
|
88
|
+
const currentFlowVisualsRef = (0, react.useRef)({});
|
|
89
|
+
const targetFlowVisualsRef = (0, react.useRef)({});
|
|
90
|
+
const register = (0, react.useCallback)((node) => {
|
|
91
|
+
setNodes((prev) => {
|
|
92
|
+
const existing = prev.get(node.id);
|
|
93
|
+
if (existing && existing.kind === node.kind && existing.variant === node.variant && existing.watts === node.watts && existing.element === node.element) return prev;
|
|
94
|
+
const next = new Map(prev);
|
|
95
|
+
next.set(node.id, node);
|
|
96
|
+
return next;
|
|
97
|
+
});
|
|
98
|
+
}, []);
|
|
99
|
+
const unregister = (0, react.useCallback)((id) => {
|
|
100
|
+
setNodes((prev) => {
|
|
101
|
+
if (!prev.has(id)) return prev;
|
|
102
|
+
const next = new Map(prev);
|
|
103
|
+
next.delete(id);
|
|
104
|
+
return next;
|
|
105
|
+
});
|
|
106
|
+
}, []);
|
|
107
|
+
const totalSourceWatts = (0, react.useMemo)(() => {
|
|
108
|
+
let total = 0;
|
|
109
|
+
for (const node of nodes.values()) if (node.kind === "source") total += node.watts;
|
|
110
|
+
return total;
|
|
111
|
+
}, [nodes]);
|
|
112
|
+
(0, react.useEffect)(() => {
|
|
113
|
+
const container = containerRef.current;
|
|
114
|
+
if (!container) return;
|
|
115
|
+
let homeNode;
|
|
116
|
+
const sources = [];
|
|
117
|
+
const devices = [];
|
|
118
|
+
for (const node of nodes.values()) if (node.kind === "home") homeNode = node;
|
|
119
|
+
else if (node.element) if (node.kind === "source") sources.push(node);
|
|
120
|
+
else devices.push(node);
|
|
121
|
+
const updatePaths = () => {
|
|
122
|
+
if (!homeNode || !homeNode.element) {
|
|
123
|
+
setConnectorPaths((prev) => prev.length === 0 ? prev : []);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const containerRect = container.getBoundingClientRect();
|
|
127
|
+
const homeRect = homeNode.element.getBoundingClientRect();
|
|
128
|
+
const homeTop = anchorTop(homeRect, containerRect);
|
|
129
|
+
const homeBottom = anchorBottom(homeRect, containerRect);
|
|
130
|
+
const next = [];
|
|
131
|
+
const sourceCount = sources.length;
|
|
132
|
+
const deviceCount = devices.length;
|
|
133
|
+
sources.forEach((source, index) => {
|
|
134
|
+
if (!source.element) return;
|
|
135
|
+
const from = anchorBottom(source.element.getBoundingClientRect(), containerRect);
|
|
136
|
+
const offsetX = SOURCE_HOME_OFFSET_STEP_PX * (index - (sourceCount - 1) / 2);
|
|
137
|
+
const to = {
|
|
138
|
+
x: homeTop.x + offsetX,
|
|
139
|
+
y: homeTop.y
|
|
140
|
+
};
|
|
141
|
+
next.push({
|
|
142
|
+
id: source.id,
|
|
143
|
+
d: buildAdaptivePath(from, to),
|
|
144
|
+
kind: "source",
|
|
145
|
+
variant: source.variant,
|
|
146
|
+
reversed: source.watts < 0
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
devices.forEach((device, index) => {
|
|
150
|
+
if (!device.element) return;
|
|
151
|
+
const to = anchorTop(device.element.getBoundingClientRect(), containerRect);
|
|
152
|
+
const offsetX = DEVICE_HOME_OFFSET_STEP_PX * (index - (deviceCount - 1) / 2);
|
|
153
|
+
const from = {
|
|
154
|
+
x: homeBottom.x + offsetX,
|
|
155
|
+
y: homeBottom.y
|
|
156
|
+
};
|
|
157
|
+
next.push({
|
|
158
|
+
id: device.id,
|
|
159
|
+
d: buildAdaptivePath(from, to),
|
|
160
|
+
kind: "device",
|
|
161
|
+
reversed: false
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
setConnectorPaths((prev) => connectorPathsEqual(prev, next) ? prev : next);
|
|
165
|
+
};
|
|
166
|
+
updatePaths();
|
|
167
|
+
const resizeObserver = new ResizeObserver(updatePaths);
|
|
168
|
+
resizeObserver.observe(container);
|
|
169
|
+
for (const node of nodes.values()) if (node.element) resizeObserver.observe(node.element);
|
|
170
|
+
window.addEventListener("resize", updatePaths);
|
|
171
|
+
return () => {
|
|
172
|
+
resizeObserver.disconnect();
|
|
173
|
+
window.removeEventListener("resize", updatePaths);
|
|
174
|
+
};
|
|
175
|
+
}, [nodes]);
|
|
176
|
+
(0, react.useEffect)(() => {
|
|
177
|
+
connectorPathsRef.current = connectorPaths;
|
|
178
|
+
}, [connectorPaths]);
|
|
179
|
+
(0, react.useEffect)(() => {
|
|
180
|
+
const targets = {};
|
|
181
|
+
const homeWatts = totalSourceWatts;
|
|
182
|
+
for (const node of nodes.values()) {
|
|
183
|
+
if (node.kind === "home") continue;
|
|
184
|
+
const watts = node.watts;
|
|
185
|
+
const relative = homeWatts > 0 ? Math.max(0, Math.min(1, Math.abs(watts) / homeWatts)) : 0;
|
|
186
|
+
targets[node.id] = {
|
|
187
|
+
gap: FLOW_GAP_MAX - (FLOW_GAP_MAX - FLOW_GAP_MIN) * relative,
|
|
188
|
+
speed: FLOW_SPEED_MIN + (FLOW_SPEED_MAX - FLOW_SPEED_MIN) * relative,
|
|
189
|
+
opacity: Math.abs(watts) > 0 ? 1 : 0
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
targetFlowVisualsRef.current = targets;
|
|
193
|
+
}, [nodes, totalSourceWatts]);
|
|
194
|
+
(0, react.useEffect)(() => {
|
|
195
|
+
if (loading) return;
|
|
196
|
+
let frameId = 0;
|
|
197
|
+
let lastFrameTime = performance.now();
|
|
198
|
+
const animate = (now) => {
|
|
199
|
+
const deltaSeconds = Math.max(.001, (now - lastFrameTime) / 1e3);
|
|
200
|
+
lastFrameTime = now;
|
|
201
|
+
const smoothing = 1 - Math.exp(-FLOW_SMOOTHING * deltaSeconds);
|
|
202
|
+
for (const connectorPath of connectorPathsRef.current) {
|
|
203
|
+
const id = connectorPath.id;
|
|
204
|
+
const target = targetFlowVisualsRef.current[id];
|
|
205
|
+
const pathElement = flowPathRefs.current[id];
|
|
206
|
+
if (!target || !pathElement) continue;
|
|
207
|
+
const current = currentFlowVisualsRef.current[id] ?? {
|
|
208
|
+
gap: target.gap,
|
|
209
|
+
offset: 0,
|
|
210
|
+
speed: target.speed,
|
|
211
|
+
opacity: target.opacity
|
|
212
|
+
};
|
|
213
|
+
current.gap += (target.gap - current.gap) * smoothing;
|
|
214
|
+
current.speed += (target.speed - current.speed) * smoothing;
|
|
215
|
+
current.opacity += (target.opacity - current.opacity) * smoothing;
|
|
216
|
+
const dashCycle = FLOW_DASH_SOLID + Math.max(.001, current.gap);
|
|
217
|
+
const direction = connectorPath.reversed ? 1 : -1;
|
|
218
|
+
current.offset = ((current.offset + direction * current.speed * deltaSeconds) % dashCycle + dashCycle) % dashCycle - dashCycle;
|
|
219
|
+
pathElement.setAttribute("stroke-dasharray", `${FLOW_DASH_SOLID} ${current.gap.toFixed(3)}`);
|
|
220
|
+
pathElement.setAttribute("stroke-dashoffset", current.offset.toFixed(3));
|
|
221
|
+
pathElement.setAttribute("opacity", current.opacity.toFixed(3));
|
|
222
|
+
currentFlowVisualsRef.current[id] = current;
|
|
223
|
+
}
|
|
224
|
+
frameId = window.requestAnimationFrame(animate);
|
|
225
|
+
};
|
|
226
|
+
frameId = window.requestAnimationFrame(animate);
|
|
227
|
+
return () => window.cancelAnimationFrame(frameId);
|
|
228
|
+
}, [loading]);
|
|
229
|
+
const contextValue = (0, react.useMemo)(() => ({
|
|
230
|
+
loading,
|
|
231
|
+
register,
|
|
232
|
+
unregister,
|
|
233
|
+
totalSourceWatts
|
|
234
|
+
}), [
|
|
235
|
+
loading,
|
|
236
|
+
register,
|
|
237
|
+
unregister,
|
|
238
|
+
totalSourceWatts
|
|
239
|
+
]);
|
|
240
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PowerNetworkContext.Provider, {
|
|
241
|
+
value: contextValue,
|
|
242
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
243
|
+
ref: containerRef,
|
|
244
|
+
className: (0, cnfast.cn)("@container relative flex flex-col", className),
|
|
245
|
+
children: [
|
|
246
|
+
title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_typography.SectionTitle, { children: title }),
|
|
247
|
+
connectorPaths.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
248
|
+
className: "pointer-events-none absolute inset-0 size-full",
|
|
249
|
+
children: connectorPaths.map((path) => {
|
|
250
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
251
|
+
d: path.d,
|
|
252
|
+
fill: "none",
|
|
253
|
+
stroke: SKELETON_STROKE,
|
|
254
|
+
strokeWidth: STROKE_WIDTH,
|
|
255
|
+
strokeLinecap: "round"
|
|
256
|
+
}, path.id);
|
|
257
|
+
const flowStroke = path.kind === "source" && path.variant ? SOURCE_VARIANTS[path.variant].flowStroke : DEVICE_FLOW_STROKE;
|
|
258
|
+
const initialDashGap = path.kind === "source" && path.variant ? SOURCE_VARIANTS[path.variant].initialDashGap : DEVICE_INITIAL_DASH_GAP;
|
|
259
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
260
|
+
d: path.d,
|
|
261
|
+
fill: "none",
|
|
262
|
+
stroke: "var(--gray-a1)",
|
|
263
|
+
strokeWidth: STROKE_WIDTH,
|
|
264
|
+
strokeLinecap: "round"
|
|
265
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
266
|
+
d: path.d,
|
|
267
|
+
fill: "none",
|
|
268
|
+
stroke: flowStroke,
|
|
269
|
+
strokeWidth: STROKE_WIDTH,
|
|
270
|
+
strokeLinecap: "round",
|
|
271
|
+
ref: (el) => {
|
|
272
|
+
flowPathRefs.current[path.id] = el;
|
|
273
|
+
},
|
|
274
|
+
strokeDasharray: `${FLOW_DASH_SOLID} ${initialDashGap}`,
|
|
275
|
+
strokeDashoffset: 0,
|
|
276
|
+
opacity: 0
|
|
277
|
+
})] }, path.id);
|
|
278
|
+
})
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
281
|
+
className: "flex flex-col gap-y-14",
|
|
282
|
+
children
|
|
283
|
+
})
|
|
284
|
+
]
|
|
285
|
+
})
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function PowerNetworkSources({ className, children }) {
|
|
289
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
290
|
+
className: (0, cnfast.cn)("flex items-center justify-center gap-[clamp(1.5rem,10cqw,4rem)]", className),
|
|
291
|
+
children
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function PowerNetworkDevices({ className, children }) {
|
|
295
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
296
|
+
className: (0, cnfast.cn)("flex items-center justify-center gap-[clamp(1.5rem,10cqw,4rem)]", className),
|
|
297
|
+
children
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function PowerSource({ id: idProp, watts, icon, variant = "neutral", className, progress }) {
|
|
301
|
+
const autoId = (0, react.useId)();
|
|
302
|
+
const id = idProp ?? autoId;
|
|
303
|
+
const { register, unregister, loading } = usePowerNetwork();
|
|
304
|
+
const [element, setElement] = (0, react.useState)(null);
|
|
305
|
+
(0, react.useEffect)(() => {
|
|
306
|
+
if (!element) return;
|
|
307
|
+
register({
|
|
308
|
+
id,
|
|
309
|
+
kind: "source",
|
|
310
|
+
variant,
|
|
311
|
+
watts,
|
|
312
|
+
element
|
|
313
|
+
});
|
|
314
|
+
}, [
|
|
315
|
+
element,
|
|
316
|
+
register,
|
|
317
|
+
id,
|
|
318
|
+
variant,
|
|
319
|
+
watts
|
|
320
|
+
]);
|
|
321
|
+
(0, react.useEffect)(() => {
|
|
322
|
+
return () => unregister(id);
|
|
323
|
+
}, [unregister, id]);
|
|
324
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceSkeleton, { anchorRef: setElement });
|
|
325
|
+
const isActive = watts !== 0;
|
|
326
|
+
const variantStyles = SOURCE_VARIANTS[variant];
|
|
327
|
+
const clampedProgress = progress == null ? null : Math.max(0, Math.min(100, progress));
|
|
328
|
+
const showRing = clampedProgress != null;
|
|
329
|
+
const RING_RADIUS = 48;
|
|
330
|
+
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
|
|
331
|
+
const ringDash = clampedProgress != null ? clampedProgress / 100 * RING_CIRCUMFERENCE : 0;
|
|
332
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
333
|
+
className: (0, cnfast.cn)("flex flex-col items-center justify-center gap-1 transition-opacity duration-500", !isActive && "opacity-45", className),
|
|
334
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_number_flow, {
|
|
335
|
+
value: Math.abs(watts),
|
|
336
|
+
suffix: "W",
|
|
337
|
+
className: "mt-1 text-sm leading-none font-medium"
|
|
338
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
339
|
+
ref: setElement,
|
|
340
|
+
className: (0, cnfast.cn)("relative flex aspect-square items-center justify-center rounded-circle border p-4 shadow-sm", isActive ? variantStyles.activeClassName : "border-gray bg-gray-a3 shadow-gray-a4 saturate-0"),
|
|
341
|
+
children: [showRing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
342
|
+
className: "pointer-events-none absolute inset-0 size-full -rotate-90",
|
|
343
|
+
viewBox: "0 0 100 100",
|
|
344
|
+
"aria-hidden": "true",
|
|
345
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
346
|
+
cx: "50",
|
|
347
|
+
cy: "50",
|
|
348
|
+
r: RING_RADIUS,
|
|
349
|
+
fill: "none",
|
|
350
|
+
stroke: variantStyles.flowStroke,
|
|
351
|
+
strokeWidth: "4",
|
|
352
|
+
strokeLinecap: "round",
|
|
353
|
+
strokeDasharray: `${ringDash} ${RING_CIRCUMFERENCE}`,
|
|
354
|
+
opacity: isActive ? 1 : .5
|
|
355
|
+
})
|
|
356
|
+
}), icon]
|
|
357
|
+
})]
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function SourceSkeleton({ anchorRef }) {
|
|
361
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
362
|
+
className: "flex flex-col items-center justify-center gap-1",
|
|
363
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_skeleton.Skeleton, { className: "h-3.5 w-10" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
364
|
+
ref: anchorRef,
|
|
365
|
+
className: "flex aspect-square animate-pulse items-center justify-center rounded-circle border border-gray bg-base-gray-soft p-4 motion-reduce:animate-none",
|
|
366
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "size-7" })
|
|
367
|
+
})]
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function PowerDevice({ id: idProp, watts, icon, className }) {
|
|
371
|
+
const autoId = (0, react.useId)();
|
|
372
|
+
const id = idProp ?? autoId;
|
|
373
|
+
const { register, unregister, loading } = usePowerNetwork();
|
|
374
|
+
const [element, setElement] = (0, react.useState)(null);
|
|
375
|
+
(0, react.useEffect)(() => {
|
|
376
|
+
if (!element) return;
|
|
377
|
+
register({
|
|
378
|
+
id,
|
|
379
|
+
kind: "device",
|
|
380
|
+
watts,
|
|
381
|
+
element
|
|
382
|
+
});
|
|
383
|
+
}, [
|
|
384
|
+
element,
|
|
385
|
+
register,
|
|
386
|
+
id,
|
|
387
|
+
watts
|
|
388
|
+
]);
|
|
389
|
+
(0, react.useEffect)(() => {
|
|
390
|
+
return () => unregister(id);
|
|
391
|
+
}, [unregister, id]);
|
|
392
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeviceSkeleton, { anchorRef: setElement });
|
|
393
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
394
|
+
className: (0, cnfast.cn)("flex flex-col items-center justify-center gap-1", className),
|
|
395
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
396
|
+
ref: setElement,
|
|
397
|
+
className: "flex aspect-square items-center justify-center rounded-circle border border-gray bg-slate-a1 p-4",
|
|
398
|
+
children: icon
|
|
399
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_number_flow, {
|
|
400
|
+
value: watts,
|
|
401
|
+
suffix: "W",
|
|
402
|
+
className: "text-sm font-medium tabular-nums"
|
|
403
|
+
})]
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
function DeviceSkeleton({ anchorRef }) {
|
|
407
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
408
|
+
className: "flex flex-col items-center justify-center gap-1",
|
|
409
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
410
|
+
ref: anchorRef,
|
|
411
|
+
className: "flex aspect-square animate-pulse items-center justify-center rounded-circle border border-gray bg-base-gray-soft p-4 motion-reduce:animate-none",
|
|
412
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "size-5" })
|
|
413
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_skeleton.Skeleton, { className: "h-3.5 w-10" })]
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function PowerNetworkHome({ watts, autarky, className }) {
|
|
417
|
+
const autoId = (0, react.useId)();
|
|
418
|
+
const { register, unregister, loading, totalSourceWatts } = usePowerNetwork();
|
|
419
|
+
const [element, setElement] = (0, react.useState)(null);
|
|
420
|
+
const effectiveWatts = watts ?? totalSourceWatts;
|
|
421
|
+
(0, react.useEffect)(() => {
|
|
422
|
+
if (!element) return;
|
|
423
|
+
register({
|
|
424
|
+
id: autoId,
|
|
425
|
+
kind: "home",
|
|
426
|
+
watts: effectiveWatts,
|
|
427
|
+
element
|
|
428
|
+
});
|
|
429
|
+
}, [
|
|
430
|
+
element,
|
|
431
|
+
register,
|
|
432
|
+
autoId,
|
|
433
|
+
effectiveWatts
|
|
434
|
+
]);
|
|
435
|
+
(0, react.useEffect)(() => {
|
|
436
|
+
return () => unregister(autoId);
|
|
437
|
+
}, [unregister, autoId]);
|
|
438
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HomeSkeleton, {
|
|
439
|
+
anchorRef: setElement,
|
|
440
|
+
className
|
|
441
|
+
});
|
|
442
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HomeSection, {
|
|
443
|
+
anchorRef: setElement,
|
|
444
|
+
autarky: autarky ?? null,
|
|
445
|
+
watts: effectiveWatts,
|
|
446
|
+
className
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function HomeSection({ anchorRef, autarky, className, watts }) {
|
|
450
|
+
const targetAutarky = autarky == null ? 0 : Math.max(0, Math.min(100, autarky * 100));
|
|
451
|
+
const [animatedAutarky, setAnimatedAutarky] = (0, react.useState)(targetAutarky);
|
|
452
|
+
const animatedAutarkyRef = (0, react.useRef)(animatedAutarky);
|
|
453
|
+
const nodeSize = 78;
|
|
454
|
+
const ringStrokeWidth = 2;
|
|
455
|
+
const radius = (nodeSize - ringStrokeWidth) / 2;
|
|
456
|
+
const circumference = 2 * Math.PI * radius;
|
|
457
|
+
const progressLength = animatedAutarky / 100 * circumference;
|
|
458
|
+
(0, react.useEffect)(() => {
|
|
459
|
+
animatedAutarkyRef.current = animatedAutarky;
|
|
460
|
+
}, [animatedAutarky]);
|
|
461
|
+
(0, react.useEffect)(() => {
|
|
462
|
+
let frameId = 0;
|
|
463
|
+
let lastTime = performance.now();
|
|
464
|
+
const animate = (now) => {
|
|
465
|
+
const deltaSeconds = Math.max(.001, (now - lastTime) / 1e3);
|
|
466
|
+
lastTime = now;
|
|
467
|
+
const smoothing = 1 - Math.exp(-7 * deltaSeconds);
|
|
468
|
+
const next = animatedAutarkyRef.current + (targetAutarky - animatedAutarkyRef.current) * smoothing;
|
|
469
|
+
animatedAutarkyRef.current = next;
|
|
470
|
+
setAnimatedAutarky(next);
|
|
471
|
+
if (Math.abs(targetAutarky - next) > .05) frameId = window.requestAnimationFrame(animate);
|
|
472
|
+
else {
|
|
473
|
+
animatedAutarkyRef.current = targetAutarky;
|
|
474
|
+
setAnimatedAutarky(targetAutarky);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
frameId = window.requestAnimationFrame(animate);
|
|
478
|
+
return () => window.cancelAnimationFrame(frameId);
|
|
479
|
+
}, [targetAutarky]);
|
|
480
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
481
|
+
ref: anchorRef,
|
|
482
|
+
className: (0, cnfast.cn)("relative mx-auto size-[78px]", className),
|
|
483
|
+
children: [autarky != null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
484
|
+
className: "absolute inset-0 size-full -rotate-90",
|
|
485
|
+
viewBox: `0 0 ${nodeSize} ${nodeSize}`,
|
|
486
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
487
|
+
cx: nodeSize / 2,
|
|
488
|
+
cy: nodeSize / 2,
|
|
489
|
+
r: radius,
|
|
490
|
+
fill: "none",
|
|
491
|
+
stroke: "var(--gray-a5)",
|
|
492
|
+
strokeWidth: ringStrokeWidth
|
|
493
|
+
}), progressLength > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
494
|
+
cx: nodeSize / 2,
|
|
495
|
+
cy: nodeSize / 2,
|
|
496
|
+
r: radius,
|
|
497
|
+
fill: "none",
|
|
498
|
+
stroke: "var(--green-a9)",
|
|
499
|
+
strokeLinecap: "round",
|
|
500
|
+
strokeWidth: ringStrokeWidth,
|
|
501
|
+
strokeDasharray: `${progressLength} ${circumference}`
|
|
502
|
+
})]
|
|
503
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
504
|
+
className: "absolute inset-0 flex flex-col items-center justify-center rounded-circle border border-gray-a5 shadow-sm shadow-gray-a1",
|
|
505
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
506
|
+
className: "text-[14px]",
|
|
507
|
+
name: "home"
|
|
508
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_number_flow, {
|
|
509
|
+
value: watts,
|
|
510
|
+
suffix: "W",
|
|
511
|
+
className: "mt-1 text-sm leading-none font-medium"
|
|
512
|
+
})]
|
|
513
|
+
})]
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
function HomeSkeleton({ anchorRef, className }) {
|
|
517
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
518
|
+
ref: anchorRef,
|
|
519
|
+
className: (0, cnfast.cn)("mx-auto size-[78px] animate-pulse rounded-circle border border-gray motion-reduce:animate-none", className)
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
//#endregion
|
|
523
|
+
exports.PowerDevice = PowerDevice;
|
|
524
|
+
exports.PowerNetworkDevices = PowerNetworkDevices;
|
|
525
|
+
exports.PowerNetworkDiagram = PowerNetworkDiagram;
|
|
526
|
+
exports.PowerNetworkHome = PowerNetworkHome;
|
|
527
|
+
exports.PowerNetworkSources = PowerNetworkSources;
|
|
528
|
+
exports.PowerSource = PowerSource;
|
|
529
|
+
|
|
530
|
+
//# sourceMappingURL=power-network.cjs.map
|