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