@mcurcio/patchbay 0.0.0-stage → 0.1.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -2
  3. package/dist/base.css +22 -0
  4. package/dist/composites.js +0 -0
  5. package/dist/graph.js +0 -0
  6. package/dist/hooks.js +71 -0
  7. package/dist/hooks.js.map +1 -0
  8. package/dist/primitives.css +1 -0
  9. package/dist/primitives.js +643 -0
  10. package/dist/primitives.js.map +1 -0
  11. package/dist/shell.js +0 -0
  12. package/dist/tokens.css +212 -0
  13. package/dist/types/composites/index.d.ts +1 -0
  14. package/dist/types/graph/index.d.ts +1 -0
  15. package/dist/types/hooks/index.d.ts +2 -0
  16. package/dist/types/hooks/use-persistent-state/index.d.ts +2 -0
  17. package/dist/types/hooks/use-persistent-state/usePersistentState.d.ts +27 -0
  18. package/dist/types/hooks/use-theme/index.d.ts +2 -0
  19. package/dist/types/hooks/use-theme/useTheme.d.ts +31 -0
  20. package/dist/types/primitives/badge/Badge.d.ts +16 -0
  21. package/dist/types/primitives/badge/index.d.ts +2 -0
  22. package/dist/types/primitives/button/Button.d.ts +13 -0
  23. package/dist/types/primitives/button/index.d.ts +2 -0
  24. package/dist/types/primitives/checkbox/Checkbox.d.ts +9 -0
  25. package/dist/types/primitives/checkbox/index.d.ts +2 -0
  26. package/dist/types/primitives/dialog/CloseGlyph.d.ts +1 -0
  27. package/dist/types/primitives/dialog/Dialog.d.ts +18 -0
  28. package/dist/types/primitives/dialog/index.d.ts +2 -0
  29. package/dist/types/primitives/field/Field.d.ts +22 -0
  30. package/dist/types/primitives/field/index.d.ts +2 -0
  31. package/dist/types/primitives/icon-button/IconButton.d.ts +10 -0
  32. package/dist/types/primitives/icon-button/index.d.ts +2 -0
  33. package/dist/types/primitives/index.d.ts +19 -0
  34. package/dist/types/primitives/key-value/KeyValue.d.ts +24 -0
  35. package/dist/types/primitives/key-value/index.d.ts +2 -0
  36. package/dist/types/primitives/panel/Panel.d.ts +13 -0
  37. package/dist/types/primitives/panel/index.d.ts +2 -0
  38. package/dist/types/primitives/panel/scroll-focus.d.ts +5 -0
  39. package/dist/types/primitives/pill/Pill.d.ts +20 -0
  40. package/dist/types/primitives/pill/index.d.ts +2 -0
  41. package/dist/types/primitives/section-title/SectionTitle.d.ts +14 -0
  42. package/dist/types/primitives/section-title/index.d.ts +2 -0
  43. package/dist/types/primitives/select/Select.d.ts +8 -0
  44. package/dist/types/primitives/select/index.d.ts +2 -0
  45. package/dist/types/primitives/sheet/Sheet.d.ts +23 -0
  46. package/dist/types/primitives/sheet/index.d.ts +2 -0
  47. package/dist/types/primitives/spinner/Spinner.d.ts +7 -0
  48. package/dist/types/primitives/spinner/index.d.ts +2 -0
  49. package/dist/types/primitives/splitter/Splitter.d.ts +25 -0
  50. package/dist/types/primitives/splitter/index.d.ts +2 -0
  51. package/dist/types/primitives/splitter/splitter-math.d.ts +19 -0
  52. package/dist/types/primitives/text-input/TextInput.d.ts +8 -0
  53. package/dist/types/primitives/text-input/index.d.ts +2 -0
  54. package/dist/types/primitives/theme-switch/ThemeSwitch.d.ts +28 -0
  55. package/dist/types/primitives/theme-switch/index.d.ts +2 -0
  56. package/dist/types/primitives/tool-group/ToolGroup.d.ts +5 -0
  57. package/dist/types/primitives/tool-group/index.d.ts +2 -0
  58. package/dist/types/primitives/toolbar/Toolbar.d.ts +11 -0
  59. package/dist/types/primitives/toolbar/index.d.ts +2 -0
  60. package/dist/types/primitives/toolbar/roving.d.ts +14 -0
  61. package/dist/types/primitives/warn-mark/WarnMark.d.ts +11 -0
  62. package/dist/types/primitives/warn-mark/index.d.ts +2 -0
  63. package/dist/types/shell/index.d.ts +1 -0
  64. package/package.json +121 -4
@@ -0,0 +1,643 @@
1
+ import "./primitives.css";import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
2
+ import { cloneElement as r, isValidElement as i, useCallback as a, useEffect as o, useId as s, useLayoutEffect as c, useRef as l } from "react";
3
+ import { createPortal as u } from "react-dom";
4
+ // src/primitives/badge/Badge.tsx
5
+ function d({ tone: e, children: n, title: r, className: i }) {
6
+ return /* @__PURE__ */ t("span", {
7
+ className: i === void 0 ? "pb-badge" : `pb-badge ${i}`,
8
+ "data-tone": e,
9
+ title: r,
10
+ children: n
11
+ });
12
+ }
13
+ // src/primitives/spinner/Spinner.tsx
14
+ function f({ label: e, className: r, ...i }) {
15
+ let a = r === void 0 ? "pb-spinner" : `pb-spinner ${r}`;
16
+ return e === void 0 || e === "" ? /* @__PURE__ */ t("span", {
17
+ ...i,
18
+ className: a,
19
+ "aria-hidden": "true"
20
+ }) : /* @__PURE__ */ n("span", {
21
+ ...i,
22
+ className: `${a} pb-spinner-labelled`,
23
+ role: "status",
24
+ children: [/* @__PURE__ */ t("span", {
25
+ className: "pb-spinner-ring",
26
+ "aria-hidden": "true"
27
+ }), /* @__PURE__ */ t("span", {
28
+ className: "pb-spinner-label",
29
+ children: e
30
+ })]
31
+ });
32
+ }
33
+ // src/primitives/button/Button.tsx
34
+ function p({ tone: e = "neutral", size: r = "md", busy: i = !1, type: a = "button", className: o, children: s, onClick: c, ...l }) {
35
+ function u(e) {
36
+ i ? e.preventDefault() : c?.(e);
37
+ }
38
+ return /* @__PURE__ */ n("button", {
39
+ ...l,
40
+ type: a,
41
+ className: o === void 0 ? "pb-button" : `pb-button ${o}`,
42
+ "data-tone": e,
43
+ "data-size": r,
44
+ "aria-busy": i || void 0,
45
+ "aria-disabled": i || l["aria-disabled"] || void 0,
46
+ onClick: u,
47
+ children: [/* @__PURE__ */ t("span", {
48
+ className: "pb-button-content",
49
+ children: s
50
+ }), i && /* @__PURE__ */ t(f, { className: "pb-button-spinner" })]
51
+ });
52
+ }
53
+ // src/primitives/checkbox/Checkbox.tsx
54
+ function m(e, t) {
55
+ typeof e == "function" ? e(t) : e != null && (e.current = t);
56
+ }
57
+ function h({ label: e, indeterminate: r = !1, className: i, ref: o, ...s }) {
58
+ let u = l(null), d = a((e) => {
59
+ u.current = e, m(o, e);
60
+ }, [o]);
61
+ c(() => {
62
+ u.current !== null && (u.current.indeterminate = r);
63
+ }, [r]);
64
+ let f = /* @__PURE__ */ t("input", {
65
+ ...s,
66
+ ref: d,
67
+ type: "checkbox",
68
+ className: e === void 0 && i !== void 0 ? `pb-checkbox ${i}` : "pb-checkbox"
69
+ });
70
+ return e === void 0 ? f : /* @__PURE__ */ n("label", {
71
+ className: i === void 0 ? "pb-checkbox-row" : `pb-checkbox-row ${i}`,
72
+ "data-disabled": s.disabled === !0 || void 0,
73
+ children: [f, /* @__PURE__ */ t("span", {
74
+ className: "pb-checkbox-label",
75
+ children: e
76
+ })]
77
+ });
78
+ }
79
+ // src/primitives/icon-button/IconButton.tsx
80
+ function g({ label: e, title: n, className: r, children: i, ...a }) {
81
+ return /* @__PURE__ */ t(p, {
82
+ ...a,
83
+ className: r === void 0 ? "pb-icon-button" : `pb-icon-button ${r}`,
84
+ "aria-label": e,
85
+ title: n ?? e,
86
+ children: /* @__PURE__ */ t("span", {
87
+ className: "pb-icon-button-glyph",
88
+ "aria-hidden": "true",
89
+ children: i
90
+ })
91
+ });
92
+ }
93
+ // src/primitives/dialog/CloseGlyph.tsx
94
+ function _() {
95
+ return /* @__PURE__ */ t("svg", {
96
+ viewBox: "0 0 16 16",
97
+ width: "12",
98
+ height: "12",
99
+ "aria-hidden": "true",
100
+ children: /* @__PURE__ */ t("path", {
101
+ d: "M3 3l10 10M13 3L3 13",
102
+ fill: "none",
103
+ stroke: "currentColor",
104
+ strokeWidth: "1.75"
105
+ })
106
+ });
107
+ }
108
+ // src/primitives/dialog/Dialog.tsx
109
+ var v = "a[href],button:not([disabled]),input:not([disabled]):not([type='hidden']),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex='-1']),[contenteditable='true']";
110
+ function y(e) {
111
+ return [...e.querySelectorAll(v)].filter((e) => e.closest("[hidden], [inert]") === null && e.tabIndex >= 0);
112
+ }
113
+ function b(e) {
114
+ let t = e.ownerDocument.querySelectorAll(".pb-dialog");
115
+ return t[t.length - 1] === e;
116
+ }
117
+ function x({ onClose: e, title: r, children: i, actions: a, closeLabel: c = "Close", className: u }) {
118
+ let d = l(null), f = l(null), p = s(), m = l(e);
119
+ return o(() => {
120
+ m.current = e;
121
+ }, [e]), o(() => {
122
+ let e = d.current;
123
+ if (e === null) return;
124
+ let t = document.activeElement instanceof HTMLElement ? document.activeElement : null;
125
+ if (!e.contains(document.activeElement)) {
126
+ let t = f.current;
127
+ (t === null ? void 0 : y(t)[0])?.focus(), e.contains(document.activeElement) || e.focus();
128
+ }
129
+ let n = (t) => {
130
+ b(e) && (t.target instanceof Node && e.contains(t.target) || (y(e)[0] ?? e).focus());
131
+ };
132
+ return document.addEventListener("focusin", n), () => {
133
+ document.removeEventListener("focusin", n), t?.isConnected === !0 && t.focus();
134
+ };
135
+ }, []), /* @__PURE__ */ t("div", {
136
+ className: "pb-dialog-scrim",
137
+ onMouseDown: (e) => {
138
+ e.target === e.currentTarget && m.current();
139
+ },
140
+ children: /* @__PURE__ */ n("div", {
141
+ ref: d,
142
+ className: u === void 0 ? "pb-dialog" : `pb-dialog ${u}`,
143
+ role: "dialog",
144
+ "aria-modal": "true",
145
+ "aria-labelledby": p,
146
+ tabIndex: -1,
147
+ onKeyDown: (e) => {
148
+ if (e.defaultPrevented) return;
149
+ if (e.key === "Escape") {
150
+ e.preventDefault(), e.stopPropagation(), m.current();
151
+ return;
152
+ }
153
+ if (e.key !== "Tab" || d.current === null) return;
154
+ let t = y(d.current), n = t[0], r = t[t.length - 1];
155
+ if (n === void 0 || r === void 0) {
156
+ e.preventDefault();
157
+ return;
158
+ }
159
+ let i = document.activeElement;
160
+ e.shiftKey && (i === n || i === d.current) ? (e.preventDefault(), r.focus()) : !e.shiftKey && i === r && (e.preventDefault(), n.focus());
161
+ },
162
+ children: [
163
+ /* @__PURE__ */ n("div", {
164
+ className: "pb-dialog-head",
165
+ children: [/* @__PURE__ */ t("h2", {
166
+ className: "pb-dialog-title",
167
+ id: p,
168
+ children: r
169
+ }), /* @__PURE__ */ t(g, {
170
+ className: "pb-dialog-close",
171
+ label: c,
172
+ onClick: () => {
173
+ m.current();
174
+ },
175
+ children: /* @__PURE__ */ t(_, {})
176
+ })]
177
+ }),
178
+ /* @__PURE__ */ t("div", {
179
+ ref: f,
180
+ className: "pb-dialog-body",
181
+ tabIndex: 0,
182
+ children: i
183
+ }),
184
+ a === void 0 ? null : /* @__PURE__ */ t("div", {
185
+ className: "pb-dialog-actions",
186
+ children: a
187
+ })
188
+ ]
189
+ })
190
+ });
191
+ }
192
+ function S({ open: e, ...n }) {
193
+ return e ? u(/* @__PURE__ */ t(x, { ...n }), document.body) : null;
194
+ }
195
+ // src/primitives/field/Field.tsx
196
+ function C(e) {
197
+ return e != null && e !== !1 && e !== "";
198
+ }
199
+ function w({ label: e, error: a, hint: o, layout: c = "stacked", className: l, children: u, ...d }) {
200
+ let f = s(), p = u, m = i(p) ? p.props : void 0, h = m?.id ?? `${f}-control`, g = C(o) ? `${f}-hint` : void 0, _ = C(a) ? `${f}-error` : void 0, v = [
201
+ m?.["aria-describedby"],
202
+ g,
203
+ _
204
+ ].filter((e) => e !== void 0 && e !== ""), y = m === void 0 ? u : r(u, {
205
+ id: h,
206
+ "aria-describedby": v.length > 0 ? v.join(" ") : void 0,
207
+ "aria-invalid": _ !== void 0 || m["aria-invalid"]
208
+ });
209
+ return /* @__PURE__ */ n("div", {
210
+ ...d,
211
+ className: l === void 0 ? "pb-field" : `pb-field ${l}`,
212
+ "data-layout": c,
213
+ "data-invalid": _ !== void 0 || void 0,
214
+ children: [/* @__PURE__ */ t("label", {
215
+ className: "pb-field-label",
216
+ htmlFor: h,
217
+ children: e
218
+ }), /* @__PURE__ */ n("div", {
219
+ className: "pb-field-control",
220
+ children: [
221
+ y,
222
+ g !== void 0 && /* @__PURE__ */ t("div", {
223
+ className: "pb-field-hint",
224
+ id: g,
225
+ children: o
226
+ }),
227
+ _ !== void 0 && /* @__PURE__ */ t("div", {
228
+ className: "pb-field-error",
229
+ id: _,
230
+ children: a
231
+ })
232
+ ]
233
+ })]
234
+ });
235
+ }
236
+ // src/primitives/key-value/KeyValue.tsx
237
+ function T({ rows: e, label: r, className: i }) {
238
+ return /* @__PURE__ */ t("dl", {
239
+ className: i === void 0 ? "pb-key-value" : `pb-key-value ${i}`,
240
+ "aria-label": r,
241
+ children: e.map((e, r) => /* @__PURE__ */ n("div", {
242
+ className: "pb-key-value-row",
243
+ "data-tone": e.tone,
244
+ children: [/* @__PURE__ */ t("dt", {
245
+ title: e.title,
246
+ children: e.key
247
+ }), /* @__PURE__ */ t("dd", { children: e.value })]
248
+ }, r))
249
+ });
250
+ }
251
+ // src/primitives/panel/scroll-focus.ts
252
+ function E(e) {
253
+ return e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth;
254
+ }
255
+ function D(e) {
256
+ o(() => {
257
+ let t = e.current;
258
+ if (t === null) return;
259
+ let n = () => {
260
+ E(t) ? t.tabIndex = 0 : t.removeAttribute("tabindex");
261
+ };
262
+ n();
263
+ let r = typeof ResizeObserver == "function" ? new ResizeObserver(n) : null, i = () => {
264
+ if (r !== null) {
265
+ r.disconnect(), r.observe(t);
266
+ for (let e of t.children) r.observe(e);
267
+ }
268
+ };
269
+ i();
270
+ let a = new MutationObserver(() => {
271
+ i(), n();
272
+ });
273
+ return a.observe(t, {
274
+ childList: !0,
275
+ subtree: !0,
276
+ characterData: !0
277
+ }), () => {
278
+ r?.disconnect(), a.disconnect();
279
+ };
280
+ }, [e]);
281
+ }
282
+ // src/primitives/panel/Panel.tsx
283
+ function O({ title: e, actions: r, level: i = 2, className: a, children: o, ...c }) {
284
+ let u = s(), d = l(null);
285
+ D(d);
286
+ let f = `h${String(i)}`, p = e !== void 0 || r !== void 0;
287
+ return /* @__PURE__ */ n("section", {
288
+ ...c,
289
+ "aria-labelledby": c["aria-labelledby"] ?? (e !== void 0 && c["aria-label"] === void 0 ? u : void 0),
290
+ className: a === void 0 ? "pb-panel" : `pb-panel ${a}`,
291
+ children: [p && /* @__PURE__ */ n("header", {
292
+ className: "pb-panel-header",
293
+ children: [e !== void 0 && /* @__PURE__ */ t(f, {
294
+ id: u,
295
+ className: "pb-panel-title",
296
+ children: e
297
+ }), r !== void 0 && /* @__PURE__ */ t("div", {
298
+ className: "pb-panel-actions",
299
+ children: r
300
+ })]
301
+ }), /* @__PURE__ */ t("div", {
302
+ ref: d,
303
+ className: "pb-panel-body",
304
+ children: o
305
+ })]
306
+ });
307
+ }
308
+ // src/primitives/pill/Pill.tsx
309
+ function k({ tone: e, label: r, pulse: i = !1, title: a, detail: o, className: s }) {
310
+ return /* @__PURE__ */ n("span", {
311
+ className: s === void 0 ? "pb-pill" : `pb-pill ${s}`,
312
+ "data-tone": e,
313
+ "data-pulse": i ? "" : void 0,
314
+ title: a,
315
+ children: [
316
+ /* @__PURE__ */ t("span", {
317
+ className: "pb-pill-dot",
318
+ "aria-hidden": "true"
319
+ }),
320
+ r,
321
+ o !== void 0 && /* @__PURE__ */ t("code", {
322
+ className: "pb-pill-detail",
323
+ children: o
324
+ })
325
+ ]
326
+ });
327
+ }
328
+ // src/primitives/section-title/SectionTitle.tsx
329
+ function A({ children: e, actions: r, level: i = 3, className: a }) {
330
+ let o = `h${i}`;
331
+ return /* @__PURE__ */ n("div", {
332
+ className: a === void 0 ? "pb-section-title" : `pb-section-title ${a}`,
333
+ children: [/* @__PURE__ */ t(o, {
334
+ className: "pb-section-title-text",
335
+ children: e
336
+ }), r !== void 0 && /* @__PURE__ */ t("div", {
337
+ className: "pb-section-title-actions",
338
+ children: r
339
+ })]
340
+ });
341
+ }
342
+ // src/primitives/select/Select.tsx
343
+ function j({ font: e = "ui", className: n, children: r, ...i }) {
344
+ return /* @__PURE__ */ t("select", {
345
+ ...i,
346
+ className: n === void 0 ? "pb-select" : `pb-select ${n}`,
347
+ "data-font": e,
348
+ children: r
349
+ });
350
+ }
351
+ // src/primitives/sheet/Sheet.tsx
352
+ function M({ onClose: e, side: r = "right", title: i, label: a, children: c, width: u, closeLabel: d = "Close", className: f }) {
353
+ let p = l(null), m = s(), h = l(null);
354
+ o(() => {
355
+ let e = p.current;
356
+ return () => {
357
+ let t = h.current, n = document.activeElement;
358
+ (n === null || n === document.body || (e?.contains(n) ?? !1)) && t?.isConnected === !0 && t.focus();
359
+ };
360
+ }, []);
361
+ let v = (e) => {
362
+ let t = e.relatedTarget;
363
+ t instanceof HTMLElement && !e.currentTarget.contains(t) && (h.current = t);
364
+ }, y = (t) => {
365
+ t.defaultPrevented || t.key !== "Escape" || (t.preventDefault(), t.stopPropagation(), e());
366
+ }, b = u === void 0 ? void 0 : { "--pb-sheet-width": `${u}px` };
367
+ return /* @__PURE__ */ n("section", {
368
+ ref: p,
369
+ className: f === void 0 ? "pb-sheet" : `pb-sheet ${f}`,
370
+ "data-side": r,
371
+ role: "dialog",
372
+ "aria-labelledby": i === void 0 ? void 0 : m,
373
+ "aria-label": i === void 0 ? a : void 0,
374
+ style: b,
375
+ onFocus: v,
376
+ onKeyDown: y,
377
+ children: [/* @__PURE__ */ n("div", {
378
+ className: "pb-sheet-head",
379
+ children: [i === void 0 ? /* @__PURE__ */ t("span", { className: "pb-sheet-title" }) : /* @__PURE__ */ t("h2", {
380
+ className: "pb-sheet-title",
381
+ id: m,
382
+ children: i
383
+ }), /* @__PURE__ */ t(g, {
384
+ className: "pb-sheet-close",
385
+ label: d,
386
+ onClick: e,
387
+ children: /* @__PURE__ */ t(_, {})
388
+ })]
389
+ }), /* @__PURE__ */ t("div", {
390
+ className: "pb-sheet-body",
391
+ tabIndex: 0,
392
+ children: c
393
+ })]
394
+ });
395
+ }
396
+ function N({ open: e, ...n }) {
397
+ return e ? /* @__PURE__ */ t(M, { ...n }) : null;
398
+ }
399
+ // src/primitives/splitter/splitter-math.ts
400
+ function P(e, t) {
401
+ let n = Math.max(t.min, t.max);
402
+ return Math.round(Math.min(n, Math.max(t.min, e)));
403
+ }
404
+ function F(e, t, n, r) {
405
+ return P(e + n * t, r);
406
+ }
407
+ function I(e, t) {
408
+ return e === "vertical" ? t === "start" ? "ArrowLeft" : "ArrowRight" : t === "start" ? "ArrowUp" : "ArrowDown";
409
+ }
410
+ var L = {
411
+ ArrowLeft: "ArrowRight",
412
+ ArrowRight: "ArrowLeft",
413
+ ArrowUp: "ArrowDown",
414
+ ArrowDown: "ArrowUp"
415
+ };
416
+ function R(e, t, n, r, i) {
417
+ if (t === n) return P(e + r, i);
418
+ if (t === L[n]) return P(e - r, i);
419
+ if (t === "Home") return P(i.min, i);
420
+ if (t === "End") return P(i.max, i);
421
+ }
422
+ // src/primitives/splitter/Splitter.tsx
423
+ function z({ orientation: e, value: n, min: r, max: i, onChange: a, label: o, edge: s = "start", step: c = 16, className: u, onPointerDown: d, onPointerMove: f, onPointerUp: p, onPointerCancel: m, onKeyDown: h, ...g }) {
424
+ let _ = l(null), v = {
425
+ min: r,
426
+ max: i
427
+ }, y = (t) => e === "vertical" ? t.clientX : t.clientY;
428
+ function b(e) {
429
+ if (d?.(e), e.defaultPrevented || e.button !== 0) return;
430
+ e.preventDefault();
431
+ let t = e.currentTarget;
432
+ typeof t.setPointerCapture == "function" && t.setPointerCapture(e.pointerId), t.focus(), t.dataset.dragging = "", _.current = {
433
+ start: n,
434
+ at: y(e)
435
+ };
436
+ }
437
+ function x(e) {
438
+ f?.(e);
439
+ let t = _.current;
440
+ if (t === null) return;
441
+ let r = F(t.start, y(e) - t.at, s === "start" ? -1 : 1, v);
442
+ r !== n && a(r);
443
+ }
444
+ function S(e) {
445
+ if (e.type === "pointercancel" ? m?.(e) : p?.(e), _.current === null) return;
446
+ _.current = null;
447
+ let t = e.currentTarget;
448
+ delete t.dataset.dragging, typeof t.hasPointerCapture == "function" && t.hasPointerCapture(e.pointerId) && t.releasePointerCapture(e.pointerId);
449
+ }
450
+ function C(t) {
451
+ if (h?.(t), t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey) return;
452
+ let r = R(n, t.key, I(e, s), c, v);
453
+ r !== void 0 && (t.preventDefault(), r !== n && a(r));
454
+ }
455
+ return /* @__PURE__ */ t("div", {
456
+ ...g,
457
+ role: "separator",
458
+ tabIndex: g.tabIndex ?? 0,
459
+ "aria-orientation": e,
460
+ "aria-label": o,
461
+ "aria-valuenow": n,
462
+ "aria-valuemin": r,
463
+ "aria-valuemax": i,
464
+ className: u === void 0 ? "pb-splitter" : `pb-splitter ${u}`,
465
+ "data-orientation": e,
466
+ "data-edge": s,
467
+ onPointerDown: b,
468
+ onPointerMove: x,
469
+ onPointerUp: S,
470
+ onPointerCancel: S,
471
+ onKeyDown: C
472
+ });
473
+ }
474
+ // src/primitives/text-input/TextInput.tsx
475
+ function B({ font: e = "ui", type: n = "text", className: r, ...i }) {
476
+ return /* @__PURE__ */ t("input", {
477
+ ...i,
478
+ type: n,
479
+ className: r === void 0 ? "pb-text-input" : `pb-text-input ${r}`,
480
+ "data-font": e
481
+ });
482
+ }
483
+ // src/primitives/theme-switch/ThemeSwitch.tsx
484
+ var V = {
485
+ theme: "Theme",
486
+ system: "system",
487
+ light: "light",
488
+ dark: "dark",
489
+ systemHint: "follows the system's setting",
490
+ clickFor: "click for"
491
+ }, H = [
492
+ "system",
493
+ "light",
494
+ "dark"
495
+ ];
496
+ function U(e) {
497
+ return H[(H.indexOf(e) + 1) % H.length] ?? "system";
498
+ }
499
+ function W(e, t = V) {
500
+ let n = e === "system" ? ` (${t.systemHint})` : "";
501
+ return `${t.theme}: ${t[e]}${n}; ${t.clickFor} ${t[U(e)]}`;
502
+ }
503
+ function G({ choice: e, onChoose: r, labels: i, className: a, ...o }) {
504
+ let s = {
505
+ ...V,
506
+ ...i
507
+ };
508
+ return /* @__PURE__ */ n("button", {
509
+ ...o,
510
+ type: "button",
511
+ className: a === void 0 ? "pb-theme-switch" : `pb-theme-switch ${a}`,
512
+ title: W(e, s),
513
+ "aria-label": `${s.theme}: ${s[e]}`,
514
+ onClick: () => {
515
+ r(U(e));
516
+ },
517
+ children: [/* @__PURE__ */ n("svg", {
518
+ className: "pb-theme-switch-icon",
519
+ viewBox: "0 0 16 16",
520
+ width: "14",
521
+ height: "14",
522
+ "aria-hidden": "true",
523
+ children: [/* @__PURE__ */ t("circle", {
524
+ cx: "8",
525
+ cy: "8",
526
+ r: "6.25",
527
+ fill: "none",
528
+ stroke: "currentColor",
529
+ strokeWidth: "1.5"
530
+ }), /* @__PURE__ */ t("path", {
531
+ d: "M8 1.75a6.25 6.25 0 0 1 0 12.5z",
532
+ fill: "currentColor"
533
+ })]
534
+ }), /* @__PURE__ */ t("span", {
535
+ className: "pb-theme-switch-word",
536
+ children: s[e]
537
+ })]
538
+ });
539
+ }
540
+ // src/primitives/toolbar/roving.ts
541
+ var K = "button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [role=\"button\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"menuitem\"], [role=\"switch\"]";
542
+ function q(e) {
543
+ return [...e.querySelectorAll(K)].filter((t) => t.closest("[role=\"toolbar\"]") === e);
544
+ }
545
+ function J(e, t) {
546
+ let n = t !== null && e.includes(t) ? t : e[0] ?? null;
547
+ for (let t of e) t.tabIndex = t === n ? 0 : -1;
548
+ return n;
549
+ }
550
+ function Y(e, t, n, r, i) {
551
+ if (t === 0) return;
552
+ if (n === "Home") return 0;
553
+ if (n === "End") return t - 1;
554
+ let [a, o] = r === "vertical" ? ["ArrowUp", "ArrowDown"] : i ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
555
+ if (n === o) return (e + 1) % t;
556
+ if (n === a) return (e - 1 + t) % t;
557
+ }
558
+ function X(e) {
559
+ return e instanceof HTMLTextAreaElement ? !0 : e instanceof HTMLInputElement ? ![
560
+ "button",
561
+ "checkbox",
562
+ "radio",
563
+ "reset",
564
+ "submit",
565
+ "image",
566
+ "color",
567
+ "file",
568
+ "range"
569
+ ].includes(e.type) : e instanceof HTMLElement && e.isContentEditable;
570
+ }
571
+ // src/primitives/toolbar/Toolbar.tsx
572
+ function Z({ label: e, orientation: n = "horizontal", className: r, ref: i, onKeyDown: a, onFocus: s, children: c, ...u }) {
573
+ let d = l(null), f = l(null);
574
+ o(() => {
575
+ let e = d.current;
576
+ if (e === null) return;
577
+ let t = () => {
578
+ f.current = J(q(e), f.current);
579
+ };
580
+ t();
581
+ let n = new MutationObserver(t);
582
+ return n.observe(e, {
583
+ childList: !0,
584
+ subtree: !0,
585
+ attributes: !0,
586
+ attributeFilter: ["disabled", "href"]
587
+ }), () => {
588
+ n.disconnect();
589
+ };
590
+ });
591
+ function p(e) {
592
+ s?.(e);
593
+ let t = d.current;
594
+ if (t === null) return;
595
+ let n = q(t);
596
+ e.target instanceof HTMLElement && n.includes(e.target) && (f.current = J(n, e.target));
597
+ }
598
+ function m(e) {
599
+ a?.(e);
600
+ let t = d.current;
601
+ if (e.defaultPrevented || t === null || e.altKey || e.ctrlKey || e.metaKey || X(e.target)) return;
602
+ let r = q(t), i = r.indexOf(e.target);
603
+ if (i === -1) return;
604
+ let o = getComputedStyle(t).direction === "rtl", s = Y(i, r.length, e.key, n, o);
605
+ s !== void 0 && (e.preventDefault(), r[s]?.focus());
606
+ }
607
+ return /* @__PURE__ */ t("div", {
608
+ ...u,
609
+ ref: (e) => {
610
+ if (d.current = e, typeof i == "function") return i(e);
611
+ i && (i.current = e);
612
+ },
613
+ role: "toolbar",
614
+ "aria-label": e,
615
+ "aria-orientation": n,
616
+ className: r === void 0 ? "pb-toolbar" : `pb-toolbar ${r}`,
617
+ onKeyDown: m,
618
+ onFocus: p,
619
+ children: c
620
+ });
621
+ }
622
+ // src/primitives/tool-group/ToolGroup.tsx
623
+ function Q({ className: e, ...n }) {
624
+ return /* @__PURE__ */ t(Z, {
625
+ ...n,
626
+ className: e === void 0 ? "pb-tool-group" : `pb-tool-group ${e}`
627
+ });
628
+ }
629
+ // src/primitives/warn-mark/WarnMark.tsx
630
+ function $({ label: r, title: i, className: a }) {
631
+ return /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("span", {
632
+ className: a === void 0 ? "pb-warn-mark" : `pb-warn-mark ${a}`,
633
+ "aria-hidden": "true",
634
+ title: i,
635
+ children: "!"
636
+ }), /* @__PURE__ */ t("span", {
637
+ className: "pb-warn-mark-text",
638
+ children: r
639
+ })] });
640
+ }
641
+ export { d as Badge, p as Button, h as Checkbox, S as Dialog, w as Field, g as IconButton, T as KeyValue, O as Panel, k as Pill, A as SectionTitle, j as Select, N as Sheet, f as Spinner, z as Splitter, B as TextInput, G as ThemeSwitch, Q as ToolGroup, Z as Toolbar, $ as WarnMark, V as defaultThemeSwitchLabels, W as themeSwitchTitle };
642
+
643
+ //# sourceMappingURL=primitives.js.map