@nocoo/basalt 2.0.0-rc.1 → 2.0.2
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/charts/area.d.ts +8 -4
- package/dist/charts/area.js +41 -42
- package/dist/charts/area.js.map +1 -1
- package/dist/charts/bar.d.ts +7 -4
- package/dist/charts/bar.js +34 -27
- package/dist/charts/bar.js.map +1 -1
- package/dist/charts/bullet.d.ts +6 -4
- package/dist/charts/bullet.js +18 -23
- package/dist/charts/bullet.js.map +1 -1
- package/dist/charts/chart-colors.d.ts +3 -0
- package/dist/charts/charts.d.ts +6 -4
- package/dist/charts/charts.js +4 -3
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/config.d.ts +26 -15
- package/dist/charts/config.js +58 -44
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/custom-chart.d.ts +6 -4
- package/dist/charts/custom-chart.js +4 -3
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/date-navigation.d.ts +5 -0
- package/dist/charts/date-navigation.js.map +1 -1
- package/dist/charts/donut.d.ts +6 -4
- package/dist/charts/donut.js +38 -28
- package/dist/charts/donut.js.map +1 -1
- package/dist/charts/frame.d.ts +7 -3
- package/dist/charts/frame.js +30 -7
- package/dist/charts/frame.js.map +1 -1
- package/dist/charts/funnel.d.ts +6 -4
- package/dist/charts/funnel.js +16 -17
- package/dist/charts/funnel.js.map +1 -1
- package/dist/charts/gauge.d.ts +6 -3
- package/dist/charts/gauge.js +18 -17
- package/dist/charts/gauge.js.map +1 -1
- package/dist/charts/grouped-bar.d.ts +8 -4
- package/dist/charts/grouped-bar.js +36 -29
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.d.ts +11 -5
- package/dist/charts/heatmap-calendar.js +25 -20
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/item-list.d.ts +9 -7
- package/dist/charts/item-list.js +1 -5
- package/dist/charts/item-list.js.map +1 -1
- package/dist/charts/legend.d.ts +7 -0
- package/dist/charts/legend.js +56 -0
- package/dist/charts/legend.js.map +1 -0
- package/dist/charts/line.d.ts +7 -4
- package/dist/charts/line.js +33 -41
- package/dist/charts/line.js.map +1 -1
- package/dist/charts/palette.d.ts +3 -2
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/radar.d.ts +6 -4
- package/dist/charts/radar.js +18 -18
- package/dist/charts/radar.js.map +1 -1
- package/dist/charts/sample.d.ts +8 -42
- package/dist/charts/sample.js.map +1 -1
- package/dist/charts/sankey.d.ts +5 -4
- package/dist/charts/sankey.js +15 -16
- package/dist/charts/sankey.js.map +1 -1
- package/dist/charts/series.d.ts +48 -0
- package/dist/charts/series.js +19 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/slot-bar.d.ts +12 -5
- package/dist/charts/slot-bar.js +27 -22
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/sparkline.d.ts +6 -4
- package/dist/charts/sparkline.js +12 -11
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stacked-bar.d.ts +8 -4
- package/dist/charts/stacked-bar.js +40 -37
- package/dist/charts/stacked-bar.js.map +1 -1
- package/dist/charts/stat-card.d.ts +7 -5
- package/dist/charts/stat-card.js +1 -1
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeline.d.ts +15 -8
- package/dist/charts/timeline.js +9 -14
- package/dist/charts/timeline.js.map +1 -1
- package/dist/charts/timeseries.d.ts +6 -4
- package/dist/charts/timeseries.js +4 -3
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.d.ts +16 -0
- package/dist/charts/tooltip.js +105 -0
- package/dist/charts/tooltip.js.map +1 -0
- package/dist/components/alert-dialog.js +1 -0
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/button.js +2 -2
- package/dist/components/button.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +5 -1
- package/dist/components/confirm-dialog.js +52 -25
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/delete-resource.d.ts +5 -0
- package/dist/components/delete-resource.js +38 -0
- package/dist/components/delete-resource.js.map +1 -0
- package/dist/components/description-list.d.ts +21 -0
- package/dist/components/description-list.js +35 -0
- package/dist/components/description-list.js.map +1 -0
- package/dist/components/dialog.js +2 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/layer-card.d.ts +23 -4
- package/dist/components/layer-card.js +83 -50
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/loading-screen.js +9 -5
- package/dist/components/loading-screen.js.map +1 -1
- package/dist/components/page-header.d.ts +4 -4
- package/dist/components/page-header.js +20 -23
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/resource-list.d.ts +10 -0
- package/dist/components/resource-list.js +30 -0
- package/dist/components/resource-list.js.map +1 -0
- package/dist/components/section-rule.d.ts +10 -0
- package/dist/components/section-rule.js +44 -0
- package/dist/components/section-rule.js.map +1 -0
- package/dist/components/sheet.d.ts +4 -4
- package/dist/components/sheet.js +5 -4
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.js +1 -0
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/table.js +6 -5
- package/dist/components/table.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -25
- package/dist/providers/accent.d.ts +23 -0
- package/dist/providers/accent.js +232 -0
- package/dist/providers/accent.js.map +1 -0
- package/dist/styles/standalone.css +274 -111
- package/dist/styles/tailwind.css +1 -0
- package/dist/styles/tokens.css +69 -0
- package/dist/utils/control-surface.d.ts +1 -1
- package/dist/utils/control-surface.js +1 -1
- package/dist/utils/control-surface.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../../src/charts/config.ts"],"sourcesContent":["import { CHART_COLORS, chartAxis, withAlpha } from \"./palette\";\n\nexport type ChartTypeFace = \"axis\" | \"legend\" | \"tooltipTitle\" | \"tooltipBody\";\n\nexport const CHART_TYPE = {\n\taxisFontSize: 11,\n\tlegendFontSize: 12,\n\ttooltipTitleSize: 12,\n\ttooltipBodySize: 12,\n\ttooltipDot: 8,\n\tstrokeWidth: 2,\n\tgridDash: \"3 3\",\n\tgridOpacity: 0.15,\n\tareaFillAlpha: 0.2,\n} as const;\n\nexport function chartFontSize(face: ChartTypeFace): number {\n\tif (face === \"legend\") {\n\t\treturn CHART_TYPE.legendFontSize;\n\t}\n\tif (face === \"tooltipTitle\") {\n\t\treturn CHART_TYPE.tooltipTitleSize;\n\t}\n\tif (face === \"tooltipBody\") {\n\t\treturn CHART_TYPE.tooltipBodySize;\n\t}\n\treturn CHART_TYPE.axisFontSize;\n}\n\nexport function chartTextStyle(face: ChartTypeFace): { fontSize: number } {\n\treturn { fontSize: chartFontSize(face) };\n}\n\nexport function chartTickStyle(face: ChartTypeFace = \"axis\"): {\n\tfontSize: number;\n\tfill: string;\n} {\n\treturn { fontSize: chartFontSize(face), fill: chartAxis };\n}\n\nexport function getChartColor(index: number): string {\n\treturn CHART_COLORS[index % CHART_COLORS.length] ?? CHART_COLORS[0];\n}\n\nexport const AXIS_CONFIG = {\n\tget tick() {\n\t\treturn chartTickStyle(\"axis\");\n\t},\n\taxisLine: false as const,\n\ttickLine: false as const,\n};\n\nexport function cartesianAxisProps(hidden = false) {\n\treturn { hide: hidden, ...AXIS_CONFIG };\n}\n\nexport const GRID_PROPS = {\n\tvertical: false as const,\n\tstroke: chartAxis,\n\tstrokeOpacity: CHART_TYPE.gridOpacity,\n\tstrokeDasharray: CHART_TYPE.gridDash,\n};\n\nexport const BAR_RADIUS = {\n\thorizontal: [0, 4, 4, 0] as [number, number, number, number],\n\tvertical: [4, 4, 0, 0] as [number, number, number, number],\n};\n\nexport const ANIMATION_PROPS = {\n\tisAnimationActive: false,\n};\n\nexport const CHART_TOOLTIP_CURSOR_LINE = {\n\tstroke: chartAxis,\n\tstrokeOpacity: 0.35,\n\tstrokeWidth: 1,\n} as const;\n\nexport const CHART_TOOLTIP_CURSOR_BAR = {\n\tfill: withAlpha(\"foreground\", 0.06),\n\tstroke: \"none\",\n} as const;\n\nexport function chartTooltipContentStyle(): {\n\tbackground: string;\n\tborder: string;\n\tborderRadius: string;\n\tfontSize: number;\n\tcolor: string;\n} {\n\treturn {\n\t\tbackground: \"
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../src/charts/config.ts"],"sourcesContent":["import { createElement } from \"react\";\nimport { CHART_COLORS, chartAxis, withAlpha } from \"./palette\";\nimport type { ChartSeriesDescriptor } from \"./series\";\nimport { ChartTooltipContent, type ChartTooltipItem } from \"./tooltip\";\n\nexport type { ChartSeriesDescriptor } from \"./series\";\n\nexport type ChartTypeFace = \"axis\" | \"legend\" | \"tooltipTitle\" | \"tooltipBody\";\n\nexport const CHART_TYPE = {\n\taxisFontSize: 11,\n\tlegendFontSize: 12,\n\ttooltipTitleSize: 12,\n\ttooltipBodySize: 12,\n\ttooltipDot: 8,\n\tstrokeWidth: 2,\n\tgridDash: \"3 3\",\n\tgridOpacity: 0.15,\n\tareaFillAlpha: 0.2,\n} as const;\n\nexport function chartFontSize(face: ChartTypeFace): number {\n\tif (face === \"legend\") {\n\t\treturn CHART_TYPE.legendFontSize;\n\t}\n\tif (face === \"tooltipTitle\") {\n\t\treturn CHART_TYPE.tooltipTitleSize;\n\t}\n\tif (face === \"tooltipBody\") {\n\t\treturn CHART_TYPE.tooltipBodySize;\n\t}\n\treturn CHART_TYPE.axisFontSize;\n}\n\nexport function chartTextStyle(face: ChartTypeFace): { fontSize: number } {\n\treturn { fontSize: chartFontSize(face) };\n}\n\nexport function chartTickStyle(face: ChartTypeFace = \"axis\"): {\n\tfontSize: number;\n\tfill: string;\n} {\n\treturn { fontSize: chartFontSize(face), fill: chartAxis };\n}\n\nexport function getChartColor(index: number): string {\n\treturn CHART_COLORS[index % CHART_COLORS.length] ?? CHART_COLORS[0];\n}\n\nexport const AXIS_CONFIG = {\n\tget tick() {\n\t\treturn chartTickStyle(\"axis\");\n\t},\n\taxisLine: false as const,\n\ttickLine: false as const,\n};\n\nexport function cartesianAxisProps(hidden = false) {\n\treturn { hide: hidden, ...AXIS_CONFIG };\n}\n\nexport const GRID_PROPS = {\n\tvertical: false as const,\n\tstroke: chartAxis,\n\tstrokeOpacity: CHART_TYPE.gridOpacity,\n\tstrokeDasharray: CHART_TYPE.gridDash,\n};\n\nexport const BAR_RADIUS = {\n\thorizontal: [0, 4, 4, 0] as [number, number, number, number],\n\tvertical: [4, 4, 0, 0] as [number, number, number, number],\n};\n\nexport const ANIMATION_PROPS = {\n\tisAnimationActive: false,\n};\n\nexport const CHART_TOOLTIP_CURSOR_LINE = {\n\tstroke: chartAxis,\n\tstrokeOpacity: 0.35,\n\tstrokeWidth: 1,\n} as const;\n\nexport const CHART_TOOLTIP_CURSOR_BAR = {\n\tfill: withAlpha(\"foreground\", 0.06),\n\tstroke: \"none\",\n} as const;\n\nexport function chartTooltipContentStyle(): {\n\tbackground: string;\n\tborder: string;\n\tborderRadius: string;\n\tboxShadow: string;\n\tfontSize: number;\n\tcolor: string;\n\tpadding: string;\n} {\n\treturn {\n\t\tbackground: \"transparent\",\n\t\tborder: \"none\",\n\t\tborderRadius: \"0\",\n\t\tboxShadow: \"none\",\n\t\tfontSize: chartFontSize(\"tooltipBody\"),\n\t\tcolor: \"hsl(var(--basalt-foreground))\",\n\t\tpadding: \"0\",\n\t};\n}\n\nexport function chartTooltipProps(options?: {\n\tformatter?: (value: number) => string;\n\tcursor?: \"bar\" | \"line\" | false;\n}) {\n\tconst cursor =\n\t\toptions?.cursor === false\n\t\t\t? false\n\t\t\t: options?.cursor === \"line\"\n\t\t\t\t? CHART_TOOLTIP_CURSOR_LINE\n\t\t\t\t: CHART_TOOLTIP_CURSOR_BAR;\n\treturn {\n\t\tisAnimationActive: false,\n\t\tanimationDuration: 0,\n\t\toffset: 12,\n\t\tallowEscapeViewBox: { x: false, y: false },\n\t\tcursor,\n\t\twrapperStyle: {\n\t\t\toutline: \"none\",\n\t\t\tzIndex: 40,\n\t\t\tpointerEvents: \"none\" as const,\n\t\t\ttransition: \"none\",\n\t\t\tanimation: \"none\",\n\t\t},\n\t\tcontentStyle: chartTooltipContentStyle(),\n\t\tcontent: ((props: {\n\t\t\tactive?: boolean;\n\t\t\tpayload?: readonly ChartTooltipItem[];\n\t\t\tlabel?: unknown;\n\t\t}) =>\n\t\t\tcreateElement(ChartTooltipContent, {\n\t\t\t\tactive: props.active,\n\t\t\t\tpayload: props.payload,\n\t\t\t\tlabel: props.label as string | number | undefined,\n\t\t\t\tformatter: options?.formatter,\n\t\t\t})) as never,\n\t};\n}\n\nexport function seriesColor(\n\tseries: ChartSeriesDescriptor | undefined,\n\tindex: number,\n): string | undefined {\n\treturn series?.color ?? CHART_COLORS[index % CHART_COLORS.length];\n}\n\nexport const RESPONSIVE_CONTAINER_PROPS = {\n\twidth: \"100%\" as const,\n\theight: \"100%\" as const,\n\tminWidth: 0,\n\tminHeight: 0,\n\tdebounce: 150,\n};\n\nexport const CHART_PLOT_MARGIN = {\n\ttop: 4,\n\tright: 4,\n\tbottom: 0,\n\tleft: 0,\n} as const;\n\nexport const CHART_PLOT_MARGIN_BARE = {\n\ttop: 2,\n\tright: 2,\n\tbottom: 2,\n\tleft: 2,\n} as const;\n"],"mappings":";;;;;AASA,IAAa,IAAa;CACzB,cAAc;CACd,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,UAAU;CACV,aAAa;CACb,eAAe;AAChB;AAEA,SAAgB,EAAc,GAA6B;CAU1D,OATI,MAAS,WACL,EAAW,iBAEf,MAAS,iBACL,EAAW,mBAEf,MAAS,gBACL,EAAW,kBAEZ,EAAW;AACnB;AAEA,SAAgB,EAAe,GAA2C;CACzE,OAAO,EAAE,UAAU,EAAc,CAAI,EAAE;AACxC;AAEA,SAAgB,EAAe,IAAsB,QAGnD;CACD,OAAO;EAAE,UAAU,EAAc,CAAI;EAAG,MAAM;CAAU;AACzD;AAEA,SAAgB,EAAc,GAAuB;CACpD,OAAO,EAAa,IAAQ,EAAa,WAAW,EAAa;AAClE;AAEA,IAAa,IAAc;CAC1B,IAAI,OAAO;EACV,OAAO,EAAe,MAAM;CAC7B;CACA,UAAU;CACV,UAAU;AACX;AAEA,SAAgB,EAAmB,IAAS,IAAO;CAClD,OAAO;EAAE,MAAM;EAAQ,GAAG;CAAY;AACvC;AAEA,IAAa,IAAa;CACzB,UAAU;CACV,QAAQ;CACR,eAAe,EAAW;CAC1B,iBAAiB,EAAW;AAC7B,GAEa,IAAa;CACzB,YAAY;EAAC;EAAG;EAAG;EAAG;CAAC;CACvB,UAAU;EAAC;EAAG;EAAG;EAAG;CAAC;AACtB,GAEa,IAAkB,EAC9B,mBAAmB,GACpB,GAEa,IAA4B;CACxC,QAAQ;CACR,eAAe;CACf,aAAa;AACd,GAEa,IAA2B;CACvC,MAAM,EAAU,cAAc,GAAI;CAClC,QAAQ;AACT;AAEA,SAAgB,IAQd;CACD,OAAO;EACN,YAAY;EACZ,QAAQ;EACR,cAAc;EACd,WAAW;EACX,UAAU,EAAc,aAAa;EACrC,OAAO;EACP,SAAS;CACV;AACD;AAEA,SAAgB,EAAkB,GAG/B;CAOF,OAAO;EACN,mBAAmB;EACnB,mBAAmB;EACnB,QAAQ;EACR,oBAAoB;GAAE,GAAG;GAAO,GAAG;EAAM;EACzC,QAVA,GAAS,WAAW,KACjB,KACA,GAAS,WAAW,SACnB,IACA;EAOJ,cAAc;GACb,SAAS;GACT,QAAQ;GACR,eAAe;GACf,YAAY;GACZ,WAAW;EACZ;EACA,cAAc,EAAyB;EACvC,WAAW,MAKV,EAAc,GAAqB;GAClC,QAAQ,EAAM;GACd,SAAS,EAAM;GACf,OAAO,EAAM;GACb,WAAW,GAAS;EACrB,CAAC;CACH;AACD;AAEA,SAAgB,EACf,GACA,GACqB;CACrB,OAAO,GAAQ,SAAS,EAAa,IAAQ,EAAa;AAC3D;AAEA,IAAa,IAA6B;CACzC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;AACX,GAEa,IAAoB;CAChC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP,GAEa,IAAyB;CACrC,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;AACP"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { XYPoint } from "./
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import type { XYPoint, XYSeriesDescriptor } from "./series.js";
|
|
2
|
+
export type CustomChartProps = {
|
|
3
|
+
data: XYPoint[];
|
|
4
|
+
series?: XYSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export declare function CustomChart({ data, series, ariaLabel, className, }: CustomChartProps): import("react").JSX.Element;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { LineChart as e } from "./line.js";
|
|
3
3
|
import { jsx as t } from "react/jsx-runtime";
|
|
4
4
|
//#region src/charts/custom-chart.tsx
|
|
5
|
-
function n({ data: n,
|
|
5
|
+
function n({ data: n, series: r, ariaLabel: i = "Custom chart", className: a }) {
|
|
6
6
|
return /* @__PURE__ */ t(e, {
|
|
7
7
|
data: n,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
series: r,
|
|
9
|
+
ariaLabel: i,
|
|
10
|
+
className: a
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-chart.js","names":[],"sources":["../../src/charts/custom-chart.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint } from \"./
|
|
1
|
+
{"version":3,"file":"custom-chart.js","names":[],"sources":["../../src/charts/custom-chart.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint, XYSeriesDescriptor } from \"./series\";\n\nexport type CustomChartProps = {\n\tdata: XYPoint[];\n\tseries?: XYSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport function CustomChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Custom chart\",\n\tclassName,\n}: CustomChartProps) {\n\treturn <LineChart data={data} series={series} ariaLabel={ariaLabel} className={className} />;\n}\n"],"mappings":";;;;AAUA,SAAgB,EAAY,EAC3B,SACA,WACA,eAAY,gBACZ,gBACoB;CACpB,OAAO,kBAAC,GAAD;EAAiB;EAAc;EAAmB;EAAsB;CAAY,CAAA;AAC5F"}
|
|
@@ -18,5 +18,10 @@ type DisplayProps = {
|
|
|
18
18
|
timeZone?: string;
|
|
19
19
|
className?: string;
|
|
20
20
|
};
|
|
21
|
+
export type DateNavigationPickerProps = {
|
|
22
|
+
ariaLabel?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
};
|
|
25
|
+
export type DateNavigationDisplayProps = DisplayProps;
|
|
21
26
|
export declare function DateNavigation(props: PickerProps | DisplayProps): import("react").JSX.Element;
|
|
22
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-navigation.js","names":[],"sources":["../../src/charts/date-navigation.tsx"],"sourcesContent":["import { Calendar as CalendarIcon, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { type ComponentProps, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DatePicker } from \"../components/date-picker\";\nimport { cn } from \"../utils/cn\";\n\nfunction shiftIso(value: string, delta: number) {\n\tconst match = /^(\\d{4,})-(\\d{2})-(\\d{2})$/.exec(value);\n\tconst date = match\n\t\t? new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]))\n\t\t: new Date();\n\tdate.setDate(date.getDate() + delta);\n\tconst year = date.getFullYear();\n\tconst month = String(date.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(date.getDate()).padStart(2, \"0\");\n\treturn `${year}-${month}-${day}`;\n}\n\nfunction civilInZone(date: Date, timeZone?: string) {\n\tconst parts = new Intl.DateTimeFormat(\"en-CA\", {\n\t\ttimeZone,\n\t\tyear: \"numeric\",\n\t\tmonth: \"2-digit\",\n\t\tday: \"2-digit\",\n\t}).formatToParts(date);\n\tconst read = (type: Intl.DateTimeFormatPartTypes) =>\n\t\tNumber(parts.find((part) => part.type === type)?.value);\n\treturn { y: read(\"year\"), m: read(\"month\"), d: read(\"day\") };\n}\n\nfunction isSameCivil(\n\tleft: { y: number; m: number; d: number },\n\tright: { y: number; m: number; d: number },\n) {\n\treturn left.y === right.y && left.m === right.m && left.d === right.d;\n}\n\ntype PickerProps = ComponentProps<typeof DatePicker> & {\n\tariaLabel?: string;\n\tselectedDate?: undefined;\n};\n\ntype DisplayProps = {\n\tselectedDate: Date;\n\tonPrevDay: () => void;\n\tonNextDay: () => void;\n\tonToday: () => void;\n\tonToggleCalendar?: () => void;\n\ttodayLabel?: string;\n\tpreviousDayLabel?: string;\n\tnextDayLabel?: string;\n\tformatDate?: (date: Date) => string;\n\tlocale?: string;\n\ttimeZone?: string;\n\tclassName?: string;\n};\n\nexport function DateNavigation(props: PickerProps | DisplayProps) {\n\tif (\"onPrevDay\" in props) {\n\t\treturn <DateNavigationDisplay {...props} />;\n\t}\n\treturn <DateNavigationPicker {...props} />;\n}\n\nfunction DateNavigationPicker({\n\tvalue,\n\tdefaultValue = \"\",\n\tonChange,\n\tdisabled,\n\tariaLabel,\n\t\"aria-label\": ariaLabelAttr,\n\t...props\n}: PickerProps) {\n\tconst [uncontrolled, setUncontrolled] = useState(value ?? defaultValue);\n\tconst selected = value ?? uncontrolled;\n\tfunction commit(next: string) {\n\t\tif (value === undefined) {\n\t\t\tsetUncontrolled(next);\n\t\t}\n\t\tonChange?.(next);\n\t}\n\treturn (\n\t\t<div className=\"inline-flex items-center gap-1\">\n\t\t\t<Button\n\t\t\t\tvariant=\"outline\"\n\t\t\t\tsize=\"icon\"\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-label=\"Previous day\"\n\t\t\t\tonClick={() => commit(shiftIso(selected, -1))}\n\t\t\t>\n\t\t\t\t<ChevronLeft />\n\t\t\t</Button>\n\t\t\t<DatePicker\n\t\t\t\t{...props}\n\t\t\t\tvalue={selected}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tonChange={commit}\n\t\t\t\taria-label={ariaLabel ?? ariaLabelAttr ?? \"Date navigation\"}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tvariant=\"outline\"\n\t\t\t\tsize=\"icon\"\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-label=\"Next day\"\n\t\t\t\tonClick={() => commit(shiftIso(selected, 1))}\n\t\t\t>\n\t\t\t\t<ChevronRight />\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nfunction DateNavigationDisplay({\n\tselectedDate,\n\tonPrevDay,\n\tonNextDay,\n\tonToday,\n\tonToggleCalendar,\n\ttodayLabel = \"Today\",\n\tpreviousDayLabel = \"Previous day\",\n\tnextDayLabel = \"Next day\",\n\tformatDate,\n\tlocale = \"en-US\",\n\ttimeZone,\n\tclassName,\n}: DisplayProps) {\n\tconst resolvedFormatDate =\n\t\tformatDate ??\n\t\t((date: Date) =>\n\t\t\tdate.toLocaleDateString(locale, {\n\t\t\t\tweekday: \"short\",\n\t\t\t\tyear: \"numeric\",\n\t\t\t\tmonth: \"short\",\n\t\t\t\tday: \"numeric\",\n\t\t\t\ttimeZone,\n\t\t\t}));\n\tconst isToday = isSameCivil(\n\t\tcivilInZone(selectedDate, timeZone),\n\t\tcivilInZone(new Date(), timeZone),\n\t);\n\tconst formatted = resolvedFormatDate(selectedDate);\n\treturn (\n\t\t<div className={cn(\"flex items-center justify-center gap-2\", className)}>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onToday}\n\t\t\t\tdisabled={isToday}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"mr-2 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors\",\n\t\t\t\t\tisToday\n\t\t\t\t\t\t? \"cursor-not-allowed text-basalt-muted-foreground opacity-50\"\n\t\t\t\t\t\t: \"bg-basalt-secondary text-basalt-foreground hover:bg-basalt-accent\",\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{todayLabel}\n\t\t\t</button>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onPrevDay}\n\t\t\t\taria-label={previousDayLabel}\n\t\t\t\tclassName=\"flex h-8 w-8 items-center justify-center rounded-lg text-basalt-muted-foreground transition-colors hover:bg-basalt-accent hover:text-basalt-foreground\"\n\t\t\t>\n\t\t\t\t<ChevronLeft className=\"h-4 w-4\" strokeWidth={1.5} />\n\t\t\t</button>\n\t\t\t{onToggleCalendar ? (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={onToggleCalendar}\n\t\t\t\t\tclassName=\"flex cursor-pointer items-center gap-2 rounded-lg px-3 py-1.5 text-lg font-medium transition-colors hover:bg-basalt-accent\"\n\t\t\t\t>\n\t\t\t\t\t<span>{formatted}</span>\n\t\t\t\t\t<CalendarIcon className=\"h-4 w-4 text-basalt-muted-foreground\" strokeWidth={1.5} />\n\t\t\t\t</button>\n\t\t\t) : (\n\t\t\t\t<span className=\"flex items-center gap-2 rounded-lg px-3 py-1.5 text-lg font-medium\">\n\t\t\t\t\t{formatted}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onNextDay}\n\t\t\t\taria-label={nextDayLabel}\n\t\t\t\tclassName=\"flex h-8 w-8 items-center justify-center rounded-lg text-basalt-muted-foreground transition-colors hover:bg-basalt-accent hover:text-basalt-foreground\"\n\t\t\t>\n\t\t\t\t<ChevronRight className=\"h-4 w-4\" strokeWidth={1.5} />\n\t\t\t</button>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAMA,SAAS,EAAS,GAAe,GAAe;CAC/C,IAAM,IAAQ,6BAA6B,KAAK,CAAK,GAC/C,IAAO,IACV,IAAI,KAAK,OAAO,EAAM,EAAE,GAAG,OAAO,EAAM,EAAE,IAAI,GAAG,OAAO,EAAM,EAAE,CAAC,oBACjE,IAAI,KAAK;CAKZ,OAJA,EAAK,QAAQ,EAAK,QAAQ,IAAI,CAAK,GAI5B,GAHM,EAAK,YAGR,EAAK,GAFD,OAAO,EAAK,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAEpC,EAAM,GADZ,OAAO,EAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GACpB;AAC5B;AAEA,SAAS,EAAY,GAAY,GAAmB;CACnD,IAAM,IAAQ,IAAI,KAAK,eAAe,SAAS;EAC9C;EACA,MAAM;EACN,OAAO;EACP,KAAK;CACN,CAAC,CAAC,CAAC,cAAc,CAAI,GACf,KAAQ,MACb,OAAO,EAAM,MAAM,MAAS,EAAK,SAAS,CAAI,CAAC,EAAE,KAAK;CACvD,OAAO;EAAE,GAAG,EAAK,MAAM;EAAG,GAAG,EAAK,OAAO;EAAG,GAAG,EAAK,KAAK;CAAE;AAC5D;AAEA,SAAS,EACR,GACA,GACC;CACD,OAAO,EAAK,MAAM,EAAM,KAAK,EAAK,MAAM,EAAM,KAAK,EAAK,MAAM,EAAM;AACrE;
|
|
1
|
+
{"version":3,"file":"date-navigation.js","names":[],"sources":["../../src/charts/date-navigation.tsx"],"sourcesContent":["import { Calendar as CalendarIcon, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { type ComponentProps, useState } from \"react\";\nimport { Button } from \"../components/button\";\nimport { DatePicker } from \"../components/date-picker\";\nimport { cn } from \"../utils/cn\";\n\nfunction shiftIso(value: string, delta: number) {\n\tconst match = /^(\\d{4,})-(\\d{2})-(\\d{2})$/.exec(value);\n\tconst date = match\n\t\t? new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]))\n\t\t: new Date();\n\tdate.setDate(date.getDate() + delta);\n\tconst year = date.getFullYear();\n\tconst month = String(date.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(date.getDate()).padStart(2, \"0\");\n\treturn `${year}-${month}-${day}`;\n}\n\nfunction civilInZone(date: Date, timeZone?: string) {\n\tconst parts = new Intl.DateTimeFormat(\"en-CA\", {\n\t\ttimeZone,\n\t\tyear: \"numeric\",\n\t\tmonth: \"2-digit\",\n\t\tday: \"2-digit\",\n\t}).formatToParts(date);\n\tconst read = (type: Intl.DateTimeFormatPartTypes) =>\n\t\tNumber(parts.find((part) => part.type === type)?.value);\n\treturn { y: read(\"year\"), m: read(\"month\"), d: read(\"day\") };\n}\n\nfunction isSameCivil(\n\tleft: { y: number; m: number; d: number },\n\tright: { y: number; m: number; d: number },\n) {\n\treturn left.y === right.y && left.m === right.m && left.d === right.d;\n}\n\ntype PickerProps = ComponentProps<typeof DatePicker> & {\n\tariaLabel?: string;\n\tselectedDate?: undefined;\n};\n\ntype DisplayProps = {\n\tselectedDate: Date;\n\tonPrevDay: () => void;\n\tonNextDay: () => void;\n\tonToday: () => void;\n\tonToggleCalendar?: () => void;\n\ttodayLabel?: string;\n\tpreviousDayLabel?: string;\n\tnextDayLabel?: string;\n\tformatDate?: (date: Date) => string;\n\tlocale?: string;\n\ttimeZone?: string;\n\tclassName?: string;\n};\n\nexport type DateNavigationPickerProps = {\n\tariaLabel?: string;\n\tclassName?: string;\n};\n\nexport type DateNavigationDisplayProps = DisplayProps;\n\nexport function DateNavigation(props: PickerProps | DisplayProps) {\n\tif (\"onPrevDay\" in props) {\n\t\treturn <DateNavigationDisplay {...props} />;\n\t}\n\treturn <DateNavigationPicker {...props} />;\n}\n\nfunction DateNavigationPicker({\n\tvalue,\n\tdefaultValue = \"\",\n\tonChange,\n\tdisabled,\n\tariaLabel,\n\t\"aria-label\": ariaLabelAttr,\n\t...props\n}: PickerProps) {\n\tconst [uncontrolled, setUncontrolled] = useState(value ?? defaultValue);\n\tconst selected = value ?? uncontrolled;\n\tfunction commit(next: string) {\n\t\tif (value === undefined) {\n\t\t\tsetUncontrolled(next);\n\t\t}\n\t\tonChange?.(next);\n\t}\n\treturn (\n\t\t<div className=\"inline-flex items-center gap-1\">\n\t\t\t<Button\n\t\t\t\tvariant=\"outline\"\n\t\t\t\tsize=\"icon\"\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-label=\"Previous day\"\n\t\t\t\tonClick={() => commit(shiftIso(selected, -1))}\n\t\t\t>\n\t\t\t\t<ChevronLeft />\n\t\t\t</Button>\n\t\t\t<DatePicker\n\t\t\t\t{...props}\n\t\t\t\tvalue={selected}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tonChange={commit}\n\t\t\t\taria-label={ariaLabel ?? ariaLabelAttr ?? \"Date navigation\"}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tvariant=\"outline\"\n\t\t\t\tsize=\"icon\"\n\t\t\t\tdisabled={disabled}\n\t\t\t\taria-label=\"Next day\"\n\t\t\t\tonClick={() => commit(shiftIso(selected, 1))}\n\t\t\t>\n\t\t\t\t<ChevronRight />\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nfunction DateNavigationDisplay({\n\tselectedDate,\n\tonPrevDay,\n\tonNextDay,\n\tonToday,\n\tonToggleCalendar,\n\ttodayLabel = \"Today\",\n\tpreviousDayLabel = \"Previous day\",\n\tnextDayLabel = \"Next day\",\n\tformatDate,\n\tlocale = \"en-US\",\n\ttimeZone,\n\tclassName,\n}: DisplayProps) {\n\tconst resolvedFormatDate =\n\t\tformatDate ??\n\t\t((date: Date) =>\n\t\t\tdate.toLocaleDateString(locale, {\n\t\t\t\tweekday: \"short\",\n\t\t\t\tyear: \"numeric\",\n\t\t\t\tmonth: \"short\",\n\t\t\t\tday: \"numeric\",\n\t\t\t\ttimeZone,\n\t\t\t}));\n\tconst isToday = isSameCivil(\n\t\tcivilInZone(selectedDate, timeZone),\n\t\tcivilInZone(new Date(), timeZone),\n\t);\n\tconst formatted = resolvedFormatDate(selectedDate);\n\treturn (\n\t\t<div className={cn(\"flex items-center justify-center gap-2\", className)}>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onToday}\n\t\t\t\tdisabled={isToday}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"mr-2 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors\",\n\t\t\t\t\tisToday\n\t\t\t\t\t\t? \"cursor-not-allowed text-basalt-muted-foreground opacity-50\"\n\t\t\t\t\t\t: \"bg-basalt-secondary text-basalt-foreground hover:bg-basalt-accent\",\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{todayLabel}\n\t\t\t</button>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onPrevDay}\n\t\t\t\taria-label={previousDayLabel}\n\t\t\t\tclassName=\"flex h-8 w-8 items-center justify-center rounded-lg text-basalt-muted-foreground transition-colors hover:bg-basalt-accent hover:text-basalt-foreground\"\n\t\t\t>\n\t\t\t\t<ChevronLeft className=\"h-4 w-4\" strokeWidth={1.5} />\n\t\t\t</button>\n\t\t\t{onToggleCalendar ? (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={onToggleCalendar}\n\t\t\t\t\tclassName=\"flex cursor-pointer items-center gap-2 rounded-lg px-3 py-1.5 text-lg font-medium transition-colors hover:bg-basalt-accent\"\n\t\t\t\t>\n\t\t\t\t\t<span>{formatted}</span>\n\t\t\t\t\t<CalendarIcon className=\"h-4 w-4 text-basalt-muted-foreground\" strokeWidth={1.5} />\n\t\t\t\t</button>\n\t\t\t) : (\n\t\t\t\t<span className=\"flex items-center gap-2 rounded-lg px-3 py-1.5 text-lg font-medium\">\n\t\t\t\t\t{formatted}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={onNextDay}\n\t\t\t\taria-label={nextDayLabel}\n\t\t\t\tclassName=\"flex h-8 w-8 items-center justify-center rounded-lg text-basalt-muted-foreground transition-colors hover:bg-basalt-accent hover:text-basalt-foreground\"\n\t\t\t>\n\t\t\t\t<ChevronRight className=\"h-4 w-4\" strokeWidth={1.5} />\n\t\t\t</button>\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}
|
package/dist/charts/donut.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import type { ChartSeriesDescriptor, NamedValue } from "./series.js";
|
|
2
|
+
export type DonutChartProps = {
|
|
3
|
+
data: NamedValue[];
|
|
4
|
+
series?: ChartSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
7
|
showLegend?: boolean;
|
|
7
8
|
valueFormatter?: (value: number) => string;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
10
|
+
export declare function DonutChart({ data, series, ariaLabel, className, showLegend, valueFormatter, }: DonutChartProps): import("react").JSX.Element;
|
package/dist/charts/donut.js
CHANGED
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Cell as c, Legend as l, Pie as u, PieChart as d, Tooltip as f } from "recharts";
|
|
2
|
+
import { ANIMATION_PROPS as e, chartTooltipProps as t, seriesColor as n } from "./config.js";
|
|
3
|
+
import { ChartShell as r } from "./frame.js";
|
|
4
|
+
import { ChartLegend as i } from "./legend.js";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { Cell as s, Pie as c, PieChart as l, Tooltip as u } from "recharts";
|
|
8
7
|
//#region src/charts/donut.tsx
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function d({ data: d, series: f, ariaLabel: p = "Donut chart", className: m, showLegend: h = !1, valueFormatter: g }) {
|
|
9
|
+
let _ = d.map((e, t) => {
|
|
10
|
+
let r = f?.find((t) => t.key === e.name);
|
|
11
|
+
return {
|
|
12
|
+
key: `${e.name}-${t}`,
|
|
13
|
+
label: r?.label ?? e.name,
|
|
14
|
+
color: n(r, t)
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ a(r, {
|
|
18
|
+
ariaLabel: p,
|
|
19
|
+
className: m,
|
|
13
20
|
size: "h-36 w-36",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
|
|
21
|
+
legend: h ? /* @__PURE__ */ a(i, {
|
|
22
|
+
items: _,
|
|
23
|
+
shape: "bar"
|
|
24
|
+
}) : void 0,
|
|
25
|
+
children: /* @__PURE__ */ o(l, { children: [/* @__PURE__ */ a(c, {
|
|
26
|
+
data: d,
|
|
27
|
+
dataKey: "value",
|
|
28
|
+
nameKey: "name",
|
|
29
|
+
innerRadius: 24,
|
|
30
|
+
outerRadius: 48,
|
|
31
|
+
stroke: "none",
|
|
32
|
+
...e,
|
|
33
|
+
children: d.map((e, t) => {
|
|
34
|
+
let r = f?.find((t) => t.key === e.name);
|
|
35
|
+
return /* @__PURE__ */ a(s, { fill: n(r, t) }, `${e.name}-${t}`);
|
|
36
|
+
})
|
|
37
|
+
}), /* @__PURE__ */ a(u, { ...t({
|
|
38
|
+
formatter: g,
|
|
39
|
+
cursor: !1
|
|
40
|
+
}) })] })
|
|
31
41
|
});
|
|
32
42
|
}
|
|
33
43
|
//#endregion
|
|
34
|
-
export {
|
|
44
|
+
export { d as DonutChart };
|
|
35
45
|
|
|
36
46
|
//# sourceMappingURL=donut.js.map
|
package/dist/charts/donut.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donut.js","names":[],"sources":["../../src/charts/donut.tsx"],"sourcesContent":["import { Cell,
|
|
1
|
+
{"version":3,"file":"donut.js","names":[],"sources":["../../src/charts/donut.tsx"],"sourcesContent":["import { Cell, Pie, PieChart, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartShell } from \"./frame\";\nimport { ChartLegend } from \"./legend\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type DonutChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowLegend?: boolean;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function DonutChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Donut chart\",\n\tclassName,\n\tshowLegend = false,\n\tvalueFormatter,\n}: DonutChartProps) {\n\tconst legendItems = data.map((entry, index) => {\n\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\treturn {\n\t\t\tkey: `${entry.name}-${index}`,\n\t\t\tlabel: item?.label ?? entry.name,\n\t\t\tcolor: seriesColor(item, index),\n\t\t};\n\t});\n\treturn (\n\t\t<ChartShell\n\t\t\tariaLabel={ariaLabel}\n\t\t\tclassName={className}\n\t\t\tsize=\"h-36 w-36\"\n\t\t\tlegend={showLegend ? <ChartLegend items={legendItems} shape=\"bar\" /> : undefined}\n\t\t>\n\t\t\t<PieChart>\n\t\t\t\t<Pie\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tinnerRadius={24}\n\t\t\t\t\touterRadius={48}\n\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t{data.map((entry, index) => {\n\t\t\t\t\t\tconst item = series?.find((candidate) => candidate.key === entry.name);\n\t\t\t\t\t\treturn <Cell key={`${entry.name}-${index}`} fill={seriesColor(item, index)} />;\n\t\t\t\t\t})}\n\t\t\t\t</Pie>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t</PieChart>\n\t\t</ChartShell>\n\t);\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,EAAW,EAC1B,SACA,WACA,eAAY,eACZ,cACA,gBAAa,IACb,qBACmB;CACnB,IAAM,IAAc,EAAK,KAAK,GAAO,MAAU;EAC9C,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;EACrE,OAAO;GACN,KAAK,GAAG,EAAM,KAAK,GAAG;GACtB,OAAO,GAAM,SAAS,EAAM;GAC5B,OAAO,EAAY,GAAM,CAAK;EAC/B;CACD,CAAC;CACD,OACC,kBAAC,GAAD;EACY;EACA;EACX,MAAK;EACL,QAAQ,IAAa,kBAAC,GAAD;GAAa,OAAO;GAAa,OAAM;EAAO,CAAA,IAAI,KAAA;EAEvE,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,aAAa;GACb,aAAa;GACb,QAAO;GACP,GAAI;GAEH,UAAA,EAAK,KAAK,GAAO,MAAU;IAC3B,IAAM,IAAO,GAAQ,MAAM,MAAc,EAAU,QAAQ,EAAM,IAAI;IACrE,OAAO,kBAAC,GAAD,EAAqC,MAAM,EAAY,GAAM,CAAK,EAAI,GAA3D,GAAG,EAAM,KAAK,GAAG,GAA0C;GAC9E,CAAC;EACG,CAAA,GACL,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,CACtE,EAAA,CAAA;CACC,CAAA;AAEd"}
|
package/dist/charts/frame.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { type ReactElement } from "react";
|
|
2
|
-
export
|
|
3
|
-
ariaLabel
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type ChartFrameProps = {
|
|
3
|
+
ariaLabel: string;
|
|
4
4
|
className?: string;
|
|
5
5
|
children: ReactElement<{
|
|
6
6
|
accessibilityLayer?: boolean;
|
|
7
7
|
}>;
|
|
8
8
|
size?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function ChartFrame({ ariaLabel, className, children, size, }: ChartFrameProps): import("react").JSX.Element;
|
|
11
|
+
export declare function ChartShell({ ariaLabel, className, children, size, legend, }: ChartFrameProps & {
|
|
12
|
+
legend?: ReactNode;
|
|
9
13
|
}): import("react").JSX.Element;
|
package/dist/charts/frame.js
CHANGED
|
@@ -2,21 +2,44 @@
|
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
3
|
import { RESPONSIVE_CONTAINER_PROPS as t } from "./config.js";
|
|
4
4
|
import { cloneElement as n } from "react";
|
|
5
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
6
|
-
import { ResponsiveContainer as
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
import { ResponsiveContainer as a } from "recharts";
|
|
7
7
|
//#region src/charts/frame.tsx
|
|
8
|
-
function
|
|
8
|
+
function o({ ariaLabel: i, className: o, children: s, size: c = "h-36 w-56" }) {
|
|
9
9
|
return /* @__PURE__ */ r("div", {
|
|
10
10
|
role: "img",
|
|
11
|
-
"aria-label":
|
|
12
|
-
className: e(c, "basalt-chart outline-none [&_.recharts-layer]:outline-none [&_.recharts-rectangle]:outline-none [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none", o),
|
|
13
|
-
children: /* @__PURE__ */ r(
|
|
11
|
+
"aria-label": i,
|
|
12
|
+
className: e(c, "min-h-0 min-w-0 basalt-chart outline-none [&_.recharts-layer]:outline-none [&_.recharts-rectangle]:outline-none [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none", o),
|
|
13
|
+
children: /* @__PURE__ */ r(a, {
|
|
14
14
|
...t,
|
|
15
15
|
children: n(s, { accessibilityLayer: !1 })
|
|
16
16
|
})
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
+
function s({ ariaLabel: t, className: n, children: a, size: s, legend: c }) {
|
|
20
|
+
return c ? /* @__PURE__ */ i("div", {
|
|
21
|
+
"data-testid": "chart-shell",
|
|
22
|
+
className: e(s ?? "h-36 w-56", n),
|
|
23
|
+
style: {
|
|
24
|
+
display: "flex",
|
|
25
|
+
flexDirection: "column",
|
|
26
|
+
minHeight: 0,
|
|
27
|
+
minWidth: 0
|
|
28
|
+
},
|
|
29
|
+
children: [/* @__PURE__ */ r(o, {
|
|
30
|
+
ariaLabel: t,
|
|
31
|
+
className: "min-h-0 w-full flex-1",
|
|
32
|
+
size: "",
|
|
33
|
+
children: a
|
|
34
|
+
}), c]
|
|
35
|
+
}) : /* @__PURE__ */ r(o, {
|
|
36
|
+
ariaLabel: t,
|
|
37
|
+
className: n,
|
|
38
|
+
size: s,
|
|
39
|
+
children: a
|
|
40
|
+
});
|
|
41
|
+
}
|
|
19
42
|
//#endregion
|
|
20
|
-
export {
|
|
43
|
+
export { o as ChartFrame, s as ChartShell };
|
|
21
44
|
|
|
22
45
|
//# sourceMappingURL=frame.js.map
|
package/dist/charts/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","names":[],"sources":["../../src/charts/frame.tsx"],"sourcesContent":["import { cloneElement, type ReactElement } from \"react\";\nimport { ResponsiveContainer } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { RESPONSIVE_CONTAINER_PROPS } from \"./config\";\n\nexport
|
|
1
|
+
{"version":3,"file":"frame.js","names":[],"sources":["../../src/charts/frame.tsx"],"sourcesContent":["import { cloneElement, type ReactElement, type ReactNode } from \"react\";\nimport { ResponsiveContainer } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { RESPONSIVE_CONTAINER_PROPS } from \"./config\";\n\nexport type ChartFrameProps = {\n\tariaLabel: string;\n\tclassName?: string;\n\tchildren: ReactElement<{ accessibilityLayer?: boolean }>;\n\tsize?: string;\n};\n\nexport function ChartFrame({\n\tariaLabel,\n\tclassName,\n\tchildren,\n\tsize = \"h-36 w-56\",\n}: ChartFrameProps) {\n\treturn (\n\t\t<div\n\t\t\trole=\"img\"\n\t\t\taria-label={ariaLabel}\n\t\t\tclassName={cn(\n\t\t\t\tsize,\n\t\t\t\t\"min-h-0 min-w-0 basalt-chart outline-none [&_.recharts-layer]:outline-none [&_.recharts-rectangle]:outline-none [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<ResponsiveContainer {...RESPONSIVE_CONTAINER_PROPS}>\n\t\t\t\t{cloneElement(children, { accessibilityLayer: false })}\n\t\t\t</ResponsiveContainer>\n\t\t</div>\n\t);\n}\n\nexport function ChartShell({\n\tariaLabel,\n\tclassName,\n\tchildren,\n\tsize,\n\tlegend,\n}: ChartFrameProps & { legend?: ReactNode }) {\n\tif (!legend) {\n\t\treturn (\n\t\t\t<ChartFrame ariaLabel={ariaLabel} className={className} size={size}>\n\t\t\t\t{children}\n\t\t\t</ChartFrame>\n\t\t);\n\t}\n\treturn (\n\t\t<div\n\t\t\tdata-testid=\"chart-shell\"\n\t\t\tclassName={cn(size ?? \"h-36 w-56\", className)}\n\t\t\tstyle={{ display: \"flex\", flexDirection: \"column\", minHeight: 0, minWidth: 0 }}\n\t\t>\n\t\t\t<ChartFrame ariaLabel={ariaLabel} className=\"min-h-0 w-full flex-1\" size=\"\">\n\t\t\t\t{children}\n\t\t\t</ChartFrame>\n\t\t\t{legend}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,EAAW,EAC1B,cACA,cACA,aACA,UAAO,eACY;CACnB,OACC,kBAAC,OAAD;EACC,MAAK;EACL,cAAY;EACZ,WAAW,EACV,GACA,2NACA,CACD;EAEA,UAAA,kBAAC,GAAD;GAAqB,GAAI;GACvB,UAAA,EAAa,GAAU,EAAE,oBAAoB,GAAM,CAAC;EACjC,CAAA;CACjB,CAAA;AAEP;AAEA,SAAgB,EAAW,EAC1B,cACA,cACA,aACA,SACA,aAC4C;CAQ5C,OAPK,IAQJ,kBAAC,OAAD;EACC,eAAY;EACZ,WAAW,EAAG,KAAQ,aAAa,CAAS;EAC5C,OAAO;GAAE,SAAS;GAAQ,eAAe;GAAU,WAAW;GAAG,UAAU;EAAE;EAH9E,UAAA,CAKC,kBAAC,GAAD;GAAuB;GAAW,WAAU;GAAwB,MAAK;GACvE;EACU,CAAA,GACX,CACG;MAfJ,kBAAC,GAAD;EAAuB;EAAsB;EAAiB;EAC5D;CACU,CAAA;AAef"}
|
package/dist/charts/funnel.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import type { ChartSeriesDescriptor, NamedValue } from "./series.js";
|
|
2
|
+
export type FunnelChartProps = {
|
|
3
|
+
data: NamedValue[];
|
|
4
|
+
series?: ChartSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
7
|
valueFormatter?: (value: number) => string;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function FunnelChart({ data, series, ariaLabel, className, valueFormatter, }: FunnelChartProps): import("react").JSX.Element;
|
package/dist/charts/funnel.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { ANIMATION_PROPS as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Funnel as l, FunnelChart as u, LabelList as d, Tooltip as f } from "recharts";
|
|
2
|
+
import { chartAxis as e } from "./palette.js";
|
|
3
|
+
import { ANIMATION_PROPS as t, chartFontSize as n, chartTooltipProps as r, seriesColor as i } from "./config.js";
|
|
4
|
+
import { ChartFrame as a } from "./frame.js";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
import { Funnel as c, FunnelChart as l, LabelList as u, Tooltip as d } from "recharts";
|
|
8
7
|
//#region src/charts/funnel.tsx
|
|
9
|
-
function
|
|
10
|
-
return /* @__PURE__ */
|
|
8
|
+
function f({ data: f, series: p, ariaLabel: m = "Funnel chart", className: h, valueFormatter: g }) {
|
|
9
|
+
return /* @__PURE__ */ o(a, {
|
|
11
10
|
ariaLabel: m,
|
|
12
11
|
className: h,
|
|
13
|
-
children: /* @__PURE__ */
|
|
12
|
+
children: /* @__PURE__ */ s(l, { children: [/* @__PURE__ */ o(d, { ...r({
|
|
14
13
|
formatter: g,
|
|
15
14
|
cursor: !1
|
|
16
|
-
}) }), /* @__PURE__ */
|
|
17
|
-
data:
|
|
15
|
+
}) }), /* @__PURE__ */ o(c, {
|
|
16
|
+
data: f,
|
|
18
17
|
dataKey: "value",
|
|
19
18
|
nameKey: "name",
|
|
20
|
-
fill:
|
|
21
|
-
...
|
|
22
|
-
children: /* @__PURE__ */
|
|
19
|
+
fill: i(p?.[0], 1),
|
|
20
|
+
...t,
|
|
21
|
+
children: /* @__PURE__ */ o(u, {
|
|
23
22
|
dataKey: "name",
|
|
24
23
|
position: "right",
|
|
25
|
-
fill:
|
|
24
|
+
fill: e,
|
|
26
25
|
stroke: "none",
|
|
27
|
-
fontSize:
|
|
26
|
+
fontSize: n("axis")
|
|
28
27
|
})
|
|
29
28
|
})] })
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
//#endregion
|
|
33
|
-
export {
|
|
32
|
+
export { f as FunnelChart };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=funnel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funnel.js","names":[],"sources":["../../src/charts/funnel.tsx"],"sourcesContent":["import { Funnel, LabelList, FunnelChart as RechartsFunnel, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartFontSize, chartTooltipProps } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport {
|
|
1
|
+
{"version":3,"file":"funnel.js","names":[],"sources":["../../src/charts/funnel.tsx"],"sourcesContent":["import { Funnel, LabelList, FunnelChart as RechartsFunnel, Tooltip } from \"recharts\";\nimport { ANIMATION_PROPS, chartFontSize, chartTooltipProps, seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { chartAxis } from \"./palette\";\nimport type { ChartSeriesDescriptor, NamedValue } from \"./series\";\n\nexport type FunnelChartProps = {\n\tdata: NamedValue[];\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function FunnelChart({\n\tdata,\n\tseries,\n\tariaLabel = \"Funnel chart\",\n\tclassName,\n\tvalueFormatter,\n}: FunnelChartProps) {\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsFunnel>\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: false })} />\n\t\t\t\t<Funnel\n\t\t\t\t\tdata={data}\n\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\tnameKey=\"name\"\n\t\t\t\t\tfill={seriesColor(series?.[0], 1)}\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t>\n\t\t\t\t\t<LabelList\n\t\t\t\t\t\tdataKey=\"name\"\n\t\t\t\t\t\tposition=\"right\"\n\t\t\t\t\t\tfill={chartAxis}\n\t\t\t\t\t\tstroke=\"none\"\n\t\t\t\t\t\tfontSize={chartFontSize(\"axis\")}\n\t\t\t\t\t/>\n\t\t\t\t</Funnel>\n\t\t\t</RechartsFunnel>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;AAcA,SAAgB,EAAY,EAC3B,SACA,WACA,eAAY,gBACZ,cACA,qBACoB;CACpB,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD,EAAS,GAAI,EAAkB;GAAE,WAAW;GAAgB,QAAQ;EAAM,CAAC,EAAI,CAAA,GAC/E,kBAAC,GAAD;GACO;GACN,SAAQ;GACR,SAAQ;GACR,MAAM,EAAY,IAAS,IAAI,CAAC;GAChC,GAAI;GAEJ,UAAA,kBAAC,GAAD;IACC,SAAQ;IACR,UAAS;IACT,MAAM;IACN,QAAO;IACP,UAAU,EAAc,MAAM;GAC9B,CAAA;EACM,CAAA,CACO,EAAA,CAAA;CACL,CAAA;AAEd"}
|
package/dist/charts/gauge.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { ChartSeriesDescriptor } from "./series.js";
|
|
2
|
+
export type GaugeProps = {
|
|
3
|
+
value: number;
|
|
3
4
|
max?: number;
|
|
5
|
+
series?: ChartSeriesDescriptor[];
|
|
4
6
|
ariaLabel?: string;
|
|
5
7
|
className?: string;
|
|
6
8
|
hideValue?: boolean;
|
|
7
9
|
valueFormatter?: (value: number) => string;
|
|
8
|
-
}
|
|
10
|
+
};
|
|
11
|
+
export declare function Gauge({ value, max, series, ariaLabel, className, hideValue, valueFormatter, }: GaugeProps): import("react").JSX.Element;
|
package/dist/charts/gauge.js
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
3
|
import { CHART_COLORS as t } from "./palette.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { seriesColor as n } from "./config.js";
|
|
5
|
+
import { ChartFrame as r } from "./frame.js";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
import { PolarAngleAxis as o, RadialBar as s, RadialBarChart as c } from "recharts";
|
|
7
8
|
//#region src/charts/gauge.tsx
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
className: e("relative h-36 w-36",
|
|
12
|
-
children: [/* @__PURE__ */ r
|
|
13
|
-
ariaLabel:
|
|
9
|
+
function l({ value: l, max: u = 100, series: d, ariaLabel: f = "Gauge", className: p, hideValue: m = !1, valueFormatter: h }) {
|
|
10
|
+
let g = u === 0 ? 0 : Math.min(100, Math.max(0, l / u * 100)), _ = h ? h(l) : String(l);
|
|
11
|
+
return /* @__PURE__ */ a("div", {
|
|
12
|
+
className: e("relative h-36 w-36", p),
|
|
13
|
+
children: [/* @__PURE__ */ i(r, {
|
|
14
|
+
ariaLabel: f,
|
|
14
15
|
className: "h-full w-full",
|
|
15
16
|
size: "h-full w-full",
|
|
16
|
-
children: /* @__PURE__ */
|
|
17
|
+
children: /* @__PURE__ */ a(c, {
|
|
17
18
|
cx: "50%",
|
|
18
19
|
cy: "50%",
|
|
19
20
|
innerRadius: "75%",
|
|
20
21
|
outerRadius: "95%",
|
|
21
22
|
startAngle: 90,
|
|
22
23
|
endAngle: -270,
|
|
23
|
-
data: [{ value:
|
|
24
|
+
data: [{ value: g }],
|
|
24
25
|
barSize: 12,
|
|
25
|
-
children: [/* @__PURE__ */
|
|
26
|
+
children: [/* @__PURE__ */ i(o, {
|
|
26
27
|
type: "number",
|
|
27
28
|
domain: [0, 100],
|
|
28
29
|
angleAxisId: 0,
|
|
29
30
|
tick: !1
|
|
30
|
-
}), /* @__PURE__ */
|
|
31
|
+
}), /* @__PURE__ */ i(s, {
|
|
31
32
|
dataKey: "value",
|
|
32
33
|
cornerRadius: 6,
|
|
33
|
-
fill:
|
|
34
|
+
fill: n(d?.[0], 4),
|
|
34
35
|
background: { fill: t[23] }
|
|
35
36
|
})]
|
|
36
37
|
})
|
|
37
|
-
}),
|
|
38
|
+
}), m ? null : /* @__PURE__ */ i("span", {
|
|
38
39
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center text-sm font-semibold text-basalt-foreground",
|
|
39
|
-
children:
|
|
40
|
+
children: _
|
|
40
41
|
})]
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
//#endregion
|
|
44
|
-
export {
|
|
45
|
+
export { l as Gauge };
|
|
45
46
|
|
|
46
47
|
//# sourceMappingURL=gauge.js.map
|
package/dist/charts/gauge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gauge.js","names":[],"sources":["../../src/charts/gauge.tsx"],"sourcesContent":["import { PolarAngleAxis, RadialBar, RadialBarChart } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS } from \"./palette\";\
|
|
1
|
+
{"version":3,"file":"gauge.js","names":[],"sources":["../../src/charts/gauge.tsx"],"sourcesContent":["import { PolarAngleAxis, RadialBar, RadialBarChart } from \"recharts\";\nimport { cn } from \"../utils/cn\";\nimport { seriesColor } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS } from \"./palette\";\nimport type { ChartSeriesDescriptor } from \"./series\";\n\nexport type GaugeProps = {\n\tvalue: number;\n\tmax?: number;\n\tseries?: ChartSeriesDescriptor[];\n\tariaLabel?: string;\n\tclassName?: string;\n\thideValue?: boolean;\n\tvalueFormatter?: (value: number) => string;\n};\n\nexport function Gauge({\n\tvalue,\n\tmax = 100,\n\tseries,\n\tariaLabel = \"Gauge\",\n\tclassName,\n\thideValue = false,\n\tvalueFormatter,\n}: GaugeProps) {\n\tconst percent = max === 0 ? 0 : Math.min(100, Math.max(0, (value / max) * 100));\n\tconst display = valueFormatter ? valueFormatter(value) : String(value);\n\treturn (\n\t\t<div className={cn(\"relative h-36 w-36\", className)}>\n\t\t\t<ChartFrame ariaLabel={ariaLabel} className=\"h-full w-full\" size=\"h-full w-full\">\n\t\t\t\t<RadialBarChart\n\t\t\t\t\tcx=\"50%\"\n\t\t\t\t\tcy=\"50%\"\n\t\t\t\t\tinnerRadius=\"75%\"\n\t\t\t\t\touterRadius=\"95%\"\n\t\t\t\t\tstartAngle={90}\n\t\t\t\t\tendAngle={-270}\n\t\t\t\t\tdata={[{ value: percent }]}\n\t\t\t\t\tbarSize={12}\n\t\t\t\t>\n\t\t\t\t\t<PolarAngleAxis type=\"number\" domain={[0, 100]} angleAxisId={0} tick={false} />\n\t\t\t\t\t<RadialBar\n\t\t\t\t\t\tdataKey=\"value\"\n\t\t\t\t\t\tcornerRadius={6}\n\t\t\t\t\t\tfill={seriesColor(series?.[0], 4)}\n\t\t\t\t\t\tbackground={{ fill: CHART_COLORS[23] }}\n\t\t\t\t\t/>\n\t\t\t\t</RadialBarChart>\n\t\t\t</ChartFrame>\n\t\t\t{hideValue ? null : (\n\t\t\t\t<span className=\"pointer-events-none absolute inset-0 flex items-center justify-center text-sm font-semibold text-basalt-foreground\">\n\t\t\t\t\t{display}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAiBA,SAAgB,EAAM,EACrB,UACA,SAAM,KACN,WACA,eAAY,SACZ,cACA,eAAY,IACZ,qBACc;CACd,IAAM,IAAU,MAAQ,IAAI,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAI,IAAQ,IAAO,GAAG,CAAC,GACxE,IAAU,IAAiB,EAAe,CAAK,IAAI,OAAO,CAAK;CACrE,OACC,kBAAC,OAAD;EAAK,WAAW,EAAG,sBAAsB,CAAS;EAAlD,UAAA,CACC,kBAAC,GAAD;GAAuB;GAAW,WAAU;GAAgB,MAAK;GAChE,UAAA,kBAAC,GAAD;IACC,IAAG;IACH,IAAG;IACH,aAAY;IACZ,aAAY;IACZ,YAAY;IACZ,UAAU;IACV,MAAM,CAAC,EAAE,OAAO,EAAQ,CAAC;IACzB,SAAS;IARV,UAAA,CAUC,kBAAC,GAAD;KAAgB,MAAK;KAAS,QAAQ,CAAC,GAAG,GAAG;KAAG,aAAa;KAAG,MAAM;IAAQ,CAAA,GAC9E,kBAAC,GAAD;KACC,SAAQ;KACR,cAAc;KACd,MAAM,EAAY,IAAS,IAAI,CAAC;KAChC,YAAY,EAAE,MAAM,EAAa,IAAI;IACrC,CAAA,CACc;;EACL,CAAA,GACX,IAAY,OACZ,kBAAC,QAAD;GAAM,WAAU;GACd,UAAA;EACI,CAAA,CAEH;;AAEP"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { type XYPoint } from "./
|
|
2
|
-
export
|
|
3
|
-
data
|
|
1
|
+
import { type XYPoint, type XYSeriesDescriptor } from "./series.js";
|
|
2
|
+
export type GroupedBarChartProps = {
|
|
3
|
+
data: XYPoint[];
|
|
4
|
+
series?: XYSeriesDescriptor[];
|
|
4
5
|
ariaLabel?: string;
|
|
5
6
|
className?: string;
|
|
6
7
|
showAxes?: boolean;
|
|
7
|
-
|
|
8
|
+
showLegend?: boolean;
|
|
9
|
+
valueFormatter?: (value: number) => string;
|
|
10
|
+
};
|
|
11
|
+
export declare function GroupedBarChart({ data, series, ariaLabel, className, showAxes, showLegend, valueFormatter, }: GroupedBarChartProps): import("react").JSX.Element;
|
|
@@ -1,42 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { Bar as
|
|
2
|
+
import { ANIMATION_PROPS as e, BAR_RADIUS as t, CHART_PLOT_MARGIN as n, CHART_PLOT_MARGIN_BARE as r, GRID_PROPS as i, cartesianAxisProps as a, chartTooltipProps as o, seriesColor as s } from "./config.js";
|
|
3
|
+
import { resolveChartSeries as c } from "./series.js";
|
|
4
|
+
import { ChartShell as l } from "./frame.js";
|
|
5
|
+
import { ChartLegend as u } from "./legend.js";
|
|
6
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
|
+
import { Bar as p, BarChart as m, CartesianGrid as h, Tooltip as g, XAxis as _, YAxis as v } from "recharts";
|
|
8
8
|
//#region src/charts/grouped-bar.tsx
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function y({ data: y, series: b, ariaLabel: x = "Grouped bar chart", className: S, showAxes: C = !1, showLegend: w = !1, valueFormatter: T }) {
|
|
10
|
+
let E = c(b, ["y", "y2"]);
|
|
11
|
+
return /* @__PURE__ */ d(l, {
|
|
12
|
+
ariaLabel: x,
|
|
13
|
+
className: S,
|
|
14
|
+
legend: w ? /* @__PURE__ */ d(u, {
|
|
15
|
+
items: E,
|
|
16
|
+
shape: "bar"
|
|
17
|
+
}) : void 0,
|
|
18
|
+
children: /* @__PURE__ */ f(m, {
|
|
19
|
+
data: y,
|
|
20
|
+
margin: C ? n : r,
|
|
15
21
|
children: [
|
|
16
|
-
|
|
17
|
-
/* @__PURE__ */
|
|
22
|
+
C ? /* @__PURE__ */ d(h, { ...i }) : null,
|
|
23
|
+
/* @__PURE__ */ d(_, {
|
|
18
24
|
dataKey: "x",
|
|
19
|
-
...
|
|
25
|
+
...a(!C)
|
|
20
26
|
}),
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
dataKey: "y",
|
|
25
|
-
fill: e[0],
|
|
26
|
-
radius: n.vertical,
|
|
27
|
-
...t
|
|
27
|
+
/* @__PURE__ */ d(v, {
|
|
28
|
+
...a(!C),
|
|
29
|
+
tickFormatter: T
|
|
28
30
|
}),
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/* @__PURE__ */ d(g, { ...o({
|
|
32
|
+
formatter: T,
|
|
33
|
+
cursor: "bar"
|
|
34
|
+
}) }),
|
|
35
|
+
E.map((n, r) => /* @__PURE__ */ d(p, {
|
|
36
|
+
dataKey: n.key,
|
|
37
|
+
name: n.label ?? n.key,
|
|
38
|
+
fill: s(n, r),
|
|
39
|
+
radius: t.vertical,
|
|
40
|
+
...e
|
|
41
|
+
}, n.key))
|
|
35
42
|
]
|
|
36
43
|
})
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
//#endregion
|
|
40
|
-
export {
|
|
47
|
+
export { y as GroupedBarChart };
|
|
41
48
|
|
|
42
49
|
//# sourceMappingURL=grouped-bar.js.map
|