@hankchen/canvas-editor-vue 2.0.0 → 2.2.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.
@@ -0,0 +1,956 @@
1
+ import { n as e, t } from "./_plugin-vue_export-helper-CBNdHDnS.js";
2
+ import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, mergeProps as u, nextTick as d, normalizeClass as ee, 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 te } from "vue";
3
+ //#region ../canvas-editor/src/session/shortcuts.ts
4
+ var S = {
5
+ armCreateText: "TextLayer",
6
+ armCreateTable: "TableLayer",
7
+ armCreateQrCode: "QrCodeLayer",
8
+ armCreateImage: "ImageLayer"
9
+ }, C = [
10
+ {
11
+ combo: {
12
+ key: "z",
13
+ mod: !0,
14
+ shift: !1
15
+ },
16
+ action: "undo",
17
+ label: "撤销",
18
+ group: "history"
19
+ },
20
+ {
21
+ combo: {
22
+ key: "z",
23
+ mod: !0,
24
+ shift: !0
25
+ },
26
+ action: "redo",
27
+ label: "重做",
28
+ group: "history"
29
+ },
30
+ {
31
+ combo: {
32
+ key: "y",
33
+ mod: !0,
34
+ shift: !1
35
+ },
36
+ action: "redo",
37
+ label: "重做",
38
+ group: "history"
39
+ },
40
+ {
41
+ combo: {
42
+ key: "c",
43
+ mod: !0,
44
+ shift: !1
45
+ },
46
+ action: "copy",
47
+ label: "复制",
48
+ group: "clipboard"
49
+ },
50
+ {
51
+ combo: {
52
+ key: "v",
53
+ mod: !0,
54
+ shift: !1
55
+ },
56
+ action: "paste",
57
+ label: "粘贴",
58
+ group: "clipboard"
59
+ },
60
+ {
61
+ combo: {
62
+ key: "d",
63
+ mod: !0,
64
+ shift: !1
65
+ },
66
+ action: "duplicate",
67
+ label: "创建副本",
68
+ group: "clipboard"
69
+ },
70
+ {
71
+ combo: {
72
+ key: "c",
73
+ mod: !0,
74
+ shift: !1,
75
+ alt: !0,
76
+ code: "KeyC"
77
+ },
78
+ action: "copyStyle",
79
+ label: "复制样式",
80
+ group: "clipboard"
81
+ },
82
+ {
83
+ combo: {
84
+ key: "v",
85
+ mod: !0,
86
+ shift: !1,
87
+ alt: !0,
88
+ code: "KeyV"
89
+ },
90
+ action: "pasteStyle",
91
+ label: "粘贴样式",
92
+ group: "clipboard"
93
+ },
94
+ {
95
+ combo: {
96
+ key: "delete",
97
+ mod: !1,
98
+ shift: !1
99
+ },
100
+ action: "delete",
101
+ label: "删除图层",
102
+ group: "layer"
103
+ },
104
+ {
105
+ combo: {
106
+ key: "backspace",
107
+ mod: !1,
108
+ shift: !1
109
+ },
110
+ action: "delete",
111
+ label: "删除图层",
112
+ group: "layer"
113
+ },
114
+ {
115
+ combo: {
116
+ key: "f2",
117
+ mod: !1,
118
+ shift: !1
119
+ },
120
+ action: "rename",
121
+ label: "重命名图层",
122
+ group: "layer"
123
+ },
124
+ {
125
+ combo: {
126
+ key: "f",
127
+ mod: !0,
128
+ shift: !1
129
+ },
130
+ action: "findReplace",
131
+ label: "查找替换",
132
+ group: "text"
133
+ },
134
+ {
135
+ combo: {
136
+ key: "r",
137
+ mod: !1,
138
+ shift: !0
139
+ },
140
+ action: "toggleRulers",
141
+ label: "标尺显隐",
142
+ group: "view"
143
+ },
144
+ {
145
+ combo: {
146
+ key: "l",
147
+ mod: !0,
148
+ shift: !0
149
+ },
150
+ action: "toggleLayerLock",
151
+ label: "锁定/解锁图层",
152
+ group: "layer"
153
+ },
154
+ {
155
+ combo: {
156
+ key: "h",
157
+ mod: !0,
158
+ shift: !0
159
+ },
160
+ action: "toggleLayerVisibility",
161
+ label: "显示/隐藏图层",
162
+ group: "layer"
163
+ },
164
+ {
165
+ combo: {
166
+ key: "]",
167
+ mod: !0,
168
+ shift: !1
169
+ },
170
+ action: "bringForward",
171
+ label: "前移一层",
172
+ group: "layer"
173
+ },
174
+ {
175
+ combo: {
176
+ key: "[",
177
+ mod: !0,
178
+ shift: !1
179
+ },
180
+ action: "sendBackward",
181
+ label: "后移一层",
182
+ group: "layer"
183
+ },
184
+ {
185
+ combo: {
186
+ key: "]",
187
+ mod: !0,
188
+ shift: !1,
189
+ alt: !0,
190
+ code: "BracketRight"
191
+ },
192
+ action: "bringToFront",
193
+ label: "置顶",
194
+ group: "layer"
195
+ },
196
+ {
197
+ combo: {
198
+ key: "[",
199
+ mod: !0,
200
+ shift: !1,
201
+ alt: !0,
202
+ code: "BracketLeft"
203
+ },
204
+ action: "sendToBack",
205
+ label: "置底",
206
+ group: "layer"
207
+ },
208
+ {
209
+ combo: {
210
+ key: "arrowup",
211
+ mod: !1,
212
+ shift: !1
213
+ },
214
+ action: "nudgeUp",
215
+ label: "微调上移",
216
+ group: "layer"
217
+ },
218
+ {
219
+ combo: {
220
+ key: "arrowdown",
221
+ mod: !1,
222
+ shift: !1
223
+ },
224
+ action: "nudgeDown",
225
+ label: "微调下移",
226
+ group: "layer"
227
+ },
228
+ {
229
+ combo: {
230
+ key: "arrowleft",
231
+ mod: !1,
232
+ shift: !1
233
+ },
234
+ action: "nudgeLeft",
235
+ label: "微调左移",
236
+ group: "layer"
237
+ },
238
+ {
239
+ combo: {
240
+ key: "arrowright",
241
+ mod: !1,
242
+ shift: !1
243
+ },
244
+ action: "nudgeRight",
245
+ label: "微调右移",
246
+ group: "layer"
247
+ },
248
+ {
249
+ combo: {
250
+ key: "arrowup",
251
+ mod: !1,
252
+ shift: !0
253
+ },
254
+ action: "nudgeUpCoarse",
255
+ label: "大步上移",
256
+ group: "layer"
257
+ },
258
+ {
259
+ combo: {
260
+ key: "arrowdown",
261
+ mod: !1,
262
+ shift: !0
263
+ },
264
+ action: "nudgeDownCoarse",
265
+ label: "大步下移",
266
+ group: "layer"
267
+ },
268
+ {
269
+ combo: {
270
+ key: "arrowleft",
271
+ mod: !1,
272
+ shift: !0
273
+ },
274
+ action: "nudgeLeftCoarse",
275
+ label: "大步左移",
276
+ group: "layer"
277
+ },
278
+ {
279
+ combo: {
280
+ key: "arrowright",
281
+ mod: !1,
282
+ shift: !0
283
+ },
284
+ action: "nudgeRightCoarse",
285
+ label: "大步右移",
286
+ group: "layer"
287
+ },
288
+ {
289
+ combo: {
290
+ key: "tab",
291
+ mod: !1,
292
+ shift: !1
293
+ },
294
+ action: "selectNextLayer",
295
+ label: "循环选下一层",
296
+ group: "layer"
297
+ },
298
+ {
299
+ combo: {
300
+ key: "tab",
301
+ mod: !1,
302
+ shift: !0
303
+ },
304
+ action: "selectPrevLayer",
305
+ label: "循环选上一层",
306
+ group: "layer"
307
+ },
308
+ {
309
+ combo: {
310
+ key: "t",
311
+ mod: !1,
312
+ shift: !1,
313
+ code: "KeyT"
314
+ },
315
+ action: "armCreateText",
316
+ label: "画拉建文本层",
317
+ group: "layer"
318
+ },
319
+ {
320
+ combo: {
321
+ key: "g",
322
+ mod: !1,
323
+ shift: !1,
324
+ code: "KeyG"
325
+ },
326
+ action: "armCreateTable",
327
+ label: "画拉建表格",
328
+ group: "layer"
329
+ },
330
+ {
331
+ combo: {
332
+ key: "q",
333
+ mod: !1,
334
+ shift: !1,
335
+ code: "KeyQ"
336
+ },
337
+ action: "armCreateQrCode",
338
+ label: "画拉建二维码",
339
+ group: "layer"
340
+ },
341
+ {
342
+ combo: {
343
+ key: "i",
344
+ mod: !1,
345
+ shift: !1,
346
+ code: "KeyI"
347
+ },
348
+ action: "armCreateImage",
349
+ label: "画拉建图片",
350
+ group: "layer"
351
+ },
352
+ {
353
+ combo: {
354
+ key: "0",
355
+ mod: !0,
356
+ shift: !1
357
+ },
358
+ action: "zoomReset",
359
+ label: "缩放复位 100%",
360
+ group: "view"
361
+ },
362
+ {
363
+ combo: {
364
+ key: "1",
365
+ mod: !1,
366
+ shift: !0,
367
+ code: "Digit1"
368
+ },
369
+ action: "fitToSurface",
370
+ label: "适应画布",
371
+ group: "view"
372
+ },
373
+ {
374
+ combo: {
375
+ key: "2",
376
+ mod: !1,
377
+ shift: !0,
378
+ code: "Digit2"
379
+ },
380
+ action: "fitToSelection",
381
+ label: "适应选区",
382
+ group: "view"
383
+ },
384
+ {
385
+ combo: {
386
+ key: "/",
387
+ mod: !0,
388
+ shift: !1
389
+ },
390
+ action: "helpShortcuts",
391
+ label: "快捷键帮助",
392
+ group: "help"
393
+ }
394
+ ];
395
+ function w(e, t = C) {
396
+ if (e.composing || e.editing || e.editableTarget) return null;
397
+ let n = e.key.toLowerCase(), r = e.alt ?? !1;
398
+ for (let i of t) if ((i.combo.code === void 0 ? i.combo.key === n : i.combo.code === e.code) && i.combo.mod === e.mod && i.combo.shift === e.shift && (i.combo.alt ?? !1) === r) return i.action;
399
+ return null;
400
+ }
401
+ //#endregion
402
+ //#region src/shared/shortcutsHelp.ts
403
+ var T = [
404
+ "history",
405
+ "clipboard",
406
+ "layer",
407
+ "text",
408
+ "view",
409
+ "help"
410
+ ], E = {
411
+ history: "历史",
412
+ clipboard: "剪贴板",
413
+ layer: "图层",
414
+ text: "文本",
415
+ view: "视图",
416
+ help: "帮助"
417
+ }, D = {
418
+ arrowup: "↑",
419
+ arrowdown: "↓",
420
+ arrowleft: "←",
421
+ arrowright: "→",
422
+ backspace: "⌫",
423
+ delete: "Del",
424
+ escape: "Esc",
425
+ tab: "Tab",
426
+ f2: "F2"
427
+ };
428
+ function O(e, t) {
429
+ let n = e.key, r = /^[a-z]$/.test(n) ? n.toUpperCase() : D[n] ?? n;
430
+ if (t === "mac") {
431
+ let t = "";
432
+ return e.alt && (t += "⌥"), e.shift && (t += "⇧"), e.mod && (t += "⌘"), t + r;
433
+ }
434
+ let i = [];
435
+ return e.mod && i.push("Ctrl"), e.shift && i.push("Shift"), e.alt && i.push("Alt"), i.push(r), i.join("+");
436
+ }
437
+ function k(e, t) {
438
+ let n = C.find((t) => t.action === e);
439
+ return n ? O(n.combo, t) : "";
440
+ }
441
+ var A = "画拉或点击落层,Esc 取消";
442
+ function j() {
443
+ let e = globalThis.navigator;
444
+ return /mac/i.test(`${e?.userAgentData?.platform ?? ""} ${e?.platform ?? ""} ${e?.userAgent ?? ""}`) ? "mac" : "win";
445
+ }
446
+ //#endregion
447
+ //#region src/shared/useDataSourceSchema.ts
448
+ var M = "先绑定数据源";
449
+ function N(e) {
450
+ let t = v(e.store.ui.dataSourceSchema), n = e.subscribe((n) => {
451
+ n.scope === "ui" && n.branch === "dataSourceSchema" && (t.value = e.store.ui.dataSourceSchema);
452
+ });
453
+ return p(n, !0), r(() => t.value);
454
+ }
455
+ function P(e) {
456
+ let t = v(e.store.ui.dataSourceSchemaRejection), n = e.subscribe((n) => {
457
+ n.scope === "ui" && n.branch === "dataSourceSchema" && (t.value = e.store.ui.dataSourceSchemaRejection);
458
+ });
459
+ return p(n, !0), r(() => t.value);
460
+ }
461
+ //#endregion
462
+ //#region src/shared/editableTarget.ts
463
+ function F(e) {
464
+ if (!(e instanceof HTMLElement)) return !1;
465
+ if (e.isContentEditable) return !0;
466
+ let t = e.tagName;
467
+ return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || t === "BUTTON";
468
+ }
469
+ function I(e) {
470
+ if (!(e instanceof HTMLElement)) return !1;
471
+ if (e.isContentEditable) return !0;
472
+ let t = e.tagName;
473
+ return t === "INPUT" || t === "TEXTAREA" || t === "SELECT";
474
+ }
475
+ //#endregion
476
+ //#region src/shared/useDropdownMenu.ts
477
+ function L(e) {
478
+ return e !== "separator" && "kind" in e && e.kind === "submenu";
479
+ }
480
+ function R(e) {
481
+ let t = h(!1);
482
+ function n(n) {
483
+ let r = e.container.value, i = n.target;
484
+ r !== null && i instanceof Node && r.contains(i) || (t.value = !1);
485
+ }
486
+ function r(e) {
487
+ e.key === "Escape" && (t.value = !1);
488
+ }
489
+ function i() {
490
+ window.removeEventListener("pointerdown", n), window.removeEventListener("keydown", r);
491
+ }
492
+ return x(t, (e) => {
493
+ e ? (window.addEventListener("pointerdown", n), window.addEventListener("keydown", r)) : i();
494
+ }), p(i, !0), {
495
+ open: t,
496
+ toggle: () => {
497
+ t.value = !t.value;
498
+ },
499
+ openMenu: () => {
500
+ t.value = !0;
501
+ },
502
+ closeMenu: () => {
503
+ t.value = !1;
504
+ }
505
+ };
506
+ }
507
+ function z(e, t, n) {
508
+ let r = e.length;
509
+ if (r === 0) return -1;
510
+ if (n === "Home" || n === "End") {
511
+ for (let t = 0; t < r; t++) {
512
+ let i = n === "Home" ? t : r - 1 - t;
513
+ if (e[i]) return i;
514
+ }
515
+ return -1;
516
+ }
517
+ let i = n === "ArrowDown" ? 1 : -1, a = t === -1 ? i === 1 ? -1 : r : t;
518
+ for (let t = 0; t < r; t++) if (a = (a + i + r) % r, e[a]) return a;
519
+ return -1;
520
+ }
521
+ function B(e, t) {
522
+ return t.type === "close" || t.target === void 0 ? null : t.type === "open" ? t.target : e === t.target ? null : t.target;
523
+ }
524
+ function ne(e) {
525
+ 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;
526
+ n > 0 && (l = Math.max(s, Math.min(l, i - s - n)));
527
+ let u = t.top;
528
+ return r > 0 && (u = Math.max(s, Math.min(u, a - s - r))), {
529
+ left: l,
530
+ top: u,
531
+ side: c
532
+ };
533
+ }
534
+ function re(e) {
535
+ return e === "ArrowDown" || e === "ArrowUp" || e === "Home" || e === "End" ? {
536
+ type: "move",
537
+ key: e
538
+ } : e === "ArrowLeft" || e === "Escape" ? { type: "close" } : e === "Enter" || e === " " ? { type: "activate" } : e === "Tab" ? { type: "close-menu" } : { type: "none" };
539
+ }
540
+ function V(e, t) {
541
+ return e.find((e) => !e.hasAttribute("disabled")) ?? t;
542
+ }
543
+ function ie(e) {
544
+ return e?.closest("[data-dropdown-submenu-host]")?.querySelector("[data-dropdown-submenu-arrow]") ?? null;
545
+ }
546
+ function ae(e) {
547
+ return e;
548
+ }
549
+ //#endregion
550
+ //#region src/shared/DropdownMenu.vue?vue&type=script&setup=true&lang.ts
551
+ var oe = ["aria-expanded", "title"], se = ["aria-label"], ce = {
552
+ key: 0,
553
+ class: "cn-dropdown__separator",
554
+ role: "separator",
555
+ "data-dropdown-separator": "",
556
+ "aria-hidden": "true"
557
+ }, le = {
558
+ key: 1,
559
+ class: "cn-dropdown__submenu-host",
560
+ "data-dropdown-submenu-host": ""
561
+ }, ue = [
562
+ "disabled",
563
+ "title",
564
+ "onClick"
565
+ ], de = { class: "cn-dropdown__item-label" }, fe = {
566
+ key: 0,
567
+ class: "cn-dropdown__shortcut"
568
+ }, pe = [
569
+ "disabled",
570
+ "title",
571
+ "aria-expanded",
572
+ "onClick",
573
+ "onMouseenter"
574
+ ], me = ["aria-label"], he = {
575
+ key: 0,
576
+ class: "cn-dropdown__separator",
577
+ role: "separator",
578
+ "data-dropdown-submenu-separator": "",
579
+ "aria-hidden": "true"
580
+ }, ge = [
581
+ "disabled",
582
+ "title",
583
+ "onClick"
584
+ ], _e = { class: "cn-dropdown__item-label" }, ve = {
585
+ key: 0,
586
+ class: "cn-dropdown__shortcut"
587
+ }, ye = [
588
+ "role",
589
+ "aria-checked",
590
+ "disabled",
591
+ "title",
592
+ "onClick"
593
+ ], be = {
594
+ key: 0,
595
+ class: "cn-dropdown__item-lead"
596
+ }, xe = { class: "cn-dropdown__item-label" }, Se = {
597
+ key: 1,
598
+ class: "cn-dropdown__item-label"
599
+ }, Ce = {
600
+ key: 2,
601
+ class: "cn-dropdown__shortcut"
602
+ }, we = {
603
+ key: 3,
604
+ class: "cn-dropdown__check",
605
+ "aria-hidden": "true"
606
+ }, H = 6, U = 2, W = /*#__PURE__*/ t(/* @__PURE__ */ l({
607
+ __name: "DropdownMenu",
608
+ props: {
609
+ label: {},
610
+ items: {},
611
+ title: {},
612
+ direction: { default: "down" }
613
+ },
614
+ emits: ["closed"],
615
+ setup(t, { emit: r }) {
616
+ let l = t, p = r, S = h(null), C = h(null), w = h(null), { open: T, toggle: E, closeMenu: D } = R({ container: S }), O = v(null), k = h({
617
+ left: 0,
618
+ top: 0,
619
+ side: "right"
620
+ });
621
+ x(T, (e) => {
622
+ e || (O.value = null, p("closed"));
623
+ });
624
+ let A = h({
625
+ left: 0,
626
+ edge: "top",
627
+ offset: 0
628
+ });
629
+ function j() {
630
+ ae(C.value)?.focus();
631
+ }
632
+ function M(e) {
633
+ C.value = e instanceof HTMLElement ? e : null;
634
+ }
635
+ async function N() {
636
+ if (await d(), !T.value) return;
637
+ let e = w.value;
638
+ e !== null && V(q(), e).focus();
639
+ }
640
+ function P() {
641
+ return l.items.filter((e) => e !== "separator");
642
+ }
643
+ function I() {
644
+ return P().filter(L);
645
+ }
646
+ function W() {
647
+ return Array.from(w.value?.querySelectorAll("[data-dropdown-submenu-host]") ?? []);
648
+ }
649
+ function G() {
650
+ return w.value?.querySelector("[data-dropdown-submenu]") ?? null;
651
+ }
652
+ function K() {
653
+ return Array.from(G()?.querySelectorAll("[data-dropdown-submenu-item]") ?? []);
654
+ }
655
+ function q() {
656
+ return Array.from(w.value?.querySelectorAll("[data-dropdown-item]") ?? []);
657
+ }
658
+ function J(e) {
659
+ e.run(), (L(e) || e.keepsOpen !== !0) && (D(), j());
660
+ }
661
+ function Te(e) {
662
+ let t = w.value;
663
+ if (t === null) return;
664
+ let n = q(), r = z(n.map((e) => !e.hasAttribute("disabled")), document.activeElement instanceof HTMLElement ? n.indexOf(document.activeElement) : -1, e);
665
+ if (r === -1) {
666
+ t.focus();
667
+ return;
668
+ }
669
+ n[r]?.focus();
670
+ }
671
+ function Ee(e) {
672
+ let t = P()[q().indexOf(e)];
673
+ t !== void 0 && !t.disabled && J(t);
674
+ }
675
+ function De(e) {
676
+ let t = e.key, n = e.target;
677
+ if (n instanceof HTMLElement && n.matches("[data-dropdown-submenu-item]")) {
678
+ let r = re(t);
679
+ if (r.type === "move") {
680
+ e.preventDefault(), ke(r.key);
681
+ return;
682
+ }
683
+ if (r.type === "close") {
684
+ e.preventDefault(), Y();
685
+ return;
686
+ }
687
+ if (r.type === "activate") {
688
+ e.preventDefault(), Ae(n);
689
+ return;
690
+ }
691
+ if (r.type === "close-menu") {
692
+ D(), j();
693
+ return;
694
+ }
695
+ return;
696
+ }
697
+ if (t === "Escape") {
698
+ if (O.value !== null) {
699
+ Y();
700
+ return;
701
+ }
702
+ D(), j();
703
+ return;
704
+ }
705
+ if (t === "Tab") {
706
+ if (n instanceof HTMLElement && !n.matches("[data-dropdown-item]") && F(n)) return;
707
+ D(), j();
708
+ return;
709
+ }
710
+ if (t === "Enter" || t === " ") {
711
+ n instanceof HTMLElement && n.matches("[data-dropdown-item]") && (e.preventDefault(), Ee(n));
712
+ return;
713
+ }
714
+ if (t === "ArrowDown" || t === "ArrowUp" || t === "Home" || t === "End") {
715
+ if (n instanceof HTMLElement && !n.matches("[data-dropdown-item]") && F(n)) return;
716
+ e.preventDefault(), Te(t);
717
+ return;
718
+ }
719
+ if (t === "ArrowRight") {
720
+ let t = n instanceof HTMLElement ? n.closest("[data-dropdown-submenu-host]") : null;
721
+ if (t !== null) {
722
+ let n = I()[W().indexOf(t)];
723
+ n !== void 0 && (e.preventDefault(), Oe(n, t));
724
+ }
725
+ }
726
+ }
727
+ async function Oe(e, t) {
728
+ if (e.disabled === !0 || (O.value = B(O.value, {
729
+ type: "open",
730
+ target: e
731
+ }), await $(t.querySelector("[data-dropdown-submenu-arrow]")), O.value !== e || !T.value)) return;
732
+ let n = G();
733
+ n !== null && V(K(), n).focus();
734
+ }
735
+ function Y() {
736
+ let e = ie(document.activeElement instanceof HTMLElement ? document.activeElement : null);
737
+ O.value = null, e?.focus();
738
+ }
739
+ function ke(e) {
740
+ let t = G();
741
+ if (t === null) return;
742
+ let n = K(), r = z(n.map((e) => !e.hasAttribute("disabled")), document.activeElement instanceof HTMLElement ? n.indexOf(document.activeElement) : -1, e);
743
+ if (r === -1) {
744
+ t.focus();
745
+ return;
746
+ }
747
+ n[r]?.focus();
748
+ }
749
+ function Ae(e) {
750
+ let t = O.value;
751
+ if (t === null) return;
752
+ let n = Array.from(G()?.querySelectorAll("[data-dropdown-submenu-item]") ?? []), r = t.children.filter((e) => e !== "separator")[n.indexOf(e)];
753
+ r !== void 0 && !r.disabled && J(r);
754
+ }
755
+ function X(e) {
756
+ if (e.key === "ArrowDown") {
757
+ if (e.preventDefault(), !T.value) {
758
+ Z();
759
+ return;
760
+ }
761
+ N();
762
+ }
763
+ }
764
+ async function Z() {
765
+ if (!T.value) {
766
+ let e = C.value?.getBoundingClientRect();
767
+ e && (A.value = l.direction === "up" ? {
768
+ left: e.left,
769
+ edge: "bottom",
770
+ offset: window.innerHeight - e.top + H
771
+ } : {
772
+ left: e.left,
773
+ edge: "top",
774
+ offset: e.bottom + H
775
+ });
776
+ }
777
+ if (E(), !T.value) {
778
+ j();
779
+ return;
780
+ }
781
+ await d();
782
+ let e = w.value?.getBoundingClientRect();
783
+ if (!e) return;
784
+ let t = A.value;
785
+ A.value = {
786
+ left: Math.max(U, Math.min(t.left, window.innerWidth - e.width - U)),
787
+ edge: t.edge,
788
+ offset: Math.max(U, Math.min(t.offset, window.innerHeight - e.height - U))
789
+ }, N();
790
+ }
791
+ function Q(e) {
792
+ return e.currentTarget instanceof HTMLElement ? e.currentTarget : null;
793
+ }
794
+ async function $(e) {
795
+ let t = O.value;
796
+ if (t === null || e === null) return;
797
+ let n = e.getBoundingClientRect();
798
+ if (k.value = {
799
+ left: n.right + 6,
800
+ top: n.top,
801
+ side: "right"
802
+ }, await d(), O.value !== t) return;
803
+ let r = G(), i = r?.getBoundingClientRect();
804
+ r !== null && i !== void 0 && i.width !== 0 && (k.value = ne({
805
+ anchor: {
806
+ top: n.top,
807
+ bottom: n.bottom,
808
+ left: n.left,
809
+ right: n.right
810
+ },
811
+ flyoutWidth: i.width,
812
+ flyoutHeight: i.height,
813
+ viewportWidth: window.innerWidth,
814
+ viewportHeight: window.innerHeight
815
+ }));
816
+ }
817
+ function je(e, t) {
818
+ t.disabled !== !0 && (O.value = B(O.value, {
819
+ type: "open",
820
+ target: t
821
+ }), $(Q(e)));
822
+ }
823
+ function Me(e, t) {
824
+ t.disabled !== !0 && (O.value = B(O.value, {
825
+ type: "toggle",
826
+ target: t
827
+ }), $(Q(e)));
828
+ }
829
+ function Ne() {
830
+ O.value = null;
831
+ }
832
+ return (r, l) => (m(), a("div", {
833
+ ref_key: "container",
834
+ ref: S,
835
+ class: "cn-dropdown",
836
+ onMouseleave: Ne
837
+ }, [_(r.$slots, "trigger", {
838
+ open: b(T),
839
+ toggle: Z,
840
+ closeMenu: b(D),
841
+ triggerRef: M,
842
+ onKeydown: X
843
+ }, () => [o("button", {
844
+ ref: M,
845
+ type: "button",
846
+ class: "cn-dropdown__trigger",
847
+ "data-dropdown-trigger": "",
848
+ "aria-haspopup": "menu",
849
+ "aria-expanded": b(T),
850
+ title: t.title ?? t.label,
851
+ onClick: l[0] ||= (e) => Z(),
852
+ onKeydown: X
853
+ }, [s(y(t.label) + " ", 1), l[2] ||= o("span", {
854
+ class: "cn-dropdown__caret",
855
+ "aria-hidden": "true"
856
+ }, "▾", -1)], 40, oe)], !0), b(T) ? (m(), a("div", {
857
+ key: 0,
858
+ ref_key: "menuEl",
859
+ ref: w,
860
+ class: "cn-dropdown__menu",
861
+ role: "menu",
862
+ "aria-label": t.label,
863
+ "data-dropdown-menu": "",
864
+ tabindex: "-1",
865
+ style: f(A.value.edge === "top" ? {
866
+ left: `${A.value.left}px`,
867
+ top: `${A.value.offset}px`
868
+ } : {
869
+ left: `${A.value.left}px`,
870
+ bottom: `${A.value.offset}px`
871
+ }),
872
+ onKeydown: l[1] ||= te((e) => De(e), ["stop"])
873
+ }, [(m(!0), a(n, null, g(t.items, (t, r) => (m(), a(n, { key: r }, [t === "separator" ? (m(), a("div", ce)) : b(L)(t) ? (m(), a("div", le, [
874
+ o("button", u({
875
+ type: "button",
876
+ role: "menuitem",
877
+ class: "cn-dropdown__item cn-dropdown__submenu-main",
878
+ "data-dropdown-item": "",
879
+ tabindex: "-1",
880
+ disabled: t.disabled,
881
+ title: t.title
882
+ }, { ref_for: !0 }, t.dataAttrs, { onClick: (e) => J(t) }), [o("span", de, y(t.label), 1), t.shortcut ? (m(), a("span", fe, y(t.shortcut), 1)) : i("", !0)], 16, ue),
883
+ o("button", {
884
+ type: "button",
885
+ class: "cn-dropdown__submenu-arrow",
886
+ "data-dropdown-submenu-arrow": "",
887
+ tabindex: "-1",
888
+ disabled: t.disabled,
889
+ title: t.title,
890
+ "aria-haspopup": "menu",
891
+ "aria-expanded": O.value === t,
892
+ onClick: (e) => Me(e, t),
893
+ onMouseenter: (e) => je(e, t)
894
+ }, [...l[3] ||= [o("span", { "aria-hidden": "true" }, "▸", -1)]], 40, pe),
895
+ O.value === t ? (m(), a("div", {
896
+ key: 0,
897
+ class: ee(["cn-dropdown__submenu", { "cn-dropdown__submenu--left": k.value.side === "left" }]),
898
+ role: "menu",
899
+ "aria-label": t.label,
900
+ "data-dropdown-submenu": "",
901
+ tabindex: "-1",
902
+ style: f({
903
+ left: `${k.value.left}px`,
904
+ top: `${k.value.top}px`
905
+ })
906
+ }, [(m(!0), a(n, null, g(t.children, (e, t) => (m(), a(n, { key: t }, [e === "separator" ? (m(), a("div", he)) : (m(), a("button", u({
907
+ key: 1,
908
+ type: "button",
909
+ role: "menuitem",
910
+ class: "cn-dropdown__item",
911
+ "data-dropdown-submenu-item": "",
912
+ tabindex: "-1",
913
+ disabled: e.disabled,
914
+ title: e.title
915
+ }, { ref_for: !0 }, e.dataAttrs, { onClick: (t) => J(e) }), [o("span", _e, y(e.label), 1), e.shortcut ? (m(), a("span", ve, y(e.shortcut), 1)) : i("", !0)], 16, ge))], 64))), 128))], 14, me)) : i("", !0)
916
+ ])) : (m(), a("button", u({
917
+ key: 2,
918
+ type: "button",
919
+ role: "checked" in t ? "menuitemradio" : "menuitem",
920
+ "aria-checked": "checked" in t ? t.checked : void 0,
921
+ class: "cn-dropdown__item",
922
+ "data-dropdown-item": "",
923
+ tabindex: "-1",
924
+ disabled: t.disabled,
925
+ title: t.title
926
+ }, { ref_for: !0 }, t.dataAttrs, { onClick: (e) => J(t) }), [
927
+ t.icon ? (m(), a("span", be, [c(e, { icon: t.icon }, null, 8, ["icon"]), o("span", xe, y(t.label), 1)])) : (m(), a("span", Se, y(t.label), 1)),
928
+ t.shortcut ? (m(), a("span", Ce, y(t.shortcut), 1)) : i("", !0),
929
+ "checked" in t && t.checked === !0 ? (m(), a("span", we, "✓")) : i("", !0)
930
+ ], 16, ye))], 64))), 128)), _(r.$slots, "body", {
931
+ open: b(T),
932
+ toggle: Z,
933
+ closeMenu: b(D),
934
+ triggerRef: M,
935
+ onKeydown: X
936
+ }, void 0, !0)], 44, se)) : i("", !0)], 544));
937
+ }
938
+ }), [["__scopeId", "data-v-01371ad9"]]), G = 4e3, K = h(""), q = null;
939
+ function J() {
940
+ let e = () => {
941
+ q !== null && (clearTimeout(q), q = null);
942
+ };
943
+ return {
944
+ message: K,
945
+ show: (t) => {
946
+ e(), K.value = t, q = setTimeout(() => {
947
+ K.value = "", q = null;
948
+ }, G);
949
+ },
950
+ clear: () => {
951
+ e(), K.value = "";
952
+ }
953
+ };
954
+ }
955
+ //#endregion
956
+ export { w as _, I as a, P as c, T as d, j as f, C as g, S as h, F as i, A as l, O as m, W as n, M as o, k as p, R as r, N as s, J as t, E as u };