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