@brett_lamy/ui 5.13.0 → 5.15.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 (118) hide show
  1. package/dist/components/call-stack.d.ts +26 -0
  2. package/dist/components/call-stack.d.ts.map +1 -0
  3. package/dist/components/call-stack.js +236 -0
  4. package/dist/components/code-editor-window.d.ts +191 -0
  5. package/dist/components/code-editor-window.d.ts.map +1 -0
  6. package/dist/components/code-editor-window.js +1474 -0
  7. package/dist/components/code-editor.d.ts +213 -0
  8. package/dist/components/code-editor.d.ts.map +1 -0
  9. package/dist/components/code-editor.js +484 -0
  10. package/dist/components/file-upload.d.ts +1 -1
  11. package/dist/components/file-upload.d.ts.map +1 -1
  12. package/dist/components/file-upload.js +1 -1
  13. package/dist/components/filter-input.d.ts +1 -1
  14. package/dist/components/filter-input.d.ts.map +1 -1
  15. package/dist/components/filter-input.js +1 -1
  16. package/dist/components/filter.d.ts +1 -1
  17. package/dist/components/filter.d.ts.map +1 -1
  18. package/dist/components/filter.js +1 -1
  19. package/dist/components/log-list.d.ts +95 -0
  20. package/dist/components/log-list.d.ts.map +1 -0
  21. package/dist/components/log-list.js +549 -0
  22. package/dist/components/object-tree.d.ts +30 -0
  23. package/dist/components/object-tree.d.ts.map +1 -0
  24. package/dist/components/object-tree.js +415 -0
  25. package/dist/components/object-value.d.ts +13 -0
  26. package/dist/components/object-value.d.ts.map +1 -0
  27. package/dist/components/object-value.js +69 -0
  28. package/dist/components/request-table.d.ts +78 -0
  29. package/dist/components/request-table.d.ts.map +1 -0
  30. package/dist/components/request-table.js +697 -0
  31. package/dist/components/spreadsheet.d.ts +1 -1
  32. package/dist/components/spreadsheet.d.ts.map +1 -1
  33. package/dist/components/spreadsheet.js +1 -1
  34. package/dist/components/syntax-highlighting.d.ts +45 -77
  35. package/dist/components/syntax-highlighting.d.ts.map +1 -1
  36. package/dist/components/syntax-highlighting.js +36 -275
  37. package/dist/components/terminal.d.ts +62 -0
  38. package/dist/components/terminal.d.ts.map +1 -0
  39. package/dist/components/terminal.js +172 -0
  40. package/dist/components/trace-timeline.d.ts +97 -0
  41. package/dist/components/trace-timeline.d.ts.map +1 -0
  42. package/dist/components/trace-timeline.js +850 -0
  43. package/dist/components/tree.d.ts.map +1 -1
  44. package/dist/components/tree.js +99 -91
  45. package/dist/components/video-preview.d.ts +1 -1
  46. package/dist/components/video-preview.d.ts.map +1 -1
  47. package/dist/components/video-preview.js +1 -1
  48. package/dist/components/video-timeline.d.ts +1 -1
  49. package/dist/components/video-timeline.d.ts.map +1 -1
  50. package/dist/components/video-timeline.js +1 -1
  51. package/dist/components/workspace.d.ts.map +1 -1
  52. package/dist/components/workspace.js +1 -1
  53. package/dist/index.css +1 -1
  54. package/dist/index.d.ts +45 -11
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +119 -100
  57. package/dist/lib/call-stack-model.d.ts +75 -0
  58. package/dist/lib/call-stack-model.d.ts.map +1 -0
  59. package/dist/lib/call-stack-model.js +114 -0
  60. package/dist/lib/code-document.d.ts +229 -0
  61. package/dist/lib/code-document.d.ts.map +1 -0
  62. package/dist/lib/code-document.js +727 -0
  63. package/dist/lib/code-editor-gpu.d.ts +9 -0
  64. package/dist/lib/code-editor-gpu.d.ts.map +1 -0
  65. package/dist/lib/code-editor-gpu.js +23 -0
  66. package/dist/lib/code-editor-model.d.ts +371 -0
  67. package/dist/lib/code-editor-model.d.ts.map +1 -0
  68. package/dist/lib/code-editor-model.js +1105 -0
  69. package/dist/lib/{file-upload.d.ts → file-upload-model.d.ts} +1 -1
  70. package/dist/lib/file-upload-model.d.ts.map +1 -0
  71. package/dist/lib/{file-upload.js → file-upload-model.js} +1 -1
  72. package/dist/lib/{filter.d.ts → filter-model.d.ts} +1 -1
  73. package/dist/lib/filter-model.d.ts.map +1 -0
  74. package/dist/lib/{filter.js → filter-model.js} +1 -1
  75. package/dist/lib/filter-query.d.ts +1 -1
  76. package/dist/lib/filter-query.d.ts.map +1 -1
  77. package/dist/lib/filter-query.js +1 -1
  78. package/dist/lib/log-list-model.d.ts +132 -0
  79. package/dist/lib/log-list-model.d.ts.map +1 -0
  80. package/dist/lib/log-list-model.js +214 -0
  81. package/dist/lib/log-list-window.d.ts +121 -0
  82. package/dist/lib/log-list-window.d.ts.map +1 -0
  83. package/dist/lib/log-list-window.js +245 -0
  84. package/dist/lib/object-tree-model.d.ts +162 -0
  85. package/dist/lib/object-tree-model.d.ts.map +1 -0
  86. package/dist/lib/object-tree-model.js +347 -0
  87. package/dist/lib/object-tree-value.d.ts +139 -0
  88. package/dist/lib/object-tree-value.d.ts.map +1 -0
  89. package/dist/lib/object-tree-value.js +410 -0
  90. package/dist/lib/request-table-model.d.ts +85 -0
  91. package/dist/lib/request-table-model.d.ts.map +1 -0
  92. package/dist/lib/request-table-model.js +105 -0
  93. package/dist/lib/{spreadsheet.d.ts → spreadsheet-model.d.ts} +1 -1
  94. package/dist/lib/spreadsheet-model.d.ts.map +1 -0
  95. package/dist/lib/{spreadsheet.js → spreadsheet-model.js} +1 -1
  96. package/dist/lib/syntax.d.ts +19 -7
  97. package/dist/lib/syntax.d.ts.map +1 -1
  98. package/dist/lib/syntax.js +54 -50
  99. package/dist/lib/terminal-line.d.ts +155 -0
  100. package/dist/lib/terminal-line.d.ts.map +1 -0
  101. package/dist/lib/terminal-line.js +463 -0
  102. package/dist/lib/trace-timeline-draw.d.ts +109 -0
  103. package/dist/lib/trace-timeline-draw.d.ts.map +1 -0
  104. package/dist/lib/trace-timeline-draw.js +252 -0
  105. package/dist/lib/trace-timeline-model.d.ts +324 -0
  106. package/dist/lib/trace-timeline-model.d.ts.map +1 -0
  107. package/dist/lib/trace-timeline-model.js +510 -0
  108. package/dist/lib/video-render.d.ts +1 -1
  109. package/dist/lib/video-render.d.ts.map +1 -1
  110. package/dist/lib/video-render.js +1 -1
  111. package/dist/lib/{video-timeline.d.ts → video-timeline-model.d.ts} +1 -1
  112. package/dist/lib/video-timeline-model.d.ts.map +1 -0
  113. package/dist/lib/{video-timeline.js → video-timeline-model.js} +1 -1
  114. package/package.json +7 -1
  115. package/dist/lib/file-upload.d.ts.map +0 -1
  116. package/dist/lib/filter.d.ts.map +0 -1
  117. package/dist/lib/spreadsheet.d.ts.map +0 -1
  118. package/dist/lib/video-timeline.d.ts.map +0 -1
@@ -0,0 +1,697 @@
1
+ "use client";
2
+ import { cn as e } from "../lib/utils.js";
3
+ import { Icon as t } from "../lib/icon.js";
4
+ import { useControllableState as n } from "../lib/controllable-state.js";
5
+ import { DropdownMenu as r, DropdownMenuContent as i, DropdownMenuItem as a } from "./dropdown-menu.js";
6
+ import { Button as o } from "./button.js";
7
+ import { formatDuration as s } from "../lib/sql-format.js";
8
+ import { rowKeyTarget as c } from "../lib/log-list-model.js";
9
+ import { RowWindow as l, isRowPress as u, tabThroughGrid as d } from "../lib/log-list-window.js";
10
+ import { clampColumnWidth as f, columnTemplate as p, isRequestFailed as m, nextRequestSort as h, playheadShare as g, requestBar as _, requestDisplayName as v, requestDurationText as ee, requestSizeText as te, requestSortValue as ne, requestStatusText as y, requestTimeRange as re, requestTone as ie, sortRequests as ae } from "../lib/request-table-model.js";
11
+ import { memo as oe, useId as se, useImperativeHandle as ce, useLayoutEffect as b, useMemo as x, useRef as S, useState as C } from "react";
12
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
13
+ import { Button as D, composeRenderProps as O } from "react-aria-components";
14
+ import { cva as k } from "class-variance-authority";
15
+ import { mergeProps as le, useFocusRing as ue, useMove as de } from "react-aria";
16
+ //#region src/components/request-table.tsx
17
+ var fe = k("group/table relative flex h-full max-h-dvh w-full min-h-0 min-w-0 flex-col overflow-hidden rounded-panel bg-card text-card-foreground after:pointer-events-none after:absolute after:inset-0 after:z-3 after:rounded-[inherit] after:shadow-hairline after:content-['']", {
18
+ variants: { density: {
19
+ compact: "",
20
+ comfortable: ""
21
+ } },
22
+ defaultVariants: { density: "compact" }
23
+ }), pe = {
24
+ compact: {
25
+ table: 26,
26
+ stacked: 46
27
+ },
28
+ comfortable: {
29
+ table: 34,
30
+ stacked: 54
31
+ }
32
+ }, me = 28, he = 360, ge = {
33
+ name: {
34
+ id: "name",
35
+ title: "Name",
36
+ flex: 3,
37
+ minWidth: 160
38
+ },
39
+ url: {
40
+ id: "url",
41
+ title: "URL",
42
+ flex: 3,
43
+ minWidth: 200
44
+ },
45
+ method: {
46
+ id: "method",
47
+ title: "Method",
48
+ width: 66,
49
+ minWidth: 48
50
+ },
51
+ status: {
52
+ id: "status",
53
+ title: "Status",
54
+ width: 76,
55
+ minWidth: 48
56
+ },
57
+ type: {
58
+ id: "type",
59
+ title: "Type",
60
+ width: 72,
61
+ minWidth: 48,
62
+ hideBelow: 760
63
+ },
64
+ size: {
65
+ id: "size",
66
+ title: "Size",
67
+ width: 72,
68
+ minWidth: 48,
69
+ align: "end",
70
+ hideBelow: 640
71
+ },
72
+ duration: {
73
+ id: "duration",
74
+ title: "Time",
75
+ width: 72,
76
+ minWidth: 48,
77
+ align: "end"
78
+ },
79
+ waterfall: {
80
+ id: "waterfall",
81
+ title: "Waterfall",
82
+ label: "Start time",
83
+ flex: 2,
84
+ minWidth: 120
85
+ }
86
+ }, _e = [
87
+ "name",
88
+ "method",
89
+ "status",
90
+ "type",
91
+ "size",
92
+ "duration",
93
+ "waterfall"
94
+ ], ve = [
95
+ "absolute top-1/2 left-(--bar-left) h-2 w-(--bar-width) min-w-0.5 -translate-y-1/2 rounded-xs bg-primary",
96
+ "data-[tone=accent]:bg-chart-5 data-[tone=danger]:bg-destructive data-[tone=neutral]:bg-muted-foreground/60 data-[tone=success]:bg-success data-[tone=warning]:bg-warning",
97
+ "data-pending:opacity-50"
98
+ ].join(" "), A = [
99
+ "group/row absolute inset-x-0 top-0 isolate h-(--request-row) cursor-default text-caption outline-none",
100
+ "before:absolute before:inset-0 before:-z-1 before:content-[''] hover:before:bg-foreground/4 active:before:bg-foreground/8",
101
+ "after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border/60 after:content-['']",
102
+ "data-selected:before:bg-primary/16",
103
+ "group-data-focus-visible/grid:data-active:ring-2 group-data-focus-visible/grid:data-active:ring-ring group-data-focus-visible/grid:data-active:ring-inset"
104
+ ].join(" "), ye = `${A} grid grid-cols-(--request-cols) items-center data-future:*:opacity-45`, be = `${A} flex items-center gap-2 px-2 data-future:*:opacity-45`, j = "min-w-0 truncate px-2", M = `${j} text-end tabular-nums`, N = "min-w-0 truncate font-mono group-data-failed/row:text-destructive", P = "tabular-nums group-data-failed/row:text-destructive group-data-pending/row:text-muted-foreground", F = `${j} ${P}`, I = "text-muted-foreground", L = `${j} ${I}`, R = `${M} ${I}`, xe = "relative mx-2 h-full min-w-0", Se = "relative h-3 w-24 shrink-0 rounded-sm bg-secondary";
105
+ function z({ icon: n = "arrow-right", className: r, children: i, ...a }) {
106
+ return /* @__PURE__ */ T(D, {
107
+ "data-slot": "request-table-link",
108
+ className: O(r, (t) => e("inline-flex h-[18px] max-w-40 shrink-0 cursor-pointer items-center gap-0.5 rounded-md border-0 bg-primary/10 px-1.5 [font-family:inherit] text-caption2 font-medium whitespace-nowrap text-primary outline-none data-focus-visible:ring-2 data-focus-visible:ring-ring data-hovered:bg-primary/16 data-pressed:bg-primary/24", t)),
109
+ ...a,
110
+ children: O(i, (e) => /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("span", {
111
+ className: "min-w-0 truncate",
112
+ children: e
113
+ }), n ? /* @__PURE__ */ T(t, {
114
+ name: n,
115
+ size: 10,
116
+ sw: 2.4
117
+ }) : null] }))
118
+ });
119
+ }
120
+ function Ce(e, t, n, r, i) {
121
+ let a = _(e, t);
122
+ return /* @__PURE__ */ T("div", {
123
+ ...r,
124
+ "data-slot": "request-table-waterfall",
125
+ className: n,
126
+ children: a ? /* @__PURE__ */ T("div", {
127
+ "data-slot": "request-table-bar",
128
+ "data-tone": ie(e),
129
+ "data-pending": e.pending || void 0,
130
+ className: ve,
131
+ style: {
132
+ "--bar-left": `${a.left}%`,
133
+ "--bar-width": `${a.width}%`
134
+ }
135
+ }) : null
136
+ }, i);
137
+ }
138
+ var B = (e) => e.error ? `${e.url}\n${e.error}` : e.url;
139
+ function V(e) {
140
+ return e == null || e === !1 ? null : /* @__PURE__ */ T("span", {
141
+ "data-slot": "request-table-links",
142
+ "data-no-row-press": "",
143
+ className: "ms-auto flex shrink-0 items-center gap-1",
144
+ children: e
145
+ });
146
+ }
147
+ function H(e, t, n, r, i) {
148
+ let a = {
149
+ role: "gridcell",
150
+ "aria-colindex": t + 1,
151
+ "data-column": e.id
152
+ }, o = e.align === "end" ? M : j;
153
+ if (e.render) return /* @__PURE__ */ T("div", {
154
+ ...a,
155
+ className: o,
156
+ children: e.render(n)
157
+ }, e.id);
158
+ switch (e.id) {
159
+ case "name":
160
+ case "url": return /* @__PURE__ */ E("div", {
161
+ ...a,
162
+ className: "flex min-w-0 items-center gap-1.5 px-2",
163
+ children: [/* @__PURE__ */ T("span", {
164
+ "data-slot": "request-table-name",
165
+ title: B(n),
166
+ className: N,
167
+ children: e.id === "url" ? n.url : v(n)
168
+ }), V(i?.(n))]
169
+ }, e.id);
170
+ case "method": return /* @__PURE__ */ T("div", {
171
+ ...a,
172
+ className: L,
173
+ children: n.method
174
+ }, e.id);
175
+ case "status": return /* @__PURE__ */ T("div", {
176
+ ...a,
177
+ className: F,
178
+ children: y(n)
179
+ }, e.id);
180
+ case "type": return /* @__PURE__ */ T("div", {
181
+ ...a,
182
+ className: L,
183
+ children: n.type
184
+ }, e.id);
185
+ case "size": return /* @__PURE__ */ T("div", {
186
+ ...a,
187
+ className: R,
188
+ children: te(n)
189
+ }, e.id);
190
+ case "duration": return /* @__PURE__ */ T("div", {
191
+ ...a,
192
+ className: M,
193
+ children: ee(n)
194
+ }, e.id);
195
+ case "waterfall": return Ce(n, r, xe, a, e.id);
196
+ default: return /* @__PURE__ */ T("div", {
197
+ ...a,
198
+ className: o,
199
+ children: String(n[e.id] ?? "")
200
+ }, e.id);
201
+ }
202
+ }
203
+ function we({ row: e, index: t, domId: n, selected: r, active: i, stacked: a, columns: o, range: s, renderLink: c }) {
204
+ let l = {
205
+ role: "row",
206
+ id: n,
207
+ "aria-rowindex": t + 2,
208
+ "aria-selected": r,
209
+ "data-slot": "request-table-row",
210
+ "data-index": t,
211
+ "data-selected": r || void 0,
212
+ "data-active": i || void 0,
213
+ "data-failed": m(e) || void 0,
214
+ "data-pending": e.pending || void 0
215
+ };
216
+ if (a) {
217
+ let t = (e) => o.some((t) => t.id === e);
218
+ return /* @__PURE__ */ E("div", {
219
+ ...l,
220
+ className: be,
221
+ children: [/* @__PURE__ */ E("div", {
222
+ role: "gridcell",
223
+ className: "flex min-w-0 flex-1 flex-col gap-1",
224
+ children: [/* @__PURE__ */ T("span", {
225
+ "data-slot": "request-table-name",
226
+ title: B(e),
227
+ className: `${N} leading-[18px]`,
228
+ children: v(e)
229
+ }), /* @__PURE__ */ E("div", {
230
+ className: "flex h-[18px] min-w-0 items-center gap-2 text-caption2 whitespace-nowrap",
231
+ children: [
232
+ t("status") ? /* @__PURE__ */ T("span", {
233
+ className: P,
234
+ children: y(e)
235
+ }) : null,
236
+ t("method") ? /* @__PURE__ */ T("span", {
237
+ className: I,
238
+ children: e.method
239
+ }) : null,
240
+ t("duration") ? /* @__PURE__ */ T("span", {
241
+ className: "tabular-nums",
242
+ children: ee(e)
243
+ }) : null,
244
+ V(c?.(e))
245
+ ]
246
+ })]
247
+ }), t("waterfall") ? Ce(e, s, Se, { role: "gridcell" }) : null]
248
+ });
249
+ }
250
+ return /* @__PURE__ */ T("div", {
251
+ ...l,
252
+ className: ye,
253
+ children: o.map((t, n) => H(t, n, e, s, c))
254
+ });
255
+ }
256
+ var Te = oe(we);
257
+ function Ee({ column: n, index: r, domId: i, sort: a, active: o, width: c, span: l, onSort: u, onWidth: d }) {
258
+ let p = S(null), m = S(0), { moveProps: h } = de({
259
+ onMoveStart() {
260
+ m.current = p.current?.getBoundingClientRect().width ?? c ?? 80;
261
+ },
262
+ onMove(e) {
263
+ m.current += e.deltaX, d(n, f(n, m.current));
264
+ }
265
+ }), g = a?.column === n.id ? a.direction : null, _ = n.id === "waterfall", v = /* @__PURE__ */ E(w, { children: [
266
+ /* @__PURE__ */ T("span", {
267
+ className: "min-w-0 truncate",
268
+ children: n.title ?? n.label ?? n.id
269
+ }),
270
+ g ? /* @__PURE__ */ T(t, {
271
+ name: g === "ascending" ? "arrow-up" : "arrow-down",
272
+ size: 10,
273
+ sw: 2.6,
274
+ className: "shrink-0 text-foreground"
275
+ }) : null,
276
+ _ && l > 0 ? /* @__PURE__ */ T("span", {
277
+ "data-slot": "request-table-span",
278
+ className: "ms-auto shrink-0 font-normal tabular-nums",
279
+ children: s(l)
280
+ }) : null
281
+ ] });
282
+ return /* @__PURE__ */ E("div", {
283
+ ref: p,
284
+ id: i,
285
+ role: "columnheader",
286
+ "aria-colindex": r + 1,
287
+ "aria-sort": g ?? (n.sortable ? "none" : void 0),
288
+ "data-slot": "request-table-column",
289
+ "data-column": n.id,
290
+ "data-active": o || void 0,
291
+ className: "group/column relative flex h-(--request-header) min-w-0 items-center text-caption font-semibold whitespace-nowrap text-foreground/65 outline-none group-data-focus-visible/grid:data-active:ring-2 group-data-focus-visible/grid:data-active:ring-ring group-data-focus-visible/grid:data-active:ring-inset",
292
+ children: [n.sortable ? /* @__PURE__ */ T(D, {
293
+ excludeFromTabOrder: !0,
294
+ preventFocusOnPress: !0,
295
+ onPress: () => u(n.id),
296
+ className: e("flex h-full min-w-0 flex-1 cursor-default items-center gap-1 border-0 bg-transparent px-2 [font-family:inherit] text-caption font-semibold text-foreground/65 outline-none data-hovered:text-foreground", n.align === "end" && "justify-end"),
297
+ children: v
298
+ }) : /* @__PURE__ */ T("div", {
299
+ className: e("flex min-w-0 flex-1 items-center gap-1 px-2", n.align === "end" && "justify-end"),
300
+ children: v
301
+ }), /* @__PURE__ */ T("div", {
302
+ ...le(h, { onDoubleClick: () => d(n, -1) }),
303
+ role: "separator",
304
+ "aria-orientation": "vertical",
305
+ "aria-label": `Resize ${typeof n.title == "string" ? n.title : Ae(n)}`,
306
+ "aria-valuenow": c,
307
+ "data-slot": "request-table-resizer",
308
+ className: "absolute inset-y-0 -end-1 z-1 w-2 cursor-col-resize touch-none after:absolute after:inset-y-1.5 after:start-[3.5px] after:w-px after:bg-border after:content-[''] hover:after:bg-primary"
309
+ })]
310
+ });
311
+ }
312
+ var U = class {
313
+ win = new l({
314
+ estimate: pe.compact.table,
315
+ measure: !1,
316
+ overscan: he
317
+ });
318
+ root = null;
319
+ line = null;
320
+ time = null;
321
+ range = [0, 1];
322
+ drawnHeight = -1;
323
+ constructor() {
324
+ this.win.insetTop = me, this.win.decorate = this.decorate, this.win.onLayout = () => {
325
+ let e = this.win.height;
326
+ e === this.drawnHeight || !this.root || (this.drawnHeight = e, this.root.style.setProperty("--request-view", `${e}px`));
327
+ };
328
+ }
329
+ decorate = (e, t) => {
330
+ let n = this.win.rows[t]?.time;
331
+ e.toggleAttribute("data-future", this.time !== null && n !== void 0 && n > this.time);
332
+ };
333
+ setLine = (e) => {
334
+ this.line = e, e && this.drawLine();
335
+ };
336
+ drawLine() {
337
+ let e = g(this.time, this.range);
338
+ this.root?.toggleAttribute("data-playhead", e !== null), e !== null && this.line?.style.setProperty("--request-playhead", String(e));
339
+ }
340
+ set(e, t = this.range) {
341
+ let n = e !== this.time;
342
+ this.time = e, this.range = t, this.drawLine(), n && this.win.decorateAll();
343
+ }
344
+ }, De = {
345
+ start: 0,
346
+ end: 0
347
+ };
348
+ function W({ playhead: s, handlers: l, gridRef: m, range: g, rows: _, columns: v = _e, selectedId: ee, defaultSelectedId: te, renderLink: y, sort: re, defaultSort: ie, columnWidths: oe, defaultColumnWidths: ce, layout: w = "auto", stackBelow: D = 480, emptyState: O, footer: k, density: le, className: de, style: he, onKeyDown: ve, onFocus: A, "aria-label": ye = "Requests", ...be }) {
349
+ let { win: j } = s, [M, N] = C(De), [P, F] = C(0), I = S(null), L = S(null), R = se(), { isFocusVisible: xe, focusProps: Se } = ue(), [z, Ce] = n(ee, te ?? null, (e) => l.current.onSelectionChange?.(e)), [B, V] = n(re, ie ?? null, (e) => l.current.onSortChange?.(e)), [H, we] = n(oe, ce ?? Oe, (e) => l.current.onColumnWidthsChange?.(e)), [U, W] = C(null), [Me, G] = C(null), K = w === "stacked" || w === "auto" && P > 0 && P < D, q = K ? null : Me, Ne = pe[le ?? "compact"][K ? "stacked" : "table"], Pe = v.every((e) => typeof e == "string") ? v.join() : v, J = x(() => v.map((e) => {
350
+ let t = typeof e == "string" ? { id: e } : e, n = {
351
+ ...ge[t.id],
352
+ ...t
353
+ };
354
+ return {
355
+ ...n,
356
+ sortable: n.sortable ?? (!n.render || !!n.sortValue)
357
+ };
358
+ }), [Pe]), Fe = J.filter((e) => !e.hideBelow || !P || P >= e.hideBelow).map((e) => e.id).join(), Y = x(() => {
359
+ let e = new Set(Fe.split(","));
360
+ return J.filter((t) => e.has(t.id));
361
+ }, [J, Fe]), { template: Ie, minWidth: Le } = x(() => p(Y, H), [Y, H]), X = x(() => {
362
+ let e = B && J.find((e) => e.id === B.column)?.sortValue;
363
+ return ae(_, B, e ?? ne);
364
+ }, [
365
+ _,
366
+ B,
367
+ J
368
+ ]);
369
+ b(() => {
370
+ j.onRange = N, j.onWidth = (e) => F(e), s.root = I.current;
371
+ let e = m.current;
372
+ if (!e || !L.current) return;
373
+ let t = j.attach(e, L.current);
374
+ return F(e.clientWidth), t;
375
+ }, [
376
+ j,
377
+ m,
378
+ s
379
+ ]), b(() => {
380
+ j.setFixedHeight(Ne);
381
+ }, [j, Ne]), b(() => {
382
+ j.setRows(X);
383
+ }, [j, X]), b(() => {
384
+ j.sync();
385
+ });
386
+ let Re = S(B);
387
+ b(() => {
388
+ if (Re.current === B) return;
389
+ Re.current = B;
390
+ let e = z === null ? -1 : j.ids.indexOf(z);
391
+ e >= 0 ? j.scrollToIndex(e, "center", "effect") : j.scrollToIndex(0, "start", "effect");
392
+ }, [
393
+ B,
394
+ z,
395
+ j
396
+ ]);
397
+ let ze = S(null);
398
+ b(() => {
399
+ if (z === ze.current || (ze.current = z, z === null)) return;
400
+ let e = j.ids.indexOf(z);
401
+ e >= 0 && !j.isVisible(e) && j.scrollToIndex(e, "center", "effect");
402
+ }, [z, j]);
403
+ let Be = (e) => `${R}-${e}`, Ve = (e) => `${R}-h${e}`, Z = U === null ? -1 : j.indexIn(X, U), He = z === null ? -1 : j.indexIn(X, z), Ue = (e) => e >= M.start && e < Math.min(M.end, X.length), We = (e) => {
404
+ let t = X[e];
405
+ W(t.id), G(null), Ce(t.id), l.current.onRowPress?.(t, e);
406
+ }, Ge = (e) => {
407
+ let t = j.indexFrom(e.target);
408
+ t >= 0 && u(e) && We(t);
409
+ }, Q = () => He >= 0 && j.isVisible(He) ? He : j.heights.indexAt(j.scrollTop), Ke = (e, t) => {
410
+ let n = Y[t];
411
+ switch (e.key) {
412
+ case "ArrowLeft":
413
+ case "ArrowRight": {
414
+ let r = e.key === "ArrowLeft" ? -1 : 1;
415
+ if (e.altKey) {
416
+ let t = m.current?.querySelector(`[role=columnheader][data-column="${n.id}"]`)?.getBoundingClientRect().width ?? 80;
417
+ je(H, we, n.id, f(n, t + r * (e.shiftKey ? 48 : 12)));
418
+ } else G(Math.max(0, Math.min(Y.length - 1, t + r)));
419
+ break;
420
+ }
421
+ case "Escape":
422
+ G(null);
423
+ break;
424
+ case "Home":
425
+ G(0);
426
+ break;
427
+ case "End":
428
+ G(Y.length - 1);
429
+ break;
430
+ case "Enter":
431
+ case " ":
432
+ n.sortable && V(h(B, n.id));
433
+ break;
434
+ case "ArrowDown":
435
+ if (X.length) {
436
+ G(null);
437
+ let e = Z >= 0 ? Z : Q();
438
+ W(X[e].id), j.scrollToIndex(e);
439
+ }
440
+ break;
441
+ default: return;
442
+ }
443
+ e.preventDefault();
444
+ }, qe = (e) => {
445
+ if (ve?.(e), e.defaultPrevented) return;
446
+ if (e.key === "Tab") {
447
+ d(e, q === null && Z >= 0 ? j.elementAt(Z) : void 0);
448
+ return;
449
+ }
450
+ let t = e.currentTarget;
451
+ if (e.target !== t) {
452
+ e.key === "Escape" && (t.focus(), e.preventDefault());
453
+ return;
454
+ }
455
+ if (q !== null) {
456
+ Ke(e, Math.min(q, Y.length - 1));
457
+ return;
458
+ }
459
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
460
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
461
+ j.scrollLeftBy(e.key === "ArrowLeft" ? -48 : 48), e.preventDefault();
462
+ return;
463
+ }
464
+ if (!X.length) {
465
+ e.key === "ArrowUp" && !K && (G(0), e.preventDefault());
466
+ return;
467
+ }
468
+ let n = Z >= 0 ? Z : Q();
469
+ if (e.key === "Enter" || e.key === " ") {
470
+ We(n), e.preventDefault();
471
+ return;
472
+ }
473
+ if (e.key === "ArrowUp" && n === 0 && Z === 0 && !K) {
474
+ G(0), e.preventDefault();
475
+ return;
476
+ }
477
+ let r = Z < 0 && (e.key === "ArrowDown" || e.key === "ArrowUp") ? n : c(e.key, n, X.length, (e) => j.heights.indexAt(j.heights.offsetOf(n) + e * j.view));
478
+ r !== null && (e.preventDefault(), W(X[r].id), j.scrollToIndex(r));
479
+ }, Je = (e) => {
480
+ Se.onFocus?.(e), A?.(e), e.target === e.currentTarget && U === null && q === null && X.length && W(X[Q()].id);
481
+ }, $ = _.length, Ye = $ ? g[1] - g[0] : 0, Xe = x(() => {
482
+ if (K) {
483
+ let e = Y.filter((e) => e.sortable), n = B ? J.find((e) => e.id === B.column) : void 0;
484
+ return /* @__PURE__ */ E("div", {
485
+ role: "row",
486
+ "aria-rowindex": 1,
487
+ "data-slot": "request-table-header",
488
+ className: "flex h-(--request-header) items-center justify-between gap-2 bg-secondary ps-2 pe-1 text-caption text-foreground/65 shadow-hairline-b",
489
+ children: [/* @__PURE__ */ E("span", {
490
+ role: "columnheader",
491
+ className: "tabular-nums",
492
+ children: [
493
+ $.toLocaleString("en-US"),
494
+ " ",
495
+ $ === 1 ? "request" : "requests"
496
+ ]
497
+ }), e.length ? /* @__PURE__ */ T("span", {
498
+ role: "columnheader",
499
+ className: "flex items-center",
500
+ children: /* @__PURE__ */ E(r, { children: [/* @__PURE__ */ E(o, {
501
+ variant: "quiet",
502
+ size: "sm",
503
+ "aria-label": "Sort by",
504
+ "data-slot": "request-table-sort",
505
+ className: "h-6 gap-1 rounded-md px-1.5 text-caption font-medium",
506
+ children: [/* @__PURE__ */ T("span", { children: n ? Ae(n) : "Sort" }), B ? /* @__PURE__ */ T(t, {
507
+ name: B.direction === "ascending" ? "arrow-up" : "arrow-down",
508
+ size: 10,
509
+ sw: 2.6
510
+ }) : /* @__PURE__ */ T(t, {
511
+ name: "chevron-up-down",
512
+ size: 12,
513
+ sw: 2
514
+ })]
515
+ }), /* @__PURE__ */ E(i, {
516
+ "aria-label": "Sort by",
517
+ placement: "bottom end",
518
+ selectionMode: "single",
519
+ selectedKeys: [B?.column ?? ke],
520
+ onAction: (e) => V(e === ke ? null : h(B, String(e))),
521
+ children: [/* @__PURE__ */ T(a, {
522
+ id: ke,
523
+ children: "Original order"
524
+ }), e.map((e) => /* @__PURE__ */ T(a, {
525
+ id: e.id,
526
+ children: Ae(e)
527
+ }, e.id))]
528
+ })] })
529
+ }) : null]
530
+ });
531
+ }
532
+ return /* @__PURE__ */ T("div", {
533
+ role: "row",
534
+ "aria-rowindex": 1,
535
+ "data-slot": "request-table-header",
536
+ className: "grid h-(--request-header) grid-cols-(--request-cols) bg-secondary shadow-hairline-b",
537
+ children: Y.map((e, t) => /* @__PURE__ */ T(Ee, {
538
+ column: e,
539
+ index: t,
540
+ domId: `${R}-h${t}`,
541
+ sort: B,
542
+ active: q === t,
543
+ width: H[e.id],
544
+ span: Ye,
545
+ onSort: (e) => V(h(B, e)),
546
+ onWidth: (e, t) => je(H, we, e.id, t)
547
+ }, e.id))
548
+ });
549
+ }, [
550
+ K,
551
+ Y,
552
+ J,
553
+ B,
554
+ q,
555
+ H,
556
+ Ye,
557
+ $,
558
+ R
559
+ ]), Ze = [];
560
+ for (let e = M.start; e < Math.min(M.end, X.length); e++) {
561
+ let t = X[e];
562
+ Ze.push(/* @__PURE__ */ T(Te, {
563
+ row: t,
564
+ index: e,
565
+ domId: Be(e),
566
+ selected: t.id === z,
567
+ active: t.id === U && q === null,
568
+ stacked: K,
569
+ columns: Y,
570
+ range: g,
571
+ renderLink: y
572
+ }, t.id));
573
+ }
574
+ return /* @__PURE__ */ T("div", {
575
+ ref: I,
576
+ "data-slot": "request-table",
577
+ "data-rows": _.length,
578
+ "data-layout": K ? "stacked" : "table",
579
+ className: e(fe({ density: le }), de),
580
+ style: {
581
+ "--request-cols": Ie,
582
+ "--request-min-width": `${K ? 0 : Le}px`,
583
+ "--request-row": `${Ne}px`,
584
+ "--request-header": `${me}px`,
585
+ ...he
586
+ },
587
+ ...be,
588
+ children: /* @__PURE__ */ T("div", {
589
+ ref: m,
590
+ role: "grid",
591
+ tabIndex: 0,
592
+ "aria-label": ye,
593
+ "aria-rowcount": X.length + 1,
594
+ "aria-colcount": K ? void 0 : Y.length,
595
+ "aria-activedescendant": q === null ? Z >= 0 && Ue(Z) ? Be(Z) : void 0 : Ve(q),
596
+ "data-slot": "request-table-grid",
597
+ "data-focus-visible": xe || void 0,
598
+ onClick: Ge,
599
+ onKeyDown: qe,
600
+ onFocus: Je,
601
+ onBlur: Se.onBlur,
602
+ className: "group/grid bl-scroll relative min-h-0 flex-1 overflow-auto overscroll-contain outline-none [overflow-anchor:none]",
603
+ children: /* @__PURE__ */ E("div", {
604
+ className: "min-h-full w-full min-w-(--request-min-width)",
605
+ children: [
606
+ Y.some((e) => e.id === "waterfall") ? /* @__PURE__ */ T("div", {
607
+ "aria-hidden": "true",
608
+ "data-slot": "request-table-playhead",
609
+ className: "pointer-events-none sticky top-0 z-3 hidden h-0 group-data-playhead/table:block",
610
+ children: /* @__PURE__ */ T("div", {
611
+ className: e("absolute inset-x-0", K ? "top-(--request-header) flex h-[calc(var(--request-view)-var(--request-header))] justify-end pe-2" : "top-0 grid h-(--request-view) grid-cols-(--request-cols)"),
612
+ children: /* @__PURE__ */ T("div", {
613
+ className: K ? "relative w-24" : "relative mx-2",
614
+ style: K ? void 0 : { gridColumnStart: Y.findIndex((e) => e.id === "waterfall") + 1 },
615
+ children: /* @__PURE__ */ T("div", {
616
+ ref: s.setLine,
617
+ className: "absolute inset-y-0 left-[calc(var(--request-playhead,0)*100%)] w-px bg-primary"
618
+ })
619
+ })
620
+ })
621
+ }) : null,
622
+ /* @__PURE__ */ T("div", {
623
+ role: "rowgroup",
624
+ className: "sticky top-0 z-2 bg-card",
625
+ children: Xe
626
+ }),
627
+ /* @__PURE__ */ T("div", {
628
+ ref: L,
629
+ role: "rowgroup",
630
+ "data-slot": "request-table-rows",
631
+ className: "relative w-full",
632
+ children: Ze
633
+ }),
634
+ X.length ? null : /* @__PURE__ */ T("div", {
635
+ "data-slot": "request-table-empty",
636
+ className: "px-3 py-6 text-center text-footnote text-muted-foreground",
637
+ children: O ?? "No requests"
638
+ }),
639
+ k == null ? null : /* @__PURE__ */ T("div", {
640
+ "data-slot": "request-table-footer",
641
+ className: "px-3 py-2 text-center text-caption text-muted-foreground",
642
+ children: k
643
+ })
644
+ ]
645
+ })
646
+ })
647
+ });
648
+ }
649
+ var Oe = {}, ke = "$original-order";
650
+ function Ae(e) {
651
+ return e.label ?? (typeof e.title == "string" ? e.title : e.id);
652
+ }
653
+ function je(e, t, n, r) {
654
+ let i = { ...e };
655
+ r < 0 ? delete i[n] : i[n] = r, t(i);
656
+ }
657
+ var Me = oe(W);
658
+ function G({ playhead: e = null, timeRange: t, onRowPress: n, onSelectionChange: r, onSortChange: i, onColumnWidthsChange: a, ref: o, ...s }) {
659
+ let [c] = C(() => new U()), l = S(null), u = S({
660
+ onRowPress: n,
661
+ onSelectionChange: r,
662
+ onSortChange: i,
663
+ onColumnWidthsChange: a
664
+ });
665
+ b(() => {
666
+ u.current = {
667
+ onRowPress: n,
668
+ onSelectionChange: r,
669
+ onSortChange: i,
670
+ onColumnWidthsChange: a
671
+ };
672
+ });
673
+ let { rows: d } = s, f = t?.[0], p = t?.[1], m = x(() => f !== void 0 && p !== void 0 ? [f, p] : re(d), [
674
+ f,
675
+ p,
676
+ d
677
+ ]);
678
+ return b(() => {
679
+ c.set(e, m);
680
+ }, [
681
+ c,
682
+ e,
683
+ m
684
+ ]), ce(o, () => ({
685
+ focus: () => l.current?.focus(),
686
+ scrollToId: (e, t = "center") => c.win.scrollToIndex(c.win.ids.indexOf(e), t, "micro"),
687
+ setPlayhead: (e) => c.set(e)
688
+ }), [c]), /* @__PURE__ */ T(Me, {
689
+ playhead: c,
690
+ handlers: u,
691
+ gridRef: l,
692
+ range: m,
693
+ ...s
694
+ });
695
+ }
696
+ //#endregion
697
+ export { ge as REQUEST_COLUMNS, z as RequestLink, G as RequestTable, fe as requestTableVariants };
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps, ReactNode, Ref } from 'react';
2
2
  import { VariantProps } from 'class-variance-authority';
3
- import { SpreadsheetEngine, SpreadsheetRanOn, SpreadsheetSort } from '../lib/spreadsheet';
3
+ import { SpreadsheetEngine, SpreadsheetRanOn, SpreadsheetSort } from '../lib/spreadsheet-model';
4
4
  export declare const spreadsheetVariants: (props?: ({
5
5
  density?: "compact" | "comfortable" | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;