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