@craftzbay/ui 0.11.3 → 0.11.4
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-lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist-lib/components/ui/Accordion.js +42 -67
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +71 -77
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +67 -92
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.js +119 -74
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +62 -50
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +129 -131
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +99 -136
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +88 -94
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +125 -170
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +3 -3
- package/dist-lib/components/ui/Chart.js +435 -464
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +60 -69
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +179 -192
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
- package/dist-lib/components/ui/CommandPalette.js +106 -167
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
- package/dist-lib/components/ui/ContextMenu.js +89 -154
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +1 -1
- package/dist-lib/components/ui/DataGrid.js +99 -96
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +151 -188
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +3 -3
- package/dist-lib/components/ui/Dialog.js +108 -156
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +3 -3
- package/dist-lib/components/ui/Drawer.js +90 -124
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +92 -158
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.js +31 -44
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.js +57 -67
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +113 -107
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +6 -4
- package/dist-lib/components/ui/Form.js +117 -122
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +30 -29
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +61 -63
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +133 -156
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +14 -21
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +176 -208
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +152 -149
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +18 -33
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.js +77 -99
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +51 -80
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.js +22 -29
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +39 -58
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +108 -131
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +18 -24
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +2 -2
- package/dist-lib/components/ui/Sheet.js +77 -129
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +1 -1
- package/dist-lib/components/ui/Sidebar.js +168 -207
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.js +17 -27
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +45 -62
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +75 -55
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +45 -52
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.js +56 -108
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -79
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +108 -169
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +57 -88
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +76 -109
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +74 -86
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.d.ts +3 -3
- package/dist-lib/components/ui/Timeline.js +61 -49
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.d.ts +1 -1
- package/dist-lib/components/ui/Toast.js +136 -150
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +2 -2
- package/dist-lib/components/ui/Tooltip.js +35 -56
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +46 -66
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +134 -168
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.js +27 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +19 -18
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
- package/dist-lib/hooks/use-field-ids.js +14 -16
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.js +15 -19
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.js +20 -15
- package/dist-lib/hooks/use-modifier-key.js.map +1 -1
- package/dist-lib/hooks/use-strings.js +10 -10
- package/dist-lib/hooks/use-strings.js.map +1 -1
- package/dist-lib/hooks/use-toast.js +73 -62
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icon.js +2 -6
- package/dist-lib/icons/index.js +166 -163
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +7 -7
- package/dist-lib/illustrations/index.js +255 -106
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.js +69 -291
- package/dist-lib/lib/cva.js +2 -0
- package/dist-lib/lib/format.js +71 -87
- package/dist-lib/lib/format.js.map +1 -1
- package/dist-lib/lib/return-focus.js +11 -11
- package/dist-lib/lib/return-focus.js.map +1 -1
- package/dist-lib/lib/strings.js +167 -135
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +150 -113
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/lib/utils.js +9 -9
- package/dist-lib/lib/utils.js.map +1 -1
- package/dist-lib/styles.css +3 -1
- package/package.json +50 -50
- package/dist-lib/__tests__/helpers/color.d.ts +0 -9
- package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
- package/dist-lib/icon.js.map +0 -1
- package/dist-lib/index.js.map +0 -1
|
@@ -1,111 +1,78 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
onClick: () => N(t),
|
|
74
|
-
className: "text-foreground-muted hover:bg-background-subtle hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background relative rounded-sm p-0.5 outline-none before:absolute before:-inset-1.5 before:content-[''] focus-visible:ring-2 focus-visible:ring-offset-1",
|
|
75
|
-
"aria-label": L(h.tagInput.remove, { tag: e }),
|
|
76
|
-
children: /* @__PURE__ */ o(G, { className: "size-3", "aria-hidden": !0 })
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
`${e}-${t}`
|
|
82
|
-
)),
|
|
83
|
-
/* @__PURE__ */ o(
|
|
84
|
-
"input",
|
|
85
|
-
{
|
|
86
|
-
id: y,
|
|
87
|
-
value: n,
|
|
88
|
-
disabled: p,
|
|
89
|
-
onChange: (e) => d(e.target.value),
|
|
90
|
-
onKeyDown: X,
|
|
91
|
-
onBlur: () => {
|
|
92
|
-
n && (I(n), d(""));
|
|
93
|
-
},
|
|
94
|
-
placeholder: r.length === 0 ? x : void 0,
|
|
95
|
-
"aria-label": j ?? (a || b ? void 0 : x),
|
|
96
|
-
"aria-invalid": u || void 0,
|
|
97
|
-
"aria-describedby": R,
|
|
98
|
-
className: "placeholder:text-foreground-subtle min-w-[8ch] flex-1 bg-transparent text-lg outline-none md:text-sm"
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
|
-
v ? /* @__PURE__ */ o("p", { id: M, className: "text-danger-text text-xs", children: c }) : l ? /* @__PURE__ */ o("p", { id: H, className: "text-foreground-subtle text-xs", children: l }) : null
|
|
105
|
-
] });
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { formatString as t } from "../../lib/strings.js";
|
|
4
|
+
import { useFieldIds as n } from "../../hooks/use-field-ids.js";
|
|
5
|
+
import { useStrings as r } from "../../hooks/use-strings.js";
|
|
6
|
+
import { X as i } from "../../icons/index.js";
|
|
7
|
+
import { forwardRef as a, useCallback as o, useState as s } from "react";
|
|
8
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/ui/TagInput.tsx
|
|
10
|
+
var u = a(function({ value: a, defaultValue: u = [], onChange: d, label: f, hideLabel: p, description: m, placeholder: h, max: g, disabled: _, error: v, separators: y = ["Enter", ","], id: b, "aria-describedby": x, "aria-label": S, className: C }, w) {
|
|
11
|
+
let [T, E] = s(u), [D, O] = s(""), k = a ?? T, A = r(), j = h ?? A.tagInput.placeholder, M = !!v, N = M && v !== !0, { fieldId: P, helperId: F, errorId: I, describedBy: L } = n(b, {
|
|
12
|
+
hasHelper: !!m,
|
|
13
|
+
hasError: N,
|
|
14
|
+
extra: x
|
|
15
|
+
}), R = o((e) => {
|
|
16
|
+
a === void 0 && E(e), d?.(e);
|
|
17
|
+
}, [d, a]), z = (e) => {
|
|
18
|
+
let t = e.trim();
|
|
19
|
+
!t || k.includes(t) || g !== void 0 && k.length >= g || R([...k, t]);
|
|
20
|
+
}, B = (e) => R(k.filter((t, n) => n !== e));
|
|
21
|
+
return /* @__PURE__ */ l("div", {
|
|
22
|
+
ref: w,
|
|
23
|
+
className: e("flex flex-col gap-1.5", C),
|
|
24
|
+
children: [
|
|
25
|
+
f && /* @__PURE__ */ c("label", {
|
|
26
|
+
htmlFor: P,
|
|
27
|
+
className: e("text-foreground text-sm font-medium", p && "sr-only"),
|
|
28
|
+
children: f
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ l("div", {
|
|
31
|
+
className: e("bg-card flex max-h-24 min-h-9 w-full flex-wrap items-center gap-1.5 overflow-y-auto rounded-md border px-2 py-1.5", "transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]", "focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2", M ? "border-danger focus-within:border-danger focus-within:ring-danger" : "border-border-input focus-within:border-accent focus-within:ring-ring", _ && "pointer-events-none opacity-50"),
|
|
32
|
+
children: [k.map((e, n) => /* @__PURE__ */ l("span", {
|
|
33
|
+
className: "bg-background-muted inline-flex items-center gap-1 rounded-sm px-2 py-0.5 text-xs",
|
|
34
|
+
children: [e, /* @__PURE__ */ c("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: () => B(n),
|
|
37
|
+
className: "text-foreground-muted hover:bg-background-subtle hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background relative rounded-sm p-0.5 outline-none before:absolute before:-inset-1.5 before:content-[''] focus-visible:ring-2 focus-visible:ring-offset-1",
|
|
38
|
+
"aria-label": t(A.tagInput.remove, { tag: e }),
|
|
39
|
+
children: /* @__PURE__ */ c(i, {
|
|
40
|
+
className: "size-3",
|
|
41
|
+
"aria-hidden": !0
|
|
42
|
+
})
|
|
43
|
+
})]
|
|
44
|
+
}, `${e}-${n}`)), /* @__PURE__ */ c("input", {
|
|
45
|
+
id: P,
|
|
46
|
+
value: D,
|
|
47
|
+
disabled: _,
|
|
48
|
+
onChange: (e) => O(e.target.value),
|
|
49
|
+
onKeyDown: (e) => {
|
|
50
|
+
y.includes(e.key) ? (e.preventDefault(), z(D), O("")) : e.key === "Backspace" && !D && k.length && B(k.length - 1);
|
|
51
|
+
},
|
|
52
|
+
onBlur: () => {
|
|
53
|
+
D && (z(D), O(""));
|
|
54
|
+
},
|
|
55
|
+
placeholder: k.length === 0 ? j : void 0,
|
|
56
|
+
"aria-label": S ?? (f || b ? void 0 : j),
|
|
57
|
+
"aria-invalid": M || void 0,
|
|
58
|
+
"aria-describedby": L,
|
|
59
|
+
className: "placeholder:text-foreground-subtle min-w-[8ch] flex-1 bg-transparent text-lg outline-none md:text-sm"
|
|
60
|
+
})]
|
|
61
|
+
}),
|
|
62
|
+
N ? /* @__PURE__ */ c("p", {
|
|
63
|
+
id: I,
|
|
64
|
+
className: "text-danger-text text-xs",
|
|
65
|
+
children: v
|
|
66
|
+
}) : m ? /* @__PURE__ */ c("p", {
|
|
67
|
+
id: F,
|
|
68
|
+
className: "text-foreground-subtle text-xs",
|
|
69
|
+
children: m
|
|
70
|
+
}) : null
|
|
71
|
+
]
|
|
72
|
+
});
|
|
106
73
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
//# sourceMappingURL=TagInput.js.map
|
|
74
|
+
u.displayName = "TagInput";
|
|
75
|
+
//#endregion
|
|
76
|
+
export { u as TagInput };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=TagInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagInput.js","sources":["../../../src/components/ui/TagInput.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString } from '@/lib/strings';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\nexport interface TagInputProps {\n /** Controlled list of tags. */\n value?: string[];\n /** Default tags when uncontrolled. */\n defaultValue?: string[];\n /** Called when the tag list changes. */\n onChange?: (tags: string[]) => void;\n /** Visible label rendered above the field. */\n label?: ReactNode;\n /** Visually conceal the label while keeping it for screen readers. */\n hideLabel?: boolean;\n /** Hint below the field. Hidden while `error` is set. */\n description?: ReactNode;\n /** Placeholder shown inside the inline input. */\n placeholder?: string;\n /** Maximum number of tags. */\n max?: number;\n /** Disable the editor. */\n disabled?: boolean;\n /**\n * Validation state. `true` only paints the danger border; a ReactNode also\n * renders the message below the field and wires `aria-describedby`.\n */\n error?: boolean | ReactNode;\n /** Treat these characters as separators (default: Enter + comma). */\n separators?: string[];\n /** Consumer-supplied id for the inline input. */\n id?: string;\n /** Extra ids to append to `aria-describedby`. */\n 'aria-describedby'?: string;\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Chip-based multi-value input. Press Enter or comma to add. Backspace on an\n * empty input removes the last tag.\n */\nexport const TagInput = forwardRef<HTMLDivElement, TagInputProps>(function TagInput(\n {\n value,\n defaultValue = [],\n onChange,\n label,\n hideLabel,\n description,\n placeholder: placeholderProp,\n max,\n disabled,\n error,\n separators = ['Enter', ','],\n id,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n className,\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const [draft, setDraft] = useState('');\n const tags = value ?? internal;\n\n const strings = useStrings();\n const placeholder = placeholderProp ?? strings.tagInput.placeholder;\n const isError = Boolean(error);\n const hasErrorMessage = isError && error !== true;\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(description),\n hasError: hasErrorMessage,\n extra: ariaDescribedby,\n });\n\n const update = useCallback(\n (next: string[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const commit = (raw: string) => {\n const t = raw.trim();\n if (!t || tags.includes(t) || (max !== undefined && tags.length >= max)) return;\n update([...tags, t]);\n };\n\n const remove = (idx: number) => update(tags.filter((_, i) => i !== idx));\n\n const onKey = (e: KeyboardEvent<HTMLInputElement>) => {\n if (separators.includes(e.key)) {\n e.preventDefault();\n commit(draft);\n setDraft('');\n } else if (e.key === 'Backspace' && !draft && tags.length) {\n remove(tags.length - 1);\n }\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n <div\n className={cn(\n // Cap growth at ~3 chip rows and scroll inside — an unbounded field\n // pushes the surrounding layout around as tags are added.\n 'bg-card flex max-h-24 min-h-9 w-full flex-wrap items-center gap-1.5 overflow-y-auto rounded-md border px-2 py-1.5',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n isError\n ? 'border-danger focus-within:border-danger focus-within:ring-danger'\n : 'border-border-input focus-within:border-accent focus-within:ring-ring',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n {tags.map((t, i) => (\n <span\n key={`${t}-${i}`}\n className=\"bg-background-muted inline-flex items-center gap-1 rounded-sm px-2 py-0.5 text-xs\"\n >\n {t}\n <button\n type=\"button\"\n onClick={() => remove(i)}\n // 16px glyph box + halo → ≥24px hit area (WCAG 2.5.8) without growing the chip.\n className=\"text-foreground-muted hover:bg-background-subtle hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background relative rounded-sm p-0.5 outline-none before:absolute before:-inset-1.5 before:content-[''] focus-visible:ring-2 focus-visible:ring-offset-1\"\n aria-label={formatString(strings.tagInput.remove, { tag: t })}\n >\n <X className=\"size-3\" aria-hidden />\n </button>\n </span>\n ))}\n <input\n id={fieldId}\n value={draft}\n disabled={disabled}\n onChange={(e) => setDraft(e.target.value)}\n onKeyDown={onKey}\n onBlur={() => {\n if (draft) {\n commit(draft);\n setDraft('');\n }\n }}\n placeholder={tags.length === 0 ? placeholder : undefined}\n // Unlabelled field: fall back to the placeholder. A consumer `id`\n // implies an external <label htmlFor>.\n aria-label={ariaLabel ?? (label || id ? undefined : placeholder)}\n aria-invalid={isError || undefined}\n aria-describedby={describedBy}\n className=\"placeholder:text-foreground-subtle min-w-[8ch] flex-1 bg-transparent text-lg outline-none md:text-sm\"\n />\n </div>\n {hasErrorMessage ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : description ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {description}\n </p>\n ) : null}\n </div>\n );\n});\nTagInput.displayName = 'TagInput';\n"],"
|
|
1
|
+
{"version":3,"file":"TagInput.js","names":[],"sources":["../../../src/components/ui/TagInput.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString } from '@/lib/strings';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\nexport interface TagInputProps {\n /** Controlled list of tags. */\n value?: string[];\n /** Default tags when uncontrolled. */\n defaultValue?: string[];\n /** Called when the tag list changes. */\n onChange?: (tags: string[]) => void;\n /** Visible label rendered above the field. */\n label?: ReactNode;\n /** Visually conceal the label while keeping it for screen readers. */\n hideLabel?: boolean;\n /** Hint below the field. Hidden while `error` is set. */\n description?: ReactNode;\n /** Placeholder shown inside the inline input. */\n placeholder?: string;\n /** Maximum number of tags. */\n max?: number;\n /** Disable the editor. */\n disabled?: boolean;\n /**\n * Validation state. `true` only paints the danger border; a ReactNode also\n * renders the message below the field and wires `aria-describedby`.\n */\n error?: boolean | ReactNode;\n /** Treat these characters as separators (default: Enter + comma). */\n separators?: string[];\n /** Consumer-supplied id for the inline input. */\n id?: string;\n /** Extra ids to append to `aria-describedby`. */\n 'aria-describedby'?: string;\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Chip-based multi-value input. Press Enter or comma to add. Backspace on an\n * empty input removes the last tag.\n */\nexport const TagInput = forwardRef<HTMLDivElement, TagInputProps>(function TagInput(\n {\n value,\n defaultValue = [],\n onChange,\n label,\n hideLabel,\n description,\n placeholder: placeholderProp,\n max,\n disabled,\n error,\n separators = ['Enter', ','],\n id,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n className,\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const [draft, setDraft] = useState('');\n const tags = value ?? internal;\n\n const strings = useStrings();\n const placeholder = placeholderProp ?? strings.tagInput.placeholder;\n const isError = Boolean(error);\n const hasErrorMessage = isError && error !== true;\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(description),\n hasError: hasErrorMessage,\n extra: ariaDescribedby,\n });\n\n const update = useCallback(\n (next: string[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const commit = (raw: string) => {\n const t = raw.trim();\n if (!t || tags.includes(t) || (max !== undefined && tags.length >= max)) return;\n update([...tags, t]);\n };\n\n const remove = (idx: number) => update(tags.filter((_, i) => i !== idx));\n\n const onKey = (e: KeyboardEvent<HTMLInputElement>) => {\n if (separators.includes(e.key)) {\n e.preventDefault();\n commit(draft);\n setDraft('');\n } else if (e.key === 'Backspace' && !draft && tags.length) {\n remove(tags.length - 1);\n }\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n <div\n className={cn(\n // Cap growth at ~3 chip rows and scroll inside — an unbounded field\n // pushes the surrounding layout around as tags are added.\n 'bg-card flex max-h-24 min-h-9 w-full flex-wrap items-center gap-1.5 overflow-y-auto rounded-md border px-2 py-1.5',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n isError\n ? 'border-danger focus-within:border-danger focus-within:ring-danger'\n : 'border-border-input focus-within:border-accent focus-within:ring-ring',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n {tags.map((t, i) => (\n <span\n key={`${t}-${i}`}\n className=\"bg-background-muted inline-flex items-center gap-1 rounded-sm px-2 py-0.5 text-xs\"\n >\n {t}\n <button\n type=\"button\"\n onClick={() => remove(i)}\n // 16px glyph box + halo → ≥24px hit area (WCAG 2.5.8) without growing the chip.\n className=\"text-foreground-muted hover:bg-background-subtle hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background relative rounded-sm p-0.5 outline-none before:absolute before:-inset-1.5 before:content-[''] focus-visible:ring-2 focus-visible:ring-offset-1\"\n aria-label={formatString(strings.tagInput.remove, { tag: t })}\n >\n <X className=\"size-3\" aria-hidden />\n </button>\n </span>\n ))}\n <input\n id={fieldId}\n value={draft}\n disabled={disabled}\n onChange={(e) => setDraft(e.target.value)}\n onKeyDown={onKey}\n onBlur={() => {\n if (draft) {\n commit(draft);\n setDraft('');\n }\n }}\n placeholder={tags.length === 0 ? placeholder : undefined}\n // Unlabelled field: fall back to the placeholder. A consumer `id`\n // implies an external <label htmlFor>.\n aria-label={ariaLabel ?? (label || id ? undefined : placeholder)}\n aria-invalid={isError || undefined}\n aria-describedby={describedBy}\n className=\"placeholder:text-foreground-subtle min-w-[8ch] flex-1 bg-transparent text-lg outline-none md:text-sm\"\n />\n </div>\n {hasErrorMessage ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : description ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {description}\n </p>\n ) : null}\n </div>\n );\n});\nTagInput.displayName = 'TagInput';\n"],"mappings":";;;;;;;;;AA+CA,IAAa,IAAW,EAA0C,SAChE,EACE,UACA,kBAAe,CAAC,GAChB,aACA,UACA,cACA,gBACA,aAAa,GACb,QACA,aACA,UACA,gBAAa,CAAC,SAAS,GAAG,GAC1B,OACA,oBAAoB,GACpB,cAAc,GACd,gBAEF,GACA;CACA,IAAM,CAAC,GAAU,KAAe,EAAmB,CAAY,GACzD,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,IAAO,KAAS,GAEhB,IAAU,EAAW,GACrB,IAAc,KAAmB,EAAQ,SAAS,aAClD,IAAU,EAAQ,GAClB,IAAkB,KAAW,MAAU,IACvC,EAAE,YAAS,aAAU,YAAS,mBAAgB,EAAY,GAAI;EAClE,WAAW,EAAQ;EACnB,UAAU;EACV,OAAO;CACT,CAAC,GAEK,IAAS,GACZ,MAAmB;EAElB,AADI,MAAU,KAAA,KAAW,EAAY,CAAI,GACzC,IAAW,CAAI;CACjB,GACA,CAAC,GAAU,CAAK,CAClB,GAEM,KAAU,MAAgB;EAC9B,IAAM,IAAI,EAAI,KAAK;EACf,CAAC,KAAK,EAAK,SAAS,CAAC,KAAM,MAAQ,KAAA,KAAa,EAAK,UAAU,KACnE,EAAO,CAAC,GAAG,GAAM,CAAC,CAAC;CACrB,GAEM,KAAU,MAAgB,EAAO,EAAK,QAAQ,GAAG,MAAM,MAAM,CAAG,CAAC;CAYvE,OACE,kBAAC,OAAD;EAAU;EAAK,WAAW,EAAG,yBAAyB,CAAS;EAA/D,UAAA;GACG,KACC,kBAAC,SAAD;IACE,SAAS;IACT,WAAW,EAAG,uCAAuC,KAAa,SAAS;IAE1E,UAAA;GACI,CAAA;GAET,kBAAC,OAAD;IACE,WAAW,EAGT,qHACA,4EACA,sFACA,IACI,sEACA,yEACJ,KAAY,gCACd;IAXF,UAAA,CAaG,EAAK,KAAK,GAAG,MACZ,kBAAC,QAAD;KAEE,WAAU;KAFZ,UAAA,CAIG,GACD,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAO,CAAC;MAEvB,WAAU;MACV,cAAY,EAAa,EAAQ,SAAS,QAAQ,EAAE,KAAK,EAAE,CAAC;MAE5D,UAAA,kBAAC,GAAD;OAAG,WAAU;OAAS,eAAA;MAAa,CAAA;KAC7B,CAAA,CACJ;IAbC,GAAA,GAAG,EAAE,GAAG,GAaT,CACP,GACD,kBAAC,SAAD;KACE,IAAI;KACJ,OAAO;KACG;KACV,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;KACxC,YAvDO,MAAuC;MACpD,AAAI,EAAW,SAAS,EAAE,GAAG,KAC3B,EAAE,eAAe,GACjB,EAAO,CAAK,GACZ,EAAS,EAAE,KACF,EAAE,QAAQ,eAAe,CAAC,KAAS,EAAK,UACjD,EAAO,EAAK,SAAS,CAAC;KAE1B;KAgDQ,cAAc;MACZ,AAAI,MACF,EAAO,CAAK,GACZ,EAAS,EAAE;KAEf;KACA,aAAa,EAAK,WAAW,IAAI,IAAc,KAAA;KAG/C,cAAY,MAAc,KAAS,IAAK,KAAA,IAAY;KACpD,gBAAc,KAAW,KAAA;KACzB,oBAAkB;KAClB,WAAU;IACX,CAAA,CACE;;GACJ,IACC,kBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IACvB,UAAA;GACA,CAAA,IACD,IACF,kBAAC,KAAD;IAAG,IAAI;IAAU,WAAU;IACxB,UAAA;GACA,CAAA,IACD;EACD;;AAET,CAAC;AACD,EAAS,cAAc"}
|
|
@@ -1,88 +1,76 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
72
|
-
"focus-visible:ring-offset-background",
|
|
73
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
74
|
-
"border-border-input focus-visible:border-accent",
|
|
75
|
-
"aria-invalid:border-danger aria-invalid:focus-visible:border-danger aria-invalid:focus-visible:ring-danger",
|
|
76
|
-
r ? "resize-none" : "min-h-20 resize-y"
|
|
77
|
-
),
|
|
78
|
-
...k
|
|
79
|
-
}
|
|
80
|
-
),
|
|
81
|
-
i ? /* @__PURE__ */ n("p", { id: M, className: "text-danger-text text-xs", children: i }) : a ? /* @__PURE__ */ n("p", { id: I, className: "text-foreground-subtle text-xs", children: a }) : null
|
|
82
|
-
] });
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { useFieldIds as t } from "../../hooks/use-field-ids.js";
|
|
4
|
+
import { forwardRef as n, useCallback as r, useEffect as i, useRef as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ui/Textarea.tsx
|
|
7
|
+
var c = n(function({ className: n, label: c, helperText: l, error: u, autoResize: d, minRows: f = 3, maxRows: p = 12, hideLabel: m, id: h, onChange: g, value: _, defaultValue: v, "aria-describedby": y, "aria-invalid": b, ...x }, S) {
|
|
8
|
+
let C = !!u || b === !0 || b === "true", { fieldId: w, helperId: T, errorId: E, describedBy: D } = t(h, {
|
|
9
|
+
hasHelper: !!l,
|
|
10
|
+
hasError: !!u,
|
|
11
|
+
extra: y
|
|
12
|
+
}), O = a(null), k = (e) => {
|
|
13
|
+
O.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
|
|
14
|
+
}, A = r(() => {
|
|
15
|
+
let e = O.current;
|
|
16
|
+
if (!e || !d) return;
|
|
17
|
+
let t = getComputedStyle(e), n = parseFloat(t.lineHeight) || 20, r = (parseFloat(t.paddingTop) || 0) + (parseFloat(t.paddingBottom) || 0), i = (parseFloat(t.borderTopWidth) || 0) + (parseFloat(t.borderBottomWidth) || 0), a = n * f + r + i, o = n * p + r + i;
|
|
18
|
+
e.style.height = "auto";
|
|
19
|
+
let s = e.scrollHeight + i;
|
|
20
|
+
e.style.height = `${Math.min(Math.max(s, a), o)}px`, e.style.overflowY = s > o ? "auto" : "hidden";
|
|
21
|
+
}, [
|
|
22
|
+
d,
|
|
23
|
+
f,
|
|
24
|
+
p
|
|
25
|
+
]);
|
|
26
|
+
return i(() => {
|
|
27
|
+
d && A();
|
|
28
|
+
}, [
|
|
29
|
+
d,
|
|
30
|
+
A,
|
|
31
|
+
_,
|
|
32
|
+
v
|
|
33
|
+
]), i(() => {
|
|
34
|
+
let e = O.current;
|
|
35
|
+
if (!d || !e || typeof ResizeObserver > "u") return;
|
|
36
|
+
let t = new ResizeObserver(() => A());
|
|
37
|
+
return t.observe(e), () => t.disconnect();
|
|
38
|
+
}, [d, A]), /* @__PURE__ */ s("div", {
|
|
39
|
+
className: e("flex flex-col gap-1.5", n),
|
|
40
|
+
children: [
|
|
41
|
+
c && /* @__PURE__ */ o("label", {
|
|
42
|
+
htmlFor: w,
|
|
43
|
+
className: e("text-foreground text-sm font-medium", m && "sr-only"),
|
|
44
|
+
children: c
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ o("textarea", {
|
|
47
|
+
ref: k,
|
|
48
|
+
id: w,
|
|
49
|
+
rows: f,
|
|
50
|
+
value: _,
|
|
51
|
+
defaultValue: v,
|
|
52
|
+
onChange: (e) => {
|
|
53
|
+
g?.(e), d && A();
|
|
54
|
+
},
|
|
55
|
+
"aria-invalid": C ? !0 : b,
|
|
56
|
+
"aria-describedby": D,
|
|
57
|
+
className: e("bg-card text-foreground rounded-md border px-3 py-2 text-lg md:text-sm", "placeholder:text-foreground-subtle", "transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]", "outline-none", "focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2", "focus-visible:ring-offset-background", "disabled:cursor-not-allowed disabled:opacity-50", "border-border-input focus-visible:border-accent", "aria-invalid:border-danger aria-invalid:focus-visible:border-danger aria-invalid:focus-visible:ring-danger", d ? "resize-none" : "min-h-20 resize-y"),
|
|
58
|
+
...x
|
|
59
|
+
}),
|
|
60
|
+
u ? /* @__PURE__ */ o("p", {
|
|
61
|
+
id: E,
|
|
62
|
+
className: "text-danger-text text-xs",
|
|
63
|
+
children: u
|
|
64
|
+
}) : l ? /* @__PURE__ */ o("p", {
|
|
65
|
+
id: T,
|
|
66
|
+
className: "text-foreground-subtle text-xs",
|
|
67
|
+
children: l
|
|
68
|
+
}) : null
|
|
69
|
+
]
|
|
70
|
+
});
|
|
83
71
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=Textarea.js.map
|
|
72
|
+
c.displayName = "Textarea";
|
|
73
|
+
//#endregion
|
|
74
|
+
export { c as Textarea };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../../../src/components/ui/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n type TextareaHTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cn } from '@/lib/utils';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\nexport interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Visible label above the field. */\n label?: ReactNode;\n /** Hint below the field. Hidden when `error` is set. */\n helperText?: ReactNode;\n /** Validation message. Sets `aria-invalid`. */\n error?: ReactNode;\n /** Grow vertically as content is added. */\n autoResize?: boolean;\n /** Minimum rows when `autoResize`. Defaults to 3. */\n minRows?: number;\n /** Maximum rows before scrolling when `autoResize`. Defaults to 12. */\n maxRows?: number;\n /** Visually hide the label while keeping it accessible. */\n hideLabel?: boolean;\n}\n\n/**\n * Multi-line text input. With `autoResize`, height tracks content from\n * `minRows` to `maxRows`. Without it, behaves like a native `<textarea>`.\n *\n * @example Comment box\n * <Textarea label=\"Note\" autoResize minRows={3} maxRows={10} />\n *\n * @example With error\n * <Textarea label=\"Description\"\n * error={errors.description?.message}\n * {...register('description')} />\n *\n * @do Default to `autoResize` for multi-line free-form input.\n * @dont Add `resize-none` without auto-resize — users will be stuck with a\n * 3-line box for long content.\n */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n className,\n label,\n helperText,\n error,\n autoResize,\n minRows = 3,\n maxRows = 12,\n hideLabel,\n id,\n onChange,\n value,\n defaultValue,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n ref,\n) {\n const isError = Boolean(error) || ariaInvalid === true || ariaInvalid === 'true';\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(helperText),\n hasError: Boolean(error),\n extra: ariaDescribedby,\n });\n const innerRef = useRef<HTMLTextAreaElement | null>(null);\n\n // Stash a ref locally and forward to the consumer.\n const setRef = (node: HTMLTextAreaElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n };\n\n const recompute = useCallback(() => {\n const el = innerRef.current;\n if (!el || !autoResize) return;\n const cs = getComputedStyle(el);\n const lineHeight = parseFloat(cs.lineHeight) || 20;\n // scrollHeight includes padding but not borders; the element is border-box.\n const padding = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0);\n const border = (parseFloat(cs.borderTopWidth) || 0) + (parseFloat(cs.borderBottomWidth) || 0);\n const minH = lineHeight * minRows + padding + border;\n const maxH = lineHeight * maxRows + padding + border;\n el.style.height = 'auto';\n const content = el.scrollHeight + border;\n el.style.height = `${Math.min(Math.max(content, minH), maxH)}px`;\n el.style.overflowY = content > maxH ? 'auto' : 'hidden';\n }, [autoResize, minRows, maxRows]);\n\n useEffect(() => {\n if (autoResize) recompute();\n }, [autoResize, recompute, value, defaultValue]);\n\n // Width changes re-wrap the text, so recompute on resize too.\n useEffect(() => {\n const el = innerRef.current;\n if (!autoResize || !el || typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(() => recompute());\n ro.observe(el);\n return () => ro.disconnect();\n }, [autoResize, recompute]);\n\n return (\n <div className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n <textarea\n ref={setRef}\n id={fieldId}\n rows={minRows}\n value={value}\n defaultValue={defaultValue}\n onChange={(e) => {\n onChange?.(e);\n if (autoResize) recompute();\n }}\n aria-invalid={isError ? true : ariaInvalid}\n aria-describedby={describedBy}\n className={cn(\n 'bg-card text-foreground rounded-md border px-3 py-2 text-lg md:text-sm',\n 'placeholder:text-foreground-subtle',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'outline-none',\n 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2',\n 'focus-visible:ring-offset-background',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n 'border-border-input focus-visible:border-accent',\n 'aria-invalid:border-danger aria-invalid:focus-visible:border-danger aria-invalid:focus-visible:ring-danger',\n autoResize ? 'resize-none' : 'min-h-20 resize-y',\n )}\n {...props}\n />\n {error ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : helperText ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {helperText}\n </p>\n ) : null}\n </div>\n );\n});\n\nTextarea.displayName = 'Textarea';\n"],"
|
|
1
|
+
{"version":3,"file":"Textarea.js","names":[],"sources":["../../../src/components/ui/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n type TextareaHTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cn } from '@/lib/utils';\nimport { useFieldIds } from '@/hooks/use-field-ids';\n\nexport interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Visible label above the field. */\n label?: ReactNode;\n /** Hint below the field. Hidden when `error` is set. */\n helperText?: ReactNode;\n /** Validation message. Sets `aria-invalid`. */\n error?: ReactNode;\n /** Grow vertically as content is added. */\n autoResize?: boolean;\n /** Minimum rows when `autoResize`. Defaults to 3. */\n minRows?: number;\n /** Maximum rows before scrolling when `autoResize`. Defaults to 12. */\n maxRows?: number;\n /** Visually hide the label while keeping it accessible. */\n hideLabel?: boolean;\n}\n\n/**\n * Multi-line text input. With `autoResize`, height tracks content from\n * `minRows` to `maxRows`. Without it, behaves like a native `<textarea>`.\n *\n * @example Comment box\n * <Textarea label=\"Note\" autoResize minRows={3} maxRows={10} />\n *\n * @example With error\n * <Textarea label=\"Description\"\n * error={errors.description?.message}\n * {...register('description')} />\n *\n * @do Default to `autoResize` for multi-line free-form input.\n * @dont Add `resize-none` without auto-resize — users will be stuck with a\n * 3-line box for long content.\n */\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n className,\n label,\n helperText,\n error,\n autoResize,\n minRows = 3,\n maxRows = 12,\n hideLabel,\n id,\n onChange,\n value,\n defaultValue,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n ref,\n) {\n const isError = Boolean(error) || ariaInvalid === true || ariaInvalid === 'true';\n const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n hasHelper: Boolean(helperText),\n hasError: Boolean(error),\n extra: ariaDescribedby,\n });\n const innerRef = useRef<HTMLTextAreaElement | null>(null);\n\n // Stash a ref locally and forward to the consumer.\n const setRef = (node: HTMLTextAreaElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n };\n\n const recompute = useCallback(() => {\n const el = innerRef.current;\n if (!el || !autoResize) return;\n const cs = getComputedStyle(el);\n const lineHeight = parseFloat(cs.lineHeight) || 20;\n // scrollHeight includes padding but not borders; the element is border-box.\n const padding = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0);\n const border = (parseFloat(cs.borderTopWidth) || 0) + (parseFloat(cs.borderBottomWidth) || 0);\n const minH = lineHeight * minRows + padding + border;\n const maxH = lineHeight * maxRows + padding + border;\n el.style.height = 'auto';\n const content = el.scrollHeight + border;\n el.style.height = `${Math.min(Math.max(content, minH), maxH)}px`;\n el.style.overflowY = content > maxH ? 'auto' : 'hidden';\n }, [autoResize, minRows, maxRows]);\n\n useEffect(() => {\n if (autoResize) recompute();\n }, [autoResize, recompute, value, defaultValue]);\n\n // Width changes re-wrap the text, so recompute on resize too.\n useEffect(() => {\n const el = innerRef.current;\n if (!autoResize || !el || typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(() => recompute());\n ro.observe(el);\n return () => ro.disconnect();\n }, [autoResize, recompute]);\n\n return (\n <div className={cn('flex flex-col gap-1.5', className)}>\n {label && (\n <label\n htmlFor={fieldId}\n className={cn('text-foreground text-sm font-medium', hideLabel && 'sr-only')}\n >\n {label}\n </label>\n )}\n <textarea\n ref={setRef}\n id={fieldId}\n rows={minRows}\n value={value}\n defaultValue={defaultValue}\n onChange={(e) => {\n onChange?.(e);\n if (autoResize) recompute();\n }}\n aria-invalid={isError ? true : ariaInvalid}\n aria-describedby={describedBy}\n className={cn(\n 'bg-card text-foreground rounded-md border px-3 py-2 text-lg md:text-sm',\n 'placeholder:text-foreground-subtle',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'outline-none',\n 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2',\n 'focus-visible:ring-offset-background',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n 'border-border-input focus-visible:border-accent',\n 'aria-invalid:border-danger aria-invalid:focus-visible:border-danger aria-invalid:focus-visible:ring-danger',\n autoResize ? 'resize-none' : 'min-h-20 resize-y',\n )}\n {...props}\n />\n {error ? (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n ) : helperText ? (\n <p id={helperId} className=\"text-foreground-subtle text-xs\">\n {helperText}\n </p>\n ) : null}\n </div>\n );\n});\n\nTextarea.displayName = 'Textarea';\n"],"mappings":";;;;;;AA8CA,IAAa,IAAW,EAA+C,SACrE,EACE,cACA,UACA,eACA,UACA,eACA,aAAU,GACV,aAAU,IACV,cACA,OACA,aACA,UACA,iBACA,oBAAoB,GACpB,gBAAgB,GAChB,GAAG,KAEL,GACA;CACA,IAAM,IAAU,EAAQ,KAAU,MAAgB,MAAQ,MAAgB,QACpE,EAAE,YAAS,aAAU,YAAS,mBAAgB,EAAY,GAAI;EAClE,WAAW,EAAQ;EACnB,UAAU,EAAQ;EAClB,OAAO;CACT,CAAC,GACK,IAAW,EAAmC,IAAI,GAGlD,KAAU,MAAqC;EAEnD,AADA,EAAS,UAAU,GACf,OAAO,KAAQ,aAAY,EAAI,CAAI,IAC9B,MAAK,EAA4D,UAAU;CACtF,GAEM,IAAY,QAAkB;EAClC,IAAM,IAAK,EAAS;EACpB,IAAI,CAAC,KAAM,CAAC,GAAY;EACxB,IAAM,IAAK,iBAAiB,CAAE,GACxB,IAAa,WAAW,EAAG,UAAU,KAAK,IAE1C,KAAW,WAAW,EAAG,UAAU,KAAK,MAAM,WAAW,EAAG,aAAa,KAAK,IAC9E,KAAU,WAAW,EAAG,cAAc,KAAK,MAAM,WAAW,EAAG,iBAAiB,KAAK,IACrF,IAAO,IAAa,IAAU,IAAU,GACxC,IAAO,IAAa,IAAU,IAAU;EAC9C,EAAG,MAAM,SAAS;EAClB,IAAM,IAAU,EAAG,eAAe;EAElC,AADA,EAAG,MAAM,SAAS,GAAG,KAAK,IAAI,KAAK,IAAI,GAAS,CAAI,GAAG,CAAI,EAAE,KAC7D,EAAG,MAAM,YAAY,IAAU,IAAO,SAAS;CACjD,GAAG;EAAC;EAAY;EAAS;CAAO,CAAC;CAejC,OAbA,QAAgB;EACd,AAAI,KAAY,EAAU;CAC5B,GAAG;EAAC;EAAY;EAAW;EAAO;CAAY,CAAC,GAG/C,QAAgB;EACd,IAAM,IAAK,EAAS;EACpB,IAAI,CAAC,KAAc,CAAC,KAAM,OAAO,iBAAmB,KAAa;EACjE,IAAM,IAAK,IAAI,qBAAqB,EAAU,CAAC;EAE/C,OADA,EAAG,QAAQ,CAAE,SACA,EAAG,WAAW;CAC7B,GAAG,CAAC,GAAY,CAAS,CAAC,GAGxB,kBAAC,OAAD;EAAK,WAAW,EAAG,yBAAyB,CAAS;EAArD,UAAA;GACG,KACC,kBAAC,SAAD;IACE,SAAS;IACT,WAAW,EAAG,uCAAuC,KAAa,SAAS;IAE1E,UAAA;GACI,CAAA;GAET,kBAAC,YAAD;IACE,KAAK;IACL,IAAI;IACJ,MAAM;IACC;IACO;IACd,WAAW,MAAM;KAEf,AADA,IAAW,CAAC,GACR,KAAY,EAAU;IAC5B;IACA,gBAAc,IAAU,KAAO;IAC/B,oBAAkB;IAClB,WAAW,EACT,0EACA,sCACA,4EACA,gBACA,4EACA,wCACA,mDACA,mDACA,8GACA,IAAa,gBAAgB,mBAC/B;IACA,GAAI;GACL,CAAA;GACA,IACC,kBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IACvB,UAAA;GACA,CAAA,IACD,IACF,kBAAC,KAAD;IAAG,IAAI;IAAU,WAAU;IACxB,UAAA;GACA,CAAA,IACD;EACD;;AAET,CAAC;AAED,EAAS,cAAc"}
|
|
@@ -13,21 +13,21 @@ export interface TimelineTimeProps extends TimeHTMLAttributes<HTMLTimeElement> {
|
|
|
13
13
|
dateTime?: string;
|
|
14
14
|
children: ReactNode;
|
|
15
15
|
}
|
|
16
|
-
export declare function TimelineTime({ className, children, dateTime, ...props }: TimelineTimeProps): import("react
|
|
16
|
+
export declare function TimelineTime({ className, children, dateTime, ...props }: TimelineTimeProps): import("react").JSX.Element;
|
|
17
17
|
export declare namespace TimelineTime {
|
|
18
18
|
var displayName: string;
|
|
19
19
|
}
|
|
20
20
|
export declare function TimelineTitle({ className, children, }: {
|
|
21
21
|
className?: string;
|
|
22
22
|
children: ReactNode;
|
|
23
|
-
}): import("react
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
24
|
export declare namespace TimelineTitle {
|
|
25
25
|
var displayName: string;
|
|
26
26
|
}
|
|
27
27
|
export declare function TimelineDescription({ className, children, }: {
|
|
28
28
|
className?: string;
|
|
29
29
|
children: ReactNode;
|
|
30
|
-
}): import("react
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
31
|
export declare namespace TimelineDescription {
|
|
32
32
|
var displayName: string;
|
|
33
33
|
}
|
|
@@ -1,56 +1,68 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/Timeline.tsx
|
|
6
|
+
var i = t(function({ className: t, children: r, ...i }, a) {
|
|
7
|
+
return /* @__PURE__ */ n("ol", {
|
|
8
|
+
ref: a,
|
|
9
|
+
className: e("relative flex flex-col gap-6", t),
|
|
10
|
+
...i,
|
|
11
|
+
children: r
|
|
12
|
+
});
|
|
7
13
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
i.displayName = "Timeline";
|
|
15
|
+
var a = t(function({ bullet: t, isLast: i, className: a, children: o, ...s }, c) {
|
|
16
|
+
return /* @__PURE__ */ r("li", {
|
|
17
|
+
ref: c,
|
|
18
|
+
className: e("relative flex gap-4 pb-1", a),
|
|
19
|
+
...s,
|
|
20
|
+
children: [/* @__PURE__ */ r("div", {
|
|
21
|
+
className: "relative flex shrink-0 flex-col items-center",
|
|
22
|
+
children: [/* @__PURE__ */ n("div", {
|
|
23
|
+
className: "border-border bg-card text-foreground-muted flex size-6 items-center justify-center rounded-full border",
|
|
24
|
+
children: t ?? /* @__PURE__ */ n("span", {
|
|
25
|
+
className: "bg-accent size-2 rounded-full",
|
|
26
|
+
"aria-hidden": !0
|
|
27
|
+
})
|
|
28
|
+
}), !i && /* @__PURE__ */ n("span", {
|
|
29
|
+
className: "bg-border mt-1 w-px flex-1",
|
|
30
|
+
"aria-hidden": !0
|
|
31
|
+
})]
|
|
32
|
+
}), /* @__PURE__ */ n("div", {
|
|
33
|
+
className: "min-w-0 flex-1 pb-4",
|
|
34
|
+
children: o
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
17
37
|
});
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
return e;
|
|
38
|
+
a.displayName = "TimelineItem";
|
|
39
|
+
function o(e) {
|
|
40
|
+
if (e && !Number.isNaN(Date.parse(e))) return e;
|
|
22
41
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
children: i
|
|
31
|
-
}
|
|
32
|
-
);
|
|
42
|
+
function s({ className: t, children: r, dateTime: i, ...a }) {
|
|
43
|
+
return /* @__PURE__ */ n("time", {
|
|
44
|
+
dateTime: o(i ?? (typeof r == "string" ? r : void 0)),
|
|
45
|
+
className: e("text-foreground-subtle block text-xs", t),
|
|
46
|
+
...a,
|
|
47
|
+
children: r
|
|
48
|
+
});
|
|
33
49
|
}
|
|
34
|
-
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
s.displayName = "TimelineTime";
|
|
51
|
+
function c({ className: t, children: r }) {
|
|
52
|
+
return /* @__PURE__ */ n("p", {
|
|
53
|
+
className: e("text-sm font-medium", t),
|
|
54
|
+
children: r
|
|
55
|
+
});
|
|
40
56
|
}
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
c.displayName = "TimelineTitle";
|
|
58
|
+
function l({ className: t, children: r }) {
|
|
59
|
+
return /* @__PURE__ */ n("p", {
|
|
60
|
+
className: e("text-foreground-muted mt-0.5 text-sm", t),
|
|
61
|
+
children: r
|
|
62
|
+
});
|
|
47
63
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
p as TimelineTime,
|
|
54
|
-
x as TimelineTitle
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=Timeline.js.map
|
|
64
|
+
l.displayName = "TimelineDescription";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { i as Timeline, l as TimelineDescription, a as TimelineItem, s as TimelineTime, c as TimelineTitle };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=Timeline.js.map
|