@hankchen/canvas-editor-vue 0.6.0 → 0.7.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/{useDataSourceSchema-YV8g-lo0.js → DropdownMenu-CeUNKMDQ.js} +70 -78
- package/dist/ExpressionPathPicker-DchGsK70.js +739 -0
- package/dist/{canvas-CX1RdlFC.js → canvas-D3fFnBqG.js} +526 -527
- package/dist/canvas.js +1 -1
- package/dist/index.js +14 -15
- package/dist/layer-panel/TemplateTableForm.d.ts +1 -27
- package/dist/{layer-panel-Cd1e8xNB.js → layer-panel-BouAYiDq.js} +231 -257
- package/dist/layer-panel.js +1 -1
- package/dist/property-panel/PropertyField.d.ts +9 -2
- package/dist/property-panel/fieldSchema.d.ts +16 -10
- package/dist/property-panel/fields/RowsPathField.d.ts +17 -0
- package/dist/property-panel/fields/index.d.ts +1 -0
- package/dist/property-panel/usePropertyPanel.d.ts +11 -2
- package/dist/{property-panel-B32ZBQdf.js → property-panel-DJQJzioT.js} +403 -341
- package/dist/property-panel.js +2 -2
- package/dist/resourceTemplate-D-DKEo7Z.js +33 -0
- package/dist/shared/ExpressionPathPicker.d.ts +9 -2
- package/dist/shared/index.d.ts +13 -10
- package/dist/shared/pathPickerModel.d.ts +16 -3
- package/dist/shared/popupPosition.d.ts +2 -2
- package/dist/shared/rowsPathPickerSource.d.ts +15 -0
- package/dist/shared/useDataSourceSchema.d.ts +9 -1
- package/dist/shared/useExpressionDiagnostics.d.ts +11 -0
- package/dist/{shared-wuupBoZg.js → shared-CRDKDSpa.js} +22 -22
- package/dist/shared.js +9 -10
- package/dist/{status-bar-XMVbRLY9.js → status-bar-DBf5kIXY.js} +69 -67
- package/dist/status-bar.js +1 -1
- package/dist/style.css +1 -1
- package/dist/uploadFile-mXJVPEzm.js +653 -0
- package/dist/{useTransientFeedback-CTjmMmFF.js → useTransientFeedback-BN_O7V2w.js} +43 -28
- package/package.json +2 -2
- package/dist/popupPosition-Ck5Gsvjy.js +0 -526
- package/dist/resourceTemplate-cdcQtp9a.js +0 -246
- package/dist/shared/rowsPathCompletionSource.d.ts +0 -3
- package/dist/shared/usePathCompletion.d.ts +0 -18
- package/dist/uploadFile-D1RY-ji0.js +0 -516
- package/dist/usePathCompletion-Do17CQ6l.js +0 -220
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import { a as e, r as t } from "./layerPath-uy2ywyld.js";
|
|
2
|
+
import { _ as n, d as r, f as i, g as a, h as o, i as s, m as c, p as l, v as u, y as d } from "./ExpressionPathPicker-DchGsK70.js";
|
|
3
|
+
import { Fragment as f, Teleport as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, defineComponent as y, inject as b, nextTick as x, normalizeClass as S, normalizeStyle as C, onMounted as w, onScopeDispose as T, openBlock as E, reactive as ee, ref as D, renderList as O, shallowRef as k, toDisplayString as A, toValue as j, watch as M, withModifiers as N } from "vue";
|
|
4
|
+
//#region ../canvas-editor/src/shared/expressionDiagnostics.ts
|
|
5
|
+
function P(e) {
|
|
6
|
+
let t = [];
|
|
7
|
+
for (let n of l(e).parts) n.kind === "fragment" && n.diagnostic !== null && t.push(n.diagnostic);
|
|
8
|
+
return t;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../canvas-editor/src/shared/expressionFunctions.ts
|
|
12
|
+
var F = [
|
|
13
|
+
{
|
|
14
|
+
name: "date",
|
|
15
|
+
signature: "date(path[, format])",
|
|
16
|
+
summary: "日期格式化(moment 风格 token,预设 date/datetime)"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "number",
|
|
20
|
+
signature: "number(path[, n])",
|
|
21
|
+
summary: "千分位分组"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "fixed",
|
|
25
|
+
signature: "fixed(path[, n])",
|
|
26
|
+
summary: "定点补零(缺省 2 位)"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "percent",
|
|
30
|
+
signature: "percent(path[, n])",
|
|
31
|
+
summary: "百分比(乘 100)"
|
|
32
|
+
}
|
|
33
|
+
], I = F.filter((e) => e.name !== "date"), L = [
|
|
34
|
+
{
|
|
35
|
+
segment: "date",
|
|
36
|
+
description: "预设 → YYYY-MM-DD"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
segment: "datetime",
|
|
40
|
+
description: "预设 → YYYY-MM-DD HH:mm:ss"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
segment: "YYYY年MM月DD日",
|
|
44
|
+
description: "中文模板(写即所得)"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../canvas-editor/src/shared/expressionCandidates.ts
|
|
49
|
+
function R(e) {
|
|
50
|
+
return e.kind === "row" ? "row" : e.kind === "root" ? "$root" : e.name;
|
|
51
|
+
}
|
|
52
|
+
function z(e) {
|
|
53
|
+
let t = {};
|
|
54
|
+
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;
|
|
55
|
+
}
|
|
56
|
+
function te(e, t) {
|
|
57
|
+
return {
|
|
58
|
+
path: t === "" ? e.key : `${t}.${e.key}`,
|
|
59
|
+
segment: e.key,
|
|
60
|
+
kind: "path",
|
|
61
|
+
...z(e.node)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function ne(e, t, n) {
|
|
65
|
+
let r = [];
|
|
66
|
+
if (e.node.format === "date" || e.node.format === "date-time") r.push({
|
|
67
|
+
path: `date(${t}, '')`,
|
|
68
|
+
segment: `date(${t}, '')`,
|
|
69
|
+
cursorBack: 2,
|
|
70
|
+
replaceLen: n,
|
|
71
|
+
filterKey: e.key,
|
|
72
|
+
kind: "function",
|
|
73
|
+
description: "日期格式化",
|
|
74
|
+
type: "函数"
|
|
75
|
+
});
|
|
76
|
+
else if (e.node.type === "number") for (let i of I) r.push({
|
|
77
|
+
path: `${i.name}(${t})`,
|
|
78
|
+
segment: `${i.name}(${t})`,
|
|
79
|
+
replaceLen: n,
|
|
80
|
+
filterKey: e.key,
|
|
81
|
+
kind: "function",
|
|
82
|
+
description: i.summary,
|
|
83
|
+
type: "函数"
|
|
84
|
+
});
|
|
85
|
+
return r;
|
|
86
|
+
}
|
|
87
|
+
function B(e, t, n, r) {
|
|
88
|
+
let i = te(e, t);
|
|
89
|
+
return r ? [i, ...ne(e, i.path, n)] : [i];
|
|
90
|
+
}
|
|
91
|
+
function re() {
|
|
92
|
+
return F.map((e) => ({
|
|
93
|
+
path: e.signature,
|
|
94
|
+
segment: `${e.name}()`,
|
|
95
|
+
cursorBack: 1,
|
|
96
|
+
kind: "function",
|
|
97
|
+
description: e.summary,
|
|
98
|
+
type: "函数"
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
function ie() {
|
|
102
|
+
return L.map((e) => ({
|
|
103
|
+
path: e.segment,
|
|
104
|
+
segment: e.segment,
|
|
105
|
+
description: e.description,
|
|
106
|
+
type: "格式"
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
function V(e, t, n, r, i) {
|
|
110
|
+
let a = u(e).entries.flatMap((e) => B(e, "", r, i));
|
|
111
|
+
return a.push({
|
|
112
|
+
path: "$root",
|
|
113
|
+
segment: "$root",
|
|
114
|
+
kind: "path"
|
|
115
|
+
}), t === "row" && (a.push(n ? {
|
|
116
|
+
path: "row",
|
|
117
|
+
segment: "row",
|
|
118
|
+
kind: "path",
|
|
119
|
+
...z(n)
|
|
120
|
+
} : {
|
|
121
|
+
path: "row",
|
|
122
|
+
segment: "row",
|
|
123
|
+
kind: "path"
|
|
124
|
+
}), a.push({
|
|
125
|
+
path: "$index",
|
|
126
|
+
segment: "$index",
|
|
127
|
+
kind: "path"
|
|
128
|
+
})), a;
|
|
129
|
+
}
|
|
130
|
+
function ae(e, t) {
|
|
131
|
+
let n = c(t.expr);
|
|
132
|
+
if (n === null) return {
|
|
133
|
+
ok: !0,
|
|
134
|
+
prefix: "",
|
|
135
|
+
partial: "",
|
|
136
|
+
candidates: []
|
|
137
|
+
};
|
|
138
|
+
if (n.stringSlot && n.index >= 1 && n.name === "date") return {
|
|
139
|
+
ok: !0,
|
|
140
|
+
prefix: "",
|
|
141
|
+
partial: n.text,
|
|
142
|
+
candidates: ie()
|
|
143
|
+
};
|
|
144
|
+
if (n.index === 0 && !o(n.text)) {
|
|
145
|
+
let r = H(e, t, n.text, !1);
|
|
146
|
+
return r.ok ? r : {
|
|
147
|
+
ok: !0,
|
|
148
|
+
prefix: "",
|
|
149
|
+
partial: "",
|
|
150
|
+
candidates: []
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
ok: !0,
|
|
155
|
+
prefix: "",
|
|
156
|
+
partial: "",
|
|
157
|
+
candidates: []
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function H(e, t, n, r) {
|
|
161
|
+
if (e === null) return {
|
|
162
|
+
ok: !0,
|
|
163
|
+
prefix: "",
|
|
164
|
+
partial: "",
|
|
165
|
+
candidates: []
|
|
166
|
+
};
|
|
167
|
+
let i = n.endsWith("."), o = i ? n.slice(0, -1) : n;
|
|
168
|
+
if (o === "") return n === "" ? {
|
|
169
|
+
ok: !0,
|
|
170
|
+
prefix: "",
|
|
171
|
+
partial: "",
|
|
172
|
+
candidates: V(e, t.context, t.rowSchema, n.length, !1)
|
|
173
|
+
} : {
|
|
174
|
+
ok: !1,
|
|
175
|
+
reason: "expression_syntax_error"
|
|
176
|
+
};
|
|
177
|
+
let s = a(o);
|
|
178
|
+
if (!s.ok) return {
|
|
179
|
+
ok: !1,
|
|
180
|
+
reason: "expression_syntax_error"
|
|
181
|
+
};
|
|
182
|
+
let { head: c, rest: l } = s, f, p;
|
|
183
|
+
i ? (f = [R(c), ...l], p = "") : l.length > 0 ? (f = [R(c), ...l.slice(0, -1)], p = l[l.length - 1]) : (f = [], p = R(c));
|
|
184
|
+
let m = r && p !== "";
|
|
185
|
+
if (f.length === 0) {
|
|
186
|
+
let i = V(e, t.context, t.rowSchema, n.length, m), a = r && n !== "" ? re() : [];
|
|
187
|
+
return {
|
|
188
|
+
ok: !0,
|
|
189
|
+
prefix: "",
|
|
190
|
+
partial: p,
|
|
191
|
+
candidates: [...i, ...a]
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
let h, g;
|
|
195
|
+
if (c.kind === "row") {
|
|
196
|
+
if (t.context !== "row") return {
|
|
197
|
+
ok: !0,
|
|
198
|
+
prefix: f.join("."),
|
|
199
|
+
partial: p,
|
|
200
|
+
candidates: []
|
|
201
|
+
};
|
|
202
|
+
h = t.rowSchema ?? null, g = f.slice(1);
|
|
203
|
+
} else if (c.kind === "root") h = e, g = f.slice(1);
|
|
204
|
+
else if (c.name === "$index") return {
|
|
205
|
+
ok: !0,
|
|
206
|
+
prefix: f.join("."),
|
|
207
|
+
partial: p,
|
|
208
|
+
candidates: []
|
|
209
|
+
};
|
|
210
|
+
else h = e, g = f;
|
|
211
|
+
let _ = h === null ? null : d(h, g), v = f.join(".");
|
|
212
|
+
if (_ === null) return {
|
|
213
|
+
ok: !0,
|
|
214
|
+
prefix: v,
|
|
215
|
+
partial: p,
|
|
216
|
+
candidates: []
|
|
217
|
+
};
|
|
218
|
+
let y = u(_);
|
|
219
|
+
return {
|
|
220
|
+
ok: !0,
|
|
221
|
+
prefix: v,
|
|
222
|
+
partial: p,
|
|
223
|
+
candidates: y.entries.flatMap((e) => B(e, v, n.length, m))
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function oe(e, t) {
|
|
227
|
+
return e === null ? {
|
|
228
|
+
ok: !0,
|
|
229
|
+
prefix: "",
|
|
230
|
+
partial: "",
|
|
231
|
+
candidates: []
|
|
232
|
+
} : o(t.expr) ? ae(e, t) : H(e, t, t.expr, !0);
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/shared/ExpressionCompletionPopup.vue?vue&type=script&setup=true&lang.ts
|
|
236
|
+
var se = {
|
|
237
|
+
role: "listbox",
|
|
238
|
+
"aria-label": "表达式路径候选"
|
|
239
|
+
}, U = [
|
|
240
|
+
"aria-selected",
|
|
241
|
+
"title",
|
|
242
|
+
"onClick"
|
|
243
|
+
], W = { class: "cn-completion__segment font-mono text-cn-fg" }, G = {
|
|
244
|
+
key: 0,
|
|
245
|
+
class: "shrink-0 rounded-sm bg-cn-field px-1 py-0.5 text-[9px] leading-none text-cn-muted"
|
|
246
|
+
}, ce = {
|
|
247
|
+
key: 1,
|
|
248
|
+
class: "truncate text-[10px] leading-none text-cn-muted"
|
|
249
|
+
}, le = /* @__PURE__ */ y({
|
|
250
|
+
__name: "ExpressionCompletionPopup",
|
|
251
|
+
props: { state: {} },
|
|
252
|
+
emits: ["select"],
|
|
253
|
+
setup(e, { expose: t, emit: n }) {
|
|
254
|
+
let r = e, i = n, a = D(null);
|
|
255
|
+
return t({ rootEl: a }), M(() => r.state.activeIndex, async () => {
|
|
256
|
+
await x(), a.value?.querySelector(".cn-completion__option--active")?.scrollIntoView?.({ block: "nearest" });
|
|
257
|
+
}), (t, n) => (E(), h(p, { to: "body" }, [e.state.open ? (E(), _("div", {
|
|
258
|
+
key: 0,
|
|
259
|
+
ref_key: "rootRef",
|
|
260
|
+
ref: a,
|
|
261
|
+
class: "cn-props cn-completion fixed z-50 max-h-[200px] min-w-[140px] max-w-[280px] overflow-y-auto rounded-md border border-cn-field-line py-1 text-[11px] leading-none",
|
|
262
|
+
style: C({
|
|
263
|
+
top: `${e.state.top}px`,
|
|
264
|
+
left: `${e.state.left}px`
|
|
265
|
+
}),
|
|
266
|
+
onMousedown: n[0] ||= N(() => {}, ["prevent", "stop"]),
|
|
267
|
+
onPointerdown: n[1] ||= N(() => {}, ["stop"])
|
|
268
|
+
}, [v("div", se, [(E(!0), _(f, null, O(e.state.items, (t, n) => (E(), _("button", {
|
|
269
|
+
key: `${n}:${t.segment}`,
|
|
270
|
+
type: "button",
|
|
271
|
+
role: "option",
|
|
272
|
+
class: S(["cn-completion__option flex w-full items-center gap-1.5 px-2 py-1.5 text-left", n === e.state.activeIndex ? "cn-completion__option--active" : ""]),
|
|
273
|
+
"aria-selected": n === e.state.activeIndex,
|
|
274
|
+
title: t.path ?? t.segment,
|
|
275
|
+
onClick: (e) => i("select", n)
|
|
276
|
+
}, [
|
|
277
|
+
v("span", W, A(t.segment), 1),
|
|
278
|
+
t.type ? (E(), _("span", G, A(t.type), 1)) : g("", !0),
|
|
279
|
+
t.description ?? t.title ? (E(), _("span", ce, A(t.description ?? t.title), 1)) : g("", !0)
|
|
280
|
+
], 10, U))), 128))])], 36)) : g("", !0)]));
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/shared/expressionContext.ts
|
|
285
|
+
function ue(t, r, i) {
|
|
286
|
+
let a = null;
|
|
287
|
+
for (let o = 0; o < r.length; o += 1) {
|
|
288
|
+
if (r[o] !== "template") continue;
|
|
289
|
+
let s = e(t, r.slice(0, o));
|
|
290
|
+
if (s === null || s.type !== "TableLayer" || (a = n(a ?? i, s.rowsPath), a === null)) return null;
|
|
291
|
+
}
|
|
292
|
+
return a;
|
|
293
|
+
}
|
|
294
|
+
function de(e) {
|
|
295
|
+
return e[e.length - 1] === "content" && t(e);
|
|
296
|
+
}
|
|
297
|
+
function fe(e, t, n) {
|
|
298
|
+
return e === null || t === null || n === null || !de(n) ? {
|
|
299
|
+
kind: "root",
|
|
300
|
+
rowSchema: null
|
|
301
|
+
} : {
|
|
302
|
+
kind: "row",
|
|
303
|
+
rowSchema: ue(t, n, e)
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function pe(e, t) {
|
|
307
|
+
return e === null ? null : (n) => {
|
|
308
|
+
let r = oe(e, {
|
|
309
|
+
context: t.kind,
|
|
310
|
+
expr: n,
|
|
311
|
+
rowSchema: t.rowSchema
|
|
312
|
+
});
|
|
313
|
+
return r.ok ? {
|
|
314
|
+
partial: r.partial,
|
|
315
|
+
candidates: r.candidates
|
|
316
|
+
} : null;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/shared/completion.ts
|
|
321
|
+
function K(e, t, n, r, i) {
|
|
322
|
+
let a = t.start + 2, o = t.kind === "open" ? t.end : t.end - 2, s = Math.min(n, o), c = 0;
|
|
323
|
+
for (; s - c > a && " \n\r\0\v".includes(e[s - 1 - c]);) c += 1;
|
|
324
|
+
let l = s - c, u = l - (i.replaceLen ?? r.length);
|
|
325
|
+
if (u < a || i.replaceLen === void 0 && e.slice(u, l) !== r) return null;
|
|
326
|
+
let d = i.cursorBack ?? 0;
|
|
327
|
+
return d > i.segment.length ? null : {
|
|
328
|
+
value: e.slice(0, u) + i.segment + e.slice(l),
|
|
329
|
+
cursor: u + i.segment.length - d
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/shared/completionAnchor.ts
|
|
334
|
+
function q(e, t) {
|
|
335
|
+
return parseFloat(e.getPropertyValue(t)) || 0;
|
|
336
|
+
}
|
|
337
|
+
function J(e, t, n) {
|
|
338
|
+
for (let r of n) {
|
|
339
|
+
let n = e.getPropertyValue(r);
|
|
340
|
+
n && t.setProperty(r, n);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
var Y = [
|
|
344
|
+
"font-family",
|
|
345
|
+
"font-size",
|
|
346
|
+
"font-weight",
|
|
347
|
+
"font-style",
|
|
348
|
+
"font-stretch",
|
|
349
|
+
"letter-spacing",
|
|
350
|
+
"word-spacing",
|
|
351
|
+
"line-height",
|
|
352
|
+
"text-transform",
|
|
353
|
+
"text-indent",
|
|
354
|
+
"tab-size"
|
|
355
|
+
];
|
|
356
|
+
function me(e) {
|
|
357
|
+
return q(e, "line-height") || q(e, "font-size") * 1.4;
|
|
358
|
+
}
|
|
359
|
+
function X(e) {
|
|
360
|
+
let t = document.createElement("div"), n = t.style;
|
|
361
|
+
return n.position = "fixed", n.top = "0", n.left = "0", n.visibility = "hidden", e(t, n), document.body.appendChild(t), t;
|
|
362
|
+
}
|
|
363
|
+
function he(e, t) {
|
|
364
|
+
let n = e.selectionStart ?? e.value.length, r = e.getBoundingClientRect(), i = getComputedStyle(e), a = q(i, "padding-left"), o = q(i, "padding-top"), s = null, c = X((t, r) => {
|
|
365
|
+
r.whiteSpace = i.whiteSpace || "pre-wrap", r.boxSizing = "content-box", r.width = `${Math.max(0, e.clientWidth - a - q(i, "padding-right"))}px`, J(i, r, [
|
|
366
|
+
"padding-left",
|
|
367
|
+
"padding-right",
|
|
368
|
+
"padding-top",
|
|
369
|
+
"padding-bottom",
|
|
370
|
+
"word-break",
|
|
371
|
+
"overflow-wrap"
|
|
372
|
+
]), J(i, r, Y), s = document.createElement("span"), s.textContent = "", t.append(document.createTextNode(e.value.slice(0, n)), s);
|
|
373
|
+
});
|
|
374
|
+
try {
|
|
375
|
+
let n = r.left + q(i, "border-left-width") + a + s.offsetLeft * t - e.scrollLeft, c = r.top + q(i, "border-top-width") + o + s.offsetTop * t - e.scrollTop;
|
|
376
|
+
return {
|
|
377
|
+
left: n,
|
|
378
|
+
top: c,
|
|
379
|
+
bottom: c + me(i) * t
|
|
380
|
+
};
|
|
381
|
+
} finally {
|
|
382
|
+
c.remove();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function ge(e, t) {
|
|
386
|
+
let n = e.selectionStart ?? e.value.length, r = e.getBoundingClientRect(), i = getComputedStyle(e), a = X((t, r) => {
|
|
387
|
+
r.display = "inline-block", r.whiteSpace = "pre", J(i, r, Y), t.textContent = e.value.slice(0, n);
|
|
388
|
+
});
|
|
389
|
+
try {
|
|
390
|
+
let n = a.getBoundingClientRect().width || a.offsetWidth;
|
|
391
|
+
return {
|
|
392
|
+
left: r.left + q(i, "border-left-width") + q(i, "padding-left") + n * t - e.scrollLeft,
|
|
393
|
+
top: r.top + q(i, "border-top-width"),
|
|
394
|
+
bottom: r.bottom - q(i, "border-bottom-width")
|
|
395
|
+
};
|
|
396
|
+
} finally {
|
|
397
|
+
a.remove();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function Z(e, t = 1) {
|
|
401
|
+
return e instanceof HTMLTextAreaElement ? he(e, t) : ge(e, t);
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/shared/useExpressionCompletion.ts
|
|
405
|
+
var _e = [
|
|
406
|
+
"ArrowLeft",
|
|
407
|
+
"ArrowRight",
|
|
408
|
+
"Home",
|
|
409
|
+
"End",
|
|
410
|
+
"PageUp",
|
|
411
|
+
"PageDown"
|
|
412
|
+
];
|
|
413
|
+
function ve(e) {
|
|
414
|
+
let t = ee({
|
|
415
|
+
open: !1,
|
|
416
|
+
items: [],
|
|
417
|
+
activeIndex: 0,
|
|
418
|
+
top: 0,
|
|
419
|
+
left: 0
|
|
420
|
+
}), n = null, a = !1, o = null;
|
|
421
|
+
function c() {
|
|
422
|
+
t.open = !1, t.items = [], t.activeIndex = 0, o = null;
|
|
423
|
+
}
|
|
424
|
+
function u() {
|
|
425
|
+
if (!t.open || !n) return;
|
|
426
|
+
let r = Z(n, j(e.scale ?? 1)), i = e.popupEl ? j(e.popupEl) : null, a = s({
|
|
427
|
+
anchor: r,
|
|
428
|
+
popupWidth: i?.offsetWidth ?? 0,
|
|
429
|
+
popupHeight: i?.offsetHeight ?? 0,
|
|
430
|
+
viewportWidth: window.innerWidth,
|
|
431
|
+
viewportHeight: window.innerHeight
|
|
432
|
+
});
|
|
433
|
+
t.top = a.top, t.left = a.left;
|
|
434
|
+
}
|
|
435
|
+
function d(a, s = !1) {
|
|
436
|
+
if (!j(e.enabled)) {
|
|
437
|
+
c();
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
let d = n;
|
|
441
|
+
if (!d) {
|
|
442
|
+
c();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
let f = d.value, p = d.selectionStart ?? f.length, m = r(l(f), p);
|
|
446
|
+
if (!m) {
|
|
447
|
+
c();
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
let h = m.kind === "open" ? m.end : m.end - 2, g = e.resolve(i(f.slice(m.start + 2, Math.min(p, h))));
|
|
451
|
+
if (!g) {
|
|
452
|
+
c();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
let _ = s ? g.candidates : g.candidates.filter((e) => (e.filterKey ?? e.segment).startsWith(g.partial));
|
|
456
|
+
if (_.length === 0) {
|
|
457
|
+
c();
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
o = {
|
|
461
|
+
fragment: m,
|
|
462
|
+
partial: g.partial,
|
|
463
|
+
cursor: p
|
|
464
|
+
}, (t.open || a) && (t.items = _, t.activeIndex = 0, t.open = !0, u(), x(u));
|
|
465
|
+
}
|
|
466
|
+
function f(e) {
|
|
467
|
+
let r = n;
|
|
468
|
+
if (!t.open || a || !r || !o) return;
|
|
469
|
+
let i = t.items[e ?? t.activeIndex];
|
|
470
|
+
if (!i) return;
|
|
471
|
+
let s = K(r.value, o.fragment, o.cursor, o.partial, i);
|
|
472
|
+
if (!s) {
|
|
473
|
+
c();
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
r.value = s.value, r.setSelectionRange(s.cursor, s.cursor), r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })), c();
|
|
477
|
+
}
|
|
478
|
+
function p() {
|
|
479
|
+
return j(e.pairing ?? e.enabled);
|
|
480
|
+
}
|
|
481
|
+
function m(e) {
|
|
482
|
+
let t = e.selectionStart;
|
|
483
|
+
return t === null || t !== e.selectionEnd ? null : t;
|
|
484
|
+
}
|
|
485
|
+
let h = !1;
|
|
486
|
+
function g(e) {
|
|
487
|
+
if (h || !p()) return;
|
|
488
|
+
let t = n;
|
|
489
|
+
if (!t) return;
|
|
490
|
+
let r = e.inputType;
|
|
491
|
+
if (r !== void 0 && r !== "" && r !== "insertText") return;
|
|
492
|
+
let i = m(t);
|
|
493
|
+
if (i === null || i < 2) return;
|
|
494
|
+
let a = t.value;
|
|
495
|
+
a.startsWith("{{", i - 2) && (a.includes("}}", i) || (h = !0, t.value = `${a.slice(0, i)}}}${a.slice(i)}`, t.setSelectionRange(i, i), t.dispatchEvent(new Event("input", { bubbles: !0 })), h = !1));
|
|
496
|
+
}
|
|
497
|
+
function _(e) {
|
|
498
|
+
if (!p()) return !1;
|
|
499
|
+
let t = n;
|
|
500
|
+
if (!t) return !1;
|
|
501
|
+
let r = m(t);
|
|
502
|
+
if (r === null || r < 2) return !1;
|
|
503
|
+
let i = t.value;
|
|
504
|
+
return !i.startsWith("{{", r - 2) || !i.startsWith("}}", r) ? !1 : (e.preventDefault(), h = !0, t.value = i.slice(0, r - 2) + i.slice(r + 2), t.setSelectionRange(r - 2, r - 2), t.dispatchEvent(new Event("input", { bubbles: !0 })), h = !1, !0);
|
|
505
|
+
}
|
|
506
|
+
function v(e) {
|
|
507
|
+
if (!p()) return !1;
|
|
508
|
+
let t = n;
|
|
509
|
+
if (!t) return !1;
|
|
510
|
+
let r = m(t);
|
|
511
|
+
return r === null || t.value[r] !== "}" ? !1 : (e.preventDefault(), t.setSelectionRange(r + 1, r + 1), d(!1), !0);
|
|
512
|
+
}
|
|
513
|
+
function y(e) {
|
|
514
|
+
a || e.isComposing || (g(e), d(!0));
|
|
515
|
+
}
|
|
516
|
+
function b() {
|
|
517
|
+
a = !0;
|
|
518
|
+
}
|
|
519
|
+
function S() {
|
|
520
|
+
a = !1, d(!0);
|
|
521
|
+
}
|
|
522
|
+
function C(e) {
|
|
523
|
+
return a || e.isComposing || e.keyCode === 229;
|
|
524
|
+
}
|
|
525
|
+
function E(e) {
|
|
526
|
+
if (!C(e)) {
|
|
527
|
+
if (e.key === " " && (e.ctrlKey || e.metaKey)) {
|
|
528
|
+
e.preventDefault(), d(!0, !0);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (!(e.key === "Backspace" && _(e)) && !(e.key === "}" && v(e)) && t.open) {
|
|
532
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
533
|
+
e.preventDefault();
|
|
534
|
+
let n = t.items.length;
|
|
535
|
+
n > 0 && (t.activeIndex = (t.activeIndex + (e.key === "ArrowDown" ? 1 : n - 1)) % n);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
539
|
+
e.preventDefault(), f();
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
e.key === "Escape" && (e.preventDefault(), c());
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function D(e) {
|
|
547
|
+
t.open && !C(e) && _e.includes(e.key) && d(!1);
|
|
548
|
+
}
|
|
549
|
+
function O() {
|
|
550
|
+
a || d(!1);
|
|
551
|
+
}
|
|
552
|
+
function k() {
|
|
553
|
+
c();
|
|
554
|
+
}
|
|
555
|
+
function A(e) {
|
|
556
|
+
t.open && e.target !== n && c();
|
|
557
|
+
}
|
|
558
|
+
function N() {
|
|
559
|
+
u();
|
|
560
|
+
}
|
|
561
|
+
let P = [
|
|
562
|
+
["input", y],
|
|
563
|
+
["keydown", E],
|
|
564
|
+
["keyup", D],
|
|
565
|
+
["click", O],
|
|
566
|
+
["blur", k],
|
|
567
|
+
["compositionstart", b],
|
|
568
|
+
["compositionend", S]
|
|
569
|
+
];
|
|
570
|
+
function F(e) {
|
|
571
|
+
for (let [t, n] of P) e.addEventListener(t, n);
|
|
572
|
+
}
|
|
573
|
+
function I(e) {
|
|
574
|
+
for (let [t, n] of P) e.removeEventListener(t, n);
|
|
575
|
+
}
|
|
576
|
+
function L(e) {
|
|
577
|
+
n !== e && (n && I(n), n = e, e && F(e));
|
|
578
|
+
}
|
|
579
|
+
return w(() => L(e.target.value)), M(e.target, (e) => L(e)), M(() => j(e.enabled), (e) => {
|
|
580
|
+
e || c();
|
|
581
|
+
}), document.addEventListener("mousedown", A), window.addEventListener("scroll", N, !0), window.addEventListener("resize", N), T(() => {
|
|
582
|
+
n && I(n), document.removeEventListener("mousedown", A), window.removeEventListener("scroll", N, !0), window.removeEventListener("resize", N);
|
|
583
|
+
}), {
|
|
584
|
+
popup: t,
|
|
585
|
+
accept: f
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/shared/useExpressionDiagnostics.ts
|
|
590
|
+
var ye = {
|
|
591
|
+
empty_fragment: "空的表达式片段",
|
|
592
|
+
invalid_path: "非法路径",
|
|
593
|
+
missing_open_paren: "缺少左括号 (",
|
|
594
|
+
unbalanced_paren: "括号不平衡(缺少右括号)",
|
|
595
|
+
unterminated_string: "字符串字面量未闭合",
|
|
596
|
+
empty_arg_slot: "存在空的参数位",
|
|
597
|
+
bad_arg_syntax: "调用实参语法错误",
|
|
598
|
+
trailing_after_call: "调用后有多余内容",
|
|
599
|
+
first_arg_not_path: "首参必须为路径",
|
|
600
|
+
invalid_path_arg: "路径实参不合法",
|
|
601
|
+
resource_not_single_ref: "资源内容必须是单个字段路径,不支持拼接文字",
|
|
602
|
+
resource_function_call: "资源内容不支持函数调用"
|
|
603
|
+
};
|
|
604
|
+
function be(e) {
|
|
605
|
+
let t = e[0];
|
|
606
|
+
if (t === void 0) return "";
|
|
607
|
+
let n = ye[t.kind], r = e.length;
|
|
608
|
+
return r > 1 ? `${r} 处表达式语法错误:${n}` : `表达式语法错误:${n}`;
|
|
609
|
+
}
|
|
610
|
+
var xe = "绑定数据源后可选择字段";
|
|
611
|
+
function Q(e) {
|
|
612
|
+
return e ? "资源内容需为单个字段引用,点击右侧按钮选择数据字段" : "当前内容不是字段引用,绑定数据源后可选择字段";
|
|
613
|
+
}
|
|
614
|
+
function Se(e) {
|
|
615
|
+
let t = k(""), n = null;
|
|
616
|
+
function r() {
|
|
617
|
+
n !== null && (t.value = n.value);
|
|
618
|
+
}
|
|
619
|
+
function i(e) {
|
|
620
|
+
e.isComposing || r();
|
|
621
|
+
}
|
|
622
|
+
function a(e) {
|
|
623
|
+
n !== e && (n !== null && (n.removeEventListener("input", i), n.removeEventListener("compositionend", r)), n = e, e !== null && (e.addEventListener("input", i), e.addEventListener("compositionend", r)), r());
|
|
624
|
+
}
|
|
625
|
+
return w(() => a(e.target.value)), M(e.target, (e) => a(e)), M(() => j(e.enabled), (e) => {
|
|
626
|
+
e || (t.value = "");
|
|
627
|
+
}), T(() => a(null), !0), {
|
|
628
|
+
diagnostics: m(() => j(e.enabled) ? P(t.value) : []),
|
|
629
|
+
refresh: r
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/shared/fontPicker.ts
|
|
634
|
+
var $ = Symbol("canvas-font-picker");
|
|
635
|
+
function Ce() {
|
|
636
|
+
return b($, null);
|
|
637
|
+
}
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/shared/mergeKey.ts
|
|
640
|
+
function we(e, t) {
|
|
641
|
+
return `sel:${e.join(".")}:${t.join(".")}`;
|
|
642
|
+
}
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/shared/uploadFile.ts
|
|
645
|
+
async function Te(e) {
|
|
646
|
+
return {
|
|
647
|
+
name: e.name,
|
|
648
|
+
mime: e.type,
|
|
649
|
+
bytes: new Uint8Array(await e.arrayBuffer())
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
//#endregion
|
|
653
|
+
export { xe as a, Se as c, K as d, pe as f, P as h, Ce as i, ve as l, le as m, we as n, be as o, fe as p, $ as r, Q as s, Te as t, Z as u };
|