@hankchen/canvas-editor-vue 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{canvas-DqQislJ_.js → canvas-CX1RdlFC.js} +3 -3
- package/dist/canvas.js +1 -1
- package/dist/index.js +15 -15
- package/dist/layer-panel/LayerPanel.d.ts +1 -27
- package/dist/layer-panel/TemplateTableForm.d.ts +38 -0
- package/dist/layer-panel/addMenu.d.ts +56 -12
- package/dist/layer-panel/index.d.ts +7 -3
- package/dist/{layer-panel-DskyCgF5.js → layer-panel-Cd1e8xNB.js} +341 -255
- package/dist/layer-panel.js +2 -2
- package/dist/shared/index.d.ts +9 -2
- package/dist/shared/shortcutsHelp.d.ts +4 -1
- package/dist/shared/useDropdownMenu.d.ts +107 -2
- package/dist/shared.js +1 -1
- package/dist/{status-bar-_PvEXyq8.js → status-bar-XMVbRLY9.js} +1 -1
- package/dist/status-bar.js +1 -1
- package/dist/style.css +1 -1
- package/dist/useDataSourceSchema-YV8g-lo0.js +458 -0
- package/package.json +2 -2
- package/dist/useDataSourceSchema-CGbldbUj.js +0 -237
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { n as e, u as t } from "./useTransientFeedback-CTjmMmFF.js";
|
|
2
|
+
import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, mergeProps as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onScopeDispose as p, openBlock as m, ref as h, renderList as g, renderSlot as _, shallowRef as v, toDisplayString as y, unref as b, watch as x, withModifiers as ee } from "vue";
|
|
3
|
+
//#region src/shared/useDropdownMenu.ts
|
|
4
|
+
function S(e) {
|
|
5
|
+
return e !== "separator" && "kind" in e && e.kind === "submenu";
|
|
6
|
+
}
|
|
7
|
+
function C(e) {
|
|
8
|
+
let t = h(!1);
|
|
9
|
+
function n(n) {
|
|
10
|
+
let r = e.container.value, i = n.target;
|
|
11
|
+
r !== null && i instanceof Node && r.contains(i) || (t.value = !1);
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
e.key === "Escape" && (t.value = !1);
|
|
15
|
+
}
|
|
16
|
+
function i() {
|
|
17
|
+
window.removeEventListener("pointerdown", n), window.removeEventListener("keydown", r);
|
|
18
|
+
}
|
|
19
|
+
return x(t, (e) => {
|
|
20
|
+
e ? (window.addEventListener("pointerdown", n), window.addEventListener("keydown", r)) : i();
|
|
21
|
+
}), p(i, !0), {
|
|
22
|
+
open: t,
|
|
23
|
+
toggle: () => {
|
|
24
|
+
t.value = !t.value;
|
|
25
|
+
},
|
|
26
|
+
openMenu: () => {
|
|
27
|
+
t.value = !0;
|
|
28
|
+
},
|
|
29
|
+
closeMenu: () => {
|
|
30
|
+
t.value = !1;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function w(e, t, n) {
|
|
35
|
+
let r = e.length;
|
|
36
|
+
if (r === 0) return -1;
|
|
37
|
+
if (n === "Home" || n === "End") {
|
|
38
|
+
for (let t = 0; t < r; t++) {
|
|
39
|
+
let i = n === "Home" ? t : r - 1 - t;
|
|
40
|
+
if (e[i]) return i;
|
|
41
|
+
}
|
|
42
|
+
return -1;
|
|
43
|
+
}
|
|
44
|
+
let i = n === "ArrowDown" ? 1 : -1, a = t === -1 ? i === 1 ? -1 : r : t;
|
|
45
|
+
for (let t = 0; t < r; t++) if (a = (a + i + r) % r, e[a]) return a;
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
48
|
+
function T(e, t) {
|
|
49
|
+
return t.type === "close" || t.target === void 0 ? null : t.type === "open" ? t.target : e === t.target ? null : t.target;
|
|
50
|
+
}
|
|
51
|
+
function te(e) {
|
|
52
|
+
let { anchor: t, flyoutWidth: n, flyoutHeight: r, viewportWidth: i, viewportHeight: a } = e, o = e.gap ?? 6, s = e.margin ?? 2, c = n > 0 && t.right + o + n > i - s ? "left" : "right", l = c === "right" ? t.right + o : t.left - o - n;
|
|
53
|
+
n > 0 && (l = Math.max(s, Math.min(l, i - s - n)));
|
|
54
|
+
let u = t.top;
|
|
55
|
+
return r > 0 && (u = Math.max(s, Math.min(u, a - s - r))), {
|
|
56
|
+
left: l,
|
|
57
|
+
top: u,
|
|
58
|
+
side: c
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function ne(e) {
|
|
62
|
+
return e === "ArrowDown" || e === "ArrowUp" || e === "Home" || e === "End" ? {
|
|
63
|
+
type: "move",
|
|
64
|
+
key: e
|
|
65
|
+
} : e === "ArrowLeft" || e === "Escape" ? { type: "close" } : e === "Enter" || e === " " ? { type: "activate" } : e === "Tab" ? { type: "close-menu" } : { type: "none" };
|
|
66
|
+
}
|
|
67
|
+
function E(e, t) {
|
|
68
|
+
return e.find((e) => !e.hasAttribute("disabled")) ?? t;
|
|
69
|
+
}
|
|
70
|
+
function D(e) {
|
|
71
|
+
return e?.closest("[data-dropdown-submenu-host]")?.querySelector("[data-dropdown-submenu-arrow]") ?? null;
|
|
72
|
+
}
|
|
73
|
+
function O(e) {
|
|
74
|
+
return e;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/shared/DropdownMenu.vue?vue&type=script&setup=true&lang.ts
|
|
78
|
+
var re = ["aria-expanded", "title"], ie = ["aria-label"], ae = {
|
|
79
|
+
key: 0,
|
|
80
|
+
class: "cn-dropdown__separator",
|
|
81
|
+
role: "separator",
|
|
82
|
+
"data-dropdown-separator": "",
|
|
83
|
+
"aria-hidden": "true"
|
|
84
|
+
}, oe = {
|
|
85
|
+
key: 1,
|
|
86
|
+
class: "cn-dropdown__submenu-host",
|
|
87
|
+
"data-dropdown-submenu-host": ""
|
|
88
|
+
}, se = [
|
|
89
|
+
"disabled",
|
|
90
|
+
"title",
|
|
91
|
+
"onClick"
|
|
92
|
+
], ce = { class: "cn-dropdown__item-label" }, le = {
|
|
93
|
+
key: 0,
|
|
94
|
+
class: "cn-dropdown__shortcut"
|
|
95
|
+
}, ue = [
|
|
96
|
+
"disabled",
|
|
97
|
+
"title",
|
|
98
|
+
"aria-expanded",
|
|
99
|
+
"onClick",
|
|
100
|
+
"onMouseenter"
|
|
101
|
+
], de = ["aria-label"], fe = {
|
|
102
|
+
key: 0,
|
|
103
|
+
class: "cn-dropdown__separator",
|
|
104
|
+
role: "separator",
|
|
105
|
+
"data-dropdown-submenu-separator": "",
|
|
106
|
+
"aria-hidden": "true"
|
|
107
|
+
}, pe = [
|
|
108
|
+
"disabled",
|
|
109
|
+
"title",
|
|
110
|
+
"onClick"
|
|
111
|
+
], me = { class: "cn-dropdown__item-label" }, he = {
|
|
112
|
+
key: 0,
|
|
113
|
+
class: "cn-dropdown__shortcut"
|
|
114
|
+
}, ge = [
|
|
115
|
+
"disabled",
|
|
116
|
+
"title",
|
|
117
|
+
"onClick"
|
|
118
|
+
], _e = { class: "cn-dropdown__item-label" }, ve = {
|
|
119
|
+
key: 0,
|
|
120
|
+
class: "cn-dropdown__shortcut"
|
|
121
|
+
}, k = 6, A = 2, j = /*#__PURE__*/ t(/* @__PURE__ */ c({
|
|
122
|
+
__name: "DropdownMenu",
|
|
123
|
+
props: {
|
|
124
|
+
label: {},
|
|
125
|
+
items: {},
|
|
126
|
+
title: {},
|
|
127
|
+
direction: { default: "down" }
|
|
128
|
+
},
|
|
129
|
+
emits: ["closed"],
|
|
130
|
+
setup(t, { emit: r }) {
|
|
131
|
+
let c = t, p = r, j = h(null), M = h(null), N = h(null), { open: P, toggle: F, closeMenu: I } = C({ container: j }), L = v(null), R = h({
|
|
132
|
+
left: 0,
|
|
133
|
+
top: 0,
|
|
134
|
+
side: "right"
|
|
135
|
+
});
|
|
136
|
+
x(P, (e) => {
|
|
137
|
+
e || (L.value = null, p("closed"));
|
|
138
|
+
});
|
|
139
|
+
let z = h({
|
|
140
|
+
left: 0,
|
|
141
|
+
edge: "top",
|
|
142
|
+
offset: 0
|
|
143
|
+
});
|
|
144
|
+
function B() {
|
|
145
|
+
O(M.value)?.focus();
|
|
146
|
+
}
|
|
147
|
+
function V(e) {
|
|
148
|
+
M.value = e instanceof HTMLElement ? e : null;
|
|
149
|
+
}
|
|
150
|
+
async function H() {
|
|
151
|
+
if (await u(), !P.value) return;
|
|
152
|
+
let e = N.value;
|
|
153
|
+
e !== null && E(K(), e).focus();
|
|
154
|
+
}
|
|
155
|
+
function U() {
|
|
156
|
+
return c.items.filter((e) => e !== "separator");
|
|
157
|
+
}
|
|
158
|
+
function ye() {
|
|
159
|
+
return U().filter(S);
|
|
160
|
+
}
|
|
161
|
+
function be() {
|
|
162
|
+
return Array.from(N.value?.querySelectorAll("[data-dropdown-submenu-host]") ?? []);
|
|
163
|
+
}
|
|
164
|
+
function W() {
|
|
165
|
+
return N.value?.querySelector("[data-dropdown-submenu]") ?? null;
|
|
166
|
+
}
|
|
167
|
+
function G() {
|
|
168
|
+
return Array.from(W()?.querySelectorAll("[data-dropdown-submenu-item]") ?? []);
|
|
169
|
+
}
|
|
170
|
+
function K() {
|
|
171
|
+
return Array.from(N.value?.querySelectorAll("[data-dropdown-item]") ?? []);
|
|
172
|
+
}
|
|
173
|
+
function q(e) {
|
|
174
|
+
e.run(), (S(e) || e.keepsOpen !== !0) && (I(), B());
|
|
175
|
+
}
|
|
176
|
+
function xe(e) {
|
|
177
|
+
let t = N.value;
|
|
178
|
+
if (t === null) return;
|
|
179
|
+
let n = K(), r = w(n.map((e) => !e.hasAttribute("disabled")), document.activeElement instanceof HTMLElement ? n.indexOf(document.activeElement) : -1, e);
|
|
180
|
+
if (r === -1) {
|
|
181
|
+
t.focus();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
n[r]?.focus();
|
|
185
|
+
}
|
|
186
|
+
function Se(e) {
|
|
187
|
+
let t = U()[K().indexOf(e)];
|
|
188
|
+
t !== void 0 && !t.disabled && q(t);
|
|
189
|
+
}
|
|
190
|
+
function Ce(t) {
|
|
191
|
+
let n = t.key, r = t.target;
|
|
192
|
+
if (r instanceof HTMLElement && r.matches("[data-dropdown-submenu-item]")) {
|
|
193
|
+
let e = ne(n);
|
|
194
|
+
if (e.type === "move") {
|
|
195
|
+
t.preventDefault(), Y(e.key);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (e.type === "close") {
|
|
199
|
+
t.preventDefault(), J();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (e.type === "activate") {
|
|
203
|
+
t.preventDefault(), Te(r);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (e.type === "close-menu") {
|
|
207
|
+
I(), B();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (n === "Escape") {
|
|
213
|
+
if (L.value !== null) {
|
|
214
|
+
J();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
I(), B();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (n === "Tab") {
|
|
221
|
+
if (r instanceof HTMLElement && !r.matches("[data-dropdown-item]") && e(r)) return;
|
|
222
|
+
I(), B();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (n === "Enter" || n === " ") {
|
|
226
|
+
r instanceof HTMLElement && r.matches("[data-dropdown-item]") && (t.preventDefault(), Se(r));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (n === "ArrowDown" || n === "ArrowUp" || n === "Home" || n === "End") {
|
|
230
|
+
if (r instanceof HTMLElement && !r.matches("[data-dropdown-item]") && e(r)) return;
|
|
231
|
+
t.preventDefault(), xe(n);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (n === "ArrowRight") {
|
|
235
|
+
let e = r instanceof HTMLElement ? r.closest("[data-dropdown-submenu-host]") : null;
|
|
236
|
+
if (e !== null) {
|
|
237
|
+
let n = ye()[be().indexOf(e)];
|
|
238
|
+
n !== void 0 && (t.preventDefault(), we(n, e));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async function we(e, t) {
|
|
243
|
+
if (e.disabled === !0 || (L.value = T(L.value, {
|
|
244
|
+
type: "open",
|
|
245
|
+
target: e
|
|
246
|
+
}), await $(t.querySelector("[data-dropdown-submenu-arrow]")), L.value !== e || !P.value)) return;
|
|
247
|
+
let n = W();
|
|
248
|
+
n !== null && E(G(), n).focus();
|
|
249
|
+
}
|
|
250
|
+
function J() {
|
|
251
|
+
let e = D(document.activeElement instanceof HTMLElement ? document.activeElement : null);
|
|
252
|
+
L.value = null, e?.focus();
|
|
253
|
+
}
|
|
254
|
+
function Y(e) {
|
|
255
|
+
let t = W();
|
|
256
|
+
if (t === null) return;
|
|
257
|
+
let n = G(), r = w(n.map((e) => !e.hasAttribute("disabled")), document.activeElement instanceof HTMLElement ? n.indexOf(document.activeElement) : -1, e);
|
|
258
|
+
if (r === -1) {
|
|
259
|
+
t.focus();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
n[r]?.focus();
|
|
263
|
+
}
|
|
264
|
+
function Te(e) {
|
|
265
|
+
let t = L.value;
|
|
266
|
+
if (t === null) return;
|
|
267
|
+
let n = Array.from(W()?.querySelectorAll("[data-dropdown-submenu-item]") ?? []), r = t.children.filter((e) => e !== "separator")[n.indexOf(e)];
|
|
268
|
+
r !== void 0 && !r.disabled && q(r);
|
|
269
|
+
}
|
|
270
|
+
function X(e) {
|
|
271
|
+
if (e.key === "ArrowDown") {
|
|
272
|
+
if (e.preventDefault(), !P.value) {
|
|
273
|
+
Z();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
H();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function Z() {
|
|
280
|
+
if (!P.value) {
|
|
281
|
+
let e = M.value?.getBoundingClientRect();
|
|
282
|
+
e && (z.value = c.direction === "up" ? {
|
|
283
|
+
left: e.left,
|
|
284
|
+
edge: "bottom",
|
|
285
|
+
offset: window.innerHeight - e.top + k
|
|
286
|
+
} : {
|
|
287
|
+
left: e.left,
|
|
288
|
+
edge: "top",
|
|
289
|
+
offset: e.bottom + k
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (F(), !P.value) {
|
|
293
|
+
B();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
await u();
|
|
297
|
+
let e = N.value?.getBoundingClientRect();
|
|
298
|
+
if (!e) return;
|
|
299
|
+
let t = z.value;
|
|
300
|
+
z.value = {
|
|
301
|
+
left: Math.max(A, Math.min(t.left, window.innerWidth - e.width - A)),
|
|
302
|
+
edge: t.edge,
|
|
303
|
+
offset: Math.max(A, Math.min(t.offset, window.innerHeight - e.height - A))
|
|
304
|
+
}, H();
|
|
305
|
+
}
|
|
306
|
+
function Q(e) {
|
|
307
|
+
return e.currentTarget instanceof HTMLElement ? e.currentTarget : null;
|
|
308
|
+
}
|
|
309
|
+
async function $(e) {
|
|
310
|
+
let t = L.value;
|
|
311
|
+
if (t === null || e === null) return;
|
|
312
|
+
let n = e.getBoundingClientRect();
|
|
313
|
+
if (R.value = {
|
|
314
|
+
left: n.right + 6,
|
|
315
|
+
top: n.top,
|
|
316
|
+
side: "right"
|
|
317
|
+
}, await u(), L.value !== t) return;
|
|
318
|
+
let r = W(), i = r?.getBoundingClientRect();
|
|
319
|
+
r !== null && i !== void 0 && i.width !== 0 && (R.value = te({
|
|
320
|
+
anchor: {
|
|
321
|
+
top: n.top,
|
|
322
|
+
bottom: n.bottom,
|
|
323
|
+
left: n.left,
|
|
324
|
+
right: n.right
|
|
325
|
+
},
|
|
326
|
+
flyoutWidth: i.width,
|
|
327
|
+
flyoutHeight: i.height,
|
|
328
|
+
viewportWidth: window.innerWidth,
|
|
329
|
+
viewportHeight: window.innerHeight
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
function Ee(e, t) {
|
|
333
|
+
t.disabled !== !0 && (L.value = T(L.value, {
|
|
334
|
+
type: "open",
|
|
335
|
+
target: t
|
|
336
|
+
}), $(Q(e)));
|
|
337
|
+
}
|
|
338
|
+
function De(e, t) {
|
|
339
|
+
t.disabled !== !0 && (L.value = T(L.value, {
|
|
340
|
+
type: "toggle",
|
|
341
|
+
target: t
|
|
342
|
+
}), $(Q(e)));
|
|
343
|
+
}
|
|
344
|
+
function Oe() {
|
|
345
|
+
L.value = null;
|
|
346
|
+
}
|
|
347
|
+
return (e, r) => (m(), a("div", {
|
|
348
|
+
ref_key: "container",
|
|
349
|
+
ref: j,
|
|
350
|
+
class: "cn-dropdown",
|
|
351
|
+
onMouseleave: Oe
|
|
352
|
+
}, [_(e.$slots, "trigger", {
|
|
353
|
+
open: b(P),
|
|
354
|
+
toggle: Z,
|
|
355
|
+
closeMenu: b(I),
|
|
356
|
+
triggerRef: V,
|
|
357
|
+
onKeydown: X
|
|
358
|
+
}, () => [o("button", {
|
|
359
|
+
ref: V,
|
|
360
|
+
type: "button",
|
|
361
|
+
class: "cn-dropdown__trigger",
|
|
362
|
+
"data-dropdown-trigger": "",
|
|
363
|
+
"aria-haspopup": "menu",
|
|
364
|
+
"aria-expanded": b(P),
|
|
365
|
+
title: t.title ?? t.label,
|
|
366
|
+
onClick: r[0] ||= (e) => Z(),
|
|
367
|
+
onKeydown: X
|
|
368
|
+
}, [s(y(t.label) + " ", 1), r[2] ||= o("span", {
|
|
369
|
+
class: "cn-dropdown__caret",
|
|
370
|
+
"aria-hidden": "true"
|
|
371
|
+
}, "▾", -1)], 40, re)], !0), b(P) ? (m(), a("div", {
|
|
372
|
+
key: 0,
|
|
373
|
+
ref_key: "menuEl",
|
|
374
|
+
ref: N,
|
|
375
|
+
class: "cn-dropdown__menu",
|
|
376
|
+
role: "menu",
|
|
377
|
+
"aria-label": t.label,
|
|
378
|
+
"data-dropdown-menu": "",
|
|
379
|
+
tabindex: "-1",
|
|
380
|
+
style: f(z.value.edge === "top" ? {
|
|
381
|
+
left: `${z.value.left}px`,
|
|
382
|
+
top: `${z.value.offset}px`
|
|
383
|
+
} : {
|
|
384
|
+
left: `${z.value.left}px`,
|
|
385
|
+
bottom: `${z.value.offset}px`
|
|
386
|
+
}),
|
|
387
|
+
onKeydown: r[1] ||= ee((e) => Ce(e), ["stop"])
|
|
388
|
+
}, [(m(!0), a(n, null, g(t.items, (e, t) => (m(), a(n, { key: t }, [e === "separator" ? (m(), a("div", ae)) : b(S)(e) ? (m(), a("div", oe, [
|
|
389
|
+
o("button", l({
|
|
390
|
+
type: "button",
|
|
391
|
+
role: "menuitem",
|
|
392
|
+
class: "cn-dropdown__item cn-dropdown__submenu-main",
|
|
393
|
+
"data-dropdown-item": "",
|
|
394
|
+
tabindex: "-1",
|
|
395
|
+
disabled: e.disabled,
|
|
396
|
+
title: e.title
|
|
397
|
+
}, { ref_for: !0 }, e.dataAttrs, { onClick: (t) => q(e) }), [o("span", ce, y(e.label), 1), e.shortcut ? (m(), a("span", le, y(e.shortcut), 1)) : i("", !0)], 16, se),
|
|
398
|
+
o("button", {
|
|
399
|
+
type: "button",
|
|
400
|
+
class: "cn-dropdown__submenu-arrow",
|
|
401
|
+
"data-dropdown-submenu-arrow": "",
|
|
402
|
+
tabindex: "-1",
|
|
403
|
+
disabled: e.disabled,
|
|
404
|
+
title: e.title,
|
|
405
|
+
"aria-haspopup": "menu",
|
|
406
|
+
"aria-expanded": L.value === e,
|
|
407
|
+
onClick: (t) => De(t, e),
|
|
408
|
+
onMouseenter: (t) => Ee(t, e)
|
|
409
|
+
}, [...r[3] ||= [o("span", { "aria-hidden": "true" }, "▸", -1)]], 40, ue),
|
|
410
|
+
L.value === e ? (m(), a("div", {
|
|
411
|
+
key: 0,
|
|
412
|
+
class: d(["cn-dropdown__submenu", { "cn-dropdown__submenu--left": R.value.side === "left" }]),
|
|
413
|
+
role: "menu",
|
|
414
|
+
"aria-label": e.label,
|
|
415
|
+
"data-dropdown-submenu": "",
|
|
416
|
+
tabindex: "-1",
|
|
417
|
+
style: f({
|
|
418
|
+
left: `${R.value.left}px`,
|
|
419
|
+
top: `${R.value.top}px`
|
|
420
|
+
})
|
|
421
|
+
}, [(m(!0), a(n, null, g(e.children, (e, t) => (m(), a(n, { key: t }, [e === "separator" ? (m(), a("div", fe)) : (m(), a("button", l({
|
|
422
|
+
key: 1,
|
|
423
|
+
type: "button",
|
|
424
|
+
role: "menuitem",
|
|
425
|
+
class: "cn-dropdown__item",
|
|
426
|
+
"data-dropdown-submenu-item": "",
|
|
427
|
+
tabindex: "-1",
|
|
428
|
+
disabled: e.disabled,
|
|
429
|
+
title: e.title
|
|
430
|
+
}, { ref_for: !0 }, e.dataAttrs, { onClick: (t) => q(e) }), [o("span", me, y(e.label), 1), e.shortcut ? (m(), a("span", he, y(e.shortcut), 1)) : i("", !0)], 16, pe))], 64))), 128))], 14, de)) : i("", !0)
|
|
431
|
+
])) : (m(), a("button", l({
|
|
432
|
+
key: 2,
|
|
433
|
+
type: "button",
|
|
434
|
+
role: "menuitem",
|
|
435
|
+
class: "cn-dropdown__item",
|
|
436
|
+
"data-dropdown-item": "",
|
|
437
|
+
tabindex: "-1",
|
|
438
|
+
disabled: e.disabled,
|
|
439
|
+
title: e.title
|
|
440
|
+
}, { ref_for: !0 }, e.dataAttrs, { onClick: (t) => q(e) }), [o("span", _e, y(e.label), 1), e.shortcut ? (m(), a("span", ve, y(e.shortcut), 1)) : i("", !0)], 16, ge))], 64))), 128)), _(e.$slots, "body", {
|
|
441
|
+
open: b(P),
|
|
442
|
+
toggle: Z,
|
|
443
|
+
closeMenu: b(I),
|
|
444
|
+
triggerRef: V,
|
|
445
|
+
onKeydown: X
|
|
446
|
+
}, void 0, !0)], 44, ie)) : i("", !0)], 544));
|
|
447
|
+
}
|
|
448
|
+
}), [["__scopeId", "data-v-f39579b0"]]);
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/shared/useDataSourceSchema.ts
|
|
451
|
+
function M(e) {
|
|
452
|
+
let t = v(e.store.ui.dataSourceSchema), n = e.subscribe((n) => {
|
|
453
|
+
n.scope === "ui" && n.branch === "dataSourceSchema" && (t.value = e.store.ui.dataSourceSchema);
|
|
454
|
+
});
|
|
455
|
+
return p(n, !0), r(() => t.value);
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
export { j as n, C as r, M as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hankchen/canvas-editor-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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.
|
|
61
|
+
"@hankchen/canvas-editor": "0.7.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"vue": "^3.5.0"
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { n as e, u as t } from "./useTransientFeedback-CTjmMmFF.js";
|
|
2
|
-
import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, mergeProps as l, nextTick as u, normalizeStyle as d, onScopeDispose as f, openBlock as p, ref as m, renderList as h, renderSlot as g, shallowRef as _, toDisplayString as v, unref as y, watch as b, withModifiers as x } from "vue";
|
|
3
|
-
//#region src/shared/useDropdownMenu.ts
|
|
4
|
-
function S(e) {
|
|
5
|
-
let t = m(!1);
|
|
6
|
-
function n(n) {
|
|
7
|
-
let r = e.container.value, i = n.target;
|
|
8
|
-
r !== null && i instanceof Node && r.contains(i) || (t.value = !1);
|
|
9
|
-
}
|
|
10
|
-
function r(e) {
|
|
11
|
-
e.key === "Escape" && (t.value = !1);
|
|
12
|
-
}
|
|
13
|
-
function i() {
|
|
14
|
-
window.removeEventListener("pointerdown", n), window.removeEventListener("keydown", r);
|
|
15
|
-
}
|
|
16
|
-
return b(t, (e) => {
|
|
17
|
-
e ? (window.addEventListener("pointerdown", n), window.addEventListener("keydown", r)) : i();
|
|
18
|
-
}), f(i, !0), {
|
|
19
|
-
open: t,
|
|
20
|
-
toggle: () => {
|
|
21
|
-
t.value = !t.value;
|
|
22
|
-
},
|
|
23
|
-
openMenu: () => {
|
|
24
|
-
t.value = !0;
|
|
25
|
-
},
|
|
26
|
-
closeMenu: () => {
|
|
27
|
-
t.value = !1;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function C(e, t, n) {
|
|
32
|
-
let r = e.length;
|
|
33
|
-
if (r === 0) return -1;
|
|
34
|
-
if (n === "Home" || n === "End") {
|
|
35
|
-
for (let t = 0; t < r; t++) {
|
|
36
|
-
let i = n === "Home" ? t : r - 1 - t;
|
|
37
|
-
if (e[i]) return i;
|
|
38
|
-
}
|
|
39
|
-
return -1;
|
|
40
|
-
}
|
|
41
|
-
let i = n === "ArrowDown" ? 1 : -1, a = t === -1 ? i === 1 ? -1 : r : t;
|
|
42
|
-
for (let t = 0; t < r; t++) if (a = (a + i + r) % r, e[a]) return a;
|
|
43
|
-
return -1;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/shared/DropdownMenu.vue?vue&type=script&setup=true&lang.ts
|
|
47
|
-
var w = ["aria-expanded", "title"], T = ["aria-label"], E = {
|
|
48
|
-
key: 0,
|
|
49
|
-
class: "cn-dropdown__separator",
|
|
50
|
-
role: "separator",
|
|
51
|
-
"data-dropdown-separator": "",
|
|
52
|
-
"aria-hidden": "true"
|
|
53
|
-
}, D = [
|
|
54
|
-
"disabled",
|
|
55
|
-
"title",
|
|
56
|
-
"onClick"
|
|
57
|
-
], O = { class: "cn-dropdown__item-label" }, k = {
|
|
58
|
-
key: 0,
|
|
59
|
-
class: "cn-dropdown__shortcut"
|
|
60
|
-
}, A = 6, j = 2, M = /*#__PURE__*/ t(/* @__PURE__ */ c({
|
|
61
|
-
__name: "DropdownMenu",
|
|
62
|
-
props: {
|
|
63
|
-
label: {},
|
|
64
|
-
items: {},
|
|
65
|
-
title: {},
|
|
66
|
-
direction: { default: "down" }
|
|
67
|
-
},
|
|
68
|
-
emits: ["closed"],
|
|
69
|
-
setup(t, { emit: r }) {
|
|
70
|
-
let c = t, f = r, _ = m(null), M = m(null), N = m(null), { open: P, toggle: F, closeMenu: I } = S({ container: _ });
|
|
71
|
-
b(P, (e) => {
|
|
72
|
-
e || f("closed");
|
|
73
|
-
});
|
|
74
|
-
let L = m({
|
|
75
|
-
left: 0,
|
|
76
|
-
edge: "top",
|
|
77
|
-
offset: 0
|
|
78
|
-
});
|
|
79
|
-
function R() {
|
|
80
|
-
M.value?.focus();
|
|
81
|
-
}
|
|
82
|
-
function z(e) {
|
|
83
|
-
M.value = e instanceof HTMLElement ? e : null;
|
|
84
|
-
}
|
|
85
|
-
async function B() {
|
|
86
|
-
if (await u(), !P.value) return;
|
|
87
|
-
let e = N.value;
|
|
88
|
-
e !== null && (e.querySelector("[data-dropdown-item]:not([disabled])") ?? e).focus();
|
|
89
|
-
}
|
|
90
|
-
function V() {
|
|
91
|
-
return c.items.filter((e) => e !== "separator");
|
|
92
|
-
}
|
|
93
|
-
function H() {
|
|
94
|
-
return Array.from(N.value?.querySelectorAll("[data-dropdown-item]") ?? []);
|
|
95
|
-
}
|
|
96
|
-
function U(e) {
|
|
97
|
-
e.run(), e.keepsOpen !== !0 && (I(), R());
|
|
98
|
-
}
|
|
99
|
-
function W(e) {
|
|
100
|
-
let t = N.value;
|
|
101
|
-
if (t === null) return;
|
|
102
|
-
let n = H(), r = C(n.map((e) => !e.hasAttribute("disabled")), document.activeElement instanceof HTMLElement ? n.indexOf(document.activeElement) : -1, e);
|
|
103
|
-
if (r === -1) {
|
|
104
|
-
t.focus();
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
n[r]?.focus();
|
|
108
|
-
}
|
|
109
|
-
function G(e) {
|
|
110
|
-
let t = V()[H().indexOf(e)];
|
|
111
|
-
t !== void 0 && !t.disabled && U(t);
|
|
112
|
-
}
|
|
113
|
-
function K(t) {
|
|
114
|
-
let n = t.key;
|
|
115
|
-
if (n === "Escape" || n === "Tab") {
|
|
116
|
-
if (n === "Tab") {
|
|
117
|
-
let n = t.target;
|
|
118
|
-
if (n instanceof HTMLElement && !n.matches("[data-dropdown-item]") && e(n)) return;
|
|
119
|
-
}
|
|
120
|
-
I(), R();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (n === "Enter" || n === " ") {
|
|
124
|
-
let e = t.target;
|
|
125
|
-
e instanceof HTMLElement && e.matches("[data-dropdown-item]") && (t.preventDefault(), G(e));
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (n === "ArrowDown" || n === "ArrowUp" || n === "Home" || n === "End") {
|
|
129
|
-
let r = t.target;
|
|
130
|
-
if (r instanceof HTMLElement && !r.matches("[data-dropdown-item]") && e(r)) return;
|
|
131
|
-
t.preventDefault(), W(n);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function q(e) {
|
|
135
|
-
if (e.key === "ArrowDown") {
|
|
136
|
-
if (e.preventDefault(), !P.value) {
|
|
137
|
-
J();
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
B();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function J() {
|
|
144
|
-
if (!P.value) {
|
|
145
|
-
let e = M.value?.getBoundingClientRect();
|
|
146
|
-
e && (L.value = c.direction === "up" ? {
|
|
147
|
-
left: e.left,
|
|
148
|
-
edge: "bottom",
|
|
149
|
-
offset: window.innerHeight - e.top + A
|
|
150
|
-
} : {
|
|
151
|
-
left: e.left,
|
|
152
|
-
edge: "top",
|
|
153
|
-
offset: e.bottom + A
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (F(), !P.value) {
|
|
157
|
-
R();
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
await u();
|
|
161
|
-
let e = N.value?.getBoundingClientRect();
|
|
162
|
-
if (!e) return;
|
|
163
|
-
let t = L.value;
|
|
164
|
-
L.value = {
|
|
165
|
-
left: Math.max(j, Math.min(t.left, window.innerWidth - e.width - j)),
|
|
166
|
-
edge: t.edge,
|
|
167
|
-
offset: Math.max(j, Math.min(t.offset, window.innerHeight - e.height - j))
|
|
168
|
-
}, B();
|
|
169
|
-
}
|
|
170
|
-
return (e, r) => (p(), a("div", {
|
|
171
|
-
ref_key: "container",
|
|
172
|
-
ref: _,
|
|
173
|
-
class: "cn-dropdown"
|
|
174
|
-
}, [g(e.$slots, "trigger", {
|
|
175
|
-
open: y(P),
|
|
176
|
-
toggle: J,
|
|
177
|
-
closeMenu: y(I),
|
|
178
|
-
triggerRef: z,
|
|
179
|
-
onKeydown: q
|
|
180
|
-
}, () => [o("button", {
|
|
181
|
-
ref: z,
|
|
182
|
-
type: "button",
|
|
183
|
-
class: "cn-dropdown__trigger",
|
|
184
|
-
"data-dropdown-trigger": "",
|
|
185
|
-
"aria-haspopup": "menu",
|
|
186
|
-
"aria-expanded": y(P),
|
|
187
|
-
title: t.title ?? t.label,
|
|
188
|
-
onClick: r[0] ||= (e) => J(),
|
|
189
|
-
onKeydown: q
|
|
190
|
-
}, [s(v(t.label) + " ", 1), r[2] ||= o("span", {
|
|
191
|
-
class: "cn-dropdown__caret",
|
|
192
|
-
"aria-hidden": "true"
|
|
193
|
-
}, "▾", -1)], 40, w)], !0), y(P) ? (p(), a("div", {
|
|
194
|
-
key: 0,
|
|
195
|
-
ref_key: "menuEl",
|
|
196
|
-
ref: N,
|
|
197
|
-
class: "cn-dropdown__menu",
|
|
198
|
-
role: "menu",
|
|
199
|
-
"aria-label": t.label,
|
|
200
|
-
"data-dropdown-menu": "",
|
|
201
|
-
tabindex: "-1",
|
|
202
|
-
style: d(L.value.edge === "top" ? {
|
|
203
|
-
left: `${L.value.left}px`,
|
|
204
|
-
top: `${L.value.offset}px`
|
|
205
|
-
} : {
|
|
206
|
-
left: `${L.value.left}px`,
|
|
207
|
-
bottom: `${L.value.offset}px`
|
|
208
|
-
}),
|
|
209
|
-
onKeydown: r[1] ||= x((e) => K(e), ["stop"])
|
|
210
|
-
}, [(p(!0), a(n, null, h(t.items, (e, t) => (p(), a(n, { key: t }, [e === "separator" ? (p(), a("div", E)) : (p(), a("button", l({
|
|
211
|
-
key: 1,
|
|
212
|
-
type: "button",
|
|
213
|
-
role: "menuitem",
|
|
214
|
-
class: "cn-dropdown__item",
|
|
215
|
-
"data-dropdown-item": "",
|
|
216
|
-
tabindex: "-1",
|
|
217
|
-
disabled: e.disabled,
|
|
218
|
-
title: e.title
|
|
219
|
-
}, { ref_for: !0 }, e.dataAttrs, { onClick: (t) => U(e) }), [o("span", O, v(e.label), 1), e.shortcut ? (p(), a("span", k, v(e.shortcut), 1)) : i("", !0)], 16, D))], 64))), 128)), g(e.$slots, "body", {
|
|
220
|
-
open: y(P),
|
|
221
|
-
toggle: J,
|
|
222
|
-
closeMenu: y(I),
|
|
223
|
-
triggerRef: z,
|
|
224
|
-
onKeydown: q
|
|
225
|
-
}, void 0, !0)], 44, T)) : i("", !0)], 512));
|
|
226
|
-
}
|
|
227
|
-
}), [["__scopeId", "data-v-ec8a19c1"]]);
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region src/shared/useDataSourceSchema.ts
|
|
230
|
-
function N(e) {
|
|
231
|
-
let t = _(e.store.ui.dataSourceSchema), n = e.subscribe((n) => {
|
|
232
|
-
n.scope === "ui" && n.branch === "dataSourceSchema" && (t.value = e.store.ui.dataSourceSchema);
|
|
233
|
-
});
|
|
234
|
-
return f(n, !0), r(() => t.value);
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
export { M as n, S as r, N as t };
|