@mcurcio/patchbay 0.6.0 → 0.8.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 -3
- package/dist/composites.css +1 -1
- package/dist/composites.js +501 -158
- package/dist/composites.js.map +1 -1
- package/dist/graph.js +94 -79
- 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/shell.css +1 -0
- package/dist/shell.js +177 -0
- package/dist/shell.js.map +1 -0
- package/dist/testing.js +207 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/composites/banner/Banner.d.ts +9 -3
- package/dist/types/composites/banner/index.d.ts +2 -2
- package/dist/types/composites/code-editor/CodeEditor.d.ts +45 -0
- package/dist/types/composites/code-editor/CodeRuns.d.ts +5 -0
- package/dist/types/composites/code-editor/CodeText.d.ts +12 -0
- package/dist/types/composites/code-editor/highlight.d.ts +83 -0
- package/dist/types/composites/code-editor/index.d.ts +6 -0
- 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/index.d.ts +1 -0
- 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/follow-fit/useFollowFit.d.ts +3 -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 +7 -8
- package/dist/types/graph/node-box/index.d.ts +2 -2
- 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/shell/app-shell/AppShell.d.ts +76 -0
- package/dist/types/shell/app-shell/bounds.d.ts +16 -0
- package/dist/types/shell/app-shell/index.d.ts +3 -0
- package/dist/types/shell/index.d.ts +1 -1
- 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 +5 -1
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",
|
|
@@ -40,40 +45,351 @@ function g({ tone: e, children: r, actions: i, onDismiss: a, dismissLabel: o = "
|
|
|
40
45
|
]
|
|
41
46
|
});
|
|
42
47
|
}
|
|
48
|
+
// src/composites/code-editor/CodeRuns.tsx
|
|
49
|
+
function v({ runs: e }) {
|
|
50
|
+
return e.map((e, n) => e.class === "" && e.mark === void 0 ? e.text : /* @__PURE__ */ t("span", {
|
|
51
|
+
className: "pb-code-run",
|
|
52
|
+
"data-class": e.class || void 0,
|
|
53
|
+
"data-mark": e.mark,
|
|
54
|
+
children: e.text
|
|
55
|
+
}, n));
|
|
56
|
+
}
|
|
57
|
+
// src/composites/code-editor/highlight.ts
|
|
58
|
+
function y(e) {
|
|
59
|
+
return e.replace(/\r\n?/g, "\n");
|
|
60
|
+
}
|
|
61
|
+
function b(e) {
|
|
62
|
+
let t = [0];
|
|
63
|
+
for (let n = e.indexOf("\n"); n !== -1; n = e.indexOf("\n", n + 1)) t.push(n + 1);
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
function x(e, t) {
|
|
67
|
+
let n = Math.min(e.length, Math.max(0, Math.trunc(t))), r = b(e), i = 0;
|
|
68
|
+
for (; i + 1 < r.length && (r[i + 1] ?? Infinity) <= n;) i += 1;
|
|
69
|
+
return {
|
|
70
|
+
line: i + 1,
|
|
71
|
+
column: n - (r[i] ?? 0) + 1,
|
|
72
|
+
offset: n
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function S(e, t, n = 1) {
|
|
76
|
+
let r = b(e), i = Math.min(r.length, Math.max(1, Math.trunc(t))) - 1, a = r[i] ?? 0, o = i + 1 < r.length ? (r[i + 1] ?? 0) - 1 : e.length;
|
|
77
|
+
return Math.min(o, a + Math.max(1, Math.trunc(n)) - 1);
|
|
78
|
+
}
|
|
79
|
+
function C(e) {
|
|
80
|
+
return e === "error" ? "error" : e === "warning" ? "warning" : "other";
|
|
81
|
+
}
|
|
82
|
+
var w = {
|
|
83
|
+
other: 1,
|
|
84
|
+
warning: 2,
|
|
85
|
+
error: 3
|
|
86
|
+
};
|
|
87
|
+
function T(e, t) {
|
|
88
|
+
return e !== void 0 && w[e] >= w[t] ? e : t;
|
|
89
|
+
}
|
|
90
|
+
function E(e, t) {
|
|
91
|
+
let n = b(e), r = Math.min(n.length, Math.max(1, Math.trunc(t.line))) - 1, i = n[r] ?? 0, a = r + 1 < n.length ? (n[r + 1] ?? 0) - 1 : e.length;
|
|
92
|
+
if (t.column === void 0) {
|
|
93
|
+
let t = i, n = a;
|
|
94
|
+
for (; t < n && /\s/.test(e[t] ?? "");) t += 1;
|
|
95
|
+
for (; n > t && /\s/.test(e[n - 1] ?? "");) --n;
|
|
96
|
+
return {
|
|
97
|
+
start: t,
|
|
98
|
+
end: n
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
let o = S(e, r + 1, t.column), s = o;
|
|
102
|
+
for (; s < a && !/\s/.test(e[s] ?? "");) s += 1;
|
|
103
|
+
return s === o && o < a && (s = o + 1), {
|
|
104
|
+
start: o,
|
|
105
|
+
end: s
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function D(e, t = [], n = []) {
|
|
109
|
+
let r = [""], i = new Uint16Array(e.length);
|
|
110
|
+
for (let n of t) {
|
|
111
|
+
let t = Math.max(0, Math.trunc(n.start)), a = Math.min(e.length, Math.trunc(n.end));
|
|
112
|
+
if (!(a > t)) continue;
|
|
113
|
+
let o = n.class === "space" ? "" : n.class, s = r.indexOf(o);
|
|
114
|
+
s === -1 && (s = r.push(o) - 1), i.fill(s, t, a);
|
|
115
|
+
}
|
|
116
|
+
let a = [
|
|
117
|
+
void 0,
|
|
118
|
+
"other",
|
|
119
|
+
"warning",
|
|
120
|
+
"error"
|
|
121
|
+
], o = new Uint8Array(e.length);
|
|
122
|
+
for (let t of n) {
|
|
123
|
+
let { start: n, end: r } = E(e, t), i = w[C(t.severity)];
|
|
124
|
+
for (let e = n; e < r; e += 1) o[e] = Math.max(o[e] ?? 0, i);
|
|
125
|
+
}
|
|
126
|
+
let s = [], c = 0;
|
|
127
|
+
for (let t = 1; t <= e.length; t += 1) {
|
|
128
|
+
if (t < e.length && i[t] === i[c] && o[t] === o[c]) continue;
|
|
129
|
+
let n = a[o[c] ?? 0], l = {
|
|
130
|
+
text: e.slice(c, t),
|
|
131
|
+
class: r[i[c] ?? 0] ?? ""
|
|
132
|
+
};
|
|
133
|
+
n !== void 0 && (l.mark = n), s.push(l), c = t;
|
|
134
|
+
}
|
|
135
|
+
return s;
|
|
136
|
+
}
|
|
137
|
+
function O(e, t = []) {
|
|
138
|
+
let n = b(e).length, r = Array.from({ length: n }, (e, t) => ({
|
|
139
|
+
line: t + 1,
|
|
140
|
+
column: 1,
|
|
141
|
+
diagnostics: []
|
|
142
|
+
}));
|
|
143
|
+
for (let e of t) {
|
|
144
|
+
let t = r[Math.min(n, Math.max(1, Math.trunc(e.line))) - 1];
|
|
145
|
+
t !== void 0 && (t.diagnostics.length === 0 && (t.column = e.column ?? 1), t.diagnostics.push(e), t.mark = T(t.mark, C(e.severity)));
|
|
146
|
+
}
|
|
147
|
+
return r;
|
|
148
|
+
}
|
|
149
|
+
var k, A;
|
|
150
|
+
function j() {
|
|
151
|
+
return k ??= import("knobly/highlight").then((e) => A = e.highlight, (e) => (console.warn("patchbay: language \"knobly\" needs the knobly package; drawing plain text.", e), A = null, null)), k;
|
|
152
|
+
}
|
|
153
|
+
function M(e, t) {
|
|
154
|
+
let n = t === void 0 && e === "knobly", [r, a] = l(void 0);
|
|
155
|
+
return i(() => {
|
|
156
|
+
if (!n || A !== void 0) return;
|
|
157
|
+
let e = !0;
|
|
158
|
+
return j().then((t) => {
|
|
159
|
+
e && a({ highlight: t });
|
|
160
|
+
}), () => {
|
|
161
|
+
e = !1;
|
|
162
|
+
};
|
|
163
|
+
}, [n]), t === void 0 ? n ? A ?? r?.highlight ?? void 0 : void 0 : t;
|
|
164
|
+
}
|
|
165
|
+
// src/composites/code-editor/CodeEditor.tsx
|
|
166
|
+
var N = {
|
|
167
|
+
diagnostic: ({ line: e, column: t, severity: n, code: r, message: i }) => `Line ${String(e)}${t === void 0 ? "" : `, column ${String(t)}`}: ${n}${r === void 0 || r === "" ? "" : ` ${r}`}: ${i}`,
|
|
168
|
+
tabKey: "Tab indents. Press Escape, then Tab, to move on."
|
|
169
|
+
}, P = [];
|
|
170
|
+
function F(e, t) {
|
|
171
|
+
if (t !== "" && e.startsWith(t)) return t.length;
|
|
172
|
+
if (e.startsWith(" ")) return 1;
|
|
173
|
+
let n = t === " " || t === "" ? 4 : t.length, r = 0;
|
|
174
|
+
for (; r < n && e[r] === " ";) r += 1;
|
|
175
|
+
return r;
|
|
176
|
+
}
|
|
177
|
+
function I(e, t, n, r, i) {
|
|
178
|
+
let a = e.slice(t, n).includes("\n");
|
|
179
|
+
if (!i && !a) {
|
|
180
|
+
if (r === "") return;
|
|
181
|
+
let e = t + r.length;
|
|
182
|
+
return {
|
|
183
|
+
from: t,
|
|
184
|
+
to: n,
|
|
185
|
+
insert: r,
|
|
186
|
+
start: e,
|
|
187
|
+
end: e
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
let o = e.lastIndexOf("\n", t - 1) + 1, s = n > t && e[n - 1] === "\n" ? n - 1 : n, c = e.indexOf("\n", s), l = c === -1 ? e.length : c, u = e.slice(o, l).split("\n"), d = u.map((e) => i ? e.slice(F(e, r)) : e === "" ? e : r + e), f = d.join("\n");
|
|
191
|
+
if (f !== e.slice(o, l)) {
|
|
192
|
+
if (t === n) {
|
|
193
|
+
let e = (d[0] ?? "").length - (u[0] ?? "").length, n = Math.max(o, t + e);
|
|
194
|
+
return {
|
|
195
|
+
from: o,
|
|
196
|
+
to: l,
|
|
197
|
+
insert: f,
|
|
198
|
+
start: n,
|
|
199
|
+
end: n
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
from: o,
|
|
204
|
+
to: l,
|
|
205
|
+
insert: f,
|
|
206
|
+
start: o,
|
|
207
|
+
end: o + f.length
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function L(e) {
|
|
212
|
+
let t = document.execCommand;
|
|
213
|
+
return typeof t == "function" ? e === "" ? t.call(document, "delete", !1) : t.call(document, "insertText", !1, e) : !1;
|
|
214
|
+
}
|
|
215
|
+
function R({ value: e, onChange: r, language: i, highlight: l, diagnostics: u = P, onCaret: d, lineNumbers: f = !0, indent: p = " ", labels: m, readOnly: h = !1, className: g, style: _, ref: b, onKeyDown: C, onBlur: w, onScroll: T, onSelect: E, "aria-describedby": k, ...A }) {
|
|
216
|
+
let j = {
|
|
217
|
+
...N,
|
|
218
|
+
...m
|
|
219
|
+
}, F = c(null), R = c(null), z = c(null), B = c(!1), V = c(null), H = c(""), U = a(), W = M(i, l), G = y(e), ee = s(() => D(G, W?.(G), u), [
|
|
220
|
+
G,
|
|
221
|
+
W,
|
|
222
|
+
u
|
|
223
|
+
]), K = s(() => O(G, u), [G, u]), q = () => {
|
|
224
|
+
let e = F.current;
|
|
225
|
+
e !== null && (R.current !== null && (R.current.scrollTop = e.scrollTop, R.current.scrollLeft = e.scrollLeft), z.current !== null && (z.current.scrollTop = e.scrollTop));
|
|
226
|
+
}, J = () => {
|
|
227
|
+
let e = F.current;
|
|
228
|
+
if (e === null || d === void 0) return;
|
|
229
|
+
let t = e.selectionDirection === "backward" ? e.selectionStart : e.selectionEnd, n = x(e.value, t), r = `${String(n.line)}:${String(n.column)}:${String(n.offset)}`;
|
|
230
|
+
r !== H.current && (H.current = r, d(n));
|
|
231
|
+
};
|
|
232
|
+
o(() => {
|
|
233
|
+
let e = F.current, t = V.current;
|
|
234
|
+
V.current = null, e !== null && t !== null && e.value === t.value && (e.setSelectionRange(t.start, t.end), J()), q();
|
|
235
|
+
});
|
|
236
|
+
let Y = (e, t) => {
|
|
237
|
+
if (e.setSelectionRange(t.from, t.to), L(t.insert)) {
|
|
238
|
+
e.setSelectionRange(t.start, t.end), J();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
let n = e.value.slice(0, t.from) + t.insert + e.value.slice(t.to);
|
|
242
|
+
V.current = {
|
|
243
|
+
value: n,
|
|
244
|
+
start: t.start,
|
|
245
|
+
end: t.end
|
|
246
|
+
}, r?.(n);
|
|
247
|
+
}, X = (e) => {
|
|
248
|
+
if (C?.(e), e.defaultPrevented) return;
|
|
249
|
+
if (e.key === "Escape") {
|
|
250
|
+
B.current = !0;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (e.key !== "Tab") {
|
|
254
|
+
e.key !== "Shift" && (B.current = !1);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
let t = B.current;
|
|
258
|
+
if (B.current = !1, t || h || e.ctrlKey || e.altKey || e.metaKey || e.nativeEvent.isComposing) return;
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
let n = e.currentTarget, r = I(n.value, n.selectionStart, n.selectionEnd, p, e.shiftKey);
|
|
261
|
+
r !== void 0 && Y(n, r);
|
|
262
|
+
}, Z = (e, t) => {
|
|
263
|
+
let n = F.current;
|
|
264
|
+
if (n === null) return;
|
|
265
|
+
let r = S(n.value, e, t);
|
|
266
|
+
n.focus(), n.setSelectionRange(r, r), J();
|
|
267
|
+
}, Q = [...h ? [] : [j.tabKey], ...u.map((e) => j.diagnostic(e))], te = [k, Q.length > 0 ? U : void 0].filter((e) => e !== void 0 && e !== "").join(" ") || void 0, $ = String(K.length).length;
|
|
268
|
+
return /* @__PURE__ */ n("div", {
|
|
269
|
+
className: g === void 0 ? "pb-code-editor" : `pb-code-editor ${g}`,
|
|
270
|
+
style: _,
|
|
271
|
+
"data-readonly": h || void 0,
|
|
272
|
+
children: [
|
|
273
|
+
f ? /* @__PURE__ */ t("pre", {
|
|
274
|
+
ref: z,
|
|
275
|
+
className: "pb-code-gutter",
|
|
276
|
+
"aria-hidden": "true",
|
|
277
|
+
style: { "--pb-code-gutter-digits": $ },
|
|
278
|
+
children: /* @__PURE__ */ t("code", {
|
|
279
|
+
className: "pb-code-gutter-code",
|
|
280
|
+
children: K.map((e) => /* @__PURE__ */ n("span", {
|
|
281
|
+
className: "pb-code-gutter-row",
|
|
282
|
+
children: [
|
|
283
|
+
e.line,
|
|
284
|
+
/* @__PURE__ */ t("span", {
|
|
285
|
+
className: "pb-code-gutter-mark",
|
|
286
|
+
"data-mark": e.mark,
|
|
287
|
+
title: e.diagnostics.length === 0 ? void 0 : e.diagnostics.map((e) => j.diagnostic(e)).join("\n"),
|
|
288
|
+
onClick: e.mark === void 0 ? void 0 : () => {
|
|
289
|
+
Z(e.line, e.column);
|
|
290
|
+
}
|
|
291
|
+
}),
|
|
292
|
+
"\n"
|
|
293
|
+
]
|
|
294
|
+
}, e.line))
|
|
295
|
+
})
|
|
296
|
+
}) : null,
|
|
297
|
+
/* @__PURE__ */ n("div", {
|
|
298
|
+
className: "pb-code-box",
|
|
299
|
+
children: [/* @__PURE__ */ t("pre", {
|
|
300
|
+
ref: R,
|
|
301
|
+
className: "pb-code-layer",
|
|
302
|
+
"aria-hidden": "true",
|
|
303
|
+
children: /* @__PURE__ */ n("code", {
|
|
304
|
+
className: "pb-code-layer-code",
|
|
305
|
+
children: [/* @__PURE__ */ t(v, { runs: ee }), "\n"]
|
|
306
|
+
})
|
|
307
|
+
}), /* @__PURE__ */ t("textarea", {
|
|
308
|
+
spellCheck: !1,
|
|
309
|
+
autoCapitalize: "off",
|
|
310
|
+
autoComplete: "off",
|
|
311
|
+
autoCorrect: "off",
|
|
312
|
+
wrap: "off",
|
|
313
|
+
...A,
|
|
314
|
+
ref: (e) => {
|
|
315
|
+
if (F.current = e, typeof b == "function") return b(e);
|
|
316
|
+
b && (b.current = e);
|
|
317
|
+
},
|
|
318
|
+
className: "pb-code-input",
|
|
319
|
+
value: e,
|
|
320
|
+
readOnly: h,
|
|
321
|
+
"aria-describedby": te,
|
|
322
|
+
onChange: (e) => r?.(e.target.value),
|
|
323
|
+
onKeyDown: X,
|
|
324
|
+
onBlur: (e) => {
|
|
325
|
+
B.current = !1, w?.(e);
|
|
326
|
+
},
|
|
327
|
+
onScroll: (e) => {
|
|
328
|
+
q(), T?.(e);
|
|
329
|
+
},
|
|
330
|
+
onSelect: (e) => {
|
|
331
|
+
J(), E?.(e);
|
|
332
|
+
}
|
|
333
|
+
})]
|
|
334
|
+
}),
|
|
335
|
+
Q.length > 0 ? /* @__PURE__ */ t("div", {
|
|
336
|
+
id: U,
|
|
337
|
+
hidden: !0,
|
|
338
|
+
children: Q.map((e, n) => /* @__PURE__ */ t("p", { children: e }, n))
|
|
339
|
+
}) : null
|
|
340
|
+
]
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// src/composites/code-editor/CodeText.tsx
|
|
344
|
+
function z({ value: e, language: n, highlight: r, className: i, ...a }) {
|
|
345
|
+
let o = M(n, r), c = s(() => {
|
|
346
|
+
let t = y(e);
|
|
347
|
+
return D(t, o?.(t));
|
|
348
|
+
}, [e, o]);
|
|
349
|
+
return /* @__PURE__ */ t("pre", {
|
|
350
|
+
tabIndex: 0,
|
|
351
|
+
...a,
|
|
352
|
+
className: i === void 0 ? "pb-code-text" : `pb-code-text ${i}`,
|
|
353
|
+
children: /* @__PURE__ */ t("code", {
|
|
354
|
+
className: "pb-code-text-code",
|
|
355
|
+
children: /* @__PURE__ */ t(v, { runs: c })
|
|
356
|
+
})
|
|
357
|
+
});
|
|
358
|
+
}
|
|
43
359
|
// src/composites/command-palette/rank.ts
|
|
44
|
-
function
|
|
360
|
+
function B(e, t) {
|
|
45
361
|
if (t === 0) return !0;
|
|
46
362
|
let n = e.charAt(t - 1), r = e.charAt(t);
|
|
47
363
|
return !/[\p{L}\p{N}]/u.test(n) || n !== n.toUpperCase() && r !== r.toLowerCase() && r === r.toUpperCase();
|
|
48
364
|
}
|
|
49
|
-
function
|
|
365
|
+
function V(e) {
|
|
50
366
|
let t = e.toLowerCase();
|
|
51
367
|
return t.length === 1 ? t : e;
|
|
52
368
|
}
|
|
53
|
-
var
|
|
54
|
-
function
|
|
369
|
+
var H = 3, U = 2, W = 2, G = .1, ee = 1, K = .02;
|
|
370
|
+
function q(e, t) {
|
|
55
371
|
let n = t.replace(/\s+/g, "");
|
|
56
372
|
if (n === "") return {
|
|
57
373
|
indices: [],
|
|
58
374
|
score: 0
|
|
59
375
|
};
|
|
60
|
-
let r = Array.from({ length: n.length }, (e, t) =>
|
|
376
|
+
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
377
|
if (o > a) return;
|
|
62
|
-
let s = i.map((t, n) => n === 0 ?
|
|
378
|
+
let s = i.map((t, n) => n === 0 ? H : B(e, n) ? U : 0), c = [], l = [];
|
|
63
379
|
for (let e = 0; e < o; e += 1) {
|
|
64
380
|
let t = Array(a).fill(-Infinity), n = Array(a).fill(-1), o = r[e];
|
|
65
381
|
for (let r = e; r < a; r += 1) {
|
|
66
382
|
if (i[r] !== o) continue;
|
|
67
383
|
let a = 1 + (s[r] ?? 0);
|
|
68
384
|
if (e === 0) {
|
|
69
|
-
t[r] = a - r *
|
|
385
|
+
t[r] = a - r * K;
|
|
70
386
|
continue;
|
|
71
387
|
}
|
|
72
388
|
let l = c[e - 1] ?? [];
|
|
73
389
|
for (let i = e - 1; i < r; i += 1) {
|
|
74
390
|
let e = l[i] ?? -Infinity;
|
|
75
391
|
if (e === -Infinity) continue;
|
|
76
|
-
let o = i === r - 1 ?
|
|
392
|
+
let o = i === r - 1 ? W : -Math.min((r - i - 1) * G, ee), s = e + a + o;
|
|
77
393
|
s > (t[r] ?? -Infinity) && (t[r] = s, n[r] = i);
|
|
78
394
|
}
|
|
79
395
|
}
|
|
@@ -89,10 +405,10 @@ function T(e, t) {
|
|
|
89
405
|
score: u[d] ?? 0
|
|
90
406
|
};
|
|
91
407
|
}
|
|
92
|
-
function
|
|
408
|
+
function J(e, t) {
|
|
93
409
|
let n = /* @__PURE__ */ new Map();
|
|
94
410
|
e.forEach((e, r) => {
|
|
95
|
-
let i =
|
|
411
|
+
let i = q(e.label, t);
|
|
96
412
|
if (i === void 0) return;
|
|
97
413
|
let a = n.get(e.group);
|
|
98
414
|
a === void 0 && (a = {
|
|
@@ -123,7 +439,7 @@ function E(e, t) {
|
|
|
123
439
|
}))
|
|
124
440
|
}));
|
|
125
441
|
}
|
|
126
|
-
function
|
|
442
|
+
function Y(e, t) {
|
|
127
443
|
let n = new Set(t), r = [];
|
|
128
444
|
for (let t = 0; t < e.length; t += 1) {
|
|
129
445
|
let i = n.has(t), a = r[r.length - 1];
|
|
@@ -135,8 +451,14 @@ function D(e, t) {
|
|
|
135
451
|
return r;
|
|
136
452
|
}
|
|
137
453
|
// src/composites/command-palette/CommandPalette.tsx
|
|
138
|
-
var
|
|
139
|
-
|
|
454
|
+
var X = {
|
|
455
|
+
palette: "Commands",
|
|
456
|
+
placeholder: "Type a command",
|
|
457
|
+
empty: "No commands",
|
|
458
|
+
noMatch: (e) => `No command matches “${e}”`,
|
|
459
|
+
keyNames: {}
|
|
460
|
+
}, Z = 320, Q = 360, te = 8;
|
|
461
|
+
function $(e, t) {
|
|
140
462
|
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
463
|
return {
|
|
142
464
|
left: i(e.x, n, t.width),
|
|
@@ -145,8 +467,8 @@ function j(e, t) {
|
|
|
145
467
|
height: r
|
|
146
468
|
};
|
|
147
469
|
}
|
|
148
|
-
var
|
|
149
|
-
function
|
|
470
|
+
var ne = 8;
|
|
471
|
+
function re(e) {
|
|
150
472
|
let t = () => ({
|
|
151
473
|
width: window.innerWidth,
|
|
152
474
|
height: window.innerHeight
|
|
@@ -161,47 +483,50 @@ function P(e) {
|
|
|
161
483
|
};
|
|
162
484
|
}, [e]), n;
|
|
163
485
|
}
|
|
164
|
-
function
|
|
165
|
-
let
|
|
166
|
-
|
|
167
|
-
|
|
486
|
+
function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className: p }) {
|
|
487
|
+
let g = {
|
|
488
|
+
...X,
|
|
489
|
+
...f
|
|
490
|
+
}, _ = a(), v = `${_}-list`, [y, b] = l(""), x = s(() => J(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, D] = l(y);
|
|
491
|
+
E !== y && (D(y), T(void 0));
|
|
492
|
+
let O = C.find((e) => e.id === w) ?? C[0], k = (e) => `${_}-option-${S.indexOf(e)}`, A = c(null), j = c(null), M = c(null), N = c(e);
|
|
168
493
|
o(() => {
|
|
169
|
-
|
|
494
|
+
N.current = e;
|
|
170
495
|
}), o(() => {
|
|
171
496
|
let e = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
172
|
-
|
|
173
|
-
let t =
|
|
497
|
+
j.current?.focus();
|
|
498
|
+
let t = A.current;
|
|
174
499
|
return () => {
|
|
175
500
|
let n = document.activeElement;
|
|
176
501
|
(n === null || n === document.body || (t?.contains(n) ?? !1) || !n.isConnected) && e?.isConnected === !0 && e.focus();
|
|
177
502
|
};
|
|
178
503
|
}, []), i(() => {
|
|
179
|
-
if (
|
|
180
|
-
let e = document.getElementById(
|
|
504
|
+
if (O === void 0) return;
|
|
505
|
+
let e = document.getElementById(k(O));
|
|
181
506
|
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
|
-
},
|
|
507
|
+
}, [O]);
|
|
508
|
+
let P = (e) => {
|
|
509
|
+
e.disabled !== !0 && (N.current(), e.run());
|
|
510
|
+
}, F = () => {
|
|
511
|
+
let e = M.current?.querySelector("[role=\"option\"]"), t = e && e.offsetHeight > 0 ? Math.floor((M.current?.clientHeight ?? 0) / e.offsetHeight) : 0;
|
|
512
|
+
return Math.max(1, t || ne);
|
|
513
|
+
}, I = (e) => {
|
|
189
514
|
if (e.defaultPrevented || e.nativeEvent.isComposing) return;
|
|
190
|
-
let t = e.altKey || e.ctrlKey || e.metaKey, n =
|
|
515
|
+
let t = e.altKey || e.ctrlKey || e.metaKey, n = O === void 0 ? -1 : C.indexOf(O), r = C.length - 1, i = (t) => {
|
|
191
516
|
e.preventDefault();
|
|
192
|
-
let n =
|
|
193
|
-
n !== void 0 &&
|
|
517
|
+
let n = C[Math.min(Math.max(t, 0), r)];
|
|
518
|
+
n !== void 0 && T(n.id);
|
|
194
519
|
};
|
|
195
520
|
switch (e.key) {
|
|
196
521
|
case "Escape":
|
|
197
|
-
e.preventDefault(), e.stopPropagation(),
|
|
522
|
+
e.preventDefault(), e.stopPropagation(), N.current();
|
|
198
523
|
return;
|
|
199
524
|
case "Tab":
|
|
200
|
-
e.preventDefault(),
|
|
525
|
+
e.preventDefault(), N.current();
|
|
201
526
|
return;
|
|
202
527
|
case "Enter":
|
|
203
528
|
if (t) return;
|
|
204
|
-
e.preventDefault(),
|
|
529
|
+
e.preventDefault(), O !== void 0 && P(O);
|
|
205
530
|
return;
|
|
206
531
|
case "ArrowDown":
|
|
207
532
|
if (t) return;
|
|
@@ -213,11 +538,11 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
213
538
|
return;
|
|
214
539
|
case "PageDown":
|
|
215
540
|
if (t) return;
|
|
216
|
-
i(n +
|
|
541
|
+
i(n + F());
|
|
217
542
|
return;
|
|
218
543
|
case "PageUp":
|
|
219
544
|
if (t) return;
|
|
220
|
-
i(n -
|
|
545
|
+
i(n - F());
|
|
221
546
|
return;
|
|
222
547
|
case "Home":
|
|
223
548
|
if (t || e.shiftKey) return;
|
|
@@ -229,61 +554,61 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
229
554
|
return;
|
|
230
555
|
default: return;
|
|
231
556
|
}
|
|
232
|
-
},
|
|
233
|
-
return r.length === 0 ?
|
|
557
|
+
}, L = re(u !== void 0), R = u === void 0 ? void 0 : $(u, L), z = R !== void 0, B;
|
|
558
|
+
return r.length === 0 ? B = g.empty : S.length === 0 && (B = g.noMatch(y.trim())), /* @__PURE__ */ t("div", {
|
|
234
559
|
className: "pb-palette-layer",
|
|
235
|
-
"data-anchored":
|
|
560
|
+
"data-anchored": z ? "" : void 0,
|
|
236
561
|
onMouseDown: (e) => {
|
|
237
|
-
e.target === e.currentTarget &&
|
|
562
|
+
e.target === e.currentTarget && N.current();
|
|
238
563
|
},
|
|
239
564
|
children: /* @__PURE__ */ n("div", {
|
|
240
|
-
ref:
|
|
241
|
-
className:
|
|
565
|
+
ref: A,
|
|
566
|
+
className: p === void 0 ? "pb-palette" : `pb-palette ${p}`,
|
|
242
567
|
role: "dialog",
|
|
243
568
|
"aria-modal": "true",
|
|
244
|
-
"aria-label":
|
|
245
|
-
style:
|
|
569
|
+
"aria-label": g.palette,
|
|
570
|
+
style: R === void 0 ? void 0 : {
|
|
246
571
|
position: "fixed",
|
|
247
|
-
left:
|
|
248
|
-
top:
|
|
249
|
-
width:
|
|
250
|
-
maxHeight:
|
|
572
|
+
left: R.left,
|
|
573
|
+
top: R.top,
|
|
574
|
+
width: R.width,
|
|
575
|
+
maxHeight: R.height
|
|
251
576
|
},
|
|
252
577
|
onBlur: (e) => {
|
|
253
578
|
let t = e.relatedTarget;
|
|
254
|
-
t instanceof Node && !e.currentTarget.contains(t) &&
|
|
579
|
+
t instanceof Node && !e.currentTarget.contains(t) && N.current();
|
|
255
580
|
},
|
|
256
581
|
children: [
|
|
257
582
|
/* @__PURE__ */ t("input", {
|
|
258
|
-
ref:
|
|
583
|
+
ref: j,
|
|
259
584
|
className: "pb-palette-field",
|
|
260
585
|
type: "text",
|
|
261
586
|
role: "combobox",
|
|
262
|
-
"aria-label":
|
|
587
|
+
"aria-label": g.palette,
|
|
263
588
|
"aria-expanded": "true",
|
|
264
|
-
"aria-controls":
|
|
589
|
+
"aria-controls": v,
|
|
265
590
|
"aria-autocomplete": "list",
|
|
266
|
-
"aria-activedescendant":
|
|
591
|
+
"aria-activedescendant": O === void 0 ? void 0 : k(O),
|
|
267
592
|
autoComplete: "off",
|
|
268
593
|
autoCapitalize: "off",
|
|
269
594
|
autoCorrect: "off",
|
|
270
595
|
spellCheck: !1,
|
|
271
|
-
placeholder:
|
|
272
|
-
value:
|
|
596
|
+
placeholder: g.placeholder,
|
|
597
|
+
value: y,
|
|
273
598
|
onChange: (e) => {
|
|
274
|
-
|
|
599
|
+
b(e.target.value);
|
|
275
600
|
},
|
|
276
|
-
onKeyDown:
|
|
601
|
+
onKeyDown: I
|
|
277
602
|
}),
|
|
278
603
|
/* @__PURE__ */ t("div", {
|
|
279
|
-
ref:
|
|
604
|
+
ref: M,
|
|
280
605
|
className: "pb-palette-list",
|
|
281
|
-
id:
|
|
606
|
+
id: v,
|
|
282
607
|
role: "listbox",
|
|
283
|
-
"aria-label":
|
|
284
|
-
hidden:
|
|
285
|
-
children:
|
|
286
|
-
let i = `${
|
|
608
|
+
"aria-label": g.palette,
|
|
609
|
+
hidden: S.length === 0,
|
|
610
|
+
children: x.map((e, r) => {
|
|
611
|
+
let i = `${_}-group-${r}`;
|
|
287
612
|
return /* @__PURE__ */ n("div", {
|
|
288
613
|
role: "group",
|
|
289
614
|
"aria-labelledby": i,
|
|
@@ -294,29 +619,29 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
294
619
|
role: "presentation",
|
|
295
620
|
children: e.group
|
|
296
621
|
}), e.items.map(({ command: e, indices: r }) => {
|
|
297
|
-
let i =
|
|
622
|
+
let i = k(e), a = e.keys === void 0 ? [] : typeof e.keys == "string" ? [e.keys] : e.keys, o = e === O;
|
|
298
623
|
return /* @__PURE__ */ n("div", {
|
|
299
624
|
id: i,
|
|
300
625
|
role: "option",
|
|
301
626
|
"aria-selected": o,
|
|
302
627
|
"aria-disabled": e.disabled === !0 || void 0,
|
|
303
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a,
|
|
628
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a, d),
|
|
304
629
|
className: "pb-palette-option",
|
|
305
630
|
"data-command-id": e.id,
|
|
306
631
|
onMouseDown: (e) => {
|
|
307
632
|
e.preventDefault();
|
|
308
633
|
},
|
|
309
634
|
onPointerMove: () => {
|
|
310
|
-
e.disabled !== !0 && !o &&
|
|
635
|
+
e.disabled !== !0 && !o && T(e.id);
|
|
311
636
|
},
|
|
312
637
|
onClick: () => {
|
|
313
|
-
|
|
638
|
+
P(e);
|
|
314
639
|
},
|
|
315
640
|
children: [/* @__PURE__ */ n("span", {
|
|
316
641
|
className: "pb-palette-text",
|
|
317
642
|
children: [/* @__PURE__ */ t("span", {
|
|
318
643
|
className: "pb-palette-label",
|
|
319
|
-
children:
|
|
644
|
+
children: Y(e.label, r).map((e, n) => e.marked ? /* @__PURE__ */ t("mark", { children: e.text }, n) : e.text)
|
|
320
645
|
}), e.hint !== void 0 && /* @__PURE__ */ t("span", {
|
|
321
646
|
className: "pb-palette-hint",
|
|
322
647
|
children: e.hint
|
|
@@ -324,8 +649,8 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
324
649
|
}), a.length > 0 && /* @__PURE__ */ t("span", {
|
|
325
650
|
className: "pb-palette-keys",
|
|
326
651
|
children: a.map((e) => /* @__PURE__ */ t("kbd", { children: h(e, {
|
|
327
|
-
platform:
|
|
328
|
-
names:
|
|
652
|
+
platform: d,
|
|
653
|
+
names: g.keyNames
|
|
329
654
|
}) }, e))
|
|
330
655
|
})]
|
|
331
656
|
}, e.id);
|
|
@@ -336,27 +661,27 @@ function F({ onClose: e, commands: r, at: u, placeholder: d = "Type a command",
|
|
|
336
661
|
/* @__PURE__ */ t("p", {
|
|
337
662
|
className: "pb-palette-empty",
|
|
338
663
|
role: "status",
|
|
339
|
-
children:
|
|
664
|
+
children: B
|
|
340
665
|
})
|
|
341
666
|
]
|
|
342
667
|
})
|
|
343
668
|
});
|
|
344
669
|
}
|
|
345
|
-
function
|
|
346
|
-
return e ? u(/* @__PURE__ */ t(
|
|
670
|
+
function ae({ open: e, ...n }) {
|
|
671
|
+
return e ? u(/* @__PURE__ */ t(ie, { ...n }), document.body) : null;
|
|
347
672
|
}
|
|
348
673
|
// src/composites/diff-view/DiffView.tsx
|
|
349
|
-
function
|
|
674
|
+
function oe(e) {
|
|
350
675
|
return e.startsWith("+++ ") || e.startsWith("--- ") ? "meta" : e.startsWith("@@") ? "hunk" : e.startsWith("+") ? "add" : e.startsWith("-") ? "del" : e.startsWith("\\") ? "note" : e === "" || e.startsWith(" ") ? "context" : "meta";
|
|
351
676
|
}
|
|
352
|
-
function
|
|
677
|
+
function se(e) {
|
|
353
678
|
return e.split("/").filter((e) => e !== "").at(-1) ?? e;
|
|
354
679
|
}
|
|
355
|
-
function
|
|
680
|
+
function ce(e) {
|
|
356
681
|
let t = e.split(/\r?\n/);
|
|
357
682
|
return t.length > 0 && t.at(-1) === "" && t.pop(), t;
|
|
358
683
|
}
|
|
359
|
-
function
|
|
684
|
+
function le({ text: e, id: n, hidden: r }) {
|
|
360
685
|
return /* @__PURE__ */ t("pre", {
|
|
361
686
|
className: "pb-diff-body",
|
|
362
687
|
id: n,
|
|
@@ -364,22 +689,22 @@ function B({ text: e, id: n, hidden: r }) {
|
|
|
364
689
|
tabIndex: 0,
|
|
365
690
|
children: /* @__PURE__ */ t("code", {
|
|
366
691
|
className: "pb-diff-code",
|
|
367
|
-
children:
|
|
692
|
+
children: ce(e).map((e, n) => /* @__PURE__ */ t("span", {
|
|
368
693
|
className: "pb-diff-line",
|
|
369
|
-
"data-kind":
|
|
694
|
+
"data-kind": oe(e),
|
|
370
695
|
children: e === "" ? " " : e
|
|
371
696
|
}, n))
|
|
372
697
|
})
|
|
373
698
|
});
|
|
374
699
|
}
|
|
375
|
-
function
|
|
700
|
+
function ue({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, className: c, ...u }) {
|
|
376
701
|
let d = a(), [f, p] = l([]), m = o ?? f, h = `h${String(i)}`, g = (e, t) => {
|
|
377
702
|
o === void 0 && p((n) => t ? n.filter((t) => t !== e) : [...n, e]), s?.(e, t);
|
|
378
703
|
};
|
|
379
704
|
return /* @__PURE__ */ t("div", {
|
|
380
705
|
...u,
|
|
381
706
|
className: c === void 0 ? "pb-diff" : `pb-diff ${c}`,
|
|
382
|
-
children: r === void 0 ? /* @__PURE__ */ t(
|
|
707
|
+
children: r === void 0 ? /* @__PURE__ */ t(le, { text: e }) : r.map((e, r) => {
|
|
383
708
|
let i = !m.includes(e.path), a = `${d}-${String(r)}`;
|
|
384
709
|
return /* @__PURE__ */ n("div", {
|
|
385
710
|
className: "pb-diff-file",
|
|
@@ -407,9 +732,9 @@ function V({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
|
|
|
407
732
|
stroke: "currentColor",
|
|
408
733
|
strokeWidth: "2"
|
|
409
734
|
})
|
|
410
|
-
}),
|
|
735
|
+
}), se(e.path)]
|
|
411
736
|
})
|
|
412
|
-
}), /* @__PURE__ */ t(
|
|
737
|
+
}), /* @__PURE__ */ t(le, {
|
|
413
738
|
text: e.diff,
|
|
414
739
|
id: a,
|
|
415
740
|
hidden: !i
|
|
@@ -419,7 +744,14 @@ function V({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
|
|
|
419
744
|
});
|
|
420
745
|
}
|
|
421
746
|
// src/composites/shortcut-sheet/ShortcutSheet.tsx
|
|
422
|
-
|
|
747
|
+
var de = {
|
|
748
|
+
title: "Keyboard shortcuts",
|
|
749
|
+
or: "or",
|
|
750
|
+
empty: "No shortcuts",
|
|
751
|
+
close: "Close",
|
|
752
|
+
keyNames: {}
|
|
753
|
+
};
|
|
754
|
+
function fe(e) {
|
|
423
755
|
let t = /* @__PURE__ */ new Map();
|
|
424
756
|
for (let n of e) {
|
|
425
757
|
let e = t.get(n.group);
|
|
@@ -430,21 +762,24 @@ function H(e) {
|
|
|
430
762
|
lines: t
|
|
431
763
|
}));
|
|
432
764
|
}
|
|
433
|
-
function
|
|
434
|
-
let
|
|
765
|
+
function pe({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels: l, className: u }) {
|
|
766
|
+
let d = {
|
|
767
|
+
...de,
|
|
768
|
+
...l
|
|
769
|
+
}, p = a(), g = fe(o);
|
|
435
770
|
return /* @__PURE__ */ n(f, {
|
|
436
771
|
open: e,
|
|
437
772
|
onClose: i,
|
|
438
|
-
title:
|
|
439
|
-
|
|
440
|
-
className:
|
|
773
|
+
title: d.title,
|
|
774
|
+
labels: { close: d.close },
|
|
775
|
+
className: u === void 0 ? "pb-shortcut-sheet" : `pb-shortcut-sheet ${u}`,
|
|
441
776
|
children: [
|
|
442
|
-
|
|
777
|
+
g.length === 0 && /* @__PURE__ */ t("p", {
|
|
443
778
|
className: "pb-shortcut-sheet-empty",
|
|
444
|
-
children:
|
|
779
|
+
children: d.empty
|
|
445
780
|
}),
|
|
446
|
-
|
|
447
|
-
let o = `${
|
|
781
|
+
g.map(({ group: e, lines: i }, a) => {
|
|
782
|
+
let o = `${p}-${a}`;
|
|
448
783
|
return /* @__PURE__ */ n("section", {
|
|
449
784
|
className: "pb-shortcut-sheet-group",
|
|
450
785
|
"aria-labelledby": o,
|
|
@@ -459,17 +794,17 @@ function U({ open: e, onClose: i, shortcuts: o, title: s = "Keyboard shortcuts",
|
|
|
459
794
|
return /* @__PURE__ */ n("div", {
|
|
460
795
|
className: "pb-shortcut-sheet-line",
|
|
461
796
|
children: [/* @__PURE__ */ t("dt", { children: e.label }), /* @__PURE__ */ t("dd", {
|
|
462
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a,
|
|
797
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : m(a, c),
|
|
463
798
|
children: a.map((e, i) => /* @__PURE__ */ n(r, { children: [i > 0 && /* @__PURE__ */ n("span", {
|
|
464
799
|
className: "pb-shortcut-sheet-or",
|
|
465
800
|
children: [
|
|
466
801
|
" ",
|
|
467
|
-
|
|
802
|
+
d.or,
|
|
468
803
|
" "
|
|
469
804
|
]
|
|
470
805
|
}), /* @__PURE__ */ t("kbd", { children: h(e, {
|
|
471
|
-
platform:
|
|
472
|
-
names:
|
|
806
|
+
platform: c,
|
|
807
|
+
names: d.keyNames
|
|
473
808
|
}) })] }, e))
|
|
474
809
|
})]
|
|
475
810
|
}, `${e.label}-${i}`);
|
|
@@ -477,15 +812,15 @@ function U({ open: e, onClose: i, shortcuts: o, title: s = "Keyboard shortcuts",
|
|
|
477
812
|
})]
|
|
478
813
|
}, e);
|
|
479
814
|
}),
|
|
480
|
-
|
|
815
|
+
s !== void 0 && /* @__PURE__ */ t("div", {
|
|
481
816
|
className: "pb-shortcut-sheet-note",
|
|
482
|
-
children:
|
|
817
|
+
children: s
|
|
483
818
|
})
|
|
484
819
|
]
|
|
485
820
|
});
|
|
486
821
|
}
|
|
487
822
|
// src/composites/status-words/StatusWords.tsx
|
|
488
|
-
function
|
|
823
|
+
function me({ items: e, className: n, ...r }) {
|
|
489
824
|
return /* @__PURE__ */ t("ul", {
|
|
490
825
|
"aria-live": "polite",
|
|
491
826
|
...r,
|
|
@@ -499,7 +834,12 @@ function W({ items: e, className: n, ...r }) {
|
|
|
499
834
|
});
|
|
500
835
|
}
|
|
501
836
|
// src/composites/toaster/Toaster.tsx
|
|
502
|
-
var
|
|
837
|
+
var he = {
|
|
838
|
+
region: "Notifications",
|
|
839
|
+
dismiss: "Dismiss",
|
|
840
|
+
more: (e) => `and ${e} more`,
|
|
841
|
+
count: (e) => `${e} times`
|
|
842
|
+
}, ge = /* @__PURE__ */ new Set([
|
|
503
843
|
"top-start",
|
|
504
844
|
"top",
|
|
505
845
|
"top-end",
|
|
@@ -507,15 +847,18 @@ var G = /* @__PURE__ */ new Set([
|
|
|
507
847
|
"bottom",
|
|
508
848
|
"bottom-end",
|
|
509
849
|
"inline"
|
|
510
|
-
]),
|
|
511
|
-
function
|
|
512
|
-
let
|
|
850
|
+
]), _e = 256;
|
|
851
|
+
function ve({ 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 }) {
|
|
852
|
+
let x = {
|
|
853
|
+
...he,
|
|
854
|
+
...m
|
|
855
|
+
}, S = a(), C = ge.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
856
|
i(() => {
|
|
514
857
|
let e = [];
|
|
515
858
|
for (let t of r) {
|
|
516
|
-
let n = t.count ?? 1, r =
|
|
517
|
-
r !== void 0 && n <= r || (
|
|
518
|
-
seq:
|
|
859
|
+
let n = t.count ?? 1, r = D.current.get(t.id);
|
|
860
|
+
r !== void 0 && n <= r || (D.current.set(t.id, n), O.current += 1, e.push({
|
|
861
|
+
seq: O.current,
|
|
519
862
|
id: t.id,
|
|
520
863
|
alert: t.tone === "err",
|
|
521
864
|
text: t.text,
|
|
@@ -523,90 +866,90 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
523
866
|
}));
|
|
524
867
|
}
|
|
525
868
|
let t = new Set(r.map((e) => e.id));
|
|
526
|
-
if (
|
|
869
|
+
if (D.current.size > _e) for (let e of D.current.keys()) t.has(e) || D.current.delete(e);
|
|
527
870
|
let n = new Set(e.map((e) => e.id));
|
|
528
|
-
|
|
871
|
+
A((r) => {
|
|
529
872
|
let i = r.filter((e) => t.has(e.id) && !n.has(e.id));
|
|
530
873
|
return e.length === 0 && i.length === r.length ? r : [...i, ...e];
|
|
531
874
|
});
|
|
532
875
|
}, [r]);
|
|
533
|
-
let
|
|
876
|
+
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
877
|
className: "pb-toaster-announce",
|
|
535
878
|
children: [/* @__PURE__ */ t("div", {
|
|
536
879
|
role: "status",
|
|
537
|
-
children:
|
|
880
|
+
children: M(!1)
|
|
538
881
|
}), /* @__PURE__ */ t("div", {
|
|
539
882
|
role: "alert",
|
|
540
|
-
children:
|
|
883
|
+
children: M(!0)
|
|
541
884
|
})]
|
|
542
|
-
}), [
|
|
543
|
-
|
|
544
|
-
let
|
|
885
|
+
}), [P, F] = l(!1), [I, L] = l(!1);
|
|
886
|
+
E && (P || I) && (F(!1), L(!1));
|
|
887
|
+
let R = P || I, z = c(f);
|
|
545
888
|
o(() => {
|
|
546
|
-
|
|
889
|
+
z.current = f;
|
|
547
890
|
}), o(() => {
|
|
548
|
-
|
|
549
|
-
}, [
|
|
550
|
-
|
|
891
|
+
z.current?.(R);
|
|
892
|
+
}, [R]), o(() => () => {
|
|
893
|
+
z.current?.(!1);
|
|
551
894
|
}, []);
|
|
552
|
-
let
|
|
895
|
+
let B = c(null), V = c(null), H = c(void 0);
|
|
553
896
|
o(() => {
|
|
554
|
-
let e =
|
|
897
|
+
let e = H.current;
|
|
555
898
|
if (e === void 0) return;
|
|
556
|
-
|
|
557
|
-
let t = (e === null ? null :
|
|
899
|
+
H.current = void 0;
|
|
900
|
+
let t = (e === null ? null : B.current?.querySelector(`[data-toast-id="${e}"]`)) ?? B.current?.querySelector(".pb-toast");
|
|
558
901
|
if (t != null) {
|
|
559
902
|
t.focus();
|
|
560
903
|
return;
|
|
561
904
|
}
|
|
562
|
-
let n =
|
|
563
|
-
|
|
905
|
+
let n = V.current;
|
|
906
|
+
V.current = null, n?.isConnected === !0 && n.focus();
|
|
564
907
|
});
|
|
565
|
-
let
|
|
566
|
-
if (
|
|
567
|
-
let t =
|
|
568
|
-
|
|
908
|
+
let U = (e) => {
|
|
909
|
+
if (B.current?.contains(document.activeElement) === !0) {
|
|
910
|
+
let t = T.findIndex((t) => t.id === e);
|
|
911
|
+
H.current = (T[t + 1] ?? T[t - 1])?.id ?? null;
|
|
569
912
|
}
|
|
570
913
|
u(e);
|
|
571
914
|
};
|
|
572
|
-
if (
|
|
573
|
-
let
|
|
915
|
+
if (E) return N;
|
|
916
|
+
let W = s > 0 && /* @__PURE__ */ t("p", {
|
|
574
917
|
className: "pb-toaster-more",
|
|
575
|
-
children:
|
|
918
|
+
children: x.more(s)
|
|
576
919
|
});
|
|
577
|
-
return /* @__PURE__ */ n(e, { children: [
|
|
578
|
-
...
|
|
579
|
-
"aria-label":
|
|
580
|
-
className:
|
|
581
|
-
"data-placement":
|
|
920
|
+
return /* @__PURE__ */ n(e, { children: [N, /* @__PURE__ */ n("section", {
|
|
921
|
+
...b,
|
|
922
|
+
"aria-label": b["aria-label"] ?? x.region,
|
|
923
|
+
className: h === void 0 ? "pb-toaster" : `pb-toaster ${h}`,
|
|
924
|
+
"data-placement": C,
|
|
582
925
|
onPointerEnter: (e) => {
|
|
583
|
-
|
|
926
|
+
g?.(e), e.pointerType !== "touch" && F(!0);
|
|
584
927
|
},
|
|
585
928
|
onPointerLeave: (e) => {
|
|
586
|
-
|
|
929
|
+
_?.(e), F(!1);
|
|
587
930
|
},
|
|
588
931
|
onFocus: (e) => {
|
|
589
|
-
|
|
932
|
+
v?.(e);
|
|
590
933
|
let t = e.relatedTarget;
|
|
591
|
-
!
|
|
934
|
+
!I && t instanceof HTMLElement && !e.currentTarget.contains(t) && (V.current = t), L(!0);
|
|
592
935
|
},
|
|
593
936
|
onBlur: (e) => {
|
|
594
|
-
|
|
937
|
+
y?.(e), e.currentTarget.contains(e.relatedTarget) || L(!1);
|
|
595
938
|
},
|
|
596
939
|
children: [
|
|
597
|
-
!
|
|
940
|
+
!w && W,
|
|
598
941
|
/* @__PURE__ */ t("ol", {
|
|
599
942
|
className: "pb-toaster-list",
|
|
600
|
-
ref:
|
|
601
|
-
children:
|
|
602
|
-
let r = `${
|
|
943
|
+
ref: B,
|
|
944
|
+
children: T.map((e) => {
|
|
945
|
+
let r = `${S}-${e.id}`, i = e.count ?? 1;
|
|
603
946
|
return /* @__PURE__ */ n("li", {
|
|
604
947
|
className: "pb-toast",
|
|
605
948
|
"data-tone": e.tone,
|
|
606
949
|
"data-toast-id": e.id,
|
|
607
950
|
tabIndex: -1,
|
|
608
951
|
onKeyDown: (t) => {
|
|
609
|
-
t.key !== "Escape" || t.defaultPrevented || (t.preventDefault(), t.stopPropagation(),
|
|
952
|
+
t.key !== "Escape" || t.defaultPrevented || (t.preventDefault(), t.stopPropagation(), U(e.id));
|
|
610
953
|
},
|
|
611
954
|
children: [/* @__PURE__ */ n("div", {
|
|
612
955
|
className: "pb-toast-text",
|
|
@@ -618,7 +961,7 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
618
961
|
children: [" ×", i]
|
|
619
962
|
}), /* @__PURE__ */ n("span", {
|
|
620
963
|
className: "pb-toast-hidden",
|
|
621
|
-
children: [", ",
|
|
964
|
+
children: [", ", x.count(i)]
|
|
622
965
|
})]
|
|
623
966
|
})]
|
|
624
967
|
}), /* @__PURE__ */ n("div", {
|
|
@@ -626,25 +969,25 @@ function Y({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
|
|
|
626
969
|
children: [e.action !== void 0 && /* @__PURE__ */ t(d, {
|
|
627
970
|
size: "sm",
|
|
628
971
|
onClick: () => {
|
|
629
|
-
e.action?.run(),
|
|
972
|
+
e.action?.run(), U(e.id);
|
|
630
973
|
},
|
|
631
974
|
children: e.action.label
|
|
632
975
|
}), /* @__PURE__ */ t(d, {
|
|
633
976
|
size: "sm",
|
|
634
977
|
"aria-describedby": r,
|
|
635
978
|
onClick: () => {
|
|
636
|
-
|
|
979
|
+
U(e.id);
|
|
637
980
|
},
|
|
638
|
-
children:
|
|
981
|
+
children: x.dismiss
|
|
639
982
|
})]
|
|
640
983
|
})]
|
|
641
984
|
}, e.id);
|
|
642
985
|
})
|
|
643
986
|
}),
|
|
644
|
-
|
|
987
|
+
w && W
|
|
645
988
|
]
|
|
646
989
|
})] });
|
|
647
990
|
}
|
|
648
|
-
export {
|
|
991
|
+
export { _ as Banner, R as CodeEditor, z as CodeText, ae as CommandPalette, ue as DiffView, te as PALETTE_GUTTER, Q as PALETTE_HEIGHT, Z as PALETTE_WIDTH, pe as ShortcutSheet, me as StatusWords, ve as Toaster, x as caretAt, D as codeRuns, g as defaultBannerLabels, N as defaultCodeEditorLabels, X as defaultCommandPaletteLabels, de as defaultShortcutSheetLabels, he as defaultToasterLabels, fe as groupShortcuts, O as gutterRows, j as loadKnobly, C as markLevel, Y as markRuns, q as matchSubsequence, S as offsetAt, $ as placePalette, J as rankCommands, y as shownText, I as tabEdit };
|
|
649
992
|
|
|
650
993
|
//# sourceMappingURL=composites.js.map
|