@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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -2
  3. package/dist/DropdownMenu-CCvv55NI.js +967 -0
  4. package/dist/PanelIcon-cQ-hx-Ky.js +87 -0
  5. package/dist/Tooltip-BAFJN0xP.js +815 -0
  6. package/dist/canvas/AlignFloatBar.d.ts +6 -0
  7. package/dist/canvas/CanvasSurface.d.ts +13 -0
  8. package/dist/canvas/ContextMenu.d.ts +14 -0
  9. package/dist/canvas/EditOverlayToolbar.d.ts +30 -0
  10. package/dist/canvas/FindBar.d.ts +13 -0
  11. package/dist/canvas/GuidesOverlay.d.ts +19 -0
  12. package/dist/canvas/Ruler.d.ts +32 -0
  13. package/dist/canvas/TextEditingOverlay.d.ts +22 -0
  14. package/dist/canvas/createBand.d.ts +6 -0
  15. package/dist/canvas/findHighlight.d.ts +12 -0
  16. package/dist/canvas/gizmo.d.ts +24 -0
  17. package/dist/canvas/guideSnap.d.ts +5 -0
  18. package/dist/canvas/index.d.ts +24 -0
  19. package/dist/canvas/resizeHandles.d.ts +3 -0
  20. package/dist/canvas/scheduler.d.ts +2 -0
  21. package/dist/canvas/useDpr.d.ts +9 -0
  22. package/dist/canvas/useFindSession.d.ts +12 -0
  23. package/dist/canvas/useTextEditing.d.ts +90 -0
  24. package/dist/canvas-jJ7OaUvZ.js +2171 -0
  25. package/dist/canvas.js +2 -0
  26. package/dist/chevron-down-D0_YGxvV.js +359 -0
  27. package/dist/createLucideIcon-CLd1sc0f.js +140 -0
  28. package/dist/index.d.ts +19 -0
  29. package/dist/index.js +16 -0
  30. package/dist/layer-panel/LayerPanel.d.ts +6 -0
  31. package/dist/layer-panel/TemplateTableForm.d.ts +10 -0
  32. package/dist/layer-panel/addMenu.d.ts +68 -0
  33. package/dist/layer-panel/index.d.ts +11 -0
  34. package/dist/layer-panel/useLayerPanel.d.ts +12 -0
  35. package/dist/layer-panel-DIfOb40N.js +779 -0
  36. package/dist/layer-panel.js +2 -0
  37. package/dist/mergeKey--xr8gdWl.js +694 -0
  38. package/dist/property-panel/PropertyField.d.ts +39 -0
  39. package/dist/property-panel/PropertyPanel.d.ts +5 -0
  40. package/dist/property-panel/controlStyles.d.ts +17 -0
  41. package/dist/property-panel/controls.d.ts +42 -0
  42. package/dist/property-panel/fieldSchema.d.ts +142 -0
  43. package/dist/property-panel/fields/AlignField.d.ts +3 -0
  44. package/dist/property-panel/fields/AnchorDisclosureField.d.ts +3 -0
  45. package/dist/property-panel/fields/BooleanField.d.ts +3 -0
  46. package/dist/property-panel/fields/BorderField.d.ts +3 -0
  47. package/dist/property-panel/fields/BorderWidthInput.d.ts +9 -0
  48. package/dist/property-panel/fields/ColorField.d.ts +3 -0
  49. package/dist/property-panel/fields/FontField.d.ts +3 -0
  50. package/dist/property-panel/fields/ImageSrcField.d.ts +3 -0
  51. package/dist/property-panel/fields/NumberField.d.ts +3 -0
  52. package/dist/property-panel/fields/PaddingField.d.ts +3 -0
  53. package/dist/property-panel/fields/PairField.d.ts +3 -0
  54. package/dist/property-panel/fields/ResourceValueField.d.ts +3 -0
  55. package/dist/property-panel/fields/RowsPathField.d.ts +3 -0
  56. package/dist/property-panel/fields/SelectField.d.ts +3 -0
  57. package/dist/property-panel/fields/ShorthandModeButton.d.ts +7 -0
  58. package/dist/property-panel/fields/TextField.d.ts +3 -0
  59. package/dist/property-panel/fields/TextareaField.d.ts +3 -0
  60. package/dist/property-panel/fields/ValueTypeSegmented.d.ts +8 -0
  61. package/dist/property-panel/fields/index.d.ts +18 -0
  62. package/dist/property-panel/fields/intrinsicSize.d.ts +9 -0
  63. package/dist/property-panel/imageUpload.d.ts +11 -0
  64. package/dist/property-panel/index.d.ts +14 -0
  65. package/dist/property-panel/shorthand.d.ts +28 -0
  66. package/dist/property-panel/usePropertyPanel.d.ts +67 -0
  67. package/dist/property-panel/useShorthandMode.d.ts +17 -0
  68. package/dist/property-panel-DD45Myee.js +1861 -0
  69. package/dist/property-panel.js +3 -0
  70. package/dist/resourceTemplate-B4QRWGq7.js +33 -0
  71. package/dist/shared/DropdownMenu.d.ts +18 -0
  72. package/dist/shared/ExpressionCompletionPopup.d.ts +11 -0
  73. package/dist/shared/ExpressionPathPicker.d.ts +23 -0
  74. package/dist/shared/HelpDialog.d.ts +10 -0
  75. package/dist/shared/PanelIcon.d.ts +11 -0
  76. package/dist/shared/Tooltip.d.ts +11 -0
  77. package/dist/shared/completion.d.ts +73 -0
  78. package/dist/shared/completionAnchor.d.ts +28 -0
  79. package/dist/shared/editableTarget.d.ts +14 -0
  80. package/dist/shared/expressionContext.d.ts +22 -0
  81. package/dist/shared/fontPicker.d.ts +13 -0
  82. package/dist/shared/index.d.ts +42 -0
  83. package/dist/shared/mergeKey.d.ts +2 -0
  84. package/dist/shared/pathPickerModel.d.ts +24 -0
  85. package/dist/shared/popupPosition.d.ts +41 -0
  86. package/dist/shared/resourceTemplate.d.ts +7 -0
  87. package/dist/shared/rowsPathPickerSource.d.ts +15 -0
  88. package/dist/shared/shortcutsHelp.d.ts +30 -0
  89. package/dist/shared/uploadFile.d.ts +2 -0
  90. package/dist/shared/useCnTheme.d.ts +11 -0
  91. package/dist/shared/useDataSourceSchema.d.ts +10 -0
  92. package/dist/shared/useDoc.d.ts +2 -0
  93. package/dist/shared/useDocumentExchange.d.ts +21 -0
  94. package/dist/shared/useDropdownMenu.d.ts +163 -0
  95. package/dist/shared/useExpressionCompletion.d.ts +35 -0
  96. package/dist/shared/useExpressionDiagnostics.d.ts +29 -0
  97. package/dist/shared/useHistory.d.ts +6 -0
  98. package/dist/shared/useSelection.d.ts +2 -0
  99. package/dist/shared/useShortcuts.d.ts +2 -0
  100. package/dist/shared/useShortcutsHelp.d.ts +8 -0
  101. package/dist/shared/useTransientFeedback.d.ts +9 -0
  102. package/dist/shared/useViewport.d.ts +2 -0
  103. package/dist/shared-QI04Xk-a.js +236 -0
  104. package/dist/shared.js +9 -0
  105. package/dist/status-bar/StatusBar.d.ts +14 -0
  106. package/dist/status-bar/index.d.ts +9 -0
  107. package/dist/status-bar/layerGeometryLabel.d.ts +13 -0
  108. package/dist/status-bar/layerPathLabel.d.ts +2 -0
  109. package/dist/status-bar-Bt3TonDm.js +181 -0
  110. package/dist/status-bar.js +2 -0
  111. package/dist/style.css +2 -0
  112. package/dist/theme.css +420 -0
  113. package/dist/useDoc-B2LXNJV7.js +32 -0
  114. package/dist/useViewport-DXtOHYgJ.js +18 -0
  115. package/package.json +83 -3
@@ -0,0 +1,815 @@
1
+ import { o as e } from "./PanelIcon-cQ-hx-Ky.js";
2
+ import { useCallback as t, useEffect as n, useLayoutEffect as r, useRef as i, useState as a } from "react";
3
+ import { createPortal as o } from "react-dom";
4
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
+ //#region ../canvas-editor/src/shared/expressionSchema.ts
6
+ function l(e) {
7
+ let t = e;
8
+ for (; t !== void 0;) {
9
+ if (t.properties !== void 0) return t.properties;
10
+ t = t.items;
11
+ }
12
+ return null;
13
+ }
14
+ function u(e, t) {
15
+ let n = e;
16
+ for (let e of t) {
17
+ let t = l(n)?.get(e);
18
+ if (t === void 0) return null;
19
+ n = t;
20
+ }
21
+ return n;
22
+ }
23
+ function d(e) {
24
+ return e.type === "array" || e.items !== void 0 ? { entries: [] } : { entries: e.properties === void 0 ? [] : [...e.properties].map(([e, t]) => ({
25
+ key: e,
26
+ node: t
27
+ })) };
28
+ }
29
+ function f(e, t) {
30
+ let n = t.split(".");
31
+ return t === "" || n.includes("") ? null : u(e, n)?.items ?? null;
32
+ }
33
+ //#endregion
34
+ //#region ../canvas-editor/src/shared/expressionPath.ts
35
+ function p(e) {
36
+ if (e === "") return {
37
+ ok: !1,
38
+ error: "expression_syntax_error"
39
+ };
40
+ let t = e.split(".");
41
+ if (t.includes("")) return {
42
+ ok: !1,
43
+ error: "expression_syntax_error"
44
+ };
45
+ let n = t[0], r = t.slice(1);
46
+ return n === "row" ? {
47
+ ok: !0,
48
+ head: { kind: "row" },
49
+ rest: r
50
+ } : n === "$root" ? {
51
+ ok: !0,
52
+ head: { kind: "root" },
53
+ rest: r
54
+ } : {
55
+ ok: !0,
56
+ head: {
57
+ kind: "bare",
58
+ name: n
59
+ },
60
+ rest: r
61
+ };
62
+ }
63
+ //#endregion
64
+ //#region ../canvas-editor/src/shared/expressionCall.ts
65
+ var m = " \n\r\0\v", h = " \n\r", g = `()',.${m}`;
66
+ function _(e) {
67
+ let t = 0, n = e.length;
68
+ for (; t < n && m.includes(e[t]);) t += 1;
69
+ for (; n > t && m.includes(e[n - 1]);) --n;
70
+ return e.slice(t, n);
71
+ }
72
+ function v(e, t) {
73
+ for (; t < e.length && h.includes(e[t]);) t += 1;
74
+ return t;
75
+ }
76
+ function y(e, t, n) {
77
+ return {
78
+ ok: !1,
79
+ error: "expression_syntax_error",
80
+ kind: e,
81
+ at: {
82
+ start: t,
83
+ end: n
84
+ }
85
+ };
86
+ }
87
+ function b(e) {
88
+ let t = 0;
89
+ for (; t < e.length && !g.includes(e[t]);) t += 1;
90
+ if (t === 0) return !1;
91
+ let n = t;
92
+ for (; n < e.length && m.includes(e[n]);) n += 1;
93
+ return e[n] === "(";
94
+ }
95
+ function x(e) {
96
+ let t = 0;
97
+ for (; t < e.length && !g.includes(e[t]);) t += 1;
98
+ if (t === 0) return y("invalid_path", 0, e.length);
99
+ let n = e.slice(0, t), r = v(e, t);
100
+ if (r >= e.length || e[r] !== "(") return y("missing_open_paren", t, e.length);
101
+ let i = r;
102
+ r = v(e, r + 1);
103
+ let a = [], o = [];
104
+ if (r < e.length && e[r] === ")") r += 1;
105
+ else for (;;) {
106
+ if (r >= e.length) return y("unbalanced_paren", i, e.length);
107
+ let t = S(e, r);
108
+ if (!t.ok) return t;
109
+ if (a.push(t.value), o.push({
110
+ start: t.start,
111
+ end: t.end
112
+ }), r = v(e, t.end), r >= e.length) return y("unbalanced_paren", i, e.length);
113
+ if (e[r] === ",") {
114
+ let t = r;
115
+ if (r = v(e, r + 1), r < e.length && e[r] === ")") return y("empty_arg_slot", t + 1, r);
116
+ continue;
117
+ }
118
+ if (e[r] === ")") {
119
+ r += 1;
120
+ break;
121
+ }
122
+ return y("bad_arg_syntax", r, r + 1);
123
+ }
124
+ if (r = v(e, r), r !== e.length) return y("trailing_after_call", r, e.length);
125
+ if (a[0] !== void 0 && a[0].type !== "path") {
126
+ let e = o[0];
127
+ return y("first_arg_not_path", e.start, e.end);
128
+ }
129
+ for (let e = 0; e < a.length; e += 1) {
130
+ let t = a[e], n = o[e];
131
+ if (t.type === "path" && !p(t.value).ok) return y("invalid_path_arg", n.start, n.end);
132
+ }
133
+ return {
134
+ ok: !0,
135
+ name: n,
136
+ args: a
137
+ };
138
+ }
139
+ function S(e, t) {
140
+ let n = e.length, r = t, i = e[t];
141
+ if (i === "'") {
142
+ let i = t + 1, a = "";
143
+ for (;;) {
144
+ if (i >= n) return {
145
+ ok: !1,
146
+ error: "expression_syntax_error",
147
+ kind: "unterminated_string",
148
+ at: {
149
+ start: r,
150
+ end: n
151
+ }
152
+ };
153
+ if (e[i] === "'") {
154
+ if (i + 1 < n && e[i + 1] === "'") {
155
+ a += "'", i += 2;
156
+ continue;
157
+ }
158
+ i += 1;
159
+ break;
160
+ }
161
+ a += e[i], i += 1;
162
+ }
163
+ return {
164
+ ok: !0,
165
+ value: {
166
+ type: "string",
167
+ value: a
168
+ },
169
+ start: r,
170
+ end: i
171
+ };
172
+ }
173
+ if (i >= "0" && i <= "9") {
174
+ let i = (t) => {
175
+ let n = e[t];
176
+ return n !== void 0 && n >= "0" && n <= "9";
177
+ };
178
+ for (; i(t);) t += 1;
179
+ if (t < n && e[t] === "." && i(t + 1)) for (t += 1; i(t);) t += 1;
180
+ return {
181
+ ok: !0,
182
+ value: {
183
+ type: "number",
184
+ value: e.slice(r, t)
185
+ },
186
+ start: r,
187
+ end: t
188
+ };
189
+ }
190
+ for (; t < n && e[t] !== "," && e[t] !== ")";) t += 1;
191
+ let a = _(e.slice(r, t));
192
+ return a === "" ? {
193
+ ok: !1,
194
+ error: "expression_syntax_error",
195
+ kind: "empty_arg_slot",
196
+ at: {
197
+ start: r,
198
+ end: t
199
+ }
200
+ } : {
201
+ ok: !0,
202
+ value: {
203
+ type: "path",
204
+ value: a
205
+ },
206
+ start: r,
207
+ end: t
208
+ };
209
+ }
210
+ function C(e) {
211
+ let t = 0;
212
+ for (; t < e.length && !g.includes(e[t]);) t += 1;
213
+ if (t === 0) return null;
214
+ let n = v(e, t);
215
+ if (n >= e.length || e[n] !== "(") return null;
216
+ n = v(e, n + 1);
217
+ let r = 0;
218
+ for (;;) {
219
+ if (n >= e.length) return {
220
+ name: e.slice(0, t),
221
+ index: r,
222
+ text: "",
223
+ stringSlot: !1
224
+ };
225
+ let i = e[n];
226
+ if (i === "'") {
227
+ let i = n + 1;
228
+ for (;;) {
229
+ if (i >= e.length) return {
230
+ name: e.slice(0, t),
231
+ index: r,
232
+ text: e.slice(n + 1),
233
+ stringSlot: !0
234
+ };
235
+ if (e[i] === "'") {
236
+ if (i + 1 < e.length && e[i + 1] === "'") {
237
+ i += 2;
238
+ continue;
239
+ }
240
+ i += 1;
241
+ break;
242
+ }
243
+ i += 1;
244
+ }
245
+ n = i;
246
+ } else if (i !== "," && i !== ")") {
247
+ let i = n;
248
+ for (; n < e.length && e[n] !== "," && e[n] !== ")";) n += 1;
249
+ if (n >= e.length) return {
250
+ name: e.slice(0, t),
251
+ index: r,
252
+ text: _(e.slice(i)),
253
+ stringSlot: !1
254
+ };
255
+ }
256
+ if (n >= e.length) return {
257
+ name: e.slice(0, t),
258
+ index: r + 1,
259
+ text: "",
260
+ stringSlot: !1
261
+ };
262
+ if (e[n] === ")") return null;
263
+ r += 1, n = v(e, n + 1);
264
+ }
265
+ }
266
+ //#endregion
267
+ //#region ../canvas-editor/src/shared/expressionScan.ts
268
+ var w = " \n\r\0\v";
269
+ function T(e) {
270
+ let t = 0, n = e.length;
271
+ for (; t < n && " \n\r\0\v".includes(e[t]);) t += 1;
272
+ for (; n > t && " \n\r\0\v".includes(e[n - 1]);) --n;
273
+ return e.slice(t, n);
274
+ }
275
+ function E(e) {
276
+ if (e === "") return {
277
+ kind: "empty_fragment",
278
+ at: {
279
+ start: 0,
280
+ end: 0
281
+ }
282
+ };
283
+ if (b(e)) {
284
+ let t = x(e);
285
+ return t.ok ? null : {
286
+ kind: t.kind,
287
+ at: t.at
288
+ };
289
+ }
290
+ return p(e).ok ? null : {
291
+ kind: "invalid_path",
292
+ at: {
293
+ start: 0,
294
+ end: e.length
295
+ }
296
+ };
297
+ }
298
+ function D(e) {
299
+ let t = 0;
300
+ for (; t < e.length && " \n\r\0\v".includes(e[t]);) t += 1;
301
+ return t;
302
+ }
303
+ function O(e) {
304
+ let t = [], n = 0, r = e.indexOf("{{");
305
+ for (; r !== -1;) {
306
+ let i = e.indexOf("}}", r + 2);
307
+ if (i === -1) {
308
+ r > n && t.push({
309
+ kind: "literal",
310
+ start: n,
311
+ end: r,
312
+ text: e.slice(n, r)
313
+ });
314
+ let i = e.slice(r);
315
+ return t.push({
316
+ kind: "open",
317
+ start: r,
318
+ end: e.length,
319
+ text: i,
320
+ expr: T(i.slice(2))
321
+ }), {
322
+ template: e,
323
+ parts: t
324
+ };
325
+ }
326
+ r > n && t.push({
327
+ kind: "literal",
328
+ start: n,
329
+ end: r,
330
+ text: e.slice(n, r)
331
+ });
332
+ let a = e.slice(r + 2, i), o = T(a), s = null, c = E(o);
333
+ if (c) {
334
+ let e = r + 2 + D(a);
335
+ s = {
336
+ kind: c.kind,
337
+ start: r,
338
+ end: i + 2,
339
+ at: {
340
+ start: e + c.at.start,
341
+ end: e + c.at.end
342
+ }
343
+ };
344
+ }
345
+ t.push({
346
+ kind: "fragment",
347
+ start: r,
348
+ end: i + 2,
349
+ raw: a,
350
+ expr: o,
351
+ error: s === null ? null : "expression_syntax_error",
352
+ diagnostic: s
353
+ }), n = i + 2, r = e.indexOf("{{", n);
354
+ }
355
+ return n < e.length && t.push({
356
+ kind: "literal",
357
+ start: n,
358
+ end: e.length,
359
+ text: e.slice(n)
360
+ }), {
361
+ template: e,
362
+ parts: t
363
+ };
364
+ }
365
+ function k(e, t) {
366
+ for (let n of e.parts) if (n.kind !== "literal" && (n.kind === "open" ? t > n.start && t <= n.end : t > n.start && t < n.end)) return n;
367
+ return null;
368
+ }
369
+ //#endregion
370
+ //#region ../canvas-editor/src/shared/rowsPathCandidates.ts
371
+ function A(e) {
372
+ return e.type === "array" || e.items !== void 0;
373
+ }
374
+ function j(e) {
375
+ return !A(e) && e.properties === void 0;
376
+ }
377
+ function M(e, t) {
378
+ return e === "" ? t : `${e}.${t}`;
379
+ }
380
+ function N(e, t) {
381
+ return t.description !== void 0 && (e.description = t.description), t.title !== void 0 && (e.title = t.title), e;
382
+ }
383
+ function P(e, t) {
384
+ let n = e;
385
+ for (let e of t) {
386
+ if (A(n)) return null;
387
+ let t = u(n, [e]);
388
+ if (t === null) return null;
389
+ n = t;
390
+ }
391
+ return A(n) || j(n) ? null : n;
392
+ }
393
+ function F(e, t, n) {
394
+ let r = N({
395
+ path: M(n, e),
396
+ segment: e
397
+ }, t);
398
+ return A(t) && (r.type = "array"), r;
399
+ }
400
+ function I(e, t) {
401
+ let n = [];
402
+ if (e.properties !== void 0) for (let [r, i] of e.properties) j(i) || n.push(F(r, i, t));
403
+ return n;
404
+ }
405
+ function L(e, t) {
406
+ if (e === null) return null;
407
+ let n = t.split("."), r = t.endsWith(".") ? "" : n[n.length - 1], i = n.slice(0, -1), a = P(e, i);
408
+ return a === null ? null : {
409
+ partial: r,
410
+ candidates: I(a, i.join("."))
411
+ };
412
+ }
413
+ function R(e) {
414
+ if (A(e)) return !0;
415
+ if (e.properties === void 0) return !1;
416
+ for (let t of e.properties.values()) if (R(t)) return !0;
417
+ return !1;
418
+ }
419
+ function z(e, t, n) {
420
+ return N({
421
+ path: M(n, e),
422
+ segment: e,
423
+ isArray: A(t)
424
+ }, t);
425
+ }
426
+ function B(e, t) {
427
+ if (e === null) return [];
428
+ let n = t === "" ? [] : t.split(".");
429
+ if (n.includes("")) return [];
430
+ let r = P(e, n);
431
+ if (r === null) return [];
432
+ let i = [];
433
+ if (r.properties !== void 0) for (let [e, n] of r.properties) R(n) && i.push(z(e, n, t));
434
+ return i;
435
+ }
436
+ function V(t, n, r) {
437
+ if (r === null) return null;
438
+ if (t === null || n === null) return r;
439
+ let i = null;
440
+ for (let a = 0; a < n.length; a += 1) {
441
+ if (n[a] !== "template") continue;
442
+ let o = e(t, n.slice(0, a));
443
+ if (o === null || o.type !== "TableLayer" || (i = f(i ?? r, o.rowsPath), i === null)) return null;
444
+ }
445
+ return i ?? r;
446
+ }
447
+ //#endregion
448
+ //#region src/shared/rowsPathPickerSource.ts
449
+ var H = "行数组";
450
+ function U(e) {
451
+ return e === null ? null : (t) => ({
452
+ partial: "",
453
+ candidates: B(e, t.endsWith(".") ? t.slice(0, -1) : t).map((e) => ({
454
+ path: e.path,
455
+ segment: e.segment,
456
+ kind: "path",
457
+ ...e.description === void 0 ? {} : { description: e.description },
458
+ ...e.title === void 0 ? {} : { title: e.title },
459
+ ...e.isArray ? { type: "array" } : {}
460
+ }))
461
+ });
462
+ }
463
+ function W(e, t) {
464
+ if (e === null) return !1;
465
+ let n = L(e, t);
466
+ return n === null || !n.candidates.some((e) => e.path === t && e.type === "array");
467
+ }
468
+ //#endregion
469
+ //#region src/shared/pathPickerModel.ts
470
+ function G(e, t, n = "resource") {
471
+ let r = e(t);
472
+ if (r === null) return [];
473
+ let i = [];
474
+ for (let t of r.candidates) t.kind === "path" && t.path !== void 0 && i.push(n === "rowsPath" ? q(t.path, t) : K(e, t.path, t));
475
+ return i;
476
+ }
477
+ function K(e, t, n) {
478
+ let r = J(e, t);
479
+ return {
480
+ path: t,
481
+ item: n,
482
+ drillable: r,
483
+ activatable: !r
484
+ };
485
+ }
486
+ function q(e, t) {
487
+ let n = t.type === "array";
488
+ return {
489
+ path: e,
490
+ item: t,
491
+ drillable: !n,
492
+ activatable: n
493
+ };
494
+ }
495
+ function J(e, t) {
496
+ let n = e(`${t}.`);
497
+ return n !== null && n.candidates.some((e) => e.kind === "path");
498
+ }
499
+ function Y(e) {
500
+ let t = e.lastIndexOf(".");
501
+ return t === -1 ? "" : e.slice(0, t);
502
+ }
503
+ //#endregion
504
+ //#region src/shared/popupPosition.ts
505
+ var X = 4, Z = 4;
506
+ function Q(e) {
507
+ let { anchor: t, popupWidth: n, popupHeight: r, viewportWidth: i, viewportHeight: a } = e, o = e.gap ?? 4, s = e.margin ?? 4, c = t.bottom + o;
508
+ if (r > 0 && c + r > a - s) {
509
+ let e = t.top - o - r;
510
+ c = e >= s ? e : Math.max(s, Math.min(c, a - s - r));
511
+ }
512
+ let l = t.left;
513
+ return n > 0 && (l = Math.max(s, Math.min(l, i - s - n))), {
514
+ top: c,
515
+ left: l
516
+ };
517
+ }
518
+ //#endregion
519
+ //#region src/shared/ExpressionPathPicker.tsx
520
+ function $({ modelValue: e, source: l, disabled: u = !1, ariaLabel: d, placeholder: f, mode: p, className: m, onPick: h }) {
521
+ let g = !u && l !== null, [_, v] = a(!1), [y, b] = a([]), [x, S] = a(0), [C, w] = a(0), [T, E] = a(0), D = i(null), O = i(null), k = i(null), A = y[y.length - 1] ?? null, j = (() => {
522
+ let e = y[y.length - 2];
523
+ return e === void 0 ? "" : e.label === "" ? "根级字段" : e.label;
524
+ })(), M = p === "rowsPath" ? "声明中未发现行数组,请检查数据源绑定" : "无可选字段";
525
+ function N(e) {
526
+ return p === "rowsPath" && e === "array" ? H : e;
527
+ }
528
+ let P = (A?.entries ?? []).map((e) => ({
529
+ entry: e,
530
+ prefix: Y(e.path)
531
+ })), F = t((e, t) => ({
532
+ prefix: e,
533
+ label: t,
534
+ entries: l === null ? [] : G(l, e, p)
535
+ }), [l, p]), I = t(() => {
536
+ if (!_) return;
537
+ let e = D.current;
538
+ if (e === null) return;
539
+ let t = e.getBoundingClientRect(), n = k.current, r = Q({
540
+ anchor: t,
541
+ popupWidth: n?.offsetWidth ?? 0,
542
+ popupHeight: n?.offsetHeight ?? 0,
543
+ viewportWidth: window.innerWidth,
544
+ viewportHeight: window.innerHeight
545
+ });
546
+ w(r.top), E(r.left);
547
+ }, [_]), L = t(() => {
548
+ g && !_ && (b([F("", "")]), S(0), v(!0));
549
+ }, [
550
+ F,
551
+ g,
552
+ _
553
+ ]), R = t(() => {
554
+ _ && (z(), O.current?.focus());
555
+ }, [_]);
556
+ function z() {
557
+ v(!1), b([]), S(0);
558
+ }
559
+ function B() {
560
+ _ ? R() : L();
561
+ }
562
+ function V(e) {
563
+ l !== null && (b((t) => [...t, F(`${e.path}.`, e.path)]), S(0));
564
+ }
565
+ function U() {
566
+ y.length <= 1 || (b((e) => e.slice(0, -1)), S(0));
567
+ }
568
+ function W(e) {
569
+ if (e.drillable) {
570
+ V(e);
571
+ return;
572
+ }
573
+ e.activatable && (h?.(e.path), R());
574
+ }
575
+ function K() {
576
+ return A?.entries[x] ?? null;
577
+ }
578
+ function q(e) {
579
+ if (e.key === "Escape") {
580
+ e.preventDefault(), R();
581
+ return;
582
+ }
583
+ if (e.key === "Tab") {
584
+ R();
585
+ return;
586
+ }
587
+ let t = A?.entries ?? [];
588
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
589
+ e.preventDefault();
590
+ let n = t.length;
591
+ if (n > 0) {
592
+ let t = e.key === "ArrowDown" ? 1 : n - 1;
593
+ S((e) => (e + t) % n);
594
+ }
595
+ return;
596
+ }
597
+ if (e.key === "ArrowRight") {
598
+ let t = K();
599
+ t?.drillable === !0 && (e.preventDefault(), V(t));
600
+ return;
601
+ }
602
+ if (e.key === "ArrowLeft") {
603
+ y.length > 1 && (e.preventDefault(), U());
604
+ return;
605
+ }
606
+ if (e.key === "Enter" || e.key === " ") {
607
+ let t = K();
608
+ t !== null && (e.preventDefault(), W(t));
609
+ }
610
+ }
611
+ n(() => {
612
+ if (!_) return;
613
+ function e(e) {
614
+ let t = e.target;
615
+ t instanceof Node && D.current?.contains(t) !== !0 && k.current?.contains(t) !== !0 && z();
616
+ }
617
+ function t(e) {
618
+ e.key === "Escape" && R();
619
+ }
620
+ function n() {
621
+ I();
622
+ }
623
+ return window.addEventListener("pointerdown", e), window.addEventListener("keydown", t), window.addEventListener("scroll", n, !0), window.addEventListener("resize", n), () => {
624
+ window.removeEventListener("pointerdown", e), window.removeEventListener("keydown", t), window.removeEventListener("scroll", n, !0), window.removeEventListener("resize", n);
625
+ };
626
+ }, [_, I]), r(() => {
627
+ _ && I();
628
+ }, [
629
+ _,
630
+ y,
631
+ I
632
+ ]), n(() => {
633
+ _ && k.current?.focus();
634
+ }, [_]);
635
+ let J = d === void 0 ? "选择字段路径" : `选择字段路径(${d})`, X = d === void 0 ? "字段路径菜单" : `${d} 字段路径菜单`;
636
+ return /* @__PURE__ */ c("div", {
637
+ ref: D,
638
+ className: `cn-pathpicker flex w-full items-center gap-1.5${m === void 0 ? "" : ` ${m}`}`,
639
+ children: [
640
+ /* @__PURE__ */ s("div", {
641
+ className: "cn-pathpicker__value min-w-0 flex-1 truncate rounded-md border border-cn-field-line bg-cn-field px-2 py-1.5 font-mono text-[11px] leading-none text-cn-fg",
642
+ "aria-label": d,
643
+ title: e,
644
+ children: e === "" ? f ?? "点击右侧按钮选择字段" : e
645
+ }),
646
+ g && /* @__PURE__ */ s("button", {
647
+ ref: O,
648
+ type: "button",
649
+ className: "cn-pathpicker__toggle h-7 shrink-0 rounded-md border border-cn-field-line bg-cn-field px-1.5 text-[11px] leading-none text-cn-muted transition-colors duration-100 hover:border-cn-muted/40 hover:text-cn-fg",
650
+ "aria-haspopup": "menu",
651
+ "aria-expanded": _,
652
+ "aria-label": J,
653
+ title: "选择字段路径",
654
+ onClick: B,
655
+ children: "▾"
656
+ }),
657
+ _ && A !== null && o(/* @__PURE__ */ c("div", {
658
+ ref: k,
659
+ className: "cn-props cn-pathpicker__menu fixed z-50 max-h-[240px] min-w-[180px] max-w-[280px] overflow-y-auto rounded-md border border-cn-field-line py-1 text-[11px] leading-none",
660
+ style: {
661
+ top: `${C}px`,
662
+ left: `${T}px`
663
+ },
664
+ role: "menu",
665
+ "aria-label": X,
666
+ tabIndex: -1,
667
+ onKeyDown: (e) => {
668
+ e.stopPropagation(), q(e);
669
+ },
670
+ onPointerDown: (e) => {
671
+ e.stopPropagation();
672
+ },
673
+ children: [
674
+ y.length > 1 && /* @__PURE__ */ c("button", {
675
+ type: "button",
676
+ role: "menuitem",
677
+ className: "cn-pathpicker__back flex w-full items-center gap-1 border-b border-cn-line/70 px-2 py-1.5 text-left text-cn-muted",
678
+ onClick: U,
679
+ children: [/* @__PURE__ */ s("span", {
680
+ "aria-hidden": "true",
681
+ children: "‹"
682
+ }), /* @__PURE__ */ s("span", {
683
+ className: "truncate font-mono",
684
+ children: j
685
+ })]
686
+ }),
687
+ A.entries.length === 0 && /* @__PURE__ */ s("div", {
688
+ className: "cn-pathpicker__empty px-2 py-2 text-cn-muted",
689
+ children: M
690
+ }),
691
+ P.map((e, t) => /* @__PURE__ */ c("button", {
692
+ type: "button",
693
+ role: "menuitem",
694
+ className: t === x ? "cn-pathpicker__option cn-pathpicker__option--active flex w-full items-center gap-1.5 px-2 py-1.5 text-left" : "cn-pathpicker__option flex w-full items-center gap-1.5 px-2 py-1.5 text-left",
695
+ "aria-label": e.entry.path,
696
+ title: e.entry.path,
697
+ onClick: () => W(e.entry),
698
+ onMouseMove: () => S(t),
699
+ children: [
700
+ e.prefix !== "" && /* @__PURE__ */ c("span", {
701
+ className: "cn-pathpicker__prefix min-w-0 truncate font-mono text-cn-muted",
702
+ children: [
703
+ e.prefix,
704
+ " ",
705
+ "›"
706
+ ]
707
+ }),
708
+ /* @__PURE__ */ s("span", {
709
+ className: e.prefix === "" ? "cn-pathpicker__segment min-w-0 truncate font-mono text-cn-fg" : "cn-pathpicker__segment max-w-full shrink-0 truncate font-mono text-cn-fg",
710
+ children: e.entry.item.segment
711
+ }),
712
+ e.entry.item.type !== void 0 && /* @__PURE__ */ s("span", {
713
+ className: "shrink-0 rounded-sm bg-cn-field px-1 py-0.5 text-[9px] leading-none text-cn-muted",
714
+ children: N(e.entry.item.type)
715
+ }),
716
+ (e.entry.item.description ?? e.entry.item.title) !== void 0 && /* @__PURE__ */ s("span", {
717
+ className: "min-w-0 flex-1 truncate text-[10px] leading-none text-cn-muted",
718
+ children: e.entry.item.description ?? e.entry.item.title
719
+ }),
720
+ e.entry.drillable && /* @__PURE__ */ s("span", {
721
+ className: "cn-pathpicker__drill ml-auto shrink-0 text-cn-muted",
722
+ "aria-hidden": "true",
723
+ children: "›"
724
+ })
725
+ ]
726
+ }, e.entry.path))
727
+ ]
728
+ }), document.body)
729
+ ]
730
+ });
731
+ }
732
+ //#endregion
733
+ //#region src/shared/Tooltip.tsx
734
+ var ee = 300, te = 0;
735
+ function ne({ label: e, delay: t = ee, className: l, children: u }) {
736
+ let d = i(null), f = i(null), [p, m] = a(!1), [h, g] = a({
737
+ top: 0,
738
+ left: 0
739
+ }), _ = i(`cn-tooltip-${++te}`).current, v = i(null);
740
+ function y() {
741
+ v.current !== null && (clearTimeout(v.current), v.current = null);
742
+ }
743
+ function b() {
744
+ return d.current?.firstElementChild ?? null;
745
+ }
746
+ function x() {
747
+ let e = d.current?.getBoundingClientRect();
748
+ e && g(Q({
749
+ anchor: {
750
+ top: e.top,
751
+ bottom: e.bottom,
752
+ left: e.left
753
+ },
754
+ popupWidth: 0,
755
+ popupHeight: 0,
756
+ viewportWidth: window.innerWidth,
757
+ viewportHeight: window.innerHeight
758
+ })), m(!0), b()?.setAttribute("aria-describedby", _);
759
+ }
760
+ function S() {
761
+ y(), m((e) => e && (b()?.removeAttribute("aria-describedby"), !1));
762
+ }
763
+ function C() {
764
+ y(), v.current = setTimeout(() => {
765
+ v.current = null, x();
766
+ }, t);
767
+ }
768
+ function w() {
769
+ y(), x();
770
+ }
771
+ r(() => {
772
+ if (!p) return;
773
+ let e = d.current?.getBoundingClientRect(), t = f.current?.getBoundingClientRect();
774
+ e !== void 0 && t !== void 0 && g(Q({
775
+ anchor: {
776
+ top: e.top,
777
+ bottom: e.bottom,
778
+ left: e.left
779
+ },
780
+ popupWidth: t.width,
781
+ popupHeight: t.height,
782
+ viewportWidth: window.innerWidth,
783
+ viewportHeight: window.innerHeight
784
+ }));
785
+ }, [p]), n(() => y, []);
786
+ function T(e) {
787
+ S();
788
+ }
789
+ function E(e) {
790
+ C();
791
+ }
792
+ return /* @__PURE__ */ c("div", {
793
+ ref: d,
794
+ className: l === void 0 ? "cn-tooltip" : `cn-tooltip ${l}`,
795
+ onMouseEnter: E,
796
+ onMouseLeave: S,
797
+ onFocus: w,
798
+ onBlur: S,
799
+ onPointerDownCapture: T,
800
+ children: [u, p && o(/* @__PURE__ */ s("div", {
801
+ id: _,
802
+ ref: f,
803
+ role: "tooltip",
804
+ className: "cn-tooltip__bubble",
805
+ "data-tooltip": "",
806
+ style: {
807
+ top: `${h.top}px`,
808
+ left: `${h.left}px`
809
+ },
810
+ children: e
811
+ }), document.body)]
812
+ });
813
+ }
814
+ //#endregion
815
+ export { f as _, Q as a, W as c, k as d, T as f, p as g, b as h, Z as i, V as l, C as m, $ as n, G as o, O as p, X as r, U as s, ne as t, w as u, d as v, u as y };