@mcurcio/patchbay 0.9.0 → 0.10.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 +11 -2
- package/dist/composites.css +1 -1
- package/dist/composites.js +399 -254
- package/dist/composites.js.map +1 -1
- package/dist/graph.css +1 -1
- package/dist/graph.js +575 -273
- package/dist/graph.js.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/primitives.css +1 -1
- package/dist/primitives.js +123 -113
- package/dist/primitives.js.map +1 -1
- package/dist/shell.css +1 -1
- package/dist/shell.js +89 -71
- package/dist/shell.js.map +1 -1
- package/dist/types/composites/banner/Banner.d.ts +2 -2
- package/dist/types/composites/change-list/ChangeList.d.ts +44 -0
- package/dist/types/composites/change-list/index.d.ts +2 -0
- package/dist/types/composites/diagnostic-list/DiagnosticList.d.ts +23 -0
- package/dist/types/composites/diagnostic-list/index.d.ts +2 -0
- package/dist/types/composites/index.d.ts +2 -0
- package/dist/types/composites/status-words/StatusWords.d.ts +1 -1
- package/dist/types/graph/canvas-tools/CanvasTools.d.ts +7 -2
- package/dist/types/graph/connect-hints/connectTargets.d.ts +22 -0
- package/dist/types/graph/connect-hints/index.d.ts +3 -1
- package/dist/types/graph/connect-hints/useConnectHints.d.ts +9 -0
- package/dist/types/graph/connect-status/ConnectStatus.d.ts +30 -0
- package/dist/types/graph/connect-status/index.d.ts +2 -0
- package/dist/types/graph/context-at/index.d.ts +2 -0
- package/dist/types/graph/context-at/useContextAt.d.ts +43 -0
- package/dist/types/graph/empty-canvas-hint/EmptyCanvasHint.d.ts +33 -0
- package/dist/types/graph/empty-canvas-hint/index.d.ts +2 -0
- package/dist/types/graph/ghost-node/GhostNode.d.ts +32 -0
- package/dist/types/graph/ghost-node/index.d.ts +2 -0
- package/dist/types/graph/ghost-wire/GhostWire.d.ts +1 -1
- package/dist/types/graph/index.d.ts +4 -0
- package/dist/types/graph/meter/Meter.d.ts +8 -1
- package/dist/types/graph/meter/index.d.ts +1 -1
- package/dist/types/graph/wire/Wire.d.ts +4 -4
- package/dist/types/hooks/use-toasts/toastQueue.d.ts +1 -1
- package/dist/types/primitives/glyph/Glyph.d.ts +14 -0
- package/dist/types/primitives/glyph/index.d.ts +2 -0
- package/dist/types/primitives/icon-button/index.d.ts +1 -0
- package/dist/types/primitives/index.d.ts +1 -0
- package/dist/types/primitives/key-value/KeyValue.d.ts +3 -3
- package/dist/types/primitives/spinner/Spinner.d.ts +1 -1
- package/package.json +1 -1
- /package/dist/types/primitives/{dialog → icon-button}/CloseGlyph.d.ts +0 -0
package/dist/composites.js
CHANGED
|
@@ -1,52 +1,145 @@
|
|
|
1
1
|
import "./composites.css";import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
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
3
|
import { createPortal as u } from "react-dom";
|
|
4
|
-
import {
|
|
5
|
-
import { ariaKeyShortcuts as
|
|
4
|
+
import { Badge as d, Button as f, CloseGlyph as p, Dialog as m, Glyph as h, IconButton as g } from "./primitives.js";
|
|
5
|
+
import { ariaKeyShortcuts as _, keyLabel as v } from "./hooks.js";
|
|
6
6
|
// src/composites/banner/Banner.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
...
|
|
11
|
-
...
|
|
12
|
-
};
|
|
7
|
+
var y = { dismiss: "Dismiss" };
|
|
8
|
+
function b({ tone: e, children: r, actions: a, onDismiss: o, labels: s, className: c, ...u }) {
|
|
9
|
+
let d = {
|
|
10
|
+
...y,
|
|
11
|
+
...s
|
|
12
|
+
}, [f, m] = l(!1);
|
|
13
|
+
i(() => {
|
|
14
|
+
m(!0);
|
|
15
|
+
}, []);
|
|
16
|
+
let h = e === "err";
|
|
13
17
|
return /* @__PURE__ */ n("div", {
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
className: s === void 0 ? "pb-banner" : `pb-banner ${s}`,
|
|
18
|
+
...u,
|
|
19
|
+
className: c === void 0 ? "pb-banner" : `pb-banner ${c}`,
|
|
17
20
|
"data-tone": e,
|
|
18
21
|
children: [
|
|
22
|
+
/* @__PURE__ */ n("div", {
|
|
23
|
+
className: "pb-banner-announce",
|
|
24
|
+
children: [/* @__PURE__ */ t("div", {
|
|
25
|
+
role: "status",
|
|
26
|
+
children: f && !h && r
|
|
27
|
+
}), /* @__PURE__ */ t("div", {
|
|
28
|
+
role: "alert",
|
|
29
|
+
children: f && h && r
|
|
30
|
+
})]
|
|
31
|
+
}),
|
|
19
32
|
/* @__PURE__ */ t("div", {
|
|
20
33
|
className: "pb-banner-text",
|
|
21
34
|
children: r
|
|
22
35
|
}),
|
|
23
|
-
|
|
36
|
+
a !== void 0 && /* @__PURE__ */ t("div", {
|
|
24
37
|
className: "pb-banner-actions",
|
|
25
|
-
children:
|
|
38
|
+
children: a
|
|
26
39
|
}),
|
|
27
|
-
|
|
40
|
+
o !== void 0 && /* @__PURE__ */ t(g, {
|
|
28
41
|
className: "pb-banner-dismiss",
|
|
29
42
|
size: "sm",
|
|
30
|
-
label:
|
|
31
|
-
onClick:
|
|
32
|
-
children: /* @__PURE__ */ t(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
label: d.dismiss,
|
|
44
|
+
onClick: o,
|
|
45
|
+
children: /* @__PURE__ */ t(p, {})
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// src/composites/change-list/ChangeList.tsx
|
|
51
|
+
var x = {
|
|
52
|
+
added: "added",
|
|
53
|
+
removed: "removed",
|
|
54
|
+
renamed: "renamed",
|
|
55
|
+
changed: "changed",
|
|
56
|
+
count: (e) => e === 0 ? "No changes" : e === 1 ? "1 change" : `${String(e)} changes`,
|
|
57
|
+
drop: "Drop",
|
|
58
|
+
refused: (e) => `Refused: ${e}`
|
|
59
|
+
};
|
|
60
|
+
function S(e, t) {
|
|
61
|
+
switch (e) {
|
|
62
|
+
case "added": return t.added;
|
|
63
|
+
case "removed": return t.removed;
|
|
64
|
+
case "renamed": return t.renamed;
|
|
65
|
+
case "changed": return t.changed;
|
|
66
|
+
default: return e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function C({ change: e, onDrop: r, words: i }) {
|
|
70
|
+
let o = a();
|
|
71
|
+
return /* @__PURE__ */ n("li", {
|
|
72
|
+
className: "pb-change-row",
|
|
73
|
+
"data-change": e.change,
|
|
74
|
+
"data-refused": e.refused === void 0 ? void 0 : "",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ t(d, {
|
|
77
|
+
tone: e.change,
|
|
78
|
+
children: S(e.change, i)
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ n("div", {
|
|
81
|
+
className: "pb-change-words",
|
|
82
|
+
id: o,
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ t("div", {
|
|
85
|
+
className: "pb-change-label",
|
|
86
|
+
children: e.label
|
|
87
|
+
}),
|
|
88
|
+
e.detail !== void 0 && e.detail !== null && /* @__PURE__ */ t("div", {
|
|
89
|
+
className: "pb-change-detail",
|
|
90
|
+
children: e.detail
|
|
91
|
+
}),
|
|
92
|
+
e.refused !== void 0 && /* @__PURE__ */ t("div", {
|
|
93
|
+
className: "pb-change-refused",
|
|
94
|
+
children: i.refused(e.refused)
|
|
42
95
|
})
|
|
43
|
-
|
|
96
|
+
]
|
|
97
|
+
}),
|
|
98
|
+
r !== void 0 && /* @__PURE__ */ t(f, {
|
|
99
|
+
size: "sm",
|
|
100
|
+
className: "pb-change-drop",
|
|
101
|
+
"aria-describedby": o,
|
|
102
|
+
onClick: () => {
|
|
103
|
+
r(e.id);
|
|
104
|
+
},
|
|
105
|
+
children: i.drop
|
|
44
106
|
})
|
|
45
107
|
]
|
|
46
108
|
});
|
|
47
109
|
}
|
|
110
|
+
function w({ changes: e, onDrop: r, actions: i, labels: o, className: s, ...c }) {
|
|
111
|
+
let l = {
|
|
112
|
+
...x,
|
|
113
|
+
...o
|
|
114
|
+
}, u = a();
|
|
115
|
+
return /* @__PURE__ */ n("section", {
|
|
116
|
+
...c,
|
|
117
|
+
"aria-labelledby": c["aria-labelledby"] ?? (c["aria-label"] === void 0 ? u : void 0),
|
|
118
|
+
className: s === void 0 ? "pb-change-list" : `pb-change-list ${s}`,
|
|
119
|
+
"data-empty": e.length === 0 ? "" : void 0,
|
|
120
|
+
children: [/* @__PURE__ */ n("div", {
|
|
121
|
+
className: "pb-change-head",
|
|
122
|
+
children: [/* @__PURE__ */ t("p", {
|
|
123
|
+
className: "pb-change-count",
|
|
124
|
+
id: u,
|
|
125
|
+
role: "status",
|
|
126
|
+
children: l.count(e.length)
|
|
127
|
+
}), i !== void 0 && /* @__PURE__ */ t("div", {
|
|
128
|
+
className: "pb-change-actions",
|
|
129
|
+
children: i
|
|
130
|
+
})]
|
|
131
|
+
}), e.length > 0 && /* @__PURE__ */ t("ul", {
|
|
132
|
+
className: "pb-change-rows",
|
|
133
|
+
children: e.map((e) => /* @__PURE__ */ t(C, {
|
|
134
|
+
change: e,
|
|
135
|
+
onDrop: r,
|
|
136
|
+
words: l
|
|
137
|
+
}, e.id))
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
48
141
|
// src/composites/code-editor/CodeRuns.tsx
|
|
49
|
-
function
|
|
142
|
+
function T({ runs: e }) {
|
|
50
143
|
return e.map((e, n) => e.class === "" && e.mark === void 0 ? e.text : /* @__PURE__ */ t("span", {
|
|
51
144
|
className: "pb-code-run",
|
|
52
145
|
"data-class": e.class || void 0,
|
|
@@ -55,16 +148,16 @@ function v({ runs: e }) {
|
|
|
55
148
|
}, n));
|
|
56
149
|
}
|
|
57
150
|
// src/composites/code-editor/highlight.ts
|
|
58
|
-
function
|
|
151
|
+
function E(e) {
|
|
59
152
|
return e.replace(/\r\n?/g, "\n");
|
|
60
153
|
}
|
|
61
|
-
function
|
|
154
|
+
function D(e) {
|
|
62
155
|
let t = [0];
|
|
63
156
|
for (let n = e.indexOf("\n"); n !== -1; n = e.indexOf("\n", n + 1)) t.push(n + 1);
|
|
64
157
|
return t;
|
|
65
158
|
}
|
|
66
|
-
function
|
|
67
|
-
let n = Math.min(e.length, Math.max(0, Math.trunc(t))), r =
|
|
159
|
+
function O(e, t) {
|
|
160
|
+
let n = Math.min(e.length, Math.max(0, Math.trunc(t))), r = D(e), i = 0;
|
|
68
161
|
for (; i + 1 < r.length && (r[i + 1] ?? Infinity) <= n;) i += 1;
|
|
69
162
|
return {
|
|
70
163
|
line: i + 1,
|
|
@@ -72,23 +165,23 @@ function x(e, t) {
|
|
|
72
165
|
offset: n
|
|
73
166
|
};
|
|
74
167
|
}
|
|
75
|
-
function
|
|
76
|
-
let r =
|
|
168
|
+
function k(e, t, n = 1) {
|
|
169
|
+
let r = D(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
170
|
return Math.min(o, a + Math.max(1, Math.trunc(n)) - 1);
|
|
78
171
|
}
|
|
79
|
-
function
|
|
172
|
+
function A(e) {
|
|
80
173
|
return e === "error" ? "error" : e === "warning" ? "warning" : "other";
|
|
81
174
|
}
|
|
82
|
-
var
|
|
175
|
+
var j = {
|
|
83
176
|
other: 1,
|
|
84
177
|
warning: 2,
|
|
85
178
|
error: 3
|
|
86
179
|
};
|
|
87
|
-
function
|
|
88
|
-
return e !== void 0 &&
|
|
180
|
+
function M(e, t) {
|
|
181
|
+
return e !== void 0 && j[e] >= j[t] ? e : t;
|
|
89
182
|
}
|
|
90
|
-
function
|
|
91
|
-
let n =
|
|
183
|
+
function N(e, t) {
|
|
184
|
+
let n = D(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
185
|
if (t.column === void 0) {
|
|
93
186
|
let t = i, n = a;
|
|
94
187
|
for (; t < n && /\s/.test(e[t] ?? "");) t += 1;
|
|
@@ -98,14 +191,14 @@ function E(e, t) {
|
|
|
98
191
|
end: n
|
|
99
192
|
};
|
|
100
193
|
}
|
|
101
|
-
let o =
|
|
194
|
+
let o = k(e, r + 1, t.column), s = o;
|
|
102
195
|
for (; s < a && !/\s/.test(e[s] ?? "");) s += 1;
|
|
103
196
|
return s === o && o < a && (s = o + 1), {
|
|
104
197
|
start: o,
|
|
105
198
|
end: s
|
|
106
199
|
};
|
|
107
200
|
}
|
|
108
|
-
function
|
|
201
|
+
function P(e, t = [], n = []) {
|
|
109
202
|
let r = [""], i = new Uint16Array(e.length);
|
|
110
203
|
for (let n of t) {
|
|
111
204
|
let t = Math.max(0, Math.trunc(n.start)), a = Math.min(e.length, Math.trunc(n.end));
|
|
@@ -120,7 +213,7 @@ function D(e, t = [], n = []) {
|
|
|
120
213
|
"error"
|
|
121
214
|
], o = new Uint8Array(e.length);
|
|
122
215
|
for (let t of n) {
|
|
123
|
-
let { start: n, end: r } =
|
|
216
|
+
let { start: n, end: r } = N(e, t), i = j[A(t.severity)];
|
|
124
217
|
for (let e = n; e < r; e += 1) o[e] = Math.max(o[e] ?? 0, i);
|
|
125
218
|
}
|
|
126
219
|
let s = [], c = 0;
|
|
@@ -134,47 +227,47 @@ function D(e, t = [], n = []) {
|
|
|
134
227
|
}
|
|
135
228
|
return s;
|
|
136
229
|
}
|
|
137
|
-
function
|
|
138
|
-
let n =
|
|
230
|
+
function F(e, t = []) {
|
|
231
|
+
let n = D(e).length, r = Array.from({ length: n }, (e, t) => ({
|
|
139
232
|
line: t + 1,
|
|
140
233
|
column: 1,
|
|
141
234
|
diagnostics: []
|
|
142
235
|
}));
|
|
143
236
|
for (let e of t) {
|
|
144
237
|
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 =
|
|
238
|
+
t !== void 0 && (t.diagnostics.length === 0 && (t.column = e.column ?? 1), t.diagnostics.push(e), t.mark = M(t.mark, A(e.severity)));
|
|
146
239
|
}
|
|
147
240
|
return r;
|
|
148
241
|
}
|
|
149
|
-
var
|
|
150
|
-
function
|
|
151
|
-
return
|
|
242
|
+
var I, L;
|
|
243
|
+
function R() {
|
|
244
|
+
return I ??= import("knobly/highlight").then((e) => L = e.highlight, (e) => (console.warn("patchbay: language \"knobly\" needs the knobly package; drawing plain text.", e), L = null, null)), I;
|
|
152
245
|
}
|
|
153
|
-
function
|
|
246
|
+
function z(e, t) {
|
|
154
247
|
let n = t === void 0 && e === "knobly", [r, a] = l(void 0);
|
|
155
248
|
return i(() => {
|
|
156
|
-
if (!n ||
|
|
249
|
+
if (!n || L !== void 0) return;
|
|
157
250
|
let e = !0;
|
|
158
|
-
return
|
|
251
|
+
return R().then((t) => {
|
|
159
252
|
e && a({ highlight: t });
|
|
160
253
|
}), () => {
|
|
161
254
|
e = !1;
|
|
162
255
|
};
|
|
163
|
-
}, [n]), t === void 0 ? n ?
|
|
256
|
+
}, [n]), t === void 0 ? n ? L ?? r?.highlight ?? void 0 : void 0 : t;
|
|
164
257
|
}
|
|
165
258
|
// src/composites/code-editor/CodeEditor.tsx
|
|
166
|
-
var
|
|
259
|
+
var B = {
|
|
167
260
|
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
261
|
tabKey: "Tab indents. Press Escape, then Tab, to move on."
|
|
169
|
-
},
|
|
170
|
-
function
|
|
262
|
+
}, V = [];
|
|
263
|
+
function H(e, t) {
|
|
171
264
|
if (t !== "" && e.startsWith(t)) return t.length;
|
|
172
265
|
if (e.startsWith(" ")) return 1;
|
|
173
266
|
let n = t === " " || t === "" ? 4 : t.length, r = 0;
|
|
174
267
|
for (; r < n && e[r] === " ";) r += 1;
|
|
175
268
|
return r;
|
|
176
269
|
}
|
|
177
|
-
function
|
|
270
|
+
function U(e, t, n, r, i) {
|
|
178
271
|
let a = e.slice(t, n).includes("\n");
|
|
179
272
|
if (!i && !a) {
|
|
180
273
|
if (r === "") return;
|
|
@@ -187,7 +280,7 @@ function I(e, t, n, r, i) {
|
|
|
187
280
|
end: e
|
|
188
281
|
};
|
|
189
282
|
}
|
|
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(
|
|
283
|
+
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(H(e, r)) : e === "" ? e : r + e), f = d.join("\n");
|
|
191
284
|
if (f !== e.slice(o, l)) {
|
|
192
285
|
if (t === n) {
|
|
193
286
|
let e = (d[0] ?? "").length - (u[0] ?? "").length, n = Math.max(o, t + e);
|
|
@@ -208,85 +301,96 @@ function I(e, t, n, r, i) {
|
|
|
208
301
|
};
|
|
209
302
|
}
|
|
210
303
|
}
|
|
211
|
-
function
|
|
304
|
+
function W(e) {
|
|
212
305
|
let t = document.execCommand;
|
|
213
306
|
return typeof t == "function" ? e === "" ? t.call(document, "delete", !1) : t.call(document, "insertText", !1, e) : !1;
|
|
214
307
|
}
|
|
215
|
-
function
|
|
216
|
-
let
|
|
217
|
-
...
|
|
218
|
-
...
|
|
219
|
-
},
|
|
308
|
+
function G({ value: e, onChange: r, language: l, highlight: u, diagnostics: d = V, onCaret: f, lineNumbers: p = !0, indent: m = " ", labels: h, readOnly: g = !1, className: _, style: v, ref: y, onKeyDown: b, onBlur: x, onScroll: S, onSelect: C, "aria-describedby": w, ...D }) {
|
|
309
|
+
let A = {
|
|
310
|
+
...B,
|
|
311
|
+
...h
|
|
312
|
+
}, j = c(null), M = c(null), N = c(null), I = c(!1), L = c(null), R = c(""), H = a(), G = z(l, u), K = E(e), ee = s(() => P(K, G?.(K), d), [
|
|
313
|
+
K,
|
|
220
314
|
G,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
315
|
+
d
|
|
316
|
+
]), q = s(() => F(K, d), [K, d]), J = () => {
|
|
317
|
+
let e = j.current;
|
|
318
|
+
e !== null && (M.current !== null && (M.current.scrollTop = e.scrollTop, M.current.scrollLeft = e.scrollLeft), N.current !== null && (N.current.scrollTop = e.scrollTop));
|
|
319
|
+
}, Y = () => {
|
|
320
|
+
let e = j.current;
|
|
321
|
+
if (e === null || f === void 0) return;
|
|
322
|
+
let t = e.selectionDirection === "backward" ? e.selectionStart : e.selectionEnd, n = O(e.value, t), r = `${String(n.line)}:${String(n.column)}:${String(n.offset)}`;
|
|
323
|
+
r !== R.current && (R.current = r, f(n));
|
|
324
|
+
}, X = c(Y);
|
|
232
325
|
o(() => {
|
|
233
|
-
|
|
234
|
-
|
|
326
|
+
X.current = Y;
|
|
327
|
+
}), i(() => {
|
|
328
|
+
let e = j.current;
|
|
329
|
+
if (e === null) return;
|
|
330
|
+
let t = () => {
|
|
331
|
+
document.activeElement === e && X.current();
|
|
332
|
+
};
|
|
333
|
+
return e.addEventListener("selectionchange", t), e.addEventListener("select", t), () => {
|
|
334
|
+
e.removeEventListener("selectionchange", t), e.removeEventListener("select", t);
|
|
335
|
+
};
|
|
336
|
+
}, []), o(() => {
|
|
337
|
+
let e = j.current, t = L.current;
|
|
338
|
+
L.current = null, e !== null && t !== null && e.value === t.value && (e.setSelectionRange(t.start, t.end), Y()), J();
|
|
235
339
|
});
|
|
236
|
-
let
|
|
237
|
-
if (e.setSelectionRange(t.from, t.to),
|
|
238
|
-
e.setSelectionRange(t.start, t.end),
|
|
340
|
+
let te = (e, t) => {
|
|
341
|
+
if (e.setSelectionRange(t.from, t.to), W(t.insert)) {
|
|
342
|
+
e.setSelectionRange(t.start, t.end), Y();
|
|
239
343
|
return;
|
|
240
344
|
}
|
|
241
345
|
let n = e.value.slice(0, t.from) + t.insert + e.value.slice(t.to);
|
|
242
|
-
|
|
346
|
+
L.current = {
|
|
243
347
|
value: n,
|
|
244
348
|
start: t.start,
|
|
245
349
|
end: t.end
|
|
246
350
|
}, r?.(n);
|
|
247
|
-
},
|
|
248
|
-
if (
|
|
351
|
+
}, ne = (e) => {
|
|
352
|
+
if (b?.(e), e.defaultPrevented) return;
|
|
249
353
|
if (e.key === "Escape") {
|
|
250
|
-
|
|
354
|
+
I.current = !0;
|
|
251
355
|
return;
|
|
252
356
|
}
|
|
253
357
|
if (e.key !== "Tab") {
|
|
254
|
-
e.key !== "Shift" && (
|
|
358
|
+
e.key !== "Shift" && (I.current = !1);
|
|
255
359
|
return;
|
|
256
360
|
}
|
|
257
|
-
let t =
|
|
258
|
-
if (
|
|
361
|
+
let t = I.current;
|
|
362
|
+
if (I.current = !1, t || g || e.ctrlKey || e.altKey || e.metaKey || e.nativeEvent.isComposing) return;
|
|
259
363
|
e.preventDefault();
|
|
260
|
-
let n = e.currentTarget, r =
|
|
261
|
-
r !== void 0 &&
|
|
262
|
-
},
|
|
263
|
-
let n =
|
|
364
|
+
let n = e.currentTarget, r = U(n.value, n.selectionStart, n.selectionEnd, m, e.shiftKey);
|
|
365
|
+
r !== void 0 && te(n, r);
|
|
366
|
+
}, re = (e, t) => {
|
|
367
|
+
let n = j.current;
|
|
264
368
|
if (n === null) return;
|
|
265
|
-
let r =
|
|
266
|
-
n.focus(), n.setSelectionRange(r, r),
|
|
267
|
-
},
|
|
369
|
+
let r = k(n.value, e, t);
|
|
370
|
+
n.focus(), n.setSelectionRange(r, r), Y();
|
|
371
|
+
}, Z = [...g ? [] : [A.tabKey], ...d.map((e) => A.diagnostic(e))], Q = [w, Z.length > 0 ? H : void 0].filter((e) => e !== void 0 && e !== "").join(" ") || void 0, $ = String(q.length).length;
|
|
268
372
|
return /* @__PURE__ */ n("div", {
|
|
269
|
-
className:
|
|
270
|
-
style:
|
|
271
|
-
"data-readonly":
|
|
373
|
+
className: _ === void 0 ? "pb-code-editor" : `pb-code-editor ${_}`,
|
|
374
|
+
style: v,
|
|
375
|
+
"data-readonly": g || void 0,
|
|
272
376
|
children: [
|
|
273
|
-
|
|
274
|
-
ref:
|
|
377
|
+
p ? /* @__PURE__ */ t("pre", {
|
|
378
|
+
ref: N,
|
|
275
379
|
className: "pb-code-gutter",
|
|
276
380
|
"aria-hidden": "true",
|
|
277
381
|
style: { "--pb-code-gutter-digits": $ },
|
|
278
382
|
children: /* @__PURE__ */ t("code", {
|
|
279
383
|
className: "pb-code-gutter-code",
|
|
280
|
-
children:
|
|
384
|
+
children: q.map((e) => /* @__PURE__ */ n("span", {
|
|
281
385
|
className: "pb-code-gutter-row",
|
|
282
386
|
children: [
|
|
283
387
|
e.line,
|
|
284
388
|
/* @__PURE__ */ t("span", {
|
|
285
389
|
className: "pb-code-gutter-mark",
|
|
286
390
|
"data-mark": e.mark,
|
|
287
|
-
title: e.diagnostics.length === 0 ? void 0 : e.diagnostics.map((e) =>
|
|
391
|
+
title: e.diagnostics.length === 0 ? void 0 : e.diagnostics.map((e) => A.diagnostic(e)).join("\n"),
|
|
288
392
|
onClick: e.mark === void 0 ? void 0 : () => {
|
|
289
|
-
|
|
393
|
+
re(e.line, e.column);
|
|
290
394
|
}
|
|
291
395
|
}),
|
|
292
396
|
"\n"
|
|
@@ -297,12 +401,12 @@ function R({ value: e, onChange: r, language: i, highlight: l, diagnostics: u =
|
|
|
297
401
|
/* @__PURE__ */ n("div", {
|
|
298
402
|
className: "pb-code-box",
|
|
299
403
|
children: [/* @__PURE__ */ t("pre", {
|
|
300
|
-
ref:
|
|
404
|
+
ref: M,
|
|
301
405
|
className: "pb-code-layer",
|
|
302
406
|
"aria-hidden": "true",
|
|
303
407
|
children: /* @__PURE__ */ n("code", {
|
|
304
408
|
className: "pb-code-layer-code",
|
|
305
|
-
children: [/* @__PURE__ */ t(
|
|
409
|
+
children: [/* @__PURE__ */ t(T, { runs: ee }), "\n"]
|
|
306
410
|
})
|
|
307
411
|
}), /* @__PURE__ */ t("textarea", {
|
|
308
412
|
spellCheck: !1,
|
|
@@ -310,41 +414,41 @@ function R({ value: e, onChange: r, language: i, highlight: l, diagnostics: u =
|
|
|
310
414
|
autoComplete: "off",
|
|
311
415
|
autoCorrect: "off",
|
|
312
416
|
wrap: "off",
|
|
313
|
-
...
|
|
417
|
+
...D,
|
|
314
418
|
ref: (e) => {
|
|
315
|
-
if (
|
|
316
|
-
|
|
419
|
+
if (j.current = e, typeof y == "function") return y(e);
|
|
420
|
+
y && (y.current = e);
|
|
317
421
|
},
|
|
318
422
|
className: "pb-code-input",
|
|
319
423
|
value: e,
|
|
320
|
-
readOnly:
|
|
321
|
-
"aria-describedby":
|
|
424
|
+
readOnly: g,
|
|
425
|
+
"aria-describedby": Q,
|
|
322
426
|
onChange: (e) => r?.(e.target.value),
|
|
323
|
-
onKeyDown:
|
|
427
|
+
onKeyDown: ne,
|
|
324
428
|
onBlur: (e) => {
|
|
325
|
-
|
|
429
|
+
I.current = !1, x?.(e);
|
|
326
430
|
},
|
|
327
431
|
onScroll: (e) => {
|
|
328
|
-
|
|
432
|
+
J(), S?.(e);
|
|
329
433
|
},
|
|
330
434
|
onSelect: (e) => {
|
|
331
|
-
|
|
435
|
+
Y(), C?.(e);
|
|
332
436
|
}
|
|
333
437
|
})]
|
|
334
438
|
}),
|
|
335
|
-
|
|
336
|
-
id:
|
|
439
|
+
Z.length > 0 ? /* @__PURE__ */ t("div", {
|
|
440
|
+
id: H,
|
|
337
441
|
hidden: !0,
|
|
338
|
-
children:
|
|
442
|
+
children: Z.map((e, n) => /* @__PURE__ */ t("p", { children: e }, n))
|
|
339
443
|
}) : null
|
|
340
444
|
]
|
|
341
445
|
});
|
|
342
446
|
}
|
|
343
447
|
// src/composites/code-editor/CodeText.tsx
|
|
344
|
-
function
|
|
345
|
-
let o =
|
|
346
|
-
let t =
|
|
347
|
-
return
|
|
448
|
+
function K({ value: e, language: n, highlight: r, className: i, ...a }) {
|
|
449
|
+
let o = z(n, r), c = s(() => {
|
|
450
|
+
let t = E(e);
|
|
451
|
+
return P(t, o?.(t));
|
|
348
452
|
}, [e, o]);
|
|
349
453
|
return /* @__PURE__ */ t("pre", {
|
|
350
454
|
tabIndex: 0,
|
|
@@ -352,44 +456,44 @@ function z({ value: e, language: n, highlight: r, className: i, ...a }) {
|
|
|
352
456
|
className: i === void 0 ? "pb-code-text" : `pb-code-text ${i}`,
|
|
353
457
|
children: /* @__PURE__ */ t("code", {
|
|
354
458
|
className: "pb-code-text-code",
|
|
355
|
-
children: /* @__PURE__ */ t(
|
|
459
|
+
children: /* @__PURE__ */ t(T, { runs: c })
|
|
356
460
|
})
|
|
357
461
|
});
|
|
358
462
|
}
|
|
359
463
|
// src/composites/command-palette/rank.ts
|
|
360
|
-
function
|
|
464
|
+
function ee(e, t) {
|
|
361
465
|
if (t === 0) return !0;
|
|
362
466
|
let n = e.charAt(t - 1), r = e.charAt(t);
|
|
363
467
|
return !/[\p{L}\p{N}]/u.test(n) || n !== n.toUpperCase() && r !== r.toLowerCase() && r === r.toUpperCase();
|
|
364
468
|
}
|
|
365
|
-
function
|
|
469
|
+
function q(e) {
|
|
366
470
|
let t = e.toLowerCase();
|
|
367
471
|
return t.length === 1 ? t : e;
|
|
368
472
|
}
|
|
369
|
-
var
|
|
370
|
-
function
|
|
473
|
+
var J = 3, Y = 2, X = 2, te = .1, ne = 1, re = .02;
|
|
474
|
+
function Z(e, t) {
|
|
371
475
|
let n = t.replace(/\s+/g, "");
|
|
372
476
|
if (n === "") return {
|
|
373
477
|
indices: [],
|
|
374
478
|
score: 0
|
|
375
479
|
};
|
|
376
|
-
let r = Array.from({ length: n.length }, (e, t) =>
|
|
480
|
+
let r = Array.from({ length: n.length }, (e, t) => q(n.charAt(t))), i = Array.from({ length: e.length }, (t, n) => q(e.charAt(n))), a = e.length, o = r.length;
|
|
377
481
|
if (o > a) return;
|
|
378
|
-
let s = i.map((t, n) => n === 0 ?
|
|
482
|
+
let s = i.map((t, n) => n === 0 ? J : ee(e, n) ? Y : 0), c = [], l = [];
|
|
379
483
|
for (let e = 0; e < o; e += 1) {
|
|
380
484
|
let t = Array(a).fill(-Infinity), n = Array(a).fill(-1), o = r[e];
|
|
381
485
|
for (let r = e; r < a; r += 1) {
|
|
382
486
|
if (i[r] !== o) continue;
|
|
383
487
|
let a = 1 + (s[r] ?? 0);
|
|
384
488
|
if (e === 0) {
|
|
385
|
-
t[r] = a - r *
|
|
489
|
+
t[r] = a - r * re;
|
|
386
490
|
continue;
|
|
387
491
|
}
|
|
388
492
|
let l = c[e - 1] ?? [];
|
|
389
493
|
for (let i = e - 1; i < r; i += 1) {
|
|
390
494
|
let e = l[i] ?? -Infinity;
|
|
391
495
|
if (e === -Infinity) continue;
|
|
392
|
-
let o = i === r - 1 ?
|
|
496
|
+
let o = i === r - 1 ? X : -Math.min((r - i - 1) * te, ne), s = e + a + o;
|
|
393
497
|
s > (t[r] ?? -Infinity) && (t[r] = s, n[r] = i);
|
|
394
498
|
}
|
|
395
499
|
}
|
|
@@ -405,10 +509,10 @@ function q(e, t) {
|
|
|
405
509
|
score: u[d] ?? 0
|
|
406
510
|
};
|
|
407
511
|
}
|
|
408
|
-
function
|
|
512
|
+
function Q(e, t) {
|
|
409
513
|
let n = /* @__PURE__ */ new Map();
|
|
410
514
|
e.forEach((e, r) => {
|
|
411
|
-
let i =
|
|
515
|
+
let i = Z(e.label, t);
|
|
412
516
|
if (i === void 0) return;
|
|
413
517
|
let a = n.get(e.group);
|
|
414
518
|
a === void 0 && (a = {
|
|
@@ -439,7 +543,7 @@ function J(e, t) {
|
|
|
439
543
|
}))
|
|
440
544
|
}));
|
|
441
545
|
}
|
|
442
|
-
function
|
|
546
|
+
function $(e, t) {
|
|
443
547
|
let n = new Set(t), r = [];
|
|
444
548
|
for (let t = 0; t < e.length; t += 1) {
|
|
445
549
|
let i = n.has(t), a = r[r.length - 1];
|
|
@@ -451,14 +555,14 @@ function Y(e, t) {
|
|
|
451
555
|
return r;
|
|
452
556
|
}
|
|
453
557
|
// src/composites/command-palette/CommandPalette.tsx
|
|
454
|
-
var
|
|
558
|
+
var ie = {
|
|
455
559
|
palette: "Commands",
|
|
456
560
|
placeholder: "Type a command",
|
|
457
561
|
empty: "No commands",
|
|
458
562
|
noMatch: (e) => `No command matches “${e}”`,
|
|
459
563
|
keyNames: {}
|
|
460
|
-
},
|
|
461
|
-
function
|
|
564
|
+
}, ae = 320, oe = 360, se = 8;
|
|
565
|
+
function ce(e, t) {
|
|
462
566
|
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));
|
|
463
567
|
return {
|
|
464
568
|
left: i(e.x, n, t.width),
|
|
@@ -467,8 +571,8 @@ function $(e, t) {
|
|
|
467
571
|
height: r
|
|
468
572
|
};
|
|
469
573
|
}
|
|
470
|
-
var
|
|
471
|
-
function
|
|
574
|
+
var le = 8;
|
|
575
|
+
function ue(e) {
|
|
472
576
|
let t = () => ({
|
|
473
577
|
width: window.innerWidth,
|
|
474
578
|
height: window.innerHeight
|
|
@@ -483,13 +587,13 @@ function re(e) {
|
|
|
483
587
|
};
|
|
484
588
|
}, [e]), n;
|
|
485
589
|
}
|
|
486
|
-
function
|
|
487
|
-
let
|
|
488
|
-
...
|
|
590
|
+
function de({ onClose: e, commands: r, at: u, platform: d, labels: f, className: p }) {
|
|
591
|
+
let m = {
|
|
592
|
+
...ie,
|
|
489
593
|
...f
|
|
490
|
-
},
|
|
594
|
+
}, h = a(), g = `${h}-list`, [y, b] = l(""), x = s(() => Q(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
595
|
E !== y && (D(y), T(void 0));
|
|
492
|
-
let O = C.find((e) => e.id === w) ?? C[0], k = (e) => `${
|
|
596
|
+
let O = C.find((e) => e.id === w) ?? C[0], k = (e) => `${h}-option-${S.indexOf(e)}`, A = c(null), j = c(null), M = c(null), N = c(e);
|
|
493
597
|
o(() => {
|
|
494
598
|
N.current = e;
|
|
495
599
|
}), o(() => {
|
|
@@ -508,8 +612,8 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
508
612
|
let P = (e) => {
|
|
509
613
|
e.disabled !== !0 && (N.current(), e.run());
|
|
510
614
|
}, 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 ||
|
|
615
|
+
let e = M.current?.querySelector("[role=\"option\"]:not([aria-selected=\"true\"])") ?? M.current?.querySelector("[role=\"option\"]"), t = e && e.offsetHeight > 0 ? Math.floor((M.current?.clientHeight ?? 0) / e.offsetHeight) : 0;
|
|
616
|
+
return Math.max(1, t || le);
|
|
513
617
|
}, I = (e) => {
|
|
514
618
|
if (e.defaultPrevented || e.nativeEvent.isComposing) return;
|
|
515
619
|
let t = e.altKey || e.ctrlKey || e.metaKey, n = O === void 0 ? -1 : C.indexOf(O), r = C.length - 1, i = (t) => {
|
|
@@ -554,8 +658,8 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
554
658
|
return;
|
|
555
659
|
default: return;
|
|
556
660
|
}
|
|
557
|
-
}, L =
|
|
558
|
-
return r.length === 0 ? B =
|
|
661
|
+
}, L = ue(u !== void 0), R = u === void 0 ? void 0 : ce(u, L), z = R !== void 0, B;
|
|
662
|
+
return r.length === 0 ? B = m.empty : S.length === 0 && (B = m.noMatch(y.trim())), /* @__PURE__ */ t("div", {
|
|
559
663
|
className: "pb-palette-layer",
|
|
560
664
|
"data-anchored": z ? "" : void 0,
|
|
561
665
|
onMouseDown: (e) => {
|
|
@@ -566,7 +670,7 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
566
670
|
className: p === void 0 ? "pb-palette" : `pb-palette ${p}`,
|
|
567
671
|
role: "dialog",
|
|
568
672
|
"aria-modal": "true",
|
|
569
|
-
"aria-label":
|
|
673
|
+
"aria-label": m.palette,
|
|
570
674
|
style: R === void 0 ? void 0 : {
|
|
571
675
|
position: "fixed",
|
|
572
676
|
left: R.left,
|
|
@@ -584,16 +688,16 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
584
688
|
className: "pb-palette-field",
|
|
585
689
|
type: "text",
|
|
586
690
|
role: "combobox",
|
|
587
|
-
"aria-label":
|
|
691
|
+
"aria-label": m.palette,
|
|
588
692
|
"aria-expanded": "true",
|
|
589
|
-
"aria-controls":
|
|
693
|
+
"aria-controls": g,
|
|
590
694
|
"aria-autocomplete": "list",
|
|
591
695
|
"aria-activedescendant": O === void 0 ? void 0 : k(O),
|
|
592
696
|
autoComplete: "off",
|
|
593
697
|
autoCapitalize: "off",
|
|
594
698
|
autoCorrect: "off",
|
|
595
699
|
spellCheck: !1,
|
|
596
|
-
placeholder:
|
|
700
|
+
placeholder: m.placeholder,
|
|
597
701
|
value: y,
|
|
598
702
|
onChange: (e) => {
|
|
599
703
|
b(e.target.value);
|
|
@@ -603,12 +707,12 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
603
707
|
/* @__PURE__ */ t("div", {
|
|
604
708
|
ref: M,
|
|
605
709
|
className: "pb-palette-list",
|
|
606
|
-
id:
|
|
710
|
+
id: g,
|
|
607
711
|
role: "listbox",
|
|
608
|
-
"aria-label":
|
|
712
|
+
"aria-label": m.palette,
|
|
609
713
|
hidden: S.length === 0,
|
|
610
714
|
children: x.map((e, r) => {
|
|
611
|
-
let i = `${
|
|
715
|
+
let i = `${h}-group-${r}`;
|
|
612
716
|
return /* @__PURE__ */ n("div", {
|
|
613
717
|
role: "group",
|
|
614
718
|
"aria-labelledby": i,
|
|
@@ -625,7 +729,7 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
625
729
|
role: "option",
|
|
626
730
|
"aria-selected": o,
|
|
627
731
|
"aria-disabled": e.disabled === !0 || void 0,
|
|
628
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 :
|
|
732
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : _(a, d),
|
|
629
733
|
className: "pb-palette-option",
|
|
630
734
|
"data-command-id": e.id,
|
|
631
735
|
onMouseDown: (e) => {
|
|
@@ -641,16 +745,16 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
641
745
|
className: "pb-palette-text",
|
|
642
746
|
children: [/* @__PURE__ */ t("span", {
|
|
643
747
|
className: "pb-palette-label",
|
|
644
|
-
children:
|
|
748
|
+
children: $(e.label, r).map((e, n) => e.marked ? /* @__PURE__ */ t("mark", { children: e.text }, n) : e.text)
|
|
645
749
|
}), e.hint !== void 0 && /* @__PURE__ */ t("span", {
|
|
646
750
|
className: "pb-palette-hint",
|
|
647
751
|
children: e.hint
|
|
648
752
|
})]
|
|
649
753
|
}), a.length > 0 && /* @__PURE__ */ t("span", {
|
|
650
754
|
className: "pb-palette-keys",
|
|
651
|
-
children: a.map((e) => /* @__PURE__ */ t("kbd", { children:
|
|
755
|
+
children: a.map((e) => /* @__PURE__ */ t("kbd", { children: v(e, {
|
|
652
756
|
platform: d,
|
|
653
|
-
names:
|
|
757
|
+
names: m.keyNames
|
|
654
758
|
}) }, e))
|
|
655
759
|
})]
|
|
656
760
|
}, e.id);
|
|
@@ -667,21 +771,69 @@ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
|
|
|
667
771
|
})
|
|
668
772
|
});
|
|
669
773
|
}
|
|
670
|
-
function
|
|
671
|
-
return e ? u(/* @__PURE__ */ t(
|
|
774
|
+
function fe({ open: e, ...n }) {
|
|
775
|
+
return e ? u(/* @__PURE__ */ t(de, { ...n }), document.body) : null;
|
|
776
|
+
}
|
|
777
|
+
// src/composites/diagnostic-list/DiagnosticList.tsx
|
|
778
|
+
var pe = {
|
|
779
|
+
diagnostic: B.diagnostic,
|
|
780
|
+
count: (e) => e === 0 ? "No problems" : e === 1 ? "1 problem" : `${String(e)} problems`
|
|
781
|
+
};
|
|
782
|
+
function me(e, { line: t, column: n }) {
|
|
783
|
+
let r = k(e.value, t, n);
|
|
784
|
+
e.focus(), e.setSelectionRange(r, r);
|
|
785
|
+
}
|
|
786
|
+
function he({ diagnostics: e, editor: r, onGo: i, labels: o, className: s, ...c }) {
|
|
787
|
+
let l = {
|
|
788
|
+
...pe,
|
|
789
|
+
...o
|
|
790
|
+
}, u = a();
|
|
791
|
+
return /* @__PURE__ */ n("div", {
|
|
792
|
+
...c,
|
|
793
|
+
className: s === void 0 ? "pb-diagnostic-list" : `pb-diagnostic-list ${s}`,
|
|
794
|
+
"data-empty": e.length === 0 ? "" : void 0,
|
|
795
|
+
children: [/* @__PURE__ */ t("p", {
|
|
796
|
+
className: "pb-diagnostic-count",
|
|
797
|
+
id: u,
|
|
798
|
+
role: "status",
|
|
799
|
+
children: l.count(e.length)
|
|
800
|
+
}), e.length > 0 && /* @__PURE__ */ t("ul", {
|
|
801
|
+
className: "pb-diagnostic-rows",
|
|
802
|
+
"aria-labelledby": u,
|
|
803
|
+
children: e.map((e, a) => /* @__PURE__ */ t("li", {
|
|
804
|
+
className: "pb-diagnostic-row",
|
|
805
|
+
children: /* @__PURE__ */ n("button", {
|
|
806
|
+
type: "button",
|
|
807
|
+
className: "pb-diagnostic-go",
|
|
808
|
+
onClick: () => {
|
|
809
|
+
let t = r?.current;
|
|
810
|
+
t != null && me(t, e), i?.(e);
|
|
811
|
+
},
|
|
812
|
+
children: [/* @__PURE__ */ t("span", {
|
|
813
|
+
className: "pb-diagnostic-mark",
|
|
814
|
+
"data-mark": A(e.severity),
|
|
815
|
+
"aria-hidden": "true"
|
|
816
|
+
}), /* @__PURE__ */ t("span", {
|
|
817
|
+
className: "pb-diagnostic-words",
|
|
818
|
+
children: l.diagnostic(e)
|
|
819
|
+
})]
|
|
820
|
+
})
|
|
821
|
+
}, a))
|
|
822
|
+
})]
|
|
823
|
+
});
|
|
672
824
|
}
|
|
673
825
|
// src/composites/diff-view/DiffView.tsx
|
|
674
|
-
function
|
|
826
|
+
function ge(e) {
|
|
675
827
|
return e.startsWith("+++ ") || e.startsWith("--- ") ? "meta" : e.startsWith("@@") ? "hunk" : e.startsWith("+") ? "add" : e.startsWith("-") ? "del" : e.startsWith("\\") ? "note" : e === "" || e.startsWith(" ") ? "context" : "meta";
|
|
676
828
|
}
|
|
677
|
-
function
|
|
829
|
+
function _e(e) {
|
|
678
830
|
return e.split("/").filter((e) => e !== "").at(-1) ?? e;
|
|
679
831
|
}
|
|
680
|
-
function
|
|
832
|
+
function ve(e) {
|
|
681
833
|
let t = e.split(/\r?\n/);
|
|
682
834
|
return t.length > 0 && t.at(-1) === "" && t.pop(), t;
|
|
683
835
|
}
|
|
684
|
-
function
|
|
836
|
+
function ye({ text: e, id: n, hidden: r }) {
|
|
685
837
|
return /* @__PURE__ */ t("pre", {
|
|
686
838
|
className: "pb-diff-body",
|
|
687
839
|
id: n,
|
|
@@ -689,27 +841,27 @@ function le({ text: e, id: n, hidden: r }) {
|
|
|
689
841
|
tabIndex: 0,
|
|
690
842
|
children: /* @__PURE__ */ t("code", {
|
|
691
843
|
className: "pb-diff-code",
|
|
692
|
-
children:
|
|
844
|
+
children: ve(e).map((e, n) => /* @__PURE__ */ t("span", {
|
|
693
845
|
className: "pb-diff-line",
|
|
694
|
-
"data-kind":
|
|
846
|
+
"data-kind": ge(e),
|
|
695
847
|
children: e === "" ? " " : e
|
|
696
848
|
}, n))
|
|
697
849
|
})
|
|
698
850
|
});
|
|
699
851
|
}
|
|
700
|
-
function
|
|
701
|
-
let d = a(), [f, p] = l([]), m = o ?? f,
|
|
852
|
+
function be({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, className: c, ...u }) {
|
|
853
|
+
let d = a(), [f, p] = l([]), m = o ?? f, g = `h${String(i)}`, _ = (e, t) => {
|
|
702
854
|
o === void 0 && p((n) => t ? n.filter((t) => t !== e) : [...n, e]), s?.(e, t);
|
|
703
855
|
};
|
|
704
856
|
return /* @__PURE__ */ t("div", {
|
|
705
857
|
...u,
|
|
706
858
|
className: c === void 0 ? "pb-diff" : `pb-diff ${c}`,
|
|
707
|
-
children: r === void 0 ? /* @__PURE__ */ t(
|
|
859
|
+
children: r === void 0 ? /* @__PURE__ */ t(ye, { text: e }) : r.map((e, r) => {
|
|
708
860
|
let i = !m.includes(e.path), a = `${d}-${String(r)}`;
|
|
709
861
|
return /* @__PURE__ */ n("div", {
|
|
710
862
|
className: "pb-diff-file",
|
|
711
863
|
"data-open": i || void 0,
|
|
712
|
-
children: [/* @__PURE__ */ t(
|
|
864
|
+
children: [/* @__PURE__ */ t(g, {
|
|
713
865
|
className: "pb-diff-file-title",
|
|
714
866
|
children: /* @__PURE__ */ n("button", {
|
|
715
867
|
type: "button",
|
|
@@ -718,23 +870,14 @@ function ue({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classN
|
|
|
718
870
|
"aria-controls": a,
|
|
719
871
|
title: e.path,
|
|
720
872
|
onClick: () => {
|
|
721
|
-
|
|
873
|
+
_(e.path, !i);
|
|
722
874
|
},
|
|
723
|
-
children: [/* @__PURE__ */ t(
|
|
875
|
+
children: [/* @__PURE__ */ t(h, {
|
|
724
876
|
className: "pb-diff-chevron",
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
height: "10",
|
|
728
|
-
"aria-hidden": "true",
|
|
729
|
-
children: /* @__PURE__ */ t("path", {
|
|
730
|
-
d: "M5 3l5 5-5 5",
|
|
731
|
-
fill: "none",
|
|
732
|
-
stroke: "currentColor",
|
|
733
|
-
strokeWidth: "2"
|
|
734
|
-
})
|
|
735
|
-
}), se(e.path)]
|
|
877
|
+
children: /* @__PURE__ */ t("path", { d: "M6.5 4.5l3.5 3.5-3.5 3.5" })
|
|
878
|
+
}), _e(e.path)]
|
|
736
879
|
})
|
|
737
|
-
}), /* @__PURE__ */ t(
|
|
880
|
+
}), /* @__PURE__ */ t(ye, {
|
|
738
881
|
text: e.diff,
|
|
739
882
|
id: a,
|
|
740
883
|
hidden: !i
|
|
@@ -744,14 +887,14 @@ function ue({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classN
|
|
|
744
887
|
});
|
|
745
888
|
}
|
|
746
889
|
// src/composites/shortcut-sheet/ShortcutSheet.tsx
|
|
747
|
-
var
|
|
890
|
+
var xe = {
|
|
748
891
|
title: "Keyboard shortcuts",
|
|
749
892
|
or: "or",
|
|
750
893
|
empty: "No shortcuts",
|
|
751
894
|
close: "Close",
|
|
752
895
|
keyNames: {}
|
|
753
896
|
};
|
|
754
|
-
function
|
|
897
|
+
function Se(e) {
|
|
755
898
|
let t = /* @__PURE__ */ new Map();
|
|
756
899
|
for (let n of e) {
|
|
757
900
|
let e = t.get(n.group);
|
|
@@ -762,24 +905,24 @@ function fe(e) {
|
|
|
762
905
|
lines: t
|
|
763
906
|
}));
|
|
764
907
|
}
|
|
765
|
-
function
|
|
908
|
+
function Ce({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels: l, className: u }) {
|
|
766
909
|
let d = {
|
|
767
|
-
...
|
|
910
|
+
...xe,
|
|
768
911
|
...l
|
|
769
|
-
},
|
|
770
|
-
return /* @__PURE__ */ n(
|
|
912
|
+
}, f = a(), p = Se(o);
|
|
913
|
+
return /* @__PURE__ */ n(m, {
|
|
771
914
|
open: e,
|
|
772
915
|
onClose: i,
|
|
773
916
|
title: d.title,
|
|
774
917
|
labels: { close: d.close },
|
|
775
918
|
className: u === void 0 ? "pb-shortcut-sheet" : `pb-shortcut-sheet ${u}`,
|
|
776
919
|
children: [
|
|
777
|
-
|
|
920
|
+
p.length === 0 && /* @__PURE__ */ t("p", {
|
|
778
921
|
className: "pb-shortcut-sheet-empty",
|
|
779
922
|
children: d.empty
|
|
780
923
|
}),
|
|
781
|
-
|
|
782
|
-
let o = `${
|
|
924
|
+
p.map(({ group: e, lines: i }, a) => {
|
|
925
|
+
let o = `${f}-${a}`;
|
|
783
926
|
return /* @__PURE__ */ n("section", {
|
|
784
927
|
className: "pb-shortcut-sheet-group",
|
|
785
928
|
"aria-labelledby": o,
|
|
@@ -794,7 +937,7 @@ function pe({ open: e, onClose: i, shortcuts: o, children: s, platform: c, label
|
|
|
794
937
|
return /* @__PURE__ */ n("div", {
|
|
795
938
|
className: "pb-shortcut-sheet-line",
|
|
796
939
|
children: [/* @__PURE__ */ t("dt", { children: e.label }), /* @__PURE__ */ t("dd", {
|
|
797
|
-
"aria-keyshortcuts": a.length === 0 ? void 0 :
|
|
940
|
+
"aria-keyshortcuts": a.length === 0 ? void 0 : _(a, c),
|
|
798
941
|
children: a.map((e, i) => /* @__PURE__ */ n(r, { children: [i > 0 && /* @__PURE__ */ n("span", {
|
|
799
942
|
className: "pb-shortcut-sheet-or",
|
|
800
943
|
children: [
|
|
@@ -802,7 +945,7 @@ function pe({ open: e, onClose: i, shortcuts: o, children: s, platform: c, label
|
|
|
802
945
|
d.or,
|
|
803
946
|
" "
|
|
804
947
|
]
|
|
805
|
-
}), /* @__PURE__ */ t("kbd", { children:
|
|
948
|
+
}), /* @__PURE__ */ t("kbd", { children: v(e, {
|
|
806
949
|
platform: c,
|
|
807
950
|
names: d.keyNames
|
|
808
951
|
}) })] }, e))
|
|
@@ -820,7 +963,7 @@ function pe({ open: e, onClose: i, shortcuts: o, children: s, platform: c, label
|
|
|
820
963
|
});
|
|
821
964
|
}
|
|
822
965
|
// src/composites/status-words/StatusWords.tsx
|
|
823
|
-
function
|
|
966
|
+
function we({ items: e, className: n, ...r }) {
|
|
824
967
|
return /* @__PURE__ */ t("ul", {
|
|
825
968
|
"aria-live": "polite",
|
|
826
969
|
...r,
|
|
@@ -834,12 +977,12 @@ function me({ items: e, className: n, ...r }) {
|
|
|
834
977
|
});
|
|
835
978
|
}
|
|
836
979
|
// src/composites/toaster/Toaster.tsx
|
|
837
|
-
var
|
|
980
|
+
var Te = {
|
|
838
981
|
region: "Notifications",
|
|
839
982
|
dismiss: "Dismiss",
|
|
840
983
|
more: (e) => `and ${e} more`,
|
|
841
984
|
count: (e) => `${e} times`
|
|
842
|
-
},
|
|
985
|
+
}, Ee = /* @__PURE__ */ new Set([
|
|
843
986
|
"top-start",
|
|
844
987
|
"top",
|
|
845
988
|
"top-end",
|
|
@@ -847,18 +990,18 @@ var he = {
|
|
|
847
990
|
"bottom",
|
|
848
991
|
"bottom-end",
|
|
849
992
|
"inline"
|
|
850
|
-
]),
|
|
851
|
-
function
|
|
852
|
-
let
|
|
853
|
-
...
|
|
854
|
-
...
|
|
855
|
-
},
|
|
993
|
+
]), De = 256;
|
|
994
|
+
function Oe({ toasts: r, more: s = 0, onDismiss: u, onHold: d, placement: m = "bottom-end", labels: h, className: _, onPointerEnter: v, onPointerLeave: y, onFocus: b, onBlur: x, ...S }) {
|
|
995
|
+
let C = {
|
|
996
|
+
...Te,
|
|
997
|
+
...h
|
|
998
|
+
}, w = a(), T = Ee.has(m) ? m : "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([]);
|
|
856
999
|
i(() => {
|
|
857
1000
|
let e = [];
|
|
858
1001
|
for (let t of r) {
|
|
859
|
-
let n = t.count ?? 1, r =
|
|
860
|
-
r !== void 0 && n <= r || (
|
|
861
|
-
seq:
|
|
1002
|
+
let n = t.count ?? 1, r = k.current.get(t.id);
|
|
1003
|
+
r !== void 0 && n <= r || (k.current.set(t.id, n), A.current += 1, e.push({
|
|
1004
|
+
seq: A.current,
|
|
862
1005
|
id: t.id,
|
|
863
1006
|
alert: t.tone === "err",
|
|
864
1007
|
text: t.text,
|
|
@@ -866,90 +1009,90 @@ function ve({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "b
|
|
|
866
1009
|
}));
|
|
867
1010
|
}
|
|
868
1011
|
let t = new Set(r.map((e) => e.id));
|
|
869
|
-
if (
|
|
1012
|
+
if (k.current.size > De) for (let e of k.current.keys()) t.has(e) || k.current.delete(e);
|
|
870
1013
|
let n = new Set(e.map((e) => e.id));
|
|
871
|
-
|
|
1014
|
+
M((r) => {
|
|
872
1015
|
let i = r.filter((e) => t.has(e.id) && !n.has(e.id));
|
|
873
1016
|
return e.length === 0 && i.length === r.length ? r : [...i, ...e];
|
|
874
1017
|
});
|
|
875
1018
|
}, [r]);
|
|
876
|
-
let
|
|
1019
|
+
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 && `, ${C.count(e.count)}`] }, e.seq)), F = /* @__PURE__ */ n("div", {
|
|
877
1020
|
className: "pb-toaster-announce",
|
|
878
1021
|
children: [/* @__PURE__ */ t("div", {
|
|
879
1022
|
role: "status",
|
|
880
|
-
children:
|
|
1023
|
+
children: P(!1)
|
|
881
1024
|
}), /* @__PURE__ */ t("div", {
|
|
882
1025
|
role: "alert",
|
|
883
|
-
children:
|
|
1026
|
+
children: P(!0)
|
|
884
1027
|
})]
|
|
885
|
-
}), [
|
|
886
|
-
|
|
887
|
-
let
|
|
1028
|
+
}), [I, L] = l(!1), [R, z] = l(!1);
|
|
1029
|
+
O && (I || R) && (L(!1), z(!1));
|
|
1030
|
+
let B = I || R, V = c(d);
|
|
888
1031
|
o(() => {
|
|
889
|
-
|
|
1032
|
+
V.current = d;
|
|
890
1033
|
}), o(() => {
|
|
891
|
-
|
|
892
|
-
}, [
|
|
893
|
-
|
|
1034
|
+
V.current?.(B);
|
|
1035
|
+
}, [B]), o(() => () => {
|
|
1036
|
+
V.current?.(!1);
|
|
894
1037
|
}, []);
|
|
895
|
-
let
|
|
1038
|
+
let H = c(null), U = c(null), W = c(void 0);
|
|
896
1039
|
o(() => {
|
|
897
|
-
let e =
|
|
1040
|
+
let e = W.current;
|
|
898
1041
|
if (e === void 0) return;
|
|
899
|
-
|
|
900
|
-
let t = (e === null ? null :
|
|
1042
|
+
W.current = void 0;
|
|
1043
|
+
let t = (e === null ? null : H.current?.querySelector(`[data-toast-id="${e}"]`)) ?? H.current?.querySelector(".pb-toast");
|
|
901
1044
|
if (t != null) {
|
|
902
1045
|
t.focus();
|
|
903
1046
|
return;
|
|
904
1047
|
}
|
|
905
|
-
let n =
|
|
906
|
-
|
|
1048
|
+
let n = U.current;
|
|
1049
|
+
U.current = null, n?.isConnected === !0 && n.focus();
|
|
907
1050
|
});
|
|
908
|
-
let
|
|
909
|
-
if (
|
|
910
|
-
let t =
|
|
911
|
-
|
|
1051
|
+
let G = (e) => {
|
|
1052
|
+
if (H.current?.contains(document.activeElement) === !0) {
|
|
1053
|
+
let t = D.findIndex((t) => t.id === e);
|
|
1054
|
+
W.current = (D[t + 1] ?? D[t - 1])?.id ?? null;
|
|
912
1055
|
}
|
|
913
1056
|
u(e);
|
|
914
1057
|
};
|
|
915
|
-
if (
|
|
916
|
-
let
|
|
1058
|
+
if (O) return F;
|
|
1059
|
+
let K = s > 0 && /* @__PURE__ */ t("p", {
|
|
917
1060
|
className: "pb-toaster-more",
|
|
918
|
-
children:
|
|
1061
|
+
children: C.more(s)
|
|
919
1062
|
});
|
|
920
|
-
return /* @__PURE__ */ n(e, { children: [
|
|
921
|
-
...
|
|
922
|
-
"aria-label":
|
|
923
|
-
className:
|
|
924
|
-
"data-placement":
|
|
1063
|
+
return /* @__PURE__ */ n(e, { children: [F, /* @__PURE__ */ n("section", {
|
|
1064
|
+
...S,
|
|
1065
|
+
"aria-label": S["aria-label"] ?? C.region,
|
|
1066
|
+
className: _ === void 0 ? "pb-toaster" : `pb-toaster ${_}`,
|
|
1067
|
+
"data-placement": T,
|
|
925
1068
|
onPointerEnter: (e) => {
|
|
926
|
-
|
|
1069
|
+
v?.(e), e.pointerType !== "touch" && L(!0);
|
|
927
1070
|
},
|
|
928
1071
|
onPointerLeave: (e) => {
|
|
929
|
-
|
|
1072
|
+
y?.(e), L(!1);
|
|
930
1073
|
},
|
|
931
1074
|
onFocus: (e) => {
|
|
932
|
-
|
|
1075
|
+
b?.(e);
|
|
933
1076
|
let t = e.relatedTarget;
|
|
934
|
-
!
|
|
1077
|
+
!R && t instanceof HTMLElement && !e.currentTarget.contains(t) && (U.current = t), z(!0);
|
|
935
1078
|
},
|
|
936
1079
|
onBlur: (e) => {
|
|
937
|
-
|
|
1080
|
+
x?.(e), e.currentTarget.contains(e.relatedTarget) || z(!1);
|
|
938
1081
|
},
|
|
939
1082
|
children: [
|
|
940
|
-
!
|
|
1083
|
+
!E && K,
|
|
941
1084
|
/* @__PURE__ */ t("ol", {
|
|
942
1085
|
className: "pb-toaster-list",
|
|
943
|
-
ref:
|
|
944
|
-
children:
|
|
945
|
-
let r = `${
|
|
1086
|
+
ref: H,
|
|
1087
|
+
children: D.map((e) => {
|
|
1088
|
+
let r = `${w}-${e.id}`, i = e.count ?? 1;
|
|
946
1089
|
return /* @__PURE__ */ n("li", {
|
|
947
1090
|
className: "pb-toast",
|
|
948
1091
|
"data-tone": e.tone,
|
|
949
1092
|
"data-toast-id": e.id,
|
|
950
1093
|
tabIndex: -1,
|
|
951
1094
|
onKeyDown: (t) => {
|
|
952
|
-
t.key !== "Escape" || t.defaultPrevented || (t.preventDefault(), t.stopPropagation(),
|
|
1095
|
+
t.key !== "Escape" || t.defaultPrevented || t.nativeEvent.isComposing || (t.preventDefault(), t.stopPropagation(), G(e.id));
|
|
953
1096
|
},
|
|
954
1097
|
children: [/* @__PURE__ */ n("div", {
|
|
955
1098
|
className: "pb-toast-text",
|
|
@@ -961,33 +1104,35 @@ function ve({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "b
|
|
|
961
1104
|
children: [" ×", i]
|
|
962
1105
|
}), /* @__PURE__ */ n("span", {
|
|
963
1106
|
className: "pb-toast-hidden",
|
|
964
|
-
children: [", ",
|
|
1107
|
+
children: [", ", C.count(i)]
|
|
965
1108
|
})]
|
|
966
1109
|
})]
|
|
967
1110
|
}), /* @__PURE__ */ n("div", {
|
|
968
1111
|
className: "pb-toast-actions",
|
|
969
|
-
children: [e.action !== void 0 && /* @__PURE__ */ t(
|
|
1112
|
+
children: [e.action !== void 0 && /* @__PURE__ */ t(f, {
|
|
970
1113
|
size: "sm",
|
|
971
1114
|
onClick: () => {
|
|
972
|
-
e.action?.run(),
|
|
1115
|
+
e.action?.run(), G(e.id);
|
|
973
1116
|
},
|
|
974
1117
|
children: e.action.label
|
|
975
|
-
}), /* @__PURE__ */ t(
|
|
1118
|
+
}), /* @__PURE__ */ t(g, {
|
|
1119
|
+
className: "pb-toast-dismiss",
|
|
976
1120
|
size: "sm",
|
|
1121
|
+
label: C.dismiss,
|
|
977
1122
|
"aria-describedby": r,
|
|
978
1123
|
onClick: () => {
|
|
979
|
-
|
|
1124
|
+
G(e.id);
|
|
980
1125
|
},
|
|
981
|
-
children:
|
|
1126
|
+
children: /* @__PURE__ */ t(p, {})
|
|
982
1127
|
})]
|
|
983
1128
|
})]
|
|
984
1129
|
}, e.id);
|
|
985
1130
|
})
|
|
986
1131
|
}),
|
|
987
|
-
|
|
1132
|
+
E && K
|
|
988
1133
|
]
|
|
989
1134
|
})] });
|
|
990
1135
|
}
|
|
991
|
-
export {
|
|
1136
|
+
export { b as Banner, w as ChangeList, G as CodeEditor, K as CodeText, fe as CommandPalette, he as DiagnosticList, be as DiffView, se as PALETTE_GUTTER, oe as PALETTE_HEIGHT, ae as PALETTE_WIDTH, Ce as ShortcutSheet, we as StatusWords, Oe as Toaster, O as caretAt, P as codeRuns, y as defaultBannerLabels, x as defaultChangeListLabels, B as defaultCodeEditorLabels, ie as defaultCommandPaletteLabels, pe as defaultDiagnosticListLabels, xe as defaultShortcutSheetLabels, Te as defaultToasterLabels, Se as groupShortcuts, F as gutterRows, R as loadKnobly, A as markLevel, $ as markRuns, Z as matchSubsequence, k as offsetAt, ce as placePalette, Q as rankCommands, E as shownText, U as tabEdit };
|
|
992
1137
|
|
|
993
1138
|
//# sourceMappingURL=composites.js.map
|