@alexgorbatchev/shadcn 0.0.202 → 0.0.204
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/{chunk-6fvcqd48.js → chunk-1pm10n0c.js} +1 -1
- package/dist/{chunk-hcptnha3.js → chunk-t32f2tde.js} +0 -4
- package/dist/{chunk-mwgnsjac.js → chunk-wn906bmh.js} +1 -1
- package/dist/components/assistant-ui/elements/Chart.js +2 -2
- package/dist/components/assistant-ui/index.js +2 -2
- package/dist/components/chart/AnalyticsChart.d.ts +6 -1
- package/dist/components/chart/index.js +59 -20
- package/dist/components/json-render/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/AnalyticsChart.md +38 -0
- package/package.json +1 -1
|
@@ -91,7 +91,7 @@ function Chart3({
|
|
|
91
91
|
"data-density": resolvedDensity,
|
|
92
92
|
"data-slot": "chart",
|
|
93
93
|
"data-chart": chartId,
|
|
94
|
-
className: cn2("flex aspect-video min-w-0 justify-center text-xs [&_.recharts-cartesian-axis-
|
|
94
|
+
className: cn2("flex aspect-video min-w-0 justify-center text-xs [&_.recharts-cartesian-axis-tick-value]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", height !== undefined && "aspect-auto w-full", className),
|
|
95
95
|
style: height === undefined ? style : { ...style, height },
|
|
96
96
|
...props,
|
|
97
97
|
children: [
|
|
@@ -3963,10 +3963,6 @@ function AppShell2({
|
|
|
3963
3963
|
className: "flex shrink-0 items-center gap-control-gap border-b border-border p-panel",
|
|
3964
3964
|
children: [
|
|
3965
3965
|
/* @__PURE__ */ jsx39(SidebarTrigger2, {}),
|
|
3966
|
-
/* @__PURE__ */ jsx39(Separator2, {
|
|
3967
|
-
orientation: "vertical",
|
|
3968
|
-
className: "h-control"
|
|
3969
|
-
}),
|
|
3970
3966
|
header
|
|
3971
3967
|
]
|
|
3972
3968
|
}),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Chart2
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-wn906bmh.js";
|
|
4
4
|
import"../../../chunk-jc3cbwyg.js";
|
|
5
|
-
import"../../../chunk-
|
|
5
|
+
import"../../../chunk-1pm10n0c.js";
|
|
6
6
|
import"../../../chunk-tcefvfr8.js";
|
|
7
7
|
import"../../../chunk-jpvw9xqy.js";
|
|
8
8
|
import"../../../chunk-e6hk39ev.js";
|
|
@@ -53,10 +53,10 @@ import {
|
|
|
53
53
|
CanvasSplitLine2
|
|
54
54
|
} from "../../chunk-mbsfhffg.js";
|
|
55
55
|
import"../../chunk-tcefvfr8.js";
|
|
56
|
-
import"../../chunk-
|
|
56
|
+
import"../../chunk-1pm10n0c.js";
|
|
57
57
|
import {
|
|
58
58
|
Chart2
|
|
59
|
-
} from "../../chunk-
|
|
59
|
+
} from "../../chunk-wn906bmh.js";
|
|
60
60
|
import"../../chunk-t9ms87s9.js";
|
|
61
61
|
import"../../chunk-vfgp11y4.js";
|
|
62
62
|
import"../../chunk-zg00dqe8.js";
|
|
@@ -13,8 +13,13 @@ type AnalyticsChartProps = IDensityProps & {
|
|
|
13
13
|
index: string;
|
|
14
14
|
series: readonly AnalyticsSeries[];
|
|
15
15
|
valueFormatter?: (value: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Where the value axis starts. `"zero"` (the default) suits bars and totals; `"data"` fits the axis to the values, so a
|
|
18
|
+
* change of a few units in a series far from zero stays visible. A chart with a bar series always starts at zero.
|
|
19
|
+
*/
|
|
20
|
+
baseline?: "zero" | "data";
|
|
16
21
|
};
|
|
17
|
-
declare function AnalyticsChart({ label, data, index, series, valueFormatter, showDots, density, }: AnalyticsChartProps): ReactElement;
|
|
22
|
+
declare function AnalyticsChart({ label, data, index, series, valueFormatter, showDots, baseline, density, }: AnalyticsChartProps): ReactElement;
|
|
18
23
|
type SparklineProps = IDensityProps & {
|
|
19
24
|
label: string;
|
|
20
25
|
values: readonly number[];
|
|
@@ -9,14 +9,55 @@ import {
|
|
|
9
9
|
ChartLegendContent2,
|
|
10
10
|
ChartTooltip2,
|
|
11
11
|
ChartLegend2
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-1pm10n0c.js";
|
|
13
13
|
import"../../chunk-e6hk39ev.js";
|
|
14
14
|
import"../../chunk-en44w1pn.js";
|
|
15
15
|
import"../../chunk-jpvw9xqy.js";
|
|
16
16
|
import"../../chunk-5mydsjp3.js";
|
|
17
17
|
// src/components/chart/AnalyticsChart.tsx
|
|
18
|
-
import { Area, Bar, CartesianGrid, ComposedChart, Line, XAxis, YAxis } from "recharts";
|
|
18
|
+
import { Area, Bar, CartesianGrid, ComposedChart, Line, XAxis, YAxis, usePlotArea } from "recharts";
|
|
19
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var INDEX_TICK_MARGIN = 10;
|
|
21
|
+
var INDEX_TICK_GAP = 16;
|
|
22
|
+
function niceStep(rough) {
|
|
23
|
+
const power = 10 ** Math.floor(Math.log10(rough));
|
|
24
|
+
return ([1, 2, 5, 10].find((multiple) => multiple * power >= rough) ?? 10) * power;
|
|
25
|
+
}
|
|
26
|
+
function fitValueAxis(data, keys) {
|
|
27
|
+
const values = data.flatMap((row) => keys.map((key) => row[key]).filter((value) => typeof value === "number"));
|
|
28
|
+
if (!values.length)
|
|
29
|
+
return;
|
|
30
|
+
const [low, high] = [Math.min(...values), Math.max(...values)];
|
|
31
|
+
const margin = (high - low) / 4 || Math.abs(high) / 10 || 1;
|
|
32
|
+
const step = niceStep((high - low + 2 * margin) / 4);
|
|
33
|
+
const [start, end] = [Math.floor((low - margin) / step) * step, Math.ceil((high + margin) / step) * step];
|
|
34
|
+
const ticks = Array.from({ length: Math.round((end - start) / step) + 1 }, (_, i) => start + i * step);
|
|
35
|
+
return { domain: [start, end], ticks };
|
|
36
|
+
}
|
|
37
|
+
function usePointSpacing(count) {
|
|
38
|
+
const area = usePlotArea();
|
|
39
|
+
return area && count > 1 ? area.width / (count - 1) : Number.POSITIVE_INFINITY;
|
|
40
|
+
}
|
|
41
|
+
function SeriesMarks({ item, color, showDots, count }) {
|
|
42
|
+
const spacing = usePointSpacing(count);
|
|
43
|
+
const dot = showDots && { r: Math.min(3, Math.max(1.5, spacing / 4)) };
|
|
44
|
+
return item.type === "area" ? /* @__PURE__ */ jsx(Area, {
|
|
45
|
+
dataKey: item.key,
|
|
46
|
+
stroke: color,
|
|
47
|
+
fill: color,
|
|
48
|
+
fillOpacity: 0.15,
|
|
49
|
+
dot,
|
|
50
|
+
connectNulls: false,
|
|
51
|
+
stackId: item.stackId,
|
|
52
|
+
isAnimationActive: false
|
|
53
|
+
}) : /* @__PURE__ */ jsx(Line, {
|
|
54
|
+
dataKey: item.key,
|
|
55
|
+
stroke: color,
|
|
56
|
+
dot,
|
|
57
|
+
connectNulls: false,
|
|
58
|
+
isAnimationActive: false
|
|
59
|
+
});
|
|
60
|
+
}
|
|
20
61
|
function AnalyticsChart({
|
|
21
62
|
label,
|
|
22
63
|
data,
|
|
@@ -24,9 +65,12 @@ function AnalyticsChart({
|
|
|
24
65
|
series,
|
|
25
66
|
valueFormatter,
|
|
26
67
|
showDots = false,
|
|
68
|
+
baseline = "zero",
|
|
27
69
|
density
|
|
28
70
|
}) {
|
|
29
71
|
const config = Object.fromEntries(series.map((item) => [item.key, { label: item.label }]));
|
|
72
|
+
const hasBars = series.some((item) => item.type === "bar");
|
|
73
|
+
const valueAxis = baseline === "data" && !hasBars ? fitValueAxis(data, series.map((item) => item.key)) : undefined;
|
|
30
74
|
return /* @__PURE__ */ jsx(Chart3, {
|
|
31
75
|
role: "region",
|
|
32
76
|
"aria-label": label,
|
|
@@ -43,19 +87,24 @@ function AnalyticsChart({
|
|
|
43
87
|
/* @__PURE__ */ jsx(XAxis, {
|
|
44
88
|
dataKey: index,
|
|
45
89
|
tickLine: false,
|
|
46
|
-
axisLine: false
|
|
90
|
+
axisLine: false,
|
|
91
|
+
interval: "equidistantPreserveStart",
|
|
92
|
+
minTickGap: INDEX_TICK_GAP,
|
|
93
|
+
tickMargin: INDEX_TICK_MARGIN
|
|
47
94
|
}),
|
|
48
95
|
/* @__PURE__ */ jsx(YAxis, {
|
|
49
96
|
tickLine: false,
|
|
50
97
|
axisLine: false,
|
|
51
|
-
tickFormatter: valueFormatter
|
|
98
|
+
tickFormatter: valueFormatter,
|
|
99
|
+
domain: valueAxis?.domain,
|
|
100
|
+
ticks: valueAxis?.ticks
|
|
52
101
|
}),
|
|
53
102
|
/* @__PURE__ */ jsx(ChartTooltip2, {
|
|
54
103
|
content: /* @__PURE__ */ jsx(ChartTooltipContent2, {
|
|
55
104
|
valueFormatter
|
|
56
105
|
})
|
|
57
106
|
}),
|
|
58
|
-
/* @__PURE__ */ jsx(ChartLegend2, {
|
|
107
|
+
series.length > 1 && /* @__PURE__ */ jsx(ChartLegend2, {
|
|
59
108
|
content: /* @__PURE__ */ jsx(ChartLegendContent2, {})
|
|
60
109
|
}),
|
|
61
110
|
series.map((item, i) => item.type === "bar" ? /* @__PURE__ */ jsx(Bar, {
|
|
@@ -63,21 +112,11 @@ function AnalyticsChart({
|
|
|
63
112
|
fill: `var(--chart-${i % 5 + 1})`,
|
|
64
113
|
stackId: item.stackId,
|
|
65
114
|
isAnimationActive: false
|
|
66
|
-
}, item.key) :
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dot: showDots,
|
|
72
|
-
connectNulls: false,
|
|
73
|
-
stackId: item.stackId,
|
|
74
|
-
isAnimationActive: false
|
|
75
|
-
}, item.key) : /* @__PURE__ */ jsx(Line, {
|
|
76
|
-
dataKey: item.key,
|
|
77
|
-
stroke: `var(--chart-${i % 5 + 1})`,
|
|
78
|
-
dot: showDots,
|
|
79
|
-
connectNulls: false,
|
|
80
|
-
isAnimationActive: false
|
|
115
|
+
}, item.key) : /* @__PURE__ */ jsx(SeriesMarks, {
|
|
116
|
+
item,
|
|
117
|
+
color: `var(--chart-${i % 5 + 1})`,
|
|
118
|
+
showDots,
|
|
119
|
+
count: data.length
|
|
81
120
|
}, item.key))
|
|
82
121
|
]
|
|
83
122
|
})
|
package/dist/index.js
CHANGED
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.204",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -80,3 +80,41 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
|
+
|
|
84
|
+
### DatedSeries
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
{
|
|
88
|
+
args: {
|
|
89
|
+
label: "Sleep duration",
|
|
90
|
+
index: "date",
|
|
91
|
+
data: nights,
|
|
92
|
+
series: [{ key: "minutes", label: "Sleep duration" }],
|
|
93
|
+
showDots: true,
|
|
94
|
+
baseline: "data",
|
|
95
|
+
valueFormatter: (value) => `${Math.round(value)} min`,
|
|
96
|
+
},
|
|
97
|
+
render: (args) => (<div style={{ width: 448 }}>
|
|
98
|
+
<AnalyticsChart {...args}/>
|
|
99
|
+
</div>)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### DatedSeriesOnPhone
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
{
|
|
107
|
+
args: {
|
|
108
|
+
label: "Sleep duration",
|
|
109
|
+
index: "date",
|
|
110
|
+
data: nights,
|
|
111
|
+
series: [{ key: "minutes", label: "Sleep duration" }],
|
|
112
|
+
showDots: true,
|
|
113
|
+
baseline: "data",
|
|
114
|
+
valueFormatter: (value) => `${Math.round(value)} min`,
|
|
115
|
+
},
|
|
116
|
+
render: (args) => (<div style={{ width: 310 }}>
|
|
117
|
+
<AnalyticsChart {...args}/>
|
|
118
|
+
</div>)
|
|
119
|
+
}
|
|
120
|
+
```
|