nish-ui 3.1.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 +6 -3
- package/dist/chart.js +2 -2
- package/dist/elements-all.js +28 -28
- package/dist/elements-charts.d.ts +1 -1
- package/dist/elements-charts.js +22 -22
- package/dist/elements-data.js +2 -2
- package/dist/elements-forms.js +8 -8
- package/dist/elements.js +3 -3
- 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/breadcrumbs.js +1 -1
- package/dist/esm/components/calendar-base.js +1 -1
- package/dist/esm/components/combobox.js +2 -2
- package/dist/esm/components/command.js +5 -5
- package/dist/esm/components/data-classes.js +18 -4
- package/dist/esm/components/display.js +4 -4
- package/dist/esm/components/feedback.js +1 -1
- package/dist/esm/components/file-dropzone.js +23 -1
- package/dist/esm/components/flow.js +4 -4
- package/dist/esm/components/forms-classes.js +1 -1
- package/dist/esm/components/forms.js +6 -4
- package/dist/esm/components/inbox.js +4 -1
- package/dist/esm/components/menu.js +4 -0
- package/dist/esm/components/multi-select.js +2 -2
- package/dist/esm/components/nav-classes.js +9 -0
- package/dist/esm/components/nav.js +2 -1
- package/dist/esm/components/primitives-classes.js +4 -4
- package/dist/esm/components/primitives.js +1 -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 +3 -2
- package/dist/esm/components/settings.js +5 -1
- package/dist/esm/components/tabs.js +3 -2
- package/dist/esm/components/toast-store.js +16 -4
- package/dist/esm/components/url-state.js +2 -1
- package/dist/esm/format.js +24 -2
- package/dist/esm/runtime.js +9 -2
- package/dist/esm/split-layout.js +2 -1
- package/dist/format.js +33 -5
- package/dist/inbox-client.d.ts +5 -1
- package/dist/inbox-client.js +0 -1
- package/dist/index.d.ts +7 -4
- package/dist/nish-components.css +11 -2
- package/dist/nish-components.min.css +1 -1
- package/dist/server/hono.d.ts +1 -1
- package/dist/server/hono.js +91 -7
- package/dist/server/index.d.ts +20 -12
- package/dist/server/index.js +117 -27
- package/dist/{spa-7myD4xvA.d.ts → spa-BfRDo38r.d.ts} +32 -4
- package/dist/split-layout.js +2 -2
- package/dist/theme.global.js +9 -4
- package/dist/theme.js +9 -3
- package/package.json +1 -1
|
@@ -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"
|
|
@@ -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
|
}
|
|
@@ -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
|
);
|
|
@@ -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 = {
|
|
@@ -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());
|
|
@@ -248,6 +248,10 @@ function MenuItem({
|
|
|
248
248
|
"aria-current": active || void 0,
|
|
249
249
|
"data-disabled": disabled ? "" : void 0,
|
|
250
250
|
onClick: (e) => {
|
|
251
|
+
if (disabled) {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
251
255
|
onClick?.(e);
|
|
252
256
|
if (!e.defaultPrevented) select();
|
|
253
257
|
},
|
|
@@ -10,7 +10,7 @@ import { fieldClass } from "./primitives.js";
|
|
|
10
10
|
import { useStrings } from "./provider.js";
|
|
11
11
|
import { FIELD_STRINGS, MULTI_SELECT_STRINGS } from "./strings.js";
|
|
12
12
|
import { indexComboboxOptions, setRef } from "./forms-classes.js";
|
|
13
|
-
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN } from "../combobox-filter.js";
|
|
13
|
+
import { COMBOBOX_DEBOUNCE_MS, COMBOBOX_MAX_SHOWN, matchesComboboxNeedle } from "../combobox-filter.js";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
var defaultResultsText = (n) => `${n} ${n === 1 ? "result" : "results"}`;
|
|
16
16
|
function MultiSelect({
|
|
@@ -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
|
}
|
|
@@ -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
|
+
};
|
|
@@ -14,6 +14,7 @@ import { chipClass } from "./forms.js";
|
|
|
14
14
|
import { useMediaQuery } from "./hooks.js";
|
|
15
15
|
import { PanelLeftCloseIcon, PanelLeftOpenIcon } from "./icons.js";
|
|
16
16
|
import { useHeightVar, useScrollEdges } from "./layout-vars.js";
|
|
17
|
+
import { navRailItemClass } from "./nav-classes.js";
|
|
17
18
|
import { NavBadge, FOCUS, renderItem, useEndSide, visibleNavItems } from "./nav-items.js";
|
|
18
19
|
import { IconButton } from "./primitives.js";
|
|
19
20
|
import { useStrings } from "./provider.js";
|
|
@@ -136,7 +137,7 @@ function NavRail({
|
|
|
136
137
|
shown.map((item) => {
|
|
137
138
|
const node = renderItem(
|
|
138
139
|
item,
|
|
139
|
-
|
|
140
|
+
navRailItemClass(!!item.active),
|
|
140
141
|
/* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
141
142
|
/* @__PURE__ */ jsxs(
|
|
142
143
|
"span",
|
|
@@ -10,9 +10,9 @@ var BUTTON_VARIANT = {
|
|
|
10
10
|
link: "h-auto p-0 font-medium text-th-accent underline-offset-2 hover:underline"
|
|
11
11
|
};
|
|
12
12
|
var BUTTON_SIZE = {
|
|
13
|
-
xs: "h-6 gap-1 px-2 text-2xs pointer-coarse:min-h-11",
|
|
14
|
-
sm: "h-7 gap-1.5 px-2.5 text-xs pointer-coarse:min-h-11",
|
|
15
|
-
md: "h-9 gap-2 px-3.5 text-sm pointer-coarse:min-h-11",
|
|
13
|
+
xs: "h-6 gap-1 px-2 text-2xs pointer-coarse:min-h-11 pointer-coarse:min-w-11",
|
|
14
|
+
sm: "h-7 gap-1.5 px-2.5 text-xs pointer-coarse:min-h-11 pointer-coarse:min-w-11",
|
|
15
|
+
md: "h-9 gap-2 px-3.5 text-sm pointer-coarse:min-h-11 pointer-coarse:min-w-11",
|
|
16
16
|
lg: "h-11 gap-2 px-5 text-base"
|
|
17
17
|
};
|
|
18
18
|
var LINK_SIZE = {
|
|
@@ -24,7 +24,7 @@ var LINK_SIZE = {
|
|
|
24
24
|
var BUTTON_BASE = "inline-flex shrink-0 select-none items-center justify-center whitespace-nowrap rounded-lg font-medium transition-[color,background-color,border-color,transform] duration-150";
|
|
25
25
|
var BUTTON_FORCED = "forced-colors:border forced-colors:border-[ButtonText]";
|
|
26
26
|
var PRESS = "pointer-coarse:not-disabled:active:scale-[0.97]";
|
|
27
|
-
var LINK_HIT = "pointer-coarse:relative pointer-coarse:after:absolute pointer-coarse:after:-inset-x-2 pointer-coarse:after:-inset-y-3 pointer-coarse:after:content-['']";
|
|
27
|
+
var LINK_HIT = "pointer-coarse:relative pointer-coarse:after:absolute pointer-coarse:after:-inset-x-2 pointer-coarse:after:-inset-y-3.5 pointer-coarse:after:content-['']";
|
|
28
28
|
var BUTTON_DISABLED = "disabled:pointer-events-none disabled:border disabled:border-th-line disabled:bg-th-elevated disabled:text-th-ghost disabled:shadow-none forced-colors:disabled:border-[GrayText] forced-colors:disabled:text-[GrayText]";
|
|
29
29
|
var LINK_DISABLED = "disabled:pointer-events-none disabled:text-th-ghost disabled:no-underline forced-colors:disabled:text-[GrayText]";
|
|
30
30
|
function buttonClass({ variant = "secondary", size = "md", inline = false, className } = {}) {
|
|
@@ -104,7 +104,7 @@ function IconButton({
|
|
|
104
104
|
disabled,
|
|
105
105
|
"aria-label": label,
|
|
106
106
|
title: label,
|
|
107
|
-
"aria-pressed":
|
|
107
|
+
"aria-pressed": active === void 0 ? void 0 : pressed,
|
|
108
108
|
"data-state": active === void 0 ? void 0 : pressed ? "active" : "inactive",
|
|
109
109
|
"data-disabled": disabled ? "" : void 0,
|
|
110
110
|
className: iconButtonClass({ size, variant, tone, active: pressed, className }),
|
|
@@ -148,7 +148,7 @@ function Radio({ value, label, description, className, disabled, required, name,
|
|
|
148
148
|
name: name ?? ctx?.name,
|
|
149
149
|
disabled: off,
|
|
150
150
|
required: required ?? ctx?.required,
|
|
151
|
-
"aria-describedby": description != null ? descId : rest["aria-describedby"],
|
|
151
|
+
"aria-describedby": [description != null ? descId : null, rest["aria-describedby"]].filter(Boolean).join(" ") || void 0,
|
|
152
152
|
onChange: (e) => {
|
|
153
153
|
onChange?.(e);
|
|
154
154
|
if (e.target.checked) ctx?.select(value);
|
|
@@ -23,7 +23,7 @@ function configureApi(c) {
|
|
|
23
23
|
store.config = { ...store.config, ...c };
|
|
24
24
|
}
|
|
25
25
|
function isRawBody(b) {
|
|
26
|
-
return typeof b === "string" || typeof FormData !== "undefined" && b instanceof FormData || typeof Blob !== "undefined" && b instanceof Blob || typeof URLSearchParams !== "undefined" && b instanceof URLSearchParams || b instanceof ArrayBuffer || ArrayBuffer.isView(b);
|
|
26
|
+
return typeof b === "string" || typeof FormData !== "undefined" && b instanceof FormData || typeof Blob !== "undefined" && b instanceof Blob || typeof URLSearchParams !== "undefined" && b instanceof URLSearchParams || typeof ReadableStream !== "undefined" && b instanceof ReadableStream || b instanceof ArrayBuffer || ArrayBuffer.isView(b);
|
|
27
27
|
}
|
|
28
28
|
var ERROR_CODE = /^[a-z0-9_]+$/;
|
|
29
29
|
function errorMessage(body, status) {
|
|
@@ -84,8 +84,12 @@ async function apiFetch(path, o = {}) {
|
|
|
84
84
|
if (extraHeaders) new Headers(extraHeaders).forEach((v, k) => headers.set(k, v));
|
|
85
85
|
let payload;
|
|
86
86
|
if (body !== void 0) {
|
|
87
|
-
if (isRawBody(body))
|
|
88
|
-
|
|
87
|
+
if (isRawBody(body)) {
|
|
88
|
+
payload = body;
|
|
89
|
+
if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream && !("duplex" in init)) {
|
|
90
|
+
init.duplex = "half";
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
89
93
|
payload = JSON.stringify(body);
|
|
90
94
|
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
91
95
|
}
|
|
@@ -70,6 +70,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
70
70
|
}));
|
|
71
71
|
const fetcherRef = useLatest(fetcher);
|
|
72
72
|
const keyRef = useLatest(key);
|
|
73
|
+
const activeRef = useLatest(active);
|
|
73
74
|
const keepPrevRef = useLatest(keepPrevious);
|
|
74
75
|
const initialRef = useLatest(o.initialData);
|
|
75
76
|
const ctlRef = useRef(null);
|
|
@@ -81,7 +82,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
81
82
|
const load = useCallback(
|
|
82
83
|
async (fresh = false) => {
|
|
83
84
|
const k = keyRef.current;
|
|
84
|
-
if (k === null) return;
|
|
85
|
+
if (k === null || !activeRef.current) return;
|
|
85
86
|
ctlRef.current?.abort();
|
|
86
87
|
const ctl = new AbortController();
|
|
87
88
|
ctlRef.current = ctl;
|
|
@@ -116,7 +117,7 @@ function useResource(key, fetcher, o = {}) {
|
|
|
116
117
|
setState((s) => ({ ...s, key: k, error: error2, fetching: false, settled: s.settled + 1 }));
|
|
117
118
|
}
|
|
118
119
|
},
|
|
119
|
-
[fetcherRef, initialRef, keepPrevRef, keyRef]
|
|
120
|
+
[activeRef, fetcherRef, initialRef, keepPrevRef, keyRef]
|
|
120
121
|
);
|
|
121
122
|
useEffect(() => {
|
|
122
123
|
if (!active) return;
|
|
@@ -124,7 +124,11 @@ function useSaveStatus() {
|
|
|
124
124
|
const tone = status === "saved" ? "ok" : status === "error" ? "error" : "muted";
|
|
125
125
|
return { status, error, label, tone, run };
|
|
126
126
|
}
|
|
127
|
-
var parseDraft = (text) =>
|
|
127
|
+
var parseDraft = (text) => {
|
|
128
|
+
const t = text.trim().replace(/,/g, "").replace(/\u2212/g, "-");
|
|
129
|
+
const n = /^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(t) ? Number(t) : NaN;
|
|
130
|
+
return Number.isFinite(n) ? n : NaN;
|
|
131
|
+
};
|
|
128
132
|
var fmt = (v) => v == null ? "" : String(v);
|
|
129
133
|
var decimals = (n) => String(n).split(".")[1]?.length ?? 0;
|
|
130
134
|
function NumberField({
|
|
@@ -53,8 +53,9 @@ function ScrollingList({
|
|
|
53
53
|
return /* @__PURE__ */ jsx("div", { ref: setRef, ...rest, children });
|
|
54
54
|
}
|
|
55
55
|
var Ctx = /* @__PURE__ */ createContext(null);
|
|
56
|
-
var
|
|
57
|
-
var
|
|
56
|
+
var idPart = (v) => v.replace(/[^A-Za-z0-9_-]/g, (c) => "_" + c.charCodeAt(0).toString(16));
|
|
57
|
+
var tabId = (base, v) => `${base}-tab-${idPart(v)}`;
|
|
58
|
+
var panelId = (base, v) => `${base}-panel-${idPart(v)}`;
|
|
58
59
|
function Tabs({
|
|
59
60
|
value: valueProp,
|
|
60
61
|
defaultValue,
|
|
@@ -61,8 +61,8 @@ function push(tone, title, bodyOrOptions) {
|
|
|
61
61
|
const o = typeof bodyOrOptions === "string" ? { body: bodyOrOptions } : bodyOrOptions ?? {};
|
|
62
62
|
const s = store();
|
|
63
63
|
const id = s.nextId++;
|
|
64
|
-
const asked = o.duration
|
|
65
|
-
const duration = asked
|
|
64
|
+
const asked = o.duration;
|
|
65
|
+
const duration = asked === "sticky" ? "sticky" : typeof asked === "number" && asked > 0 ? asked >= 2 ** 31 - 1 ? "sticky" : asked : tone === "error" ? "sticky" : AUTO_DISMISS_MS;
|
|
66
66
|
const item = {
|
|
67
67
|
id,
|
|
68
68
|
tone,
|
|
@@ -103,10 +103,22 @@ var toast = /* @__PURE__ */ Object.assign((title, o) => push("info", title, o),
|
|
|
103
103
|
push("info", messages.loading, { duration: "sticky", id: slot });
|
|
104
104
|
promise.then(
|
|
105
105
|
(value) => {
|
|
106
|
-
|
|
106
|
+
let m;
|
|
107
|
+
try {
|
|
108
|
+
m = typeof messages.success === "function" ? messages.success(value) : messages.success;
|
|
109
|
+
} catch (e) {
|
|
110
|
+
return void push("error", String(e), { id: slot });
|
|
111
|
+
}
|
|
112
|
+
push("success", m, { id: slot });
|
|
107
113
|
},
|
|
108
114
|
(error) => {
|
|
109
|
-
|
|
115
|
+
let m;
|
|
116
|
+
try {
|
|
117
|
+
m = typeof messages.error === "function" ? messages.error(error) : messages.error;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
m = String(e);
|
|
120
|
+
}
|
|
121
|
+
push("error", m, { id: slot });
|
|
110
122
|
}
|
|
111
123
|
);
|
|
112
124
|
return promise;
|
|
@@ -69,8 +69,9 @@ function useUrlState(defaults, o = {}) {
|
|
|
69
69
|
const comma = useMemo(() => JSON.parse(commaKey), [commaKey]);
|
|
70
70
|
const defaultsKey = JSON.stringify(defaults);
|
|
71
71
|
const stableDefaults = useMemo(() => JSON.parse(defaultsKey), [defaultsKey]);
|
|
72
|
+
const subscribe = useCallback((cb) => adapter.subscribe(cb), [adapter]);
|
|
72
73
|
const search = useSyncExternalStore(
|
|
73
|
-
|
|
74
|
+
subscribe,
|
|
74
75
|
() => adapter.get().toString(),
|
|
75
76
|
() => ""
|
|
76
77
|
);
|
package/dist/esm/format.js
CHANGED
|
@@ -47,7 +47,24 @@ function nf(locale, min, max) {
|
|
|
47
47
|
() => new Intl.NumberFormat(locale, { minimumFractionDigits: min, maximumFractionDigits: max })
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
var zoneOk = /* @__PURE__ */ new Map();
|
|
51
|
+
function safeZone(timeZone) {
|
|
52
|
+
if (!timeZone) return void 0;
|
|
53
|
+
let ok = zoneOk.get(timeZone);
|
|
54
|
+
if (ok === void 0) {
|
|
55
|
+
try {
|
|
56
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
57
|
+
ok = true;
|
|
58
|
+
} catch {
|
|
59
|
+
ok = false;
|
|
60
|
+
}
|
|
61
|
+
if (zoneOk.size >= 64) zoneOk.clear();
|
|
62
|
+
zoneOk.set(timeZone, ok);
|
|
63
|
+
}
|
|
64
|
+
return ok ? timeZone : void 0;
|
|
65
|
+
}
|
|
66
|
+
function dtf(locale, key, options, zone2) {
|
|
67
|
+
const timeZone = safeZone(zone2);
|
|
51
68
|
return cached(
|
|
52
69
|
`d|${locale}|${key}|${timeZone ?? ""}`,
|
|
53
70
|
() => new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options)
|
|
@@ -232,7 +249,12 @@ function ago(t, o = {}) {
|
|
|
232
249
|
if (abs < 45) return english ? "just now" : rtf(locale, long ? "long" : "narrow").format(0, "second");
|
|
233
250
|
let pick = AGO_UNITS[0];
|
|
234
251
|
for (const u of AGO_UNITS) if (abs >= u[0]) pick = u;
|
|
235
|
-
|
|
252
|
+
let n = Math.max(1, Math.round(abs / pick[0]));
|
|
253
|
+
const next = AGO_UNITS[AGO_UNITS.indexOf(pick) + 1];
|
|
254
|
+
if (next && (n * pick[0] >= next[0] || pick[1] === "month" && n >= 12)) {
|
|
255
|
+
pick = next;
|
|
256
|
+
n = Math.max(1, Math.round(abs / pick[0]));
|
|
257
|
+
}
|
|
236
258
|
const past = diff < 0;
|
|
237
259
|
if (!english) return rtf(locale, long ? "long" : "narrow").format(past ? -n : n, pick[1]);
|
|
238
260
|
if (long) return rtf(locale, "long").format(past ? -n : n, pick[1]);
|
package/dist/esm/runtime.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// src/runtime.ts
|
|
2
|
-
var version = true ? "3.
|
|
2
|
+
var version = true ? "3.2.0" : "dev";
|
|
3
3
|
var VERSION = version;
|
|
4
4
|
var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
|
|
5
5
|
function runtime() {
|
|
6
6
|
const g = globalThis;
|
|
7
7
|
return g[KEY] ??= { versions: /* @__PURE__ */ new Set(), slots: {} };
|
|
8
8
|
}
|
|
9
|
+
function isDevelopment() {
|
|
10
|
+
try {
|
|
11
|
+
return process.env.NODE_ENV !== "production";
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
9
16
|
function register(rt) {
|
|
10
17
|
rt.versions.add(version);
|
|
11
|
-
if (rt.versions.size > 1 && !rt.warned &&
|
|
18
|
+
if (rt.versions.size > 1 && !rt.warned && isDevelopment()) {
|
|
12
19
|
rt.warned = true;
|
|
13
20
|
console.warn(
|
|
14
21
|
`nish-ui: two versions are loaded on this page (${[...rt.versions].join(", ")}). Overlays, toasts and theme state are shared, but mixing versions is unsupported.`
|
package/dist/esm/split-layout.js
CHANGED
|
@@ -361,7 +361,8 @@ function swapSlots(slots, a, b) {
|
|
|
361
361
|
function narrowLayout(count, n, aspect) {
|
|
362
362
|
if (count === 1) return leaf(0);
|
|
363
363
|
const dir = n.dir === "auto" ? aspect >= 1.2 ? "row" : "col" : n.dir;
|
|
364
|
-
const
|
|
364
|
+
const s = Number.isFinite(n.split) ? n.split : 0.5;
|
|
365
|
+
const split = Math.min(0.8, Math.max(0.2, s));
|
|
365
366
|
return {
|
|
366
367
|
type: "split",
|
|
367
368
|
dir,
|
package/dist/format.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
// src/runtime.ts
|
|
2
|
-
var version = true ? "3.
|
|
2
|
+
var version = true ? "3.2.0" : "dev";
|
|
3
3
|
var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
|
|
4
4
|
function runtime() {
|
|
5
5
|
const g = globalThis;
|
|
6
6
|
return g[KEY] ??= { versions: /* @__PURE__ */ new Set(), slots: {} };
|
|
7
7
|
}
|
|
8
|
+
function isDevelopment() {
|
|
9
|
+
try {
|
|
10
|
+
return process.env.NODE_ENV !== "production";
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
function register(rt) {
|
|
9
16
|
rt.versions.add(version);
|
|
10
|
-
if (rt.versions.size > 1 && !rt.warned &&
|
|
17
|
+
if (rt.versions.size > 1 && !rt.warned && isDevelopment()) {
|
|
11
18
|
rt.warned = true;
|
|
12
19
|
console.warn(
|
|
13
20
|
`nish-ui: two versions are loaded on this page (${[...rt.versions].join(", ")}). Overlays, toasts and theme state are shared, but mixing versions is unsupported.`
|
|
@@ -73,7 +80,24 @@ function nf(locale, min, max) {
|
|
|
73
80
|
() => new Intl.NumberFormat(locale, { minimumFractionDigits: min, maximumFractionDigits: max })
|
|
74
81
|
);
|
|
75
82
|
}
|
|
76
|
-
|
|
83
|
+
var zoneOk = /* @__PURE__ */ new Map();
|
|
84
|
+
function safeZone(timeZone) {
|
|
85
|
+
if (!timeZone) return void 0;
|
|
86
|
+
let ok = zoneOk.get(timeZone);
|
|
87
|
+
if (ok === void 0) {
|
|
88
|
+
try {
|
|
89
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
90
|
+
ok = true;
|
|
91
|
+
} catch {
|
|
92
|
+
ok = false;
|
|
93
|
+
}
|
|
94
|
+
if (zoneOk.size >= 64) zoneOk.clear();
|
|
95
|
+
zoneOk.set(timeZone, ok);
|
|
96
|
+
}
|
|
97
|
+
return ok ? timeZone : void 0;
|
|
98
|
+
}
|
|
99
|
+
function dtf(locale, key, options, zone2) {
|
|
100
|
+
const timeZone = safeZone(zone2);
|
|
77
101
|
return cached(
|
|
78
102
|
`d|${locale}|${key}|${timeZone ?? ""}`,
|
|
79
103
|
() => new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options)
|
|
@@ -258,7 +282,12 @@ function ago(t, o = {}) {
|
|
|
258
282
|
if (abs < 45) return english ? "just now" : rtf(locale, long ? "long" : "narrow").format(0, "second");
|
|
259
283
|
let pick = AGO_UNITS[0];
|
|
260
284
|
for (const u of AGO_UNITS) if (abs >= u[0]) pick = u;
|
|
261
|
-
|
|
285
|
+
let n = Math.max(1, Math.round(abs / pick[0]));
|
|
286
|
+
const next = AGO_UNITS[AGO_UNITS.indexOf(pick) + 1];
|
|
287
|
+
if (next && (n * pick[0] >= next[0] || pick[1] === "month" && n >= 12)) {
|
|
288
|
+
pick = next;
|
|
289
|
+
n = Math.max(1, Math.round(abs / pick[0]));
|
|
290
|
+
}
|
|
262
291
|
const past = diff < 0;
|
|
263
292
|
if (!english) return rtf(locale, long ? "long" : "narrow").format(past ? -n : n, pick[1]);
|
|
264
293
|
if (long) return rtf(locale, "long").format(past ? -n : n, pick[1]);
|
|
@@ -347,4 +376,3 @@ export {
|
|
|
347
376
|
signedMoney,
|
|
348
377
|
time
|
|
349
378
|
};
|
|
350
|
-
//# sourceMappingURL=format.js.map
|
package/dist/inbox-client.d.ts
CHANGED
|
@@ -69,7 +69,11 @@ interface InboxEventInput {
|
|
|
69
69
|
resolve?: boolean;
|
|
70
70
|
/** ISO 8601 time the event happened. Defaults to now; future times are clamped to now. */
|
|
71
71
|
occurredAt?: string;
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Flat extra data, JSON-encoded at most 4096 bytes. Only data.actionToken (ACTION_TOKEN_FIELD) is private
|
|
74
|
+
* (stripped before the browser and /api/v1 see the item); every other key is visible in the inbox UI and API.
|
|
75
|
+
* /ingest trusts every local caller, so action routes must verify actionToken (actionTokenMatches) on every call.
|
|
76
|
+
*/
|
|
73
77
|
data?: InboxData;
|
|
74
78
|
/** Up to 3 buttons shown on the item, ids unique. A repeat with the same dedupeKey replaces them. */
|
|
75
79
|
actions?: Array<Omit<InboxAction, 'method'> & {
|
package/dist/inbox-client.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,8 @@ declare const VERSION: string;
|
|
|
11
11
|
/** href for user-supplied links: relative URLs, #fragments, http(s), mailto and tel pass;
|
|
12
12
|
* anything else (javascript:, data:, vbscript:, file:) returns null. Trims leading and trailing
|
|
13
13
|
* C0 controls and spaces and drops tabs and newlines the way the WHATWG URL parser does, then
|
|
14
|
-
* reads the scheme from the very string that is returned.
|
|
15
|
-
* U+2028, U+3000) is
|
|
16
|
-
* not a scheme there either. */
|
|
14
|
+
* reads the scheme from the very string that is returned. A URL with leading or trailing
|
|
15
|
+
* non-C0 Unicode whitespace (NBSP, U+FEFF, U+2028, U+3000) is refused (null). */
|
|
17
16
|
declare function safeUrl(href: string | null | undefined): string | null;
|
|
18
17
|
|
|
19
18
|
type Scheme = 'dark' | 'light';
|
|
@@ -3644,7 +3643,11 @@ interface FilterBarProps extends Omit<ComponentPropsWithRef<'div'>, 'children'>
|
|
|
3644
3643
|
className?: string;
|
|
3645
3644
|
}
|
|
3646
3645
|
/** The search and filter row of a list page. From md up the controls sit inline; below md
|
|
3647
|
-
* they move into a bottom sheet behind a Filters button that shows how many are on.
|
|
3646
|
+
* they move into a bottom sheet behind a Filters button that shows how many are on.
|
|
3647
|
+
*
|
|
3648
|
+
* Server rendering: the media query is false on the server, so FilterBar first paints the inline
|
|
3649
|
+
* row and collapses to the Filters button after hydration. To avoid that flash on phones, render
|
|
3650
|
+
* it only on the client (behind a mounted check, or a dynamic import with ssr: false). */
|
|
3648
3651
|
declare function FilterBar({ search, children, activeCount, onClear, trailing, sticky, sheetTitle, sheetBelow, summary, className, ref, ...rest }: FilterBarProps): react.JSX.Element;
|
|
3649
3652
|
|
|
3650
3653
|
/** Where useUrlState reads and writes the query string. */
|
package/dist/nish-components.css
CHANGED
|
@@ -1013,7 +1013,7 @@
|
|
|
1013
1013
|
:where(.nish-stats--4) {
|
|
1014
1014
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1015
1015
|
}
|
|
1016
|
-
@media (min-width:
|
|
1016
|
+
@media (min-width: 768px) {
|
|
1017
1017
|
:where(.nish-stats--4) {
|
|
1018
1018
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
1019
1019
|
}
|
|
@@ -1695,7 +1695,8 @@
|
|
|
1695
1695
|
<div class="nish-skeleton nish-skeleton--thumb"></div>
|
|
1696
1696
|
<div class="nish-skeleton nish-skeleton--card"></div>
|
|
1697
1697
|
</div>
|
|
1698
|
-
The group
|
|
1698
|
+
The group needs role="status" and visually hidden "Loading" text to be announced (aria-busy alone says nothing):
|
|
1699
|
+
set aria-busy="false" (or remove the group) once loaded. */
|
|
1699
1700
|
:where(.nish-skeleton) {
|
|
1700
1701
|
display: block;
|
|
1701
1702
|
border-radius: var(--nish-radius-sm);
|
|
@@ -3313,6 +3314,14 @@
|
|
|
3313
3314
|
}
|
|
3314
3315
|
:where(.nish-btn--link) {
|
|
3315
3316
|
min-height: 0;
|
|
3317
|
+
position: relative;
|
|
3318
|
+
}
|
|
3319
|
+
/* The same invisible hit area as the React link Button (LINK_HIT): a 16px line grows 14px per side to 44px without moving the layout. */
|
|
3320
|
+
:where(.nish-btn--link)::after {
|
|
3321
|
+
content: '';
|
|
3322
|
+
position: absolute;
|
|
3323
|
+
inset-inline: -0.5rem;
|
|
3324
|
+
inset-block: -0.875rem;
|
|
3316
3325
|
}
|
|
3317
3326
|
/* Grown to 44px without growing the toast (the React toast's negative margins). */
|
|
3318
3327
|
:where(.nish-toast-action) {
|