nish-ui 3.2.0 → 3.3.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 +7 -3
- package/dist/base-tailwind.css +30 -15
- package/dist/base.css +30 -15
- package/dist/elements-all.js +78 -78
- package/dist/elements-charts.js +39 -38
- package/dist/elements-data.d.ts +10 -0
- package/dist/elements-data.js +4 -5
- package/dist/elements-forms.js +5 -5
- package/dist/elements.d.ts +1 -0
- package/dist/elements.js +4 -4
- package/dist/esm/command-filter.js +55 -4
- package/dist/esm/components/accordion.js +3 -2
- package/dist/esm/components/app-shell.js +8 -4
- package/dist/esm/components/breadcrumbs.js +7 -3
- package/dist/esm/components/calendar-base.js +32 -5
- package/dist/esm/components/calendar-classes.js +14 -2
- package/dist/esm/components/canvas/follow-caption.js +31 -21
- package/dist/esm/components/canvas/follow.js +5 -6
- package/dist/esm/components/canvas/minimap.js +3 -3
- package/dist/esm/components/canvas/system-canvas.js +3 -1
- package/dist/esm/components/canvas/view.js +0 -2
- package/dist/esm/components/carousel.js +2 -3
- package/dist/esm/components/charts.js +18 -7
- package/dist/esm/components/combobox.js +18 -7
- package/dist/esm/components/command.js +23 -61
- package/dist/esm/components/context-menu.js +2 -1
- package/dist/esm/components/data-classes.js +5 -4
- package/dist/esm/components/data.js +19 -10
- package/dist/esm/components/display.js +20 -11
- package/dist/esm/components/drawer.js +17 -4
- package/dist/esm/components/error-boundary.js +3 -3
- package/dist/esm/components/feedback.js +3 -3
- package/dist/esm/components/file-dropzone.js +16 -6
- package/dist/esm/components/filters.js +42 -1
- package/dist/esm/components/flow.js +8 -5
- package/dist/esm/components/forms-classes.js +2 -0
- package/dist/esm/components/forms.js +2 -2
- package/dist/esm/components/hooks.js +47 -13
- package/dist/esm/components/hover-card.js +2 -1
- package/dist/esm/components/inbox.js +5 -1
- package/dist/esm/components/latest.js +4 -2
- package/dist/esm/components/layout.js +7 -4
- package/dist/esm/components/menu.js +10 -1
- package/dist/esm/components/modal.js +17 -4
- package/dist/esm/components/multi-select.js +5 -5
- package/dist/esm/components/nav.js +30 -11
- package/dist/esm/components/navigate.js +1 -1
- package/dist/esm/components/overlay-dialog.js +35 -1
- package/dist/esm/components/pagination.js +1 -1
- package/dist/esm/components/primitives.js +17 -4
- package/dist/esm/components/progress.js +2 -1
- package/dist/esm/components/resource.js +14 -4
- package/dist/esm/components/segmented.js +2 -0
- package/dist/esm/components/separator.js +6 -1
- package/dist/esm/components/service-tokens.js +18 -7
- package/dist/esm/components/settings.js +16 -0
- package/dist/esm/components/slider.js +5 -1
- package/dist/esm/components/split.js +4 -2
- package/dist/esm/components/strings.js +17 -4
- package/dist/esm/components/table.js +15 -3
- package/dist/esm/components/tag-input.js +5 -1
- package/dist/esm/components/time-field.js +15 -7
- package/dist/esm/components/toast-card.js +5 -3
- package/dist/esm/components/toast.js +4 -1
- package/dist/esm/components/tooltip.js +3 -2
- package/dist/esm/components/url-state.js +3 -1
- package/dist/esm/components/virtual-table.js +2 -2
- package/dist/esm/components/virtual.js +8 -4
- package/dist/esm/format.js +3 -2
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/server/inbox/client.js +4 -0
- package/dist/esm/theme.js +38 -15
- package/dist/esm/tokens.mjs +1 -1
- package/dist/format.d.ts +5 -3
- package/dist/format.js +4 -3
- package/dist/inbox-client.d.ts +1 -1
- package/dist/inbox-client.js +4 -0
- package/dist/index.d.ts +61 -29
- package/dist/nish-components.css +59 -21
- package/dist/nish-components.min.css +1 -1
- package/dist/nish.css +30 -15
- package/dist/nish.min.css +1 -1
- package/dist/node/vite.js +1 -1
- package/dist/server/hono.d.ts +9 -2
- package/dist/server/hono.js +17 -4
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +7 -2
- package/dist/service-tokens.d.ts +4 -4
- package/dist/{spa-BfRDo38r.d.ts → spa-FwS7yZ8p.d.ts} +4 -3
- package/dist/system-canvas.d.ts +11 -10
- package/dist/theme.d.ts +30 -2
- package/dist/theme.global.js +45 -18
- package/dist/theme.js +45 -18
- package/package.json +3 -2
- package/dist/tokens.js +0 -425
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/components/canvas/follow-caption.tsx
|
|
4
|
-
import { memo } from "react";
|
|
4
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { StatusDot } from "../display.js";
|
|
6
6
|
import { TickerText } from "../flow.js";
|
|
7
7
|
import { DEFAULT_CANVAS_LABELS } from "./types.js";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
var FollowCaption = memo(function FollowCaption2({ step, labels = DEFAULT_CANVAS_LABELS }) {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
const only = step && step.targets.length === 1 ? step.targets[0] : null;
|
|
11
|
+
const text = !step ? null : step.mode === "idle" ? labels.followIdle : only ? labels.followOne(only.group, only.label) : labels.followMany(step.targets.length);
|
|
12
|
+
const textRef = useRef(text);
|
|
13
|
+
const [spoken, setSpoken] = useState("");
|
|
14
|
+
const mode = step?.mode;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
textRef.current = text;
|
|
17
|
+
});
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setSpoken(mode ? textRef.current ?? "" : "");
|
|
20
|
+
}, [mode]);
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: spoken }),
|
|
23
|
+
step ? /* @__PURE__ */ jsxs(
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
"data-canvas-ui": true,
|
|
27
|
+
"data-follow-caption": true,
|
|
28
|
+
className: "absolute bottom-[68px] start-3 z-10 flex max-w-[min(420px,calc(100%-24px))] items-center gap-2 rounded-xl border border-th-line bg-th-surface px-3 py-2 text-xs text-th-hi shadow-card min-[600px]:bottom-3",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(StatusDot, { tone: "accent", pulse: step.mode !== "idle" }),
|
|
31
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: "truncate", children: text }),
|
|
33
|
+
only?.note ? /* @__PURE__ */ jsx(TickerText, { as: "div", text: only.note, className: "truncate text-th-hi3" }) : null
|
|
34
|
+
] })
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
) : null
|
|
38
|
+
] });
|
|
29
39
|
});
|
|
30
40
|
export {
|
|
31
41
|
FollowCaption
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
// src/components/canvas/follow.ts
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
import { centerOn, clampK } from "./view.js";
|
|
5
|
+
import { centerOn, clampK, FIT_PAD, PHONE_K, PHONE_MAX_W } from "./view.js";
|
|
6
6
|
var CYCLE_MS = 6e3;
|
|
7
7
|
var BBOX_PAD = 80;
|
|
8
|
-
var VIEW_PAD =
|
|
9
|
-
var PHONE_W = 600;
|
|
8
|
+
var VIEW_PAD = 2 * FIT_PAD;
|
|
10
9
|
var PHONE_TOP = 0.45;
|
|
11
10
|
function followTargets(groups, layout) {
|
|
12
11
|
const out = [];
|
|
@@ -21,14 +20,14 @@ function followTargets(groups, layout) {
|
|
|
21
20
|
}
|
|
22
21
|
function place(w, h, k, box, groupBox, top = 0) {
|
|
23
22
|
const v = centerOn(w, h, k, box);
|
|
24
|
-
if (w >=
|
|
23
|
+
if (w >= PHONE_MAX_W) return v;
|
|
25
24
|
const y = Math.max(h * PHONE_TOP / 2, top + box.h * k / 2) - (box.y + box.h / 2) * k;
|
|
26
25
|
if (groupBox && groupBox.w * k <= w - 24) return { ...v, x: w / 2 - (groupBox.x + groupBox.w / 2) * k, y };
|
|
27
26
|
return { ...v, y };
|
|
28
27
|
}
|
|
29
28
|
function followStep(targets, i, w, h, fit, top = 0) {
|
|
30
29
|
if (targets.length === 0) return { mode: "idle", view: fit, targets: [] };
|
|
31
|
-
const phone = w <
|
|
30
|
+
const phone = w < PHONE_MAX_W;
|
|
32
31
|
const single = phone ? 0.8 : 1;
|
|
33
32
|
if (targets.length === 1) {
|
|
34
33
|
return { mode: "all", targets, view: place(w, h, single, targets[0].box, targets[0].groupBox, top) };
|
|
@@ -45,7 +44,7 @@ function followStep(targets, i, w, h, fit, top = 0) {
|
|
|
45
44
|
}
|
|
46
45
|
const bbox = { x: x0 - BBOX_PAD, y: y0 - BBOX_PAD, w: x1 - x0 + 2 * BBOX_PAD, h: y1 - y0 + 2 * BBOX_PAD };
|
|
47
46
|
const kAll = Math.min((w - VIEW_PAD) / bbox.w, (h - VIEW_PAD) / bbox.h, 1.1);
|
|
48
|
-
if (kAll >= (phone ?
|
|
47
|
+
if (kAll >= (phone ? PHONE_K : 0.75)) {
|
|
49
48
|
return { mode: "all", targets, view: place(w, h, clampK(kAll), bbox, void 0, top) };
|
|
50
49
|
}
|
|
51
50
|
const target = targets[(i % targets.length + targets.length) % targets.length];
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// src/components/canvas/minimap.tsx
|
|
4
4
|
import { memo, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
|
5
|
+
import { PHONE_MAX_W } from "./view.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
var MAP_W = 176;
|
|
7
8
|
var MAP_MAX_H = 132;
|
|
8
9
|
var MAP_MIN_H = 60;
|
|
9
|
-
var MIN_CANVAS_W = 600;
|
|
10
10
|
var hueVar = (hue, soft) => hue ? `var(--nish-${hue}${soft ? "-soft" : ""})` : soft ? "var(--nish-accent-soft)" : "var(--nish-accent)";
|
|
11
11
|
var Minimap = memo(function Minimap2({
|
|
12
12
|
layout,
|
|
@@ -30,7 +30,7 @@ var Minimap = memo(function Minimap2({
|
|
|
30
30
|
const rect = rectRef.current;
|
|
31
31
|
if (!cur || !wrap || !rect) return;
|
|
32
32
|
const { v, size } = cur;
|
|
33
|
-
wrap.style.display = size.w <
|
|
33
|
+
wrap.style.display = size.w < PHONE_MAX_W ? "none" : "";
|
|
34
34
|
const x0 = Math.max(0, ox + -v.x / v.k * s);
|
|
35
35
|
const y0 = Math.max(0, oy + (-v.y / v.k + layout.titleRoom) * s);
|
|
36
36
|
const x1 = Math.min(MAP_W, ox + (-v.x + size.w) / v.k * s);
|
|
@@ -68,7 +68,7 @@ var Minimap = memo(function Minimap2({
|
|
|
68
68
|
ref: wrapRef,
|
|
69
69
|
"data-canvas-ui": true,
|
|
70
70
|
"aria-hidden": "true",
|
|
71
|
-
className: "nish-canvas-minimap absolute
|
|
71
|
+
className: "nish-canvas-minimap absolute end-3 top-3 z-[5] overflow-hidden rounded-xl border border-th-line bg-th-surface shadow-pop",
|
|
72
72
|
style: { display: "none" },
|
|
73
73
|
children: /* @__PURE__ */ jsxs(
|
|
74
74
|
"svg",
|
|
@@ -502,6 +502,8 @@ function SystemCanvas({
|
|
|
502
502
|
g.mode = "pan";
|
|
503
503
|
g.lastX = rest2.x;
|
|
504
504
|
g.lastY = rest2.y;
|
|
505
|
+
} else if (pointers.current.size >= 2 && g.mode === "pinch") {
|
|
506
|
+
startPinch();
|
|
505
507
|
} else if (pointers.current.size === 0) {
|
|
506
508
|
if (g.mode === "pending" && e.pointerType === "touch" && e.type === "pointerup") {
|
|
507
509
|
const p = local(e);
|
|
@@ -731,7 +733,7 @@ function SystemCanvas({
|
|
|
731
733
|
ref: setViewportRef,
|
|
732
734
|
role: "application",
|
|
733
735
|
"aria-label": label,
|
|
734
|
-
"aria-roledescription":
|
|
736
|
+
"aria-roledescription": strings.canvasRole,
|
|
735
737
|
tabIndex: 0,
|
|
736
738
|
className: cn("nish-canvas", className),
|
|
737
739
|
style: { height, ...style },
|
|
@@ -4,7 +4,6 @@ var MAX_K = 2;
|
|
|
4
4
|
var PHONE_K = 0.55;
|
|
5
5
|
var PHONE_MAX_W = 600;
|
|
6
6
|
var FIT_PAD = 48;
|
|
7
|
-
var TITLE_ROOM = 36;
|
|
8
7
|
var LABEL_K = 0.8;
|
|
9
8
|
var ANIM_MS = 300;
|
|
10
9
|
var FOLLOW_MS = 700;
|
|
@@ -38,7 +37,6 @@ export {
|
|
|
38
37
|
MIN_K,
|
|
39
38
|
PHONE_K,
|
|
40
39
|
PHONE_MAX_W,
|
|
41
|
-
TITLE_ROOM,
|
|
42
40
|
ZOOM_STEP,
|
|
43
41
|
centerOn,
|
|
44
42
|
clampK,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/components/carousel.tsx
|
|
4
4
|
import {
|
|
5
5
|
Children,
|
|
6
|
+
isValidElement,
|
|
6
7
|
useCallback,
|
|
7
8
|
useEffect,
|
|
8
9
|
useRef,
|
|
@@ -256,8 +257,6 @@ function Carousel({
|
|
|
256
257
|
{
|
|
257
258
|
ref: trackRef,
|
|
258
259
|
tabIndex: 0,
|
|
259
|
-
role: "group",
|
|
260
|
-
"aria-label": ariaLabel,
|
|
261
260
|
onKeyDown: onTrackKey,
|
|
262
261
|
onScroll,
|
|
263
262
|
className: "flex w-full min-w-0 snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain rounded-lg [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
@@ -274,7 +273,7 @@ function Carousel({
|
|
|
274
273
|
style: { width: slideWidth },
|
|
275
274
|
children: child
|
|
276
275
|
},
|
|
277
|
-
i
|
|
276
|
+
isValidElement(child) && child.key != null ? child.key : i
|
|
278
277
|
))
|
|
279
278
|
}
|
|
280
279
|
)
|
|
@@ -85,10 +85,12 @@ function LineChart({
|
|
|
85
85
|
const yFmt = yFormat ?? ((v) => chartNumber(v, loc));
|
|
86
86
|
const xFmt = xFormat ?? ((v) => chartNumber(v, loc));
|
|
87
87
|
const [wrapRef, width, wrapEl] = useWidth();
|
|
88
|
+
const rootRef = useMemo(() => mergeRefs(wrapRef, ref), [wrapRef, ref]);
|
|
88
89
|
const rtl = useChartRtl(wrapEl);
|
|
89
90
|
const gradId = `nish-area-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
90
91
|
const [active, setActive] = useState(null);
|
|
91
92
|
const fromKey = useRef(false);
|
|
93
|
+
const [viaKey, setViaKey] = useState(false);
|
|
92
94
|
const lines = useMemo(() => series ?? (data ? [{ label, tone, points: data }] : []), [series, data, label, tone]);
|
|
93
95
|
const xs = useMemo(() => {
|
|
94
96
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -197,12 +199,14 @@ function LineChart({
|
|
|
197
199
|
};
|
|
198
200
|
const onPointer = (e) => {
|
|
199
201
|
fromKey.current = false;
|
|
202
|
+
setViaKey(false);
|
|
200
203
|
moveTo(e.clientX, e.currentTarget);
|
|
201
204
|
};
|
|
202
205
|
const onKey = (e) => {
|
|
203
206
|
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
204
207
|
e.preventDefault();
|
|
205
208
|
fromKey.current = true;
|
|
209
|
+
setViaKey(true);
|
|
206
210
|
const dir = (e.key === "ArrowRight" ? 1 : -1) * (rtl ? -1 : 1);
|
|
207
211
|
setActive((a) => a == null ? dir > 0 ? 0 : xs.length - 1 : Math.min(xs.length - 1, Math.max(0, a + dir)));
|
|
208
212
|
} else if (e.key === "Escape") setActive(null);
|
|
@@ -212,7 +216,8 @@ function LineChart({
|
|
|
212
216
|
const tipRows = ax != null ? lines.map((s, i) => ({ s, i, y: lookup[i].get(ax) })).filter((r) => r.y != null) : [];
|
|
213
217
|
const tipRight = cx < width / 2;
|
|
214
218
|
const tableXs = xs.slice(0, 200);
|
|
215
|
-
|
|
219
|
+
const announce = ax != null && viaKey ? `${xFmt(ax)}: ${tipRows.map((r) => lines.length > 1 ? `${r.s.label} ${yFmt(r.y)}` : yFmt(r.y)).join(", ")}` : "";
|
|
220
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, ref: rootRef, className: cn("relative w-full select-none", className), style: { height, ...rest.style }, children: [
|
|
216
221
|
width > 0 && /* @__PURE__ */ jsxs(
|
|
217
222
|
"svg",
|
|
218
223
|
{
|
|
@@ -301,16 +306,20 @@ function LineChart({
|
|
|
301
306
|
]
|
|
302
307
|
}
|
|
303
308
|
),
|
|
309
|
+
/* @__PURE__ */ jsx("div", { className: "sr-only", "aria-live": "polite", children: announce }),
|
|
304
310
|
/* @__PURE__ */ jsxs("table", { className: "sr-only", children: [
|
|
305
311
|
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
306
312
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
307
313
|
/* @__PURE__ */ jsx("th", { scope: "col", children: "x" }),
|
|
308
314
|
lines.map((s, i) => /* @__PURE__ */ jsx("th", { scope: "col", children: s.label }, i))
|
|
309
315
|
] }) }),
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
313
|
-
|
|
316
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
317
|
+
tableXs.map((x) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
318
|
+
/* @__PURE__ */ jsx("th", { scope: "row", children: xFmt(x) }),
|
|
319
|
+
lines.map((_, i) => /* @__PURE__ */ jsx("td", { children: lookup[i].has(x) ? yFmt(lookup[i].get(x)) : "" }, i))
|
|
320
|
+
] }, x)),
|
|
321
|
+
xs.length > tableXs.length && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", { scope: "row", colSpan: lines.length + 1, children: t.chartTruncated(tableXs.length, xs.length) }) })
|
|
322
|
+
] })
|
|
314
323
|
] })
|
|
315
324
|
] });
|
|
316
325
|
}
|
|
@@ -335,6 +344,7 @@ function BarChart({
|
|
|
335
344
|
const loc = locale ?? config.locale ?? "en-US";
|
|
336
345
|
const fmt = valueFormat ?? ((v) => chartNumber(v, loc));
|
|
337
346
|
const [wrapRef, width, wrapEl] = useWidth();
|
|
347
|
+
const rootRef = useMemo(() => mergeRefs(wrapRef, ref), [wrapRef, ref]);
|
|
338
348
|
const rtl = useChartRtl(wrapEl);
|
|
339
349
|
const coarse = useMediaQuery("(pointer: coarse)");
|
|
340
350
|
const [pickedBar, setSelected] = useState(null);
|
|
@@ -380,7 +390,7 @@ function BarChart({
|
|
|
380
390
|
setSelected(() => selected == null ? dir > 0 ? 0 : data.length - 1 : Math.min(data.length - 1, Math.max(0, selected + dir)));
|
|
381
391
|
} else if (e.key === "Escape") setSelected(null);
|
|
382
392
|
};
|
|
383
|
-
return /* @__PURE__ */ jsxs("div", { ...rest, ref:
|
|
393
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, ref: rootRef, className: cn("w-full", className), children: [
|
|
384
394
|
width > 0 && /* @__PURE__ */ jsxs(
|
|
385
395
|
"svg",
|
|
386
396
|
{
|
|
@@ -434,6 +444,7 @@ function BarChart({
|
|
|
434
444
|
] });
|
|
435
445
|
}
|
|
436
446
|
function RangeBar({ min, max, low, high, current, label, locale, className, ref, ...rest }) {
|
|
447
|
+
const t = useStrings(DISPLAY_STRINGS);
|
|
437
448
|
const config = useNishContext();
|
|
438
449
|
const loc = locale ?? config.locale ?? "en-US";
|
|
439
450
|
const num = (v) => chartNumber(v, loc);
|
|
@@ -447,7 +458,7 @@ function RangeBar({ min, max, low, high, current, label, locale, className, ref,
|
|
|
447
458
|
...rest,
|
|
448
459
|
ref,
|
|
449
460
|
role: "img",
|
|
450
|
-
"aria-label": label ??
|
|
461
|
+
"aria-label": label ?? t.rangeLabel(num(low), num(high), current != null ? num(current) : null, num(min), num(max)),
|
|
451
462
|
className: cn("relative h-1.5 w-full rounded-full bg-th-line forced-colors:bg-[color:GrayText]", className),
|
|
452
463
|
children: [
|
|
453
464
|
/* @__PURE__ */ jsx(
|
|
@@ -13,7 +13,6 @@ import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from
|
|
|
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;
|
|
16
|
-
var defaultResultsText = (n) => `${n} ${n === 1 ? "result" : "results"}`;
|
|
17
16
|
function Combobox({
|
|
18
17
|
ref,
|
|
19
18
|
options,
|
|
@@ -40,7 +39,7 @@ function Combobox({
|
|
|
40
39
|
size = "md",
|
|
41
40
|
clearLabel,
|
|
42
41
|
loadingText,
|
|
43
|
-
resultsText
|
|
42
|
+
resultsText,
|
|
44
43
|
className,
|
|
45
44
|
...rest
|
|
46
45
|
}) {
|
|
@@ -99,10 +98,22 @@ function Combobox({
|
|
|
99
98
|
useEffect(() => {
|
|
100
99
|
if (open) listRef.current?.scrollIntoView?.({ block: "nearest" });
|
|
101
100
|
}, [open]);
|
|
102
|
-
const reset =
|
|
101
|
+
const reset = () => {
|
|
102
|
+
if (dirty && onQueryChange) {
|
|
103
|
+
window.clearTimeout(debounceRef.current);
|
|
104
|
+
onQueryChange("");
|
|
105
|
+
}
|
|
103
106
|
setDirty(false);
|
|
104
107
|
setText("");
|
|
105
|
-
}
|
|
108
|
+
};
|
|
109
|
+
const [fieldLabel, setFieldLabel] = useState({});
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!open || ariaLabel || ariaLabelledBy) return;
|
|
112
|
+
const doc = inputRef.current?.ownerDocument;
|
|
113
|
+
const el = doc ? Array.from(doc.getElementsByTagName("label")).find((l) => l.htmlFor === inputId) : void 0;
|
|
114
|
+
const next = el ? el.id ? { id: el.id } : { text: el.textContent?.trim() || void 0 } : {};
|
|
115
|
+
setFieldLabel((prev) => prev.id === next.id && prev.text === next.text ? prev : next);
|
|
116
|
+
}, [open, ariaLabel, ariaLabelledBy, inputId]);
|
|
106
117
|
const close = useCallback(() => {
|
|
107
118
|
setOpen(false);
|
|
108
119
|
setActive(-1);
|
|
@@ -284,15 +295,15 @@ function Combobox({
|
|
|
284
295
|
children: /* @__PURE__ */ jsx("span", { className: "flex size-8 items-center justify-center rounded-md hover:bg-th-elevated", children: /* @__PURE__ */ jsx(XIcon, { size: 16 }) })
|
|
285
296
|
}
|
|
286
297
|
) : null,
|
|
287
|
-
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? searching : visible.length === 0 ? empty : resultsText(visible.length) : "" }),
|
|
298
|
+
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: open ? loading ? searching : visible.length === 0 ? empty : (resultsText ?? strings.resultsCount)(visible.length) : "" }),
|
|
288
299
|
open ? /* @__PURE__ */ jsxs(
|
|
289
300
|
"ul",
|
|
290
301
|
{
|
|
291
302
|
ref: listRef,
|
|
292
303
|
id: listId,
|
|
293
304
|
role: "listbox",
|
|
294
|
-
"aria-label": ariaLabel,
|
|
295
|
-
"aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ??
|
|
305
|
+
"aria-label": ariaLabel ?? (ariaLabelledBy ? void 0 : fieldLabel.text),
|
|
306
|
+
"aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? fieldLabel.id,
|
|
296
307
|
className: "absolute inset-x-0 top-full z-[var(--nish-z-dropdown,40)] mt-1 max-h-[min(16rem,40dvh)] overflow-auto rounded-xl border border-th-line bg-th-elevated shadow-pop",
|
|
297
308
|
children: [
|
|
298
309
|
visible.map((o, i) => {
|
|
@@ -9,7 +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
|
+
import { COMMAND_MAX_RESULTS, matchText, rankCommandItems } from "../command-filter.js";
|
|
13
13
|
import { safeUrl } from "../url.js";
|
|
14
14
|
import { XIcon } from "./icons.js";
|
|
15
15
|
import { Modal } from "./modal.js";
|
|
@@ -18,58 +18,8 @@ import { useLatest } from "./latest.js";
|
|
|
18
18
|
import { useStrings } from "./provider.js";
|
|
19
19
|
import { COMMAND_STRINGS, FIELD_STRINGS, OVERLAY_STRINGS } from "./strings.js";
|
|
20
20
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
-
function indexItems(items) {
|
|
22
|
-
return items.map((item) => ({ item, label: item.label.toLowerCase(), keywords: (item.keywords ?? []).map((k) => k.toLowerCase()) }));
|
|
23
|
-
}
|
|
24
|
-
function isWordStart(text, i) {
|
|
25
|
-
return i === 0 || !/[a-z0-9]/i.test(text[i - 1]);
|
|
26
|
-
}
|
|
27
|
-
function matchText(text, q) {
|
|
28
|
-
const at = text.indexOf(q);
|
|
29
|
-
if (at >= 0) {
|
|
30
|
-
let tier = at === 0 ? 0 : 2;
|
|
31
|
-
let start = at;
|
|
32
|
-
if (tier === 2) {
|
|
33
|
-
for (let from2 = at; from2 >= 0; from2 = text.indexOf(q, from2 + 1)) {
|
|
34
|
-
if (isWordStart(text, from2)) {
|
|
35
|
-
tier = 1;
|
|
36
|
-
start = from2;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
if (from2 + 1 >= text.length) break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return { tier, idx: Array.from({ length: q.length }, (_, k) => start + k) };
|
|
43
|
-
}
|
|
44
|
-
const idx = [];
|
|
45
|
-
let from = 0;
|
|
46
|
-
for (const ch of q) {
|
|
47
|
-
const found = text.indexOf(ch, from);
|
|
48
|
-
if (found < 0) return null;
|
|
49
|
-
idx.push(found);
|
|
50
|
-
from = found + 1;
|
|
51
|
-
}
|
|
52
|
-
return { tier: 3, idx };
|
|
53
|
-
}
|
|
54
21
|
function rankItems(items, query) {
|
|
55
|
-
|
|
56
|
-
if (!q) return items.slice(0, COMMAND_MAX_RESULTS).map(({ item }) => ({ item, marks: [] }));
|
|
57
|
-
const scored = [];
|
|
58
|
-
items.forEach(({ item, label: lower, keywords }, order) => {
|
|
59
|
-
const label = matchText(lower, q);
|
|
60
|
-
if (label) {
|
|
61
|
-
scored.push({ r: { item, marks: label.idx }, score: label.tier, order });
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
let best = null;
|
|
65
|
-
for (const kw of keywords) {
|
|
66
|
-
const m = matchText(kw, q);
|
|
67
|
-
if (m && m.tier < 3 && (best === null || m.tier < best)) best = m.tier;
|
|
68
|
-
}
|
|
69
|
-
if (best !== null) scored.push({ r: { item, marks: [] }, score: 4 + best, order });
|
|
70
|
-
});
|
|
71
|
-
scored.sort((a, b) => a.score - b.score || a.order - b.order);
|
|
72
|
-
return scored.slice(0, COMMAND_MAX_RESULTS).map((s) => s.r);
|
|
22
|
+
return rankCommandItems(items, query);
|
|
73
23
|
}
|
|
74
24
|
function groupRows(rows) {
|
|
75
25
|
const order = [];
|
|
@@ -124,9 +74,6 @@ function SearchIcon({ size = 18 }) {
|
|
|
124
74
|
}
|
|
125
75
|
);
|
|
126
76
|
}
|
|
127
|
-
function defaultResultsLabel(count) {
|
|
128
|
-
return `${count} result${count === 1 ? "" : "s"}`;
|
|
129
|
-
}
|
|
130
77
|
function isTypingTarget(t) {
|
|
131
78
|
if (!(t instanceof HTMLElement)) return false;
|
|
132
79
|
const tag = t.tagName;
|
|
@@ -138,7 +85,7 @@ function useCommandHotkey(open, enabled = true) {
|
|
|
138
85
|
if (!enabled) return;
|
|
139
86
|
const onKey = (e) => {
|
|
140
87
|
if (e.defaultPrevented || e.isComposing) return;
|
|
141
|
-
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "k") {
|
|
88
|
+
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && (e.key.toLowerCase() === "k" || e.code === "KeyK" && !/^[a-z]$/i.test(e.key))) {
|
|
142
89
|
e.preventDefault();
|
|
143
90
|
ref.current();
|
|
144
91
|
} else if (e.key === "/" && !e.ctrlKey && !e.metaKey && !e.altKey && !isTypingTarget(e.target)) {
|
|
@@ -176,7 +123,7 @@ function CommandPalette({
|
|
|
176
123
|
placeholder: placeholder ?? s.searchPlaceholder,
|
|
177
124
|
emptyText: emptyText ?? s.noResults,
|
|
178
125
|
resultsLabel,
|
|
179
|
-
externalLabel: externalLabel ??
|
|
126
|
+
externalLabel: externalLabel ?? s.opensInNewTab,
|
|
180
127
|
onQuery,
|
|
181
128
|
footer,
|
|
182
129
|
onSubmitQuery
|
|
@@ -196,6 +143,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
196
143
|
const itemsRef = useLatest(items);
|
|
197
144
|
const [dynamic, setDynamic] = useState([]);
|
|
198
145
|
const [pending, setPending] = useState(isFn);
|
|
146
|
+
const enterQueued = useRef(false);
|
|
199
147
|
useEffect(() => {
|
|
200
148
|
const fn = itemsRef.current;
|
|
201
149
|
if (typeof fn !== "function") return;
|
|
@@ -222,17 +170,17 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
222
170
|
if (stale) return;
|
|
223
171
|
setDynamic([]);
|
|
224
172
|
setPending(false);
|
|
173
|
+
enterQueued.current = false;
|
|
225
174
|
}
|
|
226
175
|
);
|
|
227
176
|
return () => {
|
|
228
177
|
stale = true;
|
|
229
178
|
};
|
|
230
179
|
}, [query, isFn, itemsRef]);
|
|
231
|
-
const indexed = useMemo(() => isFn ? [] : indexItems(items), [isFn, items]);
|
|
232
180
|
const rows = useMemo(() => {
|
|
233
181
|
if (isFn) return dynamic.map((item) => ({ item, marks: matchText(item.label.toLowerCase(), query.trim().toLowerCase())?.idx ?? [] }));
|
|
234
|
-
return rankItems(
|
|
235
|
-
}, [isFn, dynamic,
|
|
182
|
+
return rankItems(items, query);
|
|
183
|
+
}, [isFn, dynamic, items, query]);
|
|
236
184
|
const groups = useMemo(() => groupRows(rows), [rows]);
|
|
237
185
|
const flat = useMemo(() => groups.flatMap((g) => g.rows.map((x) => x.r.item)), [groups]);
|
|
238
186
|
useEffect(() => {
|
|
@@ -255,6 +203,16 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
255
203
|
item.onSelect?.();
|
|
256
204
|
}
|
|
257
205
|
};
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (pending || !enterQueued.current) return;
|
|
208
|
+
enterQueued.current = false;
|
|
209
|
+
const item = flat[0];
|
|
210
|
+
if (item) select(item);
|
|
211
|
+
else if (query.trim() && onSubmitQuery) {
|
|
212
|
+
onClose();
|
|
213
|
+
onSubmitQuery(query.trim());
|
|
214
|
+
}
|
|
215
|
+
}, [pending, flat]);
|
|
258
216
|
const onKeyDown = (e) => {
|
|
259
217
|
if (e.nativeEvent.isComposing) return;
|
|
260
218
|
if (e.key === "ArrowDown") {
|
|
@@ -268,6 +226,10 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
268
226
|
setActive(0);
|
|
269
227
|
} else if (e.key === "Enter") {
|
|
270
228
|
e.preventDefault();
|
|
229
|
+
if (isFn && pending) {
|
|
230
|
+
enterQueued.current = true;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
271
233
|
const item = flat[active];
|
|
272
234
|
if (item) select(item);
|
|
273
235
|
else if (!pending && query.trim() && onSubmitQuery) {
|
|
@@ -327,7 +289,7 @@ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, e
|
|
|
327
289
|
footer,
|
|
328
290
|
className: "sm:max-w-[560px]",
|
|
329
291
|
children: [
|
|
330
|
-
/* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "sr-only", children: showEmpty ? "" : (resultsLabel ??
|
|
292
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "sr-only", children: showEmpty ? "" : (resultsLabel ?? s.resultsCount)(flat.length) }),
|
|
331
293
|
/* @__PURE__ */ jsx(
|
|
332
294
|
"div",
|
|
333
295
|
{
|
|
@@ -143,7 +143,8 @@ function ContextMenu({
|
|
|
143
143
|
const active = document.activeElement;
|
|
144
144
|
if (!active || active === document.body || active.hasAttribute("data-nish-context-anchor")) returnTo.current?.focus({ preventScroll: true });
|
|
145
145
|
}, [open]);
|
|
146
|
-
const
|
|
146
|
+
const anchor = target ?? rootRef.current;
|
|
147
|
+
const content = typeof menu === "function" ? anchor ? menu(anchor) : null : menu;
|
|
147
148
|
const shown = open && content != null && content !== false;
|
|
148
149
|
return /* @__PURE__ */ jsxs(
|
|
149
150
|
"div",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { shared } from "../runtime.js";
|
|
3
3
|
var ALIGN = { left: "text-start", center: "text-center", right: "text-end" };
|
|
4
4
|
var ROW_TONE = {
|
|
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]",
|
|
6
|
-
warn: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]",
|
|
7
|
-
loss: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight]"
|
|
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] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]",
|
|
6
|
+
warn: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-warn-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-warn-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]",
|
|
7
|
+
loss: "[&>td:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] [&>th:first-child]:shadow-[inset_3px_0_0_var(--nish-loss-fill)] rtl:[&>td:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] rtl:[&>th:first-child]:shadow-[inset_-3px_0_0_var(--nish-loss-fill)] forced-colors:[&>td:first-child]:border-s-[3px] forced-colors:[&>td:first-child]:border-s-[color:Highlight] forced-colors:[&>th:first-child]:border-s-[3px] forced-colors:[&>th:first-child]:border-s-[color:Highlight]"
|
|
8
8
|
};
|
|
9
9
|
var WRAP = "relative overflow-auto rounded-xl border border-th-line bg-th-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-th-accent";
|
|
10
10
|
var STICKY = "[&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-[var(--nish-z-sticky,1)] [&_thead_th]:bg-th-surface";
|
|
@@ -41,7 +41,8 @@ var tableClass = {
|
|
|
41
41
|
/** Add to tr for a status edge. */
|
|
42
42
|
tone: ROW_TONE
|
|
43
43
|
};
|
|
44
|
-
var
|
|
44
|
+
var HIDE_BELOW = { sm: "hidden sm:table-cell", md: "hidden md:table-cell", lg: "hidden lg:table-cell" };
|
|
45
|
+
var tableInternals = { HIDE_BELOW, ALIGN, STICKY_COL, WRAP, STICKY, TABLE, ZEBRA, TH, TD, PAD, TR, TR_INTERACTIVE };
|
|
45
46
|
function mergeRefs(...refs) {
|
|
46
47
|
return (node) => {
|
|
47
48
|
const cleanups = [];
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
useId,
|
|
8
8
|
useMemo,
|
|
9
9
|
useRef,
|
|
10
|
-
useState
|
|
10
|
+
useState,
|
|
11
|
+
useSyncExternalStore
|
|
11
12
|
} from "react";
|
|
12
13
|
import { cn } from "../cn.js";
|
|
13
14
|
import { safeUrl } from "../url.js";
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
hostnameOf,
|
|
20
21
|
mergeRefs,
|
|
21
22
|
sortRows,
|
|
23
|
+
tableInternals,
|
|
22
24
|
warnOnce
|
|
23
25
|
} from "./data-classes.js";
|
|
24
26
|
import { useMediaQuery } from "./hooks.js";
|
|
@@ -58,14 +60,12 @@ function fromInteractive(e) {
|
|
|
58
60
|
const el = e.target?.closest?.('a,button,input,select,textarea,label,summary,[role="button"],[role="link"]');
|
|
59
61
|
return !!el && el !== e.currentTarget && e.currentTarget.contains(el);
|
|
60
62
|
}
|
|
63
|
+
var subscribeNever = () => () => {
|
|
64
|
+
};
|
|
61
65
|
var TABLE_SHOW = { sm: "hidden sm:block", md: "hidden md:block", lg: "hidden lg:block" };
|
|
62
66
|
var BP_PX = { sm: 640, md: 768, lg: 1024 };
|
|
63
67
|
var CARDS_SHOW = { sm: "sm:hidden", md: "md:hidden", lg: "lg:hidden" };
|
|
64
|
-
var HIDE_BELOW =
|
|
65
|
-
sm: "hidden sm:table-cell",
|
|
66
|
-
md: "hidden md:table-cell",
|
|
67
|
-
lg: "hidden lg:table-cell"
|
|
68
|
-
};
|
|
68
|
+
var { HIDE_BELOW } = tableInternals;
|
|
69
69
|
var TONE_EDGE = {
|
|
70
70
|
ok: "border-s-[3px] border-s-[var(--nish-ok-fill)]",
|
|
71
71
|
warn: "border-s-[3px] border-s-[var(--nish-warn-fill)]",
|
|
@@ -81,6 +81,9 @@ var BodyRow = /* @__PURE__ */ memo(function BodyRow2({ row, columns, tone, inter
|
|
|
81
81
|
onClick: interactive ? (e) => {
|
|
82
82
|
if (!fromInteractive(e)) onGo(row, e);
|
|
83
83
|
} : void 0,
|
|
84
|
+
onAuxClick: interactive ? (e) => {
|
|
85
|
+
if (e.button === 1 && !fromInteractive(e)) onGo(row, e);
|
|
86
|
+
} : void 0,
|
|
84
87
|
onKeyDown: interactive ? (e) => {
|
|
85
88
|
if (e.target !== e.currentTarget) return;
|
|
86
89
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -123,6 +126,9 @@ function ResponsiveTable({
|
|
|
123
126
|
const [announcement, setAnnouncement] = useState("");
|
|
124
127
|
const sortId = useId();
|
|
125
128
|
const wide = useMediaQuery(`(min-width: ${BP_PX[cardsBelow]}px)`);
|
|
129
|
+
const hydrated = useSyncExternalStore(subscribeNever, () => true, () => false);
|
|
130
|
+
const showTable = wide || !hydrated;
|
|
131
|
+
const showCards = !wide || !hydrated;
|
|
126
132
|
const external = sort !== void 0 || onSortChange !== void 0;
|
|
127
133
|
const current = sort !== void 0 ? sort : innerSort;
|
|
128
134
|
const sortKey = current?.key;
|
|
@@ -155,10 +161,12 @@ function ResponsiveTable({
|
|
|
155
161
|
else if (navigate) navigate(href);
|
|
156
162
|
else window.location.assign(href);
|
|
157
163
|
}, [latest]);
|
|
158
|
-
if (error)
|
|
164
|
+
if (error) {
|
|
165
|
+
return /* @__PURE__ */ jsx("div", { ...rest, ref, className, children: /* @__PURE__ */ jsx(ErrorState, { message: error.message, onRetry: error.onRetry }) });
|
|
166
|
+
}
|
|
159
167
|
const emptyNode = empty ?? /* @__PURE__ */ jsx(EmptyState, { title: t.nothingHere });
|
|
160
168
|
const hasRows = sorted.length > 0;
|
|
161
|
-
const table = !
|
|
169
|
+
const table = !showTable ? null : loading ? /* @__PURE__ */ jsx(SkeletonRows, { rows: 5, height: 44, label: t.loadingNamed(label) }) : !hasRows ? emptyNode : /* @__PURE__ */ jsx(TableWrap, { minWidth, stickyHeader, maxHeight, stickyFirstColumn, label, children: /* @__PURE__ */ jsxs(Table, { "aria-label": label, children: [
|
|
162
170
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((c) => /* @__PURE__ */ jsx(
|
|
163
171
|
Th,
|
|
164
172
|
{
|
|
@@ -203,7 +211,7 @@ function ResponsiveTable({
|
|
|
203
211
|
}
|
|
204
212
|
return /* @__PURE__ */ jsx("div", { className: cardClassFor(tone, false), children: cardBody(row) });
|
|
205
213
|
};
|
|
206
|
-
const cards =
|
|
214
|
+
const cards = !showCards ? null : loading ? /* @__PURE__ */ jsx(CardListSkeleton, { count: 3, lines: 2 }) : !hasRows ? emptyNode : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
207
215
|
sortable.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2", children: [
|
|
208
216
|
/* @__PURE__ */ jsx("label", { className: "shrink-0 text-xs text-th-hi3", htmlFor: sortId, children: t.sortBy }),
|
|
209
217
|
/* @__PURE__ */ jsxs(
|
|
@@ -234,7 +242,8 @@ function ResponsiveTable({
|
|
|
234
242
|
/* @__PURE__ */ jsx("ul", { "aria-label": label, className: "grid gap-2", children: sorted.map((row) => /* @__PURE__ */ jsx("li", { children: cardItem(row) }, rowKey(row))) })
|
|
235
243
|
] });
|
|
236
244
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className, children: [
|
|
237
|
-
|
|
245
|
+
showTable ? /* @__PURE__ */ jsx("div", { className: TABLE_SHOW[cardsBelow], children: table }) : null,
|
|
246
|
+
showCards ? /* @__PURE__ */ jsx("div", { className: CARDS_SHOW[cardsBelow], children: cards }) : null,
|
|
238
247
|
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement })
|
|
239
248
|
] });
|
|
240
249
|
}
|