@nocoo/basalt 2.0.0-rc.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/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/charts/area.d.ts +8 -0
- package/dist/charts/area.js +55 -0
- package/dist/charts/area.js.map +1 -0
- package/dist/charts/bar.d.ts +9 -0
- package/dist/charts/bar.js +42 -0
- package/dist/charts/bar.js.map +1 -0
- package/dist/charts/bullet.d.ts +8 -0
- package/dist/charts/bullet.js +50 -0
- package/dist/charts/bullet.js.map +1 -0
- package/dist/charts/chart-colors.d.ts +1 -0
- package/dist/charts/chart-colors.js +3 -0
- package/dist/charts/charts.d.ts +6 -0
- package/dist/charts/charts.js +15 -0
- package/dist/charts/charts.js.map +1 -0
- package/dist/charts/config.d.ts +117 -0
- package/dist/charts/config.js +117 -0
- package/dist/charts/config.js.map +1 -0
- package/dist/charts/custom-chart.d.ts +6 -0
- package/dist/charts/custom-chart.js +15 -0
- package/dist/charts/custom-chart.js.map +1 -0
- package/dist/charts/date-navigation.d.ts +22 -0
- package/dist/charts/date-navigation.js +122 -0
- package/dist/charts/date-navigation.js.map +1 -0
- package/dist/charts/donut.d.ts +8 -0
- package/dist/charts/donut.js +36 -0
- package/dist/charts/donut.js.map +1 -0
- package/dist/charts/frame.d.ts +9 -0
- package/dist/charts/frame.js +22 -0
- package/dist/charts/frame.js.map +1 -0
- package/dist/charts/funnel.d.ts +7 -0
- package/dist/charts/funnel.js +35 -0
- package/dist/charts/funnel.js.map +1 -0
- package/dist/charts/gauge.d.ts +8 -0
- package/dist/charts/gauge.js +46 -0
- package/dist/charts/gauge.js.map +1 -0
- package/dist/charts/grouped-bar.d.ts +7 -0
- package/dist/charts/grouped-bar.js +42 -0
- package/dist/charts/grouped-bar.js.map +1 -0
- package/dist/charts/heatmap-calendar.d.ts +27 -0
- package/dist/charts/heatmap-calendar.js +200 -0
- package/dist/charts/heatmap-calendar.js.map +1 -0
- package/dist/charts/item-list.d.ts +9 -0
- package/dist/charts/item-list.js +22 -0
- package/dist/charts/item-list.js.map +1 -0
- package/dist/charts/line.d.ts +9 -0
- package/dist/charts/line.js +58 -0
- package/dist/charts/line.js.map +1 -0
- package/dist/charts/palette.d.ts +33 -0
- package/dist/charts/palette.js +44 -0
- package/dist/charts/palette.js.map +1 -0
- package/dist/charts/radar.d.ts +6 -0
- package/dist/charts/radar.js +37 -0
- package/dist/charts/radar.js.map +1 -0
- package/dist/charts/sample.d.ts +42 -0
- package/dist/charts/sample.js +124 -0
- package/dist/charts/sample.js.map +1 -0
- package/dist/charts/sankey.d.ts +6 -0
- package/dist/charts/sankey.js +51 -0
- package/dist/charts/sankey.js.map +1 -0
- package/dist/charts/slot-bar.d.ts +15 -0
- package/dist/charts/slot-bar.js +80 -0
- package/dist/charts/slot-bar.js.map +1 -0
- package/dist/charts/sparkline.d.ts +6 -0
- package/dist/charts/sparkline.js +29 -0
- package/dist/charts/sparkline.js.map +1 -0
- package/dist/charts/stacked-bar.d.ts +7 -0
- package/dist/charts/stacked-bar.js +51 -0
- package/dist/charts/stacked-bar.js.map +1 -0
- package/dist/charts/stat-card.d.ts +21 -0
- package/dist/charts/stat-card.js +66 -0
- package/dist/charts/stat-card.js.map +1 -0
- package/dist/charts/timeline.d.ts +17 -0
- package/dist/charts/timeline.js +79 -0
- package/dist/charts/timeline.js.map +1 -0
- package/dist/charts/timeseries.d.ts +6 -0
- package/dist/charts/timeseries.js +15 -0
- package/dist/charts/timeseries.js.map +1 -0
- package/dist/components/accordion.d.ts +6 -0
- package/dist/components/accordion.js +21 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +25 -0
- package/dist/components/alert-dialog.js +61 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/app-header.d.ts +10 -0
- package/dist/components/app-header.js +35 -0
- package/dist/components/app-header.js.map +1 -0
- package/dist/components/app-shell.d.ts +4 -0
- package/dist/components/app-shell.js +29 -0
- package/dist/components/app-shell.js.map +1 -0
- package/dist/components/autocomplete.d.ts +47 -0
- package/dist/components/autocomplete.js +28 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/avatar.d.ts +5 -0
- package/dist/components/avatar.js +28 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.js +37 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/banner.d.ts +22 -0
- package/dist/components/banner.js +88 -0
- package/dist/components/banner.js.map +1 -0
- package/dist/components/basalt-mark.d.ts +8 -0
- package/dist/components/basalt-mark.js +17 -0
- package/dist/components/basalt-mark.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +9 -0
- package/dist/components/breadcrumbs.js +38 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +73 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox.d.ts +86 -0
- package/dist/components/checkbox.js +107 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/clipboard-text.d.ts +5 -0
- package/dist/components/clipboard-text.js +33 -0
- package/dist/components/clipboard-text.js.map +1 -0
- package/dist/components/code.d.ts +26 -0
- package/dist/components/code.js +45 -0
- package/dist/components/code.js.map +1 -0
- package/dist/components/collapsible.d.ts +33 -0
- package/dist/components/collapsible.js +38 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/combobox.d.ts +47 -0
- package/dist/components/combobox.js +28 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command-palette.d.ts +83 -0
- package/dist/components/command-palette.js +90 -0
- package/dist/components/command-palette.js.map +1 -0
- package/dist/components/confirm-dialog.d.ts +52 -0
- package/dist/components/confirm-dialog.js +61 -0
- package/dist/components/confirm-dialog.js.map +1 -0
- package/dist/components/context-menu.d.ts +7 -0
- package/dist/components/context-menu.js +23 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/data-table.d.ts +76 -0
- package/dist/components/data-table.js +230 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/date-picker.d.ts +90 -0
- package/dist/components/date-picker.js +452 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +37 -0
- package/dist/components/dialog.js +67 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +38 -0
- package/dist/components/dropdown-menu.js +24 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/empty.d.ts +6 -0
- package/dist/components/empty.js +28 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.d.ts +39 -0
- package/dist/components/field.js +52 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/flow.d.ts +24 -0
- package/dist/components/flow.js +56 -0
- package/dist/components/flow.js.map +1 -0
- package/dist/components/grid.d.ts +15 -0
- package/dist/components/grid.js +24 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/hover-card.d.ts +5 -0
- package/dist/components/hover-card.js +18 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-area.d.ts +19 -0
- package/dist/components/input-area.js +27 -0
- package/dist/components/input-area.js.map +1 -0
- package/dist/components/input-group.d.ts +70 -0
- package/dist/components/input-group.js +78 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +19 -0
- package/dist/components/input.js +28 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +20 -0
- package/dist/components/label.js +34 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/layer-card.d.ts +69 -0
- package/dist/components/layer-card.js +104 -0
- package/dist/components/layer-card.js.map +1 -0
- package/dist/components/link.d.ts +8 -0
- package/dist/components/link.js +18 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/loader.d.ts +4 -0
- package/dist/components/loader.js +66 -0
- package/dist/components/loader.js.map +1 -0
- package/dist/components/loading-screen.d.ts +5 -0
- package/dist/components/loading-screen.js +24 -0
- package/dist/components/loading-screen.js.map +1 -0
- package/dist/components/menu-bar.d.ts +8 -0
- package/dist/components/menu-bar.js +42 -0
- package/dist/components/menu-bar.js.map +1 -0
- package/dist/components/meter.d.ts +8 -0
- package/dist/components/meter.js +26 -0
- package/dist/components/meter.js.map +1 -0
- package/dist/components/navigation-menu.d.ts +6 -0
- package/dist/components/navigation-menu.js +16 -0
- package/dist/components/navigation-menu.js.map +1 -0
- package/dist/components/overlay.d.ts +16 -0
- package/dist/components/overlay.js +14 -0
- package/dist/components/overlay.js.map +1 -0
- package/dist/components/page-header.d.ts +19 -0
- package/dist/components/page-header.js +43 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/pagination.d.ts +35 -0
- package/dist/components/pagination.js +68 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +65 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/radio.d.ts +108 -0
- package/dist/components/radio.js +80 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/scroll-area.d.ts +15 -0
- package/dist/components/scroll-area.js +49 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/segment-control.d.ts +35 -0
- package/dist/components/segment-control.js +46 -0
- package/dist/components/segment-control.js.map +1 -0
- package/dist/components/select.d.ts +99 -0
- package/dist/components/select.js +51 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/sensitive-input.d.ts +23 -0
- package/dist/components/sensitive-input.js +43 -0
- package/dist/components/sensitive-input.js.map +1 -0
- package/dist/components/separator.d.ts +26 -0
- package/dist/components/separator.js +18 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +26 -0
- package/dist/components/sheet.js +49 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +101 -0
- package/dist/components/sidebar.js +260 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton-line.d.ts +6 -0
- package/dist/components/skeleton-line.js +22 -0
- package/dist/components/skeleton-line.js.map +1 -0
- package/dist/components/slider.d.ts +3 -0
- package/dist/components/slider.js +21 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/stat-strip.d.ts +19 -0
- package/dist/components/stat-strip.js +27 -0
- package/dist/components/stat-strip.js.map +1 -0
- package/dist/components/switch.d.ts +85 -0
- package/dist/components/switch.js +94 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table-of-contents.d.ts +33 -0
- package/dist/components/table-of-contents.js +37 -0
- package/dist/components/table-of-contents.js.map +1 -0
- package/dist/components/table-pager.d.ts +26 -0
- package/dist/components/table-pager.js +35 -0
- package/dist/components/table-pager.js.map +1 -0
- package/dist/components/table.d.ts +45 -0
- package/dist/components/table.js +32 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +65 -0
- package/dist/components/tabs.js +56 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/text.d.ts +32 -0
- package/dist/components/text.js +46 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/theme-toggle.d.ts +7 -0
- package/dist/components/theme-toggle.js +28 -0
- package/dist/components/theme-toggle.js.map +1 -0
- package/dist/components/toast.d.ts +27 -0
- package/dist/components/toast.js +78 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +4 -0
- package/dist/components/toggle-group.js +48 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.d.ts +7 -0
- package/dist/components/toggle.js +37 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/toolbar.d.ts +58 -0
- package/dist/components/toolbar.js +76 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/components/tooltip.d.ts +13 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/typeahead-field.d.ts +24 -0
- package/dist/components/typeahead-field.js +177 -0
- package/dist/components/typeahead-field.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +35 -0
- package/dist/providers/link.d.ts +12 -0
- package/dist/providers/link.js +18 -0
- package/dist/providers/link.js.map +1 -0
- package/dist/providers/theme.d.ts +11 -0
- package/dist/providers/theme.js +43 -0
- package/dist/providers/theme.js.map +1 -0
- package/dist/styles/standalone.css +2233 -0
- package/dist/styles/tailwind.css +103 -0
- package/dist/styles/tokens.css +277 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +11 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/control-surface.d.ts +2 -0
- package/dist/utils/control-surface.js +11 -0
- package/dist/utils/control-surface.js.map +1 -0
- package/dist/utils/selection-indicator.d.ts +24 -0
- package/dist/utils/selection-indicator.js +108 -0
- package/dist/utils/selection-indicator.js.map +1 -0
- package/package.json +107 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zheng Li
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @nocoo/basalt
|
|
2
|
+
|
|
3
|
+
Basalt component library. ESM, granular exports, Tailwind v4 or standalone CSS.
|
|
4
|
+
|
|
5
|
+
## Tailwind
|
|
6
|
+
|
|
7
|
+
Import order is required:
|
|
8
|
+
|
|
9
|
+
```css
|
|
10
|
+
@source "../node_modules/@nocoo/basalt/dist/**/*.{js,jsx,ts,tsx}";
|
|
11
|
+
@import "@nocoo/basalt/styles/tailwind";
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`./styles` points at the Tailwind contract. Basalt `@theme` tokens must register before `tailwindcss`.
|
|
16
|
+
|
|
17
|
+
## Standalone (no Tailwind)
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import "@nocoo/basalt/styles/standalone";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Standalone has no Preflight and no html/body reset. It is compiled tokens + the utilities used by shipped controls + namespaced keyframes. Rebuild with `bun scripts/build-basalt-standalone.ts`.
|
|
24
|
+
|
|
25
|
+
## Components
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { Button, ThemeProvider } from "@nocoo/basalt";
|
|
29
|
+
import { DatePicker } from "@nocoo/basalt/components/date-picker";
|
|
30
|
+
import { DonutChart } from "@nocoo/basalt/charts/donut";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Root barrel is small leaves + providers. Charts, DatePicker, and DataTable stay on granular paths.
|
|
34
|
+
|
|
35
|
+
Optional peer ranges for those granular entrypoints:
|
|
36
|
+
|
|
37
|
+
- `recharts` `^3` — used by chart modules such as `DonutChart`
|
|
38
|
+
- `react-day-picker` `^10` — declared for DatePicker consumers; the current DatePicker implementation does not call it
|
|
39
|
+
- `@tanstack/react-table` `^9` — declared for DataTable consumers; the current DataTable implementation does not call it
|
|
40
|
+
|
|
41
|
+
Install the matching library in the consumer when you use that granular path. Tailwind `^4` remains optional for the Tailwind stylesheet contract.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type XYPoint } from "./sample.js";
|
|
2
|
+
export declare function AreaChart({ data, ariaLabel, className, showAxes, stacked, }: {
|
|
3
|
+
data?: XYPoint[];
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
showAxes?: boolean;
|
|
7
|
+
stacked?: boolean;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHART_COLORS as e } from "./palette.js";
|
|
3
|
+
import { ANIMATION_PROPS as t, CHART_TYPE as n, GRID_PROPS as r, cartesianAxisProps as i, chartTooltipProps as a } from "./config.js";
|
|
4
|
+
import { SAMPLE as o } from "./sample.js";
|
|
5
|
+
import { ChartFrame as s } from "./frame.js";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Area as u, AreaChart as d, CartesianGrid as f, Tooltip as p, XAxis as m, YAxis as h } from "recharts";
|
|
8
|
+
//#region src/charts/area.tsx
|
|
9
|
+
function g({ data: g = o, ariaLabel: _ = "Area chart", className: v, showAxes: y = !1, stacked: b = !1 }) {
|
|
10
|
+
let x = g.some((e) => e.y2 != null), S = g.some((e) => e.y3 != null), C = b ? "stack" : void 0;
|
|
11
|
+
return /* @__PURE__ */ c(s, {
|
|
12
|
+
ariaLabel: _,
|
|
13
|
+
className: v,
|
|
14
|
+
children: /* @__PURE__ */ l(d, {
|
|
15
|
+
data: g,
|
|
16
|
+
children: [
|
|
17
|
+
y ? /* @__PURE__ */ c(f, { ...r }) : null,
|
|
18
|
+
/* @__PURE__ */ c(m, {
|
|
19
|
+
dataKey: "x",
|
|
20
|
+
...i(!y)
|
|
21
|
+
}),
|
|
22
|
+
/* @__PURE__ */ c(h, { ...i(!y) }),
|
|
23
|
+
/* @__PURE__ */ c(p, { ...a({ cursor: "line" }) }),
|
|
24
|
+
/* @__PURE__ */ c(u, {
|
|
25
|
+
dataKey: "y",
|
|
26
|
+
stackId: C,
|
|
27
|
+
stroke: e[0],
|
|
28
|
+
fill: e[0],
|
|
29
|
+
fillOpacity: n.areaFillAlpha,
|
|
30
|
+
...t
|
|
31
|
+
}),
|
|
32
|
+
x ? /* @__PURE__ */ c(u, {
|
|
33
|
+
dataKey: "y2",
|
|
34
|
+
stackId: C,
|
|
35
|
+
stroke: e[2],
|
|
36
|
+
fill: e[2],
|
|
37
|
+
fillOpacity: n.areaFillAlpha,
|
|
38
|
+
...t
|
|
39
|
+
}) : null,
|
|
40
|
+
S ? /* @__PURE__ */ c(u, {
|
|
41
|
+
dataKey: "y3",
|
|
42
|
+
stackId: C,
|
|
43
|
+
stroke: e[4],
|
|
44
|
+
fill: e[4],
|
|
45
|
+
fillOpacity: n.areaFillAlpha,
|
|
46
|
+
...t
|
|
47
|
+
}) : null
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { g as AreaChart };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"area.js","names":[],"sources":["../../src/charts/area.tsx"],"sourcesContent":["import { Area, CartesianGrid, AreaChart as RechartsArea, Tooltip, XAxis, YAxis } from \"recharts\";\nimport {\n\tANIMATION_PROPS,\n\tCHART_TYPE,\n\tcartesianAxisProps,\n\tchartTooltipProps,\n\tGRID_PROPS,\n} from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS } from \"./palette\";\nimport { SAMPLE, type XYPoint } from \"./sample\";\n\nexport function AreaChart({\n\tdata = SAMPLE,\n\tariaLabel = \"Area chart\",\n\tclassName,\n\tshowAxes = false,\n\tstacked = false,\n}: {\n\tdata?: XYPoint[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tstacked?: boolean;\n}) {\n\tconst dual = data.some((point) => point.y2 != null);\n\tconst triple = data.some((point) => point.y3 != null);\n\tconst stackId = stacked ? \"stack\" : undefined;\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsArea data={data}>\n\t\t\t\t{showAxes ? <CartesianGrid {...GRID_PROPS} /> : null}\n\t\t\t\t<XAxis dataKey=\"x\" {...cartesianAxisProps(!showAxes)} />\n\t\t\t\t<YAxis {...cartesianAxisProps(!showAxes)} />\n\t\t\t\t<Tooltip {...chartTooltipProps({ cursor: \"line\" })} />\n\t\t\t\t<Area\n\t\t\t\t\tdataKey=\"y\"\n\t\t\t\t\tstackId={stackId}\n\t\t\t\t\tstroke={CHART_COLORS[0]}\n\t\t\t\t\tfill={CHART_COLORS[0]}\n\t\t\t\t\tfillOpacity={CHART_TYPE.areaFillAlpha}\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t/>\n\t\t\t\t{dual ? (\n\t\t\t\t\t<Area\n\t\t\t\t\t\tdataKey=\"y2\"\n\t\t\t\t\t\tstackId={stackId}\n\t\t\t\t\t\tstroke={CHART_COLORS[2]}\n\t\t\t\t\t\tfill={CHART_COLORS[2]}\n\t\t\t\t\t\tfillOpacity={CHART_TYPE.areaFillAlpha}\n\t\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{triple ? (\n\t\t\t\t\t<Area\n\t\t\t\t\t\tdataKey=\"y3\"\n\t\t\t\t\t\tstackId={stackId}\n\t\t\t\t\t\tstroke={CHART_COLORS[4]}\n\t\t\t\t\t\tfill={CHART_COLORS[4]}\n\t\t\t\t\t\tfillOpacity={CHART_TYPE.areaFillAlpha}\n\t\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</RechartsArea>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,EAAU,EACzB,UAAO,GACP,eAAY,cACZ,cACA,cAAW,IACX,aAAU,MAOR;CACF,IAAM,IAAO,EAAK,MAAM,MAAU,EAAM,MAAM,IAAI,GAC5C,IAAS,EAAK,MAAM,MAAU,EAAM,MAAM,IAAI,GAC9C,IAAU,IAAU,UAAU,KAAA;CACpC,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD;GAAoB;GAApB,UAAA;IACE,IAAW,kBAAC,GAAD,EAAe,GAAI,EAAa,CAAA,IAAI;IAChD,kBAAC,GAAD;KAAO,SAAQ;KAAI,GAAI,EAAmB,CAAC,CAAQ;IAAI,CAAA;IACvD,kBAAC,GAAD,EAAO,GAAI,EAAmB,CAAC,CAAQ,EAAI,CAAA;IAC3C,kBAAC,GAAD,EAAS,GAAI,EAAkB,EAAE,QAAQ,OAAO,CAAC,EAAI,CAAA;IACrD,kBAAC,GAAD;KACC,SAAQ;KACC;KACT,QAAQ,EAAa;KACrB,MAAM,EAAa;KACnB,aAAa,EAAW;KACxB,GAAI;IACJ,CAAA;IACA,IACA,kBAAC,GAAD;KACC,SAAQ;KACC;KACT,QAAQ,EAAa;KACrB,MAAM,EAAa;KACnB,aAAa,EAAW;KACxB,GAAI;IACJ,CAAA,IACE;IACH,IACA,kBAAC,GAAD;KACC,SAAQ;KACC;KACT,QAAQ,EAAa;KACrB,MAAM,EAAa;KACnB,aAAa,EAAW;KACxB,GAAI;IACJ,CAAA,IACE;GACS;;CACH,CAAA;AAEd"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type XYPoint } from "./sample.js";
|
|
2
|
+
export declare function BarChart({ data, ariaLabel, className, showAxes, color, valueFormatter, }: {
|
|
3
|
+
data?: XYPoint[];
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
showAxes?: boolean;
|
|
7
|
+
color?: string;
|
|
8
|
+
valueFormatter?: (value: number) => string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHART_COLORS as e } from "./palette.js";
|
|
3
|
+
import { ANIMATION_PROPS as t, BAR_RADIUS as n, GRID_PROPS as r, cartesianAxisProps as i, chartTooltipProps as a } from "./config.js";
|
|
4
|
+
import { SAMPLE as o } from "./sample.js";
|
|
5
|
+
import { ChartFrame as s } from "./frame.js";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Bar as u, BarChart as d, CartesianGrid as f, Tooltip as p, XAxis as m, YAxis as h } from "recharts";
|
|
8
|
+
//#region src/charts/bar.tsx
|
|
9
|
+
function g({ data: g = o, ariaLabel: _ = "Bar chart", className: v, showAxes: y = !1, color: b, valueFormatter: x }) {
|
|
10
|
+
return /* @__PURE__ */ c(s, {
|
|
11
|
+
ariaLabel: _,
|
|
12
|
+
className: v,
|
|
13
|
+
children: /* @__PURE__ */ l(d, {
|
|
14
|
+
data: g,
|
|
15
|
+
children: [
|
|
16
|
+
y ? /* @__PURE__ */ c(f, { ...r }) : null,
|
|
17
|
+
/* @__PURE__ */ c(m, {
|
|
18
|
+
dataKey: "x",
|
|
19
|
+
...i(!y)
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ c(h, {
|
|
22
|
+
...i(!y),
|
|
23
|
+
tickFormatter: x
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ c(p, { ...a({
|
|
26
|
+
formatter: x,
|
|
27
|
+
cursor: "bar"
|
|
28
|
+
}) }),
|
|
29
|
+
/* @__PURE__ */ c(u, {
|
|
30
|
+
dataKey: "y",
|
|
31
|
+
fill: b ?? e[0],
|
|
32
|
+
radius: n.vertical,
|
|
33
|
+
...t
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { g as BarChart };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar.js","names":[],"sources":["../../src/charts/bar.tsx"],"sourcesContent":["import { Bar, CartesianGrid, BarChart as RechartsBar, Tooltip, XAxis, YAxis } from \"recharts\";\nimport {\n\tANIMATION_PROPS,\n\tBAR_RADIUS,\n\tcartesianAxisProps,\n\tchartTooltipProps,\n\tGRID_PROPS,\n} from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS } from \"./palette\";\nimport { SAMPLE, type XYPoint } from \"./sample\";\n\nexport function BarChart({\n\tdata = SAMPLE,\n\tariaLabel = \"Bar chart\",\n\tclassName,\n\tshowAxes = false,\n\tcolor,\n\tvalueFormatter,\n}: {\n\tdata?: XYPoint[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tcolor?: string;\n\tvalueFormatter?: (value: number) => string;\n}) {\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsBar data={data}>\n\t\t\t\t{showAxes ? <CartesianGrid {...GRID_PROPS} /> : null}\n\t\t\t\t<XAxis dataKey=\"x\" {...cartesianAxisProps(!showAxes)} />\n\t\t\t\t<YAxis {...cartesianAxisProps(!showAxes)} tickFormatter={valueFormatter} />\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: \"bar\" })} />\n\t\t\t\t<Bar\n\t\t\t\t\tdataKey=\"y\"\n\t\t\t\t\tfill={color ?? CHART_COLORS[0]}\n\t\t\t\t\tradius={BAR_RADIUS.vertical}\n\t\t\t\t\t{...ANIMATION_PROPS}\n\t\t\t\t/>\n\t\t\t</RechartsBar>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,EAAS,EACxB,UAAO,GACP,eAAY,aACZ,cACA,cAAW,IACX,UACA,qBAQE;CACF,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD;GAAmB;GAAnB,UAAA;IACE,IAAW,kBAAC,GAAD,EAAe,GAAI,EAAa,CAAA,IAAI;IAChD,kBAAC,GAAD;KAAO,SAAQ;KAAI,GAAI,EAAmB,CAAC,CAAQ;IAAI,CAAA;IACvD,kBAAC,GAAD;KAAO,GAAI,EAAmB,CAAC,CAAQ;KAAG,eAAe;IAAiB,CAAA;IAC1E,kBAAC,GAAD,EAAS,GAAI,EAAkB;KAAE,WAAW;KAAgB,QAAQ;IAAM,CAAC,EAAI,CAAA;IAC/E,kBAAC,GAAD;KACC,SAAQ;KACR,MAAM,KAAS,EAAa;KAC5B,QAAQ,EAAW;KACnB,GAAI;IACJ,CAAA;GACW;;CACF,CAAA;AAEd"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BulletPoint } from "./sample.js";
|
|
2
|
+
export declare function BulletChart({ data, ariaLabel, className, showAxes, valueFormatter, }: {
|
|
3
|
+
data?: BulletPoint[];
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
showAxes?: boolean;
|
|
7
|
+
valueFormatter?: (value: number) => string;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHART_COLORS as e } from "./palette.js";
|
|
3
|
+
import { ANIMATION_PROPS as t, cartesianAxisProps as n, chartTooltipProps as r } from "./config.js";
|
|
4
|
+
import { BULLET_SAMPLE as i } from "./sample.js";
|
|
5
|
+
import { ChartFrame as a } from "./frame.js";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { Bar as c, BarChart as l, Tooltip as u, XAxis as d, YAxis as f } from "recharts";
|
|
8
|
+
//#region src/charts/bullet.tsx
|
|
9
|
+
function p({ data: p = i, ariaLabel: m = "Bullet chart", className: h, showAxes: g = !0, valueFormatter: _ }) {
|
|
10
|
+
return /* @__PURE__ */ o(a, {
|
|
11
|
+
ariaLabel: m,
|
|
12
|
+
className: h,
|
|
13
|
+
children: /* @__PURE__ */ s(l, {
|
|
14
|
+
data: p,
|
|
15
|
+
layout: "vertical",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ o(d, {
|
|
18
|
+
type: "number",
|
|
19
|
+
...n(!g),
|
|
20
|
+
tickFormatter: _
|
|
21
|
+
}),
|
|
22
|
+
/* @__PURE__ */ o(f, {
|
|
23
|
+
type: "category",
|
|
24
|
+
dataKey: "name",
|
|
25
|
+
...n(!g)
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ o(u, { ...r({
|
|
28
|
+
formatter: _,
|
|
29
|
+
cursor: "bar"
|
|
30
|
+
}) }),
|
|
31
|
+
/* @__PURE__ */ o(c, {
|
|
32
|
+
dataKey: "target",
|
|
33
|
+
fill: e[6],
|
|
34
|
+
barSize: 10,
|
|
35
|
+
...t
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ o(c, {
|
|
38
|
+
dataKey: "value",
|
|
39
|
+
fill: e[1],
|
|
40
|
+
barSize: 6,
|
|
41
|
+
...t
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { p as BulletChart };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=bullet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bullet.js","names":[],"sources":["../../src/charts/bullet.tsx"],"sourcesContent":["import { Bar, BarChart as RechartsBar, Tooltip, XAxis, YAxis } from \"recharts\";\nimport { ANIMATION_PROPS, cartesianAxisProps, chartTooltipProps } from \"./config\";\nimport { ChartFrame } from \"./frame\";\nimport { CHART_COLORS } from \"./palette\";\nimport { BULLET_SAMPLE, type BulletPoint } from \"./sample\";\n\nexport function BulletChart({\n\tdata = BULLET_SAMPLE,\n\tariaLabel = \"Bullet chart\",\n\tclassName,\n\tshowAxes = true,\n\tvalueFormatter,\n}: {\n\tdata?: BulletPoint[];\n\tariaLabel?: string;\n\tclassName?: string;\n\tshowAxes?: boolean;\n\tvalueFormatter?: (value: number) => string;\n}) {\n\treturn (\n\t\t<ChartFrame ariaLabel={ariaLabel} className={className}>\n\t\t\t<RechartsBar data={data} layout=\"vertical\">\n\t\t\t\t<XAxis type=\"number\" {...cartesianAxisProps(!showAxes)} tickFormatter={valueFormatter} />\n\t\t\t\t<YAxis type=\"category\" dataKey=\"name\" {...cartesianAxisProps(!showAxes)} />\n\t\t\t\t<Tooltip {...chartTooltipProps({ formatter: valueFormatter, cursor: \"bar\" })} />\n\t\t\t\t<Bar dataKey=\"target\" fill={CHART_COLORS[6]} barSize={10} {...ANIMATION_PROPS} />\n\t\t\t\t<Bar dataKey=\"value\" fill={CHART_COLORS[1]} barSize={6} {...ANIMATION_PROPS} />\n\t\t\t</RechartsBar>\n\t\t</ChartFrame>\n\t);\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,EAAY,EAC3B,UAAO,GACP,eAAY,gBACZ,cACA,cAAW,IACX,qBAOE;CACF,OACC,kBAAC,GAAD;EAAuB;EAAsB;EAC5C,UAAA,kBAAC,GAAD;GAAmB;GAAM,QAAO;GAAhC,UAAA;IACC,kBAAC,GAAD;KAAO,MAAK;KAAS,GAAI,EAAmB,CAAC,CAAQ;KAAG,eAAe;IAAiB,CAAA;IACxF,kBAAC,GAAD;KAAO,MAAK;KAAW,SAAQ;KAAO,GAAI,EAAmB,CAAC,CAAQ;IAAI,CAAA;IAC1E,kBAAC,GAAD,EAAS,GAAI,EAAkB;KAAE,WAAW;KAAgB,QAAQ;IAAM,CAAC,EAAI,CAAA;IAC/E,kBAAC,GAAD;KAAK,SAAQ;KAAS,MAAM,EAAa;KAAI,SAAS;KAAI,GAAI;IAAkB,CAAA;IAChF,kBAAC,GAAD;KAAK,SAAQ;KAAQ,MAAM,EAAa;KAAI,SAAS;KAAG,GAAI;IAAkB,CAAA;GAClE;;CACF,CAAA;AAEd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CHART_COLORS, ChartPalette as Colors } from "./palette.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LineChart as e } from "./line.js";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/charts/charts.tsx
|
|
5
|
+
function n({ data: n, ariaLabel: r = "Charts", className: i }) {
|
|
6
|
+
return /* @__PURE__ */ t(e, {
|
|
7
|
+
data: n,
|
|
8
|
+
ariaLabel: r,
|
|
9
|
+
className: i
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as Charts };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=charts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.js","names":[],"sources":["../../src/charts/charts.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint } from \"./sample\";\n\nexport function Charts({\n\tdata,\n\tariaLabel = \"Charts\",\n\tclassName,\n}: {\n\tdata?: XYPoint[];\n\tariaLabel?: string;\n\tclassName?: string;\n}) {\n\treturn <LineChart data={data} ariaLabel={ariaLabel} className={className} />;\n}\n"],"mappings":";;;;AAGA,SAAgB,EAAO,EACtB,SACA,eAAY,UACZ,gBAKE;CACF,OAAO,kBAAC,GAAD;EAAiB;EAAiB;EAAsB;CAAY,CAAA;AAC5E"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export type ChartTypeFace = "axis" | "legend" | "tooltipTitle" | "tooltipBody";
|
|
2
|
+
export declare const CHART_TYPE: {
|
|
3
|
+
readonly axisFontSize: 11;
|
|
4
|
+
readonly legendFontSize: 12;
|
|
5
|
+
readonly tooltipTitleSize: 12;
|
|
6
|
+
readonly tooltipBodySize: 12;
|
|
7
|
+
readonly tooltipDot: 8;
|
|
8
|
+
readonly strokeWidth: 2;
|
|
9
|
+
readonly gridDash: "3 3";
|
|
10
|
+
readonly gridOpacity: 0.15;
|
|
11
|
+
readonly areaFillAlpha: 0.2;
|
|
12
|
+
};
|
|
13
|
+
export declare function chartFontSize(face: ChartTypeFace): number;
|
|
14
|
+
export declare function chartTextStyle(face: ChartTypeFace): {
|
|
15
|
+
fontSize: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function chartTickStyle(face?: ChartTypeFace): {
|
|
18
|
+
fontSize: number;
|
|
19
|
+
fill: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function getChartColor(index: number): string;
|
|
22
|
+
export declare const AXIS_CONFIG: {
|
|
23
|
+
readonly tick: {
|
|
24
|
+
fontSize: number;
|
|
25
|
+
fill: string;
|
|
26
|
+
};
|
|
27
|
+
axisLine: false;
|
|
28
|
+
tickLine: false;
|
|
29
|
+
};
|
|
30
|
+
export declare function cartesianAxisProps(hidden?: boolean): {
|
|
31
|
+
tick: {
|
|
32
|
+
fontSize: number;
|
|
33
|
+
fill: string;
|
|
34
|
+
};
|
|
35
|
+
axisLine: false;
|
|
36
|
+
tickLine: false;
|
|
37
|
+
hide: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare const GRID_PROPS: {
|
|
40
|
+
vertical: false;
|
|
41
|
+
stroke: string;
|
|
42
|
+
strokeOpacity: 0.15;
|
|
43
|
+
strokeDasharray: "3 3";
|
|
44
|
+
};
|
|
45
|
+
export declare const BAR_RADIUS: {
|
|
46
|
+
horizontal: [number, number, number, number];
|
|
47
|
+
vertical: [number, number, number, number];
|
|
48
|
+
};
|
|
49
|
+
export declare const ANIMATION_PROPS: {
|
|
50
|
+
isAnimationActive: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare const CHART_TOOLTIP_CURSOR_LINE: {
|
|
53
|
+
readonly stroke: string;
|
|
54
|
+
readonly strokeOpacity: 0.35;
|
|
55
|
+
readonly strokeWidth: 1;
|
|
56
|
+
};
|
|
57
|
+
export declare const CHART_TOOLTIP_CURSOR_BAR: {
|
|
58
|
+
readonly fill: string;
|
|
59
|
+
readonly stroke: "none";
|
|
60
|
+
};
|
|
61
|
+
export declare function chartTooltipContentStyle(): {
|
|
62
|
+
background: string;
|
|
63
|
+
border: string;
|
|
64
|
+
borderRadius: string;
|
|
65
|
+
fontSize: number;
|
|
66
|
+
color: string;
|
|
67
|
+
};
|
|
68
|
+
export declare function chartTooltipProps(options?: {
|
|
69
|
+
formatter?: (value: number) => string;
|
|
70
|
+
cursor?: "bar" | "line" | false;
|
|
71
|
+
}): {
|
|
72
|
+
isAnimationActive: boolean;
|
|
73
|
+
animationDuration: number;
|
|
74
|
+
offset: number;
|
|
75
|
+
cursor: boolean | {
|
|
76
|
+
readonly stroke: string;
|
|
77
|
+
readonly strokeOpacity: 0.35;
|
|
78
|
+
readonly strokeWidth: 1;
|
|
79
|
+
} | {
|
|
80
|
+
readonly fill: string;
|
|
81
|
+
readonly stroke: "none";
|
|
82
|
+
};
|
|
83
|
+
wrapperStyle: {
|
|
84
|
+
outline: string;
|
|
85
|
+
zIndex: number;
|
|
86
|
+
pointerEvents: "none";
|
|
87
|
+
};
|
|
88
|
+
contentStyle: {
|
|
89
|
+
background: string;
|
|
90
|
+
border: string;
|
|
91
|
+
borderRadius: string;
|
|
92
|
+
fontSize: number;
|
|
93
|
+
color: string;
|
|
94
|
+
};
|
|
95
|
+
labelStyle: {
|
|
96
|
+
fontSize: number;
|
|
97
|
+
color: string;
|
|
98
|
+
};
|
|
99
|
+
itemStyle: {
|
|
100
|
+
fontSize: number;
|
|
101
|
+
};
|
|
102
|
+
formatter: ((value: unknown) => string | undefined) | undefined;
|
|
103
|
+
};
|
|
104
|
+
export declare function chartLegendProps(): {
|
|
105
|
+
wrapperStyle: {
|
|
106
|
+
fontSize: number;
|
|
107
|
+
color: string;
|
|
108
|
+
};
|
|
109
|
+
iconSize: number;
|
|
110
|
+
};
|
|
111
|
+
export declare const RESPONSIVE_CONTAINER_PROPS: {
|
|
112
|
+
width: "100%";
|
|
113
|
+
height: "100%";
|
|
114
|
+
minWidth: number;
|
|
115
|
+
minHeight: number;
|
|
116
|
+
debounce: number;
|
|
117
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHART_COLORS as e, chartAxis as t, withAlpha as n } from "./palette.js";
|
|
3
|
+
//#region src/charts/config.ts
|
|
4
|
+
var r = {
|
|
5
|
+
axisFontSize: 11,
|
|
6
|
+
legendFontSize: 12,
|
|
7
|
+
tooltipTitleSize: 12,
|
|
8
|
+
tooltipBodySize: 12,
|
|
9
|
+
tooltipDot: 8,
|
|
10
|
+
strokeWidth: 2,
|
|
11
|
+
gridDash: "3 3",
|
|
12
|
+
gridOpacity: .15,
|
|
13
|
+
areaFillAlpha: .2
|
|
14
|
+
};
|
|
15
|
+
function i(e) {
|
|
16
|
+
return e === "legend" ? r.legendFontSize : e === "tooltipTitle" ? r.tooltipTitleSize : e === "tooltipBody" ? r.tooltipBodySize : r.axisFontSize;
|
|
17
|
+
}
|
|
18
|
+
function a(e) {
|
|
19
|
+
return { fontSize: i(e) };
|
|
20
|
+
}
|
|
21
|
+
function o(e = "axis") {
|
|
22
|
+
return {
|
|
23
|
+
fontSize: i(e),
|
|
24
|
+
fill: t
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function s(t) {
|
|
28
|
+
return e[t % e.length] ?? e[0];
|
|
29
|
+
}
|
|
30
|
+
var c = {
|
|
31
|
+
get tick() {
|
|
32
|
+
return o("axis");
|
|
33
|
+
},
|
|
34
|
+
axisLine: !1,
|
|
35
|
+
tickLine: !1
|
|
36
|
+
};
|
|
37
|
+
function l(e = !1) {
|
|
38
|
+
return {
|
|
39
|
+
hide: e,
|
|
40
|
+
...c
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var u = {
|
|
44
|
+
vertical: !1,
|
|
45
|
+
stroke: t,
|
|
46
|
+
strokeOpacity: r.gridOpacity,
|
|
47
|
+
strokeDasharray: r.gridDash
|
|
48
|
+
}, d = {
|
|
49
|
+
horizontal: [
|
|
50
|
+
0,
|
|
51
|
+
4,
|
|
52
|
+
4,
|
|
53
|
+
0
|
|
54
|
+
],
|
|
55
|
+
vertical: [
|
|
56
|
+
4,
|
|
57
|
+
4,
|
|
58
|
+
0,
|
|
59
|
+
0
|
|
60
|
+
]
|
|
61
|
+
}, f = { isAnimationActive: !1 }, p = {
|
|
62
|
+
stroke: t,
|
|
63
|
+
strokeOpacity: .35,
|
|
64
|
+
strokeWidth: 1
|
|
65
|
+
}, m = {
|
|
66
|
+
fill: n("foreground", .06),
|
|
67
|
+
stroke: "none"
|
|
68
|
+
};
|
|
69
|
+
function h() {
|
|
70
|
+
return {
|
|
71
|
+
background: "hsl(var(--basalt-popover))",
|
|
72
|
+
border: "1px solid hsl(var(--basalt-border))",
|
|
73
|
+
borderRadius: "8px",
|
|
74
|
+
fontSize: i("tooltipBody"),
|
|
75
|
+
color: "hsl(var(--basalt-foreground))"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function g(e) {
|
|
79
|
+
return {
|
|
80
|
+
isAnimationActive: !1,
|
|
81
|
+
animationDuration: 0,
|
|
82
|
+
offset: 12,
|
|
83
|
+
cursor: e?.cursor === !1 ? !1 : e?.cursor === "line" ? p : m,
|
|
84
|
+
wrapperStyle: {
|
|
85
|
+
outline: "none",
|
|
86
|
+
zIndex: 40,
|
|
87
|
+
pointerEvents: "none"
|
|
88
|
+
},
|
|
89
|
+
contentStyle: h(),
|
|
90
|
+
labelStyle: {
|
|
91
|
+
fontSize: i("tooltipTitle"),
|
|
92
|
+
color: "hsl(var(--basalt-foreground))"
|
|
93
|
+
},
|
|
94
|
+
itemStyle: a("tooltipBody"),
|
|
95
|
+
formatter: e?.formatter ? (t) => e.formatter?.(Number(t)) : void 0
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function _() {
|
|
99
|
+
return {
|
|
100
|
+
wrapperStyle: {
|
|
101
|
+
fontSize: i("legend"),
|
|
102
|
+
color: t
|
|
103
|
+
},
|
|
104
|
+
iconSize: 8
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
var v = {
|
|
108
|
+
width: "100%",
|
|
109
|
+
height: "100%",
|
|
110
|
+
minWidth: 0,
|
|
111
|
+
minHeight: 0,
|
|
112
|
+
debounce: 150
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { f as ANIMATION_PROPS, c as AXIS_CONFIG, d as BAR_RADIUS, m as CHART_TOOLTIP_CURSOR_BAR, p as CHART_TOOLTIP_CURSOR_LINE, r as CHART_TYPE, u as GRID_PROPS, v as RESPONSIVE_CONTAINER_PROPS, l as cartesianAxisProps, i as chartFontSize, _ as chartLegendProps, a as chartTextStyle, o as chartTickStyle, h as chartTooltipContentStyle, g as chartTooltipProps, s as getChartColor };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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: \"hsl(var(--basalt-popover))\",\n\t\tborder: \"1px solid hsl(var(--basalt-border))\",\n\t\tborderRadius: \"8px\",\n\t\tfontSize: chartFontSize(\"tooltipBody\"),\n\t\tcolor: \"hsl(var(--basalt-foreground))\",\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\tcursor,\n\t\twrapperStyle: {\n\t\t\toutline: \"none\",\n\t\t\tzIndex: 40,\n\t\t\tpointerEvents: \"none\" as const,\n\t\t},\n\t\tcontentStyle: chartTooltipContentStyle(),\n\t\tlabelStyle: {\n\t\t\tfontSize: chartFontSize(\"tooltipTitle\"),\n\t\t\tcolor: \"hsl(var(--basalt-foreground))\",\n\t\t},\n\t\titemStyle: chartTextStyle(\"tooltipBody\"),\n\t\tformatter: options?.formatter\n\t\t\t? (value: unknown) => options.formatter?.(Number(value))\n\t\t\t: undefined,\n\t};\n}\n\nexport function chartLegendProps() {\n\treturn {\n\t\twrapperStyle: {\n\t\t\tfontSize: chartFontSize(\"legend\"),\n\t\t\tcolor: chartAxis,\n\t\t},\n\t\ticonSize: 8,\n\t};\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"],"mappings":";;;AAIA,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,IAMd;CACD,OAAO;EACN,YAAY;EACZ,QAAQ;EACR,cAAc;EACd,UAAU,EAAc,aAAa;EACrC,OAAO;CACR;AACD;AAEA,SAAgB,EAAkB,GAG/B;CAOF,OAAO;EACN,mBAAmB;EACnB,mBAAmB;EACnB,QAAQ;EACR,QATA,GAAS,WAAW,KACjB,KACA,GAAS,WAAW,SACnB,IACA;EAMJ,cAAc;GACb,SAAS;GACT,QAAQ;GACR,eAAe;EAChB;EACA,cAAc,EAAyB;EACvC,YAAY;GACX,UAAU,EAAc,cAAc;GACtC,OAAO;EACR;EACA,WAAW,EAAe,aAAa;EACvC,WAAW,GAAS,aAChB,MAAmB,EAAQ,YAAY,OAAO,CAAK,CAAC,IACrD,KAAA;CACJ;AACD;AAEA,SAAgB,IAAmB;CAClC,OAAO;EACN,cAAc;GACb,UAAU,EAAc,QAAQ;GAChC,OAAO;EACR;EACA,UAAU;CACX;AACD;AAEA,IAAa,IAA6B;CACzC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;AACX"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LineChart as e } from "./line.js";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/charts/custom-chart.tsx
|
|
5
|
+
function n({ data: n, ariaLabel: r = "Custom chart", className: i }) {
|
|
6
|
+
return /* @__PURE__ */ t(e, {
|
|
7
|
+
data: n,
|
|
8
|
+
ariaLabel: r,
|
|
9
|
+
className: i
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as CustomChart };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=custom-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-chart.js","names":[],"sources":["../../src/charts/custom-chart.tsx"],"sourcesContent":["import { LineChart } from \"./line\";\nimport type { XYPoint } from \"./sample\";\n\nexport function CustomChart({\n\tdata,\n\tariaLabel = \"Custom chart\",\n\tclassName,\n}: {\n\tdata?: XYPoint[];\n\tariaLabel?: string;\n\tclassName?: string;\n}) {\n\treturn <LineChart data={data} ariaLabel={ariaLabel} className={className} />;\n}\n"],"mappings":";;;;AAGA,SAAgB,EAAY,EAC3B,SACA,eAAY,gBACZ,gBAKE;CACF,OAAO,kBAAC,GAAD;EAAiB;EAAiB;EAAsB;CAAY,CAAA;AAC5E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ComponentProps } from "react";
|
|
2
|
+
import { DatePicker } from "../components/date-picker.js";
|
|
3
|
+
type PickerProps = ComponentProps<typeof DatePicker> & {
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
selectedDate?: undefined;
|
|
6
|
+
};
|
|
7
|
+
type DisplayProps = {
|
|
8
|
+
selectedDate: Date;
|
|
9
|
+
onPrevDay: () => void;
|
|
10
|
+
onNextDay: () => void;
|
|
11
|
+
onToday: () => void;
|
|
12
|
+
onToggleCalendar?: () => void;
|
|
13
|
+
todayLabel?: string;
|
|
14
|
+
previousDayLabel?: string;
|
|
15
|
+
nextDayLabel?: string;
|
|
16
|
+
formatDate?: (date: Date) => string;
|
|
17
|
+
locale?: string;
|
|
18
|
+
timeZone?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function DateNavigation(props: PickerProps | DisplayProps): import("react").JSX.Element;
|
|
22
|
+
export {};
|