@giddaa-housing/ui 1.1.0 → 1.2.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/css/generated/shared.css +1 -1
- package/css/giddaa.css +12 -2
- package/dist/bullet-chart.d.ts +8 -4
- package/dist/bullet-chart.js +10 -6
- package/dist/button.js +1 -1
- package/dist/card.js +1 -1
- package/dist/chart.d.ts +33 -5
- package/dist/chart.js +210 -13
- package/dist/checkbox.js +1 -1
- package/dist/data-table.d.ts +7 -3
- package/dist/data-table.js +8 -5
- package/dist/funnel-chart.d.ts +11 -7
- package/dist/funnel-chart.js +11 -8
- package/dist/input-group.js +1 -1
- package/dist/input.js +1 -1
- package/dist/line-chart.d.ts +113 -41
- package/dist/line-chart.js +217 -30
- package/dist/list-item.d.ts +22 -0
- package/dist/list-item.js +84 -0
- package/dist/number-input.js +20 -17
- package/dist/pie-chart.d.ts +83 -52
- package/dist/pie-chart.js +85 -43
- package/dist/purchase-option-card.d.ts +79 -0
- package/dist/purchase-option-card.js +176 -0
- package/dist/radio-group.js +1 -1
- package/dist/select.js +1 -1
- package/dist/sparkline.d.ts +28 -15
- package/dist/sparkline.js +131 -37
- package/dist/styles.css +529 -43
- package/dist/switch.js +1 -1
- package/dist/table.js +6 -2
- package/dist/tabs.d.ts +11 -1
- package/dist/tabs.js +43 -4
- package/dist/textarea.js +1 -1
- package/dist/tree-map.d.ts +14 -14
- package/dist/tree-map.js +14 -15
- package/package.json +9 -1
package/dist/line-chart.d.ts
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
import { t as ComponentSize } from "./size-context-D4mYvcg8.js";
|
|
2
|
+
import { ChartConfig } from "./chart.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Area, AreaChart as AreaChart$1, CartesianGrid, Line, LineChart as LineChart$1, XAxis, YAxis } from "recharts";
|
|
2
5
|
//#region src/line-chart.d.ts
|
|
3
6
|
/**
|
|
4
|
-
* Line charts are
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Line and area charts are composable wrappers over the recharts cartesian
|
|
8
|
+
* primitives. recharts 3 registers graphical items through context when they
|
|
9
|
+
* render, so the primitives CAN be wrapped in our own components. Each wrapper
|
|
10
|
+
* bakes in the giddaa defaults (tokens, size-scaled type, mark specs) and
|
|
11
|
+
* forwards every recharts prop, so anything can be overridden in place or
|
|
12
|
+
* replaced with the raw recharts element.
|
|
9
13
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
14
|
-
* Tokens:
|
|
15
|
-
* - Primary series stroke + dots + area fill: `var(--color-surface-brand)`
|
|
16
|
-
* - Comparison series: `var(--color-surface-accent)`
|
|
17
|
-
* - Gridlines: `var(--color-line-subtle)`
|
|
18
|
-
* - Area wash: primary series colour at 15 % opacity (`fillOpacity={0.15}`)
|
|
19
|
-
* - Active-dot ring: `var(--color-surface-raised)` stroke (matches card bg)
|
|
14
|
+
* Anatomy: `LineChart`/`AreaChart` are the plot roots (frame + responsive box +
|
|
15
|
+
* recharts chart); compose the grid, axes, series, and the shared overlays from
|
|
16
|
+
* `./chart` as children. Both roots share the same axis and grid wrappers.
|
|
20
17
|
*
|
|
21
18
|
* @example
|
|
22
|
-
* const chart = useLineChartLayout();
|
|
23
19
|
* <ChartCard size="md">
|
|
24
20
|
* <ChartHeader>
|
|
25
21
|
* <ChartTitle>Revenue Overview</ChartTitle>
|
|
26
22
|
* <ChartDescription>Monthly revenue · Jan–Jul</ChartDescription>
|
|
27
23
|
* </ChartHeader>
|
|
28
|
-
* <
|
|
29
|
-
* <
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* <Area dataKey="revenue" {...chart.area("var(--color-revenue)")} />
|
|
36
|
-
* </AreaChart>
|
|
37
|
-
* </ChartContainer>
|
|
24
|
+
* <AreaChart config={config} data={data}>
|
|
25
|
+
* <LineChartGrid />
|
|
26
|
+
* <LineChartXAxis dataKey="month" />
|
|
27
|
+
* <LineChartYAxis />
|
|
28
|
+
* <ChartTooltip content={<ChartTooltipContent />} />
|
|
29
|
+
* <AreaChartSeries dataKey="revenue" name="Revenue" />
|
|
30
|
+
* </AreaChart>
|
|
38
31
|
* </ChartCard>
|
|
39
32
|
*/
|
|
40
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Categorical series palette — the theme-aware `chart-1`…`chart-3` tokens.
|
|
35
|
+
* Assign colours in this fixed order, never cycled: a fourth series folds into
|
|
36
|
+
* "Other" or becomes a second chart.
|
|
37
|
+
*/
|
|
38
|
+
declare const LINE_CHART_PALETTE: readonly ["var(--color-chart-1)", "var(--color-chart-2)", "var(--color-chart-3)"];
|
|
39
|
+
/**
|
|
40
|
+
* Five sizes for line/area charts — extends the three shared `ComponentSize`
|
|
41
|
+
* values with `xl` and `huge` for hero trend panels. `xl`/`huge` scale the plot
|
|
42
|
+
* height and margins on the *root only*; the child series and axes resolve to
|
|
43
|
+
* `lg` marks (identical from `lg` up), so they never need the extended union.
|
|
44
|
+
*/
|
|
41
45
|
type LineChartSize = "sm" | "md" | "lg" | "xl" | "huge";
|
|
42
46
|
type LineChartLayout = {
|
|
43
47
|
/** Plot height in px. Width stays fluid via ResponsiveContainer. */
|
|
@@ -63,21 +67,89 @@ type LineChartLayout = {
|
|
|
63
67
|
tickMargin: number;
|
|
64
68
|
};
|
|
65
69
|
declare const LINE_CHART_LAYOUT: Record<LineChartSize, LineChartLayout>;
|
|
66
|
-
/**
|
|
70
|
+
/** Clamp the 5 line-chart sizes to the 3 `ComponentSize` values for children. */
|
|
67
71
|
declare function toComponentSize(size: LineChartSize): ComponentSize;
|
|
72
|
+
/** Shared root knobs — series theming, plot scale, and the plot-box className. */
|
|
73
|
+
type LineChartRootExtras = {
|
|
74
|
+
/** Series labels/icons for the shared tooltip and legend (see `ChartConfig`). */
|
|
75
|
+
config?: ChartConfig;
|
|
76
|
+
/** Plot scale; inherited from the nearest `SizeProvider` when omitted. */
|
|
77
|
+
size?: LineChartSize;
|
|
78
|
+
/** Applied to the responsive plot box, e.g. to override its height. */
|
|
79
|
+
className?: string;
|
|
80
|
+
};
|
|
81
|
+
type LineChartProps = Omit<React.ComponentProps<typeof LineChart$1>, "width" | "height"> & LineChartRootExtras;
|
|
82
|
+
type AreaChartProps = Omit<React.ComponentProps<typeof AreaChart$1>, "width" | "height"> & LineChartRootExtras;
|
|
68
83
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
* Plot root — wraps the shared `ChartContainer` (tooltip/legend theming,
|
|
85
|
+
* responsive box) around the recharts `LineChart` with a size-scaled height and
|
|
86
|
+
* margin. `size` flows to the child primitives through `SizeProvider` (clamped
|
|
87
|
+
* to `lg` for `xl`/`huge`). Extra props reach the recharts chart (`data`,
|
|
88
|
+
* `syncId`, …).
|
|
89
|
+
*/
|
|
90
|
+
declare function LineChart({ config, size, className, children, ...props }: LineChartProps): React.JSX.Element;
|
|
91
|
+
/**
|
|
92
|
+
* Plot root for filled trends — identical to `LineChart` but wraps the recharts
|
|
93
|
+
* `AreaChart`, so it hosts `AreaChartSeries` (and the same grid/axes/overlays).
|
|
94
|
+
*/
|
|
95
|
+
declare function AreaChart({ config, size, className, children, ...props }: AreaChartProps): React.JSX.Element;
|
|
96
|
+
type LineChartGridProps = React.ComponentProps<typeof CartesianGrid>;
|
|
97
|
+
/**
|
|
98
|
+
* Value reference lines — recharts `CartesianGrid` with vertical lines hidden
|
|
99
|
+
* and the visible grid painted with the `line` token (`line-subtle` matches the
|
|
100
|
+
* chart card surface in both themes, so it would vanish).
|
|
101
|
+
*/
|
|
102
|
+
declare function LineChartGrid(props: LineChartGridProps): React.JSX.Element;
|
|
103
|
+
type LineChartXAxisProps = React.ComponentProps<typeof XAxis> & {
|
|
104
|
+
/** Explicit axis scale; otherwise inherited from the chart's `size`. */
|
|
105
|
+
size?: LineChartSize;
|
|
106
|
+
};
|
|
107
|
+
type LineChartYAxisProps = React.ComponentProps<typeof YAxis> & {
|
|
108
|
+
/** Explicit axis scale; otherwise inherited from the chart's `size`. */
|
|
109
|
+
size?: LineChartSize;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Category (time) axis — recharts `XAxis` with no axis/tick lines, a size-scaled
|
|
113
|
+
* tick margin, and caption-placeholder tick ink. Passing your own `tick`
|
|
114
|
+
* replaces the default styling entirely.
|
|
115
|
+
*/
|
|
116
|
+
declare function LineChartXAxis({ size, tick, ...props }: LineChartXAxisProps): React.JSX.Element;
|
|
117
|
+
/**
|
|
118
|
+
* Value axis — recharts `YAxis` with no axis/tick lines, size-scaled tick type,
|
|
119
|
+
* and reserved width for value labels. Override `width` for long labels.
|
|
120
|
+
*/
|
|
121
|
+
declare function LineChartYAxis({ size, tick, ...props }: LineChartYAxisProps): React.JSX.Element;
|
|
122
|
+
type LineChartSeriesProps = React.ComponentProps<typeof Line> & {
|
|
123
|
+
/** Series colour for the stroke and dots. Defaults to the first chart token. */
|
|
124
|
+
color?: string;
|
|
125
|
+
/** Explicit mark scale; otherwise inherited from the chart's `size`. */
|
|
126
|
+
size?: LineChartSize;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* One line series — recharts `Line` with the giddaa mark spec: a 2px rounded
|
|
130
|
+
* stroke in `color`, solid resting dots, and a hover dot ringed in
|
|
131
|
+
* `surface-raised` so overlapping series stay separable. `color` drives all of
|
|
132
|
+
* them at once; `stroke`/`dot`/`activeDot` still win when passed directly.
|
|
133
|
+
*/
|
|
134
|
+
declare function LineChartSeries({ color, size, dot, activeDot, ...props }: LineChartSeriesProps): React.JSX.Element;
|
|
135
|
+
type AreaChartSeriesProps = React.ComponentProps<typeof Area> & {
|
|
136
|
+
/** Series colour for the stroke, wash, and dots. Defaults to the first chart token. */
|
|
137
|
+
color?: string;
|
|
138
|
+
/** Explicit mark scale; otherwise inherited from the chart's `size`. */
|
|
139
|
+
size?: LineChartSize;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* One area series — recharts `Area` with the giddaa mark spec: the same rounded
|
|
143
|
+
* 2px stroke and dots as `LineChartSeries`, plus the series colour washed to 15%
|
|
144
|
+
* beneath the stroke. `color` drives stroke + fill + dots at once;
|
|
145
|
+
* `stroke`/`fill`/`dot` still win when passed directly.
|
|
146
|
+
*/
|
|
147
|
+
declare function AreaChartSeries({ color, size, dot, activeDot, ...props }: AreaChartSeriesProps): React.JSX.Element;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated Compose the `<LineChart>`/`<AreaChart>` primitives instead — see
|
|
150
|
+
* the module example. This layout hook predates recharts 3 wrapping support and
|
|
151
|
+
* will be removed in the next major. It returns prop bags to spread onto raw
|
|
152
|
+
* recharts elements.
|
|
81
153
|
*/
|
|
82
154
|
declare function useLineChartLayout(size?: LineChartSize): {
|
|
83
155
|
container: {
|
|
@@ -151,4 +223,4 @@ declare function useLineChartLayout(size?: LineChartSize): {
|
|
|
151
223
|
};
|
|
152
224
|
};
|
|
153
225
|
//#endregion
|
|
154
|
-
export { LINE_CHART_LAYOUT, type LineChartLayout, type LineChartSize, toComponentSize, useLineChartLayout };
|
|
226
|
+
export { AreaChart, type AreaChartProps, AreaChartSeries, type AreaChartSeriesProps, LINE_CHART_LAYOUT, LINE_CHART_PALETTE, LineChart, LineChartGrid, type LineChartGridProps, type LineChartLayout, type LineChartProps, LineChartSeries, type LineChartSeriesProps, type LineChartSize, LineChartXAxis, type LineChartXAxisProps, LineChartYAxis, type LineChartYAxisProps, toComponentSize, useLineChartLayout };
|
package/dist/line-chart.js
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { SizeProvider, useComponentSize } from "./size-context.js";
|
|
4
|
+
import { ChartContainer, cartesianAxisProps } from "./chart.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Area, AreaChart as AreaChart$1, CartesianGrid, Line, LineChart as LineChart$1, XAxis, YAxis } from "recharts";
|
|
4
7
|
//#region src/line-chart.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Line and area charts are composable wrappers over the recharts cartesian
|
|
10
|
+
* primitives. recharts 3 registers graphical items through context when they
|
|
11
|
+
* render, so the primitives CAN be wrapped in our own components. Each wrapper
|
|
12
|
+
* bakes in the giddaa defaults (tokens, size-scaled type, mark specs) and
|
|
13
|
+
* forwards every recharts prop, so anything can be overridden in place or
|
|
14
|
+
* replaced with the raw recharts element.
|
|
15
|
+
*
|
|
16
|
+
* Anatomy: `LineChart`/`AreaChart` are the plot roots (frame + responsive box +
|
|
17
|
+
* recharts chart); compose the grid, axes, series, and the shared overlays from
|
|
18
|
+
* `./chart` as children. Both roots share the same axis and grid wrappers.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <ChartCard size="md">
|
|
22
|
+
* <ChartHeader>
|
|
23
|
+
* <ChartTitle>Revenue Overview</ChartTitle>
|
|
24
|
+
* <ChartDescription>Monthly revenue · Jan–Jul</ChartDescription>
|
|
25
|
+
* </ChartHeader>
|
|
26
|
+
* <AreaChart config={config} data={data}>
|
|
27
|
+
* <LineChartGrid />
|
|
28
|
+
* <LineChartXAxis dataKey="month" />
|
|
29
|
+
* <LineChartYAxis />
|
|
30
|
+
* <ChartTooltip content={<ChartTooltipContent />} />
|
|
31
|
+
* <AreaChartSeries dataKey="revenue" name="Revenue" />
|
|
32
|
+
* </AreaChart>
|
|
33
|
+
* </ChartCard>
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Categorical series palette — the theme-aware `chart-1`…`chart-3` tokens.
|
|
37
|
+
* Assign colours in this fixed order, never cycled: a fourth series folds into
|
|
38
|
+
* "Other" or becomes a second chart.
|
|
39
|
+
*/
|
|
40
|
+
const LINE_CHART_PALETTE = [
|
|
41
|
+
"var(--color-chart-1)",
|
|
42
|
+
"var(--color-chart-2)",
|
|
43
|
+
"var(--color-chart-3)"
|
|
44
|
+
];
|
|
45
|
+
const DEFAULT_SERIES_COLOR = LINE_CHART_PALETTE[0];
|
|
5
46
|
const LINE_CHART_LAYOUT = {
|
|
6
47
|
sm: {
|
|
7
48
|
height: 64,
|
|
@@ -57,8 +98,8 @@ const LINE_CHART_LAYOUT = {
|
|
|
57
98
|
left: 0
|
|
58
99
|
},
|
|
59
100
|
strokeWidth: 2,
|
|
60
|
-
dotRadius:
|
|
61
|
-
activeDotRadius: 5
|
|
101
|
+
dotRadius: 3.5,
|
|
102
|
+
activeDotRadius: 5,
|
|
62
103
|
tickFontSize: 11,
|
|
63
104
|
yAxisWidth: 28,
|
|
64
105
|
tickMargin: 6
|
|
@@ -72,30 +113,143 @@ const LINE_CHART_LAYOUT = {
|
|
|
72
113
|
left: 0
|
|
73
114
|
},
|
|
74
115
|
strokeWidth: 2,
|
|
75
|
-
dotRadius:
|
|
76
|
-
activeDotRadius:
|
|
116
|
+
dotRadius: 3.5,
|
|
117
|
+
activeDotRadius: 5,
|
|
77
118
|
tickFontSize: 12,
|
|
78
119
|
yAxisWidth: 30,
|
|
79
120
|
tickMargin: 7
|
|
80
121
|
}
|
|
81
122
|
};
|
|
82
|
-
/**
|
|
123
|
+
/** Clamp the 5 line-chart sizes to the 3 `ComponentSize` values for children. */
|
|
83
124
|
function toComponentSize(size) {
|
|
84
125
|
if (size === "xl" || size === "huge") return "lg";
|
|
85
126
|
return size;
|
|
86
127
|
}
|
|
128
|
+
/** Resolve the layout for an explicit or inherited line-chart size. */
|
|
129
|
+
function useLineChartSize(size) {
|
|
130
|
+
const inherited = useComponentSize();
|
|
131
|
+
const resolved = size ?? inherited;
|
|
132
|
+
return {
|
|
133
|
+
size: resolved,
|
|
134
|
+
layout: LINE_CHART_LAYOUT[resolved] ?? LINE_CHART_LAYOUT.md
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Plot root — wraps the shared `ChartContainer` (tooltip/legend theming,
|
|
139
|
+
* responsive box) around the recharts `LineChart` with a size-scaled height and
|
|
140
|
+
* margin. `size` flows to the child primitives through `SizeProvider` (clamped
|
|
141
|
+
* to `lg` for `xl`/`huge`). Extra props reach the recharts chart (`data`,
|
|
142
|
+
* `syncId`, …).
|
|
143
|
+
*/
|
|
144
|
+
function LineChart({ config = {}, size, className, children, ...props }) {
|
|
145
|
+
const { size: resolved, layout } = useLineChartSize(size);
|
|
146
|
+
return /* @__PURE__ */ jsx(SizeProvider, {
|
|
147
|
+
size: toComponentSize(resolved),
|
|
148
|
+
children: /* @__PURE__ */ jsx(ChartContainer, {
|
|
149
|
+
config,
|
|
150
|
+
className: cn("aspect-auto w-full", className),
|
|
151
|
+
style: { height: layout.height },
|
|
152
|
+
children: /* @__PURE__ */ jsx(LineChart$1, {
|
|
153
|
+
accessibilityLayer: true,
|
|
154
|
+
margin: layout.margin,
|
|
155
|
+
...props,
|
|
156
|
+
children
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Plot root for filled trends — identical to `LineChart` but wraps the recharts
|
|
163
|
+
* `AreaChart`, so it hosts `AreaChartSeries` (and the same grid/axes/overlays).
|
|
164
|
+
*/
|
|
165
|
+
function AreaChart({ config = {}, size, className, children, ...props }) {
|
|
166
|
+
const { size: resolved, layout } = useLineChartSize(size);
|
|
167
|
+
return /* @__PURE__ */ jsx(SizeProvider, {
|
|
168
|
+
size: toComponentSize(resolved),
|
|
169
|
+
children: /* @__PURE__ */ jsx(ChartContainer, {
|
|
170
|
+
config,
|
|
171
|
+
className: cn("aspect-auto w-full", className),
|
|
172
|
+
style: { height: layout.height },
|
|
173
|
+
children: /* @__PURE__ */ jsx(AreaChart$1, {
|
|
174
|
+
accessibilityLayer: true,
|
|
175
|
+
margin: layout.margin,
|
|
176
|
+
...props,
|
|
177
|
+
children
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Value reference lines — recharts `CartesianGrid` with vertical lines hidden
|
|
184
|
+
* and the visible grid painted with the `line` token (`line-subtle` matches the
|
|
185
|
+
* chart card surface in both themes, so it would vanish).
|
|
186
|
+
*/
|
|
187
|
+
function LineChartGrid(props) {
|
|
188
|
+
return /* @__PURE__ */ jsx(CartesianGrid, {
|
|
189
|
+
vertical: false,
|
|
190
|
+
stroke: "var(--color-line)",
|
|
191
|
+
...props
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Category (time) axis — recharts `XAxis` with no axis/tick lines, a size-scaled
|
|
196
|
+
* tick margin, and caption-placeholder tick ink. Passing your own `tick`
|
|
197
|
+
* replaces the default styling entirely.
|
|
198
|
+
*/
|
|
199
|
+
function LineChartXAxis({ size, tick, ...props }) {
|
|
200
|
+
const { layout } = useLineChartSize(size);
|
|
201
|
+
const axes = cartesianAxisProps({
|
|
202
|
+
tickMargin: layout.tickMargin,
|
|
203
|
+
tickFontSize: layout.tickFontSize,
|
|
204
|
+
yAxisWidth: layout.yAxisWidth
|
|
205
|
+
});
|
|
206
|
+
const defaultTick = {
|
|
207
|
+
...axes.xAxis.tick,
|
|
208
|
+
fill: "var(--color-fg-caption-placeholder)"
|
|
209
|
+
};
|
|
210
|
+
return /* @__PURE__ */ jsx(XAxis, {
|
|
211
|
+
tickLine: axes.xAxis.tickLine,
|
|
212
|
+
axisLine: axes.xAxis.axisLine,
|
|
213
|
+
tickMargin: axes.xAxis.tickMargin,
|
|
214
|
+
tick: tick ?? defaultTick,
|
|
215
|
+
...props
|
|
216
|
+
});
|
|
217
|
+
}
|
|
87
218
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* `color`. `area` adds the 15 %-opacity wash beneath the stroke.
|
|
219
|
+
* Value axis — recharts `YAxis` with no axis/tick lines, size-scaled tick type,
|
|
220
|
+
* and reserved width for value labels. Override `width` for long labels.
|
|
91
221
|
*/
|
|
92
|
-
function
|
|
222
|
+
function LineChartYAxis({ size, tick, ...props }) {
|
|
223
|
+
const { layout } = useLineChartSize(size);
|
|
224
|
+
const axes = cartesianAxisProps({
|
|
225
|
+
tickMargin: layout.tickMargin,
|
|
226
|
+
tickFontSize: layout.tickFontSize,
|
|
227
|
+
yAxisWidth: layout.yAxisWidth
|
|
228
|
+
});
|
|
229
|
+
const defaultTick = {
|
|
230
|
+
...axes.yAxis.tick,
|
|
231
|
+
fill: "var(--color-fg-caption-placeholder)"
|
|
232
|
+
};
|
|
233
|
+
return /* @__PURE__ */ jsx(YAxis, {
|
|
234
|
+
tickLine: axes.yAxis.tickLine,
|
|
235
|
+
axisLine: axes.yAxis.axisLine,
|
|
236
|
+
width: axes.yAxis.width,
|
|
237
|
+
tick: tick ?? defaultTick,
|
|
238
|
+
...props
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/** The giddaa line mark spec: rounded 2px stroke, resting + surface-ringed active dots. */
|
|
242
|
+
function lineMarkProps(layout, color) {
|
|
93
243
|
return {
|
|
94
244
|
type: "linear",
|
|
95
245
|
stroke: color,
|
|
96
246
|
strokeWidth: layout.strokeWidth,
|
|
97
247
|
strokeLinejoin: "round",
|
|
98
|
-
strokeLinecap: "round"
|
|
248
|
+
strokeLinecap: "round"
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function defaultDots(layout, color) {
|
|
252
|
+
return {
|
|
99
253
|
dot: {
|
|
100
254
|
r: layout.dotRadius,
|
|
101
255
|
fill: color,
|
|
@@ -110,23 +264,56 @@ function seriesProps(layout, color) {
|
|
|
110
264
|
};
|
|
111
265
|
}
|
|
112
266
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
267
|
+
* One line series — recharts `Line` with the giddaa mark spec: a 2px rounded
|
|
268
|
+
* stroke in `color`, solid resting dots, and a hover dot ringed in
|
|
269
|
+
* `surface-raised` so overlapping series stay separable. `color` drives all of
|
|
270
|
+
* them at once; `stroke`/`dot`/`activeDot` still win when passed directly.
|
|
271
|
+
*/
|
|
272
|
+
function LineChartSeries({ color = DEFAULT_SERIES_COLOR, size, dot, activeDot, ...props }) {
|
|
273
|
+
const { layout } = useLineChartSize(size);
|
|
274
|
+
const dots = defaultDots(layout, color);
|
|
275
|
+
return /* @__PURE__ */ jsx(Line, {
|
|
276
|
+
...lineMarkProps(layout, color),
|
|
277
|
+
dot: dot ?? dots.dot,
|
|
278
|
+
activeDot: activeDot ?? dots.activeDot,
|
|
279
|
+
...props
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* One area series — recharts `Area` with the giddaa mark spec: the same rounded
|
|
284
|
+
* 2px stroke and dots as `LineChartSeries`, plus the series colour washed to 15%
|
|
285
|
+
* beneath the stroke. `color` drives stroke + fill + dots at once;
|
|
286
|
+
* `stroke`/`fill`/`dot` still win when passed directly.
|
|
287
|
+
*/
|
|
288
|
+
function AreaChartSeries({ color = DEFAULT_SERIES_COLOR, size, dot, activeDot, ...props }) {
|
|
289
|
+
const { layout } = useLineChartSize(size);
|
|
290
|
+
const dots = defaultDots(layout, color);
|
|
291
|
+
return /* @__PURE__ */ jsx(Area, {
|
|
292
|
+
...lineMarkProps(layout, color),
|
|
293
|
+
fill: color,
|
|
294
|
+
fillOpacity: .15,
|
|
295
|
+
dot: dot ?? dots.dot,
|
|
296
|
+
activeDot: activeDot ?? dots.activeDot,
|
|
297
|
+
...props
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated Compose the `<LineChart>`/`<AreaChart>` primitives instead — see
|
|
302
|
+
* the module example. This layout hook predates recharts 3 wrapping support and
|
|
303
|
+
* will be removed in the next major. It returns prop bags to spread onto raw
|
|
304
|
+
* recharts elements.
|
|
125
305
|
*/
|
|
126
306
|
function useLineChartLayout(size) {
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
307
|
+
const { layout } = useLineChartSize(size);
|
|
308
|
+
const axes = cartesianAxisProps({
|
|
309
|
+
tickMargin: layout.tickMargin,
|
|
310
|
+
tickFontSize: layout.tickFontSize,
|
|
311
|
+
yAxisWidth: layout.yAxisWidth
|
|
312
|
+
});
|
|
313
|
+
const series = (color) => ({
|
|
314
|
+
...lineMarkProps(layout, color),
|
|
315
|
+
...defaultDots(layout, color)
|
|
316
|
+
});
|
|
130
317
|
return {
|
|
131
318
|
container: {
|
|
132
319
|
className: "aspect-auto w-full",
|
|
@@ -138,13 +325,13 @@ function useLineChartLayout(size) {
|
|
|
138
325
|
},
|
|
139
326
|
xAxis: axes.xAxis,
|
|
140
327
|
yAxis: axes.yAxis,
|
|
141
|
-
line: (color) =>
|
|
328
|
+
line: (color) => series(color),
|
|
142
329
|
area: (color) => ({
|
|
143
|
-
...
|
|
330
|
+
...series(color),
|
|
144
331
|
fill: color,
|
|
145
332
|
fillOpacity: .15
|
|
146
333
|
})
|
|
147
334
|
};
|
|
148
335
|
}
|
|
149
336
|
//#endregion
|
|
150
|
-
export { LINE_CHART_LAYOUT, toComponentSize, useLineChartLayout };
|
|
337
|
+
export { AreaChart, AreaChartSeries, LINE_CHART_LAYOUT, LINE_CHART_PALETTE, LineChart, LineChartGrid, LineChartSeries, LineChartXAxis, LineChartYAxis, toComponentSize, useLineChartLayout };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Avatar } from "./avatar.js";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
//#region src/list-item.d.ts
|
|
6
|
+
declare const listItemVariants: (props?: ({
|
|
7
|
+
size?: "lg" | "md" | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
type ListItemSize = NonNullable<VariantProps<typeof listItemVariants>["size"]>;
|
|
10
|
+
type ListItemProps = useRender.ComponentProps<"div"> & VariantProps<typeof listItemVariants> & {
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare function ListItem({ className, render, size, selected, ...props }: ListItemProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
declare function ListItemAvatar({ className, size, ...props }: ComponentProps<typeof Avatar>): import("react").JSX.Element;
|
|
15
|
+
declare function ListItemIcon({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
16
|
+
declare function ListItemContent({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
17
|
+
declare function ListItemTitle({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
18
|
+
declare function ListItemDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
19
|
+
declare function ListItemMeta({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
20
|
+
declare function ListItemCount({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ListItem, ListItemAvatar, ListItemContent, ListItemCount, ListItemDescription, ListItemIcon, ListItemMeta, type ListItemProps, type ListItemSize, ListItemTitle, listItemVariants };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./cn-BI_4DMBf.js";
|
|
3
|
+
import { Avatar } from "./avatar.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
|
+
//#region src/list-item.tsx
|
|
9
|
+
const listItemVariants = cva("group/list-item flex w-full min-w-0 items-center border-b border-line-subtle bg-surface text-left text-fg-primary transition-[background-color,color,opacity,box-shadow] outline-none data-[selected=true]:bg-surface-brand-subtle [button,a,[role=button],[role=link]]:cursor-pointer [button,a,[role=button],[role=link]]:select-none [button,a,[role=button],[role=link]]:hover:bg-surface-raised [button,a,[role=button],[role=link]]:active:bg-surface-raised data-[selected=true]:[button,a,[role=button],[role=link]]:hover:bg-surface-brand-subtle data-[selected=true]:[button,a,[role=button],[role=link]]:active:bg-surface-brand-subtle disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 focus-visible:border-line-focus focus-visible:shadow-[0px_0px_0px_2px_var(--color-line-focus)]", {
|
|
10
|
+
variants: { size: {
|
|
11
|
+
md: "gap-3 px-4 py-3.5",
|
|
12
|
+
lg: "gap-4 px-5 py-4.5"
|
|
13
|
+
} },
|
|
14
|
+
defaultVariants: { size: "md" }
|
|
15
|
+
});
|
|
16
|
+
function ListItem({ className, render, size = "md", selected = false, ...props }) {
|
|
17
|
+
return useRender({
|
|
18
|
+
defaultTagName: "div",
|
|
19
|
+
props: mergeProps({
|
|
20
|
+
className: cn(listItemVariants({ size }), className),
|
|
21
|
+
"data-selected": selected,
|
|
22
|
+
"data-size": size,
|
|
23
|
+
"data-slot": "list-item"
|
|
24
|
+
}, props),
|
|
25
|
+
render,
|
|
26
|
+
state: {
|
|
27
|
+
slot: "list-item",
|
|
28
|
+
size,
|
|
29
|
+
selected
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function ListItemAvatar({ className, size = "sm", ...props }) {
|
|
34
|
+
return /* @__PURE__ */ jsx(Avatar, {
|
|
35
|
+
"data-slot": "list-item-avatar",
|
|
36
|
+
size,
|
|
37
|
+
className: cn("group-data-[size=md]/list-item:size-8 group-data-[size=lg]/list-item:size-10", "**:data-[slot=avatar-fallback]:bg-action-tertiary **:data-[slot=avatar-fallback]:text-fg-primary", "group-data-[selected=true]/list-item:**:data-[slot=avatar-fallback]:bg-surface-brand group-data-[selected=true]/list-item:**:data-[slot=avatar-fallback]:text-fg-on-brand", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function ListItemIcon({ className, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx("span", {
|
|
43
|
+
"data-slot": "list-item-icon",
|
|
44
|
+
className: cn("flex shrink-0 items-center justify-center text-fg-secondary [&>svg]:shrink-0", "group-data-[size=md]/list-item:size-5 group-data-[size=md]/list-item:[&>svg]:size-5", "group-data-[size=lg]/list-item:size-6 group-data-[size=lg]/list-item:[&>svg]:size-6", className),
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function ListItemContent({ className, ...props }) {
|
|
49
|
+
return /* @__PURE__ */ jsx("div", {
|
|
50
|
+
"data-slot": "list-item-content",
|
|
51
|
+
className: cn("flex min-w-0 flex-1 flex-col gap-0.5", className),
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function ListItemTitle({ className, ...props }) {
|
|
56
|
+
return /* @__PURE__ */ jsx("p", {
|
|
57
|
+
"data-slot": "list-item-title",
|
|
58
|
+
className: cn("min-w-0 truncate font-semibold text-fg-primary group-data-[selected=true]/list-item:text-fg-brand group-disabled/list-item:text-fg-caption-placeholder group-aria-disabled/list-item:text-fg-caption-placeholder", "group-data-[size=md]/list-item:text-gdt-sm", "group-data-[size=lg]/list-item:text-gdt-md", className),
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function ListItemDescription({ className, ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsx("p", {
|
|
64
|
+
"data-slot": "list-item-description",
|
|
65
|
+
className: cn("min-w-0 truncate font-normal text-fg-secondary group-disabled/list-item:text-fg-caption-placeholder group-aria-disabled/list-item:text-fg-caption-placeholder", "group-data-[size=md]/list-item:text-gdt-xs", "group-data-[size=lg]/list-item:text-gdt-sm", className),
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function ListItemMeta({ className, ...props }) {
|
|
70
|
+
return /* @__PURE__ */ jsx("span", {
|
|
71
|
+
"data-slot": "list-item-meta",
|
|
72
|
+
className: cn("shrink-0 whitespace-nowrap text-right font-normal text-fg-secondary group-data-[selected=true]/list-item:text-fg-brand group-disabled/list-item:text-fg-caption-placeholder group-aria-disabled/list-item:text-fg-caption-placeholder", "group-data-[size=md]/list-item:text-gdt-xs", "group-data-[size=lg]/list-item:text-gdt-sm", className),
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function ListItemCount({ className, ...props }) {
|
|
77
|
+
return /* @__PURE__ */ jsx("span", {
|
|
78
|
+
"data-slot": "list-item-count",
|
|
79
|
+
className: cn("flex shrink-0 items-center justify-center rounded-full bg-action-primary px-2 py-0.5 text-gdt-xs font-bold whitespace-nowrap text-fg-on-brand group-disabled/list-item:bg-action-tertiary group-disabled/list-item:text-fg-caption-placeholder group-aria-disabled/list-item:bg-action-tertiary group-aria-disabled/list-item:text-fg-caption-placeholder", "group-data-[size=md]/list-item:min-h-5.5", "group-data-[size=lg]/list-item:min-h-6", className),
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { ListItem, ListItemAvatar, ListItemContent, ListItemCount, ListItemDescription, ListItemIcon, ListItemMeta, ListItemTitle, listItemVariants };
|
package/dist/number-input.js
CHANGED
|
@@ -43,24 +43,27 @@ function NumberInput({ children, format, formatPreset, placeholder, size, thousa
|
|
|
43
43
|
}
|
|
44
44
|
function NumberInputControl() {
|
|
45
45
|
const size = useComponentSize();
|
|
46
|
-
return /* @__PURE__ */
|
|
46
|
+
return /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
47
47
|
align: "inline-end",
|
|
48
|
-
className: cn("flex
|
|
49
|
-
children:
|
|
50
|
-
className: "w-full flex-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"size-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"size-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
className: cn("flex h-full w-10 overflow-hidden rounded-r-full p-0! group-focus-within/input-group:mr-px group-focus-within/input-group:h-[calc(100%-2px)]", size === "lg" && "w-12"),
|
|
49
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: "flex h-full w-full flex-col gap-0 group-focus-within/input-group:ml-px group-focus-within/input-group:h-[calc(100%+2px)]",
|
|
51
|
+
children: [/* @__PURE__ */ jsx(NumberField.Increment, {
|
|
52
|
+
className: "w-full flex-1 rounded-none rounded-tr-full",
|
|
53
|
+
render: /* @__PURE__ */ jsx(InputGroupButton, { variant: "tertiary" }),
|
|
54
|
+
children: /* @__PURE__ */ jsx(PlusIcon, { className: cn("size-1.5", {
|
|
55
|
+
"size-3": size === "md",
|
|
56
|
+
"size-3.5": size === "lg"
|
|
57
|
+
}) })
|
|
58
|
+
}), /* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
59
|
+
className: "w-full flex-1 rounded-none rounded-br-full",
|
|
60
|
+
render: /* @__PURE__ */ jsx(InputGroupButton, { variant: "tertiary" }),
|
|
61
|
+
children: /* @__PURE__ */ jsx(MinusIcon, { className: cn("size-1.5", {
|
|
62
|
+
"size-3": size === "md",
|
|
63
|
+
"size-3.5": size === "lg"
|
|
64
|
+
}) })
|
|
65
|
+
})]
|
|
66
|
+
})
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
//#endregion
|