@hankchen/canvas-editor-vue 0.3.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.
Files changed (41) hide show
  1. package/dist/canvas/CanvasSurface.d.ts +28 -1
  2. package/dist/canvas/{ContentTypePill.d.ts → EditOverlayToolbar.d.ts} +19 -0
  3. package/dist/canvas/TextEditingOverlay.d.ts +31 -3
  4. package/dist/canvas/index.d.ts +1 -1
  5. package/dist/canvas/useTextEditing.d.ts +30 -8
  6. package/dist/{canvas-ZMyaouKe.js → canvas-DqQislJ_.js} +813 -434
  7. package/dist/canvas.js +2 -2
  8. package/dist/index.js +15 -14
  9. package/dist/{layer-panel-CEyB57XM.js → layer-panel-DskyCgF5.js} +7 -7
  10. package/dist/layer-panel.js +1 -1
  11. package/dist/panel-theme.css +24 -0
  12. package/dist/{completionAnchor-Da8VhzMQ.js → popupPosition-Ck5Gsvjy.js} +163 -107
  13. package/dist/property-panel/PropertyField.d.ts +6 -0
  14. package/dist/property-panel/fieldSchema.d.ts +7 -1
  15. package/dist/property-panel/fields/ImageSrcField.d.ts +5 -1
  16. package/dist/property-panel/fields/ResourceValueField.d.ts +19 -0
  17. package/dist/property-panel/fields/TextareaField.d.ts +1 -0
  18. package/dist/property-panel/fields/ValueTypeSegmented.d.ts +3 -1
  19. package/dist/property-panel/index.d.ts +5 -3
  20. package/dist/property-panel/usePropertyPanel.d.ts +16 -4
  21. package/dist/{property-panel-DmSf_GPu.js → property-panel-B32ZBQdf.js} +472 -376
  22. package/dist/property-panel.js +3 -2
  23. package/dist/resourceTemplate-cdcQtp9a.js +246 -0
  24. package/dist/shared/ExpressionPathPicker.d.ts +25 -0
  25. package/dist/shared/completion.d.ts +14 -10
  26. package/dist/shared/expressionContext.d.ts +2 -2
  27. package/dist/shared/index.d.ts +14 -1
  28. package/dist/shared/mergeKey.d.ts +2 -0
  29. package/dist/shared/pathPickerModel.d.ts +11 -0
  30. package/dist/shared/popupPosition.d.ts +41 -0
  31. package/dist/shared/resourceTemplate.d.ts +7 -0
  32. package/dist/shared/useExpressionCompletion.d.ts +0 -7
  33. package/dist/shared/useExpressionDiagnostics.d.ts +15 -0
  34. package/dist/shared.js +10 -9
  35. package/dist/style.css +1 -1
  36. package/dist/uploadFile-D1RY-ji0.js +516 -0
  37. package/dist/usePathCompletion-Do17CQ6l.js +220 -0
  38. package/package.json +2 -2
  39. package/dist/uploadFile-DXAEX9kG.js +0 -455
  40. package/dist/usePathCompletion-C52F4phW.js +0 -229
  41. /package/dist/{property-panel → shared}/fontPicker.d.ts +0 -0
@@ -0,0 +1,220 @@
1
+ import { a as e } from "./layerPath-uy2ywyld.js";
2
+ import { a as t, g as n, i as r, m as i, r as a } from "./popupPosition-Ck5Gsvjy.js";
3
+ import { nextTick as o, onMounted as s, onScopeDispose as c, reactive as l, toValue as u, watch as d } from "vue";
4
+ //#region ../canvas-editor/src/shared/rowsPathCandidates.ts
5
+ function f(e) {
6
+ return e.type === "array" || e.items !== void 0;
7
+ }
8
+ function p(e) {
9
+ return !f(e) && e.properties === void 0;
10
+ }
11
+ function m(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), f(t) && (r.type = "array"), r;
17
+ }
18
+ function h(e, t) {
19
+ let n = [];
20
+ if (e.properties !== void 0) for (let [r, i] of e.properties) p(i) || n.push(m(r, i, t));
21
+ return n;
22
+ }
23
+ function g(e, t) {
24
+ if (e === null) return null;
25
+ let r = t.split("."), i = t.endsWith(".") ? "" : r[r.length - 1], a = r.slice(0, -1), o = e;
26
+ for (let e of a) {
27
+ if (f(o)) return null;
28
+ let t = n(o, [e]);
29
+ if (t === null) return null;
30
+ o = t;
31
+ }
32
+ return f(o) || p(o) ? null : {
33
+ partial: i,
34
+ candidates: h(o, a.join("."))
35
+ };
36
+ }
37
+ function _(t, n, r) {
38
+ if (r === null) return null;
39
+ if (t === null || n === null) return r;
40
+ let a = null;
41
+ for (let o = 0; o < n.length; o += 1) {
42
+ if (n[o] !== "template") continue;
43
+ let s = e(t, n.slice(0, o));
44
+ if (s === null || s.type !== "TableLayer" || (a = i(a ?? r, s.rowsPath), a === null)) return null;
45
+ }
46
+ return a ?? r;
47
+ }
48
+ //#endregion
49
+ //#region src/shared/rowsPathCompletionSource.ts
50
+ function v(e) {
51
+ return e === null ? null : (t) => {
52
+ let n = g(e, t);
53
+ return n === null ? null : {
54
+ partial: n.partial,
55
+ candidates: n.candidates.map((e) => e.type === "array" ? {
56
+ ...e,
57
+ type: "行数组"
58
+ } : e)
59
+ };
60
+ };
61
+ }
62
+ //#endregion
63
+ //#region src/shared/usePathCompletion.ts
64
+ var y = [
65
+ "ArrowLeft",
66
+ "ArrowRight",
67
+ "Home",
68
+ "End",
69
+ "PageUp",
70
+ "PageDown"
71
+ ];
72
+ function b(e) {
73
+ return {
74
+ kind: "fragment",
75
+ start: -2,
76
+ end: e.length + 2,
77
+ raw: "",
78
+ expr: e,
79
+ error: null,
80
+ diagnostic: null
81
+ };
82
+ }
83
+ function x(e) {
84
+ let n = l({
85
+ open: !1,
86
+ items: [],
87
+ activeIndex: 0,
88
+ top: 0,
89
+ left: 0
90
+ }), i = null, f = !1, p = "";
91
+ function m() {
92
+ n.open = !1, n.items = [], n.activeIndex = 0, p = "";
93
+ }
94
+ function h() {
95
+ if (!n.open || !i) return;
96
+ let t = r(i), o = e.popupEl ? u(e.popupEl) : null, s = a({
97
+ anchor: t,
98
+ popupWidth: o?.offsetWidth ?? 0,
99
+ popupHeight: o?.offsetHeight ?? 0,
100
+ viewportWidth: window.innerWidth,
101
+ viewportHeight: window.innerHeight
102
+ });
103
+ n.top = s.top, n.left = s.left;
104
+ }
105
+ function g(t, r = !1) {
106
+ if (!u(e.enabled)) {
107
+ m();
108
+ return;
109
+ }
110
+ let a = i;
111
+ if (!a) {
112
+ m();
113
+ return;
114
+ }
115
+ let s = a.value.slice(0, a.selectionStart ?? a.value.length);
116
+ if (s === "" && !r) {
117
+ m();
118
+ return;
119
+ }
120
+ let c = e.resolve(s);
121
+ if (!c) {
122
+ m();
123
+ return;
124
+ }
125
+ let l = r ? c.candidates : c.candidates.filter((e) => e.segment.startsWith(c.partial));
126
+ if (l.length === 0) {
127
+ m();
128
+ return;
129
+ }
130
+ p = c.partial, (n.open || t) && (n.items = l, n.activeIndex = 0, n.open = !0, h(), o(h));
131
+ }
132
+ function _(e) {
133
+ let r = i;
134
+ if (!n.open || f || !r) return;
135
+ let a = n.items[e ?? n.activeIndex];
136
+ if (!a) return;
137
+ let o = r.value.slice(0, r.selectionStart ?? r.value.length), s = t(r.value, b(o), o.length, p, a);
138
+ if (!s) {
139
+ m();
140
+ return;
141
+ }
142
+ r.value = s.value, r.setSelectionRange(s.cursor, s.cursor), r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })), m();
143
+ }
144
+ function v(e) {
145
+ f || e.isComposing || g(!0);
146
+ }
147
+ function x() {
148
+ f = !0;
149
+ }
150
+ function S() {
151
+ f = !1, g(!0);
152
+ }
153
+ function C(e) {
154
+ return f || e.isComposing || e.keyCode === 229;
155
+ }
156
+ function w(e) {
157
+ if (!C(e)) {
158
+ if (e.key === " " && (e.ctrlKey || e.metaKey)) {
159
+ e.preventDefault(), g(!0, !0);
160
+ return;
161
+ }
162
+ if (n.open) {
163
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
164
+ e.preventDefault();
165
+ let t = n.items.length;
166
+ t > 0 && (n.activeIndex = (n.activeIndex + (e.key === "ArrowDown" ? 1 : t - 1)) % t);
167
+ return;
168
+ }
169
+ if (e.key === "Enter" || e.key === "Tab") {
170
+ e.preventDefault(), _();
171
+ return;
172
+ }
173
+ e.key === "Escape" && (e.preventDefault(), m());
174
+ }
175
+ }
176
+ }
177
+ function T(e) {
178
+ n.open && !C(e) && y.includes(e.key) && g(!1);
179
+ }
180
+ function E() {
181
+ f || g(!1);
182
+ }
183
+ function D() {
184
+ m();
185
+ }
186
+ function O(e) {
187
+ n.open && e.target !== i && m();
188
+ }
189
+ function k() {
190
+ h();
191
+ }
192
+ let A = [
193
+ ["input", v],
194
+ ["keydown", w],
195
+ ["keyup", T],
196
+ ["click", E],
197
+ ["blur", D],
198
+ ["compositionstart", x],
199
+ ["compositionend", S]
200
+ ];
201
+ function j(e) {
202
+ for (let [t, n] of A) e.addEventListener(t, n);
203
+ }
204
+ function M(e) {
205
+ for (let [t, n] of A) e.removeEventListener(t, n);
206
+ }
207
+ function N(e) {
208
+ i !== e && (i && M(i), i = e, e && j(e));
209
+ }
210
+ return s(() => N(e.target.value)), d(e.target, (e) => N(e)), d(() => u(e.enabled), (e) => {
211
+ e || m();
212
+ }), document.addEventListener("mousedown", O), window.addEventListener("scroll", k, !0), window.addEventListener("resize", k), c(() => {
213
+ i && M(i), document.removeEventListener("mousedown", O), window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k);
214
+ }), {
215
+ popup: n,
216
+ accept: _
217
+ };
218
+ }
219
+ //#endregion
220
+ export { v as n, _ as r, x as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hankchen/canvas-editor-vue",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "description": "Vue 3 薄绑定:响应式桥、composables、画布表面组件、textarea 文本编辑 overlay、schema 驱动属性面板注册表",
6
6
  "type": "module",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@lucide/vue": "^1.48.0",
61
- "@hankchen/canvas-editor": "0.4.0"
61
+ "@hankchen/canvas-editor": "0.5.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "vue": "^3.5.0"
@@ -1,455 +0,0 @@
1
- import { a as e, r as t } from "./layerPath-uy2ywyld.js";
2
- import { a as n, c as r, d as i, f as a, l as o, n as s, o as c, p as l, s as u, t as d, u as f } from "./completionAnchor-Da8VhzMQ.js";
3
- import { nextTick as p, onMounted as m, onScopeDispose as h, reactive as g, toValue as _, watch as v } from "vue";
4
- //#region ../canvas-editor/src/shared/expressionFunctions.ts
5
- var y = [
6
- {
7
- name: "date",
8
- signature: "date(path[, format])",
9
- summary: "日期格式化(moment 风格 token,预设 date/datetime)"
10
- },
11
- {
12
- name: "number",
13
- signature: "number(path[, n])",
14
- summary: "千分位分组"
15
- },
16
- {
17
- name: "fixed",
18
- signature: "fixed(path[, n])",
19
- summary: "定点补零(缺省 2 位)"
20
- },
21
- {
22
- name: "percent",
23
- signature: "percent(path[, n])",
24
- summary: "百分比(乘 100)"
25
- }
26
- ], b = y.filter((e) => e.name !== "date"), x = [
27
- {
28
- segment: "date",
29
- description: "预设 → YYYY-MM-DD"
30
- },
31
- {
32
- segment: "datetime",
33
- description: "预设 → YYYY-MM-DD HH:mm:ss"
34
- },
35
- {
36
- segment: "YYYY年MM月DD日",
37
- description: "中文模板(写即所得)"
38
- }
39
- ];
40
- //#endregion
41
- //#region ../canvas-editor/src/shared/expressionCandidates.ts
42
- function S(e) {
43
- return e.kind === "row" ? "row" : e.kind === "root" ? "$root" : e.name;
44
- }
45
- function C(e) {
46
- let t = {};
47
- 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;
48
- }
49
- function w(e, t) {
50
- return {
51
- path: t === "" ? e.key : `${t}.${e.key}`,
52
- segment: e.key,
53
- ...C(e.node)
54
- };
55
- }
56
- function T(e, t, n) {
57
- let r = [];
58
- if (e.node.format === "date" || e.node.format === "date-time") r.push({
59
- path: `date(${t}, '')`,
60
- segment: `date(${t}, '')`,
61
- cursorBack: 2,
62
- replaceLen: n,
63
- filterKey: e.key,
64
- description: "日期格式化",
65
- type: "函数"
66
- });
67
- else if (e.node.type === "number") for (let i of b) r.push({
68
- path: `${i.name}(${t})`,
69
- segment: `${i.name}(${t})`,
70
- replaceLen: n,
71
- filterKey: e.key,
72
- description: i.summary,
73
- type: "函数"
74
- });
75
- return r;
76
- }
77
- function E(e, t, n, r) {
78
- let i = w(e, t);
79
- return r ? [i, ...T(e, i.path, n)] : [i];
80
- }
81
- function D() {
82
- return y.map((e) => ({
83
- path: e.signature,
84
- segment: `${e.name}()`,
85
- cursorBack: 1,
86
- description: e.summary,
87
- type: "函数"
88
- }));
89
- }
90
- function O() {
91
- return x.map((e) => ({
92
- path: e.segment,
93
- segment: e.segment,
94
- description: e.description,
95
- type: "格式"
96
- }));
97
- }
98
- function k(e, t, n, r, i) {
99
- let o = a(e), s = o.entries.flatMap((e) => E(e, "", r, i));
100
- return s.push({
101
- path: "$root",
102
- segment: "$root"
103
- }), t === "row" && (s.push(n ? {
104
- path: "row",
105
- segment: "row",
106
- ...C(n)
107
- } : {
108
- path: "row",
109
- segment: "row"
110
- }), s.push({
111
- path: "$index",
112
- segment: "$index"
113
- })), o.open === !0 ? {
114
- candidates: s,
115
- open: !0
116
- } : { candidates: s };
117
- }
118
- function A(e, t) {
119
- let n = r(t.expr);
120
- if (n === null) return {
121
- ok: !0,
122
- prefix: "",
123
- partial: "",
124
- candidates: []
125
- };
126
- if (n.stringSlot && n.index >= 1 && n.name === "date") return {
127
- ok: !0,
128
- prefix: "",
129
- partial: n.text,
130
- candidates: O()
131
- };
132
- if (n.index === 0 && !o(n.text)) {
133
- let r = j(e, t, n.text, !1);
134
- return r.ok ? r : {
135
- ok: !0,
136
- prefix: "",
137
- partial: "",
138
- candidates: []
139
- };
140
- }
141
- return {
142
- ok: !0,
143
- prefix: "",
144
- partial: "",
145
- candidates: []
146
- };
147
- }
148
- function j(e, t, n, r) {
149
- if (e === null) return {
150
- ok: !0,
151
- prefix: "",
152
- partial: "",
153
- candidates: []
154
- };
155
- let i = n.endsWith("."), o = i ? n.slice(0, -1) : n;
156
- if (o === "") return n === "" ? {
157
- ok: !0,
158
- prefix: "",
159
- partial: "",
160
- ...k(e, t.context, t.rowSchema, n.length, !1)
161
- } : {
162
- ok: !1,
163
- reason: "expression_syntax_error"
164
- };
165
- let s = f(o);
166
- if (!s.ok) return {
167
- ok: !1,
168
- reason: "expression_syntax_error"
169
- };
170
- let { head: c, rest: u } = s, d, p;
171
- i ? (d = [S(c), ...u], p = "") : u.length > 0 ? (d = [S(c), ...u.slice(0, -1)], p = u[u.length - 1]) : (d = [], p = S(c));
172
- let m = r && p !== "";
173
- if (d.length === 0) {
174
- let i = k(e, t.context, t.rowSchema, n.length, m), a = r && n !== "" ? D() : [];
175
- return {
176
- ok: !0,
177
- prefix: "",
178
- partial: p,
179
- candidates: [...i.candidates, ...a],
180
- ...i.open === !0 ? { open: !0 } : {}
181
- };
182
- }
183
- let h, g;
184
- if (c.kind === "row") {
185
- if (t.context !== "row") return {
186
- ok: !0,
187
- prefix: d.join("."),
188
- partial: p,
189
- candidates: []
190
- };
191
- h = t.rowSchema ?? null, g = d.slice(1);
192
- } else if (c.kind === "root") h = e, g = d.slice(1);
193
- else if (c.name === "$index") return {
194
- ok: !0,
195
- prefix: d.join("."),
196
- partial: p,
197
- candidates: []
198
- };
199
- else h = e, g = d;
200
- let _ = h === null ? null : l(h, g), v = d.join(".");
201
- if (_ === null) return {
202
- ok: !0,
203
- prefix: v,
204
- partial: p,
205
- candidates: []
206
- };
207
- let y = a(_);
208
- return {
209
- ok: !0,
210
- prefix: v,
211
- partial: p,
212
- candidates: y.entries.flatMap((e) => E(e, v, n.length, m)),
213
- ...y.open === !0 ? { open: !0 } : {}
214
- };
215
- }
216
- function M(e, t) {
217
- return e === null ? {
218
- ok: !0,
219
- prefix: "",
220
- partial: "",
221
- candidates: []
222
- } : o(t.expr) ? A(e, t) : j(e, t, t.expr, !0);
223
- }
224
- //#endregion
225
- //#region src/shared/expressionContext.ts
226
- function N(t, n, r) {
227
- let a = null;
228
- for (let o = 0; o < n.length; o += 1) {
229
- if (n[o] !== "template") continue;
230
- let s = e(t, n.slice(0, o));
231
- if (s === null || s.type !== "TableLayer" || (a = i(a ?? r, s.rowsPath), a === null)) return null;
232
- }
233
- return a;
234
- }
235
- function P(e) {
236
- return e[e.length - 1] === "content" && t(e);
237
- }
238
- function F(e, t, n) {
239
- return e === null || t === null || n === null || !P(n) ? {
240
- kind: "root",
241
- rowSchema: null
242
- } : {
243
- kind: "row",
244
- rowSchema: N(t, n, e)
245
- };
246
- }
247
- function I(e, t) {
248
- return e === null ? null : (n) => {
249
- let r = M(e, {
250
- context: t.kind,
251
- expr: n,
252
- rowSchema: t.rowSchema
253
- });
254
- return r.ok ? {
255
- partial: r.partial,
256
- candidates: r.candidates,
257
- ...r.open === !0 ? { open: !0 } : {}
258
- } : null;
259
- };
260
- }
261
- //#endregion
262
- //#region src/shared/useExpressionCompletion.ts
263
- var L = 4, R = [
264
- "ArrowLeft",
265
- "ArrowRight",
266
- "Home",
267
- "End",
268
- "PageUp",
269
- "PageDown"
270
- ];
271
- function z(e) {
272
- let t = g({
273
- open: !1,
274
- items: [],
275
- activeIndex: 0,
276
- top: 0,
277
- left: 0,
278
- openMapping: !1
279
- }), r = null, i = !1, a = null;
280
- function o() {
281
- t.open = !1, t.items = [], t.activeIndex = 0, t.openMapping = !1, a = null;
282
- }
283
- function l() {
284
- if (!t.open || !r) return;
285
- let n = d(r, _(e.scale ?? 1));
286
- t.top = n.bottom + L, t.left = f(n.left);
287
- }
288
- function f(t) {
289
- let n = (e.popupEl ? _(e.popupEl) : null)?.offsetWidth ?? 0;
290
- return n <= 0 ? t : Math.max(0, Math.min(t, window.innerWidth - 4 - n));
291
- }
292
- function y(i, s = !1) {
293
- if (!_(e.enabled)) {
294
- o();
295
- return;
296
- }
297
- let d = r;
298
- if (!d) {
299
- o();
300
- return;
301
- }
302
- let f = d.value, m = d.selectionStart ?? f.length, h = n(u(f), m);
303
- if (!h) {
304
- o();
305
- return;
306
- }
307
- let g = h.kind === "open" ? h.end : h.end - 2, v = e.resolve(c(f.slice(h.start + 2, Math.min(m, g))));
308
- if (!v) {
309
- o();
310
- return;
311
- }
312
- let y = s ? v.candidates : v.candidates.filter((e) => (e.filterKey ?? e.segment).startsWith(v.partial));
313
- if (y.length === 0 && v.open !== !0) {
314
- o();
315
- return;
316
- }
317
- a = {
318
- fragment: h,
319
- partial: v.partial,
320
- cursor: m
321
- }, (t.open || i) && (t.items = y, t.activeIndex = 0, t.openMapping = v.open === !0, t.open = !0, l(), p(l));
322
- }
323
- function b(e) {
324
- let n = r;
325
- if (!t.open || i || !n || !a) return;
326
- let c = t.items[e ?? t.activeIndex];
327
- if (!c) return;
328
- let l = s(n.value, a.fragment, a.cursor, a.partial, c);
329
- if (!l) {
330
- o();
331
- return;
332
- }
333
- n.value = l.value, n.setSelectionRange(l.cursor, l.cursor), n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 })), o();
334
- }
335
- function x() {
336
- return _(e.pairing ?? e.enabled);
337
- }
338
- function S(e) {
339
- let t = e.selectionStart;
340
- return t === null || t !== e.selectionEnd ? null : t;
341
- }
342
- let C = !1;
343
- function w(e) {
344
- if (C || !x()) return;
345
- let t = r;
346
- if (!t) return;
347
- let n = e.inputType;
348
- if (n !== void 0 && n !== "" && n !== "insertText") return;
349
- let i = S(t);
350
- if (i === null || i < 2) return;
351
- let a = t.value;
352
- a.startsWith("{{", i - 2) && (a.includes("}}", i) || (C = !0, t.value = `${a.slice(0, i)}}}${a.slice(i)}`, t.setSelectionRange(i, i), t.dispatchEvent(new Event("input", { bubbles: !0 })), C = !1));
353
- }
354
- function T(e) {
355
- if (!x()) return !1;
356
- let t = r;
357
- if (!t) return !1;
358
- let n = S(t);
359
- if (n === null || n < 2) return !1;
360
- let i = t.value;
361
- return !i.startsWith("{{", n - 2) || !i.startsWith("}}", n) ? !1 : (e.preventDefault(), C = !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 })), C = !1, !0);
362
- }
363
- function E(e) {
364
- if (!x()) return !1;
365
- let t = r;
366
- if (!t) return !1;
367
- let n = S(t);
368
- return n === null || t.value[n] !== "}" ? !1 : (e.preventDefault(), t.setSelectionRange(n + 1, n + 1), y(!1), !0);
369
- }
370
- function D(e) {
371
- i || e.isComposing || (w(e), y(!0));
372
- }
373
- function O() {
374
- i = !0;
375
- }
376
- function k() {
377
- i = !1, y(!0);
378
- }
379
- function A(e) {
380
- return i || e.isComposing || e.keyCode === 229;
381
- }
382
- function j(e) {
383
- if (!A(e)) {
384
- if (e.key === " " && (e.ctrlKey || e.metaKey)) {
385
- e.preventDefault(), y(!0, !0);
386
- return;
387
- }
388
- if (!(e.key === "Backspace" && T(e)) && !(e.key === "}" && E(e)) && t.open) {
389
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
390
- e.preventDefault();
391
- let n = t.items.length;
392
- n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
393
- return;
394
- }
395
- if (e.key === "Enter" || e.key === "Tab") {
396
- e.preventDefault(), b();
397
- return;
398
- }
399
- e.key === "Escape" && (e.preventDefault(), o());
400
- }
401
- }
402
- }
403
- function M(e) {
404
- t.open && !A(e) && R.includes(e.key) && y(!1);
405
- }
406
- function N() {
407
- i || y(!1);
408
- }
409
- function P() {
410
- o();
411
- }
412
- function F(e) {
413
- t.open && e.target !== r && o();
414
- }
415
- function I() {
416
- l();
417
- }
418
- let z = [
419
- ["input", D],
420
- ["keydown", j],
421
- ["keyup", M],
422
- ["click", N],
423
- ["blur", P],
424
- ["compositionstart", O],
425
- ["compositionend", k]
426
- ];
427
- function B(e) {
428
- for (let [t, n] of z) e.addEventListener(t, n);
429
- }
430
- function V(e) {
431
- for (let [t, n] of z) e.removeEventListener(t, n);
432
- }
433
- function H(e) {
434
- r !== e && (r && V(r), r = e, e && B(e));
435
- }
436
- return m(() => H(e.target.value)), v(e.target, (e) => H(e)), v(() => _(e.enabled), (e) => {
437
- e || o();
438
- }), document.addEventListener("mousedown", F), window.addEventListener("scroll", I, !0), window.addEventListener("resize", I), h(() => {
439
- r && V(r), document.removeEventListener("mousedown", F), window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I);
440
- }), {
441
- popup: t,
442
- accept: b
443
- };
444
- }
445
- //#endregion
446
- //#region src/shared/uploadFile.ts
447
- async function B(e) {
448
- return {
449
- name: e.name,
450
- mime: e.type,
451
- bytes: new Uint8Array(await e.arrayBuffer())
452
- };
453
- }
454
- //#endregion
455
- export { F as i, z as n, I as r, B as t };