@brett_lamy/ui 5.15.0 → 5.16.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 (121) 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/debug-toolbar.d.ts +13 -0
  11. package/dist/components/debug-toolbar.d.ts.map +1 -0
  12. package/dist/components/debug-toolbar.js +85 -0
  13. package/dist/components/file-upload.d.ts +1 -1
  14. package/dist/components/file-upload.d.ts.map +1 -1
  15. package/dist/components/file-upload.js +1 -1
  16. package/dist/components/filter-input.d.ts +1 -1
  17. package/dist/components/filter-input.d.ts.map +1 -1
  18. package/dist/components/filter-input.js +1 -1
  19. package/dist/components/filter.d.ts +1 -1
  20. package/dist/components/filter.d.ts.map +1 -1
  21. package/dist/components/filter.js +1 -1
  22. package/dist/components/log-list.d.ts +95 -0
  23. package/dist/components/log-list.d.ts.map +1 -0
  24. package/dist/components/log-list.js +549 -0
  25. package/dist/components/object-tree.d.ts +30 -0
  26. package/dist/components/object-tree.d.ts.map +1 -0
  27. package/dist/components/object-tree.js +415 -0
  28. package/dist/components/object-value.d.ts +13 -0
  29. package/dist/components/object-value.d.ts.map +1 -0
  30. package/dist/components/object-value.js +69 -0
  31. package/dist/components/request-table.d.ts +78 -0
  32. package/dist/components/request-table.d.ts.map +1 -0
  33. package/dist/components/request-table.js +697 -0
  34. package/dist/components/spreadsheet.d.ts +1 -1
  35. package/dist/components/spreadsheet.d.ts.map +1 -1
  36. package/dist/components/spreadsheet.js +1 -1
  37. package/dist/components/syntax-highlighting.d.ts +45 -77
  38. package/dist/components/syntax-highlighting.d.ts.map +1 -1
  39. package/dist/components/syntax-highlighting.js +36 -275
  40. package/dist/components/terminal.d.ts +62 -0
  41. package/dist/components/terminal.d.ts.map +1 -0
  42. package/dist/components/terminal.js +172 -0
  43. package/dist/components/trace-timeline.d.ts +97 -0
  44. package/dist/components/trace-timeline.d.ts.map +1 -0
  45. package/dist/components/trace-timeline.js +850 -0
  46. package/dist/components/tree.d.ts.map +1 -1
  47. package/dist/components/tree.js +99 -91
  48. package/dist/components/video-preview.d.ts +1 -1
  49. package/dist/components/video-preview.d.ts.map +1 -1
  50. package/dist/components/video-preview.js +1 -1
  51. package/dist/components/video-timeline.d.ts +1 -1
  52. package/dist/components/video-timeline.d.ts.map +1 -1
  53. package/dist/components/video-timeline.js +1 -1
  54. package/dist/components/workspace.d.ts.map +1 -1
  55. package/dist/components/workspace.js +1 -1
  56. package/dist/index.css +1 -1
  57. package/dist/index.d.ts +47 -11
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +120 -100
  60. package/dist/lib/call-stack-model.d.ts +75 -0
  61. package/dist/lib/call-stack-model.d.ts.map +1 -0
  62. package/dist/lib/call-stack-model.js +114 -0
  63. package/dist/lib/code-document.d.ts +229 -0
  64. package/dist/lib/code-document.d.ts.map +1 -0
  65. package/dist/lib/code-document.js +727 -0
  66. package/dist/lib/code-editor-gpu.d.ts +9 -0
  67. package/dist/lib/code-editor-gpu.d.ts.map +1 -0
  68. package/dist/lib/code-editor-gpu.js +23 -0
  69. package/dist/lib/code-editor-model.d.ts +371 -0
  70. package/dist/lib/code-editor-model.d.ts.map +1 -0
  71. package/dist/lib/code-editor-model.js +1105 -0
  72. package/dist/lib/{file-upload.d.ts → file-upload-model.d.ts} +1 -1
  73. package/dist/lib/file-upload-model.d.ts.map +1 -0
  74. package/dist/lib/{file-upload.js → file-upload-model.js} +1 -1
  75. package/dist/lib/{filter.d.ts → filter-model.d.ts} +1 -1
  76. package/dist/lib/filter-model.d.ts.map +1 -0
  77. package/dist/lib/{filter.js → filter-model.js} +1 -1
  78. package/dist/lib/filter-query.d.ts +1 -1
  79. package/dist/lib/filter-query.d.ts.map +1 -1
  80. package/dist/lib/filter-query.js +1 -1
  81. package/dist/lib/log-list-model.d.ts +132 -0
  82. package/dist/lib/log-list-model.d.ts.map +1 -0
  83. package/dist/lib/log-list-model.js +214 -0
  84. package/dist/lib/log-list-window.d.ts +121 -0
  85. package/dist/lib/log-list-window.d.ts.map +1 -0
  86. package/dist/lib/log-list-window.js +245 -0
  87. package/dist/lib/object-tree-model.d.ts +162 -0
  88. package/dist/lib/object-tree-model.d.ts.map +1 -0
  89. package/dist/lib/object-tree-model.js +347 -0
  90. package/dist/lib/object-tree-value.d.ts +139 -0
  91. package/dist/lib/object-tree-value.d.ts.map +1 -0
  92. package/dist/lib/object-tree-value.js +410 -0
  93. package/dist/lib/request-table-model.d.ts +85 -0
  94. package/dist/lib/request-table-model.d.ts.map +1 -0
  95. package/dist/lib/request-table-model.js +105 -0
  96. package/dist/lib/{spreadsheet.d.ts → spreadsheet-model.d.ts} +1 -1
  97. package/dist/lib/spreadsheet-model.d.ts.map +1 -0
  98. package/dist/lib/{spreadsheet.js → spreadsheet-model.js} +1 -1
  99. package/dist/lib/syntax.d.ts +19 -7
  100. package/dist/lib/syntax.d.ts.map +1 -1
  101. package/dist/lib/syntax.js +54 -50
  102. package/dist/lib/terminal-line.d.ts +155 -0
  103. package/dist/lib/terminal-line.d.ts.map +1 -0
  104. package/dist/lib/terminal-line.js +463 -0
  105. package/dist/lib/trace-timeline-draw.d.ts +109 -0
  106. package/dist/lib/trace-timeline-draw.d.ts.map +1 -0
  107. package/dist/lib/trace-timeline-draw.js +252 -0
  108. package/dist/lib/trace-timeline-model.d.ts +324 -0
  109. package/dist/lib/trace-timeline-model.d.ts.map +1 -0
  110. package/dist/lib/trace-timeline-model.js +510 -0
  111. package/dist/lib/video-render.d.ts +1 -1
  112. package/dist/lib/video-render.d.ts.map +1 -1
  113. package/dist/lib/video-render.js +1 -1
  114. package/dist/lib/{video-timeline.d.ts → video-timeline-model.d.ts} +1 -1
  115. package/dist/lib/video-timeline-model.d.ts.map +1 -0
  116. package/dist/lib/{video-timeline.js → video-timeline-model.js} +1 -1
  117. package/package.json +5 -1
  118. package/dist/lib/file-upload.d.ts.map +0 -1
  119. package/dist/lib/filter.d.ts.map +0 -1
  120. package/dist/lib/spreadsheet.d.ts.map +0 -1
  121. package/dist/lib/video-timeline.d.ts.map +0 -1
@@ -0,0 +1,549 @@
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 { selectableText as r } from "../lib/primitives.js";
6
+ import { Button as i } from "./button.js";
7
+ import { RowTimes as a, followTop as o, formatLogTime as s, logRowText as c, normalizeLogLevel as l, rowKeyTarget as u, rowsChange as d } from "../lib/log-list-model.js";
8
+ import { RowWindow as f, isRowPress as p, tabThroughGrid as m, tabbablesIn as h } from "../lib/log-list-window.js";
9
+ import { memo as g, useEffect as _, useId as v, useImperativeHandle as y, useLayoutEffect as b, useMemo as x, useRef as S, useState as C, useSyncExternalStore as w } from "react";
10
+ import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
11
+ import { cva as O } from "class-variance-authority";
12
+ import { createPortal as k } from "react-dom";
13
+ import { useFocusRing as ee } from "react-aria";
14
+ //#region src/components/log-list.tsx
15
+ var A = O("@container 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-['']", {
16
+ variants: { density: {
17
+ compact: "[--log-pad:3px]",
18
+ comfortable: "[--log-pad:7px]"
19
+ } },
20
+ defaultVariants: { density: "compact" }
21
+ }), j = {
22
+ compact: 24,
23
+ comfortable: 32
24
+ }, te = {
25
+ log: /* @__PURE__ */ E(t, {
26
+ shapes: [{
27
+ c: [
28
+ 12,
29
+ 12,
30
+ 3.4
31
+ ],
32
+ f: 1
33
+ }],
34
+ size: 12,
35
+ className: "text-tertiary-foreground"
36
+ }),
37
+ info: /* @__PURE__ */ E(t, {
38
+ name: "info-fill",
39
+ size: 14,
40
+ className: "text-primary"
41
+ }),
42
+ warn: /* @__PURE__ */ E(t, {
43
+ name: "warning-fill",
44
+ size: 14,
45
+ className: "text-warning"
46
+ }),
47
+ error: /* @__PURE__ */ E(t, {
48
+ name: "xmark-circle-fill",
49
+ size: 14,
50
+ className: "text-destructive"
51
+ }),
52
+ debug: /* @__PURE__ */ E(t, {
53
+ shapes: [
54
+ { r: [
55
+ 8,
56
+ 7.5,
57
+ 8,
58
+ 12.5,
59
+ 4
60
+ ] },
61
+ { d: "M12 11.5V20" },
62
+ { d: "M8 13H4.5M16 13h3.5M8.4 17.5l-3 2M15.6 17.5l3 2M8.4 9.5l-3-2M15.6 9.5l3-2" },
63
+ { d: "M9.5 7.5a2.5 2.5 0 0 1 5 0" }
64
+ ],
65
+ size: 13,
66
+ sw: 2,
67
+ className: "text-muted-foreground"
68
+ })
69
+ }, ne = /* @__PURE__ */ E(t, {
70
+ name: "chevron-right",
71
+ size: 10,
72
+ sw: 2.6,
73
+ className: "transition-transform duration-spring-snappy ease-spring-snappy group-data-expanded/row:rotate-90 motion-reduce:transition-none"
74
+ }), re = [
75
+ "group/row absolute inset-x-0 top-0 isolate flex min-w-0 cursor-default items-start gap-1.5 ps-2 pe-(--log-end) py-(--log-pad) text-caption leading-[18px] outline-none",
76
+ "before:absolute before:inset-0 before:-z-1 before:content-[''] hover:before:bg-foreground/4 active:before:bg-foreground/8",
77
+ "after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border/60 after:content-['']",
78
+ "data-[level=warn]:bg-warning/10 data-[level=error]:bg-destructive/8 data-[level=debug]:text-muted-foreground",
79
+ "data-current:before:bg-primary/10 data-selected:before:bg-primary/16",
80
+ "data-future:opacity-45",
81
+ "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"
82
+ ].join(" "), ie = "flex min-w-0 flex-1 items-start", M = e("min-w-0 flex-1 font-mono whitespace-pre-wrap [overflow-wrap:anywhere]", r), N = e("min-w-0 flex-1 truncate font-mono", r), P = "flex max-w-full min-w-0 shrink-0 items-baseline gap-2 text-caption2 text-muted-foreground @[480px]:max-w-[40%] @[480px]:justify-end", F = "me-1.5 inline-flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-secondary-strong px-1 align-[1px] font-sans text-caption2 leading-none font-semibold tabular-nums", I = "invisible ms-[calc(var(--log-toggle)*-0.5)] flex h-[18px] w-(--log-toggle) shrink-0 items-center justify-center text-muted-foreground group-data-clipped/row:visible group-data-expanded/row:visible group-data-has-detail/row:visible", L = "me-1.5 flex h-[18px] w-3.5 shrink-0 items-center justify-center";
83
+ function R({ row: t, expanded: n = !1, cut: i = !1, disclosure: a = !1, formatTime: o = s }) {
84
+ let c = t.time === void 0 ? null : o(t.time);
85
+ return /* @__PURE__ */ D(T, { children: [
86
+ /* @__PURE__ */ E("span", {
87
+ "data-slot": "log-list-toggle",
88
+ "data-row-toggle": "",
89
+ className: I,
90
+ children: a ? ne : null
91
+ }),
92
+ /* @__PURE__ */ E("span", {
93
+ "data-slot": "log-list-icon",
94
+ className: L,
95
+ children: te[l(t.level)]
96
+ }),
97
+ /* @__PURE__ */ D("div", {
98
+ className: "min-w-0 flex-1",
99
+ children: [/* @__PURE__ */ D("div", {
100
+ className: "flex min-w-0 flex-col @[480px]:flex-row @[480px]:gap-3",
101
+ children: [/* @__PURE__ */ D("div", {
102
+ "data-slot": "log-list-message",
103
+ className: i && !n ? N : M,
104
+ children: [t.count !== void 0 && t.count > 1 ? /* @__PURE__ */ E("span", {
105
+ "data-slot": "log-list-count",
106
+ className: F,
107
+ children: t.count.toLocaleString("en-US")
108
+ }) : null, t.message]
109
+ }), c !== null || t.source != null ? /* @__PURE__ */ D("div", {
110
+ "data-slot": "log-list-meta",
111
+ className: P,
112
+ children: [t.source == null ? null : /* @__PURE__ */ E("span", {
113
+ "data-slot": "log-list-source",
114
+ className: "min-w-0 truncate",
115
+ children: t.source
116
+ }), c === null ? null : /* @__PURE__ */ E("span", {
117
+ "data-slot": "log-list-time",
118
+ className: "shrink-0 text-end tabular-nums",
119
+ children: c
120
+ })]
121
+ }) : null]
122
+ }), n && t.detail != null ? /* @__PURE__ */ E("div", {
123
+ "data-slot": "log-list-detail",
124
+ className: e("mt-0.5 font-mono text-caption2 whitespace-pre-wrap text-muted-foreground [overflow-wrap:anywhere]", r),
125
+ children: t.detail
126
+ }) : null]
127
+ })
128
+ ] });
129
+ }
130
+ var z = class {
131
+ win;
132
+ times = new a();
133
+ marker = null;
134
+ follow = !0;
135
+ tail = !1;
136
+ onFollowChange;
137
+ boundary = null;
138
+ current = -1;
139
+ id = null;
140
+ time = null;
141
+ following = !0;
142
+ away = null;
143
+ drawnY;
144
+ listeners = /* @__PURE__ */ new Set();
145
+ constructor(e) {
146
+ this.win = new f({ estimate: e }), this.win.decorate = this.decorate, this.win.onLayout = () => this.paint(), this.win.onScroll = (e) => {
147
+ e && this.keepInView("sync", !0);
148
+ };
149
+ }
150
+ setMarker = (e) => {
151
+ this.marker = e;
152
+ };
153
+ setRows(e) {
154
+ let t = d(this.win.rows, e);
155
+ this.times.update(e, t), this.win.setRows(e), this.moved("effect");
156
+ }
157
+ setPosition(e, t, n) {
158
+ this.id = e, this.time = t, this.moved(n);
159
+ }
160
+ moved(e) {
161
+ let { boundary: t, current: n } = this;
162
+ this.resolve(), (this.boundary !== t || this.current !== n) && this.win.decorateAll(), this.paint(), this.keepInView(e);
163
+ }
164
+ resolve() {
165
+ let { win: e, id: t, time: n } = this;
166
+ if (this.boundary = null, this.current = -1, t !== null) {
167
+ let n = e.ids.indexOf(t);
168
+ if (n >= 0) {
169
+ this.boundary = n + 1, this.current = n;
170
+ return;
171
+ }
172
+ }
173
+ n !== null && (this.boundary = this.times.firstAfter(n), this.boundary > 0 && e.rows[this.boundary - 1].time === n && (this.current = this.boundary - 1));
174
+ }
175
+ decorate = (e, t) => {
176
+ e.toggleAttribute("data-future", this.boundary !== null && t >= this.boundary), t === this.current ? (e.setAttribute("data-current", ""), e.setAttribute("aria-current", "true")) : e.hasAttribute("data-current") && (e.removeAttribute("data-current"), e.removeAttribute("aria-current"));
177
+ };
178
+ paint() {
179
+ let { marker: e, boundary: t, win: n } = this;
180
+ if (!e) return;
181
+ let r = t === null || !n.rows.length ? null : n.heights.offsetOf(t);
182
+ r !== this.drawnY && (r === null ? e.style.display = "none" : ((this.drawnY === null || this.drawnY === void 0) && (e.style.display = ""), e.style.transform = `translateY(${r}px)`), this.drawnY = r);
183
+ }
184
+ target() {
185
+ return this.boundary === null ? this.tail ? this.win.heights.total : null : this.win.heights.offsetOf(this.boundary);
186
+ }
187
+ keepInView(e, t = !1) {
188
+ let { win: n } = this, r = this.target();
189
+ if (r === null || !n.rows.length) {
190
+ this.setAway(null);
191
+ return;
192
+ }
193
+ let i = r >= n.scrollTop - 1 && r <= n.scrollTop + n.view + (this.boundary === null ? 24 : 1);
194
+ (t || i) && this.setFollowing(i), this.following && !t && this.follow && n.scrollWith(() => this.boundary === null ? n.endTop : o({
195
+ y: this.target() ?? 0,
196
+ top: n.scrollTop,
197
+ view: n.view,
198
+ total: n.heights.total
199
+ }), e);
200
+ let a = this.target() ?? 0, s = a >= n.scrollTop - 1 && a <= n.scrollTop + n.view + (this.boundary === null ? 24 : 1);
201
+ this.setAway(s ? null : a < n.scrollTop ? "above" : "below");
202
+ }
203
+ jump = () => {
204
+ let { win: e } = this;
205
+ this.target() !== null && (this.setFollowing(!0), e.scrollWith(() => this.boundary === null ? e.endTop : (this.target() ?? 0) - e.view / 2, "micro"), this.setAway(null));
206
+ };
207
+ setFollowing(e) {
208
+ e !== this.following && (this.following = e, this.onFollowChange?.(e));
209
+ }
210
+ setAway(e) {
211
+ e !== this.away && (this.away = e, this.listeners.forEach((e) => e()));
212
+ }
213
+ getAway = () => this.away;
214
+ subscribeAway = (e) => (this.listeners.add(e), () => {
215
+ this.listeners.delete(e);
216
+ });
217
+ }, ae = g(function({ row: e, index: t, domId: n, selected: r, active: i, expanded: a, cut: o, disclosure: s, formatTime: c, renderRow: u }) {
218
+ let d = e.detail != null;
219
+ return /* @__PURE__ */ E("div", {
220
+ role: "row",
221
+ id: n,
222
+ "aria-rowindex": t + 1,
223
+ "aria-selected": r,
224
+ "aria-expanded": d ? a : void 0,
225
+ "data-slot": "log-list-row",
226
+ "data-index": t,
227
+ "data-level": l(e.level),
228
+ "data-selected": r || void 0,
229
+ "data-active": i || void 0,
230
+ "data-expanded": a || void 0,
231
+ "data-has-detail": d || void 0,
232
+ className: re,
233
+ children: /* @__PURE__ */ E("div", {
234
+ role: "gridcell",
235
+ className: ie,
236
+ children: u ? u(e, {
237
+ index: t,
238
+ selected: r,
239
+ expanded: a,
240
+ cut: o,
241
+ disclosure: s,
242
+ formatTime: c
243
+ }) : /* @__PURE__ */ E(R, {
244
+ row: e,
245
+ expanded: a,
246
+ cut: o,
247
+ disclosure: s,
248
+ formatTime: c
249
+ })
250
+ })
251
+ });
252
+ }), oe = {
253
+ start: 0,
254
+ end: 0
255
+ };
256
+ function se({ win: e, rows: n, activeIndex: r, control: a, handlers: o, formatTime: s }) {
257
+ let [c, l] = C(-1), [u, d] = C(null), [f, p] = C(), m = S(void 0);
258
+ _(() => () => clearTimeout(m.current), []);
259
+ let h = c >= 0 ? c : r;
260
+ b(() => {
261
+ let t = () => p(h >= 0 ? e.elementAt(h) : void 0);
262
+ a.current = {
263
+ hover: l,
264
+ refresh: t
265
+ }, t();
266
+ }, [
267
+ e,
268
+ h,
269
+ a
270
+ ]);
271
+ let g = n[h];
272
+ if (!g || !f || !f.isConnected) return null;
273
+ let v = u === g.id;
274
+ return k(/* @__PURE__ */ E("div", {
275
+ role: "gridcell",
276
+ "data-slot": "log-list-actions",
277
+ "data-no-row-press": "",
278
+ className: "invisible absolute end-1 bottom-[calc(var(--log-pad)-2px)] z-1 group-focus-within/grid:visible group-hover/row:visible @[480px]:top-[calc(var(--log-pad)-2px)] @[480px]:bottom-auto",
279
+ children: /* @__PURE__ */ E(i, {
280
+ variant: "quiet",
281
+ size: "icon-sm",
282
+ "aria-label": v ? "Copied" : "Copy this row",
283
+ title: v ? "Copied" : "Copy",
284
+ onPress: () => {
285
+ B(g, o.current, s).then((e) => {
286
+ e && (d(g.id), clearTimeout(m.current), m.current = setTimeout(() => d(null), 1200));
287
+ });
288
+ },
289
+ className: "bg-card shadow-hairline data-hovered:bg-card data-pressed:bg-secondary",
290
+ children: /* @__PURE__ */ E(t, {
291
+ name: v ? "check" : "copy",
292
+ size: 12,
293
+ sw: 2.2,
294
+ className: v ? "text-success" : void 0
295
+ })
296
+ })
297
+ }), f);
298
+ }
299
+ function B(e, t, n) {
300
+ let r = t.getRowText?.(e) ?? c(e, n);
301
+ return t.onRowCopy?.(e, r), navigator.clipboard ? navigator.clipboard.writeText(r).then(() => !0, () => !1) : Promise.resolve(!1);
302
+ }
303
+ function ce({ position: e, label: n }) {
304
+ let r = w(e.subscribeAway, e.getAway, () => null);
305
+ return r ? /* @__PURE__ */ E("div", {
306
+ "data-side": r,
307
+ className: "pointer-events-none absolute inset-x-0 z-4 flex justify-center data-[side=above]:top-2 data-[side=below]:bottom-2",
308
+ children: /* @__PURE__ */ D(i, {
309
+ "data-slot": "log-list-jump",
310
+ size: "sm",
311
+ onPress: () => e.jump(),
312
+ className: "pointer-events-auto h-7 gap-1 rounded-full px-3 text-caption shadow-hairline",
313
+ children: [/* @__PURE__ */ E(t, {
314
+ name: r === "above" ? "arrow-up" : "arrow-down",
315
+ size: 12,
316
+ sw: 2.4
317
+ }), n ?? (e.boundary === null ? "Back to latest" : "Back to current")]
318
+ })
319
+ }) : null;
320
+ }
321
+ function V({ position: t, handlers: r, gridRef: i, rows: a, markerLabel: o, jumpLabel: c, overflow: l = "wrap", expandOnPress: d = l === "expand", expandedIds: f, defaultExpandedIds: g, selectedId: _, defaultSelectedId: y, copyable: w = !0, renderRow: T, formatTime: O = s, emptyState: k, footer: j, density: te, className: ne, onKeyDown: re, onFocus: ie, "aria-label": M = "Log", ...N }) {
322
+ let { win: P } = t, [F, I] = C(oe), L = S(null), R = v(), z = (e) => `${R}-${e}`, { isFocusVisible: V, focusProps: U } = ee(), [W, le] = n(_, y ?? null, (e) => r.current.onSelectionChange?.(e)), [G, ue] = n(f, x(() => new Set(g), []), (e) => r.current.onExpandedChange?.(e)), [K, q] = C(null), J = S({
323
+ hover: () => {},
324
+ refresh: () => {}
325
+ }), Y = S(-1), X = l === "expand", de = x(() => X || a.some((e) => e.detail != null), [X, a]);
326
+ b(() => {
327
+ P.onRange = I;
328
+ let e = i.current;
329
+ if (!(!e || !L.current)) return P.attach(e, L.current);
330
+ }, [P, i]), b(() => {
331
+ t.setRows(a);
332
+ }, [t, a]), b(() => {
333
+ P.sync(), J.current.refresh(), X && H(P);
334
+ }), b(() => {
335
+ if (!X) for (let e of P.elements.values()) e.removeAttribute("data-clipped");
336
+ }, [P, X]), b(() => {
337
+ P.onWidth = (e, t) => {
338
+ t && e < 480 != t < 480 && P.invalidate(), X && H(P);
339
+ };
340
+ }, [P, X]);
341
+ let Z = K === null ? -1 : P.indexIn(a, K), Q = W === null ? -1 : P.indexIn(a, W), fe = (e) => e >= F.start && e < Math.min(F.end, a.length), pe = S(null);
342
+ b(() => {
343
+ if (W === pe.current || (pe.current = W, W === null)) return;
344
+ let e = P.ids.indexOf(W);
345
+ e < 0 || P.isVisible(e) || (P.scrollToIndex(e, "center", "effect"), t.keepInView("effect", !0));
346
+ }, [
347
+ W,
348
+ P,
349
+ t
350
+ ]);
351
+ let me = (e) => {
352
+ P.scrollToIndex(e, "nearest"), t.keepInView("sync", !0);
353
+ }, he = (e) => {
354
+ let t = a[e];
355
+ return t.detail != null || G.has(t.id) || !!P.elementAt(e)?.hasAttribute("data-clipped");
356
+ }, $ = (e) => {
357
+ let t = new Set(G);
358
+ t.delete(e) || t.add(e), ue(t);
359
+ }, ge = (e) => {
360
+ let t = a[e];
361
+ q(t.id), le(t.id), d && he(e) && $(t.id), r.current.onRowPress?.(t, e);
362
+ }, _e = (e) => {
363
+ let t = P.indexFrom(e.target);
364
+ if (!(t < 0)) {
365
+ if (e.target.closest("[data-row-toggle]")) {
366
+ q(a[t].id), $(a[t].id);
367
+ return;
368
+ }
369
+ p(e) && ge(t);
370
+ }
371
+ }, ve = () => Q >= 0 && P.isVisible(Q) ? Q : t.current >= 0 && P.isVisible(t.current) ? t.current : P.heights.indexAt(P.scrollTop), ye = (e) => {
372
+ if (re?.(e), e.defaultPrevented) return;
373
+ if (e.key === "Tab") {
374
+ m(e, Z >= 0 ? P.elementAt(Z) : void 0);
375
+ return;
376
+ }
377
+ let t = e.currentTarget;
378
+ if (e.target !== t) {
379
+ e.key === "Escape" && (t.focus(), e.preventDefault());
380
+ return;
381
+ }
382
+ if (!a.length) return;
383
+ let n = Z >= 0 ? Z : ve();
384
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "c") {
385
+ if (!w || !window.getSelection()?.isCollapsed) return;
386
+ B(a[n], r.current, O), e.preventDefault();
387
+ return;
388
+ }
389
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
390
+ switch (e.key) {
391
+ case "Enter":
392
+ case " ":
393
+ ge(n), e.preventDefault();
394
+ return;
395
+ case "ArrowRight":
396
+ !G.has(a[n].id) && he(n) ? $(a[n].id) : P.elementAt(n) && h(P.elementAt(n))[0]?.focus(), e.preventDefault();
397
+ return;
398
+ case "ArrowLeft":
399
+ G.has(a[n].id) && $(a[n].id), e.preventDefault();
400
+ return;
401
+ }
402
+ let i = Z < 0 && (e.key === "ArrowDown" || e.key === "ArrowUp") ? n : u(e.key, n, a.length, (e) => P.heights.indexAt(P.heights.offsetOf(n) + e * P.view));
403
+ i !== null && (e.preventDefault(), q(a[i].id), me(i));
404
+ }, be = (e) => {
405
+ U.onFocus?.(e), ie?.(e), e.target === e.currentTarget && K === null && a.length && q(a[ve()].id);
406
+ }, xe = (e) => {
407
+ e !== Y.current && (Y.current = e, J.current.hover(e));
408
+ }, Se = (e) => {
409
+ e.pointerType !== "touch" && xe(P.indexFrom(e.target));
410
+ }, Ce = [];
411
+ for (let e = F.start; e < Math.min(F.end, a.length); e++) {
412
+ let t = a[e];
413
+ Ce.push(/* @__PURE__ */ E(ae, {
414
+ row: t,
415
+ index: e,
416
+ domId: z(e),
417
+ selected: t.id === W,
418
+ active: t.id === K,
419
+ expanded: G.has(t.id),
420
+ cut: X,
421
+ disclosure: X || t.detail != null,
422
+ formatTime: O,
423
+ renderRow: T
424
+ }, t.id));
425
+ }
426
+ return /* @__PURE__ */ D("div", {
427
+ "data-slot": "log-list",
428
+ "data-rows": a.length,
429
+ className: e(A({ density: te }), ne),
430
+ ...N,
431
+ children: [/* @__PURE__ */ D("div", {
432
+ ref: i,
433
+ role: "treegrid",
434
+ tabIndex: 0,
435
+ "aria-label": M,
436
+ "aria-rowcount": a.length,
437
+ "aria-activedescendant": Z >= 0 && fe(Z) ? z(Z) : void 0,
438
+ "data-slot": "log-list-grid",
439
+ "data-focus-visible": V || void 0,
440
+ onClick: _e,
441
+ onKeyDown: ye,
442
+ onFocus: be,
443
+ onBlur: U.onBlur,
444
+ onPointerOver: Se,
445
+ onPointerLeave: () => xe(-1),
446
+ className: "group/grid bl-scroll relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain outline-none [overflow-anchor:none]",
447
+ children: [
448
+ /* @__PURE__ */ D("div", {
449
+ ref: L,
450
+ role: "rowgroup",
451
+ "data-slot": "log-list-rows",
452
+ className: e("relative w-full", de ? "[--log-toggle:10px]" : "[--log-toggle:0px]", w ? "[--log-end:8px] @[480px]:[--log-end:28px]" : "[--log-end:8px]"),
453
+ children: [
454
+ Ce,
455
+ /* @__PURE__ */ D("div", {
456
+ ref: t.setMarker,
457
+ "aria-hidden": "true",
458
+ "data-slot": "log-list-marker",
459
+ className: "pointer-events-none absolute inset-x-0 top-0 z-3 h-0",
460
+ children: [
461
+ /* @__PURE__ */ E("div", { className: "absolute inset-x-0 -top-px h-0.5 bg-primary" }),
462
+ /* @__PURE__ */ E("div", { className: "absolute start-0.5 -top-1 size-2 rounded-full bg-primary" }),
463
+ o == null ? null : /* @__PURE__ */ E("div", {
464
+ "data-slot": "log-list-marker-label",
465
+ className: "absolute end-2 -top-[7px] flex h-3.5 items-center rounded-full bg-primary px-1.5 text-caption2 leading-none font-semibold whitespace-nowrap text-primary-foreground @[480px]:end-1/2 @[480px]:translate-x-1/2",
466
+ children: o
467
+ })
468
+ ]
469
+ }),
470
+ w ? /* @__PURE__ */ E(se, {
471
+ win: P,
472
+ rows: a,
473
+ activeIndex: Z,
474
+ control: J,
475
+ handlers: r,
476
+ formatTime: O
477
+ }) : null
478
+ ]
479
+ }),
480
+ a.length ? null : /* @__PURE__ */ E("div", {
481
+ "data-slot": "log-list-empty",
482
+ className: "px-3 py-6 text-center text-footnote text-muted-foreground",
483
+ children: k ?? "No messages"
484
+ }),
485
+ j == null ? null : /* @__PURE__ */ E("div", {
486
+ "data-slot": "log-list-footer",
487
+ className: "px-3 py-2 text-center text-caption text-muted-foreground",
488
+ children: j
489
+ })
490
+ ]
491
+ }), /* @__PURE__ */ E(ce, {
492
+ position: t,
493
+ label: c
494
+ })]
495
+ });
496
+ }
497
+ function H(e) {
498
+ let t = [];
499
+ for (let n of e.elements.values()) {
500
+ let e = n.querySelector("[data-slot=log-list-message]");
501
+ t.push([n, !!e && e.scrollWidth > e.clientWidth]);
502
+ }
503
+ for (let [e, n] of t) e.toggleAttribute("data-clipped", n), e.hasAttribute("data-has-detail") || (n || e.hasAttribute("data-expanded") ? e.setAttribute("aria-expanded", String(e.hasAttribute("data-expanded"))) : e.removeAttribute("aria-expanded"));
504
+ }
505
+ var U = g(V);
506
+ function W({ currentId: e = null, currentTime: t = null, follow: n = !0, followTail: r = !1, onFollowChange: i, onRowPress: a, onRowCopy: o, getRowText: s, onExpandedChange: c, onSelectionChange: l, estimatedRowHeight: u, ref: d, ...f }) {
507
+ let [p] = C(() => new z(u ?? j[f.density ?? "compact"])), m = S(null), h = S({
508
+ onRowPress: a,
509
+ onRowCopy: o,
510
+ getRowText: s,
511
+ onExpandedChange: c,
512
+ onSelectionChange: l
513
+ });
514
+ return b(() => {
515
+ h.current = {
516
+ onRowPress: a,
517
+ onRowCopy: o,
518
+ getRowText: s,
519
+ onExpandedChange: c,
520
+ onSelectionChange: l
521
+ }, p.onFollowChange = i;
522
+ }), b(() => {
523
+ p.follow = n, p.tail = r, p.keepInView("effect");
524
+ }, [
525
+ p,
526
+ n,
527
+ r
528
+ ]), b(() => {
529
+ p.setPosition(e, t, "effect");
530
+ }, [
531
+ p,
532
+ e,
533
+ t
534
+ ]), y(d, () => ({
535
+ focus: () => m.current?.focus(),
536
+ scrollToId: (e, t = "center") => {
537
+ p.win.scrollToIndex(p.win.ids.indexOf(e), t, "micro"), p.keepInView("micro", !0);
538
+ },
539
+ followPosition: () => p.jump(),
540
+ setCurrentTime: (e) => p.setPosition(null, e, "micro")
541
+ }), [p]), /* @__PURE__ */ E(U, {
542
+ position: p,
543
+ handlers: h,
544
+ gridRef: m,
545
+ ...f
546
+ });
547
+ }
548
+ //#endregion
549
+ export { W as LogList, R as LogRowContent, A as logListVariants };
@@ -0,0 +1,30 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { ObjectTreeGetterResult, ObjectTreeNode, ObjectTreeRoot } from '../lib/object-tree-model';
3
+ export interface ObjectTreeProps<T = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onSelect' | 'onCopy'> {
4
+ 'aria-label': string;
5
+ /** What's at the top level: one node, or several, with `section: true` for Local, Closure and Global. A new `root` is a
6
+ * new moment: what was loaded goes, and an answer still on its way is dropped. Keep it the same object until it changes. */
7
+ root: ObjectTreeRoot<T>;
8
+ /** A node's children, asked for when it opens and kept after that. `node.data` is there for your own handle. Without
9
+ * it, nodes from `nodeFromValue` open by themselves. */
10
+ loadChildren?: (node: ObjectTreeNode<T>) => Promise<readonly ObjectTreeNode<T>[]> | readonly ObjectTreeNode<T>[];
11
+ /** Calls a getter: pressing a `(...)`. Return its value, and whether it can open. */
12
+ onInvokeGetter?: (node: ObjectTreeNode<T>) => Promise<ObjectTreeGetterResult<T>> | ObjectTreeGetterResult<T>;
13
+ /** Rows can be selected, and this hears about it. A press then selects, and the chevron or a double press opens. */
14
+ onSelect?: (node: ObjectTreeNode<T> | null) => void;
15
+ /** The text copying a value gives. Default: a string's text, JSON for `nodeFromValue` values, otherwise the preview. */
16
+ copyValue?: (node: ObjectTreeNode<T>) => Promise<string> | string;
17
+ /** Indexed children to a range before they group. Default 100. */
18
+ groupSize?: number;
19
+ /** Row height in px. Default 24. */
20
+ rowHeight?: number;
21
+ /** Shown when `root` is an empty list. */
22
+ emptyMessage?: ReactNode;
23
+ }
24
+ /** A row. The indent stops at a quarter of its width, so deep rows keep room for their name and value. */
25
+ export declare const objectTreeRowVariants: (props?: ({
26
+ kind?: "section" | "range" | "note" | "node" | null | undefined;
27
+ stale?: boolean | null | undefined;
28
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
29
+ export declare function ObjectTree<T = unknown>({ 'aria-label': ariaLabel, root: rootProp, loadChildren, onInvokeGetter, onSelect, copyValue, groupSize, rowHeight, emptyMessage, className, style, ...props }: ObjectTreeProps<T>): import("react/jsx-runtime").JSX.Element;
30
+ //# sourceMappingURL=object-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-tree.d.ts","sourceRoot":"","sources":["../../src/components/object-tree.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0F,KAAK,cAAc,EAAsB,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAWxL,OAAO,EAGL,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EACtE,MAAM,yBAAyB,CAAC;AAWjC,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5H,YAAY,EAAE,MAAM,CAAC;IACrB;iIAC6H;IAC7H,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACxB;6DACyD;IACzD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IACjH,qFAAqF;IACrF,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAC7G,oHAAoH;IACpH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,wHAAwH;IACxH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAClE,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;AAID,0GAA0G;AAC1G,eAAO,MAAM,qBAAqB;;;8EAkBjC,CAAC;AA6PF,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,EACtC,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAc,EAAE,YAAgC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,EACpL,EAAE,eAAe,CAAC,CAAC,CAAC,2CA6KpB"}