nish-ui 1.8.0 → 2.0.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.
Files changed (152) hide show
  1. package/README.md +223 -61
  2. package/dist/base-tailwind.css +1757 -0
  3. package/dist/base.css +1590 -1445
  4. package/dist/chart.d.ts +4 -1
  5. package/dist/chart.js +122 -49
  6. package/dist/elements-all.d.ts +8 -0
  7. package/dist/elements-all.js +178 -0
  8. package/dist/elements-charts.d.ts +124 -2
  9. package/dist/elements-charts.js +131 -1
  10. package/dist/elements-data.d.ts +166 -2
  11. package/dist/elements-data.js +46 -1
  12. package/dist/elements-forms.d.ts +71 -0
  13. package/dist/elements-forms.js +24 -25
  14. package/dist/elements.d.ts +71 -0
  15. package/dist/elements.js +4 -5
  16. package/dist/esm/chart-values.js +58 -0
  17. package/dist/esm/chart.js +10 -0
  18. package/dist/esm/cn.js +19 -0
  19. package/dist/esm/combobox-filter.js +13 -0
  20. package/dist/esm/components/accordion.js +166 -0
  21. package/dist/esm/components/app-shell.js +198 -0
  22. package/dist/esm/components/avatar-classes.js +28 -0
  23. package/dist/esm/components/avatar.js +113 -0
  24. package/dist/esm/components/breadcrumbs.js +154 -0
  25. package/dist/esm/components/canvas/follow-caption.js +32 -0
  26. package/dist/esm/components/canvas/follow.js +119 -0
  27. package/dist/esm/components/canvas/icons.js +70 -0
  28. package/dist/esm/components/canvas/index.js +10 -0
  29. package/dist/esm/components/canvas/layout.js +258 -0
  30. package/dist/esm/components/canvas/legend.js +93 -0
  31. package/dist/esm/components/canvas/minimap.js +127 -0
  32. package/dist/esm/components/canvas/node.js +87 -0
  33. package/dist/esm/components/canvas/route.js +262 -0
  34. package/dist/esm/components/canvas/system-canvas.js +837 -0
  35. package/dist/esm/components/canvas/types.js +10 -0
  36. package/dist/esm/components/canvas/view.js +47 -0
  37. package/dist/esm/components/chart-hooks.js +19 -0
  38. package/dist/esm/components/charts.js +467 -0
  39. package/dist/esm/components/client.js +24 -0
  40. package/dist/esm/components/combobox.js +343 -0
  41. package/dist/esm/components/command.js +403 -0
  42. package/dist/esm/components/data-classes.js +159 -0
  43. package/dist/esm/components/data.js +517 -0
  44. package/dist/esm/components/display-classes.js +130 -0
  45. package/dist/esm/components/display.js +755 -0
  46. package/dist/esm/components/error-boundary.js +64 -0
  47. package/dist/esm/components/feedback.js +136 -0
  48. package/dist/esm/components/file-dropzone.js +184 -0
  49. package/dist/esm/components/filters.js +108 -0
  50. package/dist/esm/components/flow.js +746 -0
  51. package/dist/esm/components/forms-classes.js +43 -0
  52. package/dist/esm/components/forms.js +581 -0
  53. package/dist/esm/components/hooks-classes.js +9 -0
  54. package/dist/esm/components/hooks.js +236 -0
  55. package/dist/esm/components/icons.js +96 -0
  56. package/dist/esm/components/inbox-classes.js +29 -0
  57. package/dist/esm/components/inbox.js +257 -0
  58. package/dist/esm/components/latest.js +13 -0
  59. package/dist/esm/components/layout-vars.js +96 -0
  60. package/dist/esm/components/layout.js +272 -0
  61. package/dist/esm/components/media.js +143 -0
  62. package/dist/esm/components/nav.js +614 -0
  63. package/dist/esm/components/overlay-classes.js +66 -0
  64. package/dist/esm/components/overlay.js +1447 -0
  65. package/dist/esm/components/pagination-classes.js +29 -0
  66. package/dist/esm/components/pagination.js +154 -0
  67. package/dist/esm/components/portal.js +16 -0
  68. package/dist/esm/components/primitives-classes.js +198 -0
  69. package/dist/esm/components/primitives.js +268 -0
  70. package/dist/esm/components/progress.js +77 -0
  71. package/dist/esm/components/provider.js +32 -0
  72. package/dist/esm/components/radio-group.js +186 -0
  73. package/dist/esm/components/resource-classes.js +133 -0
  74. package/dist/esm/components/resource.js +209 -0
  75. package/dist/esm/components/segmented.js +178 -0
  76. package/dist/esm/components/separator.js +38 -0
  77. package/dist/esm/components/service-tokens.js +221 -0
  78. package/dist/esm/components/settings.js +301 -0
  79. package/dist/esm/components/slider.js +262 -0
  80. package/dist/esm/components/split-classes.js +8 -0
  81. package/dist/esm/components/split.js +411 -0
  82. package/dist/esm/components/strings.js +119 -0
  83. package/dist/esm/components/table.js +144 -0
  84. package/dist/esm/components/tabs-classes.js +21 -0
  85. package/dist/esm/components/tabs.js +201 -0
  86. package/dist/esm/components/tag-input.js +257 -0
  87. package/dist/esm/components/theme-toggle.js +177 -0
  88. package/dist/esm/components/toast.js +361 -0
  89. package/dist/esm/components/url-state.js +118 -0
  90. package/dist/esm/components/visually-hidden.js +20 -0
  91. package/dist/esm/format.js +320 -0
  92. package/dist/esm/inbox-client.js +2 -0
  93. package/dist/esm/inbox-types.js +2 -0
  94. package/dist/esm/index.js +320 -0
  95. package/dist/esm/runtime.js +37 -0
  96. package/dist/esm/server/inbox/client.js +297 -0
  97. package/dist/esm/server/inbox/types.js +24 -0
  98. package/dist/esm/sparkline-path.js +59 -0
  99. package/dist/esm/split-layout.js +419 -0
  100. package/dist/esm/system-canvas.js +2 -0
  101. package/dist/esm/theme.js +804 -0
  102. package/dist/esm/tokens.mjs +425 -0
  103. package/dist/esm/url.js +20 -0
  104. package/dist/files.json +5 -1
  105. package/dist/fonts/LICENSE-Inter.txt +93 -0
  106. package/dist/format.d.ts +32 -18
  107. package/dist/format.js +227 -82
  108. package/dist/inbox-client.js +3 -1
  109. package/dist/index.d.ts +1689 -667
  110. package/dist/nish-components.css +4701 -3169
  111. package/dist/nish-components.min.css +1 -0
  112. package/dist/nish.css +1603 -1450
  113. package/dist/nish.min.css +1 -0
  114. package/dist/node/eslint.js +29 -14
  115. package/dist/node/th-check.js +29 -14
  116. package/dist/node/vite.d.ts +12 -0
  117. package/dist/node/vite.js +12 -2
  118. package/dist/server/hono.d.ts +15 -6
  119. package/dist/server/hono.js +30 -25
  120. package/dist/server/index.d.ts +3 -10
  121. package/dist/server/index.js +71 -38
  122. package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
  123. package/dist/system-canvas-BLuWd69H.d.ts +183 -0
  124. package/dist/system-canvas.d.ts +2 -168
  125. package/dist/tailwind-core.css +114 -0
  126. package/dist/tailwind.css +3 -7
  127. package/dist/theme-init.js +23 -9
  128. package/dist/theme-init.sha256 +1 -0
  129. package/dist/theme.d.ts +246 -4
  130. package/dist/theme.global.js +357 -90
  131. package/dist/theme.js +338 -68
  132. package/dist/tokens.css +14 -6
  133. package/dist/tokens.dtcg.json +1513 -0
  134. package/dist/tokens.js +29 -14
  135. package/dist/tokens.json +512 -0
  136. package/package.json +51 -13
  137. package/dist/chart.js.map +0 -1
  138. package/dist/elements-charts.js.map +0 -1
  139. package/dist/elements-data.js.map +0 -1
  140. package/dist/elements-forms.js.map +0 -1
  141. package/dist/elements.js.map +0 -1
  142. package/dist/format.js.map +0 -1
  143. package/dist/inbox-client.js.map +0 -1
  144. package/dist/index.js +0 -10260
  145. package/dist/index.js.map +0 -1
  146. package/dist/server/hono.js.map +0 -1
  147. package/dist/server/index.js.map +0 -1
  148. package/dist/split-layout.js.map +0 -1
  149. package/dist/system-canvas.js +0 -2204
  150. package/dist/system-canvas.js.map +0 -1
  151. package/dist/theme.global.js.map +0 -1
  152. package/dist/theme.js.map +0 -1
@@ -0,0 +1,403 @@
1
+ "use client";
2
+
3
+ // src/components/command.tsx
4
+ import {
5
+ useEffect,
6
+ useId,
7
+ useMemo,
8
+ useRef,
9
+ useState
10
+ } from "react";
11
+ import { cn } from "../cn.js";
12
+ import { safeUrl } from "../url.js";
13
+ import { XIcon } from "./icons.js";
14
+ import { Modal, whenHistorySettled } from "./overlay.js";
15
+ import { useLatest } from "./latest.js";
16
+ import { useNishStrings } from "./provider.js";
17
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
+ var MAX_RESULTS = 50;
19
+ function indexItems(items) {
20
+ return items.map((item) => ({ item, label: item.label.toLowerCase(), keywords: (item.keywords ?? []).map((k) => k.toLowerCase()) }));
21
+ }
22
+ function isWordStart(text, i) {
23
+ return i === 0 || !/[a-z0-9]/i.test(text[i - 1]);
24
+ }
25
+ function matchText(text, q) {
26
+ const at = text.indexOf(q);
27
+ if (at >= 0) {
28
+ let tier = at === 0 ? 0 : 2;
29
+ let start = at;
30
+ if (tier === 2) {
31
+ for (let from2 = at; from2 >= 0; from2 = text.indexOf(q, from2 + 1)) {
32
+ if (isWordStart(text, from2)) {
33
+ tier = 1;
34
+ start = from2;
35
+ break;
36
+ }
37
+ if (from2 + 1 >= text.length) break;
38
+ }
39
+ }
40
+ return { tier, idx: Array.from({ length: q.length }, (_, k) => start + k) };
41
+ }
42
+ const idx = [];
43
+ let from = 0;
44
+ for (const ch of q) {
45
+ const found = text.indexOf(ch, from);
46
+ if (found < 0) return null;
47
+ idx.push(found);
48
+ from = found + 1;
49
+ }
50
+ return { tier: 3, idx };
51
+ }
52
+ function navigateFromLayer(rawHref) {
53
+ const href = safeUrl(rawHref);
54
+ if (href === null) {
55
+ warnUnsafe(rawHref);
56
+ return;
57
+ }
58
+ const inLayer = !!history.state?.nishLayer;
59
+ if (!inLayer) {
60
+ window.location.assign(href);
61
+ return;
62
+ }
63
+ let done = false;
64
+ const go = () => {
65
+ if (done) return;
66
+ done = true;
67
+ window.location.assign(href);
68
+ };
69
+ window.setTimeout(() => whenHistorySettled(go), 0);
70
+ window.setTimeout(go, 400);
71
+ }
72
+ function warnUnsafe(href) {
73
+ try {
74
+ if (process.env.NODE_ENV !== "production") console.warn(`CommandPalette: ignored an unsafe href (${href.slice(0, 40)}).`);
75
+ } catch {
76
+ }
77
+ }
78
+ function rankItems(items, query) {
79
+ const q = query.trim().toLowerCase();
80
+ if (!q) return items.slice(0, MAX_RESULTS).map(({ item }) => ({ item, marks: [] }));
81
+ const scored = [];
82
+ items.forEach(({ item, label: lower, keywords }, order) => {
83
+ const label = matchText(lower, q);
84
+ if (label) {
85
+ scored.push({ r: { item, marks: label.idx }, score: label.tier, order });
86
+ return;
87
+ }
88
+ let best = null;
89
+ for (const kw of keywords) {
90
+ const m = matchText(kw, q);
91
+ if (m && m.tier < 3 && (best === null || m.tier < best)) best = m.tier;
92
+ }
93
+ if (best !== null) scored.push({ r: { item, marks: [] }, score: 4 + best, order });
94
+ });
95
+ scored.sort((a, b) => a.score - b.score || a.order - b.order);
96
+ return scored.slice(0, MAX_RESULTS).map((s) => s.r);
97
+ }
98
+ function groupRows(rows) {
99
+ const order = [];
100
+ const map = /* @__PURE__ */ new Map();
101
+ for (const r of rows) {
102
+ const g = r.item.group ?? null;
103
+ if (!map.has(g)) {
104
+ map.set(g, []);
105
+ order.push(g);
106
+ }
107
+ map.get(g).push(r);
108
+ }
109
+ order.sort((a, b) => a === null ? -1 : b === null ? 1 : 0);
110
+ let index = 0;
111
+ return order.map((group) => ({ group, rows: map.get(group).map((r) => ({ r, index: index++ })) }));
112
+ }
113
+ function Highlighted({ text, marks }) {
114
+ if (marks.length === 0) return /* @__PURE__ */ jsx(Fragment, { children: text });
115
+ const set = new Set(marks);
116
+ const parts = [];
117
+ let i = 0;
118
+ while (i < text.length) {
119
+ const on = set.has(i);
120
+ let j = i;
121
+ while (j < text.length && set.has(j) === on) j++;
122
+ const chunk = text.slice(i, j);
123
+ parts.push(
124
+ on ? /* @__PURE__ */ jsx("mark", { className: "bg-transparent font-semibold text-th-accent", children: chunk }, i) : /* @__PURE__ */ jsx("span", { children: chunk }, i)
125
+ );
126
+ i = j;
127
+ }
128
+ return /* @__PURE__ */ jsx(Fragment, { children: parts });
129
+ }
130
+ function SearchIcon({ size = 18 }) {
131
+ return /* @__PURE__ */ jsxs(
132
+ "svg",
133
+ {
134
+ width: size,
135
+ height: size,
136
+ viewBox: "0 0 24 24",
137
+ fill: "none",
138
+ stroke: "currentColor",
139
+ strokeWidth: 2,
140
+ strokeLinecap: "round",
141
+ strokeLinejoin: "round",
142
+ "aria-hidden": "true",
143
+ focusable: "false",
144
+ children: [
145
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
146
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
147
+ ]
148
+ }
149
+ );
150
+ }
151
+ function defaultResultsLabel(count) {
152
+ return `${count} result${count === 1 ? "" : "s"}`;
153
+ }
154
+ function isTypingTarget(t) {
155
+ if (!(t instanceof HTMLElement)) return false;
156
+ const tag = t.tagName;
157
+ return tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || t.isContentEditable;
158
+ }
159
+ function useCommandHotkey(open, enabled = true) {
160
+ const ref = useLatest(open);
161
+ useEffect(() => {
162
+ if (!enabled) return;
163
+ const onKey = (e) => {
164
+ if (e.defaultPrevented || e.isComposing) return;
165
+ if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "k") {
166
+ e.preventDefault();
167
+ ref.current();
168
+ } else if (e.key === "/" && !e.ctrlKey && !e.metaKey && !e.altKey && !isTypingTarget(e.target)) {
169
+ e.preventDefault();
170
+ ref.current();
171
+ }
172
+ };
173
+ document.addEventListener("keydown", onKey);
174
+ return () => document.removeEventListener("keydown", onKey);
175
+ }, [enabled, ref]);
176
+ }
177
+ function CommandPalette({
178
+ open,
179
+ onOpenChange,
180
+ items,
181
+ placeholder,
182
+ emptyText,
183
+ resultsLabel,
184
+ externalLabel,
185
+ hotkey = true,
186
+ onQuery,
187
+ footer,
188
+ onSubmitQuery
189
+ }) {
190
+ const s = useNishStrings();
191
+ useCommandHotkey(() => {
192
+ if (!open) onOpenChange(true);
193
+ }, hotkey);
194
+ if (!open) return null;
195
+ return /* @__PURE__ */ jsx(
196
+ PaletteDialog,
197
+ {
198
+ onClose: () => onOpenChange(false),
199
+ items,
200
+ placeholder: placeholder ?? s.searchPlaceholder,
201
+ emptyText: emptyText ?? s.noResults,
202
+ resultsLabel,
203
+ externalLabel: externalLabel ?? "opens in a new tab",
204
+ onQuery,
205
+ footer,
206
+ onSubmitQuery
207
+ }
208
+ );
209
+ }
210
+ function PaletteDialog({ onClose, items, placeholder, emptyText, resultsLabel, externalLabel, onQuery, footer, onSubmitQuery }) {
211
+ const s = useNishStrings();
212
+ const uid = useId();
213
+ const listId = `${uid}-list`;
214
+ const optionId = (i) => `${uid}-opt-${i}`;
215
+ const inputRef = useRef(null);
216
+ const listRef = useRef(null);
217
+ const [query, setQuery] = useState("");
218
+ const [active, setActive] = useState(0);
219
+ const isFn = typeof items === "function";
220
+ const itemsRef = useLatest(items);
221
+ const [dynamic, setDynamic] = useState([]);
222
+ const [pending, setPending] = useState(isFn);
223
+ useEffect(() => {
224
+ const fn = itemsRef.current;
225
+ if (typeof fn !== "function") return;
226
+ let stale = false;
227
+ let res;
228
+ try {
229
+ res = fn(query);
230
+ } catch {
231
+ res = [];
232
+ }
233
+ if (Array.isArray(res)) {
234
+ setDynamic(res.slice(0, MAX_RESULTS));
235
+ setPending(false);
236
+ return;
237
+ }
238
+ setPending(true);
239
+ res.then(
240
+ (r) => {
241
+ if (stale) return;
242
+ setDynamic(r.slice(0, MAX_RESULTS));
243
+ setPending(false);
244
+ },
245
+ () => {
246
+ if (stale) return;
247
+ setDynamic([]);
248
+ setPending(false);
249
+ }
250
+ );
251
+ return () => {
252
+ stale = true;
253
+ };
254
+ }, [query, isFn, itemsRef]);
255
+ const indexed = useMemo(() => isFn ? [] : indexItems(items), [isFn, items]);
256
+ const rows = useMemo(() => {
257
+ if (isFn) return dynamic.map((item) => ({ item, marks: matchText(item.label.toLowerCase(), query.trim().toLowerCase())?.idx ?? [] }));
258
+ return rankItems(indexed, query);
259
+ }, [isFn, dynamic, indexed, query]);
260
+ const groups = useMemo(() => groupRows(rows), [rows]);
261
+ const flat = useMemo(() => groups.flatMap((g) => g.rows.map((x) => x.r.item)), [groups]);
262
+ useEffect(() => {
263
+ inputRef.current?.focus();
264
+ }, []);
265
+ useEffect(() => {
266
+ setActive(0);
267
+ }, [query, flat.length]);
268
+ useEffect(() => {
269
+ document.getElementById(optionId(active))?.scrollIntoView({ block: "nearest" });
270
+ }, [active]);
271
+ const select = (item) => {
272
+ onClose();
273
+ if (item.href) {
274
+ const href = safeUrl(item.href);
275
+ if (href === null) warnUnsafe(item.href);
276
+ else if (item.external) window.open(href, "_blank", "noopener,noreferrer");
277
+ else navigateFromLayer(href);
278
+ } else {
279
+ item.onSelect?.();
280
+ }
281
+ };
282
+ const onKeyDown = (e) => {
283
+ if (e.nativeEvent.isComposing) return;
284
+ if (e.key === "ArrowDown") {
285
+ e.preventDefault();
286
+ if (flat.length) setActive((a) => (a + 1) % flat.length);
287
+ } else if (e.key === "ArrowUp") {
288
+ e.preventDefault();
289
+ if (flat.length) setActive((a) => (a - 1 + flat.length) % flat.length);
290
+ } else if (e.key === "Home" && flat.length && !query) {
291
+ e.preventDefault();
292
+ setActive(0);
293
+ } else if (e.key === "Enter") {
294
+ e.preventDefault();
295
+ const item = flat[active];
296
+ if (item) select(item);
297
+ else if (!pending && query.trim() && onSubmitQuery) {
298
+ onClose();
299
+ onSubmitQuery(query.trim());
300
+ }
301
+ }
302
+ };
303
+ const header = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-th-line px-4 pb-2 sm:pt-1", children: [
304
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-th-hi3", children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
305
+ /* @__PURE__ */ jsx(
306
+ "input",
307
+ {
308
+ ref: inputRef,
309
+ type: "text",
310
+ role: "combobox",
311
+ "aria-expanded": "true",
312
+ "aria-controls": listId,
313
+ "aria-autocomplete": "list",
314
+ "aria-activedescendant": flat.length ? optionId(active) : void 0,
315
+ "aria-label": placeholder.replace(/…$/, "") || s.search,
316
+ value: query,
317
+ placeholder,
318
+ autoComplete: "off",
319
+ autoCorrect: "off",
320
+ autoCapitalize: "off",
321
+ spellCheck: false,
322
+ enterKeyHint: flat.length ? "go" : "search",
323
+ onChange: (e) => {
324
+ setQuery(e.target.value);
325
+ onQuery?.(e.target.value);
326
+ },
327
+ onKeyDown,
328
+ className: "h-12 min-w-0 flex-1 bg-transparent text-base text-th-hi outline-none placeholder:text-th-hi3"
329
+ }
330
+ ),
331
+ /* @__PURE__ */ jsx(
332
+ "button",
333
+ {
334
+ type: "button",
335
+ onClick: onClose,
336
+ "aria-label": s.close,
337
+ className: "inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-th-hi3 transition-colors hover:bg-th-elevated hover:text-th-hi sm:hidden",
338
+ children: /* @__PURE__ */ jsx(XIcon, { size: 18 })
339
+ }
340
+ )
341
+ ] });
342
+ const showEmpty = flat.length === 0 && !pending;
343
+ return /* @__PURE__ */ jsxs(
344
+ Modal,
345
+ {
346
+ onClose,
347
+ header,
348
+ "aria-label": s.search,
349
+ placement: "top",
350
+ sheetHeight: "full",
351
+ footer,
352
+ className: "sm:max-w-[560px]",
353
+ children: [
354
+ /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "sr-only", children: showEmpty ? "" : (resultsLabel ?? defaultResultsLabel)(flat.length) }),
355
+ /* @__PURE__ */ jsx(
356
+ "div",
357
+ {
358
+ ref: listRef,
359
+ id: listId,
360
+ role: "listbox",
361
+ "aria-label": s.results,
362
+ "aria-busy": pending,
363
+ className: "-mx-2",
364
+ onMouseDown: (e) => e.preventDefault(),
365
+ children: groups.map((g, gi) => {
366
+ const headId = `${uid}-g-${gi}`;
367
+ return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": g.group ? headId : void 0, children: [
368
+ g.group ? /* @__PURE__ */ jsx("div", { id: headId, className: "px-3 pb-1 pt-3 text-xs font-medium uppercase tracking-wide text-th-hi3", children: g.group }) : null,
369
+ g.rows.map(({ r, index }) => /* @__PURE__ */ jsxs(
370
+ "div",
371
+ {
372
+ id: optionId(index),
373
+ role: "option",
374
+ "aria-selected": index === active,
375
+ onMouseMove: () => index !== active && setActive(index),
376
+ onClick: () => select(r.item),
377
+ className: cn(
378
+ "flex min-h-11 cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-sm text-th-hi2",
379
+ index === active && "bg-th-elevated text-th-hi"
380
+ ),
381
+ children: [
382
+ r.item.icon ? /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 items-center text-th-hi3", children: r.item.icon }) : null,
383
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: /* @__PURE__ */ jsx(Highlighted, { text: r.item.label, marks: r.marks }) }),
384
+ r.item.hint ? /* @__PURE__ */ jsx("span", { className: "max-w-[40%] shrink-0 truncate text-xs text-th-hi3", children: r.item.hint }) : null,
385
+ r.item.external ? /* @__PURE__ */ jsx("span", { className: "inline-block shrink-0 text-xs text-th-hi3 rtl:-scale-x-100", role: "img", "aria-label": externalLabel, children: "\u2197" }) : null
386
+ ]
387
+ },
388
+ r.item.id
389
+ ))
390
+ ] }, g.group ?? "__none");
391
+ })
392
+ }
393
+ ),
394
+ showEmpty ? /* @__PURE__ */ jsx("div", { role: "status", className: "px-3 py-8 text-center text-sm text-th-hi3", children: emptyText }) : null
395
+ ]
396
+ }
397
+ );
398
+ }
399
+ export {
400
+ CommandPalette,
401
+ navigateFromLayer,
402
+ useCommandHotkey
403
+ };
@@ -0,0 +1,159 @@
1
+ // src/components/data-classes.ts
2
+ var ALIGN = { left: "text-start", center: "text-center", right: "text-end" };
3
+ var ROW_TONE = {
4
+ 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]",
5
+ 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]",
6
+ 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]"
7
+ };
8
+ 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";
9
+ var STICKY = "[&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-[var(--nish-z-sticky,1)] [&_thead_th]:bg-th-surface";
10
+ var TABLE = "w-full border-collapse text-sm tabular-nums text-th-hi2";
11
+ var ZEBRA = "[&_tbody>tr:nth-child(even)]:bg-th-elevated/50";
12
+ var TH = "whitespace-nowrap border-b border-th-line px-3 text-start align-middle text-xs font-medium uppercase tracking-wider text-th-hi3";
13
+ var TD = "px-3 align-middle";
14
+ var PAD = { normal: "py-2.5", dense: "py-1.5" };
15
+ var TR = "border-b border-th-line last:border-b-0";
16
+ var TR_INTERACTIVE = "cursor-pointer transition-colors hover:bg-th-elevated focus-within:bg-th-elevated";
17
+ var NUMERIC = "whitespace-nowrap text-end tabular-nums";
18
+ var STICKY_COL = "[&_thead_tr]:bg-th-surface [&_tbody_tr]:bg-th-surface [&_tr>:first-child]:sticky [&_tr>:first-child]:start-0 [&_tr>:first-child]:z-[calc(var(--nish-z-sticky,1)+9)] [&_tr>:first-child]:bg-inherit [&_tr>:first-child]:after:pointer-events-none [&_tr>:first-child]:after:absolute [&_tr>:first-child]:after:inset-y-0 [&_tr>:first-child]:after:start-full [&_tr>:first-child]:after:w-2.5 [&_tr>:first-child]:after:bg-gradient-to-r rtl:[&_tr>:first-child]:after:bg-gradient-to-l [&_tr>:first-child]:after:from-[color-mix(in_srgb,var(--nish-hi)_14%,transparent)] [&_tr>:first-child]:after:to-transparent [&_tr>:first-child]:after:opacity-0 [&_tr>:first-child]:after:transition-opacity [&[data-at-start=false]_tr>:first-child]:after:opacity-100";
19
+ var tableClass = {
20
+ /** The scroll box around the table. */
21
+ wrap: WRAP,
22
+ /** Add to wrap for a header that stays put while the body scrolls (give wrap a max height). */
23
+ sticky: STICKY,
24
+ /** The <table>. */
25
+ table: TABLE,
26
+ /** Add to table for striped rows. */
27
+ zebra: ZEBRA,
28
+ /** A header cell (add padY.normal or padY.dense). */
29
+ th: TH,
30
+ /** A body cell (add padY.normal or padY.dense). */
31
+ td: TD,
32
+ /** Vertical cell padding: normal or dense. */
33
+ padY: PAD,
34
+ /** A body row. */
35
+ tr: TR,
36
+ /** Add to tr for a clickable row. */
37
+ trInteractive: TR_INTERACTIVE,
38
+ /** Add to th or td for a right-aligned number column. */
39
+ numeric: NUMERIC,
40
+ /** Add to tr for a status edge. */
41
+ tone: ROW_TONE
42
+ };
43
+ var tableInternals = { ALIGN, STICKY_COL, WRAP, STICKY, TABLE, ZEBRA, TH, TD, PAD, TR, TR_INTERACTIVE };
44
+ function mergeRefs(...refs) {
45
+ return (node) => {
46
+ const cleanups = [];
47
+ for (const ref of refs) {
48
+ if (typeof ref === "function") {
49
+ const out = ref(node);
50
+ if (typeof out === "function") cleanups.push(out);
51
+ } else if (ref) ref.current = node;
52
+ }
53
+ if (cleanups.length) return () => cleanups.forEach((fn) => fn());
54
+ };
55
+ }
56
+ var COLLATOR = /* @__PURE__ */ new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
57
+ function compareValues(a, b) {
58
+ if (a === b) return 0;
59
+ if (a === null) return 1;
60
+ if (b === null) return -1;
61
+ if (typeof a === "number" && typeof b === "number") return a - b;
62
+ return COLLATOR.compare(String(a), String(b));
63
+ }
64
+ function sortRows(rows, get, dir) {
65
+ const sign = dir === "asc" ? 1 : -1;
66
+ const keyed = rows.map((row, index) => ({ row, index, key: get(row) }));
67
+ keyed.sort((x, y) => {
68
+ const c = x.key === null || y.key === null ? compareValues(x.key, y.key) : sign * compareValues(x.key, y.key);
69
+ return c || x.index - y.index;
70
+ });
71
+ return keyed.map((k) => k.row);
72
+ }
73
+ var googleFavicon = (host, size) => `https://www.google.com/s2/favicons?sz=${size * 2 > 32 ? 64 : 32}&domain=${encodeURIComponent(host)}`;
74
+ var faviconResolver = () => null;
75
+ function configureFavicons(options) {
76
+ faviconResolver = options.resolve ?? (() => null);
77
+ }
78
+ function getFaviconResolver() {
79
+ return faviconResolver;
80
+ }
81
+ var FAVICON_HUES = 8;
82
+ function hashString(s) {
83
+ let h = 0;
84
+ for (let i = 0; i < s.length; i++) h = h * 31 + s.charCodeAt(i) | 0;
85
+ return Math.abs(h);
86
+ }
87
+ function hostnameOf(url) {
88
+ try {
89
+ const u = new URL(url.includes("://") ? url : `https://${url}`);
90
+ return u.hostname || null;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+ function decimateMinMax(points, xMin, xMax, buckets) {
96
+ const n = Math.max(1, Math.floor(buckets));
97
+ if (points.length <= n * 2) return points.slice();
98
+ const span = xMax - xMin || 1;
99
+ const out = [];
100
+ let b = -1;
101
+ let lo = null;
102
+ let hi = null;
103
+ const flush = () => {
104
+ if (!lo || !hi) return;
105
+ if (lo === hi) out.push(lo);
106
+ else if (lo.x <= hi.x) out.push(lo, hi);
107
+ else out.push(hi, lo);
108
+ };
109
+ for (const p of points) {
110
+ const idx = Math.min(n - 1, Math.max(0, Math.floor((p.x - xMin) / span * n)));
111
+ if (idx !== b) {
112
+ flush();
113
+ b = idx;
114
+ lo = p;
115
+ hi = p;
116
+ } else {
117
+ if (lo && p.y < lo.y) lo = p;
118
+ if (hi && p.y > hi.y) hi = p;
119
+ }
120
+ }
121
+ flush();
122
+ return out;
123
+ }
124
+ var NUMBER_FORMATS = /* @__PURE__ */ new Map();
125
+ function chartNumber(v, locale = "en-US") {
126
+ let f = NUMBER_FORMATS.get(locale);
127
+ if (!f) {
128
+ f = {
129
+ whole: new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }),
130
+ small: new Intl.NumberFormat(locale, { maximumFractionDigits: 2, useGrouping: false })
131
+ };
132
+ NUMBER_FORMATS.set(locale, f);
133
+ }
134
+ if (Math.abs(v) >= 1e3) return f.whole.format(v);
135
+ return f.small.format(Math.round(v * 100) / 100 || 0);
136
+ }
137
+ var warned = /* @__PURE__ */ new Set();
138
+ function warnOnce(key, message) {
139
+ const env = globalThis.process?.env;
140
+ if (env?.NODE_ENV === "production" || warned.has(key)) return;
141
+ warned.add(key);
142
+ console.warn(`nish-ui: ${message}`);
143
+ }
144
+ export {
145
+ FAVICON_HUES,
146
+ chartNumber,
147
+ compareValues,
148
+ configureFavicons,
149
+ decimateMinMax,
150
+ getFaviconResolver,
151
+ googleFavicon,
152
+ hashString,
153
+ hostnameOf,
154
+ mergeRefs,
155
+ sortRows,
156
+ tableClass,
157
+ tableInternals,
158
+ warnOnce
159
+ };