nish-ui 1.9.0 → 2.0.1

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 +218 -58
  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 +71 -0
  9. package/dist/elements-charts.js +56 -57
  10. package/dist/elements-data.d.ts +71 -0
  11. package/dist/elements-data.js +5 -6
  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 +1461 -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 +1686 -667
  110. package/dist/nish-components.css +4649 -4506
  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 +243 -4
  130. package/dist/theme.global.js +356 -89
  131. package/dist/theme.js +337 -67
  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,419 @@
1
+ // src/split-layout.ts
2
+ var MAX_PANES = 4;
3
+ var NARROW_MAX = 2;
4
+ var NARROW_BREAKPOINT = 640;
5
+ var leaf = (slot) => ({ type: "leaf", slot });
6
+ var row = (sizes, children) => ({
7
+ type: "split",
8
+ dir: "row",
9
+ sizes,
10
+ children
11
+ });
12
+ var col = (sizes, children) => ({
13
+ type: "split",
14
+ dir: "col",
15
+ sizes,
16
+ children
17
+ });
18
+ var equal = (n) => Array.from({ length: n }, () => 1 / n);
19
+ var leaves = (...slots) => slots.map(leaf);
20
+ function presetsFor(count) {
21
+ switch (count) {
22
+ case 1:
23
+ return [
24
+ {
25
+ id: "single",
26
+ label: "Single",
27
+ hint: "One stream",
28
+ build: () => leaf(0)
29
+ }
30
+ ];
31
+ case 2:
32
+ return [
33
+ {
34
+ id: "side",
35
+ label: "Slice",
36
+ hint: "Side by side",
37
+ build: () => row([0.5, 0.5], leaves(0, 1))
38
+ },
39
+ {
40
+ id: "stack",
41
+ label: "Stack",
42
+ hint: "One above the other",
43
+ build: () => col([0.5, 0.5], leaves(0, 1))
44
+ },
45
+ {
46
+ id: "main-side",
47
+ label: "Main 1",
48
+ hint: "One big, one small on the right",
49
+ build: () => row([0.7, 0.3], leaves(0, 1))
50
+ }
51
+ ];
52
+ case 3:
53
+ return [
54
+ {
55
+ id: "main-right",
56
+ label: "Main 1",
57
+ hint: "One big, two on the right",
58
+ build: () => row([0.66, 0.34], [leaf(0), col([0.5, 0.5], leaves(1, 2))])
59
+ },
60
+ {
61
+ id: "main-bottom",
62
+ label: "Main 2",
63
+ hint: "One big, two below",
64
+ build: () => col([0.66, 0.34], [leaf(0), row([0.5, 0.5], leaves(1, 2))])
65
+ },
66
+ {
67
+ id: "cols-3",
68
+ label: "Slice",
69
+ hint: "Three side by side",
70
+ build: () => row(equal(3), leaves(0, 1, 2))
71
+ },
72
+ {
73
+ id: "rows-3",
74
+ label: "Stack",
75
+ hint: "Three stacked",
76
+ build: () => col(equal(3), leaves(0, 1, 2))
77
+ }
78
+ ];
79
+ case 4:
80
+ return [
81
+ {
82
+ id: "grid",
83
+ label: "Grid",
84
+ hint: "Two by two",
85
+ build: () => col(
86
+ [0.5, 0.5],
87
+ [row([0.5, 0.5], leaves(0, 1)), row([0.5, 0.5], leaves(2, 3))]
88
+ )
89
+ },
90
+ {
91
+ id: "main-right",
92
+ label: "Main 1",
93
+ hint: "One big, three on the right",
94
+ build: () => row([0.7, 0.3], [leaf(0), col(equal(3), leaves(1, 2, 3))])
95
+ },
96
+ {
97
+ id: "main-bottom",
98
+ label: "Main 2",
99
+ hint: "One big, three below",
100
+ build: () => col([0.7, 0.3], [leaf(0), row(equal(3), leaves(1, 2, 3))])
101
+ },
102
+ {
103
+ id: "cols-4",
104
+ label: "Slice",
105
+ hint: "Four side by side",
106
+ build: () => row(equal(4), leaves(0, 1, 2, 3))
107
+ }
108
+ ];
109
+ }
110
+ }
111
+ function defaultPreset(count, aspect) {
112
+ switch (count) {
113
+ case 1:
114
+ return "single";
115
+ case 2:
116
+ return aspect >= 1 ? "side" : "stack";
117
+ case 3:
118
+ return aspect >= 1 ? "main-right" : "main-bottom";
119
+ case 4:
120
+ return "grid";
121
+ }
122
+ }
123
+ function slotMax(node) {
124
+ if (node.type === "leaf") return node.slot;
125
+ return node.children.reduce((m, c) => Math.max(m, slotMax(c)), -1);
126
+ }
127
+ function countLeaves(node) {
128
+ if (!node) return 0;
129
+ if (node.type === "leaf") return 1;
130
+ return node.children.reduce((n, c) => n + countLeaves(c), 0);
131
+ }
132
+ function childExtents(node, total, gap) {
133
+ const n = node.children.length;
134
+ const room = Math.max(0, total - gap * (n - 1));
135
+ const out = [];
136
+ let used = 0;
137
+ for (let i = 0; i < n; i++) {
138
+ if (i === n - 1) {
139
+ out.push(room - used);
140
+ } else {
141
+ const size = Math.max(
142
+ 0,
143
+ Math.min(room - used, Math.round((node.sizes[i] ?? 0) * room))
144
+ );
145
+ out.push(size);
146
+ used += size;
147
+ }
148
+ }
149
+ return out;
150
+ }
151
+ function walk(node, rect, gap, onLeaf, onDivider, path = []) {
152
+ if (node.type === "leaf") {
153
+ onLeaf(node.slot, rect);
154
+ return;
155
+ }
156
+ const horizontal = node.dir === "row";
157
+ const extents = childExtents(node, horizontal ? rect.w : rect.h, gap);
158
+ let pos = horizontal ? rect.x : rect.y;
159
+ node.children.forEach((child, i) => {
160
+ const size = extents[i] ?? 0;
161
+ const childRect = horizontal ? { x: pos, y: rect.y, w: size, h: rect.h } : { x: rect.x, y: pos, w: rect.w, h: size };
162
+ walk(child, childRect, gap, onLeaf, onDivider, [...path, i]);
163
+ if (onDivider && i < node.children.length - 1) {
164
+ onDivider({
165
+ path,
166
+ index: i,
167
+ dir: node.dir,
168
+ x: horizontal ? pos + size : rect.x,
169
+ y: horizontal ? rect.y : pos + size,
170
+ w: horizontal ? gap : rect.w,
171
+ h: horizontal ? rect.h : gap
172
+ });
173
+ }
174
+ pos += size + gap;
175
+ });
176
+ }
177
+ function computeRects(node, w, h, gap) {
178
+ const rects = Array.from({ length: slotMax(node) + 1 }, () => ({
179
+ x: 0,
180
+ y: 0,
181
+ w: 0,
182
+ h: 0
183
+ }));
184
+ walk(
185
+ node,
186
+ { x: 0, y: 0, w: Math.round(w), h: Math.round(h) },
187
+ gap,
188
+ (slot, r) => {
189
+ rects[slot] = r;
190
+ }
191
+ );
192
+ return rects;
193
+ }
194
+ function computeDividers(node, w, h, gap) {
195
+ const out = [];
196
+ walk(
197
+ node,
198
+ { x: 0, y: 0, w: Math.round(w), h: Math.round(h) },
199
+ gap,
200
+ () => {
201
+ },
202
+ (d) => out.push(d)
203
+ );
204
+ return out;
205
+ }
206
+ function minExtent(node, axis, gap, min) {
207
+ if (node.type === "leaf") return axis === "row" ? min.w : min.h;
208
+ const parts = node.children.map((c) => minExtent(c, axis, gap, min));
209
+ if (node.dir === axis)
210
+ return parts.reduce((a, b) => a + b, 0) + gap * (node.children.length - 1);
211
+ return parts.reduce((a, b) => Math.max(a, b), 0);
212
+ }
213
+ function resizeAt(node, path, index, deltaPx, w, h, gap, minPx = { w: 160, h: 90 }) {
214
+ let cur = node;
215
+ let cw = w;
216
+ let ch = h;
217
+ for (const p of path) {
218
+ if (cur.type !== "split") return node;
219
+ const child = cur.children[p];
220
+ if (!child) return node;
221
+ const horizontal = cur.dir === "row";
222
+ const room2 = Math.max(
223
+ 0,
224
+ (horizontal ? cw : ch) - gap * (cur.children.length - 1)
225
+ );
226
+ const share = (cur.sizes[p] ?? 0) * room2;
227
+ if (horizontal) cw = share;
228
+ else ch = share;
229
+ cur = child;
230
+ }
231
+ if (cur.type !== "split") return node;
232
+ const target = cur;
233
+ const a = target.children[index];
234
+ const b = target.children[index + 1];
235
+ const sa = target.sizes[index];
236
+ const sb = target.sizes[index + 1];
237
+ if (!a || !b || sa === void 0 || sb === void 0) return node;
238
+ const room = Math.max(
239
+ 0,
240
+ (target.dir === "row" ? cw : ch) - gap * (target.children.length - 1)
241
+ );
242
+ if (room <= 0) return node;
243
+ const pxA = sa * room;
244
+ const pxB = sb * room;
245
+ const minA = minExtent(a, target.dir, gap, minPx);
246
+ const minB = minExtent(b, target.dir, gap, minPx);
247
+ const lo = minA - pxA;
248
+ const hi = pxB - minB;
249
+ let delta = deltaPx;
250
+ if (lo > hi) delta = 0;
251
+ else delta = Math.min(hi, Math.max(lo, delta));
252
+ const newA = pxA + delta;
253
+ const pair = sa + sb;
254
+ const fracA = pair * newA / (pxA + pxB);
255
+ const sizes = target.sizes.slice();
256
+ sizes[index] = fracA;
257
+ sizes[index + 1] = pair - fracA;
258
+ const replace = (n, depth) => {
259
+ if (n.type === "leaf") return n;
260
+ if (depth === path.length) return { ...n, sizes, children: n.children };
261
+ const p = path[depth];
262
+ return {
263
+ ...n,
264
+ children: n.children.map((c, i) => i === p ? replace(c, depth + 1) : c)
265
+ };
266
+ };
267
+ return replace(node, 0);
268
+ }
269
+ function equalize(node) {
270
+ if (node.type === "leaf") return node;
271
+ return {
272
+ ...node,
273
+ sizes: equal(node.children.length),
274
+ children: node.children.map(equalize)
275
+ };
276
+ }
277
+ function normalize(node) {
278
+ const sizes = [];
279
+ const children = [];
280
+ node.children.forEach((child, i) => {
281
+ const s = node.sizes[i] ?? 0;
282
+ if (child.type === "split" && child.dir === node.dir) {
283
+ child.children.forEach((gc, j) => {
284
+ children.push(gc);
285
+ sizes.push(s * (child.sizes[j] ?? 0));
286
+ });
287
+ } else {
288
+ children.push(child);
289
+ sizes.push(s);
290
+ }
291
+ });
292
+ return { ...node, sizes, children };
293
+ }
294
+ function removeSlot(node, slot) {
295
+ if (node.type === "leaf") {
296
+ if (node.slot === slot) return null;
297
+ return node.slot > slot ? leaf(node.slot - 1) : node;
298
+ }
299
+ const kept = [];
300
+ const keptSizes = [];
301
+ let removed = 0;
302
+ node.children.forEach((child, i) => {
303
+ const next = removeSlot(child, slot);
304
+ const s = node.sizes[i] ?? 0;
305
+ if (next === null) removed += s;
306
+ else {
307
+ kept.push(next);
308
+ keptSizes.push(s);
309
+ }
310
+ });
311
+ if (kept.length === 0) return null;
312
+ const rest = 1 - removed;
313
+ const sizes = removed > 0 && rest > 0 ? keptSizes.map((s) => s / rest) : keptSizes;
314
+ if (kept.length === 1) return kept[0];
315
+ return normalize({ ...node, sizes, children: kept });
316
+ }
317
+ function addSlot(node, w, h, gap) {
318
+ if (!node) return leaf(0);
319
+ const count = countLeaves(node);
320
+ const rects = computeRects(node, w, h, gap);
321
+ let best = 0;
322
+ let bestArea = -1;
323
+ rects.forEach((r2, slot) => {
324
+ const area = r2.w * r2.h;
325
+ if (area > bestArea) {
326
+ best = slot;
327
+ bestArea = area;
328
+ }
329
+ });
330
+ const r = rects[best];
331
+ const dir = r.w >= r.h ? "row" : "col";
332
+ const fresh = leaf(count);
333
+ const rec = (n) => {
334
+ if (n.type === "leaf") {
335
+ return n.slot === best ? { type: "split", dir, sizes: [0.5, 0.5], children: [n, fresh] } : n;
336
+ }
337
+ const idx = n.children.findIndex(
338
+ (c) => c.type === "leaf" && c.slot === best
339
+ );
340
+ if (idx >= 0 && n.dir === dir) {
341
+ const children = n.children.slice();
342
+ const sizes = n.sizes.slice();
343
+ const half = (sizes[idx] ?? 0) / 2;
344
+ children.splice(idx + 1, 0, fresh);
345
+ sizes.splice(idx, 1, half, half);
346
+ return { ...n, sizes, children };
347
+ }
348
+ return { ...n, children: n.children.map(rec) };
349
+ };
350
+ return rec(node);
351
+ }
352
+ function swapSlots(slots, a, b) {
353
+ const out = slots.slice();
354
+ const x = out[a];
355
+ const y = out[b];
356
+ if (x === void 0 || y === void 0) return out;
357
+ out[a] = y;
358
+ out[b] = x;
359
+ return out;
360
+ }
361
+ function narrowLayout(count, n, aspect) {
362
+ if (count === 1) return leaf(0);
363
+ const dir = n.dir === "auto" ? aspect >= 1.2 ? "row" : "col" : n.dir;
364
+ const split = Math.min(0.8, Math.max(0.2, n.split));
365
+ return {
366
+ type: "split",
367
+ dir,
368
+ sizes: [split, 1 - split],
369
+ children: leaves(0, 1)
370
+ };
371
+ }
372
+ var MAX_DEPTH = 8;
373
+ function isValidLayout(node, count) {
374
+ if (node === null) return count === 0;
375
+ const seen = [];
376
+ const ok = (n, depth) => {
377
+ if (depth > MAX_DEPTH || typeof n !== "object" || n === null) return false;
378
+ const x = n;
379
+ if (x.type === "leaf") {
380
+ if (typeof x.slot !== "number" || !Number.isInteger(x.slot)) return false;
381
+ seen.push(x.slot);
382
+ return true;
383
+ }
384
+ if (x.type !== "split") return false;
385
+ if (x.dir !== "row" && x.dir !== "col") return false;
386
+ if (!Array.isArray(x.children) || !Array.isArray(x.sizes)) return false;
387
+ if (x.children.length === 0 || x.children.length !== x.sizes.length)
388
+ return false;
389
+ let sum = 0;
390
+ for (const s of x.sizes) {
391
+ if (typeof s !== "number" || !Number.isFinite(s) || s < 0.02 || s > 1)
392
+ return false;
393
+ sum += s;
394
+ }
395
+ if (Math.abs(sum - 1) > 1e-6) return false;
396
+ return x.children.every((c) => ok(c, depth + 1));
397
+ };
398
+ if (!ok(node, 0)) return false;
399
+ if (seen.length !== count) return false;
400
+ const sorted = seen.slice().sort((a, b) => a - b);
401
+ return sorted.every((s, i) => s === i);
402
+ }
403
+ export {
404
+ MAX_PANES,
405
+ NARROW_BREAKPOINT,
406
+ NARROW_MAX,
407
+ addSlot,
408
+ computeDividers,
409
+ computeRects,
410
+ countLeaves,
411
+ defaultPreset,
412
+ equalize,
413
+ isValidLayout,
414
+ narrowLayout,
415
+ presetsFor,
416
+ removeSlot,
417
+ resizeAt,
418
+ swapSlots
419
+ };
@@ -0,0 +1,2 @@
1
+ // src/system-canvas.ts
2
+ export * from "./components/canvas/index.js";