@epilot/spark-ui 0.20.0 → 0.20.1
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/dist/components/accordion.cjs +2 -2
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.cjs +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/autocomplete.cjs +1 -1
- package/dist/components/autocomplete.js +1 -1
- package/dist/components/bar-chart-with-total.d.cts +1 -1
- package/dist/components/bar-chart-with-total.d.ts +1 -1
- package/dist/components/bar-chart.cjs +1 -1
- package/dist/components/bar-chart.js +2 -2
- package/dist/components/calendar.cjs +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +2 -2
- package/dist/components/callout.js +1 -1
- package/dist/components/dialog.cjs +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/dropdown-menu.cjs +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/energy-breakdown.cjs +80 -0
- package/dist/components/energy-breakdown.cjs.map +1 -0
- package/dist/components/energy-breakdown.d.cts +24 -0
- package/dist/components/energy-breakdown.d.ts +24 -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 +63 -0
- package/dist/components/energy-history-chart.cjs.map +1 -0
- package/dist/components/energy-history-chart.d.cts +64 -0
- package/dist/components/energy-history-chart.d.ts +64 -0
- package/dist/components/energy-history-chart.js +62 -0
- package/dist/components/energy-history-chart.js.map +1 -0
- package/dist/components/entity-card.d.ts +1 -1
- package/dist/components/input-date.cjs +1 -1
- package/dist/components/input-date.js +1 -1
- package/dist/components/input-group.d.cts +1 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/line-chart.cjs +3 -3
- package/dist/components/line-chart.js +4 -4
- package/dist/components/message-scroller.cjs +2 -2
- package/dist/components/message-scroller.js +2 -2
- package/dist/components/number-flow.d.cts +2 -12
- package/dist/components/number-flow.d.ts +2 -12
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/pill.cjs +1 -1
- package/dist/components/pill.js +1 -1
- package/dist/components/power-history-chart.cjs +498 -0
- package/dist/components/power-history-chart.cjs.map +1 -0
- package/dist/components/power-history-chart.d.cts +71 -0
- package/dist/components/power-history-chart.d.ts +71 -0
- package/dist/components/power-history-chart.js +496 -0
- package/dist/components/power-history-chart.js.map +1 -0
- package/dist/components/power-network.cjs +559 -0
- package/dist/components/power-network.cjs.map +1 -0
- package/dist/components/power-network.d.cts +80 -0
- package/dist/components/power-network.d.ts +80 -0
- package/dist/components/power-network.js +553 -0
- package/dist/components/power-network.js.map +1 -0
- package/dist/components/sankey-chart.cjs +11 -1
- package/dist/components/sankey-chart.cjs.map +1 -1
- package/dist/components/sankey-chart.d.cts +3 -2
- package/dist/components/sankey-chart.d.ts +3 -2
- package/dist/components/sankey-chart.js +11 -2
- package/dist/components/sankey-chart.js.map +1 -1
- package/dist/components/schedule-list.cjs +1 -1
- package/dist/components/schedule-list.js +1 -1
- package/dist/components/select.cjs +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sheet.cjs +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/solar-forecast-chart.cjs +108 -0
- package/dist/components/solar-forecast-chart.cjs.map +1 -0
- package/dist/components/solar-forecast-chart.d.cts +77 -0
- package/dist/components/solar-forecast-chart.d.ts +77 -0
- package/dist/components/solar-forecast-chart.js +103 -0
- package/dist/components/solar-forecast-chart.js.map +1 -0
- package/dist/components/stepper.cjs +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/table.cjs +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.cjs +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/toast.cjs +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/tooltip.cjs +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/number-flow-Bch81ixZ.d.cts +14 -0
- package/dist/number-flow-Bch81ixZ.d.ts +14 -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/format.cjs +13 -0
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.d.cts +7 -1
- package/dist/utils/format.d.ts +7 -1
- package/dist/utils/format.js +12 -1
- package/dist/utils/format.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
|
-
let _base_ui_react_accordion = require("@base-ui/react/accordion");
|
|
5
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
6
4
|
let react = require("react");
|
|
7
5
|
react = require_chunk.__toESM(react);
|
|
6
|
+
let _base_ui_react_accordion = require("@base-ui/react/accordion");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let cnfast = require("cnfast");
|
|
10
10
|
//#region src/components/accordion.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
4
3
|
import * as React$1 from "react";
|
|
4
|
+
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
5
5
|
|
|
6
6
|
//#region src/components/accordion.d.ts
|
|
7
7
|
type AccordionVariant = 'ghost' | 'soft' | 'surface' | 'outline';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
+
import "react";
|
|
3
4
|
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
4
5
|
import { KeyboardArrowDown } from "@epilot/spark-icons";
|
|
5
|
-
import "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/accordion.tsx
|
|
8
8
|
function Accordion({ className, variant = "soft", ...props }) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
const require_components_button = require("./button.cjs");
|
|
5
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_chunk.__toESM(react);
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let _base_ui_react_alert_dialog = require("@base-ui/react/alert-dialog");
|
|
10
10
|
let cnfast = require("cnfast");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { Button, buttonVariants } from "./button.js";
|
|
4
|
-
import { Close } from "@epilot/spark-icons";
|
|
5
4
|
import "react";
|
|
5
|
+
import { Close } from "@epilot/spark-icons";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
|
|
8
8
|
//#region src/components/alert-dialog.tsx
|
|
@@ -5,9 +5,9 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
5
5
|
const require_components_field = require("./field.cjs");
|
|
6
6
|
const require_components_input = require("./input.cjs");
|
|
7
7
|
const require_components_input_group = require("./input-group.cjs");
|
|
8
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
9
8
|
let react = require("react");
|
|
10
9
|
react = require_chunk.__toESM(react);
|
|
10
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
let _base_ui_react_autocomplete = require("@base-ui/react/autocomplete");
|
|
13
13
|
let cnfast = require("cnfast");
|
|
@@ -4,8 +4,8 @@ import { cn } from "../utils/cn.js";
|
|
|
4
4
|
import { useFieldControl } from "./field.js";
|
|
5
5
|
import { Input } from "./input.js";
|
|
6
6
|
import { InputGroup } from "./input-group.js";
|
|
7
|
-
import { Close, KeyboardArrowDown } from "@epilot/spark-icons";
|
|
8
7
|
import * as React$1 from "react";
|
|
8
|
+
import { Close, KeyboardArrowDown } from "@epilot/spark-icons";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
|
|
11
11
|
//#region src/components/autocomplete.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries } from "./bar-chart.cjs";
|
|
4
|
-
import { Format } from "
|
|
4
|
+
import { t as Format } from "../number-flow-Bch81ixZ.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/components/bar-chart-with-total.d.ts
|
|
7
7
|
type BarChartWithTotalProps<TDatum> = Omit<BarChartProps<TDatum>, 'renderTotal' | 'formatTotal'> & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { BarChartCategory, BarChartLineSeries, BarChartProps, BarChartSeries } from "./bar-chart.js";
|
|
4
|
-
import { Format } from "
|
|
4
|
+
import { t as Format } from "../number-flow-Bch81ixZ.js";
|
|
5
5
|
|
|
6
6
|
//#region src/components/bar-chart-with-total.d.ts
|
|
7
7
|
type BarChartWithTotalProps<TDatum> = Omit<BarChartProps<TDatum>, 'renderTotal' | 'formatTotal'> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_hooks_use_reduced_motion = require("../hooks/use-reduced-motion.cjs");
|
|
3
4
|
const require_utils_format = require("../utils/format.cjs");
|
|
4
5
|
const require_utils_chart_scale = require("../utils/chart-scale.cjs");
|
|
5
|
-
const require_hooks_use_reduced_motion = require("../hooks/use-reduced-motion.cjs");
|
|
6
6
|
const require_components_chart = require("./chart.cjs");
|
|
7
7
|
const require_components_series_legend = require("./series-legend.cjs");
|
|
8
8
|
const require_components_typography = require("./typography.cjs");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
2
4
|
import { localeNumberFormat } from "../utils/format.js";
|
|
3
5
|
import { buildYAxisScale, formatYAxisTick, measureYAxisGutter } from "../utils/chart-scale.js";
|
|
4
|
-
import { cn } from "../utils/cn.js";
|
|
5
|
-
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
6
6
|
import { ChartTooltipCard, clampTooltipPosition, useMeasuredSize } from "./chart.js";
|
|
7
7
|
import { SeriesLegend } from "./series-legend.js";
|
|
8
8
|
import { SectionTitle } from "./typography.js";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
const require_components_button = require("./button.cjs");
|
|
5
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_chunk.__toESM(react);
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let _daypicker_react = require("@daypicker/react");
|
|
10
10
|
let cnfast = require("cnfast");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { buttonVariants } from "./button.js";
|
|
4
|
-
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
5
4
|
import "react";
|
|
5
|
+
import { ChevronLeft, ChevronRight } from "@epilot/spark-icons";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { DayPicker } from "@daypicker/react";
|
|
8
8
|
//#region src/components/calendar.tsx
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
const require_components_button = require("./button.cjs");
|
|
5
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_chunk.__toESM(react);
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let class_variance_authority = require("class-variance-authority");
|
|
10
10
|
let cnfast = require("cnfast");
|
|
@@ -8,7 +8,7 @@ import { SparkIcon } from "@epilot/spark-icons";
|
|
|
8
8
|
//#region src/components/callout.d.ts
|
|
9
9
|
type CalloutVariant = 'error' | 'info' | 'neutral' | 'success' | 'warning';
|
|
10
10
|
declare const calloutVariants: (props?: ({
|
|
11
|
-
variant?: "neutral" | "
|
|
11
|
+
variant?: "neutral" | "error" | "success" | "warning" | "info" | null | undefined;
|
|
12
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
13
|
interface CalloutProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof calloutVariants> {
|
|
14
14
|
/** Overrides the variant's default icon; the variant's color is kept. `false` renders no icon. */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { ButtonProps } from "./button.js";
|
|
4
|
-
import { SparkIcon } from "@epilot/spark-icons";
|
|
5
4
|
import * as React$1 from "react";
|
|
5
|
+
import { SparkIcon } from "@epilot/spark-icons";
|
|
6
6
|
import { VariantProps } from "class-variance-authority";
|
|
7
7
|
|
|
8
8
|
//#region src/components/callout.d.ts
|
|
9
9
|
type CalloutVariant = 'error' | 'info' | 'neutral' | 'success' | 'warning';
|
|
10
10
|
declare const calloutVariants: (props?: ({
|
|
11
|
-
variant?: "neutral" | "
|
|
11
|
+
variant?: "neutral" | "error" | "success" | "warning" | "info" | null | undefined;
|
|
12
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
13
|
interface CalloutProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof calloutVariants> {
|
|
14
14
|
/** Overrides the variant's default icon; the variant's color is kept. `false` renders no icon. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { Button } from "./button.js";
|
|
4
|
-
import { Cancel, CheckCircle, Info, Warning } from "@epilot/spark-icons";
|
|
5
4
|
import * as React$1 from "react";
|
|
5
|
+
import { Cancel, CheckCircle, Info, Warning } from "@epilot/spark-icons";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { cva } from "class-variance-authority";
|
|
8
8
|
//#region src/components/callout.tsx
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
const require_components_button = require("./button.cjs");
|
|
5
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_chunk.__toESM(react);
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let _base_ui_react_dialog = require("@base-ui/react/dialog");
|
|
10
10
|
let cnfast = require("cnfast");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { buttonVariants } from "./button.js";
|
|
4
|
-
import { Close } from "@epilot/spark-icons";
|
|
5
4
|
import "react";
|
|
5
|
+
import { Close } from "@epilot/spark-icons";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
8
8
|
//#region src/components/dialog.tsx
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
|
-
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
5
4
|
let react = require("react");
|
|
6
5
|
react = require_chunk.__toESM(react);
|
|
6
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let _base_ui_react_menu = require("@base-ui/react/menu");
|
|
9
9
|
let cnfast = require("cnfast");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
-
import { Check, ChevronRight } from "@epilot/spark-icons";
|
|
4
3
|
import "react";
|
|
4
|
+
import { Check, ChevronRight } from "@epilot/spark-icons";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Menu } from "@base-ui/react/menu";
|
|
7
7
|
//#region src/components/dropdown-menu.tsx
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../utils/chars.cjs");
|
|
4
|
+
const require_utils_format = require("../utils/format.cjs");
|
|
5
|
+
const require_components_donut_chart = require("./donut-chart.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/components/energy-breakdown.tsx
|
|
9
|
+
function formatBreakdownCenter(v) {
|
|
10
|
+
if (v >= 1e3) return require_utils_format.formatThousands(v);
|
|
11
|
+
if (v >= 100) return require_utils_format.integerFormat.format(v);
|
|
12
|
+
if (v >= 10) return require_utils_format.oneDecimalFormat.format(v);
|
|
13
|
+
return require_utils_format.twoDecimalFormat.format(v);
|
|
14
|
+
}
|
|
15
|
+
function EnergyBreakdown({ title, subtitle, items, centerSub = "kWh" }) {
|
|
16
|
+
const sortedItems = (0, react.useMemo)(() => [...items].sort((a, b) => b.value - a.value), [items]);
|
|
17
|
+
const total = items.reduce((s, i) => s + i.value, 0);
|
|
18
|
+
const centerTotal = items.filter((i) => !i.excludeFromCenterTotal).reduce((s, i) => s + i.value, 0);
|
|
19
|
+
if (total === 0) return null;
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
21
|
+
className: "flex flex-col gap-4 pt-3 pb-5",
|
|
22
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
23
|
+
className: "flex flex-col gap-0.5",
|
|
24
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
25
|
+
className: "text-sm font-semibold text-gray",
|
|
26
|
+
children: title
|
|
27
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
28
|
+
className: "text-xs text-gray-light",
|
|
29
|
+
children: subtitle
|
|
30
|
+
})]
|
|
31
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32
|
+
className: "flex items-center gap-6",
|
|
33
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_donut_chart.DonutChart, {
|
|
34
|
+
centerLabel: formatBreakdownCenter(centerTotal),
|
|
35
|
+
centerSub,
|
|
36
|
+
segments: sortedItems.map(({ value, color }) => ({
|
|
37
|
+
value,
|
|
38
|
+
color
|
|
39
|
+
}))
|
|
40
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
41
|
+
className: "flex flex-1 flex-col gap-3",
|
|
42
|
+
children: sortedItems.map(({ label, value, color }) => {
|
|
43
|
+
const pct = value / total * 100;
|
|
44
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
45
|
+
className: "flex flex-col gap-1.5",
|
|
46
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
47
|
+
className: "flex items-baseline justify-between gap-2",
|
|
48
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
49
|
+
className: "min-w-0 truncate text-sm font-medium text-gray",
|
|
50
|
+
children: label
|
|
51
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
52
|
+
className: "flex shrink-0 items-baseline gap-1.5 text-xs tabular-nums",
|
|
53
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
54
|
+
className: "text-gray-light",
|
|
55
|
+
children: require_utils_format.formatEnergy(value)
|
|
56
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
57
|
+
className: "font-semibold text-gray",
|
|
58
|
+
children: `${require_utils_format.integerFormat.format(pct)} %`
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
62
|
+
className: "h-1 w-full overflow-hidden rounded-full bg-gray-a4",
|
|
63
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
64
|
+
className: "h-full rounded-full",
|
|
65
|
+
style: {
|
|
66
|
+
width: `${pct}%`,
|
|
67
|
+
background: color
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
})]
|
|
71
|
+
}, label);
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
exports.EnergyBreakdown = EnergyBreakdown;
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=energy-breakdown.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energy-breakdown.cjs","names":["formatThousands","integerFormat","oneDecimalFormat","twoDecimalFormat","DonutChart","formatEnergy"],"sources":["../../src/components/energy-breakdown.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { NARROW_NBSP } from '../utils/chars'\nimport {\n formatEnergy,\n formatThousands,\n integerFormat,\n oneDecimalFormat,\n twoDecimalFormat,\n} from '../utils/format'\nimport { DonutChart } from './donut-chart'\n\nexport type BreakdownItem = {\n label: string\n value: number\n color: string\n excludeFromCenterTotal?: boolean\n}\n\nexport type EnergyBreakdownProps = {\n title: string\n subtitle: string\n items: BreakdownItem[]\n centerSub?: string\n}\n\nfunction formatBreakdownCenter(v: number) {\n if (v >= 1000) return formatThousands(v)\n if (v >= 100) return integerFormat.format(v)\n if (v >= 10) return oneDecimalFormat.format(v)\n return twoDecimalFormat.format(v)\n}\n\nexport function EnergyBreakdown({\n title,\n subtitle,\n items,\n centerSub = 'kWh',\n}: EnergyBreakdownProps) {\n const sortedItems = useMemo(\n () => [...items].sort((a, b) => b.value - a.value),\n [items],\n )\n\n const total = items.reduce((s, i) => s + i.value, 0)\n const centerTotal = items\n .filter((i) => !i.excludeFromCenterTotal)\n .reduce((s, i) => s + i.value, 0)\n\n const dataEmpty = total === 0\n\n if (dataEmpty) return null\n\n return (\n <div className=\"flex flex-col gap-4 pt-3 pb-5\">\n <div className=\"flex flex-col gap-0.5\">\n <span className=\"text-sm font-semibold text-gray\">{title}</span>\n <span className=\"text-xs text-gray-light\">{subtitle}</span>\n </div>\n\n <div className=\"flex items-center gap-6\">\n <DonutChart\n centerLabel={formatBreakdownCenter(centerTotal)}\n centerSub={centerSub}\n segments={sortedItems.map(({ value, color }) => ({ value, color }))}\n />\n\n <div className=\"flex flex-1 flex-col gap-3\">\n {sortedItems.map(({ label, value, color }) => {\n const pct = (value / total) * 100\n return (\n <div key={label} className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-baseline justify-between gap-2\">\n <span className=\"min-w-0 truncate text-sm font-medium text-gray\">\n {label}\n </span>\n <span className=\"flex shrink-0 items-baseline gap-1.5 text-xs tabular-nums\">\n <span className=\"text-gray-light\">\n {formatEnergy(value)}\n </span>\n <span className=\"font-semibold text-gray\">\n {`${integerFormat.format(pct)}${NARROW_NBSP}%`}\n </span>\n </span>\n </div>\n <div className=\"h-1 w-full overflow-hidden rounded-full bg-gray-a4\">\n <div\n className=\"h-full rounded-full\"\n style={{ width: `${pct}%`, background: color }}\n />\n </div>\n </div>\n )\n })}\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAyBA,SAAS,sBAAsB,GAAW;CACxC,IAAI,KAAK,KAAM,OAAOA,qBAAAA,gBAAgB,CAAC;CACvC,IAAI,KAAK,KAAK,OAAOC,qBAAAA,cAAc,OAAO,CAAC;CAC3C,IAAI,KAAK,IAAI,OAAOC,qBAAAA,iBAAiB,OAAO,CAAC;CAC7C,OAAOC,qBAAAA,iBAAiB,OAAO,CAAC;AAClC;AAEA,SAAgB,gBAAgB,EAC9B,OACA,UACA,OACA,YAAY,SACW;CACvB,MAAM,eAAA,GAAA,MAAA,eACE,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,GACjD,CAAC,KAAK,CACR;CAEA,MAAM,QAAQ,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,OAAO,CAAC;CACnD,MAAM,cAAc,MACjB,QAAQ,MAAM,CAAC,EAAE,sBAAsB,EACvC,QAAQ,GAAG,MAAM,IAAI,EAAE,OAAO,CAAC;CAIlC,IAFkB,UAAU,GAEb,OAAO;CAEtB,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EAAK,WAAU;YAAf,CACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,WAAU;cAAmC;GAAY,CAAA,GAC/D,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAAM,WAAU;cAA2B;GAAe,CAAA,CACvD;MAEL,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf,CACE,iBAAA,GAAA,kBAAA,KAACC,+BAAAA,YAAD;IACE,aAAa,sBAAsB,WAAW;IACnC;IACX,UAAU,YAAY,KAAK,EAAE,OAAO,aAAa;KAAE;KAAO;IAAM,EAAE;GACnE,CAAA,GAED,iBAAA,GAAA,kBAAA,KAAC,OAAD;IAAK,WAAU;cACZ,YAAY,KAAK,EAAE,OAAO,OAAO,YAAY;KAC5C,MAAM,MAAO,QAAQ,QAAS;KAC9B,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;MAAiB,WAAU;gBAA3B,CACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;OAAK,WAAU;iBAAf,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;QAAM,WAAU;kBACb;OACG,CAAA,GACN,iBAAA,GAAA,kBAAA,MAAC,QAAD;QAAM,WAAU;kBAAhB,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;SAAM,WAAU;mBACbC,qBAAAA,aAAa,KAAK;QACf,CAAA,GACN,iBAAA,GAAA,kBAAA,KAAC,QAAD;SAAM,WAAU;mBACb,GAAGJ,qBAAAA,cAAc,OAAO,GAAG;QACxB,CAAA,CACF;SACH;UACL,iBAAA,GAAA,kBAAA,KAAC,OAAD;OAAK,WAAU;iBACb,iBAAA,GAAA,kBAAA,KAAC,OAAD;QACE,WAAU;QACV,OAAO;SAAE,OAAO,GAAG,IAAI;SAAI,YAAY;QAAM;OAC9C,CAAA;MACE,CAAA,CACF;QApBK,KAoBL;IAET,CAAC;GACE,CAAA,CACF;IACF;;AAET"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/components/energy-breakdown.d.ts
|
|
4
|
+
type BreakdownItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: number;
|
|
7
|
+
color: string;
|
|
8
|
+
excludeFromCenterTotal?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type EnergyBreakdownProps = {
|
|
11
|
+
title: string;
|
|
12
|
+
subtitle: string;
|
|
13
|
+
items: BreakdownItem[];
|
|
14
|
+
centerSub?: string;
|
|
15
|
+
};
|
|
16
|
+
declare function EnergyBreakdown({
|
|
17
|
+
title,
|
|
18
|
+
subtitle,
|
|
19
|
+
items,
|
|
20
|
+
centerSub
|
|
21
|
+
}: EnergyBreakdownProps): import("react/jsx-runtime").JSX.Element | null;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { BreakdownItem, EnergyBreakdown, EnergyBreakdownProps };
|
|
24
|
+
//# sourceMappingURL=energy-breakdown.d.cts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/components/energy-breakdown.d.ts
|
|
4
|
+
type BreakdownItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: number;
|
|
7
|
+
color: string;
|
|
8
|
+
excludeFromCenterTotal?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type EnergyBreakdownProps = {
|
|
11
|
+
title: string;
|
|
12
|
+
subtitle: string;
|
|
13
|
+
items: BreakdownItem[];
|
|
14
|
+
centerSub?: string;
|
|
15
|
+
};
|
|
16
|
+
declare function EnergyBreakdown({
|
|
17
|
+
title,
|
|
18
|
+
subtitle,
|
|
19
|
+
items,
|
|
20
|
+
centerSub
|
|
21
|
+
}: EnergyBreakdownProps): import("react/jsx-runtime").JSX.Element | null;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { BreakdownItem, EnergyBreakdown, EnergyBreakdownProps };
|
|
24
|
+
//# sourceMappingURL=energy-breakdown.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../utils/chars.js";
|
|
3
|
+
import { formatEnergy, formatThousands, integerFormat, oneDecimalFormat, twoDecimalFormat } from "../utils/format.js";
|
|
4
|
+
import { DonutChart } from "./donut-chart.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/energy-breakdown.tsx
|
|
8
|
+
function formatBreakdownCenter(v) {
|
|
9
|
+
if (v >= 1e3) return formatThousands(v);
|
|
10
|
+
if (v >= 100) return integerFormat.format(v);
|
|
11
|
+
if (v >= 10) return oneDecimalFormat.format(v);
|
|
12
|
+
return twoDecimalFormat.format(v);
|
|
13
|
+
}
|
|
14
|
+
function EnergyBreakdown({ title, subtitle, items, centerSub = "kWh" }) {
|
|
15
|
+
const sortedItems = useMemo(() => [...items].sort((a, b) => b.value - a.value), [items]);
|
|
16
|
+
const total = items.reduce((s, i) => s + i.value, 0);
|
|
17
|
+
const centerTotal = items.filter((i) => !i.excludeFromCenterTotal).reduce((s, i) => s + i.value, 0);
|
|
18
|
+
if (total === 0) return null;
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "flex flex-col gap-4 pt-3 pb-5",
|
|
21
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: "flex flex-col gap-0.5",
|
|
23
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
24
|
+
className: "text-sm font-semibold text-gray",
|
|
25
|
+
children: title
|
|
26
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
27
|
+
className: "text-xs text-gray-light",
|
|
28
|
+
children: subtitle
|
|
29
|
+
})]
|
|
30
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "flex items-center gap-6",
|
|
32
|
+
children: [/* @__PURE__ */ jsx(DonutChart, {
|
|
33
|
+
centerLabel: formatBreakdownCenter(centerTotal),
|
|
34
|
+
centerSub,
|
|
35
|
+
segments: sortedItems.map(({ value, color }) => ({
|
|
36
|
+
value,
|
|
37
|
+
color
|
|
38
|
+
}))
|
|
39
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
40
|
+
className: "flex flex-1 flex-col gap-3",
|
|
41
|
+
children: sortedItems.map(({ label, value, color }) => {
|
|
42
|
+
const pct = value / total * 100;
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "flex flex-col gap-1.5",
|
|
45
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: "flex items-baseline justify-between gap-2",
|
|
47
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
48
|
+
className: "min-w-0 truncate text-sm font-medium text-gray",
|
|
49
|
+
children: label
|
|
50
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
51
|
+
className: "flex shrink-0 items-baseline gap-1.5 text-xs tabular-nums",
|
|
52
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: "text-gray-light",
|
|
54
|
+
children: formatEnergy(value)
|
|
55
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: "font-semibold text-gray",
|
|
57
|
+
children: `${integerFormat.format(pct)} %`
|
|
58
|
+
})]
|
|
59
|
+
})]
|
|
60
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: "h-1 w-full overflow-hidden rounded-full bg-gray-a4",
|
|
62
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "h-full rounded-full",
|
|
64
|
+
style: {
|
|
65
|
+
width: `${pct}%`,
|
|
66
|
+
background: color
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
}, label);
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { EnergyBreakdown };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=energy-breakdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energy-breakdown.js","names":[],"sources":["../../src/components/energy-breakdown.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { NARROW_NBSP } from '../utils/chars'\nimport {\n formatEnergy,\n formatThousands,\n integerFormat,\n oneDecimalFormat,\n twoDecimalFormat,\n} from '../utils/format'\nimport { DonutChart } from './donut-chart'\n\nexport type BreakdownItem = {\n label: string\n value: number\n color: string\n excludeFromCenterTotal?: boolean\n}\n\nexport type EnergyBreakdownProps = {\n title: string\n subtitle: string\n items: BreakdownItem[]\n centerSub?: string\n}\n\nfunction formatBreakdownCenter(v: number) {\n if (v >= 1000) return formatThousands(v)\n if (v >= 100) return integerFormat.format(v)\n if (v >= 10) return oneDecimalFormat.format(v)\n return twoDecimalFormat.format(v)\n}\n\nexport function EnergyBreakdown({\n title,\n subtitle,\n items,\n centerSub = 'kWh',\n}: EnergyBreakdownProps) {\n const sortedItems = useMemo(\n () => [...items].sort((a, b) => b.value - a.value),\n [items],\n )\n\n const total = items.reduce((s, i) => s + i.value, 0)\n const centerTotal = items\n .filter((i) => !i.excludeFromCenterTotal)\n .reduce((s, i) => s + i.value, 0)\n\n const dataEmpty = total === 0\n\n if (dataEmpty) return null\n\n return (\n <div className=\"flex flex-col gap-4 pt-3 pb-5\">\n <div className=\"flex flex-col gap-0.5\">\n <span className=\"text-sm font-semibold text-gray\">{title}</span>\n <span className=\"text-xs text-gray-light\">{subtitle}</span>\n </div>\n\n <div className=\"flex items-center gap-6\">\n <DonutChart\n centerLabel={formatBreakdownCenter(centerTotal)}\n centerSub={centerSub}\n segments={sortedItems.map(({ value, color }) => ({ value, color }))}\n />\n\n <div className=\"flex flex-1 flex-col gap-3\">\n {sortedItems.map(({ label, value, color }) => {\n const pct = (value / total) * 100\n return (\n <div key={label} className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-baseline justify-between gap-2\">\n <span className=\"min-w-0 truncate text-sm font-medium text-gray\">\n {label}\n </span>\n <span className=\"flex shrink-0 items-baseline gap-1.5 text-xs tabular-nums\">\n <span className=\"text-gray-light\">\n {formatEnergy(value)}\n </span>\n <span className=\"font-semibold text-gray\">\n {`${integerFormat.format(pct)}${NARROW_NBSP}%`}\n </span>\n </span>\n </div>\n <div className=\"h-1 w-full overflow-hidden rounded-full bg-gray-a4\">\n <div\n className=\"h-full rounded-full\"\n style={{ width: `${pct}%`, background: color }}\n />\n </div>\n </div>\n )\n })}\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;AAyBA,SAAS,sBAAsB,GAAW;CACxC,IAAI,KAAK,KAAM,OAAO,gBAAgB,CAAC;CACvC,IAAI,KAAK,KAAK,OAAO,cAAc,OAAO,CAAC;CAC3C,IAAI,KAAK,IAAI,OAAO,iBAAiB,OAAO,CAAC;CAC7C,OAAO,iBAAiB,OAAO,CAAC;AAClC;AAEA,SAAgB,gBAAgB,EAC9B,OACA,UACA,OACA,YAAY,SACW;CACvB,MAAM,cAAc,cACZ,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,GACjD,CAAC,KAAK,CACR;CAEA,MAAM,QAAQ,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,OAAO,CAAC;CACnD,MAAM,cAAc,MACjB,QAAQ,MAAM,CAAC,EAAE,sBAAsB,EACvC,QAAQ,GAAG,MAAM,IAAI,EAAE,OAAO,CAAC;CAIlC,IAFkB,UAAU,GAEb,OAAO;CAEtB,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,QAAD;IAAM,WAAU;cAAmC;GAAY,CAAA,GAC/D,oBAAC,QAAD;IAAM,WAAU;cAA2B;GAAe,CAAA,CACvD;MAEL,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,YAAD;IACE,aAAa,sBAAsB,WAAW;IACnC;IACX,UAAU,YAAY,KAAK,EAAE,OAAO,aAAa;KAAE;KAAO;IAAM,EAAE;GACnE,CAAA,GAED,oBAAC,OAAD;IAAK,WAAU;cACZ,YAAY,KAAK,EAAE,OAAO,OAAO,YAAY;KAC5C,MAAM,MAAO,QAAQ,QAAS;KAC9B,OACE,qBAAC,OAAD;MAAiB,WAAU;gBAA3B,CACE,qBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,oBAAC,QAAD;QAAM,WAAU;kBACb;OACG,CAAA,GACN,qBAAC,QAAD;QAAM,WAAU;kBAAhB,CACE,oBAAC,QAAD;SAAM,WAAU;mBACb,aAAa,KAAK;QACf,CAAA,GACN,oBAAC,QAAD;SAAM,WAAU;mBACb,GAAG,cAAc,OAAO,GAAG;QACxB,CAAA,CACF;SACH;UACL,oBAAC,OAAD;OAAK,WAAU;iBACb,oBAAC,OAAD;QACE,WAAU;QACV,OAAO;SAAE,OAAO,GAAG,IAAI;SAAI,YAAY;QAAM;OAC9C,CAAA;MACE,CAAA,CACF;QApBK,KAoBL;IAET,CAAC;GACE,CAAA,CACF;IACF;;AAET"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../utils/chars.cjs");
|
|
4
|
+
const require_utils_format = require("../utils/format.cjs");
|
|
5
|
+
const require_components_bar_chart_with_total = require("./bar-chart-with-total.cjs");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/components/energy-history-chart.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Energy-per-bucket stacked bar chart: solar (orange), battery (green) and grid
|
|
10
|
+
* (blue) energy sources stacked per bucket, the total height being the energy
|
|
11
|
+
* consumed. Grid feed-in (translucent blue) dips below the baseline as an
|
|
12
|
+
* export. For cumulative energy (week/month/year views). Thin wrapper over the
|
|
13
|
+
* shared visx `BarChart`, so it inherits the card tooltip and both indicators.
|
|
14
|
+
*/
|
|
15
|
+
function EnergyHistoryChart({ data, unit, formatValue, formatBucketLabel, labels, omitSeries, highlightedBucket, showHighlightLine, title, className, height = 260, categoryTicks }) {
|
|
16
|
+
const fmtValue = (value) => formatValue ? formatValue(value) : `${require_utils_format.twoDecimalFormat.format(value)} ${unit}`;
|
|
17
|
+
const omitted = new Set(omitSeries);
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_bar_chart_with_total.BarChartWithTotal, {
|
|
19
|
+
data,
|
|
20
|
+
series: [
|
|
21
|
+
{
|
|
22
|
+
key: "solar",
|
|
23
|
+
label: labels.solar,
|
|
24
|
+
color: "var(--orange-9)",
|
|
25
|
+
getValue: (d) => d.solar
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "battery",
|
|
29
|
+
label: labels.battery,
|
|
30
|
+
color: "var(--green-9)",
|
|
31
|
+
getValue: (d) => d.battery
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "grid",
|
|
35
|
+
label: labels.grid,
|
|
36
|
+
color: "var(--blue-9)",
|
|
37
|
+
getValue: (d) => d.grid
|
|
38
|
+
},
|
|
39
|
+
...labels.gridFeedIn !== void 0 ? [{
|
|
40
|
+
key: "gridFeedIn",
|
|
41
|
+
label: labels.gridFeedIn,
|
|
42
|
+
color: "var(--blue-7)",
|
|
43
|
+
getValue: (d) => -Math.max(0, d.gridFeedIn ?? 0)
|
|
44
|
+
}] : []
|
|
45
|
+
].filter((s) => !omitted.has(s.key)),
|
|
46
|
+
getCategory: (d) => d.bucket,
|
|
47
|
+
title,
|
|
48
|
+
yAxisUnit: unit,
|
|
49
|
+
height,
|
|
50
|
+
className,
|
|
51
|
+
formatValue: fmtValue,
|
|
52
|
+
categoryTicks,
|
|
53
|
+
...formatBucketLabel && { formatTooltipCategory: (category) => formatBucketLabel(String(category)) },
|
|
54
|
+
totalSuffix: unit,
|
|
55
|
+
totalFormat: { maximumFractionDigits: 2 },
|
|
56
|
+
...highlightedBucket !== void 0 && { highlightedCategory: highlightedBucket },
|
|
57
|
+
...showHighlightLine !== void 0 && { showHighlightLine }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.EnergyHistoryChart = EnergyHistoryChart;
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=energy-history-chart.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energy-history-chart.cjs","names":["valueFormat","BarChartWithTotal"],"sources":["../../src/components/energy-history-chart.tsx"],"sourcesContent":["import { NARROW_NBSP } from '../utils/chars'\nimport { twoDecimalFormat as valueFormat } from '../utils/format'\nimport type { BarChartSeries } from './bar-chart'\nimport { BarChartWithTotal } from './bar-chart-with-total'\n\nexport interface EnergyHistoryDatum {\n /** Bucket label/id (e.g. weekday, day-of-month, month). */\n bucket: string\n /** Solar used on-site (kWh, ≥ 0). */\n solar: number\n /** Battery discharged (kWh, ≥ 0). */\n battery: number\n /** Grid imported (kWh, ≥ 0). */\n grid: number\n /** Grid feed-in (kWh, ≥ 0); drawn below the baseline as an export. */\n gridFeedIn?: number\n}\n\nexport interface EnergyHistoryChartProps {\n data: EnergyHistoryDatum[]\n /** Axis/tooltip unit, e.g. \"kWh\". */\n unit: string\n formatValue?: (value: number) => string\n /** Formats the hovered bucket in the tooltip header. Defaults to the raw bucket. */\n formatBucketLabel?: (bucket: string) => string\n labels: {\n solar: string\n battery: string\n grid: string\n /** Optional; when set, grid feed-in is drawn below the baseline. */\n gridFeedIn?: string\n }\n /** Series to drop entirely (no legend entry, bar segment, or tooltip row). */\n omitSeries?: readonly EnergyHistorySeriesKey[]\n /** Bucket to mark with the current-period dashed line. */\n highlightedBucket?: string\n showHighlightLine?: boolean\n title?: string\n className?: string\n height?: number\n /** Subset of bucket ids to label on the x-axis. Defaults to all buckets. */\n categoryTicks?: string[]\n}\n\nexport type EnergyHistorySeriesKey = 'solar' | 'battery' | 'grid' | 'gridFeedIn'\n\n/**\n * Energy-per-bucket stacked bar chart: solar (orange), battery (green) and grid\n * (blue) energy sources stacked per bucket, the total height being the energy\n * consumed. Grid feed-in (translucent blue) dips below the baseline as an\n * export. For cumulative energy (week/month/year views). Thin wrapper over the\n * shared visx `BarChart`, so it inherits the card tooltip and both indicators.\n */\nexport function EnergyHistoryChart({\n data,\n unit,\n formatValue,\n formatBucketLabel,\n labels,\n omitSeries,\n highlightedBucket,\n showHighlightLine,\n title,\n className,\n height = 260,\n categoryTicks,\n}: EnergyHistoryChartProps) {\n const fmtValue = (value: number) =>\n formatValue\n ? formatValue(value)\n : `${valueFormat.format(value)}${NARROW_NBSP}${unit}`\n\n const omitted = new Set<EnergyHistorySeriesKey>(omitSeries)\n const allSeries: BarChartSeries<EnergyHistoryDatum>[] = [\n {\n key: 'solar',\n label: labels.solar,\n color: 'var(--orange-9)',\n getValue: (d) => d.solar,\n },\n {\n key: 'battery',\n label: labels.battery,\n color: 'var(--green-9)',\n getValue: (d) => d.battery,\n },\n {\n key: 'grid',\n label: labels.grid,\n color: 'var(--blue-9)',\n getValue: (d) => d.grid,\n },\n ...(labels.gridFeedIn !== undefined\n ? [\n {\n key: 'gridFeedIn',\n label: labels.gridFeedIn,\n color: 'var(--blue-7)',\n getValue: (d: EnergyHistoryDatum) =>\n -Math.max(0, d.gridFeedIn ?? 0),\n },\n ]\n : []),\n ]\n const series = allSeries.filter(\n (s) => !omitted.has(s.key as EnergyHistorySeriesKey),\n )\n\n return (\n <BarChartWithTotal<EnergyHistoryDatum>\n data={data}\n series={series}\n getCategory={(d) => d.bucket}\n title={title}\n yAxisUnit={unit}\n height={height}\n className={className}\n formatValue={fmtValue}\n categoryTicks={categoryTicks}\n {...(formatBucketLabel && {\n formatTooltipCategory: (category: string | number) =>\n formatBucketLabel(String(category)),\n })}\n totalSuffix={unit}\n totalFormat={{ maximumFractionDigits: 2 }}\n {...(highlightedBucket !== undefined && {\n highlightedCategory: highlightedBucket,\n })}\n {...(showHighlightLine !== undefined && { showHighlightLine })}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,SAAgB,mBAAmB,EACjC,MACA,MACA,aACA,mBACA,QACA,YACA,mBACA,mBACA,OACA,WACA,SAAS,KACT,iBAC0B;CAC1B,MAAM,YAAY,UAChB,cACI,YAAY,KAAK,IACjB,GAAGA,qBAAAA,iBAAY,OAAO,KAAK,KAAkB;CAEnD,MAAM,UAAU,IAAI,IAA4B,UAAU;CAoC1D,OACE,iBAAA,GAAA,kBAAA,KAACC,wCAAAA,mBAAD;EACQ;EACN,QAPW;GA9Bb;IACE,KAAK;IACL,OAAO,OAAO;IACd,OAAO;IACP,WAAW,MAAM,EAAE;GACrB;GACA;IACE,KAAK;IACL,OAAO,OAAO;IACd,OAAO;IACP,WAAW,MAAM,EAAE;GACrB;GACA;IACE,KAAK;IACL,OAAO,OAAO;IACd,OAAO;IACP,WAAW,MAAM,EAAE;GACrB;GACA,GAAI,OAAO,eAAe,KAAA,IACtB,CACE;IACE,KAAK;IACL,OAAO,OAAO;IACd,OAAO;IACP,WAAW,MACT,CAAC,KAAK,IAAI,GAAG,EAAE,cAAc,CAAC;GAClC,CACF,IACA,CAAC;EAEgB,EAAE,QACtB,MAAM,CAAC,QAAQ,IAAI,EAAE,GAA6B,CAMpC;EACb,cAAc,MAAM,EAAE;EACf;EACP,WAAW;EACH;EACG;EACX,aAAa;EACE;EACf,GAAK,qBAAqB,EACxB,wBAAwB,aACtB,kBAAkB,OAAO,QAAQ,CAAC,EACtC;EACA,aAAa;EACb,aAAa,EAAE,uBAAuB,EAAE;EACxC,GAAK,sBAAsB,KAAA,KAAa,EACtC,qBAAqB,kBACvB;EACA,GAAK,sBAAsB,KAAA,KAAa,EAAE,kBAAkB;CAC7D,CAAA;AAEL"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
//#region src/components/energy-history-chart.d.ts
|
|
4
|
+
interface EnergyHistoryDatum {
|
|
5
|
+
/** Bucket label/id (e.g. weekday, day-of-month, month). */
|
|
6
|
+
bucket: string;
|
|
7
|
+
/** Solar used on-site (kWh, ≥ 0). */
|
|
8
|
+
solar: number;
|
|
9
|
+
/** Battery discharged (kWh, ≥ 0). */
|
|
10
|
+
battery: number;
|
|
11
|
+
/** Grid imported (kWh, ≥ 0). */
|
|
12
|
+
grid: number;
|
|
13
|
+
/** Grid feed-in (kWh, ≥ 0); drawn below the baseline as an export. */
|
|
14
|
+
gridFeedIn?: number;
|
|
15
|
+
}
|
|
16
|
+
interface EnergyHistoryChartProps {
|
|
17
|
+
data: EnergyHistoryDatum[];
|
|
18
|
+
/** Axis/tooltip unit, e.g. "kWh". */
|
|
19
|
+
unit: string;
|
|
20
|
+
formatValue?: (value: number) => string;
|
|
21
|
+
/** Formats the hovered bucket in the tooltip header. Defaults to the raw bucket. */
|
|
22
|
+
formatBucketLabel?: (bucket: string) => string;
|
|
23
|
+
labels: {
|
|
24
|
+
solar: string;
|
|
25
|
+
battery: string;
|
|
26
|
+
grid: string; /** Optional; when set, grid feed-in is drawn below the baseline. */
|
|
27
|
+
gridFeedIn?: string;
|
|
28
|
+
};
|
|
29
|
+
/** Series to drop entirely (no legend entry, bar segment, or tooltip row). */
|
|
30
|
+
omitSeries?: readonly EnergyHistorySeriesKey[];
|
|
31
|
+
/** Bucket to mark with the current-period dashed line. */
|
|
32
|
+
highlightedBucket?: string;
|
|
33
|
+
showHighlightLine?: boolean;
|
|
34
|
+
title?: string;
|
|
35
|
+
className?: string;
|
|
36
|
+
height?: number;
|
|
37
|
+
/** Subset of bucket ids to label on the x-axis. Defaults to all buckets. */
|
|
38
|
+
categoryTicks?: string[];
|
|
39
|
+
}
|
|
40
|
+
type EnergyHistorySeriesKey = 'solar' | 'battery' | 'grid' | 'gridFeedIn';
|
|
41
|
+
/**
|
|
42
|
+
* Energy-per-bucket stacked bar chart: solar (orange), battery (green) and grid
|
|
43
|
+
* (blue) energy sources stacked per bucket, the total height being the energy
|
|
44
|
+
* consumed. Grid feed-in (translucent blue) dips below the baseline as an
|
|
45
|
+
* export. For cumulative energy (week/month/year views). Thin wrapper over the
|
|
46
|
+
* shared visx `BarChart`, so it inherits the card tooltip and both indicators.
|
|
47
|
+
*/
|
|
48
|
+
declare function EnergyHistoryChart({
|
|
49
|
+
data,
|
|
50
|
+
unit,
|
|
51
|
+
formatValue,
|
|
52
|
+
formatBucketLabel,
|
|
53
|
+
labels,
|
|
54
|
+
omitSeries,
|
|
55
|
+
highlightedBucket,
|
|
56
|
+
showHighlightLine,
|
|
57
|
+
title,
|
|
58
|
+
className,
|
|
59
|
+
height,
|
|
60
|
+
categoryTicks
|
|
61
|
+
}: EnergyHistoryChartProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { EnergyHistoryChart, EnergyHistoryChartProps, EnergyHistoryDatum, EnergyHistorySeriesKey };
|
|
64
|
+
//# sourceMappingURL=energy-history-chart.d.cts.map
|