nish-ui 3.1.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 +13 -6
- package/dist/base-tailwind.css +30 -15
- package/dist/base.css +30 -15
- package/dist/chart.js +2 -2
- package/dist/elements-all.js +78 -78
- package/dist/elements-charts.d.ts +1 -1
- package/dist/elements-charts.js +43 -42
- package/dist/elements-data.d.ts +10 -0
- package/dist/elements-data.js +4 -5
- package/dist/elements-forms.js +9 -9
- package/dist/elements.d.ts +1 -0
- 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 +83 -0
- package/dist/esm/components/accordion.js +5 -3
- package/dist/esm/components/app-shell.js +9 -5
- package/dist/esm/components/breadcrumbs.js +8 -4
- package/dist/esm/components/calendar-base.js +33 -6
- 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 +20 -9
- package/dist/esm/components/command.js +25 -63
- package/dist/esm/components/context-menu.js +2 -1
- package/dist/esm/components/data-classes.js +23 -8
- package/dist/esm/components/data.js +19 -10
- package/dist/esm/components/display.js +24 -15
- package/dist/esm/components/drawer.js +17 -4
- package/dist/esm/components/error-boundary.js +3 -3
- package/dist/esm/components/feedback.js +4 -4
- package/dist/esm/components/file-dropzone.js +39 -7
- package/dist/esm/components/filters.js +42 -1
- package/dist/esm/components/flow.js +12 -9
- package/dist/esm/components/forms-classes.js +3 -1
- package/dist/esm/components/forms.js +8 -6
- package/dist/esm/components/hooks.js +47 -13
- package/dist/esm/components/hover-card.js +2 -1
- package/dist/esm/components/inbox.js +9 -2
- package/dist/esm/components/latest.js +4 -2
- package/dist/esm/components/layout.js +7 -4
- package/dist/esm/components/menu.js +14 -1
- package/dist/esm/components/modal.js +17 -4
- package/dist/esm/components/multi-select.js +7 -7
- package/dist/esm/components/nav-classes.js +9 -0
- package/dist/esm/components/nav.js +32 -12
- 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-classes.js +4 -4
- package/dist/esm/components/primitives.js +18 -5
- package/dist/esm/components/progress.js +2 -1
- package/dist/esm/components/radio-group.js +1 -1
- package/dist/esm/components/resource-classes.js +7 -3
- package/dist/esm/components/resource.js +17 -6
- 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 +21 -1
- 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/tabs.js +3 -2
- 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-store.js +16 -4
- package/dist/esm/components/toast.js +4 -1
- package/dist/esm/components/tooltip.js +3 -2
- package/dist/esm/components/url-state.js +5 -2
- package/dist/esm/components/virtual-table.js +2 -2
- package/dist/esm/components/virtual.js +8 -4
- package/dist/esm/format.js +27 -4
- package/dist/esm/runtime.js +9 -2
- package/dist/esm/server/inbox/client.js +4 -0
- package/dist/esm/split-layout.js +2 -1
- 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 +36 -7
- package/dist/inbox-client.d.ts +6 -2
- package/dist/inbox-client.js +4 -1
- package/dist/index.d.ts +65 -30
- package/dist/nish-components.css +70 -23
- 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 +10 -3
- package/dist/server/hono.js +108 -11
- package/dist/server/index.d.ts +21 -13
- package/dist/server/index.js +124 -29
- package/dist/service-tokens.d.ts +4 -4
- package/dist/{spa-7myD4xvA.d.ts → spa-FwS7yZ8p.d.ts} +36 -7
- package/dist/split-layout.js +2 -2
- package/dist/system-canvas.d.ts +11 -10
- package/dist/theme.d.ts +30 -2
- package/dist/theme.global.js +53 -21
- package/dist/theme.js +53 -20
- package/package.json +3 -2
- package/dist/tokens.js +0 -425
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { cn } from "../cn.js";
|
|
6
6
|
import { SearchInput } from "./forms.js";
|
|
7
|
+
import { useIsClient } from "./client.js";
|
|
7
8
|
import { NARROW_QUERY, useMediaQuery } from "./hooks.js";
|
|
8
9
|
import { Drawer } from "./drawer.js";
|
|
9
10
|
import { Badge, Button } from "./primitives.js";
|
|
@@ -63,6 +64,7 @@ function FilterBar({
|
|
|
63
64
|
...rest
|
|
64
65
|
}) {
|
|
65
66
|
const strings = useStrings(FILTER_STRINGS, FIELD_STRINGS);
|
|
67
|
+
const isClient = useIsClient();
|
|
66
68
|
const compact = useMediaQuery(sheetBelow === "lg" ? LG_QUERY : NARROW_QUERY);
|
|
67
69
|
const [openState, setOpen] = useState(false);
|
|
68
70
|
const open = openState && compact;
|
|
@@ -78,6 +80,45 @@ function FilterBar({
|
|
|
78
80
|
className: compact ? "min-w-[10rem] flex-1 basis-40" : "w-full max-w-xs"
|
|
79
81
|
}
|
|
80
82
|
) : null;
|
|
83
|
+
const hasSummary = summary != null && summary !== false && summary !== "";
|
|
84
|
+
if (!isClient) {
|
|
85
|
+
const lg = sheetBelow === "lg";
|
|
86
|
+
const searchClass = lg ? "min-w-[10rem] flex-1 basis-40 lg:w-full lg:max-w-xs lg:flex-none lg:basis-auto" : "min-w-[10rem] flex-1 basis-40 md:w-full md:max-w-xs md:flex-none md:basis-auto";
|
|
87
|
+
const buttonClass = lg ? "min-h-11 shrink-0 lg:hidden" : "min-h-11 shrink-0 md:hidden";
|
|
88
|
+
const wrapClass = lg ? "contents max-lg:hidden" : "contents max-md:hidden";
|
|
89
|
+
return /* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
...rest,
|
|
93
|
+
ref,
|
|
94
|
+
className: cn(sticky && "sticky top-[var(--nish-header-h,0px)] z-[var(--nish-z-sticky,20)] border-b border-th-line bg-th-bg py-2", className),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
97
|
+
search ? /* @__PURE__ */ jsx(
|
|
98
|
+
SearchInput,
|
|
99
|
+
{
|
|
100
|
+
value: search.value,
|
|
101
|
+
onChange: (v) => search.onChange(v),
|
|
102
|
+
placeholder: search.placeholder,
|
|
103
|
+
"aria-label": search.label ?? search.placeholder ?? strings.search,
|
|
104
|
+
className: searchClass
|
|
105
|
+
}
|
|
106
|
+
) : null,
|
|
107
|
+
hasChildren ? /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "md", icon: /* @__PURE__ */ jsx(FunnelIcon, {}), "aria-haspopup": "dialog", "aria-expanded": false, className: buttonClass, children: [
|
|
108
|
+
strings.filters,
|
|
109
|
+
activeCount > 0 ? /* @__PURE__ */ jsx(Badge, { tone: "accent", "aria-label": strings.activeCount(activeCount), children: activeCount }) : null
|
|
110
|
+
] }) : null,
|
|
111
|
+
/* @__PURE__ */ jsxs("div", { className: wrapClass, children: [
|
|
112
|
+
children,
|
|
113
|
+
activeCount > 0 && onClear ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: onClear, children: strings.clearFilters }) : null
|
|
114
|
+
] }),
|
|
115
|
+
trailing ? /* @__PURE__ */ jsx("div", { className: "ms-auto flex items-center gap-2", children: trailing }) : null
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3", hasSummary ? "mt-2" : void 0), children: summary ?? null })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
81
122
|
return /* @__PURE__ */ jsxs(
|
|
82
123
|
"div",
|
|
83
124
|
{
|
|
@@ -99,7 +140,7 @@ function FilterBar({
|
|
|
99
140
|
trailing ? /* @__PURE__ */ jsx("div", { className: "ms-auto flex items-center gap-2", children: trailing }) : null
|
|
100
141
|
] })
|
|
101
142
|
] }),
|
|
102
|
-
/* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3",
|
|
143
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", className: cn("text-sm text-th-hi3", hasSummary ? "mt-2" : void 0), children: summary ?? null }),
|
|
103
144
|
compact && hasChildren ? /* @__PURE__ */ jsx(FilterSheet, { open, onClose: () => setOpen(false), title: sheetTitle ?? strings.filters, onClear, activeCount, children }) : null
|
|
104
145
|
]
|
|
105
146
|
}
|
|
@@ -120,14 +120,14 @@ 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
|
-
function pickStepFx(
|
|
123
|
+
function pickStepFx(_from, to) {
|
|
124
124
|
if (to === "done") return "done";
|
|
125
125
|
if (to === "failed") return "failed";
|
|
126
|
-
return
|
|
126
|
+
return null;
|
|
127
127
|
}
|
|
128
128
|
function withFullText(text, label) {
|
|
129
129
|
if (typeof text !== "string") return label;
|
|
130
|
-
return /* @__PURE__ */ jsx(Tooltip, { tip: text, className: "nish-flow-label-tip max-w-full min-w-0", children: label });
|
|
130
|
+
return /* @__PURE__ */ jsx(Tooltip, { tip: text, focusable: false, className: "nish-flow-label-tip max-w-full min-w-0", children: label });
|
|
131
131
|
}
|
|
132
132
|
function StepRow({
|
|
133
133
|
step,
|
|
@@ -298,7 +298,7 @@ function TickerText({ text, as = "span", className, ref, ...rest }) {
|
|
|
298
298
|
] });
|
|
299
299
|
}
|
|
300
300
|
var AGENT_STATE = {
|
|
301
|
-
queued: "border-dashed border-th-line
|
|
301
|
+
queued: "border-dashed border-th-line bg-th-bg",
|
|
302
302
|
running: "border-th-accent",
|
|
303
303
|
done: "border-th-ok-fill/40",
|
|
304
304
|
failed: "border-th-loss-fill"
|
|
@@ -349,7 +349,10 @@ function AgentNode({ label, state, model, activity, meta, onClick, stateLabels,
|
|
|
349
349
|
done: s.agentDone,
|
|
350
350
|
failed: s.agentFailed
|
|
351
351
|
};
|
|
352
|
-
const
|
|
352
|
+
const extras = [model, typeof meta === "string" || typeof meta === "number" ? String(meta) : null, activity].filter(
|
|
353
|
+
(x) => typeof x === "string" && x !== ""
|
|
354
|
+
);
|
|
355
|
+
const aria = [`${label}: ${stateLabels?.[state] ?? stateWord[state]}`, ...extras].join(", ");
|
|
353
356
|
const classes = cn(
|
|
354
357
|
"nish-flow-agent block min-h-16 w-full min-w-0 rounded-xl border bg-th-surface p-3 text-start",
|
|
355
358
|
AGENT_STATE[state],
|
|
@@ -455,9 +458,9 @@ function WorkflowBoard({ phases, agents, label, otherLabel, waitingLabel, classN
|
|
|
455
458
|
state === "active" ? "border-th-accent/50" : "border-th-line"
|
|
456
459
|
),
|
|
457
460
|
children: [
|
|
458
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
461
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
459
462
|
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 }),
|
|
463
|
+
/* @__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
464
|
phase.model ? /* @__PURE__ */ jsx(ModelBadge, { model: phase.model }) : null,
|
|
462
465
|
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs tabular-nums text-th-hi3", children: [
|
|
463
466
|
finished,
|
|
@@ -495,7 +498,7 @@ function WorkflowBoard({ phases, agents, label, otherLabel, waitingLabel, classN
|
|
|
495
498
|
next ? /* @__PURE__ */ jsx(PhaseConnector, { flowing }) : null
|
|
496
499
|
]
|
|
497
500
|
},
|
|
498
|
-
phase.id
|
|
501
|
+
`${phase.id}:${ci}`
|
|
499
502
|
);
|
|
500
503
|
}) }) });
|
|
501
504
|
}
|
|
@@ -510,7 +513,7 @@ var FEED_DOT_FORCED = "forced-colors:bg-[color:CanvasText]";
|
|
|
510
513
|
function ActivityFeed({ items, max = 50, now, label, empty, className, ref, ...rest }) {
|
|
511
514
|
const s = useStrings(PROGRESS_STRINGS, FLOW_STRINGS);
|
|
512
515
|
const { locale } = useNishContext();
|
|
513
|
-
const internalNow = useNow(15e3);
|
|
516
|
+
const internalNow = useNow(now != null ? 2147483647 : 15e3);
|
|
514
517
|
const clock = now ?? internalNow;
|
|
515
518
|
const shown = useMemo(() => [...items].sort((a, b) => b.at - a.at).slice(0, Math.max(0, max)), [items, max]);
|
|
516
519
|
const fresh = useFreshIds(
|
|
@@ -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
|
);
|
|
@@ -34,9 +34,11 @@ var SEGMENTED_SIZE = {
|
|
|
34
34
|
function indexComboboxOptions(options) {
|
|
35
35
|
return options.map((option) => ({ option, label: option.label.toLowerCase(), hint: option.hint?.toLowerCase() }));
|
|
36
36
|
}
|
|
37
|
+
var TAG_REMOVE_HIT = "pointer-coarse:min-h-0 pointer-coarse:min-w-0 pointer-coarse:relative pointer-coarse:after:absolute pointer-coarse:after:left-1/2 pointer-coarse:after:top-1/2 pointer-coarse:after:size-11 pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:rounded-full pointer-coarse:after:content-['']";
|
|
37
38
|
export {
|
|
38
39
|
SEGMENTED_SELECTED,
|
|
39
40
|
SEGMENTED_SIZE,
|
|
41
|
+
TAG_REMOVE_HIT,
|
|
40
42
|
chipClass,
|
|
41
43
|
indexComboboxOptions,
|
|
42
44
|
setRef
|
|
@@ -18,7 +18,7 @@ import { isRtl, useIsoLayoutEffect } from "./client.js";
|
|
|
18
18
|
import { useStrings } from "./provider.js";
|
|
19
19
|
import { FIELD_STRINGS } from "./strings.js";
|
|
20
20
|
import { warnDev } from "./display-classes.js";
|
|
21
|
-
import { chipClass, setRef } from "./forms-classes.js";
|
|
21
|
+
import { chipClass, setRef, TAG_REMOVE_HIT } from "./forms-classes.js";
|
|
22
22
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
23
|
function Svg({ size = 16, children, ...rest }) {
|
|
24
24
|
return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", ...rest, children });
|
|
@@ -359,9 +359,10 @@ function Field({
|
|
|
359
359
|
const childId = only && typeof only.props.id === "string" ? only.props.id : void 0;
|
|
360
360
|
const controlId = htmlFor ?? childId ?? `${auto}-control`;
|
|
361
361
|
const hasError = error != null && error !== false && error !== "";
|
|
362
|
+
const hasHint = hint != null && hint !== false && hint !== "";
|
|
362
363
|
const hintId = `${auto}-hint`;
|
|
363
364
|
const errorId = `${auto}-error`;
|
|
364
|
-
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;
|
|
365
366
|
const control = only ? cloneElement(only, {
|
|
366
367
|
id: htmlFor ?? childId ?? controlId,
|
|
367
368
|
"aria-describedby": describedBy,
|
|
@@ -387,7 +388,7 @@ function Field({
|
|
|
387
388
|
]
|
|
388
389
|
}
|
|
389
390
|
);
|
|
390
|
-
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;
|
|
391
392
|
if (inline) {
|
|
392
393
|
return /* @__PURE__ */ jsxs(
|
|
393
394
|
"div",
|
|
@@ -414,16 +415,17 @@ function FieldGroup({ ref, label, hint, error, optional = false, className, chil
|
|
|
414
415
|
const auto = useId();
|
|
415
416
|
const strings = useStrings(FIELD_STRINGS);
|
|
416
417
|
const hasError = error != null && error !== false && error !== "";
|
|
418
|
+
const hasHint = hint != null && hint !== false && hint !== "";
|
|
417
419
|
const hintId = `${auto}-hint`;
|
|
418
420
|
const errorId = `${auto}-error`;
|
|
419
|
-
const describedBy = [rest["aria-describedby"], hasError ? errorId :
|
|
421
|
+
const describedBy = [rest["aria-describedby"], hasError ? errorId : hasHint ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
420
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: [
|
|
421
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: [
|
|
422
424
|
/* @__PURE__ */ jsx("span", { children: label }),
|
|
423
425
|
optional ? /* @__PURE__ */ jsx("span", { className: "text-xs font-normal text-th-hi3", children: strings.optional }) : null
|
|
424
426
|
] }),
|
|
425
427
|
children,
|
|
426
|
-
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
|
|
427
429
|
] });
|
|
428
430
|
}
|
|
429
431
|
var SEARCH_SIZE = {
|
|
@@ -535,7 +537,7 @@ function Chip({ ref, variant = "toggle", pressed, onRemove, removeLabel, icon, t
|
|
|
535
537
|
icon,
|
|
536
538
|
children,
|
|
537
539
|
trailing,
|
|
538
|
-
onRemove ? /* @__PURE__ */ jsx(IconButton, { label: name, size: "xs", onClick: onRemove, className: "rounded-full", children: /* @__PURE__ */ jsx(XIcon, { size: 12 }) }) : null
|
|
540
|
+
onRemove ? /* @__PURE__ */ jsx(IconButton, { label: name, size: "xs", onClick: onRemove, className: cn("rounded-full", TAG_REMOVE_HIT), children: /* @__PURE__ */ jsx(XIcon, { size: 12 }) }) : null
|
|
539
541
|
]
|
|
540
542
|
}
|
|
541
543
|
);
|
|
@@ -87,18 +87,45 @@ function subscribeBreakpoint(onChange) {
|
|
|
87
87
|
function useBreakpoint() {
|
|
88
88
|
return useSyncExternalStore(subscribeBreakpoint, currentBreakpoint, () => "base");
|
|
89
89
|
}
|
|
90
|
+
var titles = () => shared("documentTitle", () => ({
|
|
91
|
+
entries: [],
|
|
92
|
+
base: null,
|
|
93
|
+
seq: 0
|
|
94
|
+
}));
|
|
95
|
+
function applyTitle() {
|
|
96
|
+
const { entries } = titles();
|
|
97
|
+
let winner = entries[entries.length - 1];
|
|
98
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
99
|
+
if (entries[i].titled) {
|
|
100
|
+
winner = entries[i];
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (winner) document.title = winner.next;
|
|
105
|
+
}
|
|
90
106
|
function useDocumentTitle(title, o = {}) {
|
|
91
107
|
const app = o.app;
|
|
108
|
+
const [id] = useState(() => ++titles().seq);
|
|
92
109
|
useEffect(() => {
|
|
93
110
|
if (typeof document === "undefined") return;
|
|
94
111
|
const next = title && app ? `${title} \xB7 ${app}` : title || app;
|
|
95
112
|
if (!next) return;
|
|
96
|
-
const
|
|
97
|
-
|
|
113
|
+
const t = titles();
|
|
114
|
+
if (t.entries.length === 0) t.base = document.title;
|
|
115
|
+
const entry = { id, next, titled: !!title };
|
|
116
|
+
const at = t.entries.findIndex((e) => e.id === id);
|
|
117
|
+
if (at >= 0) t.entries[at] = entry;
|
|
118
|
+
else t.entries.push(entry);
|
|
119
|
+
applyTitle();
|
|
98
120
|
return () => {
|
|
99
|
-
|
|
121
|
+
const cur = titles();
|
|
122
|
+
cur.entries = cur.entries.filter((e) => e.id !== id);
|
|
123
|
+
if (cur.entries.length === 0) {
|
|
124
|
+
if (cur.base !== null) document.title = cur.base;
|
|
125
|
+
cur.base = null;
|
|
126
|
+
} else applyTitle();
|
|
100
127
|
};
|
|
101
|
-
}, [title, app]);
|
|
128
|
+
}, [title, app, id]);
|
|
102
129
|
}
|
|
103
130
|
function useNow(intervalMs = 3e4) {
|
|
104
131
|
const [now, setNow] = useState(() => Date.now());
|
|
@@ -130,7 +157,8 @@ function useNow(intervalMs = 3e4) {
|
|
|
130
157
|
var local = () => shared("localStorage", () => ({
|
|
131
158
|
subs: /* @__PURE__ */ new Map(),
|
|
132
159
|
memory: /* @__PURE__ */ new Map(),
|
|
133
|
-
listening: false
|
|
160
|
+
listening: false,
|
|
161
|
+
handler: void 0
|
|
134
162
|
}));
|
|
135
163
|
var warned = /* @__PURE__ */ new Set();
|
|
136
164
|
function notify(key) {
|
|
@@ -149,16 +177,20 @@ function subscribeKey(key, cb) {
|
|
|
149
177
|
if (!set) local().subs.set(key, set = /* @__PURE__ */ new Set());
|
|
150
178
|
const subs = set;
|
|
151
179
|
subs.add(cb);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
180
|
+
const rec = local();
|
|
181
|
+
if (!rec.handler) {
|
|
182
|
+
rec.handler = onStorageEvent;
|
|
183
|
+
rec.listening = true;
|
|
184
|
+
window.addEventListener("storage", rec.handler);
|
|
155
185
|
}
|
|
156
186
|
return () => {
|
|
157
187
|
subs.delete(cb);
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
window.removeEventListener("storage",
|
|
188
|
+
const r = local();
|
|
189
|
+
if (subs.size === 0 && r.subs.get(key) === subs) r.subs.delete(key);
|
|
190
|
+
if (r.subs.size === 0 && r.handler) {
|
|
191
|
+
window.removeEventListener("storage", r.handler);
|
|
192
|
+
r.handler = void 0;
|
|
193
|
+
r.listening = false;
|
|
162
194
|
}
|
|
163
195
|
};
|
|
164
196
|
}
|
|
@@ -187,7 +219,9 @@ function parseStored(key, text, initial, raw) {
|
|
|
187
219
|
}
|
|
188
220
|
function useLocalStorage(key, initial, o = {}) {
|
|
189
221
|
const raw = !!o.raw;
|
|
190
|
-
const [
|
|
222
|
+
const [held, setHeld] = useState(() => ({ key, initial }));
|
|
223
|
+
if (held.key !== key) setHeld({ key, initial });
|
|
224
|
+
const first = held.key === key ? held.initial : initial;
|
|
191
225
|
const subscribe = useCallback((onChange) => subscribeKey(key, onChange), [key]);
|
|
192
226
|
const get = useCallback(() => readText(key), [key]);
|
|
193
227
|
const text = useSyncExternalStore(subscribe, get, () => null);
|
|
@@ -191,7 +191,8 @@ function HoverCard({
|
|
|
191
191
|
onPointerEnter?.(e);
|
|
192
192
|
},
|
|
193
193
|
onPointerLeave: (e) => {
|
|
194
|
-
|
|
194
|
+
const active = document.activeElement;
|
|
195
|
+
if (!(active && wrapperRef.current?.contains(active) && keyboardFocused(active))) hide();
|
|
195
196
|
onPointerLeave?.(e);
|
|
196
197
|
},
|
|
197
198
|
style: {
|
|
@@ -147,7 +147,10 @@ function Inbox({
|
|
|
147
147
|
...rest
|
|
148
148
|
}) {
|
|
149
149
|
const strings = useInboxStrings();
|
|
150
|
-
const labels = {
|
|
150
|
+
const labels = {
|
|
151
|
+
...DEFAULT_INBOX_LABELS,
|
|
152
|
+
...Object.fromEntries(Object.entries(labelOverrides ?? {}).filter(([, v]) => v !== void 0))
|
|
153
|
+
};
|
|
151
154
|
const idBase = useId().replace(/:/g, "");
|
|
152
155
|
const wide = useMediaQuery("(min-width: 480px)");
|
|
153
156
|
const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
|
|
@@ -157,7 +160,11 @@ function Inbox({
|
|
|
157
160
|
const labelOf = (id) => sourceLabels[id] ?? id;
|
|
158
161
|
const rowId = (id) => `${idBase}-item-${id}`;
|
|
159
162
|
useEffect(() => {
|
|
160
|
-
if (selectedId == null
|
|
163
|
+
if (selectedId == null) {
|
|
164
|
+
scrolled.current = null;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (scrolled.current === selectedId) return;
|
|
161
168
|
const el = document.getElementById(rowId(selectedId));
|
|
162
169
|
if (!el) return;
|
|
163
170
|
scrolled.current = selectedId;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// src/components/latest.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
import { useIsoLayoutEffect } from "./client.js";
|
|
4
6
|
function useLatest(value) {
|
|
5
7
|
const ref = useRef(value);
|
|
6
8
|
useIsoLayoutEffect(() => {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
useCallback,
|
|
6
6
|
useEffect,
|
|
7
|
+
useMemo,
|
|
7
8
|
useRef,
|
|
8
9
|
useState,
|
|
9
10
|
useSyncExternalStore
|
|
@@ -29,12 +30,13 @@ function StickyBar({
|
|
|
29
30
|
const ref = useRef(null);
|
|
30
31
|
const stuck = useStuck(ref);
|
|
31
32
|
useHeightVar(ref, "--nish-sticky-extra");
|
|
33
|
+
const mergedRef = useMemo(() => mergeRefs(ref, refProp), [refProp]);
|
|
32
34
|
const Tag = as;
|
|
33
35
|
return /* @__PURE__ */ jsx(
|
|
34
36
|
Tag,
|
|
35
37
|
{
|
|
36
38
|
...rest,
|
|
37
|
-
ref:
|
|
39
|
+
ref: mergedRef,
|
|
38
40
|
"data-nish-bar": "",
|
|
39
41
|
style: { top, ...style },
|
|
40
42
|
className: cn(
|
|
@@ -58,13 +60,14 @@ function StickyActionBar({
|
|
|
58
60
|
}) {
|
|
59
61
|
const strings = useStrings(STATUS_STRINGS);
|
|
60
62
|
const ref = useRef(null);
|
|
63
|
+
const mergedRef = useMemo(() => mergeRefs(ref, refProp), [refProp]);
|
|
61
64
|
useHeightVar(ref, "--nish-bottom-bar-h", open);
|
|
62
65
|
if (!open) return null;
|
|
63
66
|
return /* @__PURE__ */ jsxs(
|
|
64
67
|
"div",
|
|
65
68
|
{
|
|
66
69
|
...rest,
|
|
67
|
-
ref:
|
|
70
|
+
ref: mergedRef,
|
|
68
71
|
role: "region",
|
|
69
72
|
"aria-label": label ?? strings.actions,
|
|
70
73
|
"data-state": "open",
|
|
@@ -180,7 +183,7 @@ function useOnline() {
|
|
|
180
183
|
function ConnectionBanner({
|
|
181
184
|
healthUrl,
|
|
182
185
|
intervalMs = 3e4,
|
|
183
|
-
message
|
|
186
|
+
message,
|
|
184
187
|
offlineMessage,
|
|
185
188
|
retryLabel,
|
|
186
189
|
onRetry,
|
|
@@ -266,7 +269,7 @@ function ConnectionBanner({
|
|
|
266
269
|
compact: true,
|
|
267
270
|
...rest,
|
|
268
271
|
action: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", loading: retrying, onClick: () => void retry(), children: retryLabel ?? strings.retry }),
|
|
269
|
-
children: online ? message : offlineMessage ?? strings.offline
|
|
272
|
+
children: online ? message ?? strings.serverUnreachable : offlineMessage ?? strings.offline
|
|
270
273
|
}
|
|
271
274
|
);
|
|
272
275
|
}
|
|
@@ -80,6 +80,15 @@ function DropdownMenu({
|
|
|
80
80
|
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
81
81
|
const dismiss = useCallback((reason) => setOpen(false, reason), [setOpen]);
|
|
82
82
|
useDismiss(shown && !asSheet, menuRef, triggerRef, dismiss);
|
|
83
|
+
const sheetEscape = useRef(false);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!(shown && asSheet)) return;
|
|
86
|
+
const key = (e) => {
|
|
87
|
+
sheetEscape.current = e.key === "Escape";
|
|
88
|
+
};
|
|
89
|
+
document.addEventListener("keydown", key, true);
|
|
90
|
+
return () => document.removeEventListener("keydown", key, true);
|
|
91
|
+
}, [shown, asSheet]);
|
|
83
92
|
useReturnFocus(shown, menuRef, triggerRef);
|
|
84
93
|
useEffect(() => {
|
|
85
94
|
if (!shown) return;
|
|
@@ -180,7 +189,7 @@ function DropdownMenu({
|
|
|
180
189
|
};
|
|
181
190
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
182
191
|
triggerEl,
|
|
183
|
-
open && asSheet ? /* @__PURE__ */ jsx(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx(drawer.Drawer, { side: "bottom", size: "md", title: sheetTitle ?? strings.menu, onClose:
|
|
192
|
+
open && asSheet ? /* @__PURE__ */ jsx(MenuContext.Provider, { value: { close }, children: /* @__PURE__ */ jsx(drawer.Drawer, { side: "bottom", size: "md", title: sheetTitle ?? strings.menu, onClose: () => dismiss(sheetEscape.current ? "escape" : "outside"), children: /* @__PURE__ */ jsx(
|
|
184
193
|
"div",
|
|
185
194
|
{
|
|
186
195
|
...menuProps,
|
|
@@ -248,6 +257,10 @@ function MenuItem({
|
|
|
248
257
|
"aria-current": active || void 0,
|
|
249
258
|
"data-disabled": disabled ? "" : void 0,
|
|
250
259
|
onClick: (e) => {
|
|
260
|
+
if (disabled) {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
251
264
|
onClick?.(e);
|
|
252
265
|
if (!e.defaultPrevented) select();
|
|
253
266
|
},
|
|
@@ -10,7 +10,7 @@ import { Portal } from "./portal.js";
|
|
|
10
10
|
import { useStrings } from "./provider.js";
|
|
11
11
|
import { OVERLAY_STRINGS } from "./strings.js";
|
|
12
12
|
import { CLOSE_BUTTON, MODAL_SIZE, SHEET_HEIGHT_CLASS } from "./overlay-classes.js";
|
|
13
|
-
import { isPhoneViewport, closeVetoes, warnDev, useMergedRef, useScrollable } from "./overlay-core.js";
|
|
13
|
+
import { isPhoneViewport, closeVetoes, warnDev, useMergedRef, useScrollable, ov, isTop } from "./overlay-core.js";
|
|
14
14
|
import { useDialog, useSheetExit, useSheetSwipe, SheetHandle } from "./overlay-dialog.js";
|
|
15
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
function Modal({ open, ...props }) {
|
|
@@ -51,6 +51,18 @@ function ModalPanel({
|
|
|
51
51
|
const named = showTitle || !!ariaLabel || !!ariaLabelledBy;
|
|
52
52
|
const scrollable = useScrollable(bodyRef);
|
|
53
53
|
const bodyLabel = typeof title === "string" ? title : ariaLabel;
|
|
54
|
+
const bodyLabelledBy = bodyLabel ? void 0 : showTitle ? titleId : ariaLabelledBy;
|
|
55
|
+
const bodyNamed = !!bodyLabel || !!bodyLabelledBy;
|
|
56
|
+
const covered = useRef(false);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const stack = ov().layerStack;
|
|
59
|
+
const self = stack[stack.length - 1];
|
|
60
|
+
const down = () => {
|
|
61
|
+
covered.current = !!self && !isTop(self);
|
|
62
|
+
};
|
|
63
|
+
document.addEventListener("pointerdown", down, true);
|
|
64
|
+
return () => document.removeEventListener("pointerdown", down, true);
|
|
65
|
+
}, []);
|
|
54
66
|
useEffect(() => {
|
|
55
67
|
if (!named) warnDev("nish-ui: <Modal> has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`.");
|
|
56
68
|
}, [named]);
|
|
@@ -66,7 +78,7 @@ function ModalPanel({
|
|
|
66
78
|
placement === "top" ? "sm:items-start sm:pt-[12vh]" : "sm:items-center"
|
|
67
79
|
),
|
|
68
80
|
onMouseDown: (e) => {
|
|
69
|
-
if (e.target === e.currentTarget) requestClose();
|
|
81
|
+
if (e.target === e.currentTarget && !covered.current) requestClose();
|
|
70
82
|
},
|
|
71
83
|
children: /* @__PURE__ */ jsxs(
|
|
72
84
|
"div",
|
|
@@ -107,9 +119,10 @@ function ModalPanel({
|
|
|
107
119
|
"div",
|
|
108
120
|
{
|
|
109
121
|
ref: bodyRef,
|
|
110
|
-
tabIndex: scrollable ? 0 : void 0,
|
|
111
|
-
role: scrollable &&
|
|
122
|
+
tabIndex: scrollable && bodyNamed ? 0 : void 0,
|
|
123
|
+
role: scrollable && bodyNamed ? "region" : void 0,
|
|
112
124
|
"aria-label": scrollable ? bodyLabel : void 0,
|
|
125
|
+
"aria-labelledby": scrollable ? bodyLabelledBy : void 0,
|
|
113
126
|
className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pb-5 text-sm text-th-hi2", header !== void 0 && "pt-3"),
|
|
114
127
|
children
|
|
115
128
|
}
|
|
@@ -6,13 +6,13 @@ import { cn } from "../cn.js";
|
|
|
6
6
|
import { CheckIcon, XIcon } from "./icons.js";
|
|
7
7
|
import { Spinner } from "./feedback.js";
|
|
8
8
|
import { Chip } from "./forms.js";
|
|
9
|
+
import { warnDev } from "./display-classes.js";
|
|
9
10
|
import { fieldClass } from "./primitives.js";
|
|
10
11
|
import { useStrings } from "./provider.js";
|
|
11
12
|
import { FIELD_STRINGS, MULTI_SELECT_STRINGS } from "./strings.js";
|
|
12
13
|
import { indexComboboxOptions, setRef } from "./forms-classes.js";
|
|
13
|
-
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
|
|
14
|
+
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from "../combobox-filter.js";
|
|
14
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var defaultResultsText = (n) => `${n} ${n === 1 ? "result" : "results"}`;
|
|
16
16
|
function MultiSelect({
|
|
17
17
|
ref,
|
|
18
18
|
options,
|
|
@@ -37,7 +37,7 @@ function MultiSelect({
|
|
|
37
37
|
onQueryChange,
|
|
38
38
|
loading = false,
|
|
39
39
|
loadingText,
|
|
40
|
-
resultsText
|
|
40
|
+
resultsText,
|
|
41
41
|
size = "md",
|
|
42
42
|
clearLabel,
|
|
43
43
|
className,
|
|
@@ -86,7 +86,7 @@ function MultiSelect({
|
|
|
86
86
|
if (needle && !serverFiltered) {
|
|
87
87
|
if (filter) {
|
|
88
88
|
if (!filter(it.option, text)) continue;
|
|
89
|
-
} else if (!it.label
|
|
89
|
+
} else if (!matchesComboboxNeedle(it.label, it.hint, needle)) continue;
|
|
90
90
|
}
|
|
91
91
|
out.push(it.option);
|
|
92
92
|
}
|
|
@@ -96,8 +96,8 @@ function MultiSelect({
|
|
|
96
96
|
const atLimit = maxSelected != null && values.length >= maxSelected;
|
|
97
97
|
useEffect(() => () => window.clearTimeout(debounceRef.current), []);
|
|
98
98
|
useEffect(() => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
99
|
+
if (!ariaLabel && !ariaLabelledBy && id == null) {
|
|
100
|
+
warnDev("MultiSelect needs a name: pass aria-label, aria-labelledby, or an id with a <label htmlFor>.");
|
|
101
101
|
}
|
|
102
102
|
}, [ariaLabel, ariaLabelledBy, id]);
|
|
103
103
|
useEffect(() => {
|
|
@@ -256,7 +256,7 @@ function MultiSelect({
|
|
|
256
256
|
}
|
|
257
257
|
const activeId = open && current >= 0 && visible[current] ? `${listId}-opt-${current}` : void 0;
|
|
258
258
|
const isInvalid = invalid || ariaInvalid === true || ariaInvalid === "true";
|
|
259
|
-
const status = announcement || (open ? loading ? searching : visible.length === 0 ? empty : resultsText(visible.length) : "");
|
|
259
|
+
const status = announcement || (open ? loading ? searching : visible.length === 0 ? empty : (resultsText ?? strings.resultsCount)(visible.length) : "");
|
|
260
260
|
return /* @__PURE__ */ jsxs(
|
|
261
261
|
"div",
|
|
262
262
|
{
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/components/nav-classes.ts
|
|
2
|
+
import { cn } from "../cn.js";
|
|
3
|
+
import { FOCUS } from "./nav-items.js";
|
|
4
|
+
function navRailItemClass(active) {
|
|
5
|
+
return cn("group flex min-h-14 w-full flex-col items-center justify-center gap-0.5 text-2xs leading-tight", FOCUS, active ? "font-medium text-th-accent" : "text-th-hi3 hover:text-th-hi");
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
navRailItemClass
|
|
9
|
+
};
|