@mcurcio/patchbay 0.5.0 → 0.7.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.
- package/README.md +9 -7
- package/dist/composites.js +190 -158
- package/dist/composites.js.map +1 -1
- package/dist/graph.css +1 -1
- package/dist/graph.js +639 -63
- package/dist/graph.js.map +1 -1
- package/dist/primitives.css +1 -1
- package/dist/primitives.js +108 -93
- package/dist/primitives.js.map +1 -1
- package/dist/testing.js +207 -0
- package/dist/testing.js.map +1 -0
- package/dist/tokens.css +22 -2
- package/dist/types/composites/banner/Banner.d.ts +9 -3
- package/dist/types/composites/banner/index.d.ts +2 -2
- package/dist/types/composites/command-palette/CommandPalette.d.ts +16 -10
- package/dist/types/composites/command-palette/index.d.ts +2 -2
- package/dist/types/composites/shortcut-sheet/ShortcutSheet.d.ts +17 -11
- package/dist/types/composites/shortcut-sheet/index.d.ts +2 -2
- package/dist/types/composites/toaster/Toaster.d.ts +15 -9
- package/dist/types/composites/toaster/index.d.ts +2 -2
- package/dist/types/graph/add-at/index.d.ts +2 -0
- package/dist/types/graph/add-at/useAddAt.d.ts +32 -0
- package/dist/types/graph/canvas-tools/CanvasTools.d.ts +40 -0
- package/dist/types/graph/canvas-tools/index.d.ts +2 -0
- package/dist/types/graph/canvas-tools/motion.d.ts +2 -0
- package/dist/types/graph/connect-hints/index.d.ts +4 -0
- package/dist/types/graph/connect-hints/mergeFlowProps.d.ts +10 -0
- package/dist/types/graph/connect-hints/useConnectHints.d.ts +48 -0
- package/dist/types/graph/follow-fit/index.d.ts +2 -0
- package/dist/types/graph/follow-fit/useFollowFit.d.ts +21 -0
- package/dist/types/graph/ghost-wire/GhostWire.d.ts +16 -0
- package/dist/types/graph/ghost-wire/index.d.ts +2 -0
- package/dist/types/graph/index.d.ts +8 -0
- package/dist/types/graph/meter/Meter.d.ts +9 -3
- package/dist/types/graph/meter/index.d.ts +2 -2
- package/dist/types/graph/node-box/NodeBox.d.ts +52 -0
- package/dist/types/graph/node-box/geometry.d.ts +47 -0
- package/dist/types/graph/node-box/index.d.ts +4 -0
- package/dist/types/graph/port-row/PortRow.d.ts +31 -0
- package/dist/types/graph/port-row/index.d.ts +2 -0
- package/dist/types/graph/wire/Wire.d.ts +27 -0
- package/dist/types/graph/wire/index.d.ts +2 -0
- package/dist/types/primitives/dialog/Dialog.d.ts +8 -2
- package/dist/types/primitives/dialog/index.d.ts +2 -2
- package/dist/types/primitives/sheet/Sheet.d.ts +8 -2
- package/dist/types/primitives/sheet/index.d.ts +2 -2
- package/dist/types/primitives/splitter/Splitter.d.ts +8 -2
- package/dist/types/primitives/splitter/splitter-math.d.ts +12 -4
- package/dist/types/testing/brand-css.d.ts +41 -0
- package/dist/types/testing/contrast.d.ts +36 -0
- package/dist/types/testing/index.d.ts +2 -0
- package/package.json +6 -2
package/dist/composites.js
CHANGED
|
@@ -4,7 +4,12 @@ import { createPortal as u } from "react-dom";
|
|
|
4
4
|
import { Button as d, Dialog as f, IconButton as p } from "./primitives.js";
|
|
5
5
|
import { ariaKeyShortcuts as m, keyLabel as h } from "./hooks.js";
|
|
6
6
|
// src/composites/banner/Banner.tsx
|
|
7
|
-
|
|
7
|
+
var g = { dismiss: "Dismiss" };
|
|
8
|
+
function _({ tone: e, children: r, actions: i, onDismiss: a, labels: o, className: s, ...c }) {
|
|
9
|
+
let l = {
|
|
10
|
+
...g,
|
|
11
|
+
...o
|
|
12
|
+
};
|
|
8
13
|
return /* @__PURE__ */ n("div", {
|
|
9
14
|
...c,
|
|
10
15
|
role: e === "err" ? "alert" : "status",
|
|
@@ -22,7 +27,7 @@ function g({ tone: e, children: r, actions: i, onDismiss: a, dismissLabel: o = "
|
|
|
22
27
|
a !== void 0 && /* @__PURE__ */ t(p, {
|
|
23
28
|
className: "pb-banner-dismiss",
|
|
24
29
|
size: "sm",
|
|
25
|
-
label:
|
|
30
|
+
label: l.dismiss,
|
|
26
31
|
onClick: a,
|
|
27
32
|
children: /* @__PURE__ */ t("svg", {
|
|
28
33
|
viewBox: "0 0 16 16",
|
|
@@ -41,39 +46,39 @@ function g({ tone: e, children: r, actions: i, onDismiss: a, dismissLabel: o = "
|
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
// src/composites/command-palette/rank.ts
|
|
44
|
-
function
|
|
49
|
+
function v(e, t) {
|
|
45
50
|
if (t === 0) return !0;
|
|
46
51
|
let n = e.charAt(t - 1), r = e.charAt(t);
|
|
47
52
|
return !/[\p{L}\p{N}]/u.test(n) || n !== n.toUpperCase() && r !== r.toLowerCase() && r === r.toUpperCase();
|
|
48
53
|
}
|
|
49
|
-
function
|
|
54
|
+
function y(e) {
|
|
50
55
|
let t = e.toLowerCase();
|
|
51
56
|
return t.length === 1 ? t : e;
|
|
52
57
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
58
|
+
var b = 3, x = 2, S = 2, C = .1, w = 1, T = .02;
|
|
59
|
+
function E(e, t) {
|
|
55
60
|
let n = t.replace(/\s+/g, "");
|
|
56
61
|
if (n === "") return {
|
|
57
62
|
indices: [],
|
|
58
63
|
score: 0
|
|
59
64
|
};
|
|
60
|
-
let r = Array.from({ length: n.length }, (e, t) =>
|
|
65
|
+
let r = Array.from({ length: n.length }, (e, t) => y(n.charAt(t))), i = Array.from({ length: e.length }, (t, n) => y(e.charAt(n))), a = e.length, o = r.length;
|
|
61
66
|
if (o > a) return;
|
|
62
|
-
let s = i.map((t, n) => n === 0 ?
|
|
67
|
+
let s = i.map((t, n) => n === 0 ? b : v(e, n) ? x : 0), c = [], l = [];
|
|
63
68
|
for (let e = 0; e < o; e += 1) {
|
|
64
69
|
let t = Array(a).fill(-Infinity), n = Array(a).fill(-1), o = r[e];
|
|
65
70
|
for (let r = e; r < a; r += 1) {
|
|
66
71
|
if (i[r] !== o) continue;
|
|
67
72
|
let a = 1 + (s[r] ?? 0);
|
|
68
73
|
if (e === 0) {
|
|
69
|
-
t[r] = a - r *
|
|
74
|
+
t[r] = a - r * T;
|
|
70
75
|
continue;
|
|
71
76
|
}
|
|
72
77
|
let l = c[e - 1] ?? [];
|
|
73
78
|
for (let i = e - 1; i < r; i += 1) {
|
|
74
79
|
let e = l[i] ?? -Infinity;
|
|
75
80
|
if (e === -Infinity) continue;
|
|
76
|
-
let o = i === r - 1 ?
|
|
81
|
+
let o = i === r - 1 ? S : -Math.min((r - i - 1) * C, w), s = e + a + o;
|
|
77
82
|
s > (t[r] ?? -Infinity) && (t[r] = s, n[r] = i);
|
|
78
83
|
}
|
|
79
84
|
}
|
|
@@ -89,10 +94,10 @@ function T(e, t) {
|
|
|
89
94
|
score: u[d] ?? 0
|
|
90
95
|
};
|
|
91
96
|
}
|
|
92
|
-
function
|
|
97
|
+
function D(e, t) {
|
|
93
98
|
let n = /* @__PURE__ */ new Map();
|
|
94
99
|
e.forEach((e, r) => {
|
|
95
|
-
let i =
|
|
100
|
+
let i = E(e.label, t);
|
|
96
101
|
if (i === void 0) return;
|
|
97
102
|
let a = n.get(e.group);
|
|
98
103
|
a === void 0 && (a = {
|
|
@@ -123,7 +128,7 @@ function E(e, t) {
|
|
|
123
128
|
}))
|
|
124
129
|
}));
|
|
125
130
|
}
|
|
126
|
-
function
|
|
131
|
+
function O(e, t) {
|
|
127
132
|
let n = new Set(t), r = [];
|
|
128
133
|
for (let t = 0; t < e.length; t += 1) {
|
|
129
134
|
let i = n.has(t), a = r[r.length - 1];
|
|
@@ -135,8 +140,14 @@ function D(e, t) {
|
|
|
135
140
|
return r;
|
|
136
141
|
}
|
|
137
142
|
// src/composites/command-palette/CommandPalette.tsx
|
|
138
|
-
var
|
|
139
|
-
|
|
143
|
+
var k = {
|
|
144
|
+
palette: "Commands",
|
|
145
|
+
placeholder: "Type a command",
|
|
146
|
+
empty: "No commands",
|
|
147
|
+
noMatch: (e) => `No command matches “${e}”`,
|
|
148
|
+
keyNames: {}
|
|
149
|
+
}, A = 320, j = 360, M = 8;
|
|
150
|
+
function N(e, t) {
|
|
140
151
|
let n = Math.max(0, Math.min(320, t.width - 16)), r = Math.max(0, Math.min(360, t.height - 16)), i = (e, t, n) => Math.min(Math.max(e, 8), Math.max(8, n - t - 8));
|
|
141
152
|
return {
|
|
142
153
|
left: i(e.x, n, t.width),
|
|
@@ -145,8 +156,8 @@ function j(e, t) {
|
|
|
145
156
|
height: r
|
|
146
157
|
};
|
|
147
158
|
}
|
|
148
|
-
var
|
|
149
|
-
function
|
|
159
|
+
var P = 8;
|
|
160
|
+
function F(e) {
|
|
150
161
|
let t = () => ({
|
|
151
162
|
width: window.innerWidth,
|
|
152
163
|
height: window.innerHeight
|
|
@@ -161,47 +172,50 @@ function P(e) {
|
|
|
161
172
|
};
|
|
162
173
|
}, [e]), n;
|
|
163
174
|
}
|
|
164
|
-
function
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className: p }) {
|
|
176
|
+
let g = {
|
|
177
|
+
...k,
|
|
178
|
+
...f
|
|
179
|
+
}, _ = a(), v = `${_}-list`, [y, b] = l(""), x = s(() => D(r, y), [r, y]), S = s(() => x.flatMap((e) => e.items.map((e) => e.command)), [x]), C = s(() => S.filter((e) => e.disabled !== !0), [S]), [w, T] = l(void 0), [E, A] = l(y);
|
|
180
|
+
E !== y && (A(y), T(void 0));
|
|
181
|
+
let j = C.find((e) => e.id === w) ?? C[0], M = (e) => `${_}-option-${S.indexOf(e)}`, I = c(null), L = c(null), R = c(null), z = c(e);
|
|
168
182
|
o(() => {
|
|
169
|
-
|
|
183
|
+
z.current = e;
|
|
170
184
|
}), o(() => {
|
|
171
185
|
let e = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
172
|
-
|
|
173
|
-
let t =
|
|
186
|
+
L.current?.focus();
|
|
187
|
+
let t = I.current;
|
|
174
188
|
return () => {
|
|
175
189
|
let n = document.activeElement;
|
|
176
190
|
(n === null || n === document.body || (t?.contains(n) ?? !1) || !n.isConnected) && e?.isConnected === !0 && e.focus();
|
|
177
191
|
};
|
|
178
192
|
}, []), i(() => {
|
|
179
|
-
if (
|
|
180
|
-
let e = document.getElementById(
|
|
193
|
+
if (j === void 0) return;
|
|
194
|
+
let e = document.getElementById(M(j));
|
|
181
195
|
typeof e?.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
182
|
-
}, [
|
|
183
|
-
let
|
|
184
|
-
e.disabled !== !0 && (
|
|
185
|
-
},
|
|
186
|
-
let e =
|
|
187
|
-
return Math.max(1, t ||
|
|
188
|
-
},
|
|
196
|
+
}, [j]);
|
|
197
|
+
let B = (e) => {
|
|
198
|
+
e.disabled !== !0 && (z.current(), e.run());
|
|
199
|
+
}, V = () => {
|
|
200
|
+
let e = R.current?.querySelector("[role=\"option\"]"), t = e && e.offsetHeight > 0 ? Math.floor((R.current?.clientHeight ?? 0) / e.offsetHeight) : 0;
|
|
201
|
+
return Math.max(1, t || P);
|
|
202
|
+
}, H = (e) => {
|
|
189
203
|
if (e.defaultPrevented || e.nativeEvent.isComposing) return;
|
|
190
|
-
let t = e.altKey || e.ctrlKey || e.metaKey, n =
|
|
204
|
+
let t = e.altKey || e.ctrlKey || e.metaKey, n = j === void 0 ? -1 : C.indexOf(j), r = C.length - 1, i = (t) => {
|
|
191
205
|
e.preventDefault();
|
|
192
|
-
let n =
|
|
193
|
-
n !== void 0 &&
|
|
206
|
+
let n = C[Math.min(Math.max(t, 0), r)];
|
|
207
|
+
n !== void 0 && T(n.id);
|
|
194
208
|
};
|
|
195
209
|
switch (e.key) {
|
|
196
210
|
case "Escape":
|
|
197
|
-
e.preventDefault(), e.stopPropagation(),
|
|
211
|
+
e.preventDefault(), e.stopPropagation(), z.current();
|
|
198
212
|
return;
|
|
199
213
|
case "Tab":
|
|
200
|
-
e.preventDefault(),
|
|
214
|
+
e.preventDefault(), z.current();
|
|
201
215
|
return;
|
|
202
216
|
case "Enter":
|
|
203
217
|
if (t) return;
|
|
204
|
-
e.preventDefault(),
|
|
218
|
+
e.preventDefault(), j !== void 0 && B(j);
|
|
205
219
|
return;
|
|
206
220
|
case "ArrowDown":
|
|
207
221
|
if (t) return;
|
|
@@ -213,11 +227,11 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
213
227
|
return;
|
|
214
228
|
case "PageDown":
|
|
215
229
|
if (t) return;
|
|
216
|
-
i(n +
|
|
230
|
+
i(n + V());
|
|
217
231
|
return;
|
|
218
232
|
case "PageUp":
|
|
219
233
|
if (t) return;
|
|
220
|
-
i(n -
|
|
234
|
+
i(n - V());
|
|
221
235
|
return;
|
|
222
236
|
case "Home":
|
|
223
237
|
if (t || e.shiftKey) return;
|
|
@@ -229,61 +243,61 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
229
243
|
return;
|
|
230
244
|
default: return;
|
|
231
245
|
}
|
|
232
|
-
},
|
|
233
|
-
return r.length === 0 ?
|
|
246
|
+
}, U = F(u !== void 0), W = u === void 0 ? void 0 : N(u, U), G = W !== void 0, K;
|
|
247
|
+
return r.length === 0 ? K = g.empty : S.length === 0 && (K = g.noMatch(y.trim())), /* @__PURE__ */ t("div", {
|
|
234
248
|
className: "pb-palette-layer",
|
|
235
|
-
"data-anchored":
|
|
249
|
+
"data-anchored": G ? "" : void 0,
|
|
236
250
|
onMouseDown: (e) => {
|
|
237
|
-
e.target === e.currentTarget &&
|
|
251
|
+
e.target === e.currentTarget && z.current();
|
|
238
252
|
},
|
|
239
253
|
children: /* @__PURE__ */ n("div", {
|
|
240
|
-
ref:
|
|
241
|
-
className:
|
|
254
|
+
ref: I,
|
|
255
|
+
className: p === void 0 ? "pb-palette" : `pb-palette ${p}`,
|
|
242
256
|
role: "dialog",
|
|
243
257
|
"aria-modal": "true",
|
|
244
|
-
"aria-label":
|
|
245
|
-
style:
|
|
258
|
+
"aria-label": g.palette,
|
|
259
|
+
style: W === void 0 ? void 0 : {
|
|
246
260
|
position: "fixed",
|
|
247
|
-
left:
|
|
248
|
-
top:
|
|
249
|
-
width:
|
|
250
|
-
maxHeight:
|
|
261
|
+
left: W.left,
|
|
262
|
+
top: W.top,
|
|
263
|
+
width: W.width,
|
|
264
|
+
maxHeight: W.height
|
|
251
265
|
},
|
|
252
266
|
onBlur: (e) => {
|
|
253
267
|
let t = e.relatedTarget;
|
|
254
|
-
t instanceof Node && !e.currentTarget.contains(t) &&
|
|
268
|
+
t instanceof Node && !e.currentTarget.contains(t) && z.current();
|
|
255
269
|
},
|
|
256
270
|
children: [
|
|
257
271
|
/* @__PURE__ */ t("input", {
|
|
258
|
-
ref:
|
|
272
|
+
ref: L,
|
|
259
273
|
className: "pb-palette-field",
|
|
260
274
|
type: "text",
|
|
261
275
|
role: "combobox",
|
|
262
|
-
"aria-label":
|
|
276
|
+
"aria-label": g.palette,
|
|
263
277
|
"aria-expanded": "true",
|
|
264
|
-
"aria-controls":
|
|
278
|
+
"aria-controls": v,
|
|
265
279
|
"aria-autocomplete": "list",
|
|
266
|
-
"aria-activedescendant":
|
|
280
|
+
"aria-activedescendant": j === void 0 ? void 0 : M(j),
|
|
267
281
|
autoComplete: "off",
|
|
268
282
|
autoCapitalize: "off",
|
|
269
283
|
autoCorrect: "off",
|
|
270
284
|
spellCheck: !1,
|
|
271
|
-
placeholder:
|
|
272
|
-
value:
|
|
285
|
+
placeholder: g.placeholder,
|
|
286
|
+
value: y,
|
|
273
287
|
onChange: (e) => {
|
|
274
|
-
|
|
288
|
+
b(e.target.value);
|
|
275
289
|
},
|
|
276
|
-
onKeyDown:
|
|
290
|
+
onKeyDown: H
|
|
277
291
|
}),
|
|
278
292
|
/* @__PURE__ */ t("div", {
|
|
279
|
-
ref:
|
|
293
|
+
ref: R,
|
|
280
294
|
className: "pb-palette-list",
|
|
281
|
-
id:
|
|
295
|
+
id: v,
|
|
282
296
|
role: "listbox",
|
|
283
|
-
"aria-label":
|
|
284
|
-
hidden:
|
|
285
|
-
children:
|
|
286
|
-
let i = `${
|
|
297
|
+
"aria-label": g.palette,
|
|
298
|
+
hidden: S.length === 0,
|
|
299
|
+
children: x.map((e, r) => {
|
|
300
|
+
let i = `${_}-group-${r}`;
|
|
287
301
|
return /* @__PURE__ */ n("div", {
|
|
288
302
|
role: "group",
|
|
289
303
|
"aria-labelledby": i,
|
|
@@ -294,29 +308,29 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
294
308
|
role: "presentation",
|
|
295
309
|
children: e.group
|
|
296
310
|
}), e.items.map(({ command: e, indices: r }) => {
|
|
297
|
-
let i =
|
|
311
|
+
let i = M(e), a = e.keys === void 0 ? [] : typeof e.keys == "string" ? [e.keys] : e.keys, o = e === j;
|
|
298
312
|
return /* @__PURE__ */ n("div", {
|
|
299
313
|
id: i,
|
|
300
314
|
role: "option",
|
|
301
315
|
"aria-selected": o,
|
|
302
316
|
"aria-disabled": e.disabled === !0 || void 0,
|
|
303
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a,
|
|
317
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a, d),
|
|
304
318
|
className: "pb-palette-option",
|
|
305
319
|
"data-command-id": e.id,
|
|
306
320
|
onMouseDown: (e) => {
|
|
307
321
|
e.preventDefault();
|
|
308
322
|
},
|
|
309
323
|
onPointerMove: () => {
|
|
310
|
-
e.disabled !== !0 && !o &&
|
|
324
|
+
e.disabled !== !0 && !o && T(e.id);
|
|
311
325
|
},
|
|
312
326
|
onClick: () => {
|
|
313
|
-
|
|
327
|
+
B(e);
|
|
314
328
|
},
|
|
315
329
|
children: [/* @__PURE__ */ n("span", {
|
|
316
330
|
className: "pb-palette-text",
|
|
317
331
|
children: [/* @__PURE__ */ t("span", {
|
|
318
332
|
className: "pb-palette-label",
|
|
319
|
-
children:
|
|
333
|
+
children: O(e.label, r).map((e, n) => e.marked ? /* @__PURE__ */ t("mark", { children: e.text }, n) : e.text)
|
|
320
334
|
}), e.hint !== void 0 && /* @__PURE__ */ t("span", {
|
|
321
335
|
className: "pb-palette-hint",
|
|
322
336
|
children: e.hint
|
|
@@ -324,8 +338,8 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
324
338
|
}), a.length > 0 && /* @__PURE__ */ t("span", {
|
|
325
339
|
className: "pb-palette-keys",
|
|
326
340
|
children: a.map((e) => /* @__PURE__ */ t("kbd", { children: h(e, {
|
|
327
|
-
platform:
|
|
328
|
-
names:
|
|
341
|
+
platform: d,
|
|
342
|
+
names: g.keyNames
|
|
329
343
|
}) }, e))
|
|
330
344
|
})]
|
|
331
345
|
}, e.id);
|
|
@@ -336,27 +350,27 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
336
350
|
/* @__PURE__ */ t("p", {
|
|
337
351
|
className: "pb-palette-empty",
|
|
338
352
|
role: "status",
|
|
339
|
-
children:
|
|
353
|
+
children: K
|
|
340
354
|
})
|
|
341
355
|
]
|
|
342
356
|
})
|
|
343
357
|
});
|
|
344
358
|
}
|
|
345
|
-
function
|
|
346
|
-
return e ? u(/* @__PURE__ */ t(
|
|
359
|
+
function L({ open: e, ...n }) {
|
|
360
|
+
return e ? u(/* @__PURE__ */ t(I, { ...n }), document.body) : null;
|
|
347
361
|
}
|
|
348
362
|
// src/composites/diff-view/DiffView.tsx
|
|
349
|
-
function
|
|
363
|
+
function R(e) {
|
|
350
364
|
return e.startsWith("+++ ") || e.startsWith("--- ") ? "meta" : e.startsWith("@@") ? "hunk" : e.startsWith("+") ? "add" : e.startsWith("-") ? "del" : e.startsWith("\\") ? "note" : e === "" || e.startsWith(" ") ? "context" : "meta";
|
|
351
365
|
}
|
|
352
|
-
function
|
|
366
|
+
function z(e) {
|
|
353
367
|
return e.split("/").filter((e) => e !== "").at(-1) ?? e;
|
|
354
368
|
}
|
|
355
|
-
function
|
|
369
|
+
function B(e) {
|
|
356
370
|
let t = e.split(/\r?\n/);
|
|
357
371
|
return t.length > 0 && t.at(-1) === "" && t.pop(), t;
|
|
358
372
|
}
|
|
359
|
-
function
|
|
373
|
+
function V({ text: e, id: n, hidden: r }) {
|
|
360
374
|
return /* @__PURE__ */ t("pre", {
|
|
361
375
|
className: "pb-diff-body",
|
|
362
376
|
id: n,
|
|
@@ -364,22 +378,22 @@ function B({ text: e, id: n, hidden: r }) {
|
|
|
364
378
|
tabIndex: 0,
|
|
365
379
|
children: /* @__PURE__ */ t("code", {
|
|
366
380
|
className: "pb-diff-code",
|
|
367
|
-
children:
|
|
381
|
+
children: B(e).map((e, n) => /* @__PURE__ */ t("span", {
|
|
368
382
|
className: "pb-diff-line",
|
|
369
|
-
"data-kind":
|
|
383
|
+
"data-kind": R(e),
|
|
370
384
|
children: e === "" ? " " : e
|
|
371
385
|
}, n))
|
|
372
386
|
})
|
|
373
387
|
});
|
|
374
388
|
}
|
|
375
|
-
function
|
|
389
|
+
function H({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, className: c, ...u }) {
|
|
376
390
|
let d = a(), [f, p] = l([]), m = o ?? f, h = `h${String(i)}`, g = (e, t) => {
|
|
377
391
|
o === void 0 && p((n) => t ? n.filter((t) => t !== e) : [...n, e]), s?.(e, t);
|
|
378
392
|
};
|
|
379
393
|
return /* @__PURE__ */ t("div", {
|
|
380
394
|
...u,
|
|
381
395
|
className: c === void 0 ? "pb-diff" : `pb-diff ${c}`,
|
|
382
|
-
children: r === void 0 ? /* @__PURE__ */ t(
|
|
396
|
+
children: r === void 0 ? /* @__PURE__ */ t(V, { text: e }) : r.map((e, r) => {
|
|
383
397
|
let i = !m.includes(e.path), a = `${d}-${String(r)}`;
|
|
384
398
|
return /* @__PURE__ */ n("div", {
|
|
385
399
|
className: "pb-diff-file",
|
|
@@ -407,9 +421,9 @@ function V({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
|
|
|
407
421
|
stroke: "currentColor",
|
|
408
422
|
strokeWidth: "2"
|
|
409
423
|
})
|
|
410
|
-
}),
|
|
424
|
+
}), z(e.path)]
|
|
411
425
|
})
|
|
412
|
-
}), /* @__PURE__ */ t(
|
|
426
|
+
}), /* @__PURE__ */ t(V, {
|
|
413
427
|
text: e.diff,
|
|
414
428
|
id: a,
|
|
415
429
|
hidden: !i
|
|
@@ -419,7 +433,14 @@ function V({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
|
|
|
419
433
|
});
|
|
420
434
|
}
|
|
421
435
|
// src/composites/shortcut-sheet/ShortcutSheet.tsx
|
|
422
|
-
|
|
436
|
+
var U = {
|
|
437
|
+
title: "Keyboard shortcuts",
|
|
438
|
+
or: "or",
|
|
439
|
+
empty: "No shortcuts",
|
|
440
|
+
close: "Close",
|
|
441
|
+
keyNames: {}
|
|
442
|
+
};
|
|
443
|
+
function W(e) {
|
|
423
444
|
let t = /* @__PURE__ */ new Map();
|
|
424
445
|
for (let n of e) {
|
|
425
446
|
let e = t.get(n.group);
|
|
@@ -430,21 +451,24 @@ function H(e) {
|
|
|
430
451
|
lines: t
|
|
431
452
|
}));
|
|
432
453
|
}
|
|
433
|
-
function
|
|
434
|
-
let
|
|
454
|
+
function G({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels: l, className: u }) {
|
|
455
|
+
let d = {
|
|
456
|
+
...U,
|
|
457
|
+
...l
|
|
458
|
+
}, p = a(), g = W(o);
|
|
435
459
|
return /* @__PURE__ */ n(f, {
|
|
436
460
|
open: e,
|
|
437
461
|
onClose: i,
|
|
438
|
-
title:
|
|
439
|
-
|
|
440
|
-
className:
|
|
462
|
+
title: d.title,
|
|
463
|
+
labels: { close: d.close },
|
|
464
|
+
className: u === void 0 ? "pb-shortcut-sheet" : `pb-shortcut-sheet ${u}`,
|
|
441
465
|
children: [
|
|
442
|
-
|
|
466
|
+
g.length === 0 && /* @__PURE__ */ t("p", {
|
|
443
467
|
className: "pb-shortcut-sheet-empty",
|
|
444
|
-
children:
|
|
468
|
+
children: d.empty
|
|
445
469
|
}),
|
|
446
|
-
|
|
447
|
-
let o = `${
|
|
470
|
+
g.map(({ group: e, lines: i }, a) => {
|
|
471
|
+
let o = `${p}-${a}`;
|
|
448
472
|
return /* @__PURE__ */ n("section", {
|
|
449
473
|
className: "pb-shortcut-sheet-group",
|
|
450
474
|
"aria-labelledby": o,
|
|
@@ -459,17 +483,17 @@ function U({ open: e, onClose: i, shortcuts: o, title: s = "Keyboard shortcuts",
|
|
|
459
483
|
return /* @__PURE__ */ n("div", {
|
|
460
484
|
className: "pb-shortcut-sheet-line",
|
|
461
485
|
children: [/* @__PURE__ */ t("dt", { children: e.label }), /* @__PURE__ */ t("dd", {
|
|
462
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a,
|
|
486
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a, c),
|
|
463
487
|
children: a.map((e, i) => /* @__PURE__ */ n(r, { children: [i > 0 && /* @__PURE__ */ n("span", {
|
|
464
488
|
className: "pb-shortcut-sheet-or",
|
|
465
489
|
children: [
|
|
466
490
|
" ",
|
|
467
|
-
|
|
491
|
+
d.or,
|
|
468
492
|
" "
|
|
469
493
|
]
|
|
470
494
|
}), /* @__PURE__ */ t("kbd", { children: h(e, {
|
|
471
|
-
platform:
|
|
472
|
-
names:
|
|
495
|
+
platform: c,
|
|
496
|
+
names: d.keyNames
|
|
473
497
|
}) })] }, e))
|
|
474
498
|
})]
|
|
475
499
|
}, `${e.label}-${i}`);
|
|
@@ -477,15 +501,15 @@ function U({ open: e, onClose: i, shortcuts: o, title: s = "Keyboard shortcuts",
|
|
|
477
501
|
})]
|
|
478
502
|
}, e);
|
|
479
503
|
}),
|
|
480
|
-
|
|
504
|
+
s !== void 0 && /* @__PURE__ */ t("div", {
|
|
481
505
|
className: "pb-shortcut-sheet-note",
|
|
482
|
-
children:
|
|
506
|
+
children: s
|
|
483
507
|
})
|
|
484
508
|
]
|
|
485
509
|
});
|
|
486
510
|
}
|
|
487
511
|
// src/composites/status-words/StatusWords.tsx
|
|
488
|
-
function
|
|
512
|
+
function K({ items: e, className: n, ...r }) {
|
|
489
513
|
return /* @__PURE__ */ t("ul", {
|
|
490
514
|
"aria-live": "polite",
|
|
491
515
|
...r,
|
|
@@ -499,7 +523,12 @@ function W({ items: e, className: n, ...r }) {
|
|
|
499
523
|
});
|
|
500
524
|
}
|
|
501
525
|
// src/composites/toaster/Toaster.tsx
|
|
502
|
-
var
|
|
526
|
+
var q = {
|
|
527
|
+
region: "Notifications",
|
|
528
|
+
dismiss: "Dismiss",
|
|
529
|
+
more: (e) => `and ${e} more`,
|
|
530
|
+
count: (e) => `${e} times`
|
|
531
|
+
}, J = /* @__PURE__ */ new Set([
|
|
503
532
|
"top-start",
|
|
504
533
|
"top",
|
|
505
534
|
"top-end",
|
|
@@ -507,15 +536,18 @@ var G = /* @__PURE__ */ new Set([
|
|
|
507
536
|
"bottom",
|
|
508
537
|
"bottom-end",
|
|
509
538
|
"inline"
|
|
510
|
-
]),
|
|
511
|
-
function
|
|
512
|
-
let
|
|
539
|
+
]), Y = 256;
|
|
540
|
+
function X({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bottom-end", labels: m, className: h, onPointerEnter: g, onPointerLeave: _, onFocus: v, onBlur: y, ...b }) {
|
|
541
|
+
let x = {
|
|
542
|
+
...q,
|
|
543
|
+
...m
|
|
544
|
+
}, S = a(), C = J.has(p) ? p : "inline", w = C.startsWith("top"), T = w ? [...r].reverse() : r, E = r.length === 0 && s <= 0, D = c(/* @__PURE__ */ new Map()), O = c(0), [k, A] = l([]);
|
|
513
545
|
i(() => {
|
|
514
546
|
let e = [];
|
|
515
547
|
for (let t of r) {
|
|
516
|
-
let n = t.count ?? 1, r =
|
|
517
|
-
r !== void 0 && n <= r || (
|
|
518
|
-
seq:
|
|
548
|
+
let n = t.count ?? 1, r = D.current.get(t.id);
|
|
549
|
+
r !== void 0 && n <= r || (D.current.set(t.id, n), O.current += 1, e.push({
|
|
550
|
+
seq: O.current,
|
|
519
551
|
id: t.id,
|
|
520
552
|
alert: t.tone === "err",
|
|
521
553
|
text: t.text,
|
|
@@ -523,90 +555,90 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
523
555
|
}));
|
|
524
556
|
}
|
|
525
557
|
let t = new Set(r.map((e) => e.id));
|
|
526
|
-
if (
|
|
558
|
+
if (D.current.size > Y) for (let e of D.current.keys()) t.has(e) || D.current.delete(e);
|
|
527
559
|
let n = new Set(e.map((e) => e.id));
|
|
528
|
-
|
|
560
|
+
A((r) => {
|
|
529
561
|
let i = r.filter((e) => t.has(e.id) && !n.has(e.id));
|
|
530
562
|
return e.length === 0 && i.length === r.length ? r : [...i, ...e];
|
|
531
563
|
});
|
|
532
564
|
}, [r]);
|
|
533
|
-
let
|
|
565
|
+
let j = new Set(r.map((e) => e.id)), M = (e) => k.filter((e) => j.has(e.id)).filter((t) => t.alert === e).map((e) => /* @__PURE__ */ n("p", { children: [e.text, e.count > 1 && `, ${x.count(e.count)}`] }, e.seq)), N = /* @__PURE__ */ n("div", {
|
|
534
566
|
className: "pb-toaster-announce",
|
|
535
567
|
children: [/* @__PURE__ */ t("div", {
|
|
536
568
|
role: "status",
|
|
537
|
-
children:
|
|
569
|
+
children: M(!1)
|
|
538
570
|
}), /* @__PURE__ */ t("div", {
|
|
539
571
|
role: "alert",
|
|
540
|
-
children:
|
|
572
|
+
children: M(!0)
|
|
541
573
|
})]
|
|
542
|
-
}), [
|
|
543
|
-
|
|
544
|
-
let
|
|
574
|
+
}), [P, F] = l(!1), [I, L] = l(!1);
|
|
575
|
+
E && (P || I) && (F(!1), L(!1));
|
|
576
|
+
let R = P || I, z = c(f);
|
|
545
577
|
o(() => {
|
|
546
|
-
|
|
578
|
+
z.current = f;
|
|
547
579
|
}), o(() => {
|
|
548
|
-
|
|
549
|
-
}, [
|
|
550
|
-
|
|
580
|
+
z.current?.(R);
|
|
581
|
+
}, [R]), o(() => () => {
|
|
582
|
+
z.current?.(!1);
|
|
551
583
|
}, []);
|
|
552
|
-
let
|
|
584
|
+
let B = c(null), V = c(null), H = c(void 0);
|
|
553
585
|
o(() => {
|
|
554
|
-
let e =
|
|
586
|
+
let e = H.current;
|
|
555
587
|
if (e === void 0) return;
|
|
556
|
-
|
|
557
|
-
let t = (e === null ? null :
|
|
588
|
+
H.current = void 0;
|
|
589
|
+
let t = (e === null ? null : B.current?.querySelector(`[data-toast-id="${e}"]`)) ?? B.current?.querySelector(".pb-toast");
|
|
558
590
|
if (t != null) {
|
|
559
591
|
t.focus();
|
|
560
592
|
return;
|
|
561
593
|
}
|
|
562
|
-
let n =
|
|
563
|
-
|
|
594
|
+
let n = V.current;
|
|
595
|
+
V.current = null, n?.isConnected === !0 && n.focus();
|
|
564
596
|
});
|
|
565
|
-
let
|
|
566
|
-
if (
|
|
567
|
-
let t =
|
|
568
|
-
|
|
597
|
+
let U = (e) => {
|
|
598
|
+
if (B.current?.contains(document.activeElement) === !0) {
|
|
599
|
+
let t = T.findIndex((t) => t.id === e);
|
|
600
|
+
H.current = (T[t + 1] ?? T[t - 1])?.id ?? null;
|
|
569
601
|
}
|
|
570
602
|
u(e);
|
|
571
603
|
};
|
|
572
|
-
if (
|
|
573
|
-
let
|
|
604
|
+
if (E) return N;
|
|
605
|
+
let W = s > 0 && /* @__PURE__ */ t("p", {
|
|
574
606
|
className: "pb-toaster-more",
|
|
575
|
-
children:
|
|
607
|
+
children: x.more(s)
|
|
576
608
|
});
|
|
577
|
-
return /* @__PURE__ */ n(e, { children: [
|
|
578
|
-
...
|
|
579
|
-
"aria-label":
|
|
580
|
-
className:
|
|
581
|
-
"data-placement":
|
|
609
|
+
return /* @__PURE__ */ n(e, { children: [N, /* @__PURE__ */ n("section", {
|
|
610
|
+
...b,
|
|
611
|
+
"aria-label": b["aria-label"] ?? x.region,
|
|
612
|
+
className: h === void 0 ? "pb-toaster" : `pb-toaster ${h}`,
|
|
613
|
+
"data-placement": C,
|
|
582
614
|
onPointerEnter: (e) => {
|
|
583
|
-
|
|
615
|
+
g?.(e), e.pointerType !== "touch" && F(!0);
|
|
584
616
|
},
|
|
585
617
|
onPointerLeave: (e) => {
|
|
586
|
-
|
|
618
|
+
_?.(e), F(!1);
|
|
587
619
|
},
|
|
588
620
|
onFocus: (e) => {
|
|
589
|
-
|
|
621
|
+
v?.(e);
|
|
590
622
|
let t = e.relatedTarget;
|
|
591
|
-
!
|
|
623
|
+
!I && t instanceof HTMLElement && !e.currentTarget.contains(t) && (V.current = t), L(!0);
|
|
592
624
|
},
|
|
593
625
|
onBlur: (e) => {
|
|
594
|
-
|
|
626
|
+
y?.(e), e.currentTarget.contains(e.relatedTarget) || L(!1);
|
|
595
627
|
},
|
|
596
628
|
children: [
|
|
597
|
-
!
|
|
629
|
+
!w && W,
|
|
598
630
|
/* @__PURE__ */ t("ol", {
|
|
599
631
|
className: "pb-toaster-list",
|
|
600
|
-
ref:
|
|
601
|
-
children:
|
|
602
|
-
let r = `${
|
|
632
|
+
ref: B,
|
|
633
|
+
children: T.map((e) => {
|
|
634
|
+
let r = `${S}-${e.id}`, i = e.count ?? 1;
|
|
603
635
|
return /* @__PURE__ */ n("li", {
|
|
604
636
|
className: "pb-toast",
|
|
605
637
|
"data-tone": e.tone,
|
|
606
638
|
"data-toast-id": e.id,
|
|
607
639
|
tabIndex: -1,
|
|
608
640
|
onKeyDown: (t) => {
|
|
609
|
-
t.key !== "Escape" || t.defaultPrevented || (t.preventDefault(), t.stopPropagation(),
|
|
641
|
+
t.key !== "Escape" || t.defaultPrevented || (t.preventDefault(), t.stopPropagation(), U(e.id));
|
|
610
642
|
},
|
|
611
643
|
children: [/* @__PURE__ */ n("div", {
|
|
612
644
|
className: "pb-toast-text",
|
|
@@ -618,7 +650,7 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
618
650
|
children: [" ×", i]
|
|
619
651
|
}), /* @__PURE__ */ n("span", {
|
|
620
652
|
className: "pb-toast-hidden",
|
|
621
|
-
children: [", ",
|
|
653
|
+
children: [", ", x.count(i)]
|
|
622
654
|
})]
|
|
623
655
|
})]
|
|
624
656
|
}), /* @__PURE__ */ n("div", {
|
|
@@ -626,25 +658,25 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
626
658
|
children: [e.action !== void 0 && /* @__PURE__ */ t(d, {
|
|
627
659
|
size: "sm",
|
|
628
660
|
onClick: () => {
|
|
629
|
-
e.action?.run(),
|
|
661
|
+
e.action?.run(), U(e.id);
|
|
630
662
|
},
|
|
631
663
|
children: e.action.label
|
|
632
664
|
}), /* @__PURE__ */ t(d, {
|
|
633
665
|
size: "sm",
|
|
634
666
|
"aria-describedby": r,
|
|
635
667
|
onClick: () => {
|
|
636
|
-
|
|
668
|
+
U(e.id);
|
|
637
669
|
},
|
|
638
|
-
children:
|
|
670
|
+
children: x.dismiss
|
|
639
671
|
})]
|
|
640
672
|
})]
|
|
641
673
|
}, e.id);
|
|
642
674
|
})
|
|
643
675
|
}),
|
|
644
|
-
|
|
676
|
+
w && W
|
|
645
677
|
]
|
|
646
678
|
})] });
|
|
647
679
|
}
|
|
648
|
-
export {
|
|
680
|
+
export { _ as Banner, L as CommandPalette, H as DiffView, M as PALETTE_GUTTER, j as PALETTE_HEIGHT, A as PALETTE_WIDTH, G as ShortcutSheet, K as StatusWords, X as Toaster, g as defaultBannerLabels, k as defaultCommandPaletteLabels, U as defaultShortcutSheetLabels, q as defaultToasterLabels, W as groupShortcuts, O as markRuns, E as matchSubsequence, N as placePalette, D as rankCommands };
|
|
649
681
|
|
|
650
682
|
//# sourceMappingURL=composites.js.map
|