@foundrykit/components 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4WYKNDYY.js +91 -0
- package/dist/chunk-4WYKNDYY.js.map +1 -0
- package/dist/chunk-5CXNMTIN.js +84 -0
- package/dist/chunk-5CXNMTIN.js.map +1 -0
- package/dist/chunk-B5ZTF5MZ.js +203 -0
- package/dist/chunk-B5ZTF5MZ.js.map +1 -0
- package/dist/chunk-EDNWBEKV.js +51 -0
- package/dist/chunk-EDNWBEKV.js.map +1 -0
- package/dist/chunk-ID7BFTID.js +248 -0
- package/dist/chunk-ID7BFTID.js.map +1 -0
- package/dist/chunk-IYBHXVCH.js +181 -0
- package/dist/chunk-IYBHXVCH.js.map +1 -0
- package/dist/chunk-KQZEF7PS.js +71 -0
- package/dist/chunk-KQZEF7PS.js.map +1 -0
- package/dist/chunk-P3GSYR7O.js +889 -0
- package/dist/chunk-P3GSYR7O.js.map +1 -0
- package/dist/chunk-PKSRYDN4.js +168 -0
- package/dist/chunk-PKSRYDN4.js.map +1 -0
- package/dist/chunk-SFM7ZMG2.js +104 -0
- package/dist/chunk-SFM7ZMG2.js.map +1 -0
- package/dist/chunk-TLQQZJUR.js +126 -0
- package/dist/chunk-TLQQZJUR.js.map +1 -0
- package/dist/chunk-UE7CDYEN.js +59 -0
- package/dist/chunk-UE7CDYEN.js.map +1 -0
- package/dist/chunk-UG7YS3D5.js +198 -0
- package/dist/chunk-UG7YS3D5.js.map +1 -0
- package/dist/components/advanced-search-bar/index.d.ts +308 -0
- package/dist/components/advanced-search-bar/index.js +34 -0
- package/dist/components/advanced-search-bar/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +20 -0
- package/dist/components/calendar/index.js +11 -0
- package/dist/components/calendar/index.js.map +1 -0
- package/dist/components/carousel/index.d.ts +40 -0
- package/dist/components/carousel/index.js +17 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/chart/index.d.ts +59 -0
- package/dist/components/chart/index.js +21 -0
- package/dist/components/chart/index.js.map +1 -0
- package/dist/components/combobox/index.d.ts +33 -0
- package/dist/components/combobox/index.js +10 -0
- package/dist/components/combobox/index.js.map +1 -0
- package/dist/components/command/index.d.ts +33 -0
- package/dist/components/command/index.js +25 -0
- package/dist/components/command/index.js.map +1 -0
- package/dist/components/data-table/index.d.ts +17 -0
- package/dist/components/data-table/index.js +9 -0
- package/dist/components/data-table/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +17 -0
- package/dist/components/date-picker/index.js +9 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/form/index.d.ts +37 -0
- package/dist/components/form/index.js +23 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/input-otp/index.d.ts +30 -0
- package/dist/components/input-otp/index.js +15 -0
- package/dist/components/input-otp/index.js.map +1 -0
- package/dist/components/pagination/index.d.ts +26 -0
- package/dist/components/pagination/index.js +20 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/search-bar/index.d.ts +17 -0
- package/dist/components/search-bar/index.js +9 -0
- package/dist/components/search-bar/index.js.map +1 -0
- package/dist/components/sidebar/index.d.ts +70 -0
- package/dist/components/sidebar/index.js +652 -0
- package/dist/components/sidebar/index.js.map +1 -0
- package/dist/components/theme-toggle/index.d.ts +20 -0
- package/dist/components/theme-toggle/index.js +9 -0
- package/dist/components/theme-toggle/index.js.map +1 -0
- package/dist/index.d.ts +27 -605
- package/dist/index.js +73 -2337
- package/dist/index.js.map +1 -1
- package/package.json +15 -8
- package/CHANGELOG.md +0 -362
- package/src/components/advanced-search-bar/config.ts +0 -223
- package/src/components/advanced-search-bar/index.tsx +0 -1415
- package/src/components/calendar/config.ts +0 -51
- package/src/components/calendar/index.tsx +0 -225
- package/src/components/carousel/config.ts +0 -28
- package/src/components/carousel/index.tsx +0 -258
- package/src/components/chart/config.ts +0 -28
- package/src/components/chart/index.tsx +0 -365
- package/src/components/combobox/config.ts +0 -28
- package/src/components/combobox/index.tsx +0 -111
- package/src/components/command/config.ts +0 -804
- package/src/components/command/index.tsx +0 -195
- package/src/components/data-table/config.ts +0 -28
- package/src/components/data-table/index.tsx +0 -124
- package/src/components/date-picker/config.ts +0 -55
- package/src/components/date-picker/index.tsx +0 -207
- package/src/components/form/config.ts +0 -21
- package/src/components/form/index.tsx +0 -150
- package/src/components/input-otp/config.ts +0 -28
- package/src/components/input-otp/index.tsx +0 -92
- package/src/components/pagination/config.ts +0 -367
- package/src/components/pagination/index.tsx +0 -135
- package/src/components/search-bar/config.ts +0 -58
- package/src/components/search-bar/index.tsx +0 -70
- package/src/components/sidebar/config.ts +0 -29
- package/src/components/sidebar/index.tsx +0 -723
- package/src/components/theme-toggle/config.ts +0 -27
- package/src/components/theme-toggle/index.tsx +0 -63
- package/src/index.ts +0 -83
- package/tsconfig.json +0 -12
- package/tsconfig.lint.json +0 -8
- package/tsup.config.ts +0 -11
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/components/chart/index.tsx
|
|
4
|
+
import { cn } from "@foundrykit/utils";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import * as RechartsPrimitive from "recharts";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
9
|
+
var ChartContext = React.createContext(null);
|
|
10
|
+
function useChart() {
|
|
11
|
+
const context = React.useContext(ChartContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
function ChartContainer({
|
|
18
|
+
id,
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
config,
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
const uniqueId = React.useId();
|
|
25
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
26
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
"data-slot": "chart",
|
|
30
|
+
"data-chart": chartId,
|
|
31
|
+
className: cn(
|
|
32
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
...props,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
|
|
38
|
+
/* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
) });
|
|
42
|
+
}
|
|
43
|
+
function ChartStyle({ id, config }) {
|
|
44
|
+
const colorConfig = Object.entries(config).filter(
|
|
45
|
+
([, itemConfig]) => itemConfig.theme || itemConfig.color
|
|
46
|
+
);
|
|
47
|
+
if (!colorConfig.length) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
"style",
|
|
52
|
+
{
|
|
53
|
+
dangerouslySetInnerHTML: {
|
|
54
|
+
__html: Object.entries(THEMES).map(
|
|
55
|
+
([theme, prefix]) => `
|
|
56
|
+
${prefix} [data-chart=${id}] {
|
|
57
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
58
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
59
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
60
|
+
}).join("\n")}
|
|
61
|
+
}
|
|
62
|
+
`
|
|
63
|
+
).join("\n")
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
69
|
+
function ChartTooltipContent({
|
|
70
|
+
active,
|
|
71
|
+
payload,
|
|
72
|
+
className,
|
|
73
|
+
indicator = "dot",
|
|
74
|
+
hideLabel = false,
|
|
75
|
+
hideIndicator = false,
|
|
76
|
+
label,
|
|
77
|
+
labelFormatter,
|
|
78
|
+
labelClassName,
|
|
79
|
+
formatter,
|
|
80
|
+
color,
|
|
81
|
+
nameKey,
|
|
82
|
+
labelKey
|
|
83
|
+
}) {
|
|
84
|
+
const { config } = useChart();
|
|
85
|
+
const tooltipLabel = React.useMemo(() => {
|
|
86
|
+
if (hideLabel || !payload?.length) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const [item] = payload;
|
|
90
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
91
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
92
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
93
|
+
if (labelFormatter) {
|
|
94
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
95
|
+
}
|
|
96
|
+
if (!value) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
|
|
100
|
+
}, [
|
|
101
|
+
label,
|
|
102
|
+
labelFormatter,
|
|
103
|
+
payload,
|
|
104
|
+
hideLabel,
|
|
105
|
+
labelClassName,
|
|
106
|
+
config,
|
|
107
|
+
labelKey
|
|
108
|
+
]);
|
|
109
|
+
if (!active || !payload?.length) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
113
|
+
return /* @__PURE__ */ jsxs(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
"data-slot": "chart-tooltip-content",
|
|
117
|
+
className: cn(
|
|
118
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
119
|
+
className
|
|
120
|
+
),
|
|
121
|
+
children: [
|
|
122
|
+
!nestLabel ? tooltipLabel : null,
|
|
123
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
|
|
124
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
125
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
126
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: cn(
|
|
131
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
132
|
+
indicator === "dot" && "items-center"
|
|
133
|
+
),
|
|
134
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
135
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
|
|
136
|
+
"div",
|
|
137
|
+
{
|
|
138
|
+
className: cn(
|
|
139
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
140
|
+
{
|
|
141
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
142
|
+
"w-1": indicator === "line",
|
|
143
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
144
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
style: {
|
|
148
|
+
"--color-bg": indicatorColor,
|
|
149
|
+
"--color-border": indicatorColor
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsxs(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
className: cn(
|
|
157
|
+
"flex flex-1 justify-between leading-none",
|
|
158
|
+
nestLabel ? "items-end" : "items-center"
|
|
159
|
+
),
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
|
|
162
|
+
nestLabel ? tooltipLabel : null,
|
|
163
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
164
|
+
] }),
|
|
165
|
+
item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] })
|
|
170
|
+
},
|
|
171
|
+
item.dataKey
|
|
172
|
+
);
|
|
173
|
+
}) })
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
179
|
+
function ChartLegendContent({
|
|
180
|
+
className,
|
|
181
|
+
hideIcon = false,
|
|
182
|
+
payload,
|
|
183
|
+
verticalAlign = "bottom",
|
|
184
|
+
nameKey
|
|
185
|
+
}) {
|
|
186
|
+
const { config } = useChart();
|
|
187
|
+
if (!payload?.length) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return /* @__PURE__ */ jsx(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
"data-slot": "chart-legend-content",
|
|
194
|
+
className: cn(
|
|
195
|
+
"flex items-center justify-center gap-4",
|
|
196
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
197
|
+
className
|
|
198
|
+
),
|
|
199
|
+
children: payload.map((item) => {
|
|
200
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
201
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
202
|
+
return /* @__PURE__ */ jsxs(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
className: cn(
|
|
206
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
207
|
+
),
|
|
208
|
+
children: [
|
|
209
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
213
|
+
style: { backgroundColor: item.color }
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
itemConfig?.label
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
item.value
|
|
220
|
+
);
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
226
|
+
if (typeof payload !== "object" || payload === null) {
|
|
227
|
+
return void 0;
|
|
228
|
+
}
|
|
229
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
230
|
+
let configLabelKey = key;
|
|
231
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
232
|
+
configLabelKey = payload[key];
|
|
233
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
234
|
+
configLabelKey = payloadPayload[key];
|
|
235
|
+
}
|
|
236
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export {
|
|
240
|
+
useChart,
|
|
241
|
+
ChartContainer,
|
|
242
|
+
ChartStyle,
|
|
243
|
+
ChartTooltip,
|
|
244
|
+
ChartTooltipContent,
|
|
245
|
+
ChartLegend,
|
|
246
|
+
ChartLegendContent
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=chunk-ID7BFTID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chart/index.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@foundrykit/utils';\nimport * as React from 'react';\nimport * as RechartsPrimitive from 'recharts';\n\n// Format: { THEME_NAME: CSS_SELECTOR }\nconst THEMES = { light: '', dark: '.dark' } as const;\n\nexport type ChartConfig = {\n [k in string]: {\n label?: React.ReactNode;\n icon?: React.ComponentType;\n } & (\n | { color?: string; theme?: never }\n | { color?: never; theme: Record<keyof typeof THEMES, string> }\n );\n};\n\ntype ChartContextProps = {\n config: ChartConfig;\n};\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null);\n\nfunction useChart() {\n const context = React.useContext(ChartContext);\n\n if (!context) {\n throw new Error('useChart must be used within a <ChartContainer />');\n }\n\n return context;\n}\n\n/**\n * Responsive chart wrapper that shares config (labels, colors) with its parts.\n *\n * @example\n * ```tsx\n * <ChartContainer config={config}>\n * <BarChart data={data}>\n * <Bar dataKey='total' fill='var(--color-total)' />\n * </BarChart>\n * </ChartContainer>\n * ```\n */\nfunction ChartContainer({\n id,\n className,\n children,\n config,\n ...props\n}: React.ComponentProps<'div'> & {\n config: ChartConfig;\n children: React.ComponentProps<\n typeof RechartsPrimitive.ResponsiveContainer\n >['children'];\n}) {\n const uniqueId = React.useId();\n const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;\n\n return (\n <ChartContext.Provider value={{ config }}>\n <div\n data-slot='chart'\n data-chart={chartId}\n className={cn(\n \"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden\",\n className\n )}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n <RechartsPrimitive.ResponsiveContainer>\n {children}\n </RechartsPrimitive.ResponsiveContainer>\n </div>\n </ChartContext.Provider>\n );\n}\n\nfunction ChartStyle({ id, config }: { id: string; config: ChartConfig }) {\n const colorConfig = Object.entries(config).filter(\n ([, itemConfig]) => itemConfig.theme || itemConfig.color\n );\n\n if (!colorConfig.length) {\n return null;\n }\n\n return (\n <style\n dangerouslySetInnerHTML={{\n __html: Object.entries(THEMES)\n .map(\n ([theme, prefix]) => `\n${prefix} [data-chart=${id}] {\n${colorConfig\n .map(([key, itemConfig]) => {\n const color =\n itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||\n itemConfig.color;\n return color ? ` --color-${key}: ${color};` : null;\n })\n .join('\\n')}\n}\n`\n )\n .join('\\n'),\n }}\n />\n );\n}\n\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\nfunction ChartTooltipContent({\n active,\n payload,\n className,\n indicator = 'dot',\n hideLabel = false,\n hideIndicator = false,\n label,\n labelFormatter,\n labelClassName,\n formatter,\n color,\n nameKey,\n labelKey,\n}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &\n React.ComponentProps<'div'> & {\n hideLabel?: boolean;\n hideIndicator?: boolean;\n indicator?: 'line' | 'dot' | 'dashed';\n nameKey?: string;\n labelKey?: string;\n }) {\n const { config } = useChart();\n\n const tooltipLabel = React.useMemo(() => {\n if (hideLabel || !payload?.length) {\n return null;\n }\n\n const [item] = payload;\n const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const value =\n !labelKey && typeof label === 'string'\n ? config[label as keyof typeof config]?.label || label\n : itemConfig?.label;\n\n if (labelFormatter) {\n return (\n <div className={cn('font-medium', labelClassName)}>\n {labelFormatter(value, payload)}\n </div>\n );\n }\n\n if (!value) {\n return null;\n }\n\n return <div className={cn('font-medium', labelClassName)}>{value}</div>;\n }, [\n label,\n labelFormatter,\n payload,\n hideLabel,\n labelClassName,\n config,\n labelKey,\n ]);\n\n if (!active || !payload?.length) {\n return null;\n }\n\n const nestLabel = payload.length === 1 && indicator !== 'dot';\n\n return (\n <div\n data-slot='chart-tooltip-content'\n className={cn(\n 'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',\n className\n )}\n >\n {!nestLabel ? tooltipLabel : null}\n <div className='grid gap-1.5'>\n {payload.map((item, index) => {\n const key = `${nameKey || item.name || item.dataKey || 'value'}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n const indicatorColor = color || item.payload.fill || item.color;\n\n return (\n <div\n key={item.dataKey}\n className={cn(\n '[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',\n indicator === 'dot' && 'items-center'\n )}\n >\n {formatter && item?.value !== undefined && item.name ? (\n formatter(item.value, item.name, item, index, item.payload)\n ) : (\n <>\n {itemConfig?.icon ? (\n <itemConfig.icon />\n ) : (\n !hideIndicator && (\n <div\n className={cn(\n 'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',\n {\n 'h-2.5 w-2.5': indicator === 'dot',\n 'w-1': indicator === 'line',\n 'w-0 border-[1.5px] border-dashed bg-transparent':\n indicator === 'dashed',\n 'my-0.5': nestLabel && indicator === 'dashed',\n }\n )}\n style={\n {\n '--color-bg': indicatorColor,\n '--color-border': indicatorColor,\n } as React.CSSProperties\n }\n />\n )\n )}\n <div\n className={cn(\n 'flex flex-1 justify-between leading-none',\n nestLabel ? 'items-end' : 'items-center'\n )}\n >\n <div className='grid gap-1.5'>\n {nestLabel ? tooltipLabel : null}\n <span className='text-muted-foreground'>\n {itemConfig?.label || item.name}\n </span>\n </div>\n {item.value && (\n <span className='text-foreground font-mono font-medium tabular-nums'>\n {item.value.toLocaleString()}\n </span>\n )}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nconst ChartLegend = RechartsPrimitive.Legend;\n\nfunction ChartLegendContent({\n className,\n hideIcon = false,\n payload,\n verticalAlign = 'bottom',\n nameKey,\n}: React.ComponentProps<'div'> &\n Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {\n hideIcon?: boolean;\n nameKey?: string;\n }) {\n const { config } = useChart();\n\n if (!payload?.length) {\n return null;\n }\n\n return (\n <div\n data-slot='chart-legend-content'\n className={cn(\n 'flex items-center justify-center gap-4',\n verticalAlign === 'top' ? 'pb-3' : 'pt-3',\n className\n )}\n >\n {payload.map(item => {\n const key = `${nameKey || item.dataKey || 'value'}`;\n const itemConfig = getPayloadConfigFromPayload(config, item, key);\n\n return (\n <div\n key={item.value}\n className={cn(\n '[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3'\n )}\n >\n {itemConfig?.icon && !hideIcon ? (\n <itemConfig.icon />\n ) : (\n <div\n className='h-2 w-2 shrink-0 rounded-[2px]'\n style={{ backgroundColor: item.color }}\n />\n )}\n {itemConfig?.label}\n </div>\n );\n })}\n </div>\n );\n}\n\n// Helper to extract item config from a payload.\nfunction getPayloadConfigFromPayload(\n config: ChartConfig,\n payload: unknown,\n key: string\n) {\n if (typeof payload !== 'object' || payload === null) {\n return undefined;\n }\n\n const payloadPayload =\n 'payload' in payload &&\n typeof payload.payload === 'object' &&\n payload.payload !== null\n ? payload.payload\n : undefined;\n\n let configLabelKey: string = key;\n\n if (\n key in payload &&\n typeof payload[key as keyof typeof payload] === 'string'\n ) {\n configLabelKey = payload[key as keyof typeof payload] as string;\n } else if (\n payloadPayload &&\n key in payloadPayload &&\n typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'\n ) {\n configLabelKey = payloadPayload[\n key as keyof typeof payloadPayload\n ] as string;\n }\n\n return configLabelKey in config\n ? config[configLabelKey]\n : config[key as keyof typeof config];\n}\n\nexport {\n ChartContainer,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n ChartTooltip,\n ChartTooltipContent,\n useChart,\n};\n"],"mappings":";;;AAEA,SAAS,UAAU;AACnB,YAAY,WAAW;AACvB,YAAY,uBAAuB;AA4D7B,SAiJU,UAxIR,KATF;AAzDN,IAAM,SAAS,EAAE,OAAO,IAAI,MAAM,QAAQ;AAgB1C,IAAM,eAAqB,oBAAwC,IAAI;AAEvE,SAAS,WAAW;AAClB,QAAM,UAAgB,iBAAW,YAAY;AAE7C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,mDAAmD;AAAA,EACrE;AAEA,SAAO;AACT;AAcA,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAKG;AACD,QAAM,WAAiB,YAAM;AAC7B,QAAM,UAAU,SAAS,MAAM,SAAS,QAAQ,MAAM,EAAE,CAAC;AAEzD,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,GACrC;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,cAAY;AAAA,MACZ,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,4BAAC,cAAW,IAAI,SAAS,QAAgB;AAAA,QACzC,oBAAmB,uCAAlB,EACE,UACH;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,SAAS,WAAW,EAAE,IAAI,OAAO,GAAwC;AACvE,QAAM,cAAc,OAAO,QAAQ,MAAM,EAAE;AAAA,IACzC,CAAC,C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,UAbR,KAAK;AAAA,QAcZ;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;AAGA,SAAS,4BACP,QACA,SACA,KACA;AACA,MAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,aAAa,WACb,OAAO,QAAQ,YAAY,YAC3B,QAAQ,YAAY,OAChB,QAAQ,UACR;AAEN,MAAI,iBAAyB;AAE7B,MACE,OAAO,WACP,OAAO,QAAQ,GAA2B,MAAM,UAChD;AACA,qBAAiB,QAAQ,GAA2B;AAAA,EACtD,WACE,kBACA,OAAO,kBACP,OAAO,eAAe,GAAkC,MAAM,UAC9D;AACA,qBAAiB,eACf,GACF;AAAA,EACF;AAEA,SAAO,kBAAkB,SACrB,OAAO,cAAc,IACrB,OAAO,GAA0B;AACvC;","names":[]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/components/command/index.tsx
|
|
4
|
+
import {
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogDescription,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle
|
|
10
|
+
} from "@foundrykit/primitives";
|
|
11
|
+
import { cn } from "@foundrykit/utils";
|
|
12
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
13
|
+
import { SearchIcon } from "lucide-react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
function Command({
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
CommandPrimitive,
|
|
21
|
+
{
|
|
22
|
+
"data-slot": "command",
|
|
23
|
+
className: cn(
|
|
24
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
...props
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function CommandDialog({
|
|
32
|
+
title = "Command Palette",
|
|
33
|
+
description = "Search for a command to run...",
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
showCloseButton = true,
|
|
37
|
+
...props
|
|
38
|
+
}) {
|
|
39
|
+
return /* @__PURE__ */ jsxs(Dialog, { ...props, children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(DialogHeader, { className: "sr-only", children: [
|
|
41
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
42
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: description })
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
DialogContent,
|
|
46
|
+
{
|
|
47
|
+
className: cn("overflow-hidden p-0", className),
|
|
48
|
+
showCloseButton,
|
|
49
|
+
children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children })
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
function CommandInput({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}) {
|
|
58
|
+
return /* @__PURE__ */ jsxs(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
"data-slot": "command-input-wrapper",
|
|
62
|
+
className: "flex h-9 items-center gap-2 border-b px-3",
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: "size-4 shrink-0 opacity-50" }),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
CommandPrimitive.Input,
|
|
67
|
+
{
|
|
68
|
+
"data-slot": "command-input",
|
|
69
|
+
className: cn(
|
|
70
|
+
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
71
|
+
className
|
|
72
|
+
),
|
|
73
|
+
...props
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
function CommandList({
|
|
81
|
+
className,
|
|
82
|
+
...props
|
|
83
|
+
}) {
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
CommandPrimitive.List,
|
|
86
|
+
{
|
|
87
|
+
"data-slot": "command-list",
|
|
88
|
+
className: cn(
|
|
89
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
90
|
+
className
|
|
91
|
+
),
|
|
92
|
+
...props
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function CommandEmpty({
|
|
97
|
+
...props
|
|
98
|
+
}) {
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
CommandPrimitive.Empty,
|
|
101
|
+
{
|
|
102
|
+
"data-slot": "command-empty",
|
|
103
|
+
className: "py-6 text-center text-sm",
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function CommandGroup({
|
|
109
|
+
className,
|
|
110
|
+
...props
|
|
111
|
+
}) {
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
CommandPrimitive.Group,
|
|
114
|
+
{
|
|
115
|
+
"data-slot": "command-group",
|
|
116
|
+
className: cn(
|
|
117
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
118
|
+
className
|
|
119
|
+
),
|
|
120
|
+
...props
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function CommandSeparator({
|
|
125
|
+
className,
|
|
126
|
+
...props
|
|
127
|
+
}) {
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
CommandPrimitive.Separator,
|
|
130
|
+
{
|
|
131
|
+
"data-slot": "command-separator",
|
|
132
|
+
className: cn("bg-border -mx-1 h-px", className),
|
|
133
|
+
...props
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function CommandItem({
|
|
138
|
+
className,
|
|
139
|
+
...props
|
|
140
|
+
}) {
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
CommandPrimitive.Item,
|
|
143
|
+
{
|
|
144
|
+
"data-slot": "command-item",
|
|
145
|
+
className: cn(
|
|
146
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
147
|
+
className
|
|
148
|
+
),
|
|
149
|
+
...props
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function CommandShortcut({
|
|
154
|
+
className,
|
|
155
|
+
...props
|
|
156
|
+
}) {
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
"data-slot": "command-shortcut",
|
|
161
|
+
className: cn(
|
|
162
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
163
|
+
className
|
|
164
|
+
),
|
|
165
|
+
...props
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
Command,
|
|
172
|
+
CommandDialog,
|
|
173
|
+
CommandInput,
|
|
174
|
+
CommandList,
|
|
175
|
+
CommandEmpty,
|
|
176
|
+
CommandGroup,
|
|
177
|
+
CommandSeparator,
|
|
178
|
+
CommandItem,
|
|
179
|
+
CommandShortcut
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=chunk-IYBHXVCH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/command/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from '@foundrykit/primitives';\nimport { cn } from '@foundrykit/utils';\nimport { Command as CommandPrimitive } from 'cmdk';\nimport { SearchIcon } from 'lucide-react';\nimport type * as React from 'react';\n\n/** Styled `cmdk` command menu — the root container for a command palette. */\nfunction Command({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n data-slot='command'\n className={cn(\n 'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',\n className\n )}\n {...props}\n />\n );\n}\n\n/**\n * Command menu rendered inside a modal dialog. `title` and `description` are\n * visually hidden but read by assistive technology.\n */\nfunction CommandDialog({\n title = 'Command Palette',\n description = 'Search for a command to run...',\n children,\n className,\n showCloseButton = true,\n ...props\n}: React.ComponentProps<typeof Dialog> & {\n title?: string;\n description?: string;\n className?: string;\n showCloseButton?: boolean;\n}) {\n return (\n <Dialog {...props}>\n <DialogHeader className='sr-only'>\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <DialogContent\n className={cn('overflow-hidden p-0', className)}\n showCloseButton={showCloseButton}\n >\n <Command className='[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5'>\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n}\n\n/** Search input for a command menu, with a leading search icon. */\nfunction CommandInput({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div\n data-slot='command-input-wrapper'\n className='flex h-9 items-center gap-2 border-b px-3'\n >\n <SearchIcon className='size-4 shrink-0 opacity-50' />\n <CommandPrimitive.Input\n data-slot='command-input'\n className={cn(\n 'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',\n className\n )}\n {...props}\n />\n </div>\n );\n}\n\n/** Scrollable list containing command groups and items. */\nfunction CommandList({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n data-slot='command-list'\n className={cn(\n 'max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto',\n className\n )}\n {...props}\n />\n );\n}\n\n/** Message shown when no command items match the current query. */\nfunction CommandEmpty({\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n data-slot='command-empty'\n className='py-6 text-center text-sm'\n {...props}\n />\n );\n}\n\n/** Labelled group of related command items. */\nfunction CommandGroup({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n data-slot='command-group'\n className={cn(\n 'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',\n className\n )}\n {...props}\n />\n );\n}\n\n/** Horizontal divider between command groups or items. */\nfunction CommandSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n data-slot='command-separator'\n className={cn('bg-border -mx-1 h-px', className)}\n {...props}\n />\n );\n}\n\n/** Selectable command item within a {@link CommandList} or {@link CommandGroup}. */\nfunction CommandItem({\n className,\n ...props\n}: React.ComponentProps<typeof CommandPrimitive.Item>) {\n return (\n <CommandPrimitive.Item\n data-slot='command-item'\n className={cn(\n \"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className\n )}\n {...props}\n />\n );\n}\n\n/** Right-aligned keyboard-shortcut hint shown inside a command item. */\nfunction CommandShortcut({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='command-shortcut'\n className={cn(\n 'text-muted-foreground ml-auto text-xs tracking-widest',\n className\n )}\n {...props}\n />\n );\n}\n\nexport {\n Command,\n CommandDialog,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n CommandShortcut,\n};\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,WAAW,wBAAwB;AAC5C,SAAS,kBAAkB;AASvB,cA8BE,YA9BF;AALJ,SAAS,QAAQ;AAAA,EACf;AAAA,EACA,GAAG;AACL,GAAkD;AAChD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF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;AACL,GAAwD;AACtD,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAGA,SAAS,iBAAiB;AAAA,EACxB;AAAA,EACA,GAAG;AACL,GAA4D;AAC1D,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,wBAAwB,SAAS;AAAA,MAC9C,GAAG;AAAA;AAAA,EACN;AAEJ;AAGA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA,GAAG;AACL,GAAuD;AACrD,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAGA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA,GAAG;AACL,GAAiC;AAC/B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/components/input-otp/index.tsx
|
|
4
|
+
import { cn } from "@foundrykit/utils";
|
|
5
|
+
import { OTPInput, OTPInputContext } from "input-otp";
|
|
6
|
+
import { MinusIcon } from "lucide-react";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function InputOTP({
|
|
10
|
+
className,
|
|
11
|
+
containerClassName,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
OTPInput,
|
|
16
|
+
{
|
|
17
|
+
"data-slot": "input-otp",
|
|
18
|
+
containerClassName: cn(
|
|
19
|
+
"flex items-center gap-2 has-disabled:opacity-50",
|
|
20
|
+
containerClassName
|
|
21
|
+
),
|
|
22
|
+
className: cn("disabled:cursor-not-allowed", className),
|
|
23
|
+
...props
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
function InputOTPGroup({ className, ...props }) {
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
"data-slot": "input-otp-group",
|
|
32
|
+
className: cn("flex items-center", className),
|
|
33
|
+
...props
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function InputOTPSlot({
|
|
38
|
+
index,
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
}) {
|
|
42
|
+
const inputOTPContext = React.useContext(OTPInputContext);
|
|
43
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {};
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
"data-slot": "input-otp-slot",
|
|
48
|
+
"data-active": isActive,
|
|
49
|
+
className: cn(
|
|
50
|
+
"data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",
|
|
51
|
+
className
|
|
52
|
+
),
|
|
53
|
+
...props,
|
|
54
|
+
children: [
|
|
55
|
+
char,
|
|
56
|
+
hasFakeCaret && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "animate-caret-blink bg-foreground h-4 w-px duration-1000" }) })
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
function InputOTPSeparator({ ...props }) {
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "input-otp-separator", role: "separator", ...props, children: /* @__PURE__ */ jsx(MinusIcon, {}) });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
InputOTP,
|
|
67
|
+
InputOTPGroup,
|
|
68
|
+
InputOTPSlot,
|
|
69
|
+
InputOTPSeparator
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=chunk-KQZEF7PS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/input-otp/index.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@foundrykit/utils';\nimport { OTPInput, OTPInputContext } from 'input-otp';\nimport { MinusIcon } from 'lucide-react';\nimport * as React from 'react';\n\n/**\n * Accessible one-time-password input with individually styled character slots.\n *\n * @example\n * ```tsx\n * <InputOTP maxLength={6}>\n * <InputOTPGroup>\n * <InputOTPSlot index={0} />\n * <InputOTPSlot index={1} />\n * </InputOTPGroup>\n * </InputOTP>\n * ```\n */\nfunction InputOTP({\n className,\n containerClassName,\n ...props\n}: React.ComponentProps<typeof OTPInput> & {\n containerClassName?: string;\n}) {\n return (\n <OTPInput\n data-slot='input-otp'\n containerClassName={cn(\n 'flex items-center gap-2 has-disabled:opacity-50',\n containerClassName\n )}\n className={cn('disabled:cursor-not-allowed', className)}\n {...props}\n />\n );\n}\n\n/** Groups related OTP slots together with a shared border. */\nfunction InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='input-otp-group'\n className={cn('flex items-center', className)}\n {...props}\n />\n );\n}\n\n/** A single character slot, driven by the OTP input context. */\nfunction InputOTPSlot({\n index,\n className,\n ...props\n}: React.ComponentProps<'div'> & {\n index: number;\n}) {\n const inputOTPContext = React.useContext(OTPInputContext);\n const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {};\n\n return (\n <div\n data-slot='input-otp-slot'\n data-active={isActive}\n className={cn(\n 'data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]',\n className\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className='pointer-events-none absolute inset-0 flex items-center justify-center'>\n <div className='animate-caret-blink bg-foreground h-4 w-px duration-1000' />\n </div>\n )}\n </div>\n );\n}\n\n/** Visual separator rendered between OTP groups. */\nfunction InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {\n return (\n <div data-slot='input-otp-separator' role='separator' {...props}>\n <MinusIcon />\n </div>\n );\n}\n\nexport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot };\n"],"mappings":";;;AAEA,SAAS,UAAU;AACnB,SAAS,UAAU,uBAAuB;AAC1C,SAAS,iBAAiB;AAC1B,YAAY,WAAW;AAuBnB,cAmCA,YAnCA;AARJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,oBAAoB;AAAA,QAClB;AAAA,QACA;AAAA,MACF;AAAA,MACA,WAAW,GAAG,+BAA+B,SAAS;AAAA,MACrD,GAAG;AAAA;AAAA,EACN;AAEJ;AAGA,SAAS,cAAc,EAAE,WAAW,GAAG,MAAM,GAAgC;AAC3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,qBAAqB,SAAS;AAAA,MAC3C,GAAG;AAAA;AAAA,EACN;AAEJ;AAGA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,QAAM,kBAAwB,iBAAW,eAAe;AACxD,QAAM,EAAE,MAAM,cAAc,SAAS,IAAI,iBAAiB,MAAM,KAAK,KAAK,CAAC;AAE3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,eAAa;AAAA,MACb,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,QACA,gBACC,oBAAC,SAAI,WAAU,yEACb,8BAAC,SAAI,WAAU,4DAA2D,GAC5E;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAGA,SAAS,kBAAkB,EAAE,GAAG,MAAM,GAAgC;AACpE,SACE,oBAAC,SAAI,aAAU,uBAAsB,MAAK,aAAa,GAAG,OACxD,8BAAC,aAAU,GACb;AAEJ;","names":[]}
|