@freecallai/pro 0.0.9 → 0.0.11

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,949 @@
1
+ import { defineComponent as J, openBlock as p, createElementBlock as $, renderSlot as z, createBlock as U, unref as g, createCommentVNode as C, computed as F, normalizeClass as D, createVNode as B, withCtx as m, toDisplayString as A, shallowRef as M, ref as se, watch as O, createElementVNode as V, withKeys as j, withModifiers as H, normalizeStyle as W, createSlots as L, normalizeProps as ae, guardReactiveProps as ie, nextTick as Z, onMounted as ye, onBeforeUnmount as re, useSlots as fe, Fragment as G, renderList as Q, mergeProps as X, isVNode as me, Comment as ve, Text as ke, useId as be } from "vue";
2
+ import { Trigger as ee, Menu as de, SubMenu as ge, MenuItem as he, Scrollbar as Ke, SortableList as $e, Tooltip as Se } from "@freecallai/ui";
3
+ import { IconDragDotVertical as Pe, IconMore as we, IconMenuFold as Ie } from "@freecallai/ui/es/icon/index.js";
4
+ import _ from "@freecallai/icons";
5
+ const Te = { class: "fkp-navigation-item-icon" }, Be = ["src"], Y = /* @__PURE__ */ J({
6
+ __name: "NavigationIcon",
7
+ props: {
8
+ icon: {},
9
+ iconUrl: {},
10
+ size: { default: 24 }
11
+ },
12
+ setup(h) {
13
+ return (S, i) => (p(), $("span", Te, [
14
+ z(S.$slots, "default", {}, () => [
15
+ S.iconUrl ? (p(), $("img", {
16
+ key: 0,
17
+ src: S.iconUrl,
18
+ alt: ""
19
+ }, null, 8, Be)) : S.icon ? (p(), U(g(_), {
20
+ key: 1,
21
+ name: S.icon,
22
+ size: S.size
23
+ }, null, 8, ["name", "size"])) : C("", !0)
24
+ ])
25
+ ]));
26
+ }
27
+ }), Ne = ["aria-label", "aria-current", "disabled", "data-item-key"], Ce = {
28
+ key: 0,
29
+ class: "fkp-navigation-item-label"
30
+ }, Ve = {
31
+ key: 1,
32
+ class: "fkp-navigation-open",
33
+ "aria-hidden": "true"
34
+ }, le = /* @__PURE__ */ J({
35
+ __name: "NavigationButton",
36
+ props: {
37
+ item: {},
38
+ section: {},
39
+ selectedKey: {},
40
+ collapsed: { type: Boolean }
41
+ },
42
+ emits: ["select"],
43
+ setup(h, { emit: S }) {
44
+ const i = h, u = S, v = F(
45
+ () => !i.item.opensInNewTab && i.selectedKey === i.item.key
46
+ );
47
+ return (c, P) => (p(), $("button", {
48
+ type: "button",
49
+ class: D(["fkp-navigation-item", { "is-selected": v.value }]),
50
+ "aria-label": c.item.label,
51
+ "aria-current": v.value ? "page" : void 0,
52
+ disabled: c.item.disabled,
53
+ "data-item-key": c.item.key,
54
+ onClick: P[0] || (P[0] = (I) => u("select", c.item.key))
55
+ }, [
56
+ B(Y, {
57
+ icon: c.item.icon,
58
+ "icon-url": c.item.iconUrl
59
+ }, {
60
+ default: m(() => [
61
+ z(c.$slots, "item-icon", {
62
+ item: c.item,
63
+ section: c.section,
64
+ level: 0
65
+ })
66
+ ]),
67
+ _: 3
68
+ }, 8, ["icon", "icon-url"]),
69
+ c.collapsed ? C("", !0) : (p(), $("span", Ce, A(c.item.label), 1)),
70
+ c.item.opensInNewTab && !c.collapsed ? (p(), $("span", Ve, [
71
+ B(g(_), {
72
+ name: "open",
73
+ size: 16
74
+ })
75
+ ])) : C("", !0)
76
+ ], 10, Ne));
77
+ }
78
+ }), ze = ["disabled", "data-item-key", "aria-label", "aria-expanded"], Ee = {
79
+ key: 0,
80
+ class: "fkp-navigation-menu-label"
81
+ }, Ue = { class: "fkp-navigation-group-popup-title" }, Fe = ["tabindex", "aria-label", "aria-expanded", "aria-disabled"], Me = /* @__PURE__ */ J({
82
+ __name: "NavigationGroup",
83
+ props: {
84
+ item: {},
85
+ section: {},
86
+ level: {},
87
+ selectedKey: {},
88
+ expandedKeys: {},
89
+ collapsed: { type: Boolean, default: !1 },
90
+ inPopup: { type: Boolean, default: !1 },
91
+ disabled: { type: Boolean, default: !1 },
92
+ panelVisible: { type: Boolean, default: !1 },
93
+ activeGroupKey: {},
94
+ themeStyle: {}
95
+ },
96
+ emits: ["group-open", "select"],
97
+ setup(h, { emit: S }) {
98
+ const i = h, u = S, v = M(!1), c = se(), P = se(), I = M(!1), E = F(() => i.collapsed || i.inPopup), b = F(() => i.disabled || !!i.item.disabled), f = F(() => {
99
+ const e = (k) => k.some(
100
+ (N) => {
101
+ var R;
102
+ return (R = N.children) != null && R.length ? e(N.children) : !N.opensInNewTab && N.key === i.selectedKey;
103
+ }
104
+ );
105
+ return e(i.item.children ?? []);
106
+ }), l = (e = !1) => {
107
+ var k;
108
+ v.value = !1, I.value = !1, e && ((k = c.value) == null || k.focus());
109
+ }, y = async () => {
110
+ var k;
111
+ if (!I.value || !v.value) return;
112
+ await Z();
113
+ const e = (k = P.value) == null ? void 0 : k.querySelector(
114
+ '[tabindex="0"], button:not(:disabled)'
115
+ );
116
+ e && (e.focus(), I.value = !1);
117
+ }, n = (e) => {
118
+ e && b.value || (v.value = e, e ? (u("group-open"), y()) : I.value = !1);
119
+ }, K = (e) => {
120
+ if (e.key === "Escape")
121
+ e.preventDefault(), e.stopPropagation(), l(!0);
122
+ else if (e.key === "Enter" || e.key === " ") {
123
+ if (e.preventDefault(), e.stopPropagation(), b.value) return;
124
+ I.value = !v.value, n(!v.value);
125
+ } else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
126
+ if (e.preventDefault(), e.stopPropagation(), b.value) return;
127
+ I.value = !0, n(!0);
128
+ }
129
+ }, d = (e) => {
130
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), b.value || e.currentTarget.click());
131
+ }, w = (e) => {
132
+ b.value && e.stopPropagation();
133
+ }, r = (e) => {
134
+ l(), u("select", e);
135
+ };
136
+ return O(
137
+ () => i.activeGroupKey,
138
+ (e) => {
139
+ e !== void 0 && e !== i.item.key && l();
140
+ }
141
+ ), O(
142
+ () => i.collapsed,
143
+ () => l()
144
+ ), O(
145
+ () => i.panelVisible,
146
+ (e) => {
147
+ e && l();
148
+ }
149
+ ), O(b, (e) => {
150
+ e && l();
151
+ }), (e, k) => E.value ? (p(), U(g(ee), {
152
+ key: 0,
153
+ "popup-visible": v.value,
154
+ trigger: ["hover", "click"],
155
+ disabled: b.value,
156
+ position: "rt",
157
+ "popup-offset": 24,
158
+ "mouse-leave-delay": 180,
159
+ "auto-fit-popup-min-width": !1,
160
+ "onUpdate:popupVisible": n,
161
+ onShow: y
162
+ }, {
163
+ content: m(() => [
164
+ V("div", {
165
+ ref_key: "popupContent",
166
+ ref: P,
167
+ class: "fkp-navigation-group-popup",
168
+ style: W(e.themeStyle),
169
+ onKeydown: k[1] || (k[1] = j(H((N) => l(!0), ["stop", "prevent"]), ["esc"]))
170
+ }, [
171
+ V("strong", Ue, A(e.item.label), 1),
172
+ B(g(de), {
173
+ "prefix-cls": "arco-trigger-menu",
174
+ "selected-keys": f.value && e.selectedKey ? [e.selectedKey] : [],
175
+ "auto-open-selected": !1
176
+ }, {
177
+ default: m(() => [
178
+ B(oe, {
179
+ items: e.item.children || [],
180
+ section: e.section,
181
+ level: e.level + 1,
182
+ "selected-key": e.selectedKey,
183
+ "expanded-keys": e.expandedKeys,
184
+ "in-popup": !0,
185
+ disabled: b.value,
186
+ "panel-visible": e.panelVisible,
187
+ "theme-style": e.themeStyle,
188
+ onSelect: r,
189
+ onGroupOpen: k[0] || (k[0] = (N) => u("group-open"))
190
+ }, L({ _: 2 }, [
191
+ e.$slots["item-icon"] ? {
192
+ name: "item-icon",
193
+ fn: m((N) => [
194
+ z(e.$slots, "item-icon", ae(ie(N)))
195
+ ]),
196
+ key: "0"
197
+ } : void 0
198
+ ]), 1032, ["items", "section", "level", "selected-key", "expanded-keys", "disabled", "panel-visible", "theme-style"])
199
+ ]),
200
+ _: 3
201
+ }, 8, ["selected-keys"])
202
+ ], 36)
203
+ ]),
204
+ default: m(() => [
205
+ V("button", {
206
+ ref_key: "triggerButton",
207
+ ref: c,
208
+ type: "button",
209
+ class: D(["fkp-navigation-group", [
210
+ e.inPopup ? "arco-trigger-menu-pop-header" : "arco-menu-pop-header",
211
+ {
212
+ "is-disabled": b.value,
213
+ "arco-menu-selected": f.value && !e.inPopup,
214
+ "arco-trigger-menu-selected": f.value && e.inPopup
215
+ }
216
+ ]]),
217
+ disabled: b.value,
218
+ "data-item-key": e.item.key,
219
+ "aria-label": e.item.label,
220
+ "aria-haspopup": "menu",
221
+ "aria-expanded": v.value,
222
+ onKeydown: K
223
+ }, [
224
+ V("span", {
225
+ class: D(e.inPopup ? "arco-trigger-menu-icon" : "arco-menu-icon")
226
+ }, [
227
+ B(Y, {
228
+ icon: e.item.icon,
229
+ "icon-url": e.item.iconUrl,
230
+ size: 16
231
+ }, {
232
+ default: m(() => [
233
+ z(e.$slots, "item-icon", {
234
+ item: e.item,
235
+ section: e.section,
236
+ level: e.level
237
+ })
238
+ ]),
239
+ _: 3
240
+ }, 8, ["icon", "icon-url"])
241
+ ], 2),
242
+ e.inPopup ? (p(), $("span", Ee, A(e.item.label), 1)) : C("", !0)
243
+ ], 42, ze)
244
+ ]),
245
+ _: 3
246
+ }, 8, ["popup-visible", "disabled"])) : (p(), U(g(ge), {
247
+ key: e.item.key,
248
+ class: D(["fkp-navigation-group", { "is-disabled": b.value }]),
249
+ "aria-disabled": b.value || void 0,
250
+ "data-item-key": e.item.key,
251
+ onClickCapture: w
252
+ }, {
253
+ icon: m(() => [
254
+ B(Y, {
255
+ icon: e.item.icon,
256
+ "icon-url": e.item.iconUrl,
257
+ size: 16
258
+ }, {
259
+ default: m(() => [
260
+ z(e.$slots, "item-icon", {
261
+ item: e.item,
262
+ section: e.section,
263
+ level: e.level
264
+ })
265
+ ]),
266
+ _: 3
267
+ }, 8, ["icon", "icon-url"])
268
+ ]),
269
+ title: m(() => [
270
+ V("span", {
271
+ class: "fkp-navigation-group-label",
272
+ role: "button",
273
+ tabindex: b.value ? -1 : 0,
274
+ "aria-label": e.item.label,
275
+ "aria-expanded": e.expandedKeys.includes(e.item.key),
276
+ "aria-disabled": b.value || void 0,
277
+ onKeydown: d
278
+ }, A(e.item.label), 41, Fe)
279
+ ]),
280
+ default: m(() => [
281
+ B(oe, {
282
+ items: e.item.children || [],
283
+ section: e.section,
284
+ level: e.level + 1,
285
+ "selected-key": e.selectedKey,
286
+ "expanded-keys": e.expandedKeys,
287
+ disabled: b.value,
288
+ "panel-visible": e.panelVisible,
289
+ "theme-style": e.themeStyle,
290
+ "indicator-enabled": e.expandedKeys.includes(e.item.key),
291
+ onSelect: k[2] || (k[2] = (N) => u("select", N)),
292
+ onGroupOpen: k[3] || (k[3] = (N) => u("group-open"))
293
+ }, L({ _: 2 }, [
294
+ e.$slots["item-icon"] ? {
295
+ name: "item-icon",
296
+ fn: m((N) => [
297
+ z(e.$slots, "item-icon", ae(ie(N)))
298
+ ]),
299
+ key: "0"
300
+ } : void 0
301
+ ]), 1032, ["items", "section", "level", "selected-key", "expanded-keys", "disabled", "panel-visible", "theme-style", "indicator-enabled"])
302
+ ]),
303
+ _: 3
304
+ }, 8, ["class", "aria-disabled", "data-item-key"]));
305
+ }
306
+ }), Oe = (h, S) => {
307
+ const i = M(), u = M(!1);
308
+ let v, c, P, I = !1;
309
+ const E = () => {
310
+ var w;
311
+ const { items: f, selectedKey: l, enabled: y } = S(), n = (w = h.value) == null ? void 0 : w.parentElement, K = f.find(
312
+ (r) => {
313
+ var e;
314
+ return r.key === l && !r.disabled && !r.opensInNewTab && !((e = r.children) != null && e.length);
315
+ }
316
+ ), d = y && K && n ? Array.from(n.children).find(
317
+ (r) => r instanceof HTMLElement && r.classList.contains("arco-menu-item") && r.dataset.itemKey === K.key
318
+ ) : void 0;
319
+ if (!d || !n) {
320
+ i.value = void 0, P = void 0, u.value = !1;
321
+ return;
322
+ }
323
+ P !== l && (u.value = P !== void 0), i.value = d.offsetTop + (d.offsetHeight - 24) / 2, P = l;
324
+ }, b = () => {
325
+ c !== void 0 && cancelAnimationFrame(c), c = requestAnimationFrame(() => {
326
+ c = void 0, E();
327
+ });
328
+ };
329
+ return O(
330
+ S,
331
+ async () => {
332
+ await Z(), I || E();
333
+ },
334
+ { deep: !0, flush: "post" }
335
+ ), ye(() => {
336
+ var l;
337
+ if (E(), typeof ResizeObserver > "u") return;
338
+ const f = (l = h.value) == null ? void 0 : l.parentElement;
339
+ f && (v = new ResizeObserver(b), v.observe(f));
340
+ }), re(() => {
341
+ I = !0, v == null || v.disconnect(), c !== void 0 && cancelAnimationFrame(c);
342
+ }), { offset: i, animated: u };
343
+ }, De = ["data-animated"], Ae = { class: "fkp-navigation-menu-label" }, Ge = {
344
+ key: 0,
345
+ class: "fkp-navigation-open",
346
+ "aria-hidden": "true"
347
+ }, oe = /* @__PURE__ */ J({
348
+ name: "NavigationNodes",
349
+ __name: "NavigationNodes",
350
+ props: {
351
+ items: {},
352
+ section: {},
353
+ level: { default: 0 },
354
+ selectedKey: {},
355
+ expandedKeys: { default: () => [] },
356
+ disabled: { type: Boolean, default: !1 },
357
+ collapsed: { type: Boolean, default: !1 },
358
+ inPopup: { type: Boolean, default: !1 },
359
+ panelVisible: { type: Boolean, default: !1 },
360
+ themeStyle: {},
361
+ indicatorEnabled: { type: Boolean, default: !0 }
362
+ },
363
+ emits: ["group-open", "select"],
364
+ setup(h, { emit: S }) {
365
+ const i = h, u = S, v = fe(), c = M(), P = M(), { offset: I, animated: E } = Oe(P, () => ({
366
+ items: i.items,
367
+ selectedKey: i.selectedKey,
368
+ enabled: !!i.level && !i.inPopup && !i.collapsed && !i.disabled && i.indicatorEnabled
369
+ })), b = (n) => Array.isArray(n) ? n.some(b) : typeof n == "string" ? n.trim().length > 0 : !me(n) || n.type === ve ? !1 : n.type === G || n.type === ke ? b(n.children) : !0, f = (n) => {
370
+ var K;
371
+ return !i.level || n.icon || n.iconUrl ? !0 : b(
372
+ (K = v["item-icon"]) == null ? void 0 : K.call(v, { item: n, section: i.section, level: i.level })
373
+ );
374
+ }, l = (n) => {
375
+ c.value = n, u("group-open");
376
+ }, y = (n, K) => {
377
+ n.key !== "Enter" && n.key !== " " || (n.preventDefault(), n.stopPropagation(), K || n.currentTarget.click());
378
+ };
379
+ return (n, K) => (p(), $(G, null, [
380
+ n.level && !n.inPopup && !n.collapsed ? (p(), $("span", {
381
+ key: 0,
382
+ ref_key: "indicator",
383
+ ref: P,
384
+ class: "fkp-navigation-selected-indicator",
385
+ "data-animated": g(E),
386
+ style: W({
387
+ visibility: g(I) === void 0 ? "hidden" : "visible",
388
+ transform: `translateY(${g(I) ?? 0}px)`
389
+ }),
390
+ "aria-hidden": "true"
391
+ }, null, 12, De)) : C("", !0),
392
+ (p(!0), $(G, null, Q(n.items, (d) => {
393
+ var w;
394
+ return p(), $(G, {
395
+ key: d.key
396
+ }, [
397
+ (w = d.children) != null && w.length ? (p(), U(Me, {
398
+ key: 0,
399
+ item: d,
400
+ section: n.section,
401
+ level: n.level,
402
+ "selected-key": n.selectedKey,
403
+ "expanded-keys": n.expandedKeys,
404
+ disabled: n.disabled,
405
+ collapsed: n.collapsed,
406
+ "in-popup": n.inPopup,
407
+ "panel-visible": n.panelVisible,
408
+ "active-group-key": c.value,
409
+ "theme-style": n.themeStyle,
410
+ onSelect: K[0] || (K[0] = (r) => u("select", r)),
411
+ onGroupOpen: (r) => l(d.key)
412
+ }, L({ _: 2 }, [
413
+ n.$slots["item-icon"] ? {
414
+ name: "item-icon",
415
+ fn: m((r) => [
416
+ z(n.$slots, "item-icon", X({ ref_for: !0 }, r))
417
+ ]),
418
+ key: "0"
419
+ } : void 0
420
+ ]), 1032, ["item", "section", "level", "selected-key", "expanded-keys", "disabled", "collapsed", "in-popup", "panel-visible", "active-group-key", "theme-style", "onGroupOpen"])) : (p(), U(g(he), {
421
+ key: d.key,
422
+ disabled: n.disabled || d.disabled,
423
+ "data-item-key": d.key,
424
+ role: "menuitem",
425
+ tabindex: n.disabled || d.disabled ? -1 : 0,
426
+ "aria-label": d.label,
427
+ "aria-disabled": n.disabled || d.disabled || void 0,
428
+ "aria-current": !d.opensInNewTab && n.selectedKey === d.key ? "page" : void 0,
429
+ onKeydown: (r) => y(r, n.disabled || !!d.disabled),
430
+ onClick: (r) => u("select", d.key)
431
+ }, L({
432
+ default: m(() => [
433
+ V("span", Ae, A(d.label), 1),
434
+ d.opensInNewTab ? (p(), $("span", Ge, [
435
+ B(g(_), {
436
+ name: "open",
437
+ size: 16
438
+ })
439
+ ])) : C("", !0)
440
+ ]),
441
+ _: 2
442
+ }, [
443
+ f(d) ? {
444
+ name: "icon",
445
+ fn: m(() => [
446
+ B(Y, {
447
+ icon: d.icon,
448
+ "icon-url": d.iconUrl,
449
+ size: n.level ? 16 : 24
450
+ }, {
451
+ default: m(() => [
452
+ z(n.$slots, "item-icon", {
453
+ item: d,
454
+ section: n.section,
455
+ level: n.level
456
+ })
457
+ ]),
458
+ _: 2
459
+ }, 1032, ["icon", "icon-url", "size"])
460
+ ]),
461
+ key: "0"
462
+ } : void 0
463
+ ]), 1032, ["disabled", "data-item-key", "tabindex", "aria-label", "aria-disabled", "aria-current", "onKeydown", "onClick"]))
464
+ ], 64);
465
+ }), 128))
466
+ ], 64));
467
+ }
468
+ }), Le = (h, S) => h.length === S.length && h.every((i, u) => i === S[u]), Re = (h, S) => {
469
+ const i = M([]), u = F(() => {
470
+ const f = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), y = (n, K, d, w) => {
471
+ var r;
472
+ for (const e of n) {
473
+ const k = w || !!e.disabled;
474
+ l.set(e.key, { item: e, sectionKey: K, ancestorKeys: d, disabled: k }), (r = e.children) != null && r.length && (f.add(e.key), y(
475
+ e.children,
476
+ K,
477
+ [...d, e.key],
478
+ k
479
+ ));
480
+ }
481
+ };
482
+ return h.sections.forEach(
483
+ (n) => y(n.items, n.key, [], !1)
484
+ ), { groupKeys: f, entries: l };
485
+ }), v = F(
486
+ () => [...h.expandedKeys ?? i.value].filter(
487
+ (f) => u.value.groupKeys.has(f)
488
+ )
489
+ ), c = F(
490
+ () => h.selectedKey !== void 0 ? u.value.entries.get(h.selectedKey) : void 0
491
+ ), P = F(() => {
492
+ var l, y;
493
+ const f = (l = c.value) == null ? void 0 : l.item;
494
+ return f && !f.opensInNewTab && !((y = f.children) != null && y.length) ? [f.key] : [];
495
+ }), I = (f) => {
496
+ const l = [...new Set(f)].filter(
497
+ (n) => u.value.groupKeys.has(n)
498
+ ), y = new Set(
499
+ h.expandedKeys ?? i.value
500
+ );
501
+ y.size === l.length && l.every((n) => y.has(n)) || (h.expandedKeys === void 0 && (i.value = l), S(l));
502
+ }, E = (f, l) => {
503
+ const y = v.value.filter(
504
+ (n) => {
505
+ var K;
506
+ return ((K = u.value.entries.get(n)) == null ? void 0 : K.sectionKey) !== f;
507
+ }
508
+ );
509
+ I([...y, ...l]);
510
+ }, b = (f) => {
511
+ var y;
512
+ const l = u.value.entries.get(f);
513
+ return l && !l.disabled && !((y = l.item.children) != null && y.length) ? l.item : void 0;
514
+ };
515
+ return O(
516
+ [() => h.selectedKey, () => [...u.value.groupKeys]],
517
+ ([f, l], [y, n]) => {
518
+ var r;
519
+ if (n && f === y && Le(l, n))
520
+ return;
521
+ const K = new Set(n), d = l.filter((e) => !K.has(e)), w = h.expandedKeys ?? [
522
+ ...v.value,
523
+ ...d
524
+ ];
525
+ I([
526
+ ...w,
527
+ ...((r = c.value) == null ? void 0 : r.ancestorKeys) ?? []
528
+ ]);
529
+ },
530
+ { immediate: !0 }
531
+ ), {
532
+ expandedKeys: v,
533
+ selectedKeys: P,
534
+ updateSectionExpandedKeys: E,
535
+ getSelectableItem: b
536
+ };
537
+ }, qe = ["aria-label"], je = ["data-section-key"], He = ["aria-label", "aria-expanded", "disabled", "onKeydown"], We = ["aria-label"], Ye = { class: "fkp-navigation-editor-title" }, Je = {
538
+ key: 0,
539
+ class: "fkp-navigation-editor-divider",
540
+ role: "separator"
541
+ }, Qe = { class: "fkp-navigation-editor-label" }, Xe = {
542
+ key: 1,
543
+ class: "fkp-navigation-items"
544
+ }, Ze = ["aria-expanded", "onKeydown"], _e = { class: "fkp-navigation-item-icon" }, xe = { key: 0 }, eo = {
545
+ key: 0,
546
+ class: "fkp-navigation-footer-actions"
547
+ }, oo = ["aria-label", "title", "aria-expanded"], to = /* @__PURE__ */ J({
548
+ name: "FkpNavigation",
549
+ __name: "FkpNavigation",
550
+ props: {
551
+ sections: {},
552
+ selectedKey: {},
553
+ expandedKeys: {},
554
+ collapsed: { type: Boolean, default: !1 },
555
+ showSectionTitles: { type: Boolean, default: !0 },
556
+ reordering: { type: Boolean, default: !1 },
557
+ ariaLabel: { default: "导航" },
558
+ theme: {},
559
+ showCollapseButton: { type: Boolean, default: !1 }
560
+ },
561
+ emits: ["open", "update:expandedKeys", "update:collapsed", "reorder", "panel-open", "select"],
562
+ setup(h, { emit: S }) {
563
+ const i = h, u = S, v = M(), c = `fkp-navigation-${be()}`, P = F(() => {
564
+ var t;
565
+ const o = {}, a = {
566
+ hoverBg: "--fkp-navigation-hover-bg",
567
+ hoverColor: "--fkp-navigation-hover-color",
568
+ selectedBg: "--fkp-navigation-selected-bg",
569
+ selectedColor: "--fkp-navigation-selected-color",
570
+ indicatorColor: "--fkp-navigation-indicator-color"
571
+ };
572
+ for (const s of Object.keys(a)) {
573
+ const T = (t = i.theme) == null ? void 0 : t[s];
574
+ T !== void 0 && (o[a[s]] = T);
575
+ }
576
+ return o;
577
+ }), I = F(
578
+ () => i.sections.filter((o) => o.items.length > 0).map((o) => {
579
+ const a = o.items.every((T) => {
580
+ var q;
581
+ return !((q = T.children) != null && q.length);
582
+ }), { maxVisible: t } = o, s = a && t !== void 0 && Number.isInteger(t) && t > 0 ? t : o.items.length;
583
+ return {
584
+ section: o,
585
+ isFlat: a,
586
+ visibleLimit: s,
587
+ sortable: a && !!o.sortable,
588
+ visibleItems: o.items.slice(0, s),
589
+ overflowItems: o.items.slice(s)
590
+ };
591
+ })
592
+ ), {
593
+ expandedKeys: E,
594
+ selectedKeys: b,
595
+ updateSectionExpandedKeys: f,
596
+ getSelectableItem: l
597
+ } = Re(i, (o) => u("update:expandedKeys", o)), y = M(), n = M(), K = M(), d = {
598
+ more: /* @__PURE__ */ new Map(),
599
+ sort: /* @__PURE__ */ new Map()
600
+ }, w = (o, a) => {
601
+ var t;
602
+ return ((t = y.value) == null ? void 0 : t.sectionKey) === o && y.value.panel === a;
603
+ }, r = (o = !1) => {
604
+ var t;
605
+ const a = y.value;
606
+ a && (y.value = void 0, n.value = void 0, u("panel-open", { ...a, visible: !1 }), o && ((t = K.value) == null || t.focus()));
607
+ }, e = (o, a, t) => {
608
+ if (!t) {
609
+ w(o, a) && r();
610
+ return;
611
+ }
612
+ w(o, a) || (r(), y.value = { sectionKey: o, panel: a }, u("panel-open", { sectionKey: o, panel: a, visible: !0 }));
613
+ }, k = (o) => {
614
+ K.value = o.currentTarget;
615
+ }, N = (o, a, t) => {
616
+ t instanceof HTMLElement ? d[a].set(o, t) : d[a].delete(o);
617
+ }, R = async (o, a) => {
618
+ var s, T;
619
+ if (((s = n.value) == null ? void 0 : s.sectionKey) !== o || n.value.panel !== a || !w(o, a))
620
+ return;
621
+ await Z();
622
+ const t = (T = d[a].get(o)) == null ? void 0 : T.querySelector('button:not(:disabled), [tabindex="0"]');
623
+ t && (t.focus(), n.value = void 0);
624
+ }, te = (o, a, t) => {
625
+ o.key !== "Enter" && o.key !== " " || (o.preventDefault(), o.stopPropagation(), !o.currentTarget.disabled && (k(o), e(a, t, !0), n.value = { sectionKey: a, panel: t }, R(a, t)));
626
+ };
627
+ O(
628
+ () => i.collapsed,
629
+ () => r()
630
+ ), O(
631
+ () => i.showSectionTitles,
632
+ async (o) => {
633
+ var T, q, ne;
634
+ if (o || ((T = y.value) == null ? void 0 : T.panel) !== "sort") return;
635
+ const { sectionKey: a } = y.value;
636
+ r(), await Z();
637
+ const t = Array.from(
638
+ ((q = v.value) == null ? void 0 : q.querySelectorAll(
639
+ ".fkp-navigation-section"
640
+ )) ?? []
641
+ ).find((ce) => ce.dataset.sectionKey === a);
642
+ (ne = (t == null ? void 0 : t.querySelector(
643
+ 'button:not(:disabled), [tabindex="0"]'
644
+ )) ?? v.value) == null || ne.focus();
645
+ }
646
+ ), O(
647
+ I,
648
+ () => {
649
+ const o = y.value;
650
+ if (!o) return;
651
+ const a = I.value.find(
652
+ (t) => t.section.key === o.sectionKey
653
+ );
654
+ (!a || (o.panel === "more" ? !a.overflowItems.length : !a.sortable || !a.section.title || a.section.items.length < 2)) && r();
655
+ },
656
+ { deep: !0 }
657
+ ), re(() => r());
658
+ const x = (o) => {
659
+ const a = l(o);
660
+ a && (a.opensInNewTab ? u("open", a.key, a) : u("select", a.key), r());
661
+ }, pe = (o, a) => {
662
+ if (i.reordering || !o.sortable || o.items.some((s) => {
663
+ var T;
664
+ return (T = s.children) == null ? void 0 : T.length;
665
+ }))
666
+ return;
667
+ const t = a.map((s) => String(s.key));
668
+ t.length !== o.items.length || new Set(t).size !== t.length || t.some((s) => !o.items.some((T) => T.key === s)) || u("reorder", { sectionKey: o.key, keys: t });
669
+ }, ue = F(() => ({
670
+ class: "fkp-navigation-group-popup",
671
+ popupOffset: 24,
672
+ mouseLeaveDelay: 180,
673
+ autoFitPopupMinWidth: !1,
674
+ contentStyle: P.value
675
+ }));
676
+ return (o, a) => (p(), $("nav", {
677
+ ref_key: "navigation",
678
+ ref: v,
679
+ class: D(["fkp-navigation", {
680
+ "fkp-navigation-collapsed": o.collapsed,
681
+ "fkp-navigation-without-titles": !o.showSectionTitles
682
+ }]),
683
+ style: W(P.value),
684
+ "aria-label": o.ariaLabel,
685
+ tabindex: "-1"
686
+ }, [
687
+ B(g(Ke), {
688
+ type: "embed",
689
+ "outer-class": "fkp-navigation-scroll",
690
+ class: "fkp-navigation-scroll-container"
691
+ }, {
692
+ default: m(() => [
693
+ V("div", {
694
+ id: c,
695
+ class: "fkp-navigation-content"
696
+ }, [
697
+ (p(!0), $(G, null, Q(I.value, (t) => (p(), $("section", {
698
+ key: t.section.key,
699
+ class: "fkp-navigation-section",
700
+ "data-section-key": t.section.key
701
+ }, [
702
+ !o.collapsed && o.showSectionTitles && t.section.title ? (p(), $("div", {
703
+ key: 0,
704
+ class: D(["fkp-navigation-heading", {
705
+ "is-editing": w(t.section.key, "sort")
706
+ }])
707
+ }, [
708
+ V("span", null, A(t.section.title), 1),
709
+ t.sortable ? (p(), U(g(ee), {
710
+ key: 0,
711
+ "popup-visible": w(t.section.key, "sort"),
712
+ trigger: "click",
713
+ position: "rt",
714
+ "popup-offset": 8,
715
+ "show-arrow": !1,
716
+ "onUpdate:popupVisible": (s) => e(t.section.key, "sort", s),
717
+ onShow: (s) => R(t.section.key, "sort")
718
+ }, {
719
+ content: m(() => [
720
+ V("div", {
721
+ ref_for: !0,
722
+ ref: (s) => N(t.section.key, "sort", s),
723
+ class: "fkp-navigation-editor",
724
+ style: W(P.value),
725
+ role: "dialog",
726
+ "aria-label": `调整${t.section.title || "导航"}顺序`,
727
+ onKeydown: a[1] || (a[1] = j(H((s) => r(!0), ["stop", "prevent"]), ["esc"]))
728
+ }, [
729
+ V("div", Ye, A(t.section.title || "导航") + "(可拖拽排序)", 1),
730
+ w(t.section.key, "sort") ? (p(), U(g($e), {
731
+ key: 0,
732
+ class: "fkp-navigation-editor-list",
733
+ "model-value": [...t.section.items],
734
+ disabled: o.reordering,
735
+ "handle-label": "拖拽排序",
736
+ "onUpdate:modelValue": (s) => pe(t.section, s)
737
+ }, {
738
+ "before-item": m(({ index: s }) => [
739
+ t.overflowItems.length && s === t.visibleLimit ? (p(), $("div", Je)) : C("", !0)
740
+ ]),
741
+ handle: m(() => [
742
+ B(g(Pe))
743
+ ]),
744
+ default: m(({ item: s }) => [
745
+ B(Y, {
746
+ icon: s.icon,
747
+ "icon-url": s.iconUrl
748
+ }, {
749
+ default: m(() => [
750
+ z(o.$slots, "item-icon", {
751
+ item: s,
752
+ section: t.section,
753
+ level: 0
754
+ })
755
+ ]),
756
+ _: 2
757
+ }, 1032, ["icon", "icon-url"]),
758
+ V("span", Qe, A(s.label), 1)
759
+ ]),
760
+ _: 2
761
+ }, 1032, ["model-value", "disabled", "onUpdate:modelValue"])) : C("", !0)
762
+ ], 44, We)
763
+ ]),
764
+ default: m(() => [
765
+ V("button", {
766
+ type: "button",
767
+ class: "fkp-navigation-edit",
768
+ "aria-label": `调整${t.section.title || "导航"}顺序`,
769
+ "aria-haspopup": "dialog",
770
+ "aria-expanded": w(t.section.key, "sort"),
771
+ disabled: o.reordering || t.section.items.length < 2,
772
+ onPointerdown: k,
773
+ onFocus: k,
774
+ onKeydown: [
775
+ (s) => te(s, t.section.key, "sort"),
776
+ a[0] || (a[0] = j(H((s) => r(!0), ["stop", "prevent"]), ["esc"]))
777
+ ]
778
+ }, [
779
+ B(g(_), {
780
+ name: "edit",
781
+ size: 16
782
+ })
783
+ ], 40, He)
784
+ ]),
785
+ _: 2
786
+ }, 1032, ["popup-visible", "onUpdate:popupVisible", "onShow"])) : C("", !0)
787
+ ], 2)) : C("", !0),
788
+ t.isFlat ? (p(), $("div", Xe, [
789
+ (p(!0), $(G, null, Q(t.visibleItems, (s) => (p(), U(g(Se), {
790
+ key: s.key,
791
+ content: s.label,
792
+ disabled: !o.collapsed,
793
+ position: "right"
794
+ }, {
795
+ default: m(() => [
796
+ B(le, {
797
+ item: s,
798
+ section: t.section,
799
+ "selected-key": o.selectedKey,
800
+ collapsed: o.collapsed,
801
+ onSelect: x
802
+ }, L({ _: 2 }, [
803
+ o.$slots["item-icon"] ? {
804
+ name: "item-icon",
805
+ fn: m((T) => [
806
+ z(o.$slots, "item-icon", X({ ref_for: !0 }, T))
807
+ ]),
808
+ key: "0"
809
+ } : void 0
810
+ ]), 1032, ["item", "section", "selected-key", "collapsed"])
811
+ ]),
812
+ _: 2
813
+ }, 1032, ["content", "disabled"]))), 128)),
814
+ t.overflowItems.length ? (p(), U(g(ee), {
815
+ key: 0,
816
+ "popup-visible": w(t.section.key, "more"),
817
+ trigger: ["hover", "click"],
818
+ position: "rt",
819
+ "popup-offset": 24,
820
+ "mouse-leave-delay": 180,
821
+ "show-arrow": !1,
822
+ "onUpdate:popupVisible": (s) => e(t.section.key, "more", s),
823
+ onShow: (s) => R(t.section.key, "more")
824
+ }, {
825
+ content: m(() => [
826
+ V("div", {
827
+ ref_for: !0,
828
+ ref: (s) => N(t.section.key, "more", s),
829
+ class: "fkp-navigation-more",
830
+ style: W(P.value),
831
+ role: "dialog",
832
+ "aria-label": "更多导航",
833
+ onKeydown: a[3] || (a[3] = j(H((s) => r(!0), ["stop", "prevent"]), ["esc"]))
834
+ }, [
835
+ (p(!0), $(G, null, Q(t.overflowItems, (s) => (p(), U(le, {
836
+ key: s.key,
837
+ item: s,
838
+ section: t.section,
839
+ "selected-key": o.selectedKey,
840
+ onSelect: x
841
+ }, L({ _: 2 }, [
842
+ o.$slots["item-icon"] ? {
843
+ name: "item-icon",
844
+ fn: m((T) => [
845
+ z(o.$slots, "item-icon", X({ ref_for: !0 }, T))
846
+ ]),
847
+ key: "0"
848
+ } : void 0
849
+ ]), 1032, ["item", "section", "selected-key"]))), 128))
850
+ ], 36)
851
+ ]),
852
+ default: m(() => [
853
+ V("button", {
854
+ type: "button",
855
+ class: D(["fkp-navigation-item fkp-navigation-more-trigger", {
856
+ "is-selected": t.overflowItems.some(
857
+ (s) => !s.opensInNewTab && s.key === o.selectedKey
858
+ )
859
+ }]),
860
+ "aria-label": "更多导航",
861
+ "aria-haspopup": "dialog",
862
+ "aria-expanded": w(t.section.key, "more"),
863
+ onPointerenter: k,
864
+ onPointerdown: k,
865
+ onFocus: k,
866
+ onKeydown: [
867
+ (s) => te(s, t.section.key, "more"),
868
+ a[2] || (a[2] = j(H((s) => r(!0), ["stop", "prevent"]), ["esc"]))
869
+ ]
870
+ }, [
871
+ V("span", _e, [
872
+ B(g(we))
873
+ ]),
874
+ o.collapsed ? C("", !0) : (p(), $("span", xe, "更多"))
875
+ ], 42, Ze)
876
+ ]),
877
+ _: 2
878
+ }, 1032, ["popup-visible", "onUpdate:popupVisible", "onShow"])) : C("", !0)
879
+ ])) : (p(), U(g(de), {
880
+ key: 2,
881
+ class: "fkp-navigation-menu",
882
+ collapsed: o.collapsed,
883
+ "selected-keys": g(b),
884
+ "open-keys": g(E),
885
+ "auto-open-selected": !1,
886
+ "trigger-props": ue.value,
887
+ "onUpdate:openKeys": (s) => g(f)(t.section.key, s)
888
+ }, {
889
+ default: m(() => [
890
+ B(oe, {
891
+ items: t.section.items,
892
+ section: t.section,
893
+ "selected-key": o.selectedKey,
894
+ "expanded-keys": g(E),
895
+ collapsed: o.collapsed,
896
+ "panel-visible": !!y.value,
897
+ "theme-style": P.value,
898
+ onSelect: x,
899
+ onGroupOpen: a[4] || (a[4] = (s) => r())
900
+ }, L({ _: 2 }, [
901
+ o.$slots["item-icon"] ? {
902
+ name: "item-icon",
903
+ fn: m((s) => [
904
+ z(o.$slots, "item-icon", X({ ref_for: !0 }, s))
905
+ ]),
906
+ key: "0"
907
+ } : void 0
908
+ ]), 1032, ["items", "section", "selected-key", "expanded-keys", "collapsed", "panel-visible", "theme-style"])
909
+ ]),
910
+ _: 2
911
+ }, 1032, ["collapsed", "selected-keys", "open-keys", "trigger-props", "onUpdate:openKeys"]))
912
+ ], 8, je))), 128))
913
+ ])
914
+ ]),
915
+ _: 3
916
+ }),
917
+ o.showCollapseButton || o.$slots["footer-actions"] ? (p(), $("footer", {
918
+ key: 0,
919
+ class: D(["fkp-navigation-footer", {
920
+ "has-collapse-button": o.showCollapseButton,
921
+ "has-footer-actions": !!o.$slots["footer-actions"]
922
+ }])
923
+ }, [
924
+ o.$slots["footer-actions"] ? (p(), $("div", eo, [
925
+ z(o.$slots, "footer-actions", { collapsed: o.collapsed })
926
+ ])) : C("", !0),
927
+ o.showCollapseButton ? (p(), $("button", {
928
+ key: 1,
929
+ type: "button",
930
+ class: "fkp-navigation-collapse",
931
+ "aria-label": o.collapsed ? "展开侧栏" : "收起侧栏",
932
+ title: o.collapsed ? "展开侧栏" : "收起侧栏",
933
+ "aria-expanded": !o.collapsed,
934
+ "aria-controls": c,
935
+ onClick: a[5] || (a[5] = (t) => u("update:collapsed", !o.collapsed))
936
+ }, [
937
+ B(g(Ie), { size: 16 })
938
+ ], 8, oo)) : C("", !0)
939
+ ], 2)) : C("", !0)
940
+ ], 14, qe));
941
+ }
942
+ }), lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
943
+ __proto__: null,
944
+ FkpNavigation: to
945
+ }, Symbol.toStringTag, { value: "Module" }));
946
+ export {
947
+ lo as N,
948
+ to as _
949
+ };