open-ds 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +66 -2
- package/assets/schemes/accessible-first.json +3093 -0
- package/assets/schemes/brand-expressive.json +3124 -0
- package/assets/schemes/content-first.json +3110 -0
- package/assets/schemes/dense-data.json +3489 -0
- package/assets/schemes/grammar.json +3903 -0
- package/assets/schemes/multi-brand.json +4359 -0
- package/assets/skills/open-ds/SKILL.md +50 -0
- package/assets/skills/open-ds-build/SKILL.md +19 -0
- package/assets/skills/open-ds-change/SKILL.md +19 -0
- package/assets/skills/open-ds-choose/SKILL.md +18 -0
- package/assets/skills/open-ds-review/SKILL.md +22 -0
- package/assets/skills/open-ds-write/SKILL.md +13 -0
- package/assets/stories/accordion.stories.tsx +46 -0
- package/assets/stories/alert-dialog.stories.tsx +65 -0
- package/assets/stories/alert.stories.tsx +44 -0
- package/assets/stories/aspect-ratio.stories.tsx +37 -0
- package/assets/stories/avatar.stories.tsx +42 -0
- package/assets/stories/badge.stories.tsx +39 -0
- package/assets/stories/breadcrumb.stories.tsx +54 -0
- package/assets/stories/button.stories.tsx +46 -0
- package/assets/stories/calendar.stories.tsx +30 -0
- package/assets/stories/card.stories.tsx +50 -0
- package/assets/stories/carousel.stories.tsx +64 -0
- package/assets/stories/chart.stories.tsx +61 -0
- package/assets/stories/checkbox.stories.tsx +29 -0
- package/assets/stories/collapsible.stories.tsx +39 -0
- package/assets/stories/combobox.stories.tsx +57 -0
- package/assets/stories/command.stories.tsx +60 -0
- package/assets/stories/context-menu.stories.tsx +55 -0
- package/assets/stories/data-table.stories.tsx +93 -0
- package/assets/stories/date-picker.stories.tsx +27 -0
- package/assets/stories/dialog.stories.tsx +70 -0
- package/assets/stories/drawer.stories.tsx +62 -0
- package/assets/stories/dropdown-menu.stories.tsx +65 -0
- package/assets/stories/empty.stories.tsx +39 -0
- package/assets/stories/field.stories.tsx +42 -0
- package/assets/stories/form.stories.tsx +56 -0
- package/assets/stories/input-group.stories.tsx +41 -0
- package/assets/stories/input-otp.stories.tsx +48 -0
- package/assets/stories/input.stories.tsx +32 -0
- package/assets/stories/kbd.stories.tsx +30 -0
- package/assets/stories/label.stories.tsx +26 -0
- package/assets/stories/native-select.stories.tsx +39 -0
- package/assets/stories/navigation-menu.stories.tsx +41 -0
- package/assets/stories/pagination.stories.tsx +61 -0
- package/assets/stories/popover.stories.tsx +37 -0
- package/assets/stories/progress.stories.tsx +30 -0
- package/assets/stories/radio-group.stories.tsx +45 -0
- package/assets/stories/resizable.stories.tsx +54 -0
- package/assets/stories/scroll-area.stories.tsx +47 -0
- package/assets/stories/select.stories.tsx +57 -0
- package/assets/stories/separator.stories.tsx +28 -0
- package/assets/stories/sheet.stories.tsx +46 -0
- package/assets/stories/sidebar.stories.tsx +62 -0
- package/assets/stories/skeleton.stories.tsx +27 -0
- package/assets/stories/slider.stories.tsx +44 -0
- package/assets/stories/spinner.stories.tsx +25 -0
- package/assets/stories/switch.stories.tsx +29 -0
- package/assets/stories/table.stories.tsx +97 -0
- package/assets/stories/tabs.stories.tsx +55 -0
- package/assets/stories/textarea.stories.tsx +28 -0
- package/assets/stories/toast.stories.tsx +30 -0
- package/assets/stories/toggle-group.stories.tsx +41 -0
- package/assets/stories/toggle.stories.tsx +20 -0
- package/assets/stories/tooltip.stories.tsx +49 -0
- package/assets/tokens/accessible-first/content.json +32 -0
- package/assets/tokens/accessible-first/dark.tokens.json +581 -0
- package/assets/tokens/accessible-first/light.tokens.json +581 -0
- package/assets/tokens/accessible-first/shadcn.css +21 -0
- package/assets/tokens/accessible-first/theme.css +101 -0
- package/assets/tokens/accessible-first/tokens.css +331 -0
- package/assets/tokens/accessible-first/tokens.json +1616 -0
- package/assets/tokens/accessible-first/tokens.scoped.css +333 -0
- package/assets/tokens/brand-expressive/content.json +32 -0
- package/assets/tokens/brand-expressive/dark.tokens.json +585 -0
- package/assets/tokens/brand-expressive/light.tokens.json +585 -0
- package/assets/tokens/brand-expressive/shadcn.css +21 -0
- package/assets/tokens/brand-expressive/theme.css +101 -0
- package/assets/tokens/brand-expressive/tokens.css +331 -0
- package/assets/tokens/brand-expressive/tokens.json +1651 -0
- package/assets/tokens/brand-expressive/tokens.scoped.css +333 -0
- package/assets/tokens/content-first/content.json +32 -0
- package/assets/tokens/content-first/dark.tokens.json +582 -0
- package/assets/tokens/content-first/light.tokens.json +582 -0
- package/assets/tokens/content-first/shadcn.css +21 -0
- package/assets/tokens/content-first/theme.css +101 -0
- package/assets/tokens/content-first/tokens.css +331 -0
- package/assets/tokens/content-first/tokens.json +1631 -0
- package/assets/tokens/content-first/tokens.scoped.css +333 -0
- package/assets/tokens/dense-data/content.json +32 -0
- package/assets/tokens/dense-data/dark.tokens.json +580 -0
- package/assets/tokens/dense-data/light.tokens.json +580 -0
- package/assets/tokens/dense-data/shadcn.css +21 -0
- package/assets/tokens/dense-data/theme.css +101 -0
- package/assets/tokens/dense-data/tokens.css +331 -0
- package/assets/tokens/dense-data/tokens.json +1623 -0
- package/assets/tokens/dense-data/tokens.scoped.css +333 -0
- package/assets/tokens/index.json +143 -0
- package/assets/tokens/multi-brand/aster-dark.tokens.json +625 -0
- package/assets/tokens/multi-brand/aster-light.tokens.json +625 -0
- package/assets/tokens/multi-brand/birch-dark.tokens.json +625 -0
- package/assets/tokens/multi-brand/birch-light.tokens.json +625 -0
- package/assets/tokens/multi-brand/content.json +32 -0
- package/assets/tokens/multi-brand/coral-dark.tokens.json +625 -0
- package/assets/tokens/multi-brand/coral-light.tokens.json +625 -0
- package/assets/tokens/multi-brand/shadcn.css +21 -0
- package/assets/tokens/multi-brand/theme.css +101 -0
- package/assets/tokens/multi-brand/tokens.css +1002 -0
- package/assets/tokens/multi-brand/tokens.json +1754 -0
- package/assets/tokens/multi-brand/tokens.scoped.css +1022 -0
- package/assets/tokens/shadcn-map.json +34 -0
- package/assets/ui/components/accordion.tsx +60 -0
- package/assets/ui/components/alert-dialog.tsx +171 -0
- package/assets/ui/components/alert.tsx +56 -0
- package/assets/ui/components/aspect-ratio.tsx +17 -0
- package/assets/ui/components/avatar.tsx +96 -0
- package/assets/ui/components/badge.tsx +36 -0
- package/assets/ui/components/breadcrumb.tsx +99 -0
- package/assets/ui/components/button.tsx +53 -0
- package/assets/ui/components/calendar.tsx +169 -0
- package/assets/ui/components/card.tsx +72 -0
- package/assets/ui/components/carousel.tsx +224 -0
- package/assets/ui/components/chart.tsx +315 -0
- package/assets/ui/components/checkbox.tsx +29 -0
- package/assets/ui/components/collapsible.tsx +25 -0
- package/assets/ui/components/combobox.tsx +275 -0
- package/assets/ui/components/command.tsx +145 -0
- package/assets/ui/components/context-menu.tsx +218 -0
- package/assets/ui/components/data-table.tsx +307 -0
- package/assets/ui/components/date-picker.tsx +79 -0
- package/assets/ui/components/dialog.tsx +68 -0
- package/assets/ui/components/drawer.tsx +115 -0
- package/assets/ui/components/dropdown-menu.tsx +58 -0
- package/assets/ui/components/empty.tsx +92 -0
- package/assets/ui/components/field.tsx +234 -0
- package/assets/ui/components/form.tsx +146 -0
- package/assets/ui/components/input-group.tsx +154 -0
- package/assets/ui/components/input-otp.tsx +75 -0
- package/assets/ui/components/input.tsx +25 -0
- package/assets/ui/components/kbd.tsx +30 -0
- package/assets/ui/components/label.tsx +22 -0
- package/assets/ui/components/native-select.tsx +59 -0
- package/assets/ui/components/navigation-menu.tsx +149 -0
- package/assets/ui/components/pagination.tsx +108 -0
- package/assets/ui/components/popover.tsx +61 -0
- package/assets/ui/components/progress.tsx +31 -0
- package/assets/ui/components/radio-group.tsx +40 -0
- package/assets/ui/components/resizable.tsx +54 -0
- package/assets/ui/components/scroll-area.tsx +55 -0
- package/assets/ui/components/select.tsx +81 -0
- package/assets/ui/components/separator.tsx +35 -0
- package/assets/ui/components/sheet.tsx +114 -0
- package/assets/ui/components/sidebar.tsx +685 -0
- package/assets/ui/components/skeleton.tsx +15 -0
- package/assets/ui/components/slider.tsx +70 -0
- package/assets/ui/components/spinner.tsx +16 -0
- package/assets/ui/components/switch.tsx +32 -0
- package/assets/ui/components/table.tsx +78 -0
- package/assets/ui/components/tabs.tsx +49 -0
- package/assets/ui/components/textarea.tsx +25 -0
- package/assets/ui/components/toast.tsx +54 -0
- package/assets/ui/components/toggle-group.tsx +88 -0
- package/assets/ui/components/toggle.tsx +48 -0
- package/assets/ui/components/tooltip.tsx +34 -0
- package/assets/ui/lib/use-mobile.ts +20 -0
- package/assets/ui/lib/utils.ts +7 -0
- package/assets/ui/styles.css +27 -0
- package/bin/open-ds.js +6 -0
- package/package.json +56 -4
- package/src/agents.mjs +150 -0
- package/src/cli.mjs +445 -0
- package/src/components.mjs +69 -0
- package/src/context.mjs +143 -0
- package/src/create.mjs +377 -0
- package/src/docs.mjs +570 -0
- package/src/guidance.mjs +63 -0
- package/src/index.mjs +20 -0
- package/src/mcp.mjs +660 -0
- package/src/readmes.mjs +106 -0
- package/src/schemes.mjs +188 -0
- package/src/tokens.mjs +127 -0
- package/templates/project/.github/workflows/ci.yml +15 -0
- package/templates/project/.storybook/component-docs.mdx +26 -0
- package/templates/project/.storybook/main.ts +17 -0
- package/templates/project/.storybook/manager-head.html +3 -0
- package/templates/project/.storybook/manager.ts +37 -0
- package/templates/project/.storybook/preview-head.html +3 -0
- package/templates/project/.storybook/preview.tsx +82 -0
- package/templates/project/docs/docusaurus.config.ts +64 -0
- package/templates/project/docs/sidebars.ts +8 -0
- package/templates/project/docs/src/css/custom.css +275 -0
- package/templates/project/gitignore +6 -0
- package/templates/project/src/styles/index.css +16 -0
- package/templates/project/src/vite-env.d.ts +7 -0
- package/templates/project/stories/docs-blocks.tsx +190 -0
- package/templates/project/stories/samples.tsx +102 -0
- package/templates/project/stories/usage.tsx +31 -0
- package/templates/project/tokens/build.mjs +468 -0
- package/templates/project/tsconfig.json +15 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chart. Bars, lines and areas built on Recharts.
|
|
3
|
+
*
|
|
4
|
+
* From shadcn/ui (new-york-v4, MIT), carried by the schemes whose inventory names it.
|
|
5
|
+
* Reads the shadcn variables, which theme.css maps onto the scheme's semantic tokens, and the
|
|
6
|
+
* radius, shadow and text scale that shadcn.css maps onto the scheme's tokens. Dark mode comes
|
|
7
|
+
* from the tokens, so no dark: classes.
|
|
8
|
+
*/
|
|
9
|
+
"use client";
|
|
10
|
+
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { cn } from "../lib/utils";
|
|
13
|
+
import * as RechartsPrimitive from "recharts";
|
|
14
|
+
import type { TooltipValueType } from "recharts";
|
|
15
|
+
|
|
16
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
17
|
+
const THEMES = { light: "", dark: ".dark" } as const;
|
|
18
|
+
|
|
19
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
|
|
20
|
+
type TooltipNameType = number | string;
|
|
21
|
+
|
|
22
|
+
export type ChartConfig = Record<
|
|
23
|
+
string,
|
|
24
|
+
{
|
|
25
|
+
label?: React.ReactNode;
|
|
26
|
+
icon?: React.ComponentType;
|
|
27
|
+
} & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> })
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
type ChartContextProps = {
|
|
31
|
+
config: ChartConfig;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
35
|
+
|
|
36
|
+
function useChart() {
|
|
37
|
+
const context = React.useContext(ChartContext);
|
|
38
|
+
|
|
39
|
+
if (!context) {
|
|
40
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return context;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ChartContainer({
|
|
47
|
+
id,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
config,
|
|
51
|
+
initialDimension = INITIAL_DIMENSION,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<"div"> & {
|
|
54
|
+
config: ChartConfig;
|
|
55
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
56
|
+
initialDimension?: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
}) {
|
|
61
|
+
const uniqueId = React.useId();
|
|
62
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<ChartContext.Provider value={{ config }}>
|
|
66
|
+
<div
|
|
67
|
+
data-slot="chart"
|
|
68
|
+
data-chart={chartId}
|
|
69
|
+
className={cn(
|
|
70
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
<ChartStyle id={chartId} config={config} />
|
|
76
|
+
<RechartsPrimitive.ResponsiveContainer initialDimension={initialDimension}>
|
|
77
|
+
{children}
|
|
78
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
79
|
+
</div>
|
|
80
|
+
</ChartContext.Provider>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
85
|
+
const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);
|
|
86
|
+
|
|
87
|
+
if (!colorConfig.length) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<style
|
|
93
|
+
dangerouslySetInnerHTML={{
|
|
94
|
+
__html: Object.entries(THEMES)
|
|
95
|
+
.map(
|
|
96
|
+
([theme, prefix]) => `
|
|
97
|
+
${prefix} [data-chart=${id}] {
|
|
98
|
+
${colorConfig
|
|
99
|
+
.map(([key, itemConfig]) => {
|
|
100
|
+
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ?? itemConfig.color;
|
|
101
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
102
|
+
})
|
|
103
|
+
.join("\n")}
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
)
|
|
107
|
+
.join("\n"),
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
114
|
+
|
|
115
|
+
function ChartTooltipContent({
|
|
116
|
+
active,
|
|
117
|
+
payload,
|
|
118
|
+
className,
|
|
119
|
+
indicator = "dot",
|
|
120
|
+
hideLabel = false,
|
|
121
|
+
hideIndicator = false,
|
|
122
|
+
label,
|
|
123
|
+
labelFormatter,
|
|
124
|
+
labelClassName,
|
|
125
|
+
formatter,
|
|
126
|
+
color,
|
|
127
|
+
nameKey,
|
|
128
|
+
labelKey,
|
|
129
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
130
|
+
React.ComponentProps<"div"> & {
|
|
131
|
+
hideLabel?: boolean;
|
|
132
|
+
hideIndicator?: boolean;
|
|
133
|
+
indicator?: "line" | "dot" | "dashed";
|
|
134
|
+
nameKey?: string;
|
|
135
|
+
labelKey?: string;
|
|
136
|
+
} & Omit<RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>, "accessibilityLayer">) {
|
|
137
|
+
const { config } = useChart();
|
|
138
|
+
|
|
139
|
+
const tooltipLabel = React.useMemo(() => {
|
|
140
|
+
if (hideLabel || !payload?.length) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const [item] = payload;
|
|
145
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
146
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
147
|
+
const value = !labelKey && typeof label === "string" ? (config[label]?.label ?? label) : itemConfig?.label;
|
|
148
|
+
|
|
149
|
+
if (labelFormatter) {
|
|
150
|
+
return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!value) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
|
158
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
159
|
+
|
|
160
|
+
if (!active || !payload?.length) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div
|
|
168
|
+
className={cn(
|
|
169
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
170
|
+
className,
|
|
171
|
+
)}
|
|
172
|
+
>
|
|
173
|
+
{!nestLabel ? tooltipLabel : null}
|
|
174
|
+
<div className="grid gap-1.5">
|
|
175
|
+
{payload
|
|
176
|
+
.filter((item) => item.type !== "none")
|
|
177
|
+
.map((item, index) => {
|
|
178
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
|
|
179
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
180
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color;
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<div
|
|
184
|
+
key={index}
|
|
185
|
+
className={cn(
|
|
186
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
187
|
+
indicator === "dot" && "items-center",
|
|
188
|
+
)}
|
|
189
|
+
>
|
|
190
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
191
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
192
|
+
) : (
|
|
193
|
+
<>
|
|
194
|
+
{itemConfig?.icon ? (
|
|
195
|
+
<itemConfig.icon />
|
|
196
|
+
) : (
|
|
197
|
+
!hideIndicator && (
|
|
198
|
+
<div
|
|
199
|
+
className={cn("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
|
|
200
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
201
|
+
"w-1": indicator === "line",
|
|
202
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
203
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
204
|
+
})}
|
|
205
|
+
style={
|
|
206
|
+
{
|
|
207
|
+
"--color-bg": indicatorColor,
|
|
208
|
+
"--color-border": indicatorColor,
|
|
209
|
+
} as React.CSSProperties
|
|
210
|
+
}
|
|
211
|
+
/>
|
|
212
|
+
)
|
|
213
|
+
)}
|
|
214
|
+
<div
|
|
215
|
+
className={cn(
|
|
216
|
+
"flex flex-1 justify-between leading-none",
|
|
217
|
+
nestLabel ? "items-end" : "items-center",
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
220
|
+
<div className="grid gap-1.5">
|
|
221
|
+
{nestLabel ? tooltipLabel : null}
|
|
222
|
+
<span className="text-muted-foreground">{itemConfig?.label ?? item.name}</span>
|
|
223
|
+
</div>
|
|
224
|
+
{item.value != null && (
|
|
225
|
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
226
|
+
{typeof item.value === "number" ? item.value.toLocaleString() : String(item.value)}
|
|
227
|
+
</span>
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
</>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
})}
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
241
|
+
|
|
242
|
+
function ChartLegendContent({
|
|
243
|
+
className,
|
|
244
|
+
hideIcon = false,
|
|
245
|
+
payload,
|
|
246
|
+
verticalAlign = "bottom",
|
|
247
|
+
nameKey,
|
|
248
|
+
}: React.ComponentProps<"div"> & {
|
|
249
|
+
hideIcon?: boolean;
|
|
250
|
+
nameKey?: string;
|
|
251
|
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
252
|
+
const { config } = useChart();
|
|
253
|
+
|
|
254
|
+
if (!payload?.length) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<div className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}>
|
|
260
|
+
{payload
|
|
261
|
+
.filter((item) => item.type !== "none")
|
|
262
|
+
.map((item, index) => {
|
|
263
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`;
|
|
264
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<div
|
|
268
|
+
key={index}
|
|
269
|
+
className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
|
|
270
|
+
>
|
|
271
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
272
|
+
<itemConfig.icon />
|
|
273
|
+
) : (
|
|
274
|
+
<div
|
|
275
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
276
|
+
style={{
|
|
277
|
+
backgroundColor: item.color,
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
{itemConfig?.label}
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
})}
|
|
285
|
+
</div>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Helper to extract item config from a payload.
|
|
290
|
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
|
291
|
+
if (typeof payload !== "object" || payload === null) {
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const payloadPayload =
|
|
296
|
+
"payload" in payload && typeof payload.payload === "object" && payload.payload !== null
|
|
297
|
+
? payload.payload
|
|
298
|
+
: undefined;
|
|
299
|
+
|
|
300
|
+
let configLabelKey: string = key;
|
|
301
|
+
|
|
302
|
+
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
|
|
303
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
304
|
+
} else if (
|
|
305
|
+
payloadPayload &&
|
|
306
|
+
key in payloadPayload &&
|
|
307
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
308
|
+
) {
|
|
309
|
+
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox. Turns one option on or off inside a form.
|
|
3
|
+
*
|
|
4
|
+
* Reads only component keys: --control-*.
|
|
5
|
+
*/
|
|
6
|
+
import { Check } from "lucide-react";
|
|
7
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { cn } from "../lib/utils";
|
|
10
|
+
|
|
11
|
+
export function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<CheckboxPrimitive.Root
|
|
14
|
+
data-slot="checkbox"
|
|
15
|
+
className={cn(
|
|
16
|
+
"peer size-[var(--size-icon)] shrink-0 rounded-[var(--control-radius)] bg-[var(--input-background)]",
|
|
17
|
+
"border-[length:var(--border-width-default)] border-[var(--control-track)]",
|
|
18
|
+
"data-[state=checked]:bg-[var(--control-checked)] data-[state=checked]:border-[var(--control-checked)] data-[state=checked]:text-[var(--control-thumb)]",
|
|
19
|
+
"outline-none focus-visible:ring-[length:var(--border-width-focus)] focus-visible:ring-[color:var(--button-focus-ring)] disabled:opacity-[var(--opacity-disabled)]",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
<CheckboxPrimitive.Indicator className="flex items-center justify-center">
|
|
25
|
+
<Check className="size-[calc(var(--size-icon)*0.8)]" strokeWidth={3} />
|
|
26
|
+
</CheckboxPrimitive.Indicator>
|
|
27
|
+
</CheckboxPrimitive.Root>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapsible. One section that opens and closes.
|
|
3
|
+
*
|
|
4
|
+
* From shadcn/ui (new-york-v4, MIT), carried by the schemes whose inventory names it.
|
|
5
|
+
* Reads the shadcn variables, which theme.css maps onto the scheme's semantic tokens, and the
|
|
6
|
+
* radius, shadow and text scale that shadcn.css maps onto the scheme's tokens. Dark mode comes
|
|
7
|
+
* from the tokens, so no dark: classes.
|
|
8
|
+
*/
|
|
9
|
+
"use client";
|
|
10
|
+
|
|
11
|
+
import { Collapsible as CollapsiblePrimitive } from "radix-ui";
|
|
12
|
+
|
|
13
|
+
function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
14
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CollapsibleTrigger({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
18
|
+
return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function CollapsibleContent({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
22
|
+
return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combobox. A text field with a filtered list of choices.
|
|
3
|
+
*
|
|
4
|
+
* From shadcn/ui (new-york-v4, MIT), carried by the schemes whose inventory names it.
|
|
5
|
+
* Reads the shadcn variables, which theme.css maps onto the scheme's semantic tokens, and the
|
|
6
|
+
* radius, shadow and text scale that shadcn.css maps onto the scheme's tokens. Dark mode comes
|
|
7
|
+
* from the tokens, so no dark: classes.
|
|
8
|
+
*/
|
|
9
|
+
"use client";
|
|
10
|
+
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react";
|
|
13
|
+
import { cn } from "../lib/utils";
|
|
14
|
+
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
|
|
15
|
+
|
|
16
|
+
import { Button } from "./button";
|
|
17
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "./input-group";
|
|
18
|
+
|
|
19
|
+
const Combobox = ComboboxPrimitive.Root;
|
|
20
|
+
|
|
21
|
+
function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
|
|
22
|
+
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {
|
|
26
|
+
return (
|
|
27
|
+
<ComboboxPrimitive.Trigger
|
|
28
|
+
data-slot="combobox-trigger"
|
|
29
|
+
className={cn("[&_svg:not([class*='size-'])]:size-4", className)}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
<ChevronDownIcon data-slot="combobox-trigger-icon" className="pointer-events-none size-4 text-muted-foreground" />
|
|
34
|
+
</ComboboxPrimitive.Trigger>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
|
|
39
|
+
return (
|
|
40
|
+
<ComboboxPrimitive.Clear
|
|
41
|
+
data-slot="combobox-clear"
|
|
42
|
+
render={<InputGroupButton variant="ghost" size="icon-xs" />}
|
|
43
|
+
className={cn(className)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
<XIcon className="pointer-events-none" />
|
|
47
|
+
</ComboboxPrimitive.Clear>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function ComboboxInput({
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
disabled = false,
|
|
55
|
+
showTrigger = true,
|
|
56
|
+
showClear = false,
|
|
57
|
+
...props
|
|
58
|
+
}: ComboboxPrimitive.Input.Props & {
|
|
59
|
+
showTrigger?: boolean;
|
|
60
|
+
showClear?: boolean;
|
|
61
|
+
}) {
|
|
62
|
+
return (
|
|
63
|
+
<InputGroup className={cn("w-auto", className)}>
|
|
64
|
+
<ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
|
|
65
|
+
<InputGroupAddon align="inline-end">
|
|
66
|
+
{showTrigger && (
|
|
67
|
+
<InputGroupButton
|
|
68
|
+
size="icon-xs"
|
|
69
|
+
variant="ghost"
|
|
70
|
+
asChild
|
|
71
|
+
data-slot="input-group-button"
|
|
72
|
+
className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
>
|
|
75
|
+
<ComboboxTrigger />
|
|
76
|
+
</InputGroupButton>
|
|
77
|
+
)}
|
|
78
|
+
{showClear && <ComboboxClear disabled={disabled} />}
|
|
79
|
+
</InputGroupAddon>
|
|
80
|
+
{children}
|
|
81
|
+
</InputGroup>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function ComboboxContent({
|
|
86
|
+
className,
|
|
87
|
+
side = "bottom",
|
|
88
|
+
sideOffset = 6,
|
|
89
|
+
align = "start",
|
|
90
|
+
alignOffset = 0,
|
|
91
|
+
anchor,
|
|
92
|
+
...props
|
|
93
|
+
}: ComboboxPrimitive.Popup.Props &
|
|
94
|
+
Pick<ComboboxPrimitive.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">) {
|
|
95
|
+
return (
|
|
96
|
+
<ComboboxPrimitive.Portal>
|
|
97
|
+
<ComboboxPrimitive.Positioner
|
|
98
|
+
side={side}
|
|
99
|
+
sideOffset={sideOffset}
|
|
100
|
+
align={align}
|
|
101
|
+
alignOffset={alignOffset}
|
|
102
|
+
anchor={anchor}
|
|
103
|
+
className="isolate z-50"
|
|
104
|
+
>
|
|
105
|
+
<ComboboxPrimitive.Popup
|
|
106
|
+
data-slot="combobox-content"
|
|
107
|
+
data-chips={!!anchor}
|
|
108
|
+
className={cn(
|
|
109
|
+
"group/combobox-content relative max-h-96 w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
110
|
+
className,
|
|
111
|
+
)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
</ComboboxPrimitive.Positioner>
|
|
115
|
+
</ComboboxPrimitive.Portal>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
120
|
+
return (
|
|
121
|
+
<ComboboxPrimitive.List
|
|
122
|
+
data-slot="combobox-list"
|
|
123
|
+
className={cn(
|
|
124
|
+
"max-h-[min(calc(--spacing(96)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:p-0",
|
|
125
|
+
className,
|
|
126
|
+
)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {
|
|
133
|
+
return (
|
|
134
|
+
<ComboboxPrimitive.Item
|
|
135
|
+
data-slot="combobox-item"
|
|
136
|
+
className={cn(
|
|
137
|
+
"relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
138
|
+
className,
|
|
139
|
+
)}
|
|
140
|
+
{...props}
|
|
141
|
+
>
|
|
142
|
+
{children}
|
|
143
|
+
<ComboboxPrimitive.ItemIndicator
|
|
144
|
+
data-slot="combobox-item-indicator"
|
|
145
|
+
render={<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />}
|
|
146
|
+
>
|
|
147
|
+
<CheckIcon className="pointer-events-none size-4 pointer-coarse:size-5" />
|
|
148
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
149
|
+
</ComboboxPrimitive.Item>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
|
|
154
|
+
return <ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {
|
|
158
|
+
return (
|
|
159
|
+
<ComboboxPrimitive.GroupLabel
|
|
160
|
+
data-slot="combobox-label"
|
|
161
|
+
className={cn(
|
|
162
|
+
"px-2 py-1.5 text-xs text-muted-foreground pointer-coarse:px-3 pointer-coarse:py-2 pointer-coarse:text-sm",
|
|
163
|
+
className,
|
|
164
|
+
)}
|
|
165
|
+
{...props}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
|
|
171
|
+
return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
175
|
+
return (
|
|
176
|
+
<ComboboxPrimitive.Empty
|
|
177
|
+
data-slot="combobox-empty"
|
|
178
|
+
className={cn(
|
|
179
|
+
"hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
|
|
180
|
+
className,
|
|
181
|
+
)}
|
|
182
|
+
{...props}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {
|
|
188
|
+
return (
|
|
189
|
+
<ComboboxPrimitive.Separator
|
|
190
|
+
data-slot="combobox-separator"
|
|
191
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
192
|
+
{...props}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function ComboboxChips({
|
|
198
|
+
className,
|
|
199
|
+
...props
|
|
200
|
+
}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {
|
|
201
|
+
return (
|
|
202
|
+
<ComboboxPrimitive.Chips
|
|
203
|
+
data-slot="combobox-chips"
|
|
204
|
+
className={cn(
|
|
205
|
+
"flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-[3px] has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1.5",
|
|
206
|
+
className,
|
|
207
|
+
)}
|
|
208
|
+
{...props}
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function ComboboxChip({
|
|
214
|
+
className,
|
|
215
|
+
children,
|
|
216
|
+
showRemove = true,
|
|
217
|
+
...props
|
|
218
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
219
|
+
showRemove?: boolean;
|
|
220
|
+
}) {
|
|
221
|
+
return (
|
|
222
|
+
<ComboboxPrimitive.Chip
|
|
223
|
+
data-slot="combobox-chip"
|
|
224
|
+
className={cn(
|
|
225
|
+
"flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
|
|
226
|
+
className,
|
|
227
|
+
)}
|
|
228
|
+
{...props}
|
|
229
|
+
>
|
|
230
|
+
{children}
|
|
231
|
+
{showRemove && (
|
|
232
|
+
<ComboboxPrimitive.ChipRemove
|
|
233
|
+
render={<Button variant="ghost" size="icon" />}
|
|
234
|
+
className="-ml-1 opacity-50 hover:opacity-100"
|
|
235
|
+
data-slot="combobox-chip-remove"
|
|
236
|
+
>
|
|
237
|
+
<XIcon className="pointer-events-none" />
|
|
238
|
+
</ComboboxPrimitive.ChipRemove>
|
|
239
|
+
)}
|
|
240
|
+
</ComboboxPrimitive.Chip>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function ComboboxChipsInput({ className, children, ...props }: ComboboxPrimitive.Input.Props) {
|
|
245
|
+
return (
|
|
246
|
+
<ComboboxPrimitive.Input
|
|
247
|
+
data-slot="combobox-chip-input"
|
|
248
|
+
className={cn("min-w-16 flex-1 outline-none", className)}
|
|
249
|
+
{...props}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function useComboboxAnchor() {
|
|
255
|
+
return React.useRef<HTMLDivElement | null>(null);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
Combobox,
|
|
260
|
+
ComboboxInput,
|
|
261
|
+
ComboboxContent,
|
|
262
|
+
ComboboxList,
|
|
263
|
+
ComboboxItem,
|
|
264
|
+
ComboboxGroup,
|
|
265
|
+
ComboboxLabel,
|
|
266
|
+
ComboboxCollection,
|
|
267
|
+
ComboboxEmpty,
|
|
268
|
+
ComboboxSeparator,
|
|
269
|
+
ComboboxChips,
|
|
270
|
+
ComboboxChip,
|
|
271
|
+
ComboboxChipsInput,
|
|
272
|
+
ComboboxTrigger,
|
|
273
|
+
ComboboxValue,
|
|
274
|
+
useComboboxAnchor,
|
|
275
|
+
};
|