nish-ui 3.0.0 → 3.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/README.md +11 -8
- package/dist/chart.d.ts +8 -3
- package/dist/chart.js +4 -419
- package/dist/elements-all.js +70 -69
- package/dist/elements-charts.d.ts +8 -2
- package/dist/elements-charts.js +23 -23
- package/dist/elements-data.d.ts +7 -1
- package/dist/elements-data.js +5 -5
- package/dist/elements-forms.d.ts +7 -1
- package/dist/elements-forms.js +20 -19
- package/dist/elements.d.ts +7 -1
- package/dist/elements.js +4 -4
- package/dist/esm/chart-values.js +2 -1
- package/dist/esm/combobox-filter.js +6 -5
- package/dist/esm/command-filter.js +32 -0
- package/dist/esm/components/accordion.js +2 -1
- package/dist/esm/components/app-shell.js +1 -1
- package/dist/esm/components/avatar.js +2 -2
- package/dist/esm/components/breadcrumbs.js +1 -1
- package/dist/esm/components/calendar-base.js +1 -1
- package/dist/esm/components/canvas/legend.js +4 -4
- package/dist/esm/components/canvas/system-canvas.js +24 -1
- package/dist/esm/components/carousel.js +21 -3
- package/dist/esm/components/charts.js +21 -13
- package/dist/esm/components/combobox.js +3 -3
- package/dist/esm/components/command.js +5 -5
- package/dist/esm/components/data-classes.js +23 -8
- package/dist/esm/components/data.js +1 -5
- package/dist/esm/components/date-picker.js +1 -0
- package/dist/esm/components/date-range-picker.js +1 -0
- package/dist/esm/components/display.js +7 -7
- package/dist/esm/components/feedback.js +1 -1
- package/dist/esm/components/file-dropzone.js +44 -2
- package/dist/esm/components/filters.js +3 -1
- package/dist/esm/components/flow.js +16 -15
- package/dist/esm/components/forms-classes.js +1 -1
- package/dist/esm/components/forms.js +30 -6
- package/dist/esm/components/hooks.js +20 -17
- package/dist/esm/components/inbox.js +13 -8
- package/dist/esm/components/layout-vars.js +10 -7
- package/dist/esm/components/menu.js +11 -4
- package/dist/esm/components/multi-select.js +9 -6
- package/dist/esm/components/nav-classes.js +9 -0
- package/dist/esm/components/nav.js +2 -1
- package/dist/esm/components/overlay-core.js +31 -10
- package/dist/esm/components/overlay-dialog.js +17 -2
- package/dist/esm/components/pagination.js +4 -1
- package/dist/esm/components/popover.js +15 -9
- package/dist/esm/components/primitives-classes.js +4 -4
- package/dist/esm/components/primitives.js +2 -2
- package/dist/esm/components/progress.js +2 -0
- package/dist/esm/components/radio-group.js +1 -1
- package/dist/esm/components/resource-classes.js +41 -19
- package/dist/esm/components/resource.js +8 -6
- package/dist/esm/components/settings.js +9 -3
- package/dist/esm/components/slider.js +1 -0
- package/dist/esm/components/strings.js +9 -1
- package/dist/esm/components/tabs.js +3 -2
- package/dist/esm/components/tag-input.js +15 -7
- package/dist/esm/components/time-field-classes.js +5 -2
- package/dist/esm/components/time-field.js +15 -7
- package/dist/esm/components/toast-store.js +16 -4
- package/dist/esm/components/tooltip.js +1 -1
- package/dist/esm/components/url-state.js +3 -1
- package/dist/esm/components/virtual-table.js +8 -2
- package/dist/esm/components/virtual.js +16 -2
- package/dist/esm/format.js +41 -16
- package/dist/esm/runtime.js +9 -2
- package/dist/esm/server/inbox/client.js +1 -1
- package/dist/esm/split-layout.js +2 -1
- package/dist/esm/theme.js +66 -6
- package/dist/format.js +50 -19
- package/dist/inbox-client.d.ts +5 -1
- package/dist/inbox-client.js +1 -2
- package/dist/index.d.ts +39 -11
- package/dist/nish-components.css +52 -3
- package/dist/nish-components.min.css +1 -1
- package/dist/node/th-check.js +12 -3
- package/dist/server/hono.d.ts +2 -2
- package/dist/server/hono.js +111 -8
- package/dist/server/index.d.ts +20 -12
- package/dist/server/index.js +136 -32
- package/dist/{spa-BLlMc0eI.d.ts → spa-BfRDo38r.d.ts} +35 -6
- package/dist/split-layout.js +2 -2
- package/dist/system-canvas.d.ts +0 -4
- package/dist/theme.d.ts +20 -2
- package/dist/theme.global.js +75 -10
- package/dist/theme.js +75 -9
- package/package.json +1 -1
|
@@ -150,6 +150,7 @@ function LineChart({
|
|
|
150
150
|
const yLabels = scale ? ticksBetween(scale.yMin, scale.yMax, yTicks).map((v) => ({ v, text: yFmt(v) })) : [];
|
|
151
151
|
const padLeft = Math.ceil(Math.max(0, ...yLabels.map((l) => l.text.length)) * 6.6) + 10;
|
|
152
152
|
const plotW = Math.max(0, width - padLeft - PAD_RIGHT);
|
|
153
|
+
const plotX = rtl ? PAD_RIGHT : padLeft;
|
|
153
154
|
const plotH = Math.max(0, height - PAD_TOP - PAD_BOTTOM);
|
|
154
155
|
const paths = useMemo(() => {
|
|
155
156
|
if (!scale) return [];
|
|
@@ -157,11 +158,11 @@ function LineChart({
|
|
|
157
158
|
return runs.map(
|
|
158
159
|
(segs) => segs.map(
|
|
159
160
|
(seg) => decimateMinMax(seg, scale.xMin, scale.xMax, plotW).map(
|
|
160
|
-
(p) => `${xPos(p.x, scale.xMin, scale.xMax,
|
|
161
|
+
(p) => `${xPos(p.x, scale.xMin, scale.xMax, plotX, plotW, rtl).toFixed(1)},${sy2(p.y).toFixed(1)}`
|
|
161
162
|
)
|
|
162
163
|
)
|
|
163
164
|
);
|
|
164
|
-
}, [runs, scale, plotW, plotH,
|
|
165
|
+
}, [runs, scale, plotW, plotH, plotX, rtl]);
|
|
165
166
|
if (loading) return /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", className), style: { height } });
|
|
166
167
|
if (!scale) {
|
|
167
168
|
return /* @__PURE__ */ jsx(
|
|
@@ -177,13 +178,13 @@ function LineChart({
|
|
|
177
178
|
}
|
|
178
179
|
);
|
|
179
180
|
}
|
|
180
|
-
const sx = (x) => xPos(x, scale.xMin, scale.xMax,
|
|
181
|
+
const sx = (x) => xPos(x, scale.xMin, scale.xMax, plotX, plotW, rtl);
|
|
181
182
|
const sy = (y) => PAD_TOP + (1 - (y - scale.yMin) / (scale.yMax - scale.yMin)) * plotH;
|
|
182
183
|
const bottom = PAD_TOP + plotH;
|
|
183
184
|
const xLabels = ticksBetween(scale.xMin, scale.xMax, Math.min(xTicks, Math.max(2, Math.floor(plotW / 72))));
|
|
184
185
|
const moveTo = (clientX, el) => {
|
|
185
186
|
const rect = el.getBoundingClientRect();
|
|
186
|
-
const f = (clientX - rect.left -
|
|
187
|
+
const f = (clientX - rect.left - plotX) / (plotW || 1);
|
|
187
188
|
const x = scale.xMin + (rtl ? 1 - f : f) * (scale.xMax - scale.xMin);
|
|
188
189
|
let lo = 0;
|
|
189
190
|
let hi = xs.length - 1;
|
|
@@ -220,7 +221,7 @@ function LineChart({
|
|
|
220
221
|
role: "img",
|
|
221
222
|
tabIndex: 0,
|
|
222
223
|
"aria-label": label,
|
|
223
|
-
className: "block rounded-md outline-none focus-visible:ring-2 focus-visible:ring-th-accent",
|
|
224
|
+
className: "block rounded-md outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight] focus-visible:ring-2 focus-visible:ring-th-accent",
|
|
224
225
|
style: { touchAction: "pan-y" },
|
|
225
226
|
onPointerDown: onPointer,
|
|
226
227
|
onPointerMove: onPointer,
|
|
@@ -237,11 +238,11 @@ function LineChart({
|
|
|
237
238
|
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: toneColor(lines[0].tone, 0), stopOpacity: 0 })
|
|
238
239
|
] }) }),
|
|
239
240
|
yLabels.map((l, i) => /* @__PURE__ */ jsxs("g", { children: [
|
|
240
|
-
/* @__PURE__ */ jsx("line", { x1:
|
|
241
|
+
/* @__PURE__ */ jsx("line", { x1: plotX, x2: plotX + plotW, y1: sy(l.v), y2: sy(l.v), stroke: CHART.grid, strokeWidth: 1 }),
|
|
241
242
|
/* @__PURE__ */ jsx(
|
|
242
243
|
"text",
|
|
243
244
|
{
|
|
244
|
-
x: rtl ?
|
|
245
|
+
x: rtl ? plotX + plotW + 6 : plotX - 6,
|
|
245
246
|
y: sy(l.v),
|
|
246
247
|
textAnchor: rtl ? "start" : "end",
|
|
247
248
|
dominantBaseline: "middle",
|
|
@@ -265,7 +266,7 @@ function LineChart({
|
|
|
265
266
|
},
|
|
266
267
|
i
|
|
267
268
|
)),
|
|
268
|
-
baseline != null && Number.isFinite(baseline) && /* @__PURE__ */ jsx("line", { x1:
|
|
269
|
+
baseline != null && Number.isFinite(baseline) && /* @__PURE__ */ jsx("line", { x1: plotX, x2: plotX + plotW, y1: sy(baseline), y2: sy(baseline), stroke: CHART.zero, strokeWidth: 1, strokeDasharray: "4 4" }),
|
|
269
270
|
area && paths[0]?.map((seg, i) => /* @__PURE__ */ jsx("polygon", { points: `${seg[0].split(",")[0]},${bottom} ${seg.join(" ")} ${seg[seg.length - 1].split(",")[0]},${bottom}`, fill: `url(#${gradId})` }, i)),
|
|
270
271
|
paths.map(
|
|
271
272
|
(segs, si) => segs.map(
|
|
@@ -282,8 +283,14 @@ function LineChart({
|
|
|
282
283
|
ax != null && width > 0 && /* @__PURE__ */ jsxs(
|
|
283
284
|
"div",
|
|
284
285
|
{
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
ref: (el) => {
|
|
287
|
+
if (!el) return;
|
|
288
|
+
const w = el.offsetWidth;
|
|
289
|
+
if (tipRight) el.style.left = `${Math.max(0, Math.min(cx + 10, width - w))}px`;
|
|
290
|
+
else el.style.right = `${Math.max(0, Math.min(width - cx + 10, width - w))}px`;
|
|
291
|
+
},
|
|
292
|
+
className: "pointer-events-none absolute top-1 z-[var(--nish-z-tooltip,10)] overflow-hidden whitespace-nowrap px-2 py-1 tabular-nums",
|
|
293
|
+
style: { ...tooltipStyle, maxWidth: "calc(100% - 8px)", ...tipRight ? { left: cx + 10 } : { right: width - cx + 10 } },
|
|
287
294
|
children: [
|
|
288
295
|
/* @__PURE__ */ jsx("div", { className: "text-th-hi3", children: xFmt(ax) }),
|
|
289
296
|
tipRows.map((r) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
@@ -330,7 +337,8 @@ function BarChart({
|
|
|
330
337
|
const [wrapRef, width, wrapEl] = useWidth();
|
|
331
338
|
const rtl = useChartRtl(wrapEl);
|
|
332
339
|
const coarse = useMediaQuery("(pointer: coarse)");
|
|
333
|
-
const [
|
|
340
|
+
const [pickedBar, setSelected] = useState(null);
|
|
341
|
+
const selected = pickedBar != null && pickedBar < data.length ? pickedBar : null;
|
|
334
342
|
const color = toneColor(tone, 0);
|
|
335
343
|
const pick = useCallback(
|
|
336
344
|
(clientX, el) => {
|
|
@@ -369,7 +377,7 @@ function BarChart({
|
|
|
369
377
|
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
370
378
|
e.preventDefault();
|
|
371
379
|
const dir = (e.key === "ArrowRight" ? 1 : -1) * (rtl ? -1 : 1);
|
|
372
|
-
setSelected((
|
|
380
|
+
setSelected(() => selected == null ? dir > 0 ? 0 : data.length - 1 : Math.min(data.length - 1, Math.max(0, selected + dir)));
|
|
373
381
|
} else if (e.key === "Escape") setSelected(null);
|
|
374
382
|
};
|
|
375
383
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref: mergeRefs(wrapRef, ref), className: cn("w-full", className), children: [
|
|
@@ -381,7 +389,7 @@ function BarChart({
|
|
|
381
389
|
role: "img",
|
|
382
390
|
tabIndex: 0,
|
|
383
391
|
"aria-label": label,
|
|
384
|
-
className: "block rounded-md outline-none focus-visible:ring-2 focus-visible:ring-th-accent",
|
|
392
|
+
className: "block rounded-md outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight] focus-visible:ring-2 focus-visible:ring-th-accent",
|
|
385
393
|
style: { touchAction: "pan-y" },
|
|
386
394
|
onPointerDown: (e) => pick(e.clientX, e.currentTarget),
|
|
387
395
|
onPointerMove: (e) => {
|
|
@@ -9,7 +9,7 @@ import { fieldClass } from "./primitives.js";
|
|
|
9
9
|
import { useStrings } from "./provider.js";
|
|
10
10
|
import { FIELD_STRINGS } from "./strings.js";
|
|
11
11
|
import { indexComboboxOptions, setRef } from "./forms-classes.js";
|
|
12
|
-
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
|
|
12
|
+
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from "../combobox-filter.js";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
var MAX_SHOWN = COMBOBOX_MAX_SHOWN;
|
|
15
15
|
var DEBOUNCE_MS = COMBOBOX_DEBOUNCE_MS;
|
|
@@ -76,7 +76,7 @@ function Combobox({
|
|
|
76
76
|
if (dirty && !serverFiltered) {
|
|
77
77
|
if (filter) {
|
|
78
78
|
if (!filter(it.option, text)) continue;
|
|
79
|
-
} else if (
|
|
79
|
+
} else if (!matchesComboboxNeedle(it.label, it.hint, needle)) continue;
|
|
80
80
|
}
|
|
81
81
|
out.push(it.option);
|
|
82
82
|
}
|
|
@@ -167,7 +167,7 @@ function Combobox({
|
|
|
167
167
|
return true;
|
|
168
168
|
}
|
|
169
169
|
function onKeyDown(e) {
|
|
170
|
-
if (disabled) return;
|
|
170
|
+
if (disabled || e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
171
171
|
switch (e.key) {
|
|
172
172
|
case "ArrowDown":
|
|
173
173
|
case "ArrowUp": {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useState
|
|
10
10
|
} from "react";
|
|
11
11
|
import { cn } from "../cn.js";
|
|
12
|
+
import { COMMAND_MAX_RESULTS } from "../command-filter.js";
|
|
12
13
|
import { safeUrl } from "../url.js";
|
|
13
14
|
import { XIcon } from "./icons.js";
|
|
14
15
|
import { Modal } from "./modal.js";
|
|
@@ -17,7 +18,6 @@ import { useLatest } from "./latest.js";
|
|
|
17
18
|
import { useStrings } from "./provider.js";
|
|
18
19
|
import { COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS } from "./strings.js";
|
|
19
20
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
var MAX_RESULTS = 50;
|
|
21
21
|
function indexItems(items) {
|
|
22
22
|
return items.map((item) => ({ item, label: item.label.toLowerCase(), keywords: (item.keywords ?? []).map((k) => k.toLowerCase()) }));
|
|
23
23
|
}
|
|
@@ -53,7 +53,7 @@ function matchText(text, q) {
|
|
|
53
53
|
}
|
|
54
54
|
function rankItems(items, query) {
|
|
55
55
|
const q = query.trim().toLowerCase();
|
|
56
|
-
if (!q) return items.slice(0,
|
|
56
|
+
if (!q) return items.slice(0, COMMAND_MAX_RESULTS).map(({ item }) => ({ item, marks: [] }));
|
|
57
57
|
const scored = [];
|
|
58
58
|
items.forEach(({ item, label: lower, keywords }, order) => {
|
|
59
59
|
const label = matchText(lower, q);
|
|
@@ -69,7 +69,7 @@ function rankItems(items, query) {
|
|
|
69
69
|
if (best !== null) scored.push({ r: { item, marks: [] }, score: 4 + best, order });
|
|
70
70
|
});
|
|
71
71
|
scored.sort((a, b) => a.score - b.score || a.order - b.order);
|
|
72
|
-
return scored.slice(0,
|
|
72
|
+
return scored.slice(0, COMMAND_MAX_RESULTS).map((s) => s.r);
|
|
73
73
|
}
|
|
74
74
|
function groupRows(rows) {
|
|
75
75
|
const order = [];
|
|
@@ -207,7 +207,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
207
207
|
res = [];
|
|
208
208
|
}
|
|
209
209
|
if (Array.isArray(res)) {
|
|
210
|
-
setDynamic(res.slice(0,
|
|
210
|
+
setDynamic(res.slice(0, COMMAND_MAX_RESULTS));
|
|
211
211
|
setPending(false);
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
@@ -215,7 +215,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
215
215
|
res.then(
|
|
216
216
|
(r) => {
|
|
217
217
|
if (stale) return;
|
|
218
|
-
setDynamic(r.slice(0,
|
|
218
|
+
setDynamic(r.slice(0, COMMAND_MAX_RESULTS));
|
|
219
219
|
setPending(false);
|
|
220
220
|
},
|
|
221
221
|
() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/components/data-classes.ts
|
|
2
|
+
import { shared } from "../runtime.js";
|
|
2
3
|
var ALIGN = { left: "text-start", center: "text-center", right: "text-end" };
|
|
3
4
|
var ROW_TONE = {
|
|
4
5
|
ok: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-ok-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-ok-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]",
|
|
@@ -15,7 +16,7 @@ var PAD = { normal: "py-2.5", dense: "py-1.5" };
|
|
|
15
16
|
var TR = "border-b border-th-line last:border-b-0";
|
|
16
17
|
var TR_INTERACTIVE = "cursor-pointer transition-colors hover:bg-th-elevated focus-within:bg-th-elevated";
|
|
17
18
|
var NUMERIC = "whitespace-nowrap text-end tabular-nums";
|
|
18
|
-
var STICKY_COL = "[&_thead_tr]:bg-th-surface [&_tbody_tr]:bg-th-surface [&_tr>:first-child]:sticky [&_tr>:first-child]:start-0 [&_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+9)] [&_tr>:first-child]:bg-inherit [&_tr>:first-child]:after:pointer-events-none [&_tr>:first-child]:after:absolute [&_tr>:first-child]:after:inset-y-0 [&_tr>:first-child]:after:start-full [&_tr>:first-child]:after:w-2.5 [&_tr>:first-child]:after:bg-gradient-to-r rtl:[&_tr>:first-child]:after:bg-gradient-to-l [&_tr>:first-child]:after:from-[color-mix(in_srgb,var(--nish-hi)_14%,transparent)] [&_tr>:first-child]:after:to-transparent [&_tr>:first-child]:after:opacity-0 [&_tr>:first-child]:after:transition-opacity [&[data-at-start=false]_tr>:first-child]:after:opacity-100";
|
|
19
|
+
var STICKY_COL = "[&_thead_tr]:bg-th-surface [&_tbody_tr]:bg-th-surface [&_thead_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+10)] [&_tr>:first-child]:sticky [&_tr>:first-child]:start-0 [&_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+9)] [&_tr>:first-child]:bg-inherit [&_tr>:first-child]:after:pointer-events-none [&_tr>:first-child]:after:absolute [&_tr>:first-child]:after:inset-y-0 [&_tr>:first-child]:after:start-full [&_tr>:first-child]:after:w-2.5 [&_tr>:first-child]:after:bg-gradient-to-r rtl:[&_tr>:first-child]:after:bg-gradient-to-l [&_tr>:first-child]:after:from-[color-mix(in_srgb,var(--nish-hi)_14%,transparent)] [&_tr>:first-child]:after:to-transparent [&_tr>:first-child]:after:opacity-0 [&_tr>:first-child]:after:transition-opacity ltr:[&[data-at-start=false]_tr>:first-child]:after:opacity-100 rtl:[&[data-at-end=false]_tr>:first-child]:after:opacity-100";
|
|
19
20
|
var tableClass = {
|
|
20
21
|
/** The scroll box around the table. */
|
|
21
22
|
wrap: WRAP,
|
|
@@ -44,13 +45,26 @@ var tableInternals = { ALIGN, STICKY_COL, WRAP, STICKY, TABLE, ZEBRA, TH, TD, PA
|
|
|
44
45
|
function mergeRefs(...refs) {
|
|
45
46
|
return (node) => {
|
|
46
47
|
const cleanups = [];
|
|
48
|
+
const withCleanup = /* @__PURE__ */ new Set();
|
|
47
49
|
for (const ref of refs) {
|
|
48
50
|
if (typeof ref === "function") {
|
|
49
51
|
const out = ref(node);
|
|
50
|
-
if (typeof out === "function")
|
|
52
|
+
if (typeof out === "function") {
|
|
53
|
+
cleanups.push(out);
|
|
54
|
+
withCleanup.add(ref);
|
|
55
|
+
}
|
|
51
56
|
} else if (ref) ref.current = node;
|
|
52
57
|
}
|
|
53
|
-
if (cleanups.length)
|
|
58
|
+
if (cleanups.length) {
|
|
59
|
+
return () => {
|
|
60
|
+
for (const ref of refs) {
|
|
61
|
+
if (typeof ref === "function") {
|
|
62
|
+
if (!withCleanup.has(ref)) ref(null);
|
|
63
|
+
} else if (ref) ref.current = null;
|
|
64
|
+
}
|
|
65
|
+
cleanups.forEach((fn) => fn());
|
|
66
|
+
};
|
|
67
|
+
}
|
|
54
68
|
};
|
|
55
69
|
}
|
|
56
70
|
var COLLATOR = /* @__PURE__ */ new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
@@ -71,12 +85,12 @@ function sortRows(rows, get, dir) {
|
|
|
71
85
|
return keyed.map((k) => k.row);
|
|
72
86
|
}
|
|
73
87
|
var googleFavicon = (host, size) => `https://www.google.com/s2/favicons?sz=${size * 2 > 32 ? 64 : 32}&domain=${encodeURIComponent(host)}`;
|
|
74
|
-
var
|
|
88
|
+
var favicons = () => shared("favicons", () => ({ resolve: (() => null) }));
|
|
75
89
|
function configureFavicons(options) {
|
|
76
|
-
|
|
90
|
+
favicons().resolve = options.resolve ?? (() => null);
|
|
77
91
|
}
|
|
78
92
|
function getFaviconResolver() {
|
|
79
|
-
return
|
|
93
|
+
return favicons().resolve;
|
|
80
94
|
}
|
|
81
95
|
var FAVICON_HUES = 8;
|
|
82
96
|
function hashString(s) {
|
|
@@ -131,8 +145,9 @@ function chartNumber(v, locale = "en-US") {
|
|
|
131
145
|
};
|
|
132
146
|
NUMBER_FORMATS.set(locale, f);
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
const r = Math.round(v * 100) / 100 || 0;
|
|
149
|
+
if (Math.abs(r) >= 1e3) return f.whole.format(r);
|
|
150
|
+
return f.small.format(r);
|
|
136
151
|
}
|
|
137
152
|
var warned = /* @__PURE__ */ new Set();
|
|
138
153
|
function warnOnce(key, message) {
|
|
@@ -71,10 +71,6 @@ var TONE_EDGE = {
|
|
|
71
71
|
warn: "border-s-[3px] border-s-[var(--nish-warn-fill)]",
|
|
72
72
|
loss: "border-s-[3px] border-s-[var(--nish-loss-fill)]"
|
|
73
73
|
};
|
|
74
|
-
var DEFAULT_SORT_TEXT = {
|
|
75
|
-
announce: (header, dir) => dir ? `Sorted by ${header}, ${dir === "asc" ? "ascending" : "descending"}` : "Sorting cleared",
|
|
76
|
-
toggle: (dir) => dir === "desc" ? "Sorted descending, switch to ascending" : "Sorted ascending, switch to descending"
|
|
77
|
-
};
|
|
78
74
|
var BodyRow = /* @__PURE__ */ memo(function BodyRow2({ row, columns, tone, interactive, onGo }) {
|
|
79
75
|
return /* @__PURE__ */ jsx(
|
|
80
76
|
Tr,
|
|
@@ -122,7 +118,7 @@ function ResponsiveTable({
|
|
|
122
118
|
...rest
|
|
123
119
|
}) {
|
|
124
120
|
const t = useStrings(STATUS_STRINGS, TABLE_STRINGS);
|
|
125
|
-
const text = {
|
|
121
|
+
const text = { announce: sortText?.announce ?? t.sortAnnounce, toggle: sortText?.toggle ?? t.sortToggle };
|
|
126
122
|
const [innerSort, setInnerSort] = useState(null);
|
|
127
123
|
const [announcement, setAnnouncement] = useState("");
|
|
128
124
|
const sortId = useId();
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import { Skeleton } from "./feedback.js";
|
|
37
37
|
import { AlertTriangleIcon, CheckCircleIcon, ChevronDownIcon, InfoIcon, XIcon } from "./icons.js";
|
|
38
38
|
import { useHeightVar, useStuck } from "./layout-vars.js";
|
|
39
|
-
import { DropdownMenu } from "./menu.js";
|
|
39
|
+
import { DropdownMenu, InlineMenuItemContext } from "./menu.js";
|
|
40
40
|
import { Tooltip } from "./tooltip.js";
|
|
41
41
|
import { Badge, Button, Card, IconButton } from "./primitives.js";
|
|
42
42
|
import { useStrings } from "./provider.js";
|
|
@@ -115,7 +115,7 @@ function Callout({
|
|
|
115
115
|
const dismissEl = onDismiss ? /* @__PURE__ */ jsx(IconButton, { label: dismissLabel ?? strings.dismiss, size: "xs", onClick: onDismiss, className: "-my-0.5 -me-1", children: /* @__PURE__ */ jsx(XIcon, { size: 14 }) }) : null;
|
|
116
116
|
const chevron = /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, className: "-rotate-90 shrink-0 self-center text-th-hi3 rtl:rotate-90" });
|
|
117
117
|
const hit = cn(
|
|
118
|
-
"flex min-h-11 min-w-0 flex-1 items-start text-start outline-none focus-visible:ring-2 focus-visible:ring-th-accent/40",
|
|
118
|
+
"flex min-h-11 min-w-0 flex-1 items-start text-start outline-none focus-visible:ring-2 focus-visible:ring-th-accent/40 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-[Highlight]",
|
|
119
119
|
compact ? "gap-2" : "gap-3",
|
|
120
120
|
// Pull the padding of the row into the link so the whole row is the target.
|
|
121
121
|
compact ? "-my-2 py-2" : "-my-3 py-3"
|
|
@@ -273,7 +273,7 @@ function Meter({
|
|
|
273
273
|
track === "overlay" ? "bg-th-overlay" : "bg-th-elevated",
|
|
274
274
|
"forced-colors:border forced-colors:border-[CanvasText] forced-colors:bg-[Canvas]",
|
|
275
275
|
vertical ? cn("h-full", METER_THICK_V[size]) : cn("w-full", METER_THICK[size]),
|
|
276
|
-
!showValue && className
|
|
276
|
+
(!showValue || vertical) && className
|
|
277
277
|
),
|
|
278
278
|
children: /* @__PURE__ */ jsx(
|
|
279
279
|
"div",
|
|
@@ -601,7 +601,7 @@ function AppHeader({
|
|
|
601
601
|
/* @__PURE__ */ jsx("span", { className: cn("truncate", hideName && "max-sm:sr-only"), children: name })
|
|
602
602
|
] });
|
|
603
603
|
const markClass = "inline-flex min-w-0 items-center gap-2 text-xl font-bold tracking-tight text-th-hi";
|
|
604
|
-
const pillArrow = /* @__PURE__ */ jsx("span", { className: "inline-block rtl:-scale-x-100", children: "\u2190" });
|
|
604
|
+
const pillArrow = /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-block rtl:-scale-x-100", children: "\u2190" });
|
|
605
605
|
return /* @__PURE__ */ jsxs(
|
|
606
606
|
"header",
|
|
607
607
|
{
|
|
@@ -648,7 +648,7 @@ function AppHeader({
|
|
|
648
648
|
/* @__PURE__ */ jsxs("div", { className: "ms-auto flex shrink-0 items-center gap-2", children: [
|
|
649
649
|
actions,
|
|
650
650
|
overflowActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
651
|
-
/* @__PURE__ */ jsx("div", { ref: inlineActionsRef, className: "hidden items-center gap-2 sm:flex [&>button]:w-auto", children: overflowActions }),
|
|
651
|
+
/* @__PURE__ */ jsx("div", { ref: inlineActionsRef, className: "hidden items-center gap-2 sm:flex [&>button]:w-auto", children: /* @__PURE__ */ jsx(InlineMenuItemContext.Provider, { value: true, children: overflowActions }) }),
|
|
652
652
|
/* @__PURE__ */ jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsx(
|
|
653
653
|
DropdownMenu,
|
|
654
654
|
{
|
|
@@ -720,7 +720,7 @@ function ChartLegend({ items, marker = "line", label, className, ref, ...rest })
|
|
|
720
720
|
"aria-label": label ?? strings.legend,
|
|
721
721
|
className: cn("flex flex-wrap gap-x-4 gap-y-1 text-xs text-th-hi2", className),
|
|
722
722
|
...rest,
|
|
723
|
-
children: items.map((it) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
|
|
723
|
+
children: items.map((it, i) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
|
|
724
724
|
/* @__PURE__ */ jsx(
|
|
725
725
|
"i",
|
|
726
726
|
{
|
|
@@ -734,7 +734,7 @@ function ChartLegend({ items, marker = "line", label, className, ref, ...rest })
|
|
|
734
734
|
}
|
|
735
735
|
),
|
|
736
736
|
it.label
|
|
737
|
-
] }, it.label))
|
|
737
|
+
] }, `${it.label}-${i}`))
|
|
738
738
|
}
|
|
739
739
|
);
|
|
740
740
|
}
|
|
@@ -14,7 +14,7 @@ function SkeletonRows({ rows = 5, height = 56, gap = "md", label, className, row
|
|
|
14
14
|
const s = useStrings(STATUS_STRINGS);
|
|
15
15
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, role: "status", className: cn("grid", gap === "sm" ? "gap-1.5" : "gap-2.5", className), children: [
|
|
16
16
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label ?? s.loading }),
|
|
17
|
-
Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", rowClassName), style: rowClassName &&
|
|
17
|
+
Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: cn("w-full rounded-xl", rowClassName), style: rowClassName && /(^|\s)([\w-]+:)*(h|size)-/.test(rowClassName) ? void 0 : { height } }, i))
|
|
18
18
|
] });
|
|
19
19
|
}
|
|
20
20
|
var SPINNER_SIZE = { xs: 12, sm: 14, md: 16, lg: 24 };
|
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/components/file-dropzone.tsx
|
|
4
|
-
import { useRef, useState } from "react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
5
|
import { cn } from "../cn.js";
|
|
6
6
|
import { XIcon } from "./icons.js";
|
|
7
7
|
import { IconButton } from "./primitives.js";
|
|
8
8
|
import { useStrings } from "./provider.js";
|
|
9
9
|
import { FILE_STRINGS } from "./strings.js";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var EXT_TYPES = {
|
|
12
|
+
jpg: "image/jpeg",
|
|
13
|
+
jpeg: "image/jpeg",
|
|
14
|
+
png: "image/png",
|
|
15
|
+
gif: "image/gif",
|
|
16
|
+
webp: "image/webp",
|
|
17
|
+
heic: "image/heic",
|
|
18
|
+
heif: "image/heif",
|
|
19
|
+
avif: "image/avif",
|
|
20
|
+
svg: "image/svg+xml",
|
|
21
|
+
pdf: "application/pdf",
|
|
22
|
+
mp4: "video/mp4",
|
|
23
|
+
mov: "video/quicktime",
|
|
24
|
+
webm: "video/webm",
|
|
25
|
+
mp3: "audio/mpeg",
|
|
26
|
+
wav: "audio/wav",
|
|
27
|
+
m4a: "audio/mp4",
|
|
28
|
+
txt: "text/plain",
|
|
29
|
+
csv: "text/csv",
|
|
30
|
+
json: "application/json"
|
|
31
|
+
};
|
|
11
32
|
function matchesAccept(file, accept) {
|
|
12
33
|
const tokens = (accept ?? "").split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
13
34
|
if (tokens.length === 0) return true;
|
|
14
35
|
const fileName = file.name.toLowerCase();
|
|
15
|
-
const type = file.type.toLowerCase();
|
|
36
|
+
const type = file.type.toLowerCase() || EXT_TYPES[fileName.split(".").pop() ?? ""] || "";
|
|
16
37
|
return tokens.some((t) => {
|
|
17
38
|
if (t.startsWith(".")) return fileName.endsWith(t);
|
|
39
|
+
if (!type) return t.endsWith("/*");
|
|
18
40
|
if (t.endsWith("/*")) return type.startsWith(t.slice(0, -1));
|
|
19
41
|
return type === t;
|
|
20
42
|
});
|
|
@@ -60,6 +82,26 @@ function FileDropzone({
|
|
|
60
82
|
const [files, setFiles] = useState([]);
|
|
61
83
|
const [dragging, setDragging] = useState(false);
|
|
62
84
|
const isInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
|
|
85
|
+
const latestChange = useRef(onFilesChange);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
latestChange.current = onFilesChange;
|
|
88
|
+
});
|
|
89
|
+
const hasFiles = useRef(false);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
hasFiles.current = files.length > 0;
|
|
92
|
+
}, [files]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const form = input.current?.form;
|
|
95
|
+
if (!form) return;
|
|
96
|
+
const onReset = () => {
|
|
97
|
+
depth.current = 0;
|
|
98
|
+
setDragging(false);
|
|
99
|
+
setFiles([]);
|
|
100
|
+
if (hasFiles.current) latestChange.current?.([], []);
|
|
101
|
+
};
|
|
102
|
+
form.addEventListener("reset", onReset);
|
|
103
|
+
return () => form.removeEventListener("reset", onReset);
|
|
104
|
+
}, []);
|
|
63
105
|
const take = (incoming) => {
|
|
64
106
|
const rejected = [];
|
|
65
107
|
const list = multiple ? [...files] : [];
|
|
@@ -64,7 +64,9 @@ function FilterBar({
|
|
|
64
64
|
}) {
|
|
65
65
|
const strings = useStrings(FILTER_STRINGS, FIELD_STRINGS);
|
|
66
66
|
const compact = useMediaQuery(sheetBelow === "lg" ? LG_QUERY : NARROW_QUERY);
|
|
67
|
-
const [
|
|
67
|
+
const [openState, setOpen] = useState(false);
|
|
68
|
+
const open = openState && compact;
|
|
69
|
+
if (!compact && openState) setOpen(false);
|
|
68
70
|
const hasChildren = children != null && children !== false;
|
|
69
71
|
const searchBox = search ? /* @__PURE__ */ jsx(
|
|
70
72
|
SearchInput,
|
|
@@ -14,7 +14,7 @@ import { useIsoLayoutEffect } from "./client.js";
|
|
|
14
14
|
import { useMediaQuery, useNow } from "./hooks.js";
|
|
15
15
|
import { Tooltip } from "./tooltip.js";
|
|
16
16
|
import { Badge } from "./primitives.js";
|
|
17
|
-
import { useStrings } from "./provider.js";
|
|
17
|
+
import { useNishContext, useStrings } from "./provider.js";
|
|
18
18
|
import { PROGRESS_STRINGS, FLOW_STRINGS } from "./strings.js";
|
|
19
19
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
20
|
var EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
@@ -120,7 +120,6 @@ var NODE_STATUS = {
|
|
|
120
120
|
done: "bg-th-ok-fill text-th-on-ok forced-colors:border-2 forced-colors:border-[color:Highlight]",
|
|
121
121
|
failed: "bg-th-loss-fill text-th-on-loss forced-colors:border-2 forced-colors:border-dashed forced-colors:border-[color:CanvasText]"
|
|
122
122
|
};
|
|
123
|
-
var STEP_SR_DEFAULT = { done: ", done", failed: ", failed" };
|
|
124
123
|
function pickStepFx(from, to) {
|
|
125
124
|
if (to === "done") return "done";
|
|
126
125
|
if (to === "failed") return "failed";
|
|
@@ -229,7 +228,7 @@ function FlowSteps({ steps, orientation = "auto", label, statusLabels, className
|
|
|
229
228
|
index: i,
|
|
230
229
|
last: i === steps.length - 1,
|
|
231
230
|
sweeping,
|
|
232
|
-
statusWord: step.status === "done" || step.status === "failed" ? statusLabels?.[step.status] ??
|
|
231
|
+
statusWord: step.status === "done" || step.status === "failed" ? statusLabels?.[step.status] ?? (step.status === "done" ? s.stepDone : s.stepFailed) : void 0
|
|
233
232
|
},
|
|
234
233
|
step.id
|
|
235
234
|
)) }) });
|
|
@@ -298,14 +297,8 @@ function TickerText({ text, as = "span", className, ref, ...rest }) {
|
|
|
298
297
|
/* @__PURE__ */ jsx("span", { className: animating ? "nish-flow-ticker-in" : void 0, children: cur.text }, cur.text)
|
|
299
298
|
] });
|
|
300
299
|
}
|
|
301
|
-
var STATE_WORD = {
|
|
302
|
-
queued: "Queued",
|
|
303
|
-
running: "Running",
|
|
304
|
-
done: "Done",
|
|
305
|
-
failed: "Failed"
|
|
306
|
-
};
|
|
307
300
|
var AGENT_STATE = {
|
|
308
|
-
queued: "border-dashed border-th-line
|
|
301
|
+
queued: "border-dashed border-th-line bg-th-bg",
|
|
309
302
|
running: "border-th-accent",
|
|
310
303
|
done: "border-th-ok-fill/40",
|
|
311
304
|
failed: "border-th-loss-fill"
|
|
@@ -349,7 +342,14 @@ function AgentNode({ label, state, model, activity, meta, onClick, stateLabels,
|
|
|
349
342
|
const own = useRef(null);
|
|
350
343
|
const ref = useMergedRef(own, refProp);
|
|
351
344
|
useTransitionFx(state, own, pickAgentFx);
|
|
352
|
-
const
|
|
345
|
+
const s = useStrings(FLOW_STRINGS);
|
|
346
|
+
const stateWord = {
|
|
347
|
+
queued: s.agentQueued,
|
|
348
|
+
running: s.agentRunning,
|
|
349
|
+
done: s.agentDone,
|
|
350
|
+
failed: s.agentFailed
|
|
351
|
+
};
|
|
352
|
+
const aria = `${label}: ${stateLabels?.[state] ?? stateWord[state]}`;
|
|
353
353
|
const classes = cn(
|
|
354
354
|
"nish-flow-agent block min-h-16 w-full min-w-0 rounded-xl border bg-th-surface p-3 text-start",
|
|
355
355
|
AGENT_STATE[state],
|
|
@@ -455,9 +455,9 @@ function WorkflowBoard({ phases, agents, label, otherLabel, waitingLabel, classN
|
|
|
455
455
|
state === "active" ? "border-th-accent/50" : "border-th-line"
|
|
456
456
|
),
|
|
457
457
|
children: [
|
|
458
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
458
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
459
459
|
state === "done" ? /* @__PURE__ */ jsx("span", { className: "grid size-4 shrink-0 place-items-center rounded-full bg-th-ok-fill text-th-on-ok", children: /* @__PURE__ */ jsx(CheckSvg, { size: 10 }) }) : null,
|
|
460
|
-
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm font-medium", state === "active" ? "text-th-accent" : "text-th-hi"), children: phase.title }),
|
|
460
|
+
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate text-sm font-medium", state === "active" ? "text-th-accent" : state === "waiting" ? "text-th-hi2" : "text-th-hi"), children: phase.title }),
|
|
461
461
|
phase.model ? /* @__PURE__ */ jsx(ModelBadge, { model: phase.model }) : null,
|
|
462
462
|
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs tabular-nums text-th-hi3", children: [
|
|
463
463
|
finished,
|
|
@@ -495,7 +495,7 @@ function WorkflowBoard({ phases, agents, label, otherLabel, waitingLabel, classN
|
|
|
495
495
|
next ? /* @__PURE__ */ jsx(PhaseConnector, { flowing }) : null
|
|
496
496
|
]
|
|
497
497
|
},
|
|
498
|
-
phase.id
|
|
498
|
+
`${phase.id}:${ci}`
|
|
499
499
|
);
|
|
500
500
|
}) }) });
|
|
501
501
|
}
|
|
@@ -509,6 +509,7 @@ var FEED_DOT = {
|
|
|
509
509
|
var FEED_DOT_FORCED = "forced-colors:bg-[color:CanvasText]";
|
|
510
510
|
function ActivityFeed({ items, max = 50, now, label, empty, className, ref, ...rest }) {
|
|
511
511
|
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
512
|
+
const { locale } = useNishContext();
|
|
512
513
|
const internalNow = useNow(15e3);
|
|
513
514
|
const clock = now ?? internalNow;
|
|
514
515
|
const shown = useMemo(() => [...items].sort((a, b) => b.at - a.at).slice(0, Math.max(0, max)), [items, max]);
|
|
@@ -525,7 +526,7 @@ function ActivityFeed({ items, max = 50, now, label, empty, className, ref, ...r
|
|
|
525
526
|
/* @__PURE__ */ jsx("div", { className: "break-words text-sm text-th-hi2", children: item.text }),
|
|
526
527
|
item.source != null ? /* @__PURE__ */ jsx("div", { className: "break-words text-xs text-th-hi3", children: item.source }) : null
|
|
527
528
|
] }),
|
|
528
|
-
/* @__PURE__ */ jsx("span", { className: "pt-0.5 text-end text-xs tabular-nums text-th-hi3", children: ago(item.at, { now: clock, style: "short" }) })
|
|
529
|
+
/* @__PURE__ */ jsx("span", { className: "pt-0.5 text-end text-xs tabular-nums text-th-hi3", children: ago(item.at, { now: clock, style: "short", locale }) })
|
|
529
530
|
] }) }) }, item.id)) });
|
|
530
531
|
}
|
|
531
532
|
var ENTER_MS = 400;
|
|
@@ -16,7 +16,7 @@ function chipClass({ pressed = false, variant = "toggle", size = "md", className
|
|
|
16
16
|
return cn(
|
|
17
17
|
CHIP_BASE,
|
|
18
18
|
CHIP_SIZE[size],
|
|
19
|
-
variant !== "tag" && "pointer-coarse:min-h-11",
|
|
19
|
+
variant !== "tag" && "pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center",
|
|
20
20
|
CHIP_LOOK[variant === "toggle" && pressed ? "pressed" : variant],
|
|
21
21
|
className
|
|
22
22
|
);
|
|
@@ -69,6 +69,28 @@ function Textarea({ ref, invalid, size = "md", autoGrow = false, className, rows
|
|
|
69
69
|
useIsoLayoutEffect(() => {
|
|
70
70
|
resize();
|
|
71
71
|
}, [resize, value]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const el = inner.current;
|
|
74
|
+
if (!grow || !el) return;
|
|
75
|
+
let lastWidth = el.clientWidth;
|
|
76
|
+
let ro;
|
|
77
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
78
|
+
ro = new ResizeObserver(() => {
|
|
79
|
+
const w = el.clientWidth;
|
|
80
|
+
if (w === lastWidth) return;
|
|
81
|
+
lastWidth = w;
|
|
82
|
+
resize();
|
|
83
|
+
});
|
|
84
|
+
ro.observe(el);
|
|
85
|
+
}
|
|
86
|
+
const form = el.form;
|
|
87
|
+
const onReset = () => queueMicrotask(resize);
|
|
88
|
+
form?.addEventListener("reset", onReset);
|
|
89
|
+
return () => {
|
|
90
|
+
ro?.disconnect();
|
|
91
|
+
form?.removeEventListener("reset", onReset);
|
|
92
|
+
};
|
|
93
|
+
}, [grow, resize]);
|
|
72
94
|
return /* @__PURE__ */ jsx(
|
|
73
95
|
"textarea",
|
|
74
96
|
{
|
|
@@ -225,8 +247,8 @@ function Switch({
|
|
|
225
247
|
role: "switch",
|
|
226
248
|
"aria-checked": checked,
|
|
227
249
|
"aria-required": required || void 0,
|
|
228
|
-
"aria-labelledby": label != null ? labelId : rest["aria-labelledby"],
|
|
229
|
-
"aria-describedby": description != null ? descId :
|
|
250
|
+
"aria-labelledby": [label != null ? labelId : void 0, rest["aria-labelledby"]].filter(Boolean).join(" ") || void 0,
|
|
251
|
+
"aria-describedby": [rest["aria-describedby"], description != null ? descId : void 0].filter(Boolean).join(" ") || void 0,
|
|
230
252
|
"data-state": state,
|
|
231
253
|
"data-disabled": disabled ? "" : void 0,
|
|
232
254
|
disabled,
|
|
@@ -337,9 +359,10 @@ function Field({
|
|
|
337
359
|
const childId = only && typeof only.props.id === "string" ? only.props.id : void 0;
|
|
338
360
|
const controlId = htmlFor ?? childId ?? `${auto}-control`;
|
|
339
361
|
const hasError = error != null && error !== false && error !== "";
|
|
362
|
+
const hasHint = hint != null && hint !== false && hint !== "";
|
|
340
363
|
const hintId = `${auto}-hint`;
|
|
341
364
|
const errorId = `${auto}-error`;
|
|
342
|
-
const describedBy = [only?.props["aria-describedby"], hasError ? errorId :
|
|
365
|
+
const describedBy = [only?.props["aria-describedby"], hasError ? errorId : hasHint ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
343
366
|
const control = only ? cloneElement(only, {
|
|
344
367
|
id: htmlFor ?? childId ?? controlId,
|
|
345
368
|
"aria-describedby": describedBy,
|
|
@@ -365,7 +388,7 @@ function Field({
|
|
|
365
388
|
]
|
|
366
389
|
}
|
|
367
390
|
);
|
|
368
|
-
const message = hasError ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-xs text-th-loss", children: error }) :
|
|
391
|
+
const message = hasError ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-xs text-th-loss", children: error }) : hasHint ? /* @__PURE__ */ jsx("p", { id: hintId, className: "text-xs text-th-hi3", children: hint }) : null;
|
|
369
392
|
if (inline) {
|
|
370
393
|
return /* @__PURE__ */ jsxs(
|
|
371
394
|
"div",
|
|
@@ -392,16 +415,17 @@ function FieldGroup({ ref, label, hint, error, optional = false, className, chil
|
|
|
392
415
|
const auto = useId();
|
|
393
416
|
const strings = useStrings(FIELD_STRINGS);
|
|
394
417
|
const hasError = error != null && error !== false && error !== "";
|
|
418
|
+
const hasHint = hint != null && hint !== false && hint !== "";
|
|
395
419
|
const hintId = `${auto}-hint`;
|
|
396
420
|
const errorId = `${auto}-error`;
|
|
397
|
-
const describedBy = [rest["aria-describedby"], hasError ? errorId :
|
|
421
|
+
const describedBy = [rest["aria-describedby"], hasError ? errorId : hasHint ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
398
422
|
return /* @__PURE__ */ jsxs("fieldset", { ...rest, ref, "aria-describedby": describedBy, className: cn("m-0 grid min-w-0 gap-1.5 border-0 p-0", className), children: [
|
|
399
423
|
/* @__PURE__ */ jsxs("legend", { className: "mb-1.5 flex flex-wrap items-baseline gap-x-1.5 p-0 text-sm font-medium text-th-hi", children: [
|
|
400
424
|
/* @__PURE__ */ jsx("span", { children: label }),
|
|
401
425
|
optional ? /* @__PURE__ */ jsx("span", { className: "text-xs font-normal text-th-hi3", children: strings.optional }) : null
|
|
402
426
|
] }),
|
|
403
427
|
children,
|
|
404
|
-
hasError ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-xs text-th-loss", children: error }) :
|
|
428
|
+
hasError ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-xs text-th-loss", children: error }) : hasHint ? /* @__PURE__ */ jsx("p", { id: hintId, className: "text-xs text-th-hi3", children: hint }) : null
|
|
405
429
|
] });
|
|
406
430
|
}
|
|
407
431
|
var SEARCH_SIZE = {
|