vue-devui 1.5.3 → 1.5.4-alpha.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,845 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode, Transition, mergeProps, unref, nextTick, withModifiers, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, provide, Teleport, vShow, getCurrentInstance, onBeforeUnmount, resolveComponent } from "vue";
21
+ import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
22
+ const breadcrumbProps = {
23
+ source: {
24
+ type: Array,
25
+ default: []
26
+ },
27
+ separatorIcon: {
28
+ type: String
29
+ }
30
+ };
31
+ const breadcrumbItemProps = {
32
+ showMenu: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ menuList: {
37
+ type: Array
38
+ },
39
+ isSearch: {
40
+ type: Boolean,
41
+ dafault: false
42
+ },
43
+ to: {
44
+ type: [String, Object],
45
+ default: ""
46
+ },
47
+ replace: {
48
+ type: Boolean,
49
+ default: false
50
+ }
51
+ };
52
+ function createBem(namespace, element, modifier) {
53
+ let cls = namespace;
54
+ if (element) {
55
+ cls += `__${element}`;
56
+ }
57
+ if (modifier) {
58
+ cls += `--${modifier}`;
59
+ }
60
+ return cls;
61
+ }
62
+ function useNamespace(block, needDot = false) {
63
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
64
+ const b = () => createBem(namespace);
65
+ const e = (element) => element ? createBem(namespace, element) : "";
66
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
67
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
68
+ return {
69
+ b,
70
+ e,
71
+ m,
72
+ em
73
+ };
74
+ }
75
+ var breadcrumbItem = "";
76
+ const dropdownProps = {
77
+ visible: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ trigger: {
82
+ type: String,
83
+ default: "click"
84
+ },
85
+ closeScope: {
86
+ type: String,
87
+ default: "all"
88
+ },
89
+ position: {
90
+ type: Array,
91
+ default: ["bottom"]
92
+ },
93
+ align: {
94
+ type: String,
95
+ default: null
96
+ },
97
+ offset: {
98
+ type: [Number, Object],
99
+ default: 4
100
+ },
101
+ shiftOffset: {
102
+ type: Number
103
+ },
104
+ closeOnMouseLeaveMenu: {
105
+ type: Boolean,
106
+ default: false
107
+ },
108
+ showAnimation: {
109
+ type: Boolean,
110
+ default: true
111
+ },
112
+ overlayClass: {
113
+ type: String,
114
+ default: ""
115
+ },
116
+ destroyOnHide: {
117
+ type: Boolean,
118
+ default: true
119
+ }
120
+ };
121
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
122
+ function getElement(element) {
123
+ if (element instanceof Element) {
124
+ return element;
125
+ }
126
+ if (element && typeof element === "object" && element.$el instanceof Element) {
127
+ return element.$el;
128
+ }
129
+ return null;
130
+ }
131
+ const dropdownMap = /* @__PURE__ */ new Map();
132
+ function subscribeEvent(dom, type, callback) {
133
+ dom == null ? void 0 : dom.addEventListener(type, callback);
134
+ return () => {
135
+ dom == null ? void 0 : dom.removeEventListener(type, callback);
136
+ };
137
+ }
138
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
139
+ let overlayEnter = false;
140
+ let originEnter = false;
141
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
142
+ const toggle = (status) => {
143
+ isOpen.value = status;
144
+ emit("toggle", isOpen.value);
145
+ };
146
+ const handleLeave = async (elementType, closeAll) => {
147
+ await new Promise((resolve) => setTimeout(resolve, 50));
148
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
149
+ return;
150
+ }
151
+ if (closeAll) {
152
+ [...dropdownMap.values()].reverse().forEach((item) => {
153
+ setTimeout(() => {
154
+ var _a;
155
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
156
+ }, 0);
157
+ });
158
+ }
159
+ toggle(false);
160
+ };
161
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
162
+ const originEl = getElement(originVal);
163
+ const subscriptions = [];
164
+ setTimeout(() => {
165
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
166
+ e.stopPropagation();
167
+ const dropdownValues = [...dropdownMap.values()];
168
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
169
+ var _a;
170
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
171
+ }) && dropdownValues.some((item) => {
172
+ var _a;
173
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
174
+ })) {
175
+ return;
176
+ }
177
+ [...dropdownMap.values()].reverse().forEach((item) => {
178
+ setTimeout(() => {
179
+ var _a, _b;
180
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
181
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
182
+ }
183
+ }, 0);
184
+ });
185
+ overlayEnter = false;
186
+ }));
187
+ }, 0);
188
+ if (triggerVal === "click") {
189
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
190
+ var _a;
191
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
192
+ handleLeave("dropdown", true);
193
+ }
194
+ }));
195
+ } else if (triggerVal === "hover") {
196
+ subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
197
+ originEnter = true;
198
+ toggle(true);
199
+ }), subscribeEvent(originEl, "mouseleave", () => {
200
+ originEnter = false;
201
+ handleLeave("origin");
202
+ }), subscribeEvent(dropdownEl, "mouseenter", () => {
203
+ overlayEnter = true;
204
+ isOpen.value = true;
205
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
206
+ var _a;
207
+ overlayEnter = false;
208
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
209
+ return;
210
+ }
211
+ handleLeave("dropdown", true);
212
+ }));
213
+ }
214
+ onInvalidate(() => subscriptions.forEach((v) => v()));
215
+ });
216
+ };
217
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
218
+ const calcPopDirection = (dropdownEl) => {
219
+ const elementHeight = dropdownEl.offsetHeight;
220
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
221
+ const isBottomEnough = bottomDistance >= elementHeight;
222
+ if (!isBottomEnough) {
223
+ popDirection.value = "top";
224
+ } else {
225
+ popDirection.value = "bottom";
226
+ }
227
+ };
228
+ watch(visible, (newVal, oldVal) => {
229
+ if (oldVal === void 0) {
230
+ return;
231
+ }
232
+ isOpen.value = newVal;
233
+ emit("toggle", isOpen.value);
234
+ }, { immediate: true });
235
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
236
+ var _a;
237
+ if (isOpenVal) {
238
+ dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
239
+ menuEl: dropdownEl,
240
+ toggle: () => {
241
+ isOpen.value = false;
242
+ emit("toggle", isOpen.value);
243
+ }
244
+ }));
245
+ for (const value of dropdownMap.values()) {
246
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
247
+ value.child = dropdownEl;
248
+ }
249
+ }
250
+ }
251
+ if (dropdownEl) {
252
+ calcPopDirection(dropdownEl);
253
+ }
254
+ });
255
+ onMounted(() => {
256
+ dropdownMap.set(id, { toggleEl: origin.value });
257
+ });
258
+ onUnmounted(() => {
259
+ dropdownMap.delete(id);
260
+ });
261
+ }
262
+ function useOverlayProps(props, currentPosition, isOpen) {
263
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
264
+ const overlayModelValue = ref(false);
265
+ const overlayShowValue = ref(false);
266
+ const styles = computed(() => ({
267
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
268
+ zIndex: "var(--devui-z-index-dropdown, 1052)"
269
+ }));
270
+ const classes = computed(() => ({
271
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
272
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
273
+ [`${overlayClass.value}`]: true
274
+ }));
275
+ const handlePositionChange = (pos) => {
276
+ currentPosition.value = pos.includes("top") || pos.includes("right-end") || pos.includes("left-end") ? "top" : "bottom";
277
+ };
278
+ watch(isOpen, (isOpenVal) => {
279
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
280
+ overlayShowValue.value = isOpenVal;
281
+ });
282
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
283
+ }
284
+ const fixedOverlayProps = {
285
+ modelValue: {
286
+ type: Boolean,
287
+ default: false
288
+ },
289
+ lockScroll: {
290
+ type: Boolean,
291
+ default: true
292
+ },
293
+ closeOnClickOverlay: {
294
+ type: Boolean,
295
+ default: true
296
+ }
297
+ };
298
+ function lockScroll() {
299
+ if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
300
+ const scrollTop = document.documentElement.scrollTop;
301
+ const style = document.documentElement.getAttribute("style");
302
+ document.documentElement.style.position = "fixed";
303
+ document.documentElement.style.top = `-${scrollTop}px`;
304
+ document.documentElement.style.width = document.documentElement.style.width || "100%";
305
+ document.documentElement.style.overflowY = "scroll";
306
+ return () => {
307
+ if (style) {
308
+ document.documentElement.setAttribute("style", style);
309
+ } else {
310
+ document.documentElement.removeAttribute("style");
311
+ }
312
+ document.documentElement.scrollTop = scrollTop;
313
+ };
314
+ }
315
+ return;
316
+ }
317
+ function useFixedOverlay(props, ctx) {
318
+ let lockScrollCb;
319
+ const onClick = (event) => {
320
+ event.preventDefault();
321
+ ctx.emit("click", event);
322
+ if (props.closeOnClickOverlay) {
323
+ ctx.emit("update:modelValue", false);
324
+ }
325
+ };
326
+ const removeBodyAdditions = () => {
327
+ lockScrollCb == null ? void 0 : lockScrollCb();
328
+ };
329
+ watch(() => props.modelValue, (val) => {
330
+ if (val) {
331
+ props.lockScroll && (lockScrollCb = lockScroll());
332
+ } else {
333
+ removeBodyAdditions();
334
+ }
335
+ });
336
+ onUnmounted(removeBodyAdditions);
337
+ return { onClick };
338
+ }
339
+ var fixedOverlay = "";
340
+ defineComponent({
341
+ name: "DFixedOverlay",
342
+ inheritAttrs: false,
343
+ props: fixedOverlayProps,
344
+ emits: ["update:modelValue", "click"],
345
+ setup(props, ctx) {
346
+ const {
347
+ modelValue
348
+ } = toRefs(props);
349
+ const ns2 = useNamespace("fixed-overlay");
350
+ const {
351
+ onClick
352
+ } = useFixedOverlay(props, ctx);
353
+ return () => createVNode(Transition, {
354
+ "name": ns2.m("fade")
355
+ }, {
356
+ default: () => {
357
+ var _a, _b;
358
+ return [modelValue.value && createVNode("div", mergeProps({
359
+ "class": ns2.b()
360
+ }, ctx.attrs, {
361
+ "onClick": onClick
362
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
363
+ }
364
+ });
365
+ }
366
+ });
367
+ const flexibleOverlayProps = {
368
+ modelValue: {
369
+ type: Boolean,
370
+ default: false
371
+ },
372
+ origin: {
373
+ type: Object,
374
+ require: true
375
+ },
376
+ position: {
377
+ type: Array,
378
+ default: ["bottom"]
379
+ },
380
+ offset: {
381
+ type: [Number, Object],
382
+ default: 8
383
+ },
384
+ shiftOffset: {
385
+ type: Number
386
+ },
387
+ align: {
388
+ type: String,
389
+ default: null
390
+ },
391
+ showArrow: {
392
+ type: Boolean,
393
+ default: false
394
+ },
395
+ isArrowCenter: {
396
+ type: Boolean,
397
+ default: true
398
+ },
399
+ clickEventBubble: {
400
+ type: Boolean,
401
+ default: false
402
+ }
403
+ };
404
+ function getScrollParent(element) {
405
+ const overflowRegex = /(auto|scroll|hidden)/;
406
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
407
+ const style = window.getComputedStyle(parent);
408
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
409
+ return parent;
410
+ }
411
+ }
412
+ return window;
413
+ }
414
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
415
+ let { x, y } = point;
416
+ if (!isArrowCenter) {
417
+ const { width, height } = originRect;
418
+ if (x && placement.includes("start")) {
419
+ x = 12;
420
+ }
421
+ if (x && placement.includes("end")) {
422
+ x = Math.round(width - 24);
423
+ }
424
+ if (y && placement.includes("start")) {
425
+ y = 10;
426
+ }
427
+ if (y && placement.includes("end")) {
428
+ y = height - 14;
429
+ }
430
+ }
431
+ return { x, y };
432
+ }
433
+ function useOverlay(props, emit) {
434
+ const overlayRef = ref();
435
+ const arrowRef = ref();
436
+ let originParent = null;
437
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
438
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
439
+ const staticSide = {
440
+ top: "bottom",
441
+ right: "left",
442
+ bottom: "top",
443
+ left: "right"
444
+ }[placement.split("-")[0]];
445
+ Object.assign(arrowEl.style, {
446
+ left: x ? `${x}px` : "",
447
+ top: y ? `${y}px` : "",
448
+ right: "",
449
+ bottom: "",
450
+ [staticSide]: "-4px"
451
+ });
452
+ };
453
+ const updatePosition = async () => {
454
+ const hostEl = props.origin;
455
+ const overlayEl = unref(overlayRef.value);
456
+ const arrowEl = unref(arrowRef.value);
457
+ const middleware = [
458
+ offset(props.offset),
459
+ autoPlacement({
460
+ alignment: props.align,
461
+ allowedPlacements: props.position
462
+ })
463
+ ];
464
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
465
+ props.shiftOffset !== void 0 && middleware.push(shift());
466
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
467
+ strategy: "fixed",
468
+ middleware
469
+ });
470
+ let applyX = x;
471
+ let applyY = y;
472
+ if (props.shiftOffset !== void 0) {
473
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
474
+ shiftX < 0 && (applyX -= props.shiftOffset);
475
+ shiftX > 0 && (applyX += props.shiftOffset);
476
+ shiftY < 0 && (applyY -= props.shiftOffset);
477
+ shiftY > 0 && (applyY += props.shiftOffset);
478
+ }
479
+ emit("positionChange", placement);
480
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
481
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
482
+ };
483
+ watch(() => props.modelValue, () => {
484
+ if (props.modelValue && props.origin) {
485
+ originParent = getScrollParent(props.origin);
486
+ nextTick(updatePosition);
487
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
488
+ originParent !== window && window.addEventListener("scroll", updatePosition);
489
+ window.addEventListener("resize", updatePosition);
490
+ } else {
491
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
492
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
493
+ window.removeEventListener("resize", updatePosition);
494
+ }
495
+ });
496
+ onUnmounted(() => {
497
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
498
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
499
+ window.removeEventListener("resize", updatePosition);
500
+ });
501
+ return { arrowRef, overlayRef, updatePosition };
502
+ }
503
+ var flexibleOverlay = "";
504
+ const FlexibleOverlay = defineComponent({
505
+ name: "DFlexibleOverlay",
506
+ inheritAttrs: false,
507
+ props: flexibleOverlayProps,
508
+ emits: ["update:modelValue", "positionChange"],
509
+ setup(props, {
510
+ slots,
511
+ attrs,
512
+ emit,
513
+ expose
514
+ }) {
515
+ const ns2 = useNamespace("flexible-overlay");
516
+ const {
517
+ clickEventBubble
518
+ } = toRefs(props);
519
+ const {
520
+ arrowRef,
521
+ overlayRef,
522
+ updatePosition
523
+ } = useOverlay(props, emit);
524
+ expose({
525
+ updatePosition
526
+ });
527
+ return () => {
528
+ var _a;
529
+ return props.modelValue && createVNode("div", mergeProps({
530
+ "ref": overlayRef,
531
+ "class": ns2.b()
532
+ }, attrs, {
533
+ "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
534
+ "onPointerup": withModifiers(() => ({}), ["stop"])
535
+ }), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
536
+ "ref": arrowRef,
537
+ "class": ns2.e("arrow")
538
+ }, null)]);
539
+ };
540
+ }
541
+ });
542
+ const isObject = (val) => val !== null && typeof val === "object";
543
+ const ns = useNamespace("popper-trigger");
544
+ function wrapContent(content) {
545
+ return h("span", { class: ns.b() }, content);
546
+ }
547
+ function getFirstValidChild(nodes) {
548
+ for (const child of nodes) {
549
+ if (isObject(child)) {
550
+ if (child.type === Comment) {
551
+ continue;
552
+ }
553
+ if (child.type === "svg" || child.type === Text) {
554
+ return wrapContent(child);
555
+ }
556
+ if (child.type === Fragment) {
557
+ return getFirstValidChild(child.children);
558
+ }
559
+ return child;
560
+ }
561
+ return wrapContent(child);
562
+ }
563
+ return null;
564
+ }
565
+ var PopperTrigger = defineComponent({
566
+ name: "DPopperTrigger",
567
+ setup(_, ctx) {
568
+ const {
569
+ slots,
570
+ attrs
571
+ } = ctx;
572
+ return () => {
573
+ var _a;
574
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
575
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
576
+ if (!defaultSlot) {
577
+ return null;
578
+ }
579
+ const firstValidChild = getFirstValidChild(defaultSlot);
580
+ if (!firstValidChild) {
581
+ return null;
582
+ }
583
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
584
+ mounted(el) {
585
+ triggerRef.value = el;
586
+ },
587
+ updated(el) {
588
+ triggerRef.value = el;
589
+ },
590
+ unmounted() {
591
+ triggerRef.value = null;
592
+ }
593
+ }]]);
594
+ };
595
+ }
596
+ });
597
+ var dropdown = "";
598
+ let dropdownId = 1;
599
+ var DDropdown = defineComponent({
600
+ name: "DDropdown",
601
+ inheritAttrs: false,
602
+ props: dropdownProps,
603
+ emits: ["toggle"],
604
+ setup(props, {
605
+ slots,
606
+ attrs,
607
+ emit,
608
+ expose
609
+ }) {
610
+ const {
611
+ visible,
612
+ position,
613
+ align,
614
+ offset: offset2,
615
+ destroyOnHide,
616
+ shiftOffset,
617
+ showAnimation
618
+ } = toRefs(props);
619
+ const origin = ref();
620
+ const dropdownRef = ref();
621
+ const overlayRef = ref();
622
+ const id = `dropdown_${dropdownId++}`;
623
+ const isOpen = ref(false);
624
+ const currentPosition = ref("bottom");
625
+ const ns2 = useNamespace("dropdown");
626
+ provide(POPPER_TRIGGER_TOKEN, origin);
627
+ useDropdownEvent({
628
+ id,
629
+ isOpen,
630
+ origin,
631
+ dropdownRef,
632
+ props,
633
+ emit
634
+ });
635
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
636
+ const {
637
+ overlayModelValue,
638
+ overlayShowValue,
639
+ styles,
640
+ classes,
641
+ handlePositionChange
642
+ } = useOverlayProps(props, currentPosition, isOpen);
643
+ watch(overlayShowValue, (overlayShowValueVal) => {
644
+ nextTick(() => {
645
+ if (!destroyOnHide.value && overlayShowValueVal) {
646
+ overlayRef.value.updatePosition();
647
+ }
648
+ });
649
+ });
650
+ expose({
651
+ updatePosition: () => overlayRef.value.updatePosition()
652
+ });
653
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
654
+ default: () => {
655
+ var _a;
656
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
657
+ }
658
+ }), createVNode(Teleport, {
659
+ "to": "body"
660
+ }, {
661
+ default: () => [createVNode(Transition, {
662
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
663
+ }, {
664
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
665
+ "modelValue": overlayModelValue.value,
666
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
667
+ "ref": overlayRef,
668
+ "origin": origin.value,
669
+ "position": position.value,
670
+ "align": align.value,
671
+ "offset": offset2.value,
672
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
673
+ "onPositionChange": handlePositionChange,
674
+ "click-event-bubble": true,
675
+ "class": classes.value,
676
+ "style": styles.value
677
+ }, {
678
+ default: () => {
679
+ var _a;
680
+ return [createVNode("div", mergeProps({
681
+ "ref": dropdownRef,
682
+ "class": ns2.e("menu-wrap")
683
+ }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
684
+ }
685
+ }), [[vShow, overlayShowValue.value]])]
686
+ })]
687
+ })]);
688
+ }
689
+ });
690
+ var BreadcrumbItem = defineComponent({
691
+ name: "DBreadcrumbItem",
692
+ components: {
693
+ DDropdown
694
+ },
695
+ props: breadcrumbItemProps,
696
+ setup(props, {
697
+ slots
698
+ }) {
699
+ var _a;
700
+ const separatorIcon = inject("separatorIcon");
701
+ const ns2 = useNamespace("breadcrumb");
702
+ const linkClass = props.to ? "is-link" : "";
703
+ const dropdownTitleClass = props.showMenu && ((_a = props.menuList) == null ? void 0 : _a.length) ? ns2.e("dropdown-title") : "";
704
+ const link = ref(null);
705
+ const instance = getCurrentInstance();
706
+ const router = instance == null ? void 0 : instance.appContext.config.globalProperties.$router;
707
+ const showMenu = ref(props.showMenu);
708
+ const menuList = ref(props.menuList || []);
709
+ const handleClickLink = () => {
710
+ if (!props.to || !router) {
711
+ return;
712
+ }
713
+ props.replace ? router.replace(props.to) : router.push(props.to);
714
+ };
715
+ onMounted(() => {
716
+ var _a2;
717
+ (_a2 = link.value) == null ? void 0 : _a2.addEventListener("click", handleClickLink);
718
+ });
719
+ onBeforeUnmount(() => {
720
+ var _a2;
721
+ (_a2 = link.value) == null ? void 0 : _a2.removeEventListener("click", handleClickLink);
722
+ });
723
+ const renderBreadcrumbSperator = () => {
724
+ return createVNode("span", {
725
+ "class": ns2.e("separator")
726
+ }, [separatorIcon]);
727
+ };
728
+ const renderBreadcrumbNode = () => {
729
+ var _a2;
730
+ if (showMenu.value) {
731
+ return createVNode("div", {
732
+ "class": ns2.e("item")
733
+ }, [createVNode(resolveComponent("d-dropdown"), {
734
+ "trigger": "hover",
735
+ "close-scope": "blank"
736
+ }, {
737
+ default: () => {
738
+ var _a3;
739
+ return [createVNode("span", {
740
+ "class": [linkClass, dropdownTitleClass]
741
+ }, [(_a3 = slots == null ? void 0 : slots.default) == null ? void 0 : _a3.call(slots), createVNode("span", {
742
+ "class": "icon icon-chevron-down"
743
+ }, null)])];
744
+ },
745
+ menu: () => createVNode("ul", {
746
+ "class": ns2.e("item-dropdown")
747
+ }, [menuList.value.map((item) => {
748
+ return item.link ? createVNode("a", {
749
+ "href": item.link,
750
+ "target": item.target ? item.target : "_self"
751
+ }, [createVNode("li", {
752
+ "class": ns2.e("item-dropdown-item")
753
+ }, [item.title])]) : createVNode("li", {
754
+ "class": ns2.e("item-dropdown-item")
755
+ }, [createVNode("span", {
756
+ "class": linkClass
757
+ }, [item.title])]);
758
+ })])
759
+ })]);
760
+ }
761
+ return createVNode("div", {
762
+ "class": ns2.e("item")
763
+ }, [createVNode("span", {
764
+ "ref": link,
765
+ "class": linkClass
766
+ }, [(_a2 = slots == null ? void 0 : slots.default) == null ? void 0 : _a2.call(slots)]), renderBreadcrumbSperator()]);
767
+ };
768
+ return () => {
769
+ return renderBreadcrumbNode();
770
+ };
771
+ }
772
+ });
773
+ function getPropsSlot(slots, props, prop = "default") {
774
+ var _a, _b;
775
+ return (_b = props[prop]) != null ? _b : (_a = slots[prop]) == null ? void 0 : _a.call(slots);
776
+ }
777
+ var breadcrumb = "";
778
+ var Breadcrumb = defineComponent({
779
+ name: "DBreadcrumb",
780
+ components: {
781
+ DBreadcrumbItem: BreadcrumbItem
782
+ },
783
+ props: breadcrumbProps,
784
+ setup(props, {
785
+ slots
786
+ }) {
787
+ var _a;
788
+ const separatorIcon = (_a = getPropsSlot(slots, props, "separatorIcon")) != null ? _a : "/";
789
+ provide("separatorIcon", separatorIcon);
790
+ const ns2 = useNamespace("breadcrumb");
791
+ const renderBreadcrumbItemRouted = (item) => {
792
+ return createVNode(resolveComponent("d-breadcrumb-item"), {
793
+ "to": `path: ${item.link}`,
794
+ "replace": item.replace
795
+ }, {
796
+ default: () => [item.title]
797
+ });
798
+ };
799
+ const renderBreadcrumbItemDropdown = (item) => {
800
+ return createVNode(resolveComponent("d-breadcrumb-item"), {
801
+ "menuList": item.children,
802
+ "showMenu": item.showMenu,
803
+ "to": `path: ${item.link}`,
804
+ "replace": item.replace
805
+ }, {
806
+ default: () => [!item.noNavigation && (!item.linkType || item.linkType === "hrefLink") ? createVNode("a", {
807
+ "href": item.link,
808
+ "target": item.target ? item.target : "_self"
809
+ }, [item.title]) : null, item.noNavigation ? createVNode("span", null, [item.title]) : null]
810
+ });
811
+ };
812
+ const renderBreadItemList = (source) => {
813
+ return source.map((item) => {
814
+ if (!item.noNavigation && item.linkType === "routerLink") {
815
+ return renderBreadcrumbItemRouted(item);
816
+ }
817
+ if (item.children && item.children.length > 0) {
818
+ return renderBreadcrumbItemDropdown(item);
819
+ }
820
+ return createVNode(resolveComponent("d-breadcrumb-item"), null, {
821
+ default: () => [!item.noNavigation && (!item.linkType || item.linkType === "hrefLink") ? createVNode("a", {
822
+ "href": item.link,
823
+ "target": item.target ? item.target : "_self"
824
+ }, [item.title]) : null, item.noNavigation ? createVNode("span", null, [item.title]) : null]
825
+ });
826
+ });
827
+ };
828
+ return () => {
829
+ var _a2;
830
+ return createVNode("div", {
831
+ "class": ns2.b()
832
+ }, [props.source && props.source.length ? renderBreadItemList(props.source) : (_a2 = slots == null ? void 0 : slots.default) == null ? void 0 : _a2.call(slots)]);
833
+ };
834
+ }
835
+ });
836
+ var index = {
837
+ title: "Breadcrumb \u9762\u5305\u5C51",
838
+ category: "\u5BFC\u822A",
839
+ status: "100%",
840
+ install(app) {
841
+ app.component(Breadcrumb.name, Breadcrumb);
842
+ app.component(BreadcrumbItem.name, BreadcrumbItem);
843
+ }
844
+ };
845
+ export { Breadcrumb, BreadcrumbItem, breadcrumbItemProps, breadcrumbProps, index as default };