@omnifyjp/ui 1.0.0 → 1.0.2

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.
@@ -1,239 +0,0 @@
1
- import { cn } from './chunk-DGPY4WP3.js';
2
- import * as React from 'react';
3
- import * as RechartsPrimitive from 'recharts';
4
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
-
6
- var THEMES = { light: "", dark: ".dark" };
7
- var ChartContext = React.createContext(null);
8
- function useChart() {
9
- const context = React.useContext(ChartContext);
10
- if (!context) {
11
- throw new Error("useChart must be used within a <ChartContainer />");
12
- }
13
- return context;
14
- }
15
- function ChartContainer({
16
- id,
17
- className,
18
- children,
19
- config,
20
- ...props
21
- }) {
22
- const uniqueId = React.useId();
23
- const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
24
- return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
25
- "div",
26
- {
27
- "data-slot": "chart",
28
- "data-chart": chartId,
29
- className: cn(
30
- "[&_.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",
31
- className
32
- ),
33
- ...props,
34
- children: [
35
- /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
36
- /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
37
- ]
38
- }
39
- ) });
40
- }
41
- var ChartStyle = ({ id, config }) => {
42
- const colorConfig = Object.entries(config).filter(
43
- ([, config2]) => config2.theme || config2.color
44
- );
45
- if (!colorConfig.length) {
46
- return null;
47
- }
48
- return /* @__PURE__ */ jsx(
49
- "style",
50
- {
51
- dangerouslySetInnerHTML: {
52
- __html: Object.entries(THEMES).map(
53
- ([theme, prefix]) => `
54
- ${prefix} [data-chart=${id}] {
55
- ${colorConfig.map(([key, itemConfig]) => {
56
- const color = itemConfig.theme?.[theme] || itemConfig.color;
57
- return color ? ` --color-${key}: ${color};` : null;
58
- }).join("\n")}
59
- }
60
- `
61
- ).join("\n")
62
- }
63
- }
64
- );
65
- };
66
- var ChartTooltip = RechartsPrimitive.Tooltip;
67
- function ChartTooltipContent({
68
- active,
69
- payload,
70
- className,
71
- indicator = "dot",
72
- hideLabel = false,
73
- hideIndicator = false,
74
- label,
75
- labelFormatter,
76
- labelClassName,
77
- formatter,
78
- color,
79
- nameKey,
80
- labelKey
81
- }) {
82
- const { config } = useChart();
83
- const tooltipLabel = React.useMemo(() => {
84
- if (hideLabel || !payload?.length) {
85
- return null;
86
- }
87
- const [item] = payload;
88
- const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
89
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
90
- const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
91
- if (labelFormatter) {
92
- return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
93
- }
94
- if (!value) {
95
- return null;
96
- }
97
- return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
98
- }, [
99
- label,
100
- labelFormatter,
101
- payload,
102
- hideLabel,
103
- labelClassName,
104
- config,
105
- labelKey
106
- ]);
107
- if (!active || !payload?.length) {
108
- return null;
109
- }
110
- const nestLabel = payload.length === 1 && indicator !== "dot";
111
- return /* @__PURE__ */ jsxs(
112
- "div",
113
- {
114
- className: cn(
115
- "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",
116
- className
117
- ),
118
- children: [
119
- !nestLabel ? tooltipLabel : null,
120
- /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
121
- const key = `${nameKey || item.name || item.dataKey || "value"}`;
122
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
123
- const indicatorColor = color || item.payload?.fill || item.color;
124
- return /* @__PURE__ */ jsx(
125
- "div",
126
- {
127
- className: cn(
128
- "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
129
- indicator === "dot" && "items-center"
130
- ),
131
- children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
132
- itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
133
- "div",
134
- {
135
- className: cn(
136
- "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
137
- {
138
- "h-2.5 w-2.5": indicator === "dot",
139
- "w-1": indicator === "line",
140
- "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
141
- "my-0.5": nestLabel && indicator === "dashed"
142
- }
143
- ),
144
- style: {
145
- "--color-bg": indicatorColor,
146
- "--color-border": indicatorColor
147
- }
148
- }
149
- ),
150
- /* @__PURE__ */ jsxs(
151
- "div",
152
- {
153
- className: cn(
154
- "flex flex-1 justify-between leading-none",
155
- nestLabel ? "items-end" : "items-center"
156
- ),
157
- children: [
158
- /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
159
- nestLabel ? tooltipLabel : null,
160
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
161
- ] }),
162
- item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
163
- ]
164
- }
165
- )
166
- ] })
167
- },
168
- item.dataKey
169
- );
170
- }) })
171
- ]
172
- }
173
- );
174
- }
175
- var ChartLegend = RechartsPrimitive.Legend;
176
- function ChartLegendContent({
177
- className,
178
- hideIcon = false,
179
- payload,
180
- verticalAlign = "bottom",
181
- nameKey
182
- }) {
183
- const { config } = useChart();
184
- if (!payload?.length) {
185
- return null;
186
- }
187
- return /* @__PURE__ */ jsx(
188
- "div",
189
- {
190
- className: cn(
191
- "flex items-center justify-center gap-4",
192
- verticalAlign === "top" ? "pb-3" : "pt-3",
193
- className
194
- ),
195
- children: payload.map((item) => {
196
- const key = `${nameKey || item.dataKey || "value"}`;
197
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
198
- return /* @__PURE__ */ jsxs(
199
- "div",
200
- {
201
- className: cn(
202
- "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
203
- ),
204
- children: [
205
- itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
206
- "div",
207
- {
208
- className: "h-2 w-2 shrink-0 rounded-[2px]",
209
- style: {
210
- backgroundColor: item.color
211
- }
212
- }
213
- ),
214
- itemConfig?.label
215
- ]
216
- },
217
- item.value
218
- );
219
- })
220
- }
221
- );
222
- }
223
- function getPayloadConfigFromPayload(config, payload, key) {
224
- if (typeof payload !== "object" || payload === null) {
225
- return void 0;
226
- }
227
- const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
228
- let configLabelKey = key;
229
- if (key in payload && typeof payload[key] === "string") {
230
- configLabelKey = payload[key];
231
- } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
232
- configLabelKey = payloadPayload[key];
233
- }
234
- return configLabelKey in config ? config[configLabelKey] : config[key];
235
- }
236
-
237
- export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
238
- //# sourceMappingURL=chunk-DNCZOUNY.js.map
239
- //# sour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AAA,KAAY,QAAA,IAC3B,OAAA,CAAQ,OAAA,KAAY,IAAA,GAChB,OAAA,CAAQ,OAAA,GACR,MAAA;AAEN,EAAA,IAAI,cAAA,GAAyB,GAAA;AAE7B,EAAA,IACE,OAAO,OAAA,IACP,OAAO,OAAA,CAAQ,GAA2B,MAAM,QAAA,EAChD;AACA,IAAA,cAAA,GAAiB,QAAQ,GAA2B,CAAA;AAAA,EACtD,CAAA,MAAA,IACE,kBACA,GAAA,IAAO,cAAA,IACP,OAAO,cAAA,CAAe,GAAkC,MAAM,QAAA,EAC9D;AACA,IAAA,cAAA,GAAiB,eACf,GACF,CAAA;AAAA,EACF;AAEA,EAAA,OAAO,kBAAkB,MAAA,GACrB,MAAA,CAAO,cAAc,CAAA,GACrB,OAAO,GAA0B,CAAA;AACvC","file":"chunk-DNCZOUNY.js","sourcesContent":["import * as React from \"react\";\nimport * as RechartsPrimitive from \"recharts\";\n\nimport { cn } from \"../lib/utils\";\n\n// Format: { THEME_NAME: CSS_SELECTOR }\nconst THEMES = { light: \"\", dark: \".dark\" } as const;\n\n/**\n * Configuration object for chart data series. Each key maps to a data series\n * and defines its label, optional icon, and color (either a single color or\n * per-theme colors).\n *\n * @example\n * ```tsx\n * const config: ChartConfig = {\n * revenue: { label: \"Revenue\", color: \"var(--color-blue-500)\" },\n * expenses: { label: \"Expenses\", theme: { light: \"#ef4444\", dark: \"#f87171\" } },\n * };\n * ```\n */\nexport type ChartConfig = {\n [k in string]: {\n /** Display label for this data series. */\n label?: React.ReactNode;\n /** Optional icon component displayed in the legend. */\n icon?: React.ComponentType;\n } & (\n | { /** Single color used across all themes. */ color?: string; theme?: never }\n | { color?: never; /** Per-theme color mapping (light/dark). */ theme: Record<keyof typeof THEMES, string> }\n );\n};\n\ntype ChartContextProps = {\n config: ChartConfig;\n};\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null);\n\n/**\n * Hook to access the chart configuration from the nearest ChartContainer.\n * Must be used within a {@link ChartContainer}.\n *\n * @throws If used outside of a ChartContainer.\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 * Wrapper that provides chart configuration context, injects theme-aware CSS\n * custom properties for data series colors, and renders a Recharts\n * `ResponsiveContainer`.\n *\n * @param config - Chart configuration mapping data keys to labels, icons, and colors.\n *\n * @example\n * ```tsx\n * <ChartContainer config={{ revenue: { label: \"Revenue\", color: \"#3b82f6\" } }}>\n * <BarChart data={data}>\n * <Bar dataKey=\"revenue\" fill=\"var(--color-revenue)\" />\n * </BarChart>\n * </ChartContainer>\n * ```\n */\nfunction ChartContainer({\n id,\n className,\n children,\n config,\n ...props\n}: React.ComponentProps<\"div\"> & {\n /** Chart configuration mapping data keys to labels, icons, and colors. */\n config: ChartConfig;\n /** Recharts chart element (e.g. BarChart, LineChart). */\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\n/** Injects a `<style>` tag with CSS custom properties for chart colors, scoped to the chart container. */\nconst ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {\n const colorConfig = Object.entries(config).filter(\n ([, config]) => config.theme || config.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\n/** Re-export of Recharts Tooltip for use with ChartTooltipContent. */\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\n/**\n * Styled tooltip content for use inside `<ChartTooltip content={<ChartTooltipContent />} />`.\n * Renders data series with color indicators, labels from ChartConfig, and formatted values.\n *\n * @param indicator - Shape of the color indicator: `\"dot\"`, `\"line\"`, or `\"dashed\"`.\n * @param hideLabel - Whether to hide the tooltip header label.\n * @param hideIndicator - Whether to hide the color indicator.\n * @param nameKey - Data key to resolve series name from the payload.\n * @param labelKey - Data key to resolve the tooltip header label from config.\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<\"div\"> & {\n active?: boolean;\n payload?: Array<{\n name?: string;\n value?: string | number;\n dataKey?: string;\n color?: string;\n fill?: string;\n payload?: Record<string, unknown>;\n [key: string]: unknown;\n }>;\n label?: string;\n labelClassName?: string;\n labelFormatter?: (label: unknown, payload: Array<Record<string, unknown>>) => React.ReactNode;\n formatter?: (value: unknown, name: string, item: Record<string, unknown>, index: number, payload: unknown) => React.ReactNode;\n color?: string;\n /** Whether to hide the tooltip header label. */\n hideLabel?: boolean;\n /** Whether to hide the color indicator next to each series. */\n hideIndicator?: boolean;\n /** Shape of the color indicator. Defaults to `\"dot\"`. */\n indicator?: \"line\" | \"dot\" | \"dashed\";\n /** Data key used to resolve the series name from payload. */\n nameKey?: string;\n /** Data key used to resolve the header label from config. */\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 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 as string) || 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\n/** Re-export of Recharts Legend for use with ChartLegendContent. */\nconst ChartLegend = RechartsPrimitive.Legend;\n\n/**\n * Styled legend content for use inside `<ChartLegend content={<ChartLegendContent />} />`.\n * Renders a horizontal list of series labels with color indicators or custom icons from ChartConfig.\n *\n * @param hideIcon - Whether to hide the color dot / custom icon.\n * @param nameKey - Data key to resolve the series name from payload.\n */\nfunction ChartLegendContent({\n className,\n hideIcon = false,\n payload,\n verticalAlign = \"bottom\",\n nameKey,\n}: React.ComponentProps<\"div\"> & {\n payload?: Array<{\n value?: string;\n dataKey?: string;\n color?: string;\n [key: string]: unknown;\n }>;\n verticalAlign?: \"top\" | \"bottom\" | \"middle\";\n /** Whether to hide the color indicator or custom icon. */\n hideIcon?: boolean;\n /** Data key used to resolve the series name from payload. */\n nameKey?: string;\n }) {\n const { config } = useChart();\n\n if (!payload?.length) {\n return null;\n }\n\n return (\n <div\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={{\n backgroundColor: item.color,\n }}\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 ChartTooltip,\n ChartTooltipContent,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n};"]}
@@ -1,90 +0,0 @@
1
- import { Popover, PopoverTrigger, PopoverContent } from './chunk-C34KSTWA.js';
2
- import { Calendar as Calendar$1 } from './chunk-QB3UWRZH.js';
3
- import { Button } from './chunk-55E7D2HR.js';
4
- import { cn } from './chunk-DGPY4WP3.js';
5
- import { format } from 'date-fns';
6
- import { Calendar } from 'lucide-react';
7
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
-
9
- function DatePicker({
10
- value,
11
- onChange,
12
- placeholder = "Select date",
13
- className,
14
- disabled,
15
- locale
16
- }) {
17
- return /* @__PURE__ */ jsxs(Popover, { children: [
18
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
19
- Button,
20
- {
21
- variant: "outline",
22
- disabled,
23
- className: cn(
24
- "w-full justify-start text-left font-normal",
25
- !value && "text-muted-foreground",
26
- className
27
- ),
28
- children: [
29
- /* @__PURE__ */ jsx(Calendar, { className: "mr-2 h-4 w-4" }),
30
- value ? format(value, "PPP", locale ? { locale } : void 0) : /* @__PURE__ */ jsx("span", { children: placeholder })
31
- ]
32
- }
33
- ) }),
34
- /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
35
- Calendar$1,
36
- {
37
- mode: "single",
38
- selected: value,
39
- onSelect: onChange,
40
- autoFocus: true
41
- }
42
- ) })
43
- ] });
44
- }
45
- function DateRangePicker({
46
- value,
47
- onChange,
48
- placeholder = "Select date range",
49
- className,
50
- disabled,
51
- locale
52
- }) {
53
- return /* @__PURE__ */ jsxs(Popover, { children: [
54
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
55
- Button,
56
- {
57
- variant: "outline",
58
- disabled,
59
- className: cn(
60
- "w-full justify-start text-left font-normal",
61
- !value && "text-muted-foreground",
62
- className
63
- ),
64
- children: [
65
- /* @__PURE__ */ jsx(Calendar, { className: "mr-2 h-4 w-4" }),
66
- value?.from ? value.to ? /* @__PURE__ */ jsxs(Fragment, { children: [
67
- format(value.from, "PPP", locale ? { locale } : void 0),
68
- " -",
69
- " ",
70
- format(value.to, "PPP", locale ? { locale } : void 0)
71
- ] }) : format(value.from, "PPP", locale ? { locale } : void 0) : /* @__PURE__ */ jsx("span", { children: placeholder })
72
- ]
73
- }
74
- ) }),
75
- /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
76
- Calendar$1,
77
- {
78
- mode: "range",
79
- selected: value,
80
- onSelect: onChange,
81
- numberOfMonths: 2,
82
- autoFocus: true
83
- }
84
- ) })
85
- ] });
86
- }
87
-
88
- export { DatePicker, DateRangePicker };
89
- //# sourceMappingURL=chunk-HWTW64R5.js.map
90
- //# sourceMappingURL=chunk-HWTW64R5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/date-picker.tsx"],"names":["CalendarIcon","Calendar"],"mappings":";;;;;;;;AAuCO,SAAS,UAAA,CAAW;AAAA,EACzB,KAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA,GAAc,aAAA;AAAA,EACd,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAoB;AAClB,EAAA,4BACG,OAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,cAAA,EAAA,EAAe,SAAO,IAAA,EACrB,QAAA,kBAAA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAQ,SAAA;AAAA,QACR,QAAA;AAAA,QACA,SAAA,EAAW,EAAA;AAAA,UACT,4CAAA;AAAA,UACA,CAAC,KAAA,IAAS,uBAAA;AAAA,UACV;AAAA,SACF;AAAA,QAEA,QAAA,EAAA;AAAA,0BAAA,GAAA,CAACA,QAAA,EAAA,EAAa,WAAU,cAAA,EAAe,CAAA;AAAA,UACtC,KAAA,GAAQ,MAAA,CAAO,KAAA,EAAO,KAAA,EAAO,MAAA,GAAS,EAAE,MAAA,EAAO,GAAI,MAAS,CAAA,mBAAI,GAAA,CAAC,MAAA,EAAA,EAAM,QAAA,EAAA,WAAA,EAAY;AAAA;AAAA;AAAA,KACtF,EACF,CAAA;AAAA,oBACA,GAAA,CAAC,cAAA,EAAA,EAAe,SAAA,EAAU,YAAA,EAAa,OAAM,OAAA,EAC3C,QAAA,kBAAA,GAAA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,EAAY;AAAA;AAAA;AAAA,KAEvB,EACF,CAAA;AAAA,oBACA,GAAA,CAAC,cAAA,EAAA,EAAe,SAAA,EAAU,YAAA,EAAa,OAAM,OAAA,EAC3C,QAAA,kBAAA,GAAA;AAAA,MAACC,UAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,OAAA;AAAA,QACL,QAAA,EAAU,KAAA;AAAA,QACV,QAAA,EAAU,QAAA;AAAA,QACV,cAAA,EAAgB,CAAA;AAAA,QAChB,SAAA,EAAS;AAAA;AAAA,KACX,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-HWTW64R5.js","sourcesContent":["import { format } from \"date-fns\";\nimport { Calendar as CalendarIcon } from \"lucide-react\";\nimport type { Locale } from \"date-fns\";\n\nimport { cn } from \"../lib/utils\";\nimport { Button } from \"./button\";\nimport { Calendar } from \"./calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\n\ninterface DatePickerProps {\n /** Currently selected date. */\n value?: Date;\n /** Callback fired when a date is selected or cleared. */\n onChange?: (date: Date | undefined) => void;\n /** Placeholder text shown when no date is selected. */\n placeholder?: string;\n /** Additional CSS class for the trigger button. */\n className?: string;\n /** Whether the date picker is disabled. */\n disabled?: boolean;\n /** date-fns Locale object for date formatting (e.g., `ja` for Japanese). */\n locale?: Locale;\n}\n\n/**\n * Single date picker with a calendar popover.\n * Displays the selected date formatted with date-fns and opens a calendar on click.\n *\n * @example\n * ```tsx\n * const [date, setDate] = useState<Date>();\n *\n * <DatePicker\n * value={date}\n * onChange={setDate}\n * placeholder=\"Pick a date\"\n * />\n * ```\n */\nexport function DatePicker({\n value,\n onChange,\n placeholder = \"Select date\",\n className,\n disabled,\n locale,\n}: DatePickerProps) {\n return (\n <Popover>\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n disabled={disabled}\n className={cn(\n \"w-full justify-start text-left font-normal\",\n !value && \"text-muted-foreground\",\n className\n )}\n >\n <CalendarIcon className=\"mr-2 h-4 w-4\" />\n {value ? format(value, \"PPP\", locale ? { locale } : undefined) : <span>{placeholder}</span>}\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <Calendar\n mode=\"single\"\n selected={value}\n onSelect={onChange}\n autoFocus\n />\n </PopoverContent>\n </Popover>\n );\n}\n\ninterface DateRangePickerProps {\n /** Currently selected date range with `from` and optional `to`. */\n value?: { from: Date | undefined; to?: Date | undefined };\n /** Callback fired when the date range changes. */\n onChange?: (range: { from: Date | undefined; to?: Date | undefined } | undefined) => void;\n /** Placeholder text shown when no range is selected. */\n placeholder?: string;\n /** Additional CSS class for the trigger button. */\n className?: string;\n /** Whether the date range picker is disabled. */\n disabled?: boolean;\n /** date-fns Locale object for date formatting (e.g., `ja` for Japanese). */\n locale?: Locale;\n}\n\n/**\n * Date range picker with a two-month calendar popover.\n * Allows selecting a start and end date displayed as a range string.\n *\n * @example\n * ```tsx\n * const [range, setRange] = useState<{ from: Date | undefined; to?: Date }>();\n *\n * <DateRangePicker\n * value={range}\n * onChange={setRange}\n * placeholder=\"Select date range\"\n * />\n * ```\n */\nexport function DateRangePicker({\n value,\n onChange,\n placeholder = \"Select date range\",\n className,\n disabled,\n locale,\n}: DateRangePickerProps) {\n return (\n <Popover>\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n disabled={disabled}\n className={cn(\n \"w-full justify-start text-left font-normal\",\n !value && \"text-muted-foreground\",\n className\n )}\n >\n <CalendarIcon className=\"mr-2 h-4 w-4\" />\n {value?.from ? (\n value.to ? (\n <>\n {format(value.from, \"PPP\", locale ? { locale } : undefined)} -{\" \"}\n {format(value.to, \"PPP\", locale ? { locale } : undefined)}\n </>\n ) : (\n format(value.from, \"PPP\", locale ? { locale } : undefined)\n )\n ) : (\n <span>{placeholder}</span>\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <Calendar\n mode=\"range\"\n selected={value}\n onSelect={onChange}\n numberOfMonths={2}\n autoFocus\n />\n </PopoverContent>\n </Popover>\n );\n}\n"]}
@@ -1,93 +0,0 @@
1
- import { Checkbox } from './chunk-WL4ZO2H3.js';
2
- import { Separator } from './chunk-PGWNOZDX.js';
3
- import { cn } from './chunk-DGPY4WP3.js';
4
- import { useMemo } from 'react';
5
- import { startOfMonth, endOfMonth, startOfWeek, endOfWeek, eachDayOfInterval, format, isSameMonth, isSameDay, isToday } from 'date-fns';
6
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
-
8
- var defaultLabels = {
9
- sun: "Sun",
10
- mon: "Mon",
11
- tue: "Tue",
12
- wed: "Wed",
13
- thu: "Thu",
14
- fri: "Fri",
15
- sat: "Sat",
16
- categories: "Categories"
17
- };
18
- function CalendarMini({
19
- currentDate,
20
- selectedDate,
21
- onSelectDate,
22
- categories,
23
- enabledCategories,
24
- onToggleCategory,
25
- labels: labelsProp
26
- }) {
27
- const labels = { ...defaultLabels, ...labelsProp };
28
- const days = useMemo(() => {
29
- const monthStart = startOfMonth(currentDate);
30
- const monthEnd = endOfMonth(currentDate);
31
- const calStart = startOfWeek(monthStart, { weekStartsOn: 0 });
32
- const calEnd = endOfWeek(monthEnd, { weekStartsOn: 0 });
33
- return eachDayOfInterval({ start: calStart, end: calEnd });
34
- }, [currentDate]);
35
- const weekDays = [labels.sun, labels.mon, labels.tue, labels.wed, labels.thu, labels.fri, labels.sat];
36
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
37
- /* @__PURE__ */ jsxs("div", { children: [
38
- /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold mb-2", children: format(currentDate, "MMMM yyyy") }),
39
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-7 gap-0", children: [
40
- weekDays.map((day) => /* @__PURE__ */ jsx("div", { className: "text-center text-[10px] font-medium text-muted-foreground py-1", children: day }, day)),
41
- days.map((day) => {
42
- const inMonth = isSameMonth(day, currentDate);
43
- const selected = isSameDay(day, selectedDate);
44
- const today = isToday(day);
45
- return /* @__PURE__ */ jsx(
46
- "button",
47
- {
48
- type: "button",
49
- onClick: () => onSelectDate(day),
50
- className: cn(
51
- "w-7 h-7 text-[11px] rounded-full flex items-center justify-center transition-colors",
52
- !inMonth && "text-muted-foreground/40",
53
- inMonth && !selected && "hover:bg-accent",
54
- selected && "bg-primary text-primary-foreground",
55
- today && !selected && "font-bold text-primary"
56
- ),
57
- children: format(day, "d")
58
- },
59
- day.toISOString()
60
- );
61
- })
62
- ] })
63
- ] }),
64
- categories && categories.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
65
- /* @__PURE__ */ jsx(Separator, {}),
66
- /* @__PURE__ */ jsxs("div", { children: [
67
- /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold mb-2", children: labels.categories }),
68
- /* @__PURE__ */ jsx("div", { className: "space-y-1.5", children: categories.map((cat) => /* @__PURE__ */ jsxs(
69
- "label",
70
- {
71
- className: "flex items-center gap-2 py-1 px-1 rounded hover:bg-accent transition-colors cursor-pointer",
72
- children: [
73
- /* @__PURE__ */ jsx(
74
- Checkbox,
75
- {
76
- checked: enabledCategories?.includes(cat.key) ?? false,
77
- onCheckedChange: () => onToggleCategory?.(cat.key)
78
- }
79
- ),
80
- /* @__PURE__ */ jsx("div", { className: "w-2.5 h-2.5 rounded-full", style: { backgroundColor: cat.color } }),
81
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: cat.label })
82
- ]
83
- },
84
- cat.key
85
- )) })
86
- ] })
87
- ] })
88
- ] });
89
- }
90
-
91
- export { CalendarMini };
92
- //# sourceMappingURL=chunk-KTBOZ4NE.js.map
93
- //# sourceMappingURL=chunk-KTBOZ4NE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/calendar-mini.tsx"],"names":[],"mappings":";;;;;;;AAuCA,IAAM,aAAA,GAA8C;AAAA,EAClD,GAAA,EAAK,KAAA;AAAA,EAAO,GAAA,EAAK,KAAA;AAAA,EAAO,GAAA,EAAK,KAAA;AAAA,EAAO,G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A,EAAE,SAAA,EAAU,4BAAA,EAA8B,QAAA,EAAA,MAAA,CAAO,UAAA,EAAW,CAAA;AAAA,4BAC5D,KAAA,EAAA,EAAI,SAAA,EAAU,aAAA,EACZ,QAAA,EAAA,UAAA,CAAW,IAAI,CAAA,GAAA,qBACd,IAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YAEC,SAAA,EAAU,4FAAA;AAAA,YAEV,QAAA,EAAA;AAAA,8BAAA,GAAA;AAAA,gBAAC,QAAA;AAAA,gBAAA;AAAA,kBACC,OAAA,EAAS,iBAAA,EAAmB,QAAA,CAAS,GAAA,CAAI,GAAG,CAAA,IAAK,KAAA;AAAA,kBACjD,eAAA,EAAiB,MAAM,gBAAA,GAAmB,GAAA,CAAI,GAAG;AAAA;AAAA,eACnD;AAAA,8BACA,GAAA,CAAC,SAAI,SAAA,EAAU,0BAAA,EAA2B,OAAO,EAAE,eAAA,EAAiB,GAAA,CAAI,KAAA,EAAM,EAAG,CAAA;AAAA,8BACjF,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAW,cAAI,KAAA,EAAM;AAAA;AAAA,WAAA;AAAA,UARhC,GAAA,CAAI;AAAA,SAUZ,CAAA,EACH;AAAA,OAAA,EACF;AAAA,KAAA,EACF;AAAA,GAAA,EAEJ,CAAA;AAEJ","file":"chunk-KTBOZ4NE.js","sourcesContent":["import { useMemo } from 'react';\nimport {\n startOfMonth, endOfMonth, startOfWeek, endOfWeek,\n eachDayOfInterval, isSameMonth, isSameDay, isToday, format,\n} from 'date-fns';\nimport { cn } from '../lib/utils';\nimport { Checkbox } from './checkbox';\nimport { Separator } from './separator';\n\n/** A category that can be toggled on/off in the mini calendar's filter section. */\nexport interface CalendarCategory {\n /** Unique key for this category. */\n key: string;\n /** CSS color string used for the category dot. */\n color: string;\n /** Display label for the category. */\n label: string;\n}\n\n/** Localizable labels for the mini calendar. All have English defaults. */\nexport interface CalendarMiniLabels {\n /** Label for Sunday column header. */\n sun?: string;\n /** Label for Monday column header. */\n mon?: string;\n /** Label for Tuesday column header. */\n tue?: string;\n /** Label for Wednesday column header. */\n wed?: string;\n /** Label for Thursday column header. */\n thu?: string;\n /** Label for Friday column header. */\n fri?: string;\n /** Label for Saturday column header. */\n sat?: string;\n /** Heading text for the categories filter section. */\n categories?: string;\n}\n\nconst defaultLabels: Required<CalendarMiniLabels> = {\n sun: 'Sun', mon: 'Mon', tue: 'Tue', wed: 'Wed', thu: 'Thu', fri: 'Fri', sat: 'Sat',\n categories: 'Categories',\n};\n\nexport interface CalendarMiniProps {\n /** The month to display (any date within the target month). */\n currentDate: Date;\n /** The currently selected date, highlighted with primary color. */\n selectedDate: Date;\n /** Callback when a day cell is clicked. */\n onSelectDate: (date: Date) => void;\n /** Optional list of event categories for the filter section. */\n categories?: CalendarCategory[];\n /** Keys of currently enabled categories. */\n enabledCategories?: string[];\n /** Callback when a category checkbox is toggled. */\n onToggleCategory?: (key: string) => void;\n /** Localizable UI labels with English defaults. */\n labels?: CalendarMiniLabels;\n}\n\n/**\n * Compact month calendar with optional category filters. Designed for sidebar\n * placement in calendar views. Locale-agnostic via the `labels` prop.\n *\n * @example\n * ```tsx\n * <CalendarMini\n * currentDate={new Date()}\n * selectedDate={selectedDate}\n * onSelectDate={setSelectedDate}\n * categories={[{ key: \"meeting\", color: \"#3b82f6\", label: \"Meeting\" }]}\n * enabledCategories={[\"meeting\"]}\n * onToggleCategory={(key) => toggle(key)}\n * />\n * ```\n */\nexport function CalendarMini({\n currentDate,\n selectedDate,\n onSelectDate,\n categories,\n enabledCategories,\n onToggleCategory,\n labels: labelsProp,\n}: CalendarMiniProps) {\n const labels = { ...defaultLabels, ...labelsProp };\n\n const days = useMemo(() => {\n const monthStart = startOfMonth(currentDate);\n const monthEnd = endOfMonth(currentDate);\n const calStart = startOfWeek(monthStart, { weekStartsOn: 0 });\n const calEnd = endOfWeek(monthEnd, { weekStartsOn: 0 });\n return eachDayOfInterval({ start: calStart, end: calEnd });\n }, [currentDate]);\n\n const weekDays = [labels.sun, labels.mon, labels.tue, labels.wed, labels.thu, labels.fri, labels.sat];\n\n return (\n <div className=\"space-y-4\">\n {/* Mini calendar */}\n <div>\n <p className=\"text-sm font-semibold mb-2\">{format(currentDate, 'MMMM yyyy')}</p>\n <div className=\"grid grid-cols-7 gap-0\">\n {weekDays.map(day => (\n <div key={day} className=\"text-center text-[10px] font-medium text-muted-foreground py-1\">\n {day}\n </div>\n ))}\n {days.map(day => {\n const inMonth = isSameMonth(day, currentDate);\n const selected = isSameDay(day, selectedDate);\n const today = isToday(day);\n return (\n <button\n key={day.toISOString()}\n type=\"button\"\n onClick={() => onSelectDate(day)}\n className={cn(\n 'w-7 h-7 text-[11px] rounded-full flex items-center justify-center transition-colors',\n !inMonth && 'text-muted-foreground/40',\n inMonth && !selected && 'hover:bg-accent',\n selected && 'bg-primary text-primary-foreground',\n today && !selected && 'font-bold text-primary',\n )}\n >\n {format(day, 'd')}\n </button>\n );\n })}\n </div>\n </div>\n\n {categories && categories.length > 0 && (\n <>\n <Separator />\n {/* Category filters */}\n <div>\n <p className=\"text-sm font-semibold mb-2\">{labels.categories}</p>\n <div className=\"space-y-1.5\">\n {categories.map(cat => (\n <label\n key={cat.key}\n className=\"flex items-center gap-2 py-1 px-1 rounded hover:bg-accent transition-colors cursor-pointer\"\n >\n <Checkbox\n checked={enabledCategories?.includes(cat.key) ?? false}\n onCheckedChange={() => onToggleCategory?.(cat.key)}\n />\n <div className=\"w-2.5 h-2.5 rounded-full\" style={{ backgroundColor: cat.color }} />\n <span className=\"text-sm\">{cat.label}</span>\n </label>\n ))}\n </div>\n </div>\n </>\n )}\n </div>\n );\n}\n"]}
@@ -1,111 +0,0 @@
1
- import { Label } from './chunk-P3M5TZD2.js';
2
- import { cn } from './chunk-DGPY4WP3.js';
3
- import * as React from 'react';
4
- import { Slot } from '@radix-ui/react-slot';
5
- import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
6
- import { jsx } from 'react/jsx-runtime';
7
-
8
- var Form = FormProvider;
9
- var FormFieldContext = React.createContext(
10
- {}
11
- );
12
- var FormField = ({
13
- ...props
14
- }) => {
15
- return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
16
- };
17
- var useFormField = () => {
18
- const fieldContext = React.useContext(FormFieldContext);
19
- const itemContext = React.useContext(FormItemContext);
20
- const { getFieldState } = useFormContext();
21
- const formState = useFormState({ name: fieldContext.name });
22
- const fieldState = getFieldState(fieldContext.name, formState);
23
- if (!fieldContext) {
24
- throw new Error("useFormField should be used within <FormField>");
25
- }
26
- const { id } = itemContext;
27
- return {
28
- id,
29
- name: fieldContext.name,
30
- formItemId: `${id}-form-item`,
31
- formDescriptionId: `${id}-form-item-description`,
32
- formMessageId: `${id}-form-item-message`,
33
- ...fieldState
34
- };
35
- };
36
- var FormItemContext = React.createContext(
37
- {}
38
- );
39
- function FormItem({ className, ...props }) {
40
- const id = React.useId();
41
- return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx(
42
- "div",
43
- {
44
- "data-slot": "form-item",
45
- className: cn("grid gap-2", className),
46
- ...props
47
- }
48
- ) });
49
- }
50
- function FormLabel({
51
- className,
52
- ...props
53
- }) {
54
- const { error, formItemId } = useFormField();
55
- return /* @__PURE__ */ jsx(
56
- Label,
57
- {
58
- "data-slot": "form-label",
59
- "data-error": !!error,
60
- className: cn("data-[error=true]:text-destructive", className),
61
- htmlFor: formItemId,
62
- ...props
63
- }
64
- );
65
- }
66
- function FormControl({ ...props }) {
67
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
68
- return /* @__PURE__ */ jsx(
69
- Slot,
70
- {
71
- "data-slot": "form-control",
72
- id: formItemId,
73
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
74
- "aria-invalid": !!error,
75
- ...props
76
- }
77
- );
78
- }
79
- function FormDescription({ className, ...props }) {
80
- const { formDescriptionId } = useFormField();
81
- return /* @__PURE__ */ jsx(
82
- "p",
83
- {
84
- "data-slot": "form-description",
85
- id: formDescriptionId,
86
- className: cn("text-muted-foreground text-sm", className),
87
- ...props
88
- }
89
- );
90
- }
91
- function FormMessage({ className, ...props }) {
92
- const { error, formMessageId } = useFormField();
93
- const body = error ? String(error?.message ?? "") : props.children;
94
- if (!body) {
95
- return null;
96
- }
97
- return /* @__PURE__ */ jsx(
98
- "p",
99
- {
100
- "data-slot": "form-message",
101
- id: formMessageId,
102
- className: cn("text-destructive text-sm", className),
103
- ...props,
104
- children: body
105
- }
106
- );
107
- }
108
-
109
- export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
110
- //# sourceMappingURL=chunk-LVZNNIK4.js.map
111
- //# sourceMappingURL=chunk-LVZNNIK4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/form.tsx"],"names":[],"mappings":";;;;;;;AA6CA,IAAM,IAAA,GAAO;AASb,IAAM,gBAAA,GAAyB,KAAA,CAAA,aAAA;AAAA,EAC7B;AACF,CAAA;AAGA,IAAM,YAAY,CAGhB;AAAA,EACA,GAAG;AACL,CAAA,KAA4C;AAC1C,EAAA,uBACE,GAAA,CAAC,gBAAA,CAAiB,QAAA,EAAjB,EAA0B,OAAO,EAAE,IAAA,EAAM,KAAA,CAAM,IAAA,EAAK,EACnD,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAY,GAAG,OAAO,CAAA,EACzB,CAAA;AAEJ;AAMA,IAAM,eAAe,MAAM;AACzB,EAAA,MAAM,YAAA,GAAqB,iBAAW,gBAAgB,CAAA;AACtD,EAAA,MAAM,WAAA,GAAoB,iBAAW,eAAe,CAAA;AACpD,EAAA,MAAM,EAAE,aAAA,EAAc,GAAI,cAAA,EAAe;AACzC,EAAA,MAAM,YAAY,YAAA,CAAa,EAAE,IAAA,EAAM,YAAA,CAAa,MAAM,CAAA;AAC1D,EAAA,MAAM,U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C,GAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,EAAA,EAAI,aAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,0BAAA,EAA4B,SAAS,CAAA;AAAA,MAClD,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"chunk-LVZNNIK4.js","sourcesContent":["import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\n\nimport { cn } from \"../lib/utils\";\nimport { Label } from \"./label\";\n\n/**\n * Form provider component built on react-hook-form's FormProvider.\n * Wraps form fields and provides form context for validation, error display, and accessibility.\n *\n * @example\n * ```tsx\n * const form = useForm({ defaultValues: { email: \"\" } });\n *\n * <Form {...form}>\n * <form onSubmit={form.handleSubmit(onSubmit)}>\n * <FormField\n * control={form.control}\n * name=\"email\"\n * render={({ field }) => (\n * <FormItem>\n * <FormLabel>Email</FormLabel>\n * <FormControl>\n * <Input placeholder=\"you@example.com\" {...field} />\n * </FormControl>\n * <FormDescription>Your work email address.</FormDescription>\n * <FormMessage />\n * </FormItem>\n * )}\n * />\n * <Button type=\"submit\">Submit</Button>\n * </form>\n * </Form>\n * ```\n */\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\n/** Connects a form field to react-hook-form's Controller and provides field context. */\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\n/**\n * Hook that returns field state, IDs, and error information for the current form field.\n * Must be used within a `FormField` component.\n */\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\n/** Container for a single form field, grouping label, control, description, and message. */\nfunction FormItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n className={cn(\"grid gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\n/** Label for a form field that turns red on validation error. */\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\n/** Slot wrapper that wires up aria attributes for the form control. */\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n}\n\n/** Helper text displayed below the form control. */\nfunction FormDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n );\n}\n\n/** Displays the validation error message for the form field. */\nfunction FormMessage({ className, ...props }: React.ComponentProps<\"p\">) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? \"\") : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};"]}