@glyphui/ui 0.2.0 → 0.3.0
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/chart.d.ts +202 -0
- package/dist/chart.js +457 -0
- package/dist/data-table.js +3 -2
- package/dist/{field-CCecIzdq.js → field-CWZ_FdkD.js} +2 -1
- package/dist/{field-context-B6WOcK5m.js → field-context-anGPYXbW.js} +2 -56
- package/dist/form.js +3 -2
- package/dist/index.d.ts +2285 -241
- package/dist/index.js +2819 -266
- package/dist/{states-Rp8wZ_jH.js → states-DR-OoDT-.js} +2 -1
- package/dist/tv-DBAGlgXJ.js +58 -0
- package/package.json +17 -2
- package/src/components/accordion/accordion.styles.ts +4 -4
- package/src/components/calendar/calendar.styles.ts +50 -0
- package/src/components/calendar/calendar.tsx +84 -0
- package/src/components/calendar/index.ts +3 -0
- package/src/components/carousel/carousel.styles.ts +43 -0
- package/src/components/carousel/carousel.tsx +278 -0
- package/src/components/carousel/index.ts +13 -0
- package/src/components/collapsible/collapsible.tsx +66 -0
- package/src/components/collapsible/index.ts +6 -0
- package/src/components/context-menu/context-menu.styles.ts +19 -0
- package/src/components/context-menu/context-menu.tsx +226 -0
- package/src/components/context-menu/index.ts +19 -0
- package/src/components/copy-button/copy-button.tsx +117 -0
- package/src/components/copy-button/index.ts +1 -0
- package/src/components/date-picker/date-picker.styles.ts +42 -0
- package/src/components/date-picker/date-picker.tsx +322 -0
- package/src/components/date-picker/index.ts +8 -0
- package/src/components/file-upload/file-upload.styles.ts +43 -0
- package/src/components/file-upload/file-upload.tsx +343 -0
- package/src/components/file-upload/index.ts +10 -0
- package/src/components/hover-card/hover-card.tsx +41 -0
- package/src/components/hover-card/index.ts +1 -0
- package/src/components/input-otp/index.ts +10 -0
- package/src/components/input-otp/input-otp.styles.ts +38 -0
- package/src/components/input-otp/input-otp.tsx +116 -0
- package/src/components/modal/index.ts +2 -0
- package/src/components/modal/modal.styles.ts +18 -0
- package/src/components/modal/modal.tsx +86 -0
- package/src/components/navigation-menu/index.ts +14 -0
- package/src/components/navigation-menu/navigation-menu.styles.ts +48 -0
- package/src/components/navigation-menu/navigation-menu.tsx +198 -0
- package/src/components/number-input/index.ts +2 -0
- package/src/components/number-input/number-input.styles.ts +41 -0
- package/src/components/number-input/number-input.tsx +211 -0
- package/src/components/password-input/index.ts +7 -0
- package/src/components/password-input/password-input.styles.ts +30 -0
- package/src/components/password-input/password-input.tsx +127 -0
- package/src/components/resizable/index.ts +9 -0
- package/src/components/resizable/resizable.styles.ts +28 -0
- package/src/components/resizable/resizable.tsx +69 -0
- package/src/components/sheet/sheet.styles.ts +7 -7
- package/src/components/stepper/index.ts +2 -0
- package/src/components/stepper/stepper.styles.ts +74 -0
- package/src/components/stepper/stepper.tsx +138 -0
- package/src/components/tag-input/index.ts +2 -0
- package/src/components/tag-input/tag-input.styles.ts +39 -0
- package/src/components/tag-input/tag-input.tsx +198 -0
- package/src/components/timeline/index.ts +8 -0
- package/src/components/timeline/timeline.styles.ts +56 -0
- package/src/components/timeline/timeline.tsx +91 -0
- package/src/components/toggle/index.ts +9 -0
- package/src/components/toggle/toggle.styles.ts +39 -0
- package/src/components/toggle/toggle.tsx +61 -0
- package/src/components/tree-view/index.ts +2 -0
- package/src/components/tree-view/tree-view.styles.ts +42 -0
- package/src/components/tree-view/tree-view.tsx +274 -0
- package/src/components/visually-hidden/index.ts +1 -0
- package/src/components/visually-hidden/visually-hidden.tsx +10 -0
- package/src/index.ts +20 -0
- package/src/patterns/chart/chart-parts.tsx +171 -0
- package/src/patterns/chart/chart.styles.ts +35 -0
- package/src/patterns/chart/chart.tsx +369 -0
- package/src/patterns/chart/index.ts +13 -0
- package/styles.css +16 -0
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { t as VariantProps } from "./tv-DuMh7UH2.js";
|
|
2
|
+
import { t as StylesEntry } from "./registry-BGSJoiLq.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
//#region src/patterns/chart/chart-parts.d.ts
|
|
5
|
+
/** Theme colors a series can use by name. Any CSS color also works. */
|
|
6
|
+
type ChartColor = 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'foreground' | 'muted-foreground';
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/patterns/chart/chart.d.ts
|
|
9
|
+
type Key<T> = Extract<keyof T, string>;
|
|
10
|
+
interface ChartSeries<T> {
|
|
11
|
+
/** Field of each data row holding this series' value. */
|
|
12
|
+
key: Key<T>;
|
|
13
|
+
/** Name shown in the legend, tooltip and accessible table. Defaults to `key`. */
|
|
14
|
+
label?: string;
|
|
15
|
+
/** A theme color name (`primary`, `info`, ...) or any CSS color. Defaults follow the theme palette. */
|
|
16
|
+
color?: ChartColor | (string & {});
|
|
17
|
+
}
|
|
18
|
+
interface CartesianChartProps<T extends object> {
|
|
19
|
+
data: readonly T[];
|
|
20
|
+
/** Field used for the x axis, e.g. `"month"`. */
|
|
21
|
+
index: Key<T>;
|
|
22
|
+
series: readonly ChartSeries<T>[];
|
|
23
|
+
/** Accessible name; also shown as the caption unless `hideTitle` is set. */
|
|
24
|
+
title: string;
|
|
25
|
+
description?: ReactNode;
|
|
26
|
+
hideTitle?: boolean;
|
|
27
|
+
/** Formats values on the y axis, in tooltips and in the accessible table. */
|
|
28
|
+
valueFormatter?: (value: number) => string;
|
|
29
|
+
/** Plot height in pixels. Default 240. */
|
|
30
|
+
height?: number;
|
|
31
|
+
showGrid?: boolean;
|
|
32
|
+
/** Defaults to true when there is more than one series. */
|
|
33
|
+
showLegend?: boolean;
|
|
34
|
+
showYAxis?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Trends over time, one line per series. */
|
|
38
|
+
export declare function LineChart<T extends object>(props: CartesianChartProps<T> & {
|
|
39
|
+
curve?: 'monotone' | 'linear';
|
|
40
|
+
}): import("react").JSX.Element;
|
|
41
|
+
/** Trends with filled areas. `stacked` shows how series add up to a total. */
|
|
42
|
+
export declare function AreaChart<T extends object>(props: CartesianChartProps<T> & {
|
|
43
|
+
stacked?: boolean;
|
|
44
|
+
}): import("react").JSX.Element;
|
|
45
|
+
/** Compare values across categories. `stacked` puts series on top of each other. */
|
|
46
|
+
export declare function BarChart<T extends object>(props: CartesianChartProps<T> & {
|
|
47
|
+
stacked?: boolean; /** Corner radius of bar tops. Default 3. */
|
|
48
|
+
barRadius?: number;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
interface DonutChartProps<T extends object> {
|
|
51
|
+
data: readonly T[];
|
|
52
|
+
/** Field naming each slice. */
|
|
53
|
+
category: Key<T>;
|
|
54
|
+
/** Field holding each slice's value. */
|
|
55
|
+
value: Key<T>;
|
|
56
|
+
title: string;
|
|
57
|
+
description?: ReactNode;
|
|
58
|
+
hideTitle?: boolean;
|
|
59
|
+
/** One color per slice, in order. Defaults follow the theme palette. */
|
|
60
|
+
colors?: readonly (ChartColor | (string & {}))[];
|
|
61
|
+
/** Content in the hole, e.g. the total. */
|
|
62
|
+
centerLabel?: ReactNode;
|
|
63
|
+
valueFormatter?: (value: number) => string;
|
|
64
|
+
/** Diameter in pixels. Default 200. */
|
|
65
|
+
size?: number;
|
|
66
|
+
showLegend?: boolean;
|
|
67
|
+
className?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Parts of a whole. Best with five or fewer slices. */
|
|
70
|
+
export declare function DonutChart<T extends object>(props: DonutChartProps<T>): import("react").JSX.Element;
|
|
71
|
+
interface SparklineProps {
|
|
72
|
+
values: readonly number[];
|
|
73
|
+
/** Accessible description, e.g. "Revenue over the last 12 months, rising". */
|
|
74
|
+
title: string;
|
|
75
|
+
color?: ChartColor | (string & {});
|
|
76
|
+
/** Height in pixels. Default 36. */
|
|
77
|
+
height?: number;
|
|
78
|
+
/** Fill the area under the line. */
|
|
79
|
+
area?: boolean;
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
/** A tiny trend line without axes, for stat cards and table cells. */
|
|
83
|
+
export declare function Sparkline({ values, title, color, height, area, className }: SparklineProps): import("react").JSX.Element;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/patterns/chart/chart.styles.d.ts
|
|
86
|
+
export declare const chartStyles: import("tailwind-variants").TVReturnType<{
|
|
87
|
+
[key: string]: {
|
|
88
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
89
|
+
root?: import("tailwind-variants").ClassValue;
|
|
90
|
+
caption?: import("tailwind-variants").ClassValue;
|
|
91
|
+
title?: import("tailwind-variants").ClassValue;
|
|
92
|
+
description?: import("tailwind-variants").ClassValue;
|
|
93
|
+
plot?: import("tailwind-variants").ClassValue;
|
|
94
|
+
legend?: import("tailwind-variants").ClassValue;
|
|
95
|
+
legendItem?: import("tailwind-variants").ClassValue;
|
|
96
|
+
swatch?: import("tailwind-variants").ClassValue;
|
|
97
|
+
tooltipLabel?: import("tailwind-variants").ClassValue;
|
|
98
|
+
tooltipRow?: import("tailwind-variants").ClassValue;
|
|
99
|
+
tooltipName?: import("tailwind-variants").ClassValue;
|
|
100
|
+
tooltipValue?: import("tailwind-variants").ClassValue;
|
|
101
|
+
center?: import("tailwind-variants").ClassValue;
|
|
102
|
+
srOnly?: import("tailwind-variants").ClassValue;
|
|
103
|
+
tooltip?: import("tailwind-variants").ClassValue;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
[x: string]: {
|
|
108
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
109
|
+
root?: import("tailwind-variants").ClassValue;
|
|
110
|
+
caption?: import("tailwind-variants").ClassValue;
|
|
111
|
+
title?: import("tailwind-variants").ClassValue;
|
|
112
|
+
description?: import("tailwind-variants").ClassValue;
|
|
113
|
+
plot?: import("tailwind-variants").ClassValue;
|
|
114
|
+
legend?: import("tailwind-variants").ClassValue;
|
|
115
|
+
legendItem?: import("tailwind-variants").ClassValue;
|
|
116
|
+
swatch?: import("tailwind-variants").ClassValue;
|
|
117
|
+
tooltipLabel?: import("tailwind-variants").ClassValue;
|
|
118
|
+
tooltipRow?: import("tailwind-variants").ClassValue;
|
|
119
|
+
tooltipName?: import("tailwind-variants").ClassValue;
|
|
120
|
+
tooltipValue?: import("tailwind-variants").ClassValue;
|
|
121
|
+
center?: import("tailwind-variants").ClassValue;
|
|
122
|
+
srOnly?: import("tailwind-variants").ClassValue;
|
|
123
|
+
tooltip?: import("tailwind-variants").ClassValue;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
} | {}, {
|
|
127
|
+
root: string;
|
|
128
|
+
caption: string;
|
|
129
|
+
title: string;
|
|
130
|
+
description: string;
|
|
131
|
+
plot: string;
|
|
132
|
+
legend: string;
|
|
133
|
+
legendItem: string;
|
|
134
|
+
swatch: string;
|
|
135
|
+
tooltip: string[];
|
|
136
|
+
tooltipLabel: string;
|
|
137
|
+
tooltipRow: string;
|
|
138
|
+
tooltipName: string;
|
|
139
|
+
tooltipValue: string;
|
|
140
|
+
center: string;
|
|
141
|
+
srOnly: string;
|
|
142
|
+
}, undefined, {
|
|
143
|
+
[key: string]: {
|
|
144
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
145
|
+
root?: import("tailwind-variants").ClassValue;
|
|
146
|
+
caption?: import("tailwind-variants").ClassValue;
|
|
147
|
+
title?: import("tailwind-variants").ClassValue;
|
|
148
|
+
description?: import("tailwind-variants").ClassValue;
|
|
149
|
+
plot?: import("tailwind-variants").ClassValue;
|
|
150
|
+
legend?: import("tailwind-variants").ClassValue;
|
|
151
|
+
legendItem?: import("tailwind-variants").ClassValue;
|
|
152
|
+
swatch?: import("tailwind-variants").ClassValue;
|
|
153
|
+
tooltipLabel?: import("tailwind-variants").ClassValue;
|
|
154
|
+
tooltipRow?: import("tailwind-variants").ClassValue;
|
|
155
|
+
tooltipName?: import("tailwind-variants").ClassValue;
|
|
156
|
+
tooltipValue?: import("tailwind-variants").ClassValue;
|
|
157
|
+
center?: import("tailwind-variants").ClassValue;
|
|
158
|
+
srOnly?: import("tailwind-variants").ClassValue;
|
|
159
|
+
tooltip?: import("tailwind-variants").ClassValue;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
} | {}, {
|
|
163
|
+
root: string;
|
|
164
|
+
caption: string;
|
|
165
|
+
title: string;
|
|
166
|
+
description: string;
|
|
167
|
+
plot: string;
|
|
168
|
+
legend: string;
|
|
169
|
+
legendItem: string;
|
|
170
|
+
swatch: string;
|
|
171
|
+
tooltip: string[];
|
|
172
|
+
tooltipLabel: string;
|
|
173
|
+
tooltipRow: string;
|
|
174
|
+
tooltipName: string;
|
|
175
|
+
tooltipValue: string;
|
|
176
|
+
center: string;
|
|
177
|
+
srOnly: string;
|
|
178
|
+
}, import("tailwind-variants").TVReturnTypeLike<unknown, {
|
|
179
|
+
root: string;
|
|
180
|
+
caption: string;
|
|
181
|
+
title: string;
|
|
182
|
+
description: string;
|
|
183
|
+
plot: string;
|
|
184
|
+
legend: string;
|
|
185
|
+
legendItem: string;
|
|
186
|
+
swatch: string;
|
|
187
|
+
tooltip: string[];
|
|
188
|
+
tooltipLabel: string;
|
|
189
|
+
tooltipRow: string;
|
|
190
|
+
tooltipName: string;
|
|
191
|
+
tooltipValue: string;
|
|
192
|
+
center: string;
|
|
193
|
+
srOnly: string;
|
|
194
|
+
}>>;
|
|
195
|
+
type ChartVariants = VariantProps<typeof chartStyles>;
|
|
196
|
+
declare module '@glyphui/tokens' {
|
|
197
|
+
interface GlyphComponentRegistry {
|
|
198
|
+
Chart: StylesEntry<typeof chartStyles>;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
export type { CartesianChartProps, ChartColor, ChartSeries, ChartVariants, DonutChartProps, SparklineProps };
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as themedBorder, s as useComponentConfig, t as tv } from "./tv-DBAGlgXJ.js";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import * as R from "recharts";
|
|
6
|
+
//#region src/patterns/chart/chart.styles.ts
|
|
7
|
+
const chartStyles = tv({ slots: {
|
|
8
|
+
root: "m-0 grid min-w-0 gap-3",
|
|
9
|
+
caption: "grid gap-0.5",
|
|
10
|
+
title: "text-small font-medium text-foreground",
|
|
11
|
+
description: "text-caption text-muted-foreground",
|
|
12
|
+
plot: "min-w-0 [&_.recharts-surface]:overflow-visible [&_.recharts-text]:fill-muted-foreground",
|
|
13
|
+
legend: "flex flex-wrap items-center gap-x-4 gap-y-1 text-caption text-muted-foreground",
|
|
14
|
+
legendItem: "inline-flex items-center gap-1.5",
|
|
15
|
+
swatch: "size-2.5 shrink-0 rounded-[2px]",
|
|
16
|
+
tooltip: ["grid min-w-36 gap-1.5 rounded-md border-border bg-raised px-3 py-2 text-caption text-foreground shadow-lg", themedBorder],
|
|
17
|
+
tooltipLabel: "font-medium text-foreground",
|
|
18
|
+
tooltipRow: "flex items-center gap-2",
|
|
19
|
+
tooltipName: "flex-1 text-muted-foreground",
|
|
20
|
+
tooltipValue: "font-mono font-medium tabular-nums text-foreground",
|
|
21
|
+
center: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center",
|
|
22
|
+
srOnly: "sr-only"
|
|
23
|
+
} });
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/patterns/chart/chart-parts.tsx
|
|
26
|
+
const palette = [
|
|
27
|
+
"primary",
|
|
28
|
+
"info",
|
|
29
|
+
"success",
|
|
30
|
+
"warning",
|
|
31
|
+
"danger"
|
|
32
|
+
];
|
|
33
|
+
function resolveColor(color, index) {
|
|
34
|
+
const value = color ?? palette[index % palette.length];
|
|
35
|
+
return /^[a-z-]+$/.test(value) ? `var(--color-${value})` : value;
|
|
36
|
+
}
|
|
37
|
+
const defaultFormatter = (value) => typeof value === "number" ? value.toLocaleString() : String(value);
|
|
38
|
+
function useChartParts() {
|
|
39
|
+
const [, slots] = useComponentConfig("Chart", {});
|
|
40
|
+
return {
|
|
41
|
+
s: chartStyles(),
|
|
42
|
+
slots
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function ChartLegend({ items }) {
|
|
46
|
+
const { s, slots } = useChartParts();
|
|
47
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
48
|
+
"data-slot": "chart-legend",
|
|
49
|
+
className: s.legend({ class: slots.legend }),
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: items.map((item, i) => /* @__PURE__ */ jsxs("li", {
|
|
52
|
+
className: s.legendItem({ class: slots.legendItem }),
|
|
53
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
54
|
+
className: s.swatch({ class: slots.swatch }),
|
|
55
|
+
style: { background: item.color }
|
|
56
|
+
}), item.label]
|
|
57
|
+
}, i))
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function ChartTooltipCard({ active, payload, label, formatter, labelFormatter }) {
|
|
61
|
+
const { s, slots } = useChartParts();
|
|
62
|
+
if (!active || !payload?.length) return null;
|
|
63
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
"data-slot": "chart-tooltip",
|
|
65
|
+
className: s.tooltip({ class: slots.tooltip }),
|
|
66
|
+
children: [label !== void 0 && label !== "" && /* @__PURE__ */ jsx("p", {
|
|
67
|
+
className: s.tooltipLabel({ class: slots.tooltipLabel }),
|
|
68
|
+
children: labelFormatter ? labelFormatter(label) : label
|
|
69
|
+
}), payload.map((item, i) => /* @__PURE__ */ jsxs("div", {
|
|
70
|
+
className: s.tooltipRow({ class: slots.tooltipRow }),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("span", {
|
|
73
|
+
className: s.swatch({ class: slots.swatch }),
|
|
74
|
+
style: { background: item.color ?? item.payload?.fill }
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx("span", {
|
|
77
|
+
className: s.tooltipName({ class: slots.tooltipName }),
|
|
78
|
+
children: String(item.name ?? "")
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx("span", {
|
|
81
|
+
className: s.tooltipValue({ class: slots.tooltipValue }),
|
|
82
|
+
children: formatter(Number(item.value))
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
}, i))]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Wraps every chart in a `<figure>` with a caption and a visually hidden data table,
|
|
90
|
+
* so screen-reader users get the numbers the chart shows.
|
|
91
|
+
*/
|
|
92
|
+
function ChartFrame({ title, description, hideTitle, className, legend, table, children }) {
|
|
93
|
+
const { s, slots } = useChartParts();
|
|
94
|
+
const titleId = useId();
|
|
95
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
96
|
+
"data-slot": "chart",
|
|
97
|
+
"aria-labelledby": titleId,
|
|
98
|
+
className: s.root({ class: [slots.root, className] }),
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("figcaption", {
|
|
101
|
+
className: hideTitle ? s.srOnly() : s.caption({ class: slots.caption }),
|
|
102
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
103
|
+
id: titleId,
|
|
104
|
+
className: s.title({ class: slots.title }),
|
|
105
|
+
children: title
|
|
106
|
+
}), description && /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: s.description({ class: slots.description }),
|
|
108
|
+
children: description
|
|
109
|
+
})]
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("div", {
|
|
112
|
+
className: s.plot({ class: slots.plot }),
|
|
113
|
+
"aria-hidden": "true",
|
|
114
|
+
children
|
|
115
|
+
}),
|
|
116
|
+
legend && legend.length > 1 && /* @__PURE__ */ jsx(ChartLegend, { items: legend }),
|
|
117
|
+
/* @__PURE__ */ jsxs("table", {
|
|
118
|
+
className: s.srOnly(),
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ jsx("caption", { children: title }),
|
|
121
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: table.columns.map((column) => /* @__PURE__ */ jsx("th", {
|
|
122
|
+
scope: "col",
|
|
123
|
+
children: column
|
|
124
|
+
}, column)) }) }),
|
|
125
|
+
/* @__PURE__ */ jsx("tbody", { children: table.rows.map((row, i) => /* @__PURE__ */ jsx("tr", { children: row.map((cell, j) => j === 0 ? /* @__PURE__ */ jsx("th", {
|
|
126
|
+
scope: "row",
|
|
127
|
+
children: cell
|
|
128
|
+
}, j) : /* @__PURE__ */ jsx("td", { children: cell }, j)) }, i)) })
|
|
129
|
+
]
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/patterns/chart/chart.tsx
|
|
136
|
+
const axisTick = {
|
|
137
|
+
fill: "var(--color-muted-foreground)",
|
|
138
|
+
fontSize: 12
|
|
139
|
+
};
|
|
140
|
+
function useCartesian(props) {
|
|
141
|
+
const { data, index, series, title, valueFormatter = defaultFormatter } = props;
|
|
142
|
+
const resolved = series.map((item, i) => ({
|
|
143
|
+
...item,
|
|
144
|
+
label: item.label ?? item.key,
|
|
145
|
+
stroke: resolveColor(item.color, i)
|
|
146
|
+
}));
|
|
147
|
+
return {
|
|
148
|
+
resolved,
|
|
149
|
+
table: {
|
|
150
|
+
columns: [String(index), ...resolved.map((item) => item.label)],
|
|
151
|
+
rows: data.map((row) => [String(row[index]), ...resolved.map((item) => valueFormatter(Number(row[item.key])))])
|
|
152
|
+
},
|
|
153
|
+
legend: props.showLegend ?? series.length > 1 ? resolved.map((item) => ({
|
|
154
|
+
label: item.label,
|
|
155
|
+
color: item.stroke
|
|
156
|
+
})) : void 0,
|
|
157
|
+
valueFormatter,
|
|
158
|
+
title
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function frameProps(props) {
|
|
162
|
+
return {
|
|
163
|
+
title: props.title,
|
|
164
|
+
description: props.description,
|
|
165
|
+
hideTitle: props.hideTitle,
|
|
166
|
+
className: props.className
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function Axes({ index, showGrid = true, showYAxis = true, valueFormatter }) {
|
|
170
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
171
|
+
showGrid && /* @__PURE__ */ jsx(R.CartesianGrid, {
|
|
172
|
+
vertical: false,
|
|
173
|
+
stroke: "var(--color-border)",
|
|
174
|
+
strokeDasharray: "3 3"
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx(R.XAxis, {
|
|
177
|
+
dataKey: index,
|
|
178
|
+
tick: axisTick,
|
|
179
|
+
tickLine: false,
|
|
180
|
+
axisLine: false,
|
|
181
|
+
tickMargin: 8,
|
|
182
|
+
minTickGap: 16
|
|
183
|
+
}),
|
|
184
|
+
showYAxis && /* @__PURE__ */ jsx(R.YAxis, {
|
|
185
|
+
tick: axisTick,
|
|
186
|
+
tickLine: false,
|
|
187
|
+
axisLine: false,
|
|
188
|
+
width: 48,
|
|
189
|
+
tickFormatter: valueFormatter
|
|
190
|
+
})
|
|
191
|
+
] });
|
|
192
|
+
}
|
|
193
|
+
function tooltip(valueFormatter, cursor) {
|
|
194
|
+
return /* @__PURE__ */ jsx(R.Tooltip, {
|
|
195
|
+
cursor,
|
|
196
|
+
content: (p) => /* @__PURE__ */ jsx(ChartTooltipCard, {
|
|
197
|
+
active: p.active,
|
|
198
|
+
payload: p.payload,
|
|
199
|
+
label: p.label,
|
|
200
|
+
formatter: valueFormatter
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/** Trends over time, one line per series. */
|
|
205
|
+
function LineChart(props) {
|
|
206
|
+
const { resolved, table, legend, valueFormatter } = useCartesian(props);
|
|
207
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
208
|
+
...frameProps(props),
|
|
209
|
+
legend,
|
|
210
|
+
table,
|
|
211
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
212
|
+
width: "100%",
|
|
213
|
+
height: props.height ?? 240,
|
|
214
|
+
children: /* @__PURE__ */ jsxs(R.LineChart, {
|
|
215
|
+
data: props.data,
|
|
216
|
+
margin: {
|
|
217
|
+
top: 8,
|
|
218
|
+
right: 8,
|
|
219
|
+
bottom: 0,
|
|
220
|
+
left: 0
|
|
221
|
+
},
|
|
222
|
+
children: [
|
|
223
|
+
/* @__PURE__ */ jsx(Axes, {
|
|
224
|
+
index: props.index,
|
|
225
|
+
showGrid: props.showGrid,
|
|
226
|
+
showYAxis: props.showYAxis,
|
|
227
|
+
valueFormatter
|
|
228
|
+
}),
|
|
229
|
+
tooltip(valueFormatter, { stroke: "var(--color-border-strong)" }),
|
|
230
|
+
resolved.map((item) => /* @__PURE__ */ jsx(R.Line, {
|
|
231
|
+
dataKey: item.key,
|
|
232
|
+
name: item.label,
|
|
233
|
+
type: props.curve ?? "monotone",
|
|
234
|
+
stroke: item.stroke,
|
|
235
|
+
strokeWidth: 2,
|
|
236
|
+
dot: false,
|
|
237
|
+
activeDot: {
|
|
238
|
+
r: 4,
|
|
239
|
+
strokeWidth: 0
|
|
240
|
+
},
|
|
241
|
+
isAnimationActive: false
|
|
242
|
+
}, item.key))
|
|
243
|
+
]
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/** Trends with filled areas. `stacked` shows how series add up to a total. */
|
|
249
|
+
function AreaChart(props) {
|
|
250
|
+
const { resolved, table, legend, valueFormatter } = useCartesian(props);
|
|
251
|
+
const id = useId().replace(/:/g, "");
|
|
252
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
253
|
+
...frameProps(props),
|
|
254
|
+
legend,
|
|
255
|
+
table,
|
|
256
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
257
|
+
width: "100%",
|
|
258
|
+
height: props.height ?? 240,
|
|
259
|
+
children: /* @__PURE__ */ jsxs(R.AreaChart, {
|
|
260
|
+
data: props.data,
|
|
261
|
+
margin: {
|
|
262
|
+
top: 8,
|
|
263
|
+
right: 8,
|
|
264
|
+
bottom: 0,
|
|
265
|
+
left: 0
|
|
266
|
+
},
|
|
267
|
+
children: [
|
|
268
|
+
/* @__PURE__ */ jsx("defs", { children: resolved.map((item, i) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
269
|
+
id: `${id}-${i}`,
|
|
270
|
+
x1: "0",
|
|
271
|
+
x2: "0",
|
|
272
|
+
y1: "0",
|
|
273
|
+
y2: "1",
|
|
274
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
275
|
+
offset: "0%",
|
|
276
|
+
stopColor: item.stroke,
|
|
277
|
+
stopOpacity: .3
|
|
278
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
279
|
+
offset: "100%",
|
|
280
|
+
stopColor: item.stroke,
|
|
281
|
+
stopOpacity: 0
|
|
282
|
+
})]
|
|
283
|
+
}, item.key)) }),
|
|
284
|
+
/* @__PURE__ */ jsx(Axes, {
|
|
285
|
+
index: props.index,
|
|
286
|
+
showGrid: props.showGrid,
|
|
287
|
+
showYAxis: props.showYAxis,
|
|
288
|
+
valueFormatter
|
|
289
|
+
}),
|
|
290
|
+
tooltip(valueFormatter, { stroke: "var(--color-border-strong)" }),
|
|
291
|
+
resolved.map((item, i) => /* @__PURE__ */ jsx(R.Area, {
|
|
292
|
+
dataKey: item.key,
|
|
293
|
+
name: item.label,
|
|
294
|
+
type: "monotone",
|
|
295
|
+
stroke: item.stroke,
|
|
296
|
+
strokeWidth: 2,
|
|
297
|
+
fill: `url(#${id}-${i})`,
|
|
298
|
+
...props.stacked && { stackId: "stack" },
|
|
299
|
+
isAnimationActive: false
|
|
300
|
+
}, item.key))
|
|
301
|
+
]
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** Compare values across categories. `stacked` puts series on top of each other. */
|
|
307
|
+
function BarChart(props) {
|
|
308
|
+
const { resolved, table, legend, valueFormatter } = useCartesian(props);
|
|
309
|
+
const radius = props.barRadius ?? 3;
|
|
310
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
311
|
+
...frameProps(props),
|
|
312
|
+
legend,
|
|
313
|
+
table,
|
|
314
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
315
|
+
width: "100%",
|
|
316
|
+
height: props.height ?? 240,
|
|
317
|
+
children: /* @__PURE__ */ jsxs(R.BarChart, {
|
|
318
|
+
data: props.data,
|
|
319
|
+
margin: {
|
|
320
|
+
top: 8,
|
|
321
|
+
right: 8,
|
|
322
|
+
bottom: 0,
|
|
323
|
+
left: 0
|
|
324
|
+
},
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ jsx(Axes, {
|
|
327
|
+
index: props.index,
|
|
328
|
+
showGrid: props.showGrid,
|
|
329
|
+
showYAxis: props.showYAxis,
|
|
330
|
+
valueFormatter
|
|
331
|
+
}),
|
|
332
|
+
tooltip(valueFormatter, {
|
|
333
|
+
fill: "var(--color-muted)",
|
|
334
|
+
opacity: .6
|
|
335
|
+
}),
|
|
336
|
+
resolved.map((item, i) => /* @__PURE__ */ jsx(R.Bar, {
|
|
337
|
+
dataKey: item.key,
|
|
338
|
+
name: item.label,
|
|
339
|
+
fill: item.stroke,
|
|
340
|
+
radius: props.stacked && i < resolved.length - 1 ? 0 : [
|
|
341
|
+
radius,
|
|
342
|
+
radius,
|
|
343
|
+
0,
|
|
344
|
+
0
|
|
345
|
+
],
|
|
346
|
+
...props.stacked && { stackId: "stack" },
|
|
347
|
+
isAnimationActive: false
|
|
348
|
+
}, item.key))
|
|
349
|
+
]
|
|
350
|
+
})
|
|
351
|
+
})
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/** Parts of a whole. Best with five or fewer slices. */
|
|
355
|
+
function DonutChart(props) {
|
|
356
|
+
const { data, category, value, valueFormatter = defaultFormatter, size = 200 } = props;
|
|
357
|
+
const { s, slots } = useChartParts();
|
|
358
|
+
const rows = data.map((row) => row);
|
|
359
|
+
const colors = rows.map((_, i) => resolveColor(props.colors?.[i], i));
|
|
360
|
+
const table = {
|
|
361
|
+
columns: [String(category), String(value)],
|
|
362
|
+
rows: rows.map((row) => [String(row[category]), valueFormatter(Number(row[value]))])
|
|
363
|
+
};
|
|
364
|
+
const legend = props.showLegend ?? true ? rows.map((row, i) => ({
|
|
365
|
+
label: String(row[category]),
|
|
366
|
+
color: colors[i]
|
|
367
|
+
})) : void 0;
|
|
368
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
369
|
+
title: props.title,
|
|
370
|
+
description: props.description,
|
|
371
|
+
hideTitle: props.hideTitle,
|
|
372
|
+
className: props.className,
|
|
373
|
+
legend,
|
|
374
|
+
table,
|
|
375
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
376
|
+
className: "relative mx-auto",
|
|
377
|
+
style: {
|
|
378
|
+
width: size,
|
|
379
|
+
height: size
|
|
380
|
+
},
|
|
381
|
+
children: [/* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
382
|
+
width: "100%",
|
|
383
|
+
height: "100%",
|
|
384
|
+
children: /* @__PURE__ */ jsxs(R.PieChart, { children: [tooltip(valueFormatter, false), /* @__PURE__ */ jsx(R.Pie, {
|
|
385
|
+
data: rows,
|
|
386
|
+
dataKey: value,
|
|
387
|
+
nameKey: category,
|
|
388
|
+
innerRadius: "68%",
|
|
389
|
+
outerRadius: "100%",
|
|
390
|
+
paddingAngle: 2,
|
|
391
|
+
stroke: "var(--color-surface)",
|
|
392
|
+
strokeWidth: 2,
|
|
393
|
+
isAnimationActive: false,
|
|
394
|
+
children: rows.map((_, i) => /* @__PURE__ */ jsx(R.Cell, { fill: colors[i] }, i))
|
|
395
|
+
})] })
|
|
396
|
+
}), props.centerLabel && /* @__PURE__ */ jsx("div", {
|
|
397
|
+
className: s.center({ class: slots.center }),
|
|
398
|
+
children: props.centerLabel
|
|
399
|
+
})]
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
/** A tiny trend line without axes, for stat cards and table cells. */
|
|
404
|
+
function Sparkline({ values, title, color, height = 36, area = true, className }) {
|
|
405
|
+
const id = useId().replace(/:/g, "");
|
|
406
|
+
const stroke = resolveColor(color, 0);
|
|
407
|
+
const data = values.map((v, i) => ({
|
|
408
|
+
i,
|
|
409
|
+
v
|
|
410
|
+
}));
|
|
411
|
+
return /* @__PURE__ */ jsx("div", {
|
|
412
|
+
role: "img",
|
|
413
|
+
"aria-label": title,
|
|
414
|
+
"data-slot": "sparkline",
|
|
415
|
+
className,
|
|
416
|
+
style: { height },
|
|
417
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
418
|
+
width: "100%",
|
|
419
|
+
height: "100%",
|
|
420
|
+
children: /* @__PURE__ */ jsxs(R.AreaChart, {
|
|
421
|
+
data,
|
|
422
|
+
margin: {
|
|
423
|
+
top: 2,
|
|
424
|
+
right: 2,
|
|
425
|
+
bottom: 2,
|
|
426
|
+
left: 2
|
|
427
|
+
},
|
|
428
|
+
children: [/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
429
|
+
id,
|
|
430
|
+
x1: "0",
|
|
431
|
+
x2: "0",
|
|
432
|
+
y1: "0",
|
|
433
|
+
y2: "1",
|
|
434
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
435
|
+
offset: "0%",
|
|
436
|
+
stopColor: stroke,
|
|
437
|
+
stopOpacity: area ? .25 : 0
|
|
438
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
439
|
+
offset: "100%",
|
|
440
|
+
stopColor: stroke,
|
|
441
|
+
stopOpacity: 0
|
|
442
|
+
})]
|
|
443
|
+
}) }), /* @__PURE__ */ jsx(R.Area, {
|
|
444
|
+
dataKey: "v",
|
|
445
|
+
type: "monotone",
|
|
446
|
+
stroke,
|
|
447
|
+
strokeWidth: 1.75,
|
|
448
|
+
fill: `url(#${id})`,
|
|
449
|
+
isAnimationActive: false,
|
|
450
|
+
dot: false
|
|
451
|
+
})]
|
|
452
|
+
})
|
|
453
|
+
})
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
export { AreaChart, BarChart, DonutChart, LineChart, Sparkline, chartStyles };
|
package/dist/data-table.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as themedBorder, r as focusRing, s as useComponentConfig, t as tv } from "./tv-DBAGlgXJ.js";
|
|
3
|
+
import { b as SearchIcon, h as ChevronsUpDownIcon, i as IconButton, l as ArrowDownIcon, m as ChevronRightIcon, p as ChevronLeftIcon, r as Button, u as ArrowUpIcon } from "./field-context-anGPYXbW.js";
|
|
4
|
+
import { a as Table, c as TableCell, d as TableRow, h as Input, l as TableHead, n as ErrorState, o as TableBody, p as Skeleton, t as EmptyState, u as TableHeader, v as Checkbox } from "./states-DR-OoDT-.js";
|
|
4
5
|
import { useEffect, useMemo, useState } from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { createColumnHelper, flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { s as useComponentConfig, t as tv } from "./tv-DBAGlgXJ.js";
|
|
3
|
+
import { t as FieldContext } from "./field-context-anGPYXbW.js";
|
|
3
4
|
import { Label } from "radix-ui";
|
|
4
5
|
import { useId, useMemo } from "react";
|
|
5
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|