@wealth-os/design-system 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/LICENSE +201 -0
- package/README.md +89 -2
- package/dist/button-yvMc7CT-.js +47 -0
- package/dist/charts.d.ts +138 -0
- package/dist/charts.js +712 -0
- package/dist/command-menu.d.ts +3 -0
- package/dist/command-menu.js +53 -0
- package/dist/components/advanced-controls.d.ts +145 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/button-group.d.ts +15 -0
- package/dist/components/button.d.ts +14 -0
- package/dist/components/command-menu.d.ts +42 -0
- package/dist/components/data-display.d.ts +100 -0
- package/dist/components/data-table.d.ts +113 -0
- package/dist/components/date-input.d.ts +36 -0
- package/dist/components/date-range-picker.d.ts +23 -0
- package/dist/components/field.d.ts +18 -0
- package/dist/components/financial.d.ts +83 -0
- package/dist/components/form.d.ts +8 -0
- package/dist/components/icon-button.d.ts +11 -0
- package/dist/components/icons.d.ts +9 -0
- package/dist/components/navigation.d.ts +53 -0
- package/dist/components/notice.d.ts +11 -0
- package/dist/components/number-input.d.ts +44 -0
- package/dist/components/overlays.d.ts +91 -0
- package/dist/components/select-menu.d.ts +27 -0
- package/dist/components/select.d.ts +23 -0
- package/dist/components/status-badge.d.ts +9 -0
- package/dist/components/surface.d.ts +16 -0
- package/dist/components/text-input.d.ts +8 -0
- package/dist/components/textarea.d.ts +7 -0
- package/dist/components/validation-message.d.ts +8 -0
- package/dist/data-display-BA7t1E4G.js +278 -0
- package/dist/data-table.d.ts +2 -0
- package/dist/data-table.js +346 -0
- package/dist/financial.d.ts +1 -0
- package/dist/financial.js +178 -0
- package/dist/form-Csxly6Es.js +74 -0
- package/dist/forms.d.ts +39 -0
- package/dist/forms.js +32 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1411 -0
- package/dist/lib/control-density.d.ts +3 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/navigation.d.ts +3 -0
- package/dist/navigation.js +224 -0
- package/dist/notice-jbY9FQu_.js +49 -0
- package/dist/overlays-BleXRtz6.js +219 -0
- package/dist/overlays.d.ts +7 -0
- package/dist/overlays.js +2 -0
- package/dist/reset.css +16 -0
- package/dist/styles.css +3 -0
- package/dist/tokens.css +157 -0
- package/dist/utils-CX-Pz5p6.js +8 -0
- package/docs/accessibility.md +154 -0
- package/docs/charts.md +47 -0
- package/docs/components.md +296 -0
- package/docs/data-table.md +87 -0
- package/docs/layout-composition.md +224 -0
- package/docs/migration.md +91 -0
- package/docs/tokens.md +170 -0
- package/package.json +118 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1411 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { n as e, r as t, t as n } from "./button-yvMc7CT-.js";
|
|
3
|
+
import { t as r } from "./utils-CX-Pz5p6.js";
|
|
4
|
+
import { i, n as a, r as o, t as s } from "./form-Csxly6Es.js";
|
|
5
|
+
import { n as c, t as l } from "./notice-jbY9FQu_.js";
|
|
6
|
+
import { C as u, S as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, l as x, m as S, n as C, o as w, p as T, r as E, s as D, t as O, u as k, v as A, x as j, y as M } from "./data-display-BA7t1E4G.js";
|
|
7
|
+
import * as N from "react";
|
|
8
|
+
import { cva as P } from "class-variance-authority";
|
|
9
|
+
import { Fragment as F, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/icon-button.tsx
|
|
11
|
+
var R = N.forwardRef(({ label: e, icon: t, size: r = "md", ...i }, a) => /* @__PURE__ */ I(n, {
|
|
12
|
+
...i,
|
|
13
|
+
ref: a,
|
|
14
|
+
size: r === "sm" ? "icon-sm" : r === "lg" ? "icon-lg" : "icon",
|
|
15
|
+
"aria-label": e,
|
|
16
|
+
children: /* @__PURE__ */ I("span", {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: "inline-flex items-center justify-center",
|
|
19
|
+
children: t
|
|
20
|
+
})
|
|
21
|
+
}));
|
|
22
|
+
R.displayName = "IconButton";
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/components/button-group.tsx
|
|
25
|
+
var z = N.forwardRef(({ orientation: e = "horizontal", className: t, children: n, ...i }, a) => /* @__PURE__ */ I("div", {
|
|
26
|
+
...i,
|
|
27
|
+
ref: a,
|
|
28
|
+
role: "group",
|
|
29
|
+
"data-orientation": e,
|
|
30
|
+
className: r("inline-flex gap-2", e === "horizontal" ? "flex-row flex-wrap items-center" : "flex-col items-stretch", t),
|
|
31
|
+
children: n
|
|
32
|
+
}));
|
|
33
|
+
z.displayName = "ButtonGroup";
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/components/icons.tsx
|
|
36
|
+
function B({ name: e, size: t = 16, strokeWidth: n = 1.75, className: r }) {
|
|
37
|
+
let i = {
|
|
38
|
+
fill: "none",
|
|
39
|
+
stroke: "currentColor",
|
|
40
|
+
strokeWidth: n,
|
|
41
|
+
strokeLinecap: "round",
|
|
42
|
+
strokeLinejoin: "round"
|
|
43
|
+
}, a = {
|
|
44
|
+
check: /* @__PURE__ */ I("path", {
|
|
45
|
+
...i,
|
|
46
|
+
d: "M12.5 4 6.5 10 3.5 7"
|
|
47
|
+
}),
|
|
48
|
+
"chevron-down": /* @__PURE__ */ I("path", {
|
|
49
|
+
...i,
|
|
50
|
+
d: "m4 6 4 4 4-4"
|
|
51
|
+
}),
|
|
52
|
+
"chevron-left": /* @__PURE__ */ I("path", {
|
|
53
|
+
...i,
|
|
54
|
+
d: "m9 4-4 4 4 4"
|
|
55
|
+
}),
|
|
56
|
+
"chevron-right": /* @__PURE__ */ I("path", {
|
|
57
|
+
...i,
|
|
58
|
+
d: "m7 4 4 4-4 4"
|
|
59
|
+
}),
|
|
60
|
+
"chevrons-left": /* @__PURE__ */ I("path", {
|
|
61
|
+
...i,
|
|
62
|
+
d: "m10 4-4 4 4 4M6 4 2 8l4 4"
|
|
63
|
+
}),
|
|
64
|
+
"chevrons-right": /* @__PURE__ */ I("path", {
|
|
65
|
+
...i,
|
|
66
|
+
d: "m6 4 4 4-4 4m4-8 4 4-4 4"
|
|
67
|
+
}),
|
|
68
|
+
calendar: /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ I("rect", {
|
|
69
|
+
...i,
|
|
70
|
+
x: "2",
|
|
71
|
+
y: "3",
|
|
72
|
+
width: "12",
|
|
73
|
+
height: "11",
|
|
74
|
+
rx: "2"
|
|
75
|
+
}), /* @__PURE__ */ I("path", {
|
|
76
|
+
...i,
|
|
77
|
+
d: "M5 1.5v3M11 1.5v3M2 6.5h12"
|
|
78
|
+
})] })
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ I("svg", {
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
className: r,
|
|
83
|
+
width: t,
|
|
84
|
+
height: t,
|
|
85
|
+
viewBox: "0 0 16 16",
|
|
86
|
+
children: a[e]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/text-input.tsx
|
|
91
|
+
var V = N.forwardRef(({ className: e, type: n = "text", invalid: i, density: a, "aria-invalid": o, ...s }, c) => /* @__PURE__ */ I("input", {
|
|
92
|
+
type: n,
|
|
93
|
+
"data-density": a,
|
|
94
|
+
className: r("wos-field block", t(a), e),
|
|
95
|
+
"aria-invalid": i || o || void 0,
|
|
96
|
+
ref: c,
|
|
97
|
+
...s
|
|
98
|
+
}));
|
|
99
|
+
V.displayName = "TextInput";
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/components/number-input.tsx
|
|
102
|
+
var H = N.forwardRef(({ label: e, value: n, onChange: i, density: a, help: s, error: c, invalid: l, disabled: u, placeholder: d, inputMode: f = "decimal", prefix: p, suffix: m, format: h, className: g, inputClassName: _, id: v, name: y, inputRef: b, onBlur: x, "aria-describedby": S, ...C }, w) => {
|
|
103
|
+
let T = N.useId(), E = v ?? T, D = [
|
|
104
|
+
S,
|
|
105
|
+
s ? `${E}-help` : void 0,
|
|
106
|
+
c ? `${E}-error` : void 0
|
|
107
|
+
].filter(Boolean).join(" ") || void 0, O = (e) => {
|
|
108
|
+
re(w, e), re(b, e);
|
|
109
|
+
};
|
|
110
|
+
return /* @__PURE__ */ I(o, {
|
|
111
|
+
label: e,
|
|
112
|
+
help: s,
|
|
113
|
+
error: c,
|
|
114
|
+
htmlFor: E,
|
|
115
|
+
className: g,
|
|
116
|
+
children: /* @__PURE__ */ L("div", {
|
|
117
|
+
className: r("relative", t(a)),
|
|
118
|
+
"data-field-container": "true",
|
|
119
|
+
children: [
|
|
120
|
+
p != null && p !== "" && /* @__PURE__ */ I("span", {
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
className: "pointer-events-none absolute inset-y-0 left-2.5 flex items-center text-[length:var(--wos-control-font-size,var(--type-size-control))] text-muted-foreground",
|
|
123
|
+
children: p
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ I(V, {
|
|
126
|
+
...C,
|
|
127
|
+
density: a,
|
|
128
|
+
ref: O,
|
|
129
|
+
id: E,
|
|
130
|
+
name: y,
|
|
131
|
+
type: "text",
|
|
132
|
+
inputMode: f,
|
|
133
|
+
value: n,
|
|
134
|
+
placeholder: d,
|
|
135
|
+
disabled: u,
|
|
136
|
+
invalid: l || !!c,
|
|
137
|
+
"aria-describedby": D,
|
|
138
|
+
"aria-errormessage": c ? `${E}-error` : void 0,
|
|
139
|
+
className: r(p ? "pl-6" : void 0, m ? "pr-14" : void 0, "tabular", _),
|
|
140
|
+
onChange: (e) => i(e.currentTarget.value),
|
|
141
|
+
onBlur: (e) => {
|
|
142
|
+
h && i(ne(e.currentTarget.value, h)), x?.(e);
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
m != null && m !== "" && /* @__PURE__ */ I("span", {
|
|
146
|
+
"aria-hidden": "true",
|
|
147
|
+
className: "pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-[13px] text-muted-foreground",
|
|
148
|
+
children: m
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
H.displayName = "NumberInput";
|
|
155
|
+
var ee = N.forwardRef(({ prefix: e = "$", ...t }, n) => /* @__PURE__ */ I(H, {
|
|
156
|
+
...t,
|
|
157
|
+
ref: n,
|
|
158
|
+
prefix: e,
|
|
159
|
+
inputMode: "decimal",
|
|
160
|
+
format: "money"
|
|
161
|
+
}));
|
|
162
|
+
ee.displayName = "MoneyInput";
|
|
163
|
+
var te = N.forwardRef(({ prefix: e, ...t }, n) => /* @__PURE__ */ I(H, {
|
|
164
|
+
...t,
|
|
165
|
+
ref: n,
|
|
166
|
+
prefix: e,
|
|
167
|
+
inputMode: "numeric",
|
|
168
|
+
format: "int"
|
|
169
|
+
}));
|
|
170
|
+
te.displayName = "QuantityInput";
|
|
171
|
+
function ne(e, t) {
|
|
172
|
+
let n = e.replace(/[$,\s]/g, "");
|
|
173
|
+
if (!n) return e;
|
|
174
|
+
let r = Number(n);
|
|
175
|
+
return Number.isFinite(r) ? new Intl.NumberFormat("en-US", {
|
|
176
|
+
maximumFractionDigits: t === "money" ? 2 : 0,
|
|
177
|
+
minimumFractionDigits: t === "money" && !Number.isInteger(r) ? 2 : 0
|
|
178
|
+
}).format(r) : e;
|
|
179
|
+
}
|
|
180
|
+
function re(e, t) {
|
|
181
|
+
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/components/select-menu.tsx
|
|
185
|
+
function U({ id: e, value: n, onChange: i, options: a, placeholder: o, ariaLabel: s, className: c = "", compact: l = !1, density: u, tone: d, disabled: f, "aria-describedby": p, "aria-invalid": m }) {
|
|
186
|
+
let h = N.useId(), g = e ?? h, _ = `${g}-list`, [v, y] = N.useState(!1), [b, x] = N.useState(-1), [S, C] = N.useState(!1), w = N.useRef(null), T = N.useRef(null), E = N.useRef({
|
|
187
|
+
text: "",
|
|
188
|
+
at: 0
|
|
189
|
+
}), D = a.findIndex((e) => e.value === n), O = D >= 0 ? a[D] : null, k = (e) => e >= 0 && e < a.length && !a[e].disabled, A = (e = D) => {
|
|
190
|
+
x(k(e) ? e : a.findIndex((e) => !e.disabled)), y(!0);
|
|
191
|
+
}, j = (e = !0) => {
|
|
192
|
+
y(!1), e && w.current?.querySelector("button")?.focus();
|
|
193
|
+
}, M = (e) => {
|
|
194
|
+
k(e) && (a[e].value !== n && i(a[e].value), j());
|
|
195
|
+
}, P = (e, t) => {
|
|
196
|
+
for (let n = e + t; n >= 0 && n < a.length; n += t) if (!a[n].disabled) return n;
|
|
197
|
+
return e;
|
|
198
|
+
};
|
|
199
|
+
return N.useEffect(() => {
|
|
200
|
+
if (!v) return;
|
|
201
|
+
let e = (e) => {
|
|
202
|
+
w.current?.contains(e.target) || y(!1);
|
|
203
|
+
};
|
|
204
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
205
|
+
}, [v]), N.useLayoutEffect(() => {
|
|
206
|
+
if (!v || !w.current) return;
|
|
207
|
+
let e = w.current.getBoundingClientRect();
|
|
208
|
+
C(window.innerHeight - e.bottom < 260 && e.top > window.innerHeight - e.bottom);
|
|
209
|
+
}, [v]), N.useEffect(() => {
|
|
210
|
+
v && b >= 0 && (T.current?.children[b])?.scrollIntoView?.({ block: "nearest" });
|
|
211
|
+
}, [v, b]), /* @__PURE__ */ L("div", {
|
|
212
|
+
ref: w,
|
|
213
|
+
className: r("relative", t(u), c.includes("w-") ? void 0 : "w-full", c),
|
|
214
|
+
children: [/* @__PURE__ */ L("button", {
|
|
215
|
+
id: g,
|
|
216
|
+
"data-density": u,
|
|
217
|
+
type: "button",
|
|
218
|
+
role: "combobox",
|
|
219
|
+
"aria-haspopup": "listbox",
|
|
220
|
+
"aria-expanded": v,
|
|
221
|
+
"aria-controls": _,
|
|
222
|
+
"aria-label": s,
|
|
223
|
+
"aria-activedescendant": v && b >= 0 ? `${_}-${b}` : void 0,
|
|
224
|
+
"aria-describedby": p,
|
|
225
|
+
"aria-invalid": m,
|
|
226
|
+
disabled: f,
|
|
227
|
+
className: r("wos-field flex items-center justify-between gap-2 text-left", u ? "h-[var(--wos-control-height)]" : l ? "h-8" : "h-9", d),
|
|
228
|
+
onClick: () => v ? j(!1) : A(),
|
|
229
|
+
onKeyDown: (e) => {
|
|
230
|
+
let t = e.key;
|
|
231
|
+
if (!v) [
|
|
232
|
+
"ArrowDown",
|
|
233
|
+
"ArrowUp",
|
|
234
|
+
"Enter",
|
|
235
|
+
" "
|
|
236
|
+
].includes(t) && (e.preventDefault(), A());
|
|
237
|
+
else if (t === "Escape") e.preventDefault(), j();
|
|
238
|
+
else if (t === "Tab") y(!1);
|
|
239
|
+
else if (t === "ArrowDown") e.preventDefault(), x((e) => P(e, 1));
|
|
240
|
+
else if (t === "ArrowUp") e.preventDefault(), x((e) => P(e, -1));
|
|
241
|
+
else if (t === "Home") e.preventDefault(), x(P(-1, 1));
|
|
242
|
+
else if (t === "End") e.preventDefault(), x(P(a.length, -1));
|
|
243
|
+
else if (t === "Enter" || t === " ") e.preventDefault(), M(b);
|
|
244
|
+
else if (t.length === 1 && /\S/.test(t)) {
|
|
245
|
+
let e = Date.now(), n = e - E.current.at < 500 ? E.current.text + t.toLowerCase() : t.toLowerCase();
|
|
246
|
+
E.current = {
|
|
247
|
+
text: n,
|
|
248
|
+
at: e
|
|
249
|
+
};
|
|
250
|
+
let r = n.length === 1 ? b + 1 : b, i = [...a.keys()].map((e) => (r + e) % a.length).find((e) => k(e) && a[e].label.toLowerCase().startsWith(n));
|
|
251
|
+
i !== void 0 && x(i);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
children: [/* @__PURE__ */ I("span", {
|
|
255
|
+
className: r("truncate", O ? void 0 : "text-muted-foreground"),
|
|
256
|
+
children: O?.label ?? o ?? "Choose"
|
|
257
|
+
}), /* @__PURE__ */ I(B, {
|
|
258
|
+
name: "chevron-down",
|
|
259
|
+
className: r("shrink-0 text-muted-foreground transition-transform", v && "rotate-180")
|
|
260
|
+
})]
|
|
261
|
+
}), v && /* @__PURE__ */ I("ul", {
|
|
262
|
+
ref: T,
|
|
263
|
+
id: _,
|
|
264
|
+
role: "listbox",
|
|
265
|
+
"aria-labelledby": s ? void 0 : g,
|
|
266
|
+
"aria-label": s,
|
|
267
|
+
className: r("absolute left-0 z-50 max-h-[280px] min-w-full overflow-y-auto rounded-[var(--control-radius)] border border-border bg-surface py-1 shadow-working", S ? "bottom-full mb-1" : "top-full mt-1"),
|
|
268
|
+
children: a.map((e, t) => /* @__PURE__ */ L("li", {
|
|
269
|
+
id: `${_}-${t}`,
|
|
270
|
+
role: "option",
|
|
271
|
+
"data-active": t === b || void 0,
|
|
272
|
+
"aria-selected": t === D,
|
|
273
|
+
"aria-disabled": e.disabled || void 0,
|
|
274
|
+
className: r("wos-option flex cursor-pointer items-center gap-2 whitespace-nowrap px-3 text-[length:var(--wos-control-font-size,var(--type-size-control))]", u ? "h-[var(--wos-control-height)]" : "h-9", e.disabled ? "cursor-default text-muted-foreground" : t === b ? "bg-surface-subtle text-foreground" : "text-secondary-foreground"),
|
|
275
|
+
onPointerEnter: () => !e.disabled && x(t),
|
|
276
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
277
|
+
onClick: () => M(t),
|
|
278
|
+
children: [/* @__PURE__ */ I("span", {
|
|
279
|
+
className: "w-4 shrink-0",
|
|
280
|
+
children: t === D && /* @__PURE__ */ I(B, {
|
|
281
|
+
name: "check",
|
|
282
|
+
size: 14,
|
|
283
|
+
className: "text-selected"
|
|
284
|
+
})
|
|
285
|
+
}), /* @__PURE__ */ I("span", {
|
|
286
|
+
className: t === D ? "font-medium text-foreground" : void 0,
|
|
287
|
+
children: e.label
|
|
288
|
+
})]
|
|
289
|
+
}, e.value || `empty-${t}`))
|
|
290
|
+
})]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
U.displayName = "SelectMenu", U.fieldControl = !0;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/components/select.tsx
|
|
296
|
+
function ie({ label: e, value: t, onChange: n, options: r, help: i, error: a, placeholder: s, compact: c, density: l, disabled: u, className: d, menuClassName: f, id: p }) {
|
|
297
|
+
return /* @__PURE__ */ I(o, {
|
|
298
|
+
label: e,
|
|
299
|
+
help: i,
|
|
300
|
+
error: a,
|
|
301
|
+
htmlFor: p,
|
|
302
|
+
className: d,
|
|
303
|
+
children: /* @__PURE__ */ I(U, {
|
|
304
|
+
id: p,
|
|
305
|
+
value: t,
|
|
306
|
+
onChange: n,
|
|
307
|
+
options: r,
|
|
308
|
+
placeholder: s,
|
|
309
|
+
compact: c,
|
|
310
|
+
density: l,
|
|
311
|
+
disabled: u,
|
|
312
|
+
className: f
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
ie.displayName = "Select";
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/components/date-input.tsx
|
|
319
|
+
var W = [
|
|
320
|
+
"January",
|
|
321
|
+
"February",
|
|
322
|
+
"March",
|
|
323
|
+
"April",
|
|
324
|
+
"May",
|
|
325
|
+
"June",
|
|
326
|
+
"July",
|
|
327
|
+
"August",
|
|
328
|
+
"September",
|
|
329
|
+
"October",
|
|
330
|
+
"November",
|
|
331
|
+
"December"
|
|
332
|
+
], ae = [
|
|
333
|
+
"Jan",
|
|
334
|
+
"Feb",
|
|
335
|
+
"Mar",
|
|
336
|
+
"Apr",
|
|
337
|
+
"May",
|
|
338
|
+
"Jun",
|
|
339
|
+
"Jul",
|
|
340
|
+
"Aug",
|
|
341
|
+
"Sep",
|
|
342
|
+
"Oct",
|
|
343
|
+
"Nov",
|
|
344
|
+
"Dec"
|
|
345
|
+
], oe = [
|
|
346
|
+
"Su",
|
|
347
|
+
"Mo",
|
|
348
|
+
"Tu",
|
|
349
|
+
"We",
|
|
350
|
+
"Th",
|
|
351
|
+
"Fr",
|
|
352
|
+
"Sa"
|
|
353
|
+
], se = [
|
|
354
|
+
"Sunday",
|
|
355
|
+
"Monday",
|
|
356
|
+
"Tuesday",
|
|
357
|
+
"Wednesday",
|
|
358
|
+
"Thursday",
|
|
359
|
+
"Friday",
|
|
360
|
+
"Saturday"
|
|
361
|
+
], G = /^\d{4}-\d{2}-\d{2}$/, K = (e) => String(e).padStart(2, "0"), q = (e, t, n) => {
|
|
362
|
+
let r = new Date(Date.UTC(e, t, n));
|
|
363
|
+
return `${r.getUTCFullYear()}-${K(r.getUTCMonth() + 1)}-${K(r.getUTCDate())}`;
|
|
364
|
+
}, J = (e) => ({
|
|
365
|
+
year: Number(e.slice(0, 4)),
|
|
366
|
+
month: Number(e.slice(5, 7)) - 1,
|
|
367
|
+
day: Number(e.slice(8, 10))
|
|
368
|
+
}), Y = (e, t) => {
|
|
369
|
+
let { year: n, month: r, day: i } = J(e);
|
|
370
|
+
return q(n, r, i + t);
|
|
371
|
+
}, X = (e, t) => {
|
|
372
|
+
let { year: n, month: r, day: i } = J(e), a = new Date(Date.UTC(n, r + t + 1, 0)).getUTCDate();
|
|
373
|
+
return q(n, r + t, Math.min(i, a));
|
|
374
|
+
}, Z = (e) => {
|
|
375
|
+
let { year: t, month: n, day: r } = J(e);
|
|
376
|
+
return new Date(Date.UTC(t, n, r)).getUTCDay();
|
|
377
|
+
}, ce = () => {
|
|
378
|
+
let e = /* @__PURE__ */ new Date();
|
|
379
|
+
return `${e.getFullYear()}-${K(e.getMonth() + 1)}-${K(e.getDate())}`;
|
|
380
|
+
}, le = (e) => G.test(e) ? `${e.slice(5, 7)}/${e.slice(8, 10)}/${e.slice(0, 4)}` : "", Q = (e) => {
|
|
381
|
+
let t = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e.trim());
|
|
382
|
+
if (!t) return null;
|
|
383
|
+
let [n, r, i] = [
|
|
384
|
+
Number(t[1]),
|
|
385
|
+
Number(t[2]),
|
|
386
|
+
Number(t[3])
|
|
387
|
+
], a = new Date(Date.UTC(i, n - 1, r));
|
|
388
|
+
return a.getUTCFullYear() !== i || a.getUTCMonth() !== n - 1 || a.getUTCDate() !== r ? null : `${i}-${K(n)}-${K(r)}`;
|
|
389
|
+
};
|
|
390
|
+
function ue(e) {
|
|
391
|
+
let t = e.replace(/[^\d]/g, "").slice(0, 8);
|
|
392
|
+
return e.includes("/") ? e.replace(/[^\d/]/g, "").slice(0, 10) : t.length > 4 ? `${t.slice(0, 2)}/${t.slice(2, 4)}/${t.slice(4)}` : t.length > 2 ? `${t.slice(0, 2)}/${t.slice(2)}` : t;
|
|
393
|
+
}
|
|
394
|
+
function $({ id: e, value: n, onChange: i, ariaLabel: a, min: o, max: s, disabled: c, required: l, invalid: u, compact: d, density: f, longDisplay: p, className: m = "", "aria-describedby": h, "aria-errormessage": g, "aria-invalid": _ }) {
|
|
395
|
+
let v = N.useId(), y = e ?? v, [b, x] = N.useState(le(n)), [S, C] = N.useState(!1), [w, T] = N.useState(!1), E = !!p && !w && G.test(n) && Q(b) === n, D = N.useRef(null), O = N.useRef(null);
|
|
396
|
+
N.useEffect(() => {
|
|
397
|
+
Q(b) !== n && (n !== "" || b === "" || Q(b) !== null) && x(le(n));
|
|
398
|
+
}, [n]), N.useEffect(() => {
|
|
399
|
+
if (!S) return;
|
|
400
|
+
let e = (e) => {
|
|
401
|
+
D.current?.contains(e.target) || C(!1);
|
|
402
|
+
};
|
|
403
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
404
|
+
}, [S]);
|
|
405
|
+
let k = (e) => {
|
|
406
|
+
let t = ue(e);
|
|
407
|
+
x(t), i(Q(t) ?? "");
|
|
408
|
+
};
|
|
409
|
+
return /* @__PURE__ */ L("div", {
|
|
410
|
+
ref: D,
|
|
411
|
+
className: r("relative", t(f), m),
|
|
412
|
+
children: [
|
|
413
|
+
/* @__PURE__ */ I("input", {
|
|
414
|
+
id: y,
|
|
415
|
+
"data-density": f,
|
|
416
|
+
className: r("wos-field pr-9 tabular disabled:cursor-not-allowed", !f && d && "h-8", E && "text-transparent"),
|
|
417
|
+
inputMode: "numeric",
|
|
418
|
+
placeholder: "MM/DD/YYYY",
|
|
419
|
+
autoComplete: "off",
|
|
420
|
+
required: l,
|
|
421
|
+
value: b,
|
|
422
|
+
onFocus: () => T(!0),
|
|
423
|
+
onBlur: () => T(!1),
|
|
424
|
+
disabled: c,
|
|
425
|
+
"aria-label": a,
|
|
426
|
+
"aria-invalid": u || _ || void 0,
|
|
427
|
+
"aria-describedby": h,
|
|
428
|
+
"aria-errormessage": g,
|
|
429
|
+
onChange: (e) => k(e.currentTarget.value)
|
|
430
|
+
}),
|
|
431
|
+
E && /* @__PURE__ */ I("span", {
|
|
432
|
+
"aria-hidden": "true",
|
|
433
|
+
className: "pointer-events-none absolute inset-y-0 left-3 flex items-center text-[length:var(--wos-control-font-size,var(--type-size-control))] tabular",
|
|
434
|
+
"data-testid": "date-long",
|
|
435
|
+
children: fe(n)
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ I("button", {
|
|
438
|
+
ref: O,
|
|
439
|
+
type: "button",
|
|
440
|
+
disabled: c,
|
|
441
|
+
className: r("absolute inset-y-0 right-0.5 my-auto grid place-items-center rounded-[var(--control-radius-inner)] text-muted-foreground hover:bg-interaction-hover hover:text-foreground disabled:pointer-events-none", f ? "h-[calc(var(--wos-control-height)-4px)] w-[calc(var(--wos-control-height)-4px)]" : d ? "h-7 w-7" : "h-8 w-8"),
|
|
442
|
+
"aria-label": `Choose ${a ? a.toLowerCase() : "date"} from a calendar`,
|
|
443
|
+
"aria-haspopup": "dialog",
|
|
444
|
+
"aria-expanded": S,
|
|
445
|
+
onClick: () => C(!S),
|
|
446
|
+
children: /* @__PURE__ */ I(B, { name: "calendar" })
|
|
447
|
+
}),
|
|
448
|
+
S && /* @__PURE__ */ I(pe, {
|
|
449
|
+
value: G.test(n) ? n : null,
|
|
450
|
+
min: o,
|
|
451
|
+
max: s,
|
|
452
|
+
onPick: (e) => {
|
|
453
|
+
x(le(e)), i(e), C(!1), O.current?.focus();
|
|
454
|
+
},
|
|
455
|
+
onClose: () => {
|
|
456
|
+
C(!1), O.current?.focus();
|
|
457
|
+
},
|
|
458
|
+
anchor: D
|
|
459
|
+
})
|
|
460
|
+
]
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
$.displayName = "DateInput", $.fieldControl = !0;
|
|
464
|
+
function de({ label: e, help: t, error: n, confirm: r, ...i }) {
|
|
465
|
+
return /* @__PURE__ */ L("div", { children: [/* @__PURE__ */ I(o, {
|
|
466
|
+
label: e,
|
|
467
|
+
help: t,
|
|
468
|
+
error: n,
|
|
469
|
+
htmlFor: i.id,
|
|
470
|
+
children: /* @__PURE__ */ I($, {
|
|
471
|
+
...i,
|
|
472
|
+
ariaLabel: typeof e == "string" ? e : void 0,
|
|
473
|
+
invalid: i.invalid || !!n
|
|
474
|
+
})
|
|
475
|
+
}), !n && r && /* @__PURE__ */ I("p", {
|
|
476
|
+
className: "mt-1 text-[length:var(--type-size-metadata)] text-secondary-foreground",
|
|
477
|
+
children: r
|
|
478
|
+
})] });
|
|
479
|
+
}
|
|
480
|
+
de.displayName = "UsDateInput";
|
|
481
|
+
function fe(e) {
|
|
482
|
+
let { year: t, month: n, day: r } = J(e);
|
|
483
|
+
return `${ae[n]} ${r}, ${t}`;
|
|
484
|
+
}
|
|
485
|
+
function pe({ value: e, min: t, max: n, onPick: i, onClose: a, anchor: o }) {
|
|
486
|
+
let s = ce(), c = (e) => t && e < t ? t : n && e > n ? n : e, [l, u] = N.useState(() => c(e ?? s)), [d, f] = N.useState(!1), p = N.useRef(null), { year: m, month: h } = J(l), g = (e) => (!t || e >= t) && (!n || e <= n);
|
|
487
|
+
N.useLayoutEffect(() => {
|
|
488
|
+
let e = o.current?.getBoundingClientRect();
|
|
489
|
+
e && f(window.innerHeight - e.bottom < 360 && e.top > window.innerHeight - e.bottom);
|
|
490
|
+
}, [o]), N.useEffect(() => {
|
|
491
|
+
p.current?.querySelector(`[data-day="${l}"]`)?.focus();
|
|
492
|
+
}, [l]);
|
|
493
|
+
let _ = q(m, h, 1), v = Y(_, -Z(_)), y = Array.from({ length: 42 }, (e, t) => Y(v, t)), b = (e) => u(c(e)), x = (e) => {
|
|
494
|
+
let t = {
|
|
495
|
+
ArrowLeft: () => Y(l, -1),
|
|
496
|
+
ArrowRight: () => Y(l, 1),
|
|
497
|
+
ArrowUp: () => Y(l, -7),
|
|
498
|
+
ArrowDown: () => Y(l, 7),
|
|
499
|
+
Home: () => Y(l, -Z(l)),
|
|
500
|
+
End: () => Y(l, 6 - Z(l)),
|
|
501
|
+
PageUp: () => X(l, e.shiftKey ? -12 : -1),
|
|
502
|
+
PageDown: () => X(l, e.shiftKey ? 12 : 1)
|
|
503
|
+
};
|
|
504
|
+
t[e.key] ? (e.preventDefault(), b(t[e.key]())) : e.key === "Escape" && (e.preventDefault(), a());
|
|
505
|
+
}, S = (e, t, n) => /* @__PURE__ */ I("button", {
|
|
506
|
+
type: "button",
|
|
507
|
+
className: "grid h-8 w-8 place-items-center rounded-[var(--control-radius-inner)] text-secondary-foreground hover:bg-interaction-hover",
|
|
508
|
+
"aria-label": e,
|
|
509
|
+
onClick: () => b(n),
|
|
510
|
+
children: t
|
|
511
|
+
});
|
|
512
|
+
return /* @__PURE__ */ L("div", {
|
|
513
|
+
role: "dialog",
|
|
514
|
+
"aria-modal": "false",
|
|
515
|
+
"aria-label": "Choose a date",
|
|
516
|
+
className: r("absolute right-0 z-50 w-[300px] rounded-[var(--surface-radius)] border border-border bg-surface p-3 shadow-working", d ? "bottom-full mb-1" : "top-full mt-1"),
|
|
517
|
+
onKeyDown: x,
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ L("div", {
|
|
520
|
+
className: "flex items-center justify-between",
|
|
521
|
+
children: [
|
|
522
|
+
/* @__PURE__ */ L("div", {
|
|
523
|
+
className: "flex",
|
|
524
|
+
children: [S("Previous year", /* @__PURE__ */ I(B, { name: "chevrons-left" }), X(l, -12)), S("Previous month", /* @__PURE__ */ I(B, { name: "chevron-left" }), X(l, -1))]
|
|
525
|
+
}),
|
|
526
|
+
/* @__PURE__ */ L("p", {
|
|
527
|
+
className: "text-[length:var(--type-size-control)] font-semibold text-foreground",
|
|
528
|
+
"aria-live": "polite",
|
|
529
|
+
children: [
|
|
530
|
+
W[h],
|
|
531
|
+
" ",
|
|
532
|
+
m
|
|
533
|
+
]
|
|
534
|
+
}),
|
|
535
|
+
/* @__PURE__ */ L("div", {
|
|
536
|
+
className: "flex",
|
|
537
|
+
children: [S("Next month", /* @__PURE__ */ I(B, { name: "chevron-right" }), X(l, 1)), S("Next year", /* @__PURE__ */ I(B, { name: "chevrons-right" }), X(l, 12))]
|
|
538
|
+
})
|
|
539
|
+
]
|
|
540
|
+
}),
|
|
541
|
+
/* @__PURE__ */ L("div", {
|
|
542
|
+
ref: p,
|
|
543
|
+
role: "grid",
|
|
544
|
+
"aria-label": `${W[h]} ${m}`,
|
|
545
|
+
className: "mt-2",
|
|
546
|
+
children: [/* @__PURE__ */ I("div", {
|
|
547
|
+
role: "row",
|
|
548
|
+
className: "grid grid-cols-7",
|
|
549
|
+
children: oe.map((e) => /* @__PURE__ */ I("span", {
|
|
550
|
+
role: "columnheader",
|
|
551
|
+
className: "grid h-8 place-items-center text-[12px] font-medium text-muted-foreground",
|
|
552
|
+
children: e
|
|
553
|
+
}, e))
|
|
554
|
+
}), [
|
|
555
|
+
0,
|
|
556
|
+
1,
|
|
557
|
+
2,
|
|
558
|
+
3,
|
|
559
|
+
4,
|
|
560
|
+
5
|
|
561
|
+
].map((t) => /* @__PURE__ */ I("div", {
|
|
562
|
+
role: "row",
|
|
563
|
+
className: "grid grid-cols-7",
|
|
564
|
+
children: y.slice(t * 7, t * 7 + 7).map((t) => {
|
|
565
|
+
let n = J(t).month === h, a = t === e, o = g(t);
|
|
566
|
+
return /* @__PURE__ */ I("span", {
|
|
567
|
+
role: "gridcell",
|
|
568
|
+
children: /* @__PURE__ */ I("button", {
|
|
569
|
+
type: "button",
|
|
570
|
+
"data-day": t,
|
|
571
|
+
tabIndex: t === l ? 0 : -1,
|
|
572
|
+
disabled: !o,
|
|
573
|
+
"aria-selected": a,
|
|
574
|
+
"aria-current": t === s ? "date" : void 0,
|
|
575
|
+
"aria-label": me(t),
|
|
576
|
+
className: r("tabular grid h-9 w-full place-items-center rounded-[var(--control-radius-inner)] text-[length:var(--type-size-control)] outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-color)] disabled:cursor-not-allowed disabled:opacity-[var(--state-disabled-opacity)]", a ? "bg-selection-indicator font-semibold text-selection-indicator-foreground" : t === s ? "font-semibold text-link hover:bg-interaction-hover" : n ? "text-foreground hover:bg-interaction-hover" : "text-muted-foreground hover:bg-interaction-hover"),
|
|
577
|
+
onClick: () => i(t),
|
|
578
|
+
children: J(t).day
|
|
579
|
+
})
|
|
580
|
+
}, t);
|
|
581
|
+
})
|
|
582
|
+
}, t))]
|
|
583
|
+
}),
|
|
584
|
+
/* @__PURE__ */ L("div", {
|
|
585
|
+
className: "mt-2 flex items-center justify-between border-t border-border-subtle pt-2",
|
|
586
|
+
children: [/* @__PURE__ */ I("button", {
|
|
587
|
+
type: "button",
|
|
588
|
+
className: "rounded-[var(--control-radius-inner)] px-2 py-1 text-[13px] font-medium text-link hover:bg-interaction-hover disabled:text-muted-foreground",
|
|
589
|
+
disabled: !g(s),
|
|
590
|
+
onClick: () => i(s),
|
|
591
|
+
children: "Today"
|
|
592
|
+
}), /* @__PURE__ */ I("button", {
|
|
593
|
+
type: "button",
|
|
594
|
+
className: "rounded-[var(--control-radius-inner)] px-2 py-1 text-[13px] text-secondary-foreground hover:bg-interaction-hover",
|
|
595
|
+
onClick: a,
|
|
596
|
+
children: "Close"
|
|
597
|
+
})]
|
|
598
|
+
})
|
|
599
|
+
]
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
function me(e) {
|
|
603
|
+
let { year: t, month: n, day: r } = J(e);
|
|
604
|
+
return `${se[Z(e)]}, ${W[n]} ${r}, ${t}`;
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/components/date-range-picker.tsx
|
|
608
|
+
function he({ label: e, value: t, onChange: n, help: r, error: i, min: a, max: o, disabled: s, required: c, density: l, className: u, id: d }) {
|
|
609
|
+
let f = N.useId(), p = typeof e == "string" || typeof e == "number" ? String(e) : "Date range", m = !ge(t, a, o), h = t.start && t.end && t.start > t.end ? "End date must be on or after the start date." : a && t.start && t.start < a ? `Start date must be on or after ${a}.` : o && t.end && t.end > o ? `End date must be on or before ${o}.` : void 0, g = i ?? (m ? h : void 0), _ = [r ? `${d ?? f}-help` : void 0, g ? `${d ?? f}-error` : void 0].filter(Boolean).join(" ") || void 0, v = t.end && (!o || t.end < o) ? t.end : o, y = t.start && (!a || t.start > a) ? t.start : a;
|
|
610
|
+
return /* @__PURE__ */ L("fieldset", {
|
|
611
|
+
className: u,
|
|
612
|
+
children: [
|
|
613
|
+
/* @__PURE__ */ L("legend", {
|
|
614
|
+
className: "mb-2 type-label text-secondary-foreground",
|
|
615
|
+
children: [e, c && /* @__PURE__ */ I("span", {
|
|
616
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
617
|
+
children: "Required"
|
|
618
|
+
})]
|
|
619
|
+
}),
|
|
620
|
+
/* @__PURE__ */ L("div", {
|
|
621
|
+
className: "grid min-w-0 gap-3 sm:grid-cols-2",
|
|
622
|
+
children: [/* @__PURE__ */ L("div", { children: [/* @__PURE__ */ I("span", {
|
|
623
|
+
className: "mb-1 block type-caption text-muted-foreground",
|
|
624
|
+
children: "Start date"
|
|
625
|
+
}), /* @__PURE__ */ I($, {
|
|
626
|
+
density: l,
|
|
627
|
+
id: `${d ?? f}-start`,
|
|
628
|
+
value: t.start,
|
|
629
|
+
onChange: (e) => n({
|
|
630
|
+
start: e,
|
|
631
|
+
end: t.end
|
|
632
|
+
}),
|
|
633
|
+
ariaLabel: `${p} start date`,
|
|
634
|
+
min: a,
|
|
635
|
+
max: v,
|
|
636
|
+
disabled: s,
|
|
637
|
+
required: c,
|
|
638
|
+
invalid: !!g,
|
|
639
|
+
"aria-describedby": _
|
|
640
|
+
})] }), /* @__PURE__ */ L("div", { children: [/* @__PURE__ */ I("span", {
|
|
641
|
+
className: "mb-1 block type-caption text-muted-foreground",
|
|
642
|
+
children: "End date"
|
|
643
|
+
}), /* @__PURE__ */ I($, {
|
|
644
|
+
density: l,
|
|
645
|
+
id: `${d ?? f}-end`,
|
|
646
|
+
value: t.end,
|
|
647
|
+
onChange: (e) => n({
|
|
648
|
+
start: t.start,
|
|
649
|
+
end: e
|
|
650
|
+
}),
|
|
651
|
+
ariaLabel: `${p} end date`,
|
|
652
|
+
min: y,
|
|
653
|
+
max: o,
|
|
654
|
+
disabled: s,
|
|
655
|
+
required: c,
|
|
656
|
+
invalid: !!g,
|
|
657
|
+
"aria-describedby": _
|
|
658
|
+
})] })]
|
|
659
|
+
}),
|
|
660
|
+
r && /* @__PURE__ */ I("p", {
|
|
661
|
+
id: `${d ?? f}-help`,
|
|
662
|
+
className: "mt-1 type-caption text-muted-foreground",
|
|
663
|
+
children: r
|
|
664
|
+
}),
|
|
665
|
+
g && /* @__PURE__ */ I("p", {
|
|
666
|
+
id: `${d ?? f}-error`,
|
|
667
|
+
className: "mt-1 type-caption text-destructive",
|
|
668
|
+
children: g
|
|
669
|
+
})
|
|
670
|
+
]
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function ge(e, t, n) {
|
|
674
|
+
return (!e.start || !e.end || e.start <= e.end) && (!t || !e.start || e.start >= t) && (!n || !e.end || e.end <= n);
|
|
675
|
+
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/components/advanced-controls.tsx
|
|
678
|
+
var _e = (e, t) => typeof e == "string" || typeof e == "number" ? String(e) : t;
|
|
679
|
+
function ve({ label: e, value: n, onChange: i, options: a, help: s, error: c, placeholder: l = "Search options", emptyMessage: u = "No results found.", disabled: d, required: f, clearable: p = !0, loading: m, className: h, id: g, allowCustomValue: _, onValueSubmit: v, name: y, density: b }) {
|
|
680
|
+
let x = N.useId(), S = g ?? x, C = `${S}-options`, [w, T] = N.useState(!1), [E, D] = N.useState(""), [O, k] = N.useState(0), A = N.useRef(null), j = N.useRef(null), M = N.useRef(null), P = a.find((e) => e.value === n), F = a.filter((e) => e.label.toLocaleLowerCase().includes(E.toLocaleLowerCase())), R = (e = 0) => {
|
|
681
|
+
for (let t = e; t < F.length; t++) if (!F[t].disabled) return t;
|
|
682
|
+
return -1;
|
|
683
|
+
}, z = () => {
|
|
684
|
+
for (let e = F.length - 1; e >= 0; e--) if (!F[e].disabled) return e;
|
|
685
|
+
return -1;
|
|
686
|
+
};
|
|
687
|
+
N.useEffect(() => {
|
|
688
|
+
if (!w) return;
|
|
689
|
+
let e = (e) => {
|
|
690
|
+
A.current?.contains(e.target) || T(!1);
|
|
691
|
+
};
|
|
692
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
693
|
+
}, [w]), N.useEffect(() => {
|
|
694
|
+
w && (M.current?.querySelector(`[data-index="${O}"]`))?.scrollIntoView?.({ block: "nearest" });
|
|
695
|
+
}, [w, O]);
|
|
696
|
+
let H = (e) => {
|
|
697
|
+
e.disabled || (i(e.value), D(""), T(!1), j.current?.focus());
|
|
698
|
+
};
|
|
699
|
+
return /* @__PURE__ */ I(o, {
|
|
700
|
+
label: e,
|
|
701
|
+
help: s,
|
|
702
|
+
error: c,
|
|
703
|
+
htmlFor: S,
|
|
704
|
+
required: f,
|
|
705
|
+
className: h,
|
|
706
|
+
children: /* @__PURE__ */ L("div", {
|
|
707
|
+
ref: A,
|
|
708
|
+
className: r("relative", t(b)),
|
|
709
|
+
"data-field-container": "true",
|
|
710
|
+
children: [
|
|
711
|
+
/* @__PURE__ */ I(V, {
|
|
712
|
+
density: b,
|
|
713
|
+
ref: j,
|
|
714
|
+
id: S,
|
|
715
|
+
name: _ ? y : void 0,
|
|
716
|
+
role: "combobox",
|
|
717
|
+
"aria-autocomplete": "list",
|
|
718
|
+
"aria-expanded": w,
|
|
719
|
+
"aria-controls": C,
|
|
720
|
+
"aria-activedescendant": w && O >= 0 ? `${C}-${O}` : void 0,
|
|
721
|
+
"aria-describedby": [s && `${S}-help`, c && `${S}-error`].filter(Boolean).join(" ") || void 0,
|
|
722
|
+
required: f,
|
|
723
|
+
placeholder: P && !w ? P.label : l,
|
|
724
|
+
value: w ? E : P?.label ?? (_ ? n : ""),
|
|
725
|
+
disabled: d,
|
|
726
|
+
invalid: !!c,
|
|
727
|
+
onFocus: () => {
|
|
728
|
+
T(!0), D(_ ? n : ""), k(-1);
|
|
729
|
+
},
|
|
730
|
+
onChange: (e) => {
|
|
731
|
+
D(e.currentTarget.value), _ && i(e.currentTarget.value), k(R()), T(!0);
|
|
732
|
+
},
|
|
733
|
+
onKeyDown: (e) => {
|
|
734
|
+
if (e.key === "ArrowDown") e.preventDefault(), w || T(!0), k((e) => {
|
|
735
|
+
for (let t = Math.max(e + 1, 0); t < F.length; t++) if (!F[t].disabled) return t;
|
|
736
|
+
return R();
|
|
737
|
+
});
|
|
738
|
+
else if (e.key === "ArrowUp" && w) e.preventDefault(), k((e) => {
|
|
739
|
+
if (e < 0) return z();
|
|
740
|
+
for (let t = e - 1; t >= 0; t--) if (!F[t].disabled) return t;
|
|
741
|
+
return e;
|
|
742
|
+
});
|
|
743
|
+
else if (e.key === "Home" && w) e.preventDefault(), k(R());
|
|
744
|
+
else if (e.key === "End" && w) e.preventDefault(), k(z());
|
|
745
|
+
else if (e.key === "Enter" && w) {
|
|
746
|
+
e.preventDefault();
|
|
747
|
+
let t = F[O];
|
|
748
|
+
t && !t.disabled ? H(t) : _ && v?.();
|
|
749
|
+
} else e.key === "Escape" && w ? (e.preventDefault(), T(!1), D("")) : e.key === "Tab" && T(!1);
|
|
750
|
+
},
|
|
751
|
+
autoComplete: "off"
|
|
752
|
+
}),
|
|
753
|
+
y && !_ && /* @__PURE__ */ I("input", {
|
|
754
|
+
type: "hidden",
|
|
755
|
+
name: y,
|
|
756
|
+
value: n,
|
|
757
|
+
disabled: d
|
|
758
|
+
}),
|
|
759
|
+
/* @__PURE__ */ L("div", {
|
|
760
|
+
className: "absolute inset-y-0 right-1 flex items-center gap-0.5",
|
|
761
|
+
children: [p && n !== "" && /* @__PURE__ */ I("button", {
|
|
762
|
+
type: "button",
|
|
763
|
+
"aria-label": "Clear selection",
|
|
764
|
+
disabled: d,
|
|
765
|
+
className: "grid h-7 w-7 place-items-center rounded-[var(--control-radius-inner)] text-muted-foreground hover:bg-interaction-hover disabled:cursor-not-allowed disabled:opacity-[var(--state-disabled-opacity)]",
|
|
766
|
+
onClick: () => {
|
|
767
|
+
i(""), D(""), k(-1), T(!0), j.current?.focus();
|
|
768
|
+
},
|
|
769
|
+
children: "×"
|
|
770
|
+
}), /* @__PURE__ */ I(B, {
|
|
771
|
+
name: "chevron-down",
|
|
772
|
+
className: r("text-muted-foreground transition-transform", w && "rotate-180")
|
|
773
|
+
})]
|
|
774
|
+
}),
|
|
775
|
+
w && (m || F.length === 0 ? /* @__PURE__ */ I("div", {
|
|
776
|
+
id: C,
|
|
777
|
+
role: "status",
|
|
778
|
+
className: "absolute left-0 right-0 top-full z-50 mt-1 rounded-[var(--control-radius)] border border-border bg-surface px-3 py-2 type-caption text-muted-foreground shadow-working",
|
|
779
|
+
children: m ? "Loading…" : u
|
|
780
|
+
}) : /* @__PURE__ */ I("ul", {
|
|
781
|
+
id: C,
|
|
782
|
+
ref: M,
|
|
783
|
+
role: "listbox",
|
|
784
|
+
"aria-label": `${_e(e, "Search")} options`,
|
|
785
|
+
className: "absolute left-0 right-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-[var(--control-radius)] border border-border bg-surface py-1 shadow-working",
|
|
786
|
+
children: F.map((e, t) => /* @__PURE__ */ L("li", {
|
|
787
|
+
id: `${C}-${t}`,
|
|
788
|
+
"data-index": t,
|
|
789
|
+
role: "option",
|
|
790
|
+
"data-active": t === O || void 0,
|
|
791
|
+
"aria-selected": e.value === n,
|
|
792
|
+
"aria-disabled": e.disabled || void 0,
|
|
793
|
+
className: r("wos-option cursor-pointer px-3 py-2 text-[length:var(--wos-control-font-size,var(--type-size-control))]", b && "min-h-[var(--wos-control-height)]", e.disabled ? "cursor-not-allowed text-muted-foreground opacity-[var(--state-disabled-opacity)]" : t === O ? "bg-surface-subtle" : "text-secondary-foreground"),
|
|
794
|
+
onPointerEnter: () => !e.disabled && k(t),
|
|
795
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
796
|
+
onClick: () => H(e),
|
|
797
|
+
children: [/* @__PURE__ */ I("span", { children: e.label }), e.description && /* @__PURE__ */ I("span", {
|
|
798
|
+
className: "block type-caption text-muted-foreground",
|
|
799
|
+
children: e.description
|
|
800
|
+
})]
|
|
801
|
+
}, e.value))
|
|
802
|
+
}))
|
|
803
|
+
]
|
|
804
|
+
})
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
function ye(e) {
|
|
808
|
+
return /* @__PURE__ */ I(ve, { ...e });
|
|
809
|
+
}
|
|
810
|
+
function be({ label: e, value: t, onChange: n, onSubmit: r, options: i = [], ...a }) {
|
|
811
|
+
return /* @__PURE__ */ I(ve, {
|
|
812
|
+
...a,
|
|
813
|
+
label: e,
|
|
814
|
+
value: t,
|
|
815
|
+
onChange: (e) => n(e),
|
|
816
|
+
options: i,
|
|
817
|
+
allowCustomValue: !0,
|
|
818
|
+
onValueSubmit: () => r?.(t),
|
|
819
|
+
clearable: !0
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function xe({ label: e, value: n, onChange: i, options: a, help: s, error: c, placeholder: l = "Search options", emptyMessage: u = "No results found.", disabled: d, required: f, name: p, className: m, id: h, density: g }) {
|
|
823
|
+
let _ = N.useId(), v = h ?? _, [y, b] = N.useState(""), [x, S] = N.useState(!1), [C, w] = N.useState(0), T = N.useRef(null), E = N.useRef(null), D = `${v}-list`, O = a.filter((e) => e.label.toLowerCase().includes(y.toLowerCase())), k = N.useRef(null), A = (e, t) => {
|
|
824
|
+
for (let n = e; n >= 0 && n < O.length; n += t) if (!O[n].disabled) return n;
|
|
825
|
+
return -1;
|
|
826
|
+
};
|
|
827
|
+
N.useEffect(() => {
|
|
828
|
+
if (!x) return;
|
|
829
|
+
let e = (e) => {
|
|
830
|
+
T.current?.contains(e.target) || S(!1);
|
|
831
|
+
};
|
|
832
|
+
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
833
|
+
}, [x]), N.useEffect(() => {
|
|
834
|
+
x && C >= 0 && document.getElementById(`${D}-${C}`)?.scrollIntoView?.({ block: "nearest" });
|
|
835
|
+
}, [
|
|
836
|
+
x,
|
|
837
|
+
C,
|
|
838
|
+
D
|
|
839
|
+
]);
|
|
840
|
+
let j = (e) => {
|
|
841
|
+
e.disabled || (i(n.includes(e.value) ? n.filter((t) => t !== e.value) : [...n, e.value]), b(""), w(-1), S(!0), E.current?.focus());
|
|
842
|
+
};
|
|
843
|
+
return /* @__PURE__ */ I(o, {
|
|
844
|
+
label: e,
|
|
845
|
+
help: s,
|
|
846
|
+
error: c,
|
|
847
|
+
htmlFor: v,
|
|
848
|
+
required: f,
|
|
849
|
+
className: m,
|
|
850
|
+
children: /* @__PURE__ */ L("div", {
|
|
851
|
+
"data-field-container": "true",
|
|
852
|
+
ref: T,
|
|
853
|
+
"data-invalid": !!c || void 0,
|
|
854
|
+
"data-disabled": d || void 0,
|
|
855
|
+
className: r("wos-multiselect relative rounded-[var(--control-radius)] border border-input bg-surface px-2 py-1.5 focus-within:ring-2 focus-within:ring-ring", t(g)),
|
|
856
|
+
children: [
|
|
857
|
+
p && n.map((e) => /* @__PURE__ */ I("input", {
|
|
858
|
+
type: "hidden",
|
|
859
|
+
name: p,
|
|
860
|
+
value: e,
|
|
861
|
+
disabled: d
|
|
862
|
+
}, e)),
|
|
863
|
+
/* @__PURE__ */ L("div", {
|
|
864
|
+
className: "flex min-h-7 flex-wrap items-center gap-1.5",
|
|
865
|
+
children: [n.map((e) => {
|
|
866
|
+
let t = a.find((t) => t.value === e);
|
|
867
|
+
return /* @__PURE__ */ L("span", {
|
|
868
|
+
className: "inline-flex items-center gap-1 rounded-[var(--control-radius-inner)] bg-selected-subtle px-2 py-1 type-caption text-selected",
|
|
869
|
+
children: [t?.label ?? e, /* @__PURE__ */ I("button", {
|
|
870
|
+
type: "button",
|
|
871
|
+
disabled: d,
|
|
872
|
+
"aria-label": `Remove ${t?.label ?? e}`,
|
|
873
|
+
onClick: () => {
|
|
874
|
+
i(n.filter((t) => t !== e)), E.current?.focus();
|
|
875
|
+
},
|
|
876
|
+
className: "min-h-8 min-w-8 rounded-[var(--control-radius-inner)] hover:text-foreground disabled:cursor-not-allowed",
|
|
877
|
+
children: "×"
|
|
878
|
+
})]
|
|
879
|
+
}, e);
|
|
880
|
+
}), /* @__PURE__ */ I("input", {
|
|
881
|
+
"data-density": g,
|
|
882
|
+
ref: E,
|
|
883
|
+
id: v,
|
|
884
|
+
role: "combobox",
|
|
885
|
+
"aria-expanded": x,
|
|
886
|
+
"aria-controls": D,
|
|
887
|
+
"aria-activedescendant": x && C >= 0 ? `${D}-${C}` : void 0,
|
|
888
|
+
"aria-autocomplete": "list",
|
|
889
|
+
"aria-invalid": !!c || void 0,
|
|
890
|
+
"aria-describedby": [s && `${v}-help`, c && `${v}-error`].filter(Boolean).join(" ") || void 0,
|
|
891
|
+
disabled: d,
|
|
892
|
+
required: f && n.length === 0,
|
|
893
|
+
className: "min-w-28 flex-1 border-0 bg-transparent px-1 py-1 text-[length:var(--wos-control-font-size,var(--type-size-control))] outline-none placeholder:text-muted-foreground",
|
|
894
|
+
placeholder: n.length ? "Add another" : l,
|
|
895
|
+
value: y,
|
|
896
|
+
onFocus: () => {
|
|
897
|
+
S(!0), w(-1);
|
|
898
|
+
},
|
|
899
|
+
onChange: (e) => {
|
|
900
|
+
b(e.currentTarget.value), w(A(0, 1)), S(!0);
|
|
901
|
+
},
|
|
902
|
+
onKeyDown: (e) => {
|
|
903
|
+
e.key === "ArrowDown" ? (e.preventDefault(), S(!0), w((e) => {
|
|
904
|
+
let t = A(e < 0 ? 0 : e + 1, 1);
|
|
905
|
+
return t < 0 ? A(0, 1) : t;
|
|
906
|
+
})) : e.key === "ArrowUp" ? (e.preventDefault(), w((e) => {
|
|
907
|
+
let t = A(e < 0 ? O.length - 1 : e - 1, -1);
|
|
908
|
+
return t < 0 ? A(O.length - 1, -1) : t;
|
|
909
|
+
})) : e.key === "Home" && x ? (e.preventDefault(), w(A(0, 1))) : e.key === "End" && x ? (e.preventDefault(), w(A(O.length - 1, -1))) : e.key === "Enter" && x && O[C] && !O[C].disabled ? (e.preventDefault(), j(O[C])) : e.key === "Escape" ? S(!1) : e.key === "Backspace" && !y && n.length ? i(n.slice(0, -1)) : e.key === "Tab" && S(!1);
|
|
910
|
+
}
|
|
911
|
+
})]
|
|
912
|
+
}),
|
|
913
|
+
x && (O.length ? /* @__PURE__ */ I("ul", {
|
|
914
|
+
id: D,
|
|
915
|
+
ref: k,
|
|
916
|
+
role: "listbox",
|
|
917
|
+
"aria-multiselectable": "true",
|
|
918
|
+
"aria-label": `${_e(e, "Selection")} options`,
|
|
919
|
+
className: "absolute left-0 right-0 top-full z-50 mt-1 max-h-64 overflow-auto rounded-[var(--control-radius)] border border-border bg-surface py-1 shadow-working",
|
|
920
|
+
children: O.map((e, t) => /* @__PURE__ */ L("li", {
|
|
921
|
+
id: `${D}-${t}`,
|
|
922
|
+
"data-index": t,
|
|
923
|
+
role: "option",
|
|
924
|
+
"data-active": t === C || void 0,
|
|
925
|
+
"aria-selected": n.includes(e.value),
|
|
926
|
+
"aria-disabled": e.disabled || void 0,
|
|
927
|
+
className: r("wos-option cursor-pointer px-3 py-2 text-[length:var(--wos-control-font-size,var(--type-size-control))]", g && "min-h-[var(--wos-control-height)]", e.disabled && "opacity-[var(--state-disabled-opacity)]", t === C && "bg-surface-subtle"),
|
|
928
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
929
|
+
onPointerEnter: () => !e.disabled && w(t),
|
|
930
|
+
onClick: () => j(e),
|
|
931
|
+
children: [e.label, n.includes(e.value) && /* @__PURE__ */ I("span", {
|
|
932
|
+
className: "float-right",
|
|
933
|
+
children: "✓"
|
|
934
|
+
})]
|
|
935
|
+
}, e.value))
|
|
936
|
+
}) : /* @__PURE__ */ I("div", {
|
|
937
|
+
id: D,
|
|
938
|
+
role: "status",
|
|
939
|
+
className: "absolute left-0 right-0 top-full z-50 mt-1 rounded-[var(--control-radius)] border border-border bg-surface px-3 py-2 type-caption text-muted-foreground shadow-working",
|
|
940
|
+
children: u
|
|
941
|
+
}))
|
|
942
|
+
]
|
|
943
|
+
})
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function Se({ label: e, help: n, error: i, className: a, onChange: o, density: s, ...c }) {
|
|
947
|
+
let l = N.useId(), u = c.id ?? l, d = n ? `${u}-help` : void 0, f = i ? `${u}-error` : void 0;
|
|
948
|
+
return /* @__PURE__ */ L("label", {
|
|
949
|
+
"data-disabled": c.disabled || void 0,
|
|
950
|
+
"data-density": s,
|
|
951
|
+
className: r("wos-choice-label flex min-h-11 cursor-pointer items-start gap-2.5 py-1.5 rounded-[var(--control-radius)] hover:bg-interaction-hover", t(s), s && "min-h-[var(--wos-control-height)]", c.disabled && "cursor-not-allowed opacity-[var(--state-disabled-opacity)]", a),
|
|
952
|
+
children: [/* @__PURE__ */ I("input", {
|
|
953
|
+
...c,
|
|
954
|
+
id: u,
|
|
955
|
+
type: "checkbox",
|
|
956
|
+
"aria-invalid": !!i || c["aria-invalid"] || void 0,
|
|
957
|
+
"aria-describedby": [
|
|
958
|
+
c["aria-describedby"],
|
|
959
|
+
d,
|
|
960
|
+
f
|
|
961
|
+
].filter(Boolean).join(" ") || void 0,
|
|
962
|
+
className: "wos-choice-input mt-0.5 h-4 w-4 accent-selection-indicator focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
|
|
963
|
+
onChange: (e) => o?.(e.currentTarget.checked, e)
|
|
964
|
+
}), /* @__PURE__ */ L("span", {
|
|
965
|
+
className: "min-w-0",
|
|
966
|
+
children: [
|
|
967
|
+
/* @__PURE__ */ L("span", {
|
|
968
|
+
className: "block type-label text-secondary-foreground",
|
|
969
|
+
children: [e, c.required && /* @__PURE__ */ I("span", {
|
|
970
|
+
className: "ml-1 text-muted-foreground",
|
|
971
|
+
children: "Required"
|
|
972
|
+
})]
|
|
973
|
+
}),
|
|
974
|
+
n && /* @__PURE__ */ I("span", {
|
|
975
|
+
id: d,
|
|
976
|
+
className: "block type-caption text-muted-foreground",
|
|
977
|
+
children: n
|
|
978
|
+
}),
|
|
979
|
+
i && /* @__PURE__ */ I("span", {
|
|
980
|
+
id: f,
|
|
981
|
+
className: "block type-caption text-destructive",
|
|
982
|
+
children: i
|
|
983
|
+
})
|
|
984
|
+
]
|
|
985
|
+
})]
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function Ce({ label: e, value: n, onChange: i, options: a, help: o, error: s, disabled: c, required: l, orientation: u = "vertical", name: d, className: f, density: p }) {
|
|
989
|
+
let m = N.useId(), h = d ?? m;
|
|
990
|
+
return /* @__PURE__ */ L("fieldset", {
|
|
991
|
+
className: r("min-w-0", t(p), f),
|
|
992
|
+
disabled: c,
|
|
993
|
+
"aria-describedby": [o && `${m}-help`, s && `${m}-error`].filter(Boolean).join(" ") || void 0,
|
|
994
|
+
children: [
|
|
995
|
+
/* @__PURE__ */ L("legend", {
|
|
996
|
+
className: "mb-2 type-label text-secondary-foreground",
|
|
997
|
+
children: [e, l && /* @__PURE__ */ I("span", {
|
|
998
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
999
|
+
children: "Required"
|
|
1000
|
+
})]
|
|
1001
|
+
}),
|
|
1002
|
+
/* @__PURE__ */ I("div", {
|
|
1003
|
+
className: r("flex gap-x-5 gap-y-2", u === "vertical" ? "flex-col" : "flex-wrap"),
|
|
1004
|
+
role: "radiogroup",
|
|
1005
|
+
"aria-required": l || void 0,
|
|
1006
|
+
"aria-invalid": !!s || void 0,
|
|
1007
|
+
children: a.map((e) => /* @__PURE__ */ L("label", {
|
|
1008
|
+
"data-disabled": c || e.disabled || void 0,
|
|
1009
|
+
"data-density": p,
|
|
1010
|
+
className: r("wos-choice-label flex min-h-11 cursor-pointer items-center gap-2 rounded-[var(--control-radius)] hover:bg-interaction-hover", p && "min-h-[var(--wos-control-height)]", (c || e.disabled) && "cursor-not-allowed opacity-[var(--state-disabled-opacity)]"),
|
|
1011
|
+
children: [/* @__PURE__ */ I("input", {
|
|
1012
|
+
"aria-invalid": !!s || void 0,
|
|
1013
|
+
type: "radio",
|
|
1014
|
+
name: h,
|
|
1015
|
+
value: e.value,
|
|
1016
|
+
checked: n === e.value,
|
|
1017
|
+
disabled: c || e.disabled,
|
|
1018
|
+
required: l,
|
|
1019
|
+
onChange: () => i(e.value),
|
|
1020
|
+
className: "wos-choice-input h-4 w-4 accent-selection-indicator focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
1021
|
+
}), /* @__PURE__ */ I("span", {
|
|
1022
|
+
className: "type-supporting text-secondary-foreground",
|
|
1023
|
+
children: e.label
|
|
1024
|
+
})]
|
|
1025
|
+
}, e.value))
|
|
1026
|
+
}),
|
|
1027
|
+
o && /* @__PURE__ */ I("p", {
|
|
1028
|
+
id: `${m}-help`,
|
|
1029
|
+
className: "mt-1 type-caption text-muted-foreground",
|
|
1030
|
+
children: o
|
|
1031
|
+
}),
|
|
1032
|
+
s && /* @__PURE__ */ I("p", {
|
|
1033
|
+
id: `${m}-error`,
|
|
1034
|
+
className: "mt-1 type-caption text-destructive",
|
|
1035
|
+
children: s
|
|
1036
|
+
})
|
|
1037
|
+
]
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
function we({ label: e, description: t, error: n, className: i, onChange: a, ...o }) {
|
|
1041
|
+
let s = N.useId(), c = n ? `${o.id ?? s}-error` : void 0;
|
|
1042
|
+
return /* @__PURE__ */ L("div", {
|
|
1043
|
+
className: r("space-y-1", i),
|
|
1044
|
+
children: [/* @__PURE__ */ L("label", {
|
|
1045
|
+
className: r("flex min-h-11 cursor-pointer items-center justify-between gap-4", o.disabled && "cursor-not-allowed opacity-[var(--state-disabled-opacity)]"),
|
|
1046
|
+
children: [
|
|
1047
|
+
/* @__PURE__ */ L("span", { children: [/* @__PURE__ */ L("span", {
|
|
1048
|
+
className: "block type-label text-secondary-foreground",
|
|
1049
|
+
children: [e, o.required && /* @__PURE__ */ I("span", {
|
|
1050
|
+
className: "ml-1 text-muted-foreground",
|
|
1051
|
+
children: "Required"
|
|
1052
|
+
})]
|
|
1053
|
+
}), t && /* @__PURE__ */ I("span", {
|
|
1054
|
+
id: s,
|
|
1055
|
+
className: "block type-caption text-muted-foreground",
|
|
1056
|
+
children: t
|
|
1057
|
+
})] }),
|
|
1058
|
+
/* @__PURE__ */ I("input", {
|
|
1059
|
+
...o,
|
|
1060
|
+
type: "checkbox",
|
|
1061
|
+
role: "switch",
|
|
1062
|
+
"aria-invalid": !!n || o["aria-invalid"] || void 0,
|
|
1063
|
+
"aria-describedby": [
|
|
1064
|
+
t && s,
|
|
1065
|
+
c,
|
|
1066
|
+
o["aria-describedby"]
|
|
1067
|
+
].filter(Boolean).join(" ") || void 0,
|
|
1068
|
+
className: "peer sr-only",
|
|
1069
|
+
onChange: (e) => a?.(e.currentTarget.checked)
|
|
1070
|
+
}),
|
|
1071
|
+
/* @__PURE__ */ I("span", {
|
|
1072
|
+
"aria-hidden": "true",
|
|
1073
|
+
className: "relative h-6 w-11 shrink-0 rounded-full bg-border transition-colors duration-[var(--motion-duration-fast)] after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-surface after:shadow-sm after:transition-transform after:duration-[var(--motion-duration-fast)] peer-checked:bg-selection-indicator peer-checked:after:translate-x-5 peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-ring peer-disabled:opacity-[var(--state-disabled-opacity)] peer-aria-[invalid=true]:ring-1 peer-aria-[invalid=true]:ring-destructive"
|
|
1074
|
+
})
|
|
1075
|
+
]
|
|
1076
|
+
}), n && /* @__PURE__ */ I("p", {
|
|
1077
|
+
id: c,
|
|
1078
|
+
className: "type-caption text-destructive",
|
|
1079
|
+
children: n
|
|
1080
|
+
})]
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
function Te({ label: e, value: t, onChange: n, help: r, error: i, className: a, ...s }) {
|
|
1084
|
+
let c = s.id ?? N.useId();
|
|
1085
|
+
return /* @__PURE__ */ I(o, {
|
|
1086
|
+
label: e,
|
|
1087
|
+
help: r,
|
|
1088
|
+
error: i,
|
|
1089
|
+
htmlFor: c,
|
|
1090
|
+
required: s.required,
|
|
1091
|
+
className: a,
|
|
1092
|
+
children: /* @__PURE__ */ L("div", {
|
|
1093
|
+
"data-field-container": "true",
|
|
1094
|
+
className: "flex items-center gap-3",
|
|
1095
|
+
children: [/* @__PURE__ */ I("input", {
|
|
1096
|
+
...s,
|
|
1097
|
+
id: c,
|
|
1098
|
+
type: "range",
|
|
1099
|
+
value: t,
|
|
1100
|
+
"aria-describedby": [r && `${c}-help`, i && `${c}-error`].filter(Boolean).join(" ") || void 0,
|
|
1101
|
+
"aria-invalid": !!i || void 0,
|
|
1102
|
+
className: "w-full accent-selection-indicator focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
|
|
1103
|
+
onChange: (e) => n(Number(e.currentTarget.value))
|
|
1104
|
+
}), /* @__PURE__ */ I("output", {
|
|
1105
|
+
htmlFor: c,
|
|
1106
|
+
className: "min-w-10 text-right type-caption tabular",
|
|
1107
|
+
children: t
|
|
1108
|
+
})]
|
|
1109
|
+
})
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
function Ee({ pressed: e, onPressedChange: n, className: i, children: a, density: o, ...s }) {
|
|
1113
|
+
return /* @__PURE__ */ I("button", {
|
|
1114
|
+
...s,
|
|
1115
|
+
"data-density": o,
|
|
1116
|
+
type: "button",
|
|
1117
|
+
"aria-pressed": e,
|
|
1118
|
+
className: r("wos-state-control inline-flex min-h-9 items-center justify-center rounded-[var(--control-radius)] border px-3 type-control transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-[var(--state-disabled-opacity)]", t(o), o && "min-h-[var(--wos-control-height)] text-[length:var(--wos-control-font-size)]", e ? "border-selection-indicator bg-selected-subtle text-selected" : "border-border bg-surface text-secondary-foreground hover:bg-interaction-hover", i),
|
|
1119
|
+
onClick: () => !s.disabled && n(!e),
|
|
1120
|
+
children: a
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
function De({ label: e, value: n, onChange: i, options: a, type: o = "single", disabled: s, className: c, density: l }) {
|
|
1124
|
+
let u = Array.isArray(n) ? n : n ? [n] : [], d = (e) => {
|
|
1125
|
+
o === "multiple" ? i(u.includes(e) ? u.filter((t) => t !== e) : [...u, e]) : u[0] !== e && i(e);
|
|
1126
|
+
}, f = a.map((e, t) => !e.disabled && !s ? t : -1).filter((e) => e >= 0), p = a.findIndex((e) => u.includes(e.value) && !e.disabled), m = f.includes(p) ? p : f[0] ?? -1, h = (e, t) => {
|
|
1127
|
+
let n = ["ArrowRight", "ArrowDown"].includes(e.key) ? 1 : ["ArrowLeft", "ArrowUp"].includes(e.key) ? -1 : 0;
|
|
1128
|
+
if (!n || o !== "single" || !f.length) return;
|
|
1129
|
+
e.preventDefault();
|
|
1130
|
+
let r = f.indexOf(t), i = f[(r + n + f.length) % f.length];
|
|
1131
|
+
(e.currentTarget.parentElement?.children[i])?.focus(), d(a[i].value);
|
|
1132
|
+
};
|
|
1133
|
+
return /* @__PURE__ */ I("div", {
|
|
1134
|
+
"data-density": l,
|
|
1135
|
+
role: o === "single" ? "radiogroup" : "group",
|
|
1136
|
+
"aria-label": e,
|
|
1137
|
+
className: r("inline-flex max-w-full flex-wrap rounded-[var(--control-radius)] border border-border bg-surface p-0.5", t(l), c),
|
|
1138
|
+
children: a.map((e, t) => /* @__PURE__ */ I("button", {
|
|
1139
|
+
type: "button",
|
|
1140
|
+
role: o === "single" ? "radio" : "button",
|
|
1141
|
+
"aria-checked": u.includes(e.value),
|
|
1142
|
+
tabIndex: o === "single" ? t === m ? 0 : -1 : void 0,
|
|
1143
|
+
disabled: s || e.disabled,
|
|
1144
|
+
className: r("min-h-8 rounded-[var(--control-radius)] px-3 type-control hover:bg-interaction-hover text-secondary-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-[var(--state-disabled-opacity)]", l && "min-h-[var(--wos-control-height)] text-[length:var(--wos-control-font-size)]", u.includes(e.value) && "bg-selected-subtle font-medium text-selected"),
|
|
1145
|
+
onKeyDown: (e) => h(e, t),
|
|
1146
|
+
onClick: () => d(e.value),
|
|
1147
|
+
children: e.label
|
|
1148
|
+
}, e.value))
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
var Oe = De;
|
|
1152
|
+
function ke({ label: e, value: t, onChange: n, length: i = 6, error: a, help: o, disabled: s, required: c, name: l, className: u }) {
|
|
1153
|
+
let d = N.useId(), f = N.useRef([]), p = Array.from({ length: i }, (e, n) => t[n] ?? ""), m = (e, t) => {
|
|
1154
|
+
let r = t.replace(/\D/g, "");
|
|
1155
|
+
if (!r) {
|
|
1156
|
+
let t = [...p];
|
|
1157
|
+
t[e] = "", n(t.join(""));
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
let a = r.slice(0, i - e), o = [...p];
|
|
1161
|
+
a.split("").forEach((t, n) => {
|
|
1162
|
+
o[e + n] = t;
|
|
1163
|
+
}), n(o.join("")), f.current[Math.min(e + a.length, i - 1)]?.focus();
|
|
1164
|
+
};
|
|
1165
|
+
return /* @__PURE__ */ L("fieldset", {
|
|
1166
|
+
className: r("min-w-0", u),
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ L("legend", {
|
|
1169
|
+
className: "mb-2 type-label text-secondary-foreground",
|
|
1170
|
+
children: [e, c && /* @__PURE__ */ I("span", {
|
|
1171
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
1172
|
+
children: "Required"
|
|
1173
|
+
})]
|
|
1174
|
+
}),
|
|
1175
|
+
/* @__PURE__ */ I("div", {
|
|
1176
|
+
className: "flex flex-wrap gap-2",
|
|
1177
|
+
role: "group",
|
|
1178
|
+
"aria-label": String(e),
|
|
1179
|
+
children: p.map((t, n) => /* @__PURE__ */ I("input", {
|
|
1180
|
+
ref: (e) => {
|
|
1181
|
+
f.current[n] = e;
|
|
1182
|
+
},
|
|
1183
|
+
id: `${d}-${n}`,
|
|
1184
|
+
name: n === 0 ? l : void 0,
|
|
1185
|
+
"aria-label": `${String(e)} digit ${n + 1} of ${i}`,
|
|
1186
|
+
"aria-invalid": !!a || void 0,
|
|
1187
|
+
"aria-describedby": a ? `${d}-error` : o ? `${d}-help` : void 0,
|
|
1188
|
+
type: "text",
|
|
1189
|
+
inputMode: "numeric",
|
|
1190
|
+
autoComplete: n === 0 ? "one-time-code" : "off",
|
|
1191
|
+
maxLength: i,
|
|
1192
|
+
value: t,
|
|
1193
|
+
required: c,
|
|
1194
|
+
disabled: s,
|
|
1195
|
+
className: "wos-choice-input w-10 h-11 rounded-[var(--control-radius)] border border-input bg-surface text-center text-lg tabular focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-[var(--state-disabled-opacity)]",
|
|
1196
|
+
onChange: (e) => m(n, e.currentTarget.value),
|
|
1197
|
+
onKeyDown: (e) => {
|
|
1198
|
+
e.key === "Backspace" && !p[n] && n > 0 && f.current[n - 1]?.focus(), e.key === "ArrowLeft" && n > 0 && (e.preventDefault(), f.current[n - 1]?.focus()), e.key === "ArrowRight" && n < i - 1 && (e.preventDefault(), f.current[n + 1]?.focus());
|
|
1199
|
+
},
|
|
1200
|
+
onPaste: (e) => {
|
|
1201
|
+
let t = e.clipboardData.getData("text").replace(/\D/g, "");
|
|
1202
|
+
t && (e.preventDefault(), m(n, t));
|
|
1203
|
+
}
|
|
1204
|
+
}, n))
|
|
1205
|
+
}),
|
|
1206
|
+
o && /* @__PURE__ */ I("p", {
|
|
1207
|
+
id: `${d}-help`,
|
|
1208
|
+
className: "mt-1 type-caption text-muted-foreground",
|
|
1209
|
+
children: o
|
|
1210
|
+
}),
|
|
1211
|
+
a && /* @__PURE__ */ I("p", {
|
|
1212
|
+
id: `${d}-error`,
|
|
1213
|
+
className: "mt-1 type-caption text-destructive",
|
|
1214
|
+
children: a
|
|
1215
|
+
})
|
|
1216
|
+
]
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
function Ae({ label: e, files: t, onFilesChange: n, accept: i, multiple: a, maxSizeBytes: o, help: s, disabled: c, required: l, className: u }) {
|
|
1220
|
+
let d = N.useId(), [f, p] = N.useState(!1), [m, h] = N.useState(""), g = s ? `${d}-help` : void 0, _ = m ? `${d}-error` : void 0, v = (e) => {
|
|
1221
|
+
let r = Array.from(e), s = o ? r.find((e) => e.size > o) : void 0;
|
|
1222
|
+
if (s) {
|
|
1223
|
+
let e = o >= 1048576 ? `${(o / 1024 / 1024).toFixed(1)} MB` : `${Math.round(o / 1024)} KB`;
|
|
1224
|
+
h(`${s.name} exceeds the ${e} limit.`);
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
let c = i?.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), l = c?.length ? r.find((e) => !c.some((t) => t.startsWith(".") ? e.name.toLowerCase().endsWith(t) : t.endsWith("/*") ? e.type.startsWith(t.slice(0, -1)) : e.type === t)) : void 0;
|
|
1228
|
+
l ? h(`${l.name} is not an accepted file type (${i}).`) : (h(""), n(a ? [...t, ...r] : r.slice(0, 1)));
|
|
1229
|
+
};
|
|
1230
|
+
return /* @__PURE__ */ L("div", {
|
|
1231
|
+
className: r("space-y-1.5", u),
|
|
1232
|
+
children: [
|
|
1233
|
+
/* @__PURE__ */ L("label", {
|
|
1234
|
+
htmlFor: d,
|
|
1235
|
+
className: "block type-label text-secondary-foreground",
|
|
1236
|
+
children: [e, l && /* @__PURE__ */ I("span", {
|
|
1237
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
1238
|
+
children: "Required"
|
|
1239
|
+
})]
|
|
1240
|
+
}),
|
|
1241
|
+
/* @__PURE__ */ L("div", {
|
|
1242
|
+
onDragOver: (e) => {
|
|
1243
|
+
e.preventDefault(), c || p(!0);
|
|
1244
|
+
},
|
|
1245
|
+
onDragLeave: () => p(!1),
|
|
1246
|
+
onDrop: (e) => {
|
|
1247
|
+
e.preventDefault(), p(!1), c || v(e.dataTransfer.files);
|
|
1248
|
+
},
|
|
1249
|
+
className: r("rounded-[var(--surface-radius)] border border-dashed p-4 text-center", f ? "border-selection-indicator bg-selected-subtle" : "border-border", c && "opacity-[var(--state-disabled-opacity)]"),
|
|
1250
|
+
children: [
|
|
1251
|
+
/* @__PURE__ */ I("input", {
|
|
1252
|
+
id: d,
|
|
1253
|
+
type: "file",
|
|
1254
|
+
accept: i,
|
|
1255
|
+
multiple: a,
|
|
1256
|
+
required: l,
|
|
1257
|
+
disabled: c,
|
|
1258
|
+
"aria-describedby": [g, _].filter(Boolean).join(" ") || void 0,
|
|
1259
|
+
"aria-invalid": !!m || void 0,
|
|
1260
|
+
className: "peer sr-only",
|
|
1261
|
+
onChange: (e) => {
|
|
1262
|
+
e.currentTarget.files && v(e.currentTarget.files), e.currentTarget.value = "";
|
|
1263
|
+
}
|
|
1264
|
+
}),
|
|
1265
|
+
/* @__PURE__ */ L("label", {
|
|
1266
|
+
htmlFor: d,
|
|
1267
|
+
className: r("inline-flex min-h-11 cursor-pointer items-center rounded-[var(--control-radius)] border border-border bg-surface px-3 type-control hover:bg-interaction-hover peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-ring", c && "cursor-not-allowed"),
|
|
1268
|
+
children: ["Choose file", a ? "s" : ""]
|
|
1269
|
+
}),
|
|
1270
|
+
/* @__PURE__ */ L("p", {
|
|
1271
|
+
className: "mt-2 type-caption text-muted-foreground",
|
|
1272
|
+
children: [
|
|
1273
|
+
"or drop ",
|
|
1274
|
+
a ? "files" : "a file",
|
|
1275
|
+
" here",
|
|
1276
|
+
i ? ` · ${i}` : ""
|
|
1277
|
+
]
|
|
1278
|
+
}),
|
|
1279
|
+
s && /* @__PURE__ */ I("p", {
|
|
1280
|
+
id: g,
|
|
1281
|
+
className: "mt-1 type-caption text-muted-foreground",
|
|
1282
|
+
children: s
|
|
1283
|
+
})
|
|
1284
|
+
]
|
|
1285
|
+
}),
|
|
1286
|
+
m && /* @__PURE__ */ I("p", {
|
|
1287
|
+
id: _,
|
|
1288
|
+
role: "alert",
|
|
1289
|
+
className: "type-caption text-destructive",
|
|
1290
|
+
children: m
|
|
1291
|
+
}),
|
|
1292
|
+
t.length > 0 && /* @__PURE__ */ I("ul", {
|
|
1293
|
+
"aria-label": "Selected files",
|
|
1294
|
+
className: "space-y-1",
|
|
1295
|
+
children: t.map((e, r) => /* @__PURE__ */ L("li", {
|
|
1296
|
+
className: "flex items-center justify-between gap-2 type-caption",
|
|
1297
|
+
children: [/* @__PURE__ */ I("span", {
|
|
1298
|
+
className: "truncate",
|
|
1299
|
+
children: e.name
|
|
1300
|
+
}), /* @__PURE__ */ I("button", {
|
|
1301
|
+
type: "button",
|
|
1302
|
+
"aria-label": `Remove ${e.name}`,
|
|
1303
|
+
disabled: c,
|
|
1304
|
+
className: "min-h-11 px-2 text-muted-foreground hover:text-foreground",
|
|
1305
|
+
onClick: () => n(t.filter((e, t) => t !== r)),
|
|
1306
|
+
children: "Remove"
|
|
1307
|
+
})]
|
|
1308
|
+
}, `${e.name}-${r}`))
|
|
1309
|
+
})
|
|
1310
|
+
]
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
//#endregion
|
|
1314
|
+
//#region src/components/textarea.tsx
|
|
1315
|
+
var je = N.forwardRef(({ className: e, invalid: n, density: i, "aria-invalid": a, ...o }, s) => /* @__PURE__ */ I("textarea", {
|
|
1316
|
+
"data-density": i,
|
|
1317
|
+
className: r("wos-textarea placeholder:text-muted-foreground aria-[invalid=true]:border-destructive", t(i), e),
|
|
1318
|
+
"aria-invalid": n || a || void 0,
|
|
1319
|
+
ref: s,
|
|
1320
|
+
...o
|
|
1321
|
+
}));
|
|
1322
|
+
je.displayName = "Textarea";
|
|
1323
|
+
//#endregion
|
|
1324
|
+
//#region src/components/surface.tsx
|
|
1325
|
+
var Me = P("", {
|
|
1326
|
+
variants: {
|
|
1327
|
+
variant: {
|
|
1328
|
+
working: "wos-surface",
|
|
1329
|
+
quiet: "border border-surface-border bg-surface",
|
|
1330
|
+
raised: "border border-surface-border bg-surface-raised shadow-working"
|
|
1331
|
+
},
|
|
1332
|
+
radius: {
|
|
1333
|
+
default: "rounded-[var(--surface-radius)]",
|
|
1334
|
+
lg: "rounded-[var(--surface-radius-large)]",
|
|
1335
|
+
xl: "rounded-[var(--surface-radius-presentation)]"
|
|
1336
|
+
},
|
|
1337
|
+
padding: {
|
|
1338
|
+
none: "p-0",
|
|
1339
|
+
sm: "p-3",
|
|
1340
|
+
md: "p-5",
|
|
1341
|
+
lg: "p-6"
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1344
|
+
defaultVariants: {
|
|
1345
|
+
variant: "working",
|
|
1346
|
+
padding: "md",
|
|
1347
|
+
radius: "default"
|
|
1348
|
+
}
|
|
1349
|
+
}), Ne = N.forwardRef(({ className: e, variant: t, padding: n, radius: i, ...a }, o) => /* @__PURE__ */ I("div", {
|
|
1350
|
+
ref: o,
|
|
1351
|
+
className: r(Me({
|
|
1352
|
+
variant: t,
|
|
1353
|
+
padding: n,
|
|
1354
|
+
radius: i
|
|
1355
|
+
}), e),
|
|
1356
|
+
...a
|
|
1357
|
+
}));
|
|
1358
|
+
Ne.displayName = "Surface";
|
|
1359
|
+
var Pe = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I(Ne, {
|
|
1360
|
+
ref: n,
|
|
1361
|
+
className: e,
|
|
1362
|
+
...t
|
|
1363
|
+
}));
|
|
1364
|
+
Pe.displayName = "Card";
|
|
1365
|
+
var Fe = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I("div", {
|
|
1366
|
+
ref: n,
|
|
1367
|
+
className: r("flex flex-col gap-1.5", e),
|
|
1368
|
+
...t
|
|
1369
|
+
}));
|
|
1370
|
+
Fe.displayName = "CardHeader";
|
|
1371
|
+
var Ie = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I("h3", {
|
|
1372
|
+
ref: n,
|
|
1373
|
+
className: r("type-subsection text-foreground", e),
|
|
1374
|
+
...t
|
|
1375
|
+
}));
|
|
1376
|
+
Ie.displayName = "CardTitle";
|
|
1377
|
+
var Le = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I("p", {
|
|
1378
|
+
ref: n,
|
|
1379
|
+
className: r("type-supporting text-muted-foreground", e),
|
|
1380
|
+
...t
|
|
1381
|
+
}));
|
|
1382
|
+
Le.displayName = "CardDescription";
|
|
1383
|
+
var Re = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I("div", {
|
|
1384
|
+
ref: n,
|
|
1385
|
+
className: r(e),
|
|
1386
|
+
...t
|
|
1387
|
+
}));
|
|
1388
|
+
Re.displayName = "CardContent";
|
|
1389
|
+
var ze = N.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ I("div", {
|
|
1390
|
+
ref: n,
|
|
1391
|
+
className: r("flex items-center", e),
|
|
1392
|
+
...t
|
|
1393
|
+
}));
|
|
1394
|
+
ze.displayName = "CardFooter";
|
|
1395
|
+
//#endregion
|
|
1396
|
+
//#region src/components/badge.tsx
|
|
1397
|
+
var Be = P("wos-badge inline-flex items-center font-normal", {
|
|
1398
|
+
variants: { variant: {
|
|
1399
|
+
default: "",
|
|
1400
|
+
secondary: "border-transparent bg-surface-subtle text-secondary-foreground",
|
|
1401
|
+
outline: "bg-transparent"
|
|
1402
|
+
} },
|
|
1403
|
+
defaultVariants: { variant: "default" }
|
|
1404
|
+
}), Ve = N.forwardRef(({ className: e, variant: t, ...n }, i) => /* @__PURE__ */ I("span", {
|
|
1405
|
+
ref: i,
|
|
1406
|
+
className: r(Be({ variant: t }), e),
|
|
1407
|
+
...n
|
|
1408
|
+
}));
|
|
1409
|
+
Ve.displayName = "Badge";
|
|
1410
|
+
//#endregion
|
|
1411
|
+
export { O as AspectRatio, ye as Autocomplete, C as Avatar, E as AvatarGroup, Ve as Badge, n as Button, z as ButtonGroup, Pe as Card, Re as CardContent, Le as CardDescription, ze as CardFooter, Fe as CardHeader, Ie as CardTitle, Se as Checkbox, b as CircularProgress, ve as Combobox, p as DataList, $ as DateInput, he as DateRangePicker, w as DescriptionList, D as EmptyState, o as Field, Ae as FileUpload, s as Form, a as FormField, R as IconButton, ke as InputOTP, h as KeyValue, x as MetricCard, ee as MoneyInput, xe as MultiSelect, l as Notice, H as NumberInput, k as Progress, te as QuantityInput, Ce as RadioGroup, g as ScrollArea, be as SearchInput, Oe as SegmentedControl, ie as Select, U as SelectMenu, _ as Separator, T as Skeleton, Te as Slider, S as Stat, c as StatusBadge, Ne as Surface, we as Switch, y as Table, v as TableBody, f as TableCaption, A as TableCell, M as TableFooter, m as TableHead, j as TableHeader, d as TableRow, V as TextInput, je as Textarea, u as Timeline, Ee as Toggle, De as ToggleGroup, de as UsDateInput, i as ValidationMessage, B as WealthIcon, Be as badgeVariants, e as buttonVariants, r as cn, ge as isDateRangeValid, Me as surfaceVariants };
|