@hankchen/canvas-editor-vue 0.2.0 → 0.4.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/dist/canvas/CanvasSurface.d.ts +28 -1
- package/dist/canvas/{ContentTypePill.d.ts → EditOverlayToolbar.d.ts} +19 -0
- package/dist/canvas/TextEditingOverlay.d.ts +31 -3
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/useTextEditing.d.ts +30 -8
- package/dist/{canvas-C70NSsoF.js → canvas-DqQislJ_.js} +813 -434
- package/dist/canvas.js +2 -2
- package/dist/index.js +15 -14
- package/dist/{layer-panel-BEcT9HhJ.js → layer-panel-DskyCgF5.js} +10 -10
- package/dist/layer-panel.js +1 -1
- package/dist/panel-theme.css +24 -0
- package/dist/popupPosition-Ck5Gsvjy.js +526 -0
- package/dist/property-panel/PropertyField.d.ts +6 -0
- package/dist/property-panel/fieldSchema.d.ts +7 -1
- package/dist/property-panel/fields/ImageSrcField.d.ts +5 -1
- package/dist/property-panel/fields/ResourceValueField.d.ts +19 -0
- package/dist/property-panel/fields/TextareaField.d.ts +1 -0
- package/dist/property-panel/fields/ValueTypeSegmented.d.ts +3 -1
- package/dist/property-panel/index.d.ts +5 -3
- package/dist/property-panel/usePropertyPanel.d.ts +16 -4
- package/dist/{property-panel-C2etsIhF.js → property-panel-B32ZBQdf.js} +472 -376
- package/dist/property-panel.js +3 -2
- package/dist/resourceTemplate-cdcQtp9a.js +246 -0
- package/dist/shared/ExpressionPathPicker.d.ts +25 -0
- package/dist/shared/completion.d.ts +40 -16
- package/dist/shared/expressionContext.d.ts +2 -2
- package/dist/shared/index.d.ts +14 -1
- package/dist/shared/mergeKey.d.ts +2 -0
- package/dist/shared/pathPickerModel.d.ts +11 -0
- package/dist/shared/popupPosition.d.ts +41 -0
- package/dist/shared/resourceTemplate.d.ts +7 -0
- package/dist/shared/useExpressionCompletion.d.ts +0 -7
- package/dist/shared/useExpressionDiagnostics.d.ts +15 -0
- package/dist/shared.js +10 -9
- package/dist/style.css +1 -1
- package/dist/uploadFile-D1RY-ji0.js +516 -0
- package/dist/usePathCompletion-Do17CQ6l.js +220 -0
- package/package.json +2 -2
- package/dist/completionAnchor-CDR5YZhu.js +0 -273
- package/dist/uploadFile-BOfv8aLG.js +0 -331
- package/dist/usePathCompletion-uJ5c_gQ0.js +0 -229
- /package/dist/{property-panel → shared}/fontPicker.d.ts +0 -0
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { a as e, r as t } from "./layerPath-uy2ywyld.js";
|
|
2
|
-
import { a as n, c as r, l as i, n as a, o, s, t as c, u as l } from "./completionAnchor-CDR5YZhu.js";
|
|
3
|
-
import { nextTick as u, onMounted as d, onScopeDispose as f, reactive as p, toValue as m, watch as h } from "vue";
|
|
4
|
-
//#region ../canvas-editor/src/shared/expressionCandidates.ts
|
|
5
|
-
function g(e) {
|
|
6
|
-
return e.kind === "row" ? "row" : e.kind === "root" ? "$root" : e.name;
|
|
7
|
-
}
|
|
8
|
-
function _(e) {
|
|
9
|
-
let t = {};
|
|
10
|
-
return e.description !== void 0 && (t.description = e.description), e.title !== void 0 && (t.title = e.title), e.type !== void 0 && (t.type = e.type), t;
|
|
11
|
-
}
|
|
12
|
-
function v(e, t) {
|
|
13
|
-
return {
|
|
14
|
-
path: t === "" ? e.key : `${t}.${e.key}`,
|
|
15
|
-
segment: e.key,
|
|
16
|
-
..._(e.node)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function y(e, t, n) {
|
|
20
|
-
let r = i(e), a = r.entries.map((e) => v(e, ""));
|
|
21
|
-
return a.push({
|
|
22
|
-
path: "$root",
|
|
23
|
-
segment: "$root"
|
|
24
|
-
}), t === "row" && (a.push(n ? {
|
|
25
|
-
path: "row",
|
|
26
|
-
segment: "row",
|
|
27
|
-
..._(n)
|
|
28
|
-
} : {
|
|
29
|
-
path: "row",
|
|
30
|
-
segment: "row"
|
|
31
|
-
}), a.push({
|
|
32
|
-
path: "$index",
|
|
33
|
-
segment: "$index"
|
|
34
|
-
})), r.open === !0 ? {
|
|
35
|
-
candidates: a,
|
|
36
|
-
open: !0
|
|
37
|
-
} : { candidates: a };
|
|
38
|
-
}
|
|
39
|
-
function b(e, t) {
|
|
40
|
-
if (e === null) return {
|
|
41
|
-
ok: !0,
|
|
42
|
-
prefix: "",
|
|
43
|
-
partial: "",
|
|
44
|
-
candidates: []
|
|
45
|
-
};
|
|
46
|
-
let n = t.expr.endsWith("."), r = n ? t.expr.slice(0, -1) : t.expr;
|
|
47
|
-
if (r === "") return t.expr === "" ? {
|
|
48
|
-
ok: !0,
|
|
49
|
-
prefix: "",
|
|
50
|
-
partial: "",
|
|
51
|
-
...y(e, t.context, t.rowSchema)
|
|
52
|
-
} : {
|
|
53
|
-
ok: !1,
|
|
54
|
-
reason: "expression_syntax_error"
|
|
55
|
-
};
|
|
56
|
-
let a = s(r);
|
|
57
|
-
if (!a.ok) return {
|
|
58
|
-
ok: !1,
|
|
59
|
-
reason: "expression_syntax_error"
|
|
60
|
-
};
|
|
61
|
-
let { head: o, rest: c } = a, u, d;
|
|
62
|
-
if (n ? (u = [g(o), ...c], d = "") : c.length > 0 ? (u = [g(o), ...c.slice(0, -1)], d = c[c.length - 1]) : (u = [], d = g(o)), u.length === 0) return {
|
|
63
|
-
ok: !0,
|
|
64
|
-
prefix: "",
|
|
65
|
-
partial: d,
|
|
66
|
-
...y(e, t.context, t.rowSchema)
|
|
67
|
-
};
|
|
68
|
-
let f, p;
|
|
69
|
-
if (o.kind === "row") {
|
|
70
|
-
if (t.context !== "row") return {
|
|
71
|
-
ok: !0,
|
|
72
|
-
prefix: u.join("."),
|
|
73
|
-
partial: d,
|
|
74
|
-
candidates: []
|
|
75
|
-
};
|
|
76
|
-
f = t.rowSchema ?? null, p = u.slice(1);
|
|
77
|
-
} else if (o.kind === "root") f = e, p = u.slice(1);
|
|
78
|
-
else if (o.name === "$index") return {
|
|
79
|
-
ok: !0,
|
|
80
|
-
prefix: u.join("."),
|
|
81
|
-
partial: d,
|
|
82
|
-
candidates: []
|
|
83
|
-
};
|
|
84
|
-
else f = e, p = u;
|
|
85
|
-
let m = f === null ? null : l(f, p), h = u.join(".");
|
|
86
|
-
if (m === null) return {
|
|
87
|
-
ok: !0,
|
|
88
|
-
prefix: h,
|
|
89
|
-
partial: d,
|
|
90
|
-
candidates: []
|
|
91
|
-
};
|
|
92
|
-
let _ = i(m);
|
|
93
|
-
return {
|
|
94
|
-
ok: !0,
|
|
95
|
-
prefix: h,
|
|
96
|
-
partial: d,
|
|
97
|
-
candidates: _.entries.map((e) => v(e, h)),
|
|
98
|
-
..._.open === !0 ? { open: !0 } : {}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/shared/expressionContext.ts
|
|
103
|
-
function x(t, n, i) {
|
|
104
|
-
let a = null;
|
|
105
|
-
for (let o = 0; o < n.length; o += 1) {
|
|
106
|
-
if (n[o] !== "template") continue;
|
|
107
|
-
let s = e(t, n.slice(0, o));
|
|
108
|
-
if (s === null || s.type !== "TableLayer" || (a = r(a ?? i, s.rowsPath), a === null)) return null;
|
|
109
|
-
}
|
|
110
|
-
return a;
|
|
111
|
-
}
|
|
112
|
-
function S(e) {
|
|
113
|
-
return e[e.length - 1] === "content" && t(e);
|
|
114
|
-
}
|
|
115
|
-
function C(e, t, n) {
|
|
116
|
-
return e === null || t === null || n === null || !S(n) ? {
|
|
117
|
-
kind: "root",
|
|
118
|
-
rowSchema: null
|
|
119
|
-
} : {
|
|
120
|
-
kind: "row",
|
|
121
|
-
rowSchema: x(t, n, e)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function w(e, t) {
|
|
125
|
-
return e === null ? null : (n) => {
|
|
126
|
-
let r = b(e, {
|
|
127
|
-
context: t.kind,
|
|
128
|
-
expr: n,
|
|
129
|
-
rowSchema: t.rowSchema
|
|
130
|
-
});
|
|
131
|
-
return r.ok ? {
|
|
132
|
-
partial: r.partial,
|
|
133
|
-
candidates: r.candidates,
|
|
134
|
-
...r.open === !0 ? { open: !0 } : {}
|
|
135
|
-
} : null;
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/shared/useExpressionCompletion.ts
|
|
140
|
-
var T = 4, E = [
|
|
141
|
-
"ArrowLeft",
|
|
142
|
-
"ArrowRight",
|
|
143
|
-
"Home",
|
|
144
|
-
"End",
|
|
145
|
-
"PageUp",
|
|
146
|
-
"PageDown"
|
|
147
|
-
];
|
|
148
|
-
function D(e) {
|
|
149
|
-
let t = p({
|
|
150
|
-
open: !1,
|
|
151
|
-
items: [],
|
|
152
|
-
activeIndex: 0,
|
|
153
|
-
top: 0,
|
|
154
|
-
left: 0,
|
|
155
|
-
openMapping: !1
|
|
156
|
-
}), r = null, i = !1, s = null;
|
|
157
|
-
function l() {
|
|
158
|
-
t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, s = null;
|
|
159
|
-
}
|
|
160
|
-
function g() {
|
|
161
|
-
if (!t.open || !r) return;
|
|
162
|
-
let n = c(r, m(e.scale ?? 1));
|
|
163
|
-
t.top = n.bottom + T, t.left = _(n.left);
|
|
164
|
-
}
|
|
165
|
-
function _(t) {
|
|
166
|
-
let n = (e.popupEl ? m(e.popupEl) : null)?.offsetWidth ?? 0;
|
|
167
|
-
return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - 4 - n));
|
|
168
|
-
}
|
|
169
|
-
function v(i, a = !1) {
|
|
170
|
-
if (!m(e.enabled)) {
|
|
171
|
-
l();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let c = r;
|
|
175
|
-
if (!c) {
|
|
176
|
-
l();
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
let d = c.value, f = c.selectionStart ?? d.length, p = n(o(d), f);
|
|
180
|
-
if (!p) {
|
|
181
|
-
l();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let h = e.resolve(p.expr);
|
|
185
|
-
if (!h) {
|
|
186
|
-
l();
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
let _ = a ? h.candidates : h.candidates.filter((e) => e.segment.startsWith(h.partial));
|
|
190
|
-
if (_.length === 0 && h.open !== !0) {
|
|
191
|
-
l();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
s = {
|
|
195
|
-
fragment: p,
|
|
196
|
-
partial: h.partial
|
|
197
|
-
}, (t.open || i) && (t.items = _, t.activeIndex = 0, t.openMapping = h.open === !0, t.open = !0, g(), u(g));
|
|
198
|
-
}
|
|
199
|
-
function y(e) {
|
|
200
|
-
let n = r;
|
|
201
|
-
if (!t.open || i || !n || !s) return;
|
|
202
|
-
let o = t.items[e ?? t.activeIndex];
|
|
203
|
-
if (!o) return;
|
|
204
|
-
let c = a(n.value, s.fragment, s.partial, o.segment);
|
|
205
|
-
if (!c) {
|
|
206
|
-
l();
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
n.value = c.value, n.setSelectionRange(c.cursor, c.cursor), n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), l();
|
|
210
|
-
}
|
|
211
|
-
function b() {
|
|
212
|
-
return m(e.pairing ?? e.enabled);
|
|
213
|
-
}
|
|
214
|
-
function x(e) {
|
|
215
|
-
let t = e.selectionStart;
|
|
216
|
-
return t === null || t !== e.selectionEnd ? null : t;
|
|
217
|
-
}
|
|
218
|
-
let S = !1;
|
|
219
|
-
function C(e) {
|
|
220
|
-
if (S || !b()) return;
|
|
221
|
-
let t = r;
|
|
222
|
-
if (!t) return;
|
|
223
|
-
let n = e.inputType;
|
|
224
|
-
if (n !== void 0 && n !== "" && n !== "insertText") return;
|
|
225
|
-
let i = x(t);
|
|
226
|
-
if (i === null || i < 2) return;
|
|
227
|
-
let a = t.value;
|
|
228
|
-
a.startsWith("{{", i - 2) && (a.includes("}}", i) || (S = !0, t.value = `${a.slice(0, i)}}}${a.slice(i)}`, t.setSelectionRange(i, i), t.dispatchEvent(new Event("input", { bubbles: !0 })), S = !1));
|
|
229
|
-
}
|
|
230
|
-
function w(e) {
|
|
231
|
-
if (!b()) return !1;
|
|
232
|
-
let t = r;
|
|
233
|
-
if (!t) return !1;
|
|
234
|
-
let n = x(t);
|
|
235
|
-
if (n === null || n < 2) return !1;
|
|
236
|
-
let i = t.value;
|
|
237
|
-
return !i.startsWith("{{", n - 2) || !i.startsWith("}}", n) ? !1 : (e.preventDefault(), S = !0, t.value = i.slice(0, n - 2) + i.slice(n + 2), t.setSelectionRange(n - 2, n - 2), t.dispatchEvent(new Event("input", { bubbles: !0 })), S = !1, !0);
|
|
238
|
-
}
|
|
239
|
-
function D(e) {
|
|
240
|
-
if (!b()) return !1;
|
|
241
|
-
let t = r;
|
|
242
|
-
if (!t) return !1;
|
|
243
|
-
let n = x(t);
|
|
244
|
-
return n === null || t.value[n] !== "}" ? !1 : (e.preventDefault(), t.setSelectionRange(n + 1, n + 1), v(!1), !0);
|
|
245
|
-
}
|
|
246
|
-
function O(e) {
|
|
247
|
-
i || e.isComposing || (C(e), v(!0));
|
|
248
|
-
}
|
|
249
|
-
function k() {
|
|
250
|
-
i = !0;
|
|
251
|
-
}
|
|
252
|
-
function A() {
|
|
253
|
-
i = !1, v(!0);
|
|
254
|
-
}
|
|
255
|
-
function j(e) {
|
|
256
|
-
return i || e.isComposing || e.keyCode === 229;
|
|
257
|
-
}
|
|
258
|
-
function M(e) {
|
|
259
|
-
if (!j(e)) {
|
|
260
|
-
if (e.key === " " && (e.ctrlKey || e.metaKey)) {
|
|
261
|
-
e.preventDefault(), v(!0, !0);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (!(e.key === "Backspace" && w(e)) && !(e.key === "}" && D(e)) && t.open) {
|
|
265
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
266
|
-
e.preventDefault();
|
|
267
|
-
let n = t.items.length;
|
|
268
|
-
n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (e.key === "Enter" || e.key === "Tab") {
|
|
272
|
-
e.preventDefault(), y();
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
e.key === "Escape" && (e.preventDefault(), l());
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function N(e) {
|
|
280
|
-
t.open && !j(e) && E.includes(e.key) && v(!1);
|
|
281
|
-
}
|
|
282
|
-
function P() {
|
|
283
|
-
i || v(!1);
|
|
284
|
-
}
|
|
285
|
-
function F() {
|
|
286
|
-
l();
|
|
287
|
-
}
|
|
288
|
-
function I(e) {
|
|
289
|
-
t.open && e.target !== r && l();
|
|
290
|
-
}
|
|
291
|
-
function L() {
|
|
292
|
-
g();
|
|
293
|
-
}
|
|
294
|
-
let R = [
|
|
295
|
-
["input", O],
|
|
296
|
-
["keydown", M],
|
|
297
|
-
["keyup", N],
|
|
298
|
-
["click", P],
|
|
299
|
-
["blur", F],
|
|
300
|
-
["compositionstart", k],
|
|
301
|
-
["compositionend", A]
|
|
302
|
-
];
|
|
303
|
-
function z(e) {
|
|
304
|
-
for (let [t, n] of R) e.addEventListener(t, n);
|
|
305
|
-
}
|
|
306
|
-
function B(e) {
|
|
307
|
-
for (let [t, n] of R) e.removeEventListener(t, n);
|
|
308
|
-
}
|
|
309
|
-
function V(e) {
|
|
310
|
-
r !== e && (r && B(r), r = e, e && z(e));
|
|
311
|
-
}
|
|
312
|
-
return d(() => V(e.target.value)), h(e.target, (e) => V(e)), h(() => m(e.enabled), (e) => {
|
|
313
|
-
e || l();
|
|
314
|
-
}), document.addEventListener("mousedown", I), window.addEventListener("scroll", L, !0), window.addEventListener("resize", L), f(() => {
|
|
315
|
-
r && B(r), document.removeEventListener("mousedown", I), window.removeEventListener("scroll", L, !0), window.removeEventListener("resize", L);
|
|
316
|
-
}), {
|
|
317
|
-
popup: t,
|
|
318
|
-
accept: y
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region src/shared/uploadFile.ts
|
|
323
|
-
async function O(e) {
|
|
324
|
-
return {
|
|
325
|
-
name: e.name,
|
|
326
|
-
mime: e.type,
|
|
327
|
-
bytes: new Uint8Array(await e.arrayBuffer())
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
//#endregion
|
|
331
|
-
export { C as i, D as n, w as r, O as t };
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { a as e } from "./layerPath-uy2ywyld.js";
|
|
2
|
-
import { c as t, n, t as r, u as i } from "./completionAnchor-CDR5YZhu.js";
|
|
3
|
-
import { nextTick as a, onMounted as o, onScopeDispose as s, reactive as c, toValue as l, watch as u } from "vue";
|
|
4
|
-
//#region ../canvas-editor/src/shared/rowsPathCandidates.ts
|
|
5
|
-
function d(e) {
|
|
6
|
-
return e.type === "array" || e.items !== void 0;
|
|
7
|
-
}
|
|
8
|
-
function f(e) {
|
|
9
|
-
return !d(e) && e.properties === void 0 && e.open !== !0;
|
|
10
|
-
}
|
|
11
|
-
function p(e, t, n) {
|
|
12
|
-
let r = {
|
|
13
|
-
path: n === "" ? e : `${n}.${e}`,
|
|
14
|
-
segment: e
|
|
15
|
-
};
|
|
16
|
-
return t.description !== void 0 && (r.description = t.description), t.title !== void 0 && (r.title = t.title), d(t) && (r.type = "array"), r;
|
|
17
|
-
}
|
|
18
|
-
function m(e, t) {
|
|
19
|
-
let n = [];
|
|
20
|
-
if (e.properties !== void 0) for (let [r, i] of e.properties) f(i) || n.push(p(r, i, t));
|
|
21
|
-
return e.open === !0 ? {
|
|
22
|
-
candidates: n,
|
|
23
|
-
open: !0
|
|
24
|
-
} : { candidates: n };
|
|
25
|
-
}
|
|
26
|
-
function h(e, t) {
|
|
27
|
-
if (e === null) return null;
|
|
28
|
-
let n = t.split("."), r = t.endsWith(".") ? "" : n[n.length - 1], a = n.slice(0, -1), o = e;
|
|
29
|
-
for (let e of a) {
|
|
30
|
-
if (d(o)) return null;
|
|
31
|
-
let t = i(o, [e]);
|
|
32
|
-
if (t === null) return null;
|
|
33
|
-
o = t;
|
|
34
|
-
}
|
|
35
|
-
if (d(o) || f(o)) return null;
|
|
36
|
-
let s = m(o, a.join("."));
|
|
37
|
-
return {
|
|
38
|
-
partial: r,
|
|
39
|
-
candidates: s.candidates,
|
|
40
|
-
...s.open === !0 ? { open: !0 } : {}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function g(n, r, i) {
|
|
44
|
-
if (i === null) return null;
|
|
45
|
-
if (n === null || r === null) return i;
|
|
46
|
-
let a = null;
|
|
47
|
-
for (let o = 0; o < r.length; o += 1) {
|
|
48
|
-
if (r[o] !== "template") continue;
|
|
49
|
-
let s = e(n, r.slice(0, o));
|
|
50
|
-
if (s === null || s.type !== "TableLayer" || (a = t(a ?? i, s.rowsPath), a === null)) return null;
|
|
51
|
-
}
|
|
52
|
-
return a ?? i;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/shared/rowsPathCompletionSource.ts
|
|
56
|
-
function _(e) {
|
|
57
|
-
return e === null ? null : (t) => {
|
|
58
|
-
let n = h(e, t);
|
|
59
|
-
return n === null ? null : {
|
|
60
|
-
partial: n.partial,
|
|
61
|
-
candidates: n.candidates.map((e) => e.type === "array" ? {
|
|
62
|
-
...e,
|
|
63
|
-
type: "行数组"
|
|
64
|
-
} : e),
|
|
65
|
-
...n.open === !0 ? { open: !0 } : {}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/shared/usePathCompletion.ts
|
|
71
|
-
var v = 4, y = 4, b = [
|
|
72
|
-
"ArrowLeft",
|
|
73
|
-
"ArrowRight",
|
|
74
|
-
"Home",
|
|
75
|
-
"End",
|
|
76
|
-
"PageUp",
|
|
77
|
-
"PageDown"
|
|
78
|
-
];
|
|
79
|
-
function x(e) {
|
|
80
|
-
return {
|
|
81
|
-
kind: "fragment",
|
|
82
|
-
start: -2,
|
|
83
|
-
end: e.length + 2,
|
|
84
|
-
raw: "",
|
|
85
|
-
expr: e,
|
|
86
|
-
error: null
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function S(e) {
|
|
90
|
-
let t = c({
|
|
91
|
-
open: !1,
|
|
92
|
-
items: [],
|
|
93
|
-
activeIndex: 0,
|
|
94
|
-
top: 0,
|
|
95
|
-
left: 0,
|
|
96
|
-
openMapping: !1
|
|
97
|
-
}), i = null, d = !1, f = "";
|
|
98
|
-
function p() {
|
|
99
|
-
t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, f = "";
|
|
100
|
-
}
|
|
101
|
-
function m() {
|
|
102
|
-
if (!t.open || !i) return;
|
|
103
|
-
let e = r(i);
|
|
104
|
-
t.top = e.bottom + v, t.left = h(e.left);
|
|
105
|
-
}
|
|
106
|
-
function h(t) {
|
|
107
|
-
let n = (e.popupEl ? l(e.popupEl) : null)?.offsetWidth ?? 0;
|
|
108
|
-
return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - y - n));
|
|
109
|
-
}
|
|
110
|
-
function g(n, r = !1) {
|
|
111
|
-
if (!l(e.enabled)) {
|
|
112
|
-
p();
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
let o = i;
|
|
116
|
-
if (!o) {
|
|
117
|
-
p();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
let s = o.value.slice(0, o.selectionStart ?? o.value.length);
|
|
121
|
-
if (s === "" && !r) {
|
|
122
|
-
p();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
let c = e.resolve(s);
|
|
126
|
-
if (!c) {
|
|
127
|
-
p();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
let u = r ? c.candidates : c.candidates.filter((e) => e.segment.startsWith(c.partial));
|
|
131
|
-
if (u.length === 0 && c.open !== !0) {
|
|
132
|
-
p();
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
f = c.partial, (t.open || n) && (t.items = u, t.activeIndex = 0, t.openMapping = c.open === !0, t.open = !0, m(), a(m));
|
|
136
|
-
}
|
|
137
|
-
function _(e) {
|
|
138
|
-
let r = i;
|
|
139
|
-
if (!t.open || d || !r) return;
|
|
140
|
-
let a = t.items[e ?? t.activeIndex];
|
|
141
|
-
if (!a) return;
|
|
142
|
-
let o = r.value.slice(0, r.selectionStart ?? r.value.length), s = n(r.value, x(o), f, a.segment);
|
|
143
|
-
if (!s) {
|
|
144
|
-
p();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
r.value = s.value, r.setSelectionRange(s.cursor, s.cursor), r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })), p();
|
|
148
|
-
}
|
|
149
|
-
function S(e) {
|
|
150
|
-
d || e.isComposing || g(!0);
|
|
151
|
-
}
|
|
152
|
-
function C() {
|
|
153
|
-
d = !0;
|
|
154
|
-
}
|
|
155
|
-
function w() {
|
|
156
|
-
d = !1, g(!0);
|
|
157
|
-
}
|
|
158
|
-
function T(e) {
|
|
159
|
-
return d || e.isComposing || e.keyCode === 229;
|
|
160
|
-
}
|
|
161
|
-
function E(e) {
|
|
162
|
-
if (!T(e)) {
|
|
163
|
-
if (e.key === " " && (e.ctrlKey || e.metaKey)) {
|
|
164
|
-
e.preventDefault(), g(!0, !0);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (t.open) {
|
|
168
|
-
if (t.items.length === 0) {
|
|
169
|
-
e.key === "Escape" && (e.preventDefault(), p());
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
173
|
-
e.preventDefault();
|
|
174
|
-
let n = t.items.length;
|
|
175
|
-
n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (e.key === "Enter" || e.key === "Tab") {
|
|
179
|
-
e.preventDefault(), _();
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
e.key === "Escape" && (e.preventDefault(), p());
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function D(e) {
|
|
187
|
-
t.open && !T(e) && b.includes(e.key) && g(!1);
|
|
188
|
-
}
|
|
189
|
-
function O() {
|
|
190
|
-
d || g(!1);
|
|
191
|
-
}
|
|
192
|
-
function k() {
|
|
193
|
-
p();
|
|
194
|
-
}
|
|
195
|
-
function A(e) {
|
|
196
|
-
t.open && e.target !== i && p();
|
|
197
|
-
}
|
|
198
|
-
function j() {
|
|
199
|
-
m();
|
|
200
|
-
}
|
|
201
|
-
let M = [
|
|
202
|
-
["input", S],
|
|
203
|
-
["keydown", E],
|
|
204
|
-
["keyup", D],
|
|
205
|
-
["click", O],
|
|
206
|
-
["blur", k],
|
|
207
|
-
["compositionstart", C],
|
|
208
|
-
["compositionend", w]
|
|
209
|
-
];
|
|
210
|
-
function N(e) {
|
|
211
|
-
for (let [t, n] of M) e.addEventListener(t, n);
|
|
212
|
-
}
|
|
213
|
-
function P(e) {
|
|
214
|
-
for (let [t, n] of M) e.removeEventListener(t, n);
|
|
215
|
-
}
|
|
216
|
-
function F(e) {
|
|
217
|
-
i !== e && (i && P(i), i = e, e && N(e));
|
|
218
|
-
}
|
|
219
|
-
return o(() => F(e.target.value)), u(e.target, (e) => F(e)), u(() => l(e.enabled), (e) => {
|
|
220
|
-
e || p();
|
|
221
|
-
}), document.addEventListener("mousedown", A), window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), s(() => {
|
|
222
|
-
i && P(i), document.removeEventListener("mousedown", A), window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
223
|
-
}), {
|
|
224
|
-
popup: t,
|
|
225
|
-
accept: _
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
//#endregion
|
|
229
|
-
export { _ as n, g as r, S as t };
|
|
File without changes
|