vue-devui 1.6.14 → 1.6.16
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/auto-complete/index.es.js +60 -42
- package/auto-complete/index.umd.js +13 -13
- package/breadcrumb/index.es.js +57 -39
- package/breadcrumb/index.umd.js +1 -1
- package/category-search/index.es.js +93 -44
- package/category-search/index.umd.js +21 -21
- package/checkbox/index.es.js +60 -42
- package/checkbox/index.umd.js +18 -18
- package/code-review/index.es.js +60 -42
- package/code-review/index.umd.js +20 -20
- package/data-grid/index.es.js +60 -42
- package/data-grid/index.umd.js +15 -15
- package/date-picker-pro/index.es.js +60 -42
- package/date-picker-pro/index.umd.js +13 -13
- package/dropdown/index.es.js +57 -39
- package/dropdown/index.umd.js +1 -1
- package/editable-select/index.es.js +66 -43
- package/editable-select/index.umd.js +10 -10
- package/editor-md/index.es.js +69 -44
- package/editor-md/index.umd.js +28 -28
- package/form/index.es.js +60 -42
- package/form/index.umd.js +17 -17
- package/input/index.es.js +59 -41
- package/input/index.umd.js +20 -20
- package/input-number/index.es.js +60 -42
- package/input-number/index.umd.js +19 -19
- package/mention/index.es.js +60 -42
- package/mention/index.umd.js +17 -17
- package/message/index.es.js +13 -13
- package/message/index.umd.js +1 -1
- package/modal/index.es.js +57 -39
- package/modal/index.umd.js +2 -2
- package/overlay/index.es.js +58 -40
- package/overlay/index.umd.js +1 -1
- package/package.json +3 -2
- package/pagination/index.es.js +77 -59
- package/pagination/index.umd.js +18 -18
- package/pagination/style.css +1 -1
- package/popover/index.es.js +60 -42
- package/popover/index.umd.js +15 -15
- package/radio/index.es.js +60 -42
- package/radio/index.umd.js +16 -16
- package/search/index.es.js +60 -42
- package/search/index.umd.js +16 -16
- package/select/index.es.js +77 -59
- package/select/index.umd.js +20 -20
- package/select/style.css +1 -1
- package/splitter/index.es.js +60 -42
- package/splitter/index.umd.js +14 -14
- package/style.css +1 -1
- package/switch/index.es.js +60 -42
- package/switch/index.umd.js +17 -17
- package/table/index.es.js +59 -41
- package/table/index.umd.js +16 -16
- package/textarea/index.es.js +60 -42
- package/textarea/index.umd.js +19 -19
- package/time-picker/index.es.js +59 -41
- package/time-picker/index.umd.js +14 -14
- package/time-select/index.es.js +77 -59
- package/time-select/index.umd.js +18 -18
- package/time-select/style.css +1 -1
- package/tooltip/index.es.js +60 -42
- package/tooltip/index.umd.js +15 -15
- package/tree/index.es.js +59 -41
- package/tree/index.umd.js +14 -14
- package/types/category-search/src/category-search-types.d.ts +5 -0
- package/types/editable-select/src/editable-select-types.d.ts +3 -0
- package/types/overlay/src/flexible-overlay/flexible-overlay-types.d.ts +5 -6
- package/types/overlay/src/flexible-overlay/index.d.ts +9 -0
- package/types/overlay/src/flexible-overlay/use-flexible-overlay.d.ts +11 -2
- package/types/select/src/composables/use-select-content.d.ts +21 -2
- package/types/select/src/select-types.d.ts +7 -44
- package/types/select/src/use-select.d.ts +26 -2
- package/vue-devui.es.js +138 -77
- package/vue-devui.umd.js +74 -74
package/dropdown/index.es.js
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
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 } from "vue";
|
|
21
|
-
import { offset,
|
|
21
|
+
import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
|
|
22
22
|
import { onClickOutside } from "@vueuse/core";
|
|
23
23
|
const dropdownProps = {
|
|
24
24
|
visible: {
|
|
@@ -360,18 +360,12 @@ const flexibleOverlayProps = {
|
|
|
360
360
|
clickEventBubble: {
|
|
361
361
|
type: Boolean,
|
|
362
362
|
default: false
|
|
363
|
+
},
|
|
364
|
+
fitOriginWidth: {
|
|
365
|
+
type: Boolean,
|
|
366
|
+
default: false
|
|
363
367
|
}
|
|
364
368
|
};
|
|
365
|
-
function getScrollParent(element) {
|
|
366
|
-
const overflowRegex = /(auto|scroll|hidden)/;
|
|
367
|
-
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
368
|
-
const style = window.getComputedStyle(parent);
|
|
369
|
-
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
370
|
-
return parent;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return window;
|
|
374
|
-
}
|
|
375
369
|
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
376
370
|
let { x, y } = point;
|
|
377
371
|
if (!isArrowCenter) {
|
|
@@ -392,9 +386,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
|
392
386
|
return { x, y };
|
|
393
387
|
}
|
|
394
388
|
function useOverlay(props, emit) {
|
|
389
|
+
const { fitOriginWidth, position, showArrow } = toRefs(props);
|
|
395
390
|
const overlayRef = ref();
|
|
396
391
|
const arrowRef = ref();
|
|
397
|
-
|
|
392
|
+
const overlayWidth = ref(0);
|
|
393
|
+
let originObserver;
|
|
394
|
+
const styles = computed(() => {
|
|
395
|
+
if (fitOriginWidth.value) {
|
|
396
|
+
return { width: overlayWidth.value + "px" };
|
|
397
|
+
} else {
|
|
398
|
+
return {};
|
|
399
|
+
}
|
|
400
|
+
});
|
|
398
401
|
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
399
402
|
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
400
403
|
const staticSide = {
|
|
@@ -415,54 +418,67 @@ function useOverlay(props, emit) {
|
|
|
415
418
|
const hostEl = props.origin;
|
|
416
419
|
const overlayEl = unref(overlayRef.value);
|
|
417
420
|
const arrowEl = unref(arrowRef.value);
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
})
|
|
424
|
-
];
|
|
425
|
-
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
426
|
-
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
427
|
-
if (!overlayEl) {
|
|
428
|
-
return;
|
|
421
|
+
const [mainPosition, ...fallbackPosition] = position.value;
|
|
422
|
+
const middleware = [offset(props.offset)];
|
|
423
|
+
middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
|
|
424
|
+
if (showArrow.value) {
|
|
425
|
+
middleware.push(arrow({ element: arrowRef.value }));
|
|
429
426
|
}
|
|
430
427
|
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
431
428
|
strategy: "fixed",
|
|
429
|
+
placement: mainPosition,
|
|
432
430
|
middleware
|
|
433
431
|
});
|
|
434
432
|
let applyX = x;
|
|
435
433
|
let applyY = y;
|
|
436
|
-
if (props.shiftOffset !== void 0) {
|
|
437
|
-
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
438
|
-
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
439
|
-
shiftX > 0 && (applyX += props.shiftOffset);
|
|
440
|
-
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
441
|
-
shiftY > 0 && (applyY += props.shiftOffset);
|
|
442
|
-
}
|
|
443
434
|
emit("positionChange", placement);
|
|
444
435
|
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
445
436
|
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
446
437
|
};
|
|
438
|
+
const scrollCallback = (e) => {
|
|
439
|
+
var _a, _b;
|
|
440
|
+
const scrollElement = e.target;
|
|
441
|
+
if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
|
|
442
|
+
updatePosition();
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const updateWidth = (originEl) => {
|
|
446
|
+
overlayWidth.value = originEl.getBoundingClientRect().width;
|
|
447
|
+
updatePosition();
|
|
448
|
+
};
|
|
449
|
+
const observeOrigin = () => {
|
|
450
|
+
var _a, _b;
|
|
451
|
+
if (fitOriginWidth.value && typeof window !== "undefined") {
|
|
452
|
+
const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
|
|
453
|
+
if (originEl) {
|
|
454
|
+
originObserver = new window.ResizeObserver(() => updateWidth(originEl));
|
|
455
|
+
originObserver.observe(originEl);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
const unobserveOrigin = () => {
|
|
460
|
+
var _a, _b;
|
|
461
|
+
const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
|
|
462
|
+
originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
|
|
463
|
+
};
|
|
447
464
|
watch(() => props.modelValue, () => {
|
|
448
465
|
if (props.modelValue && props.origin) {
|
|
449
|
-
originParent = getScrollParent(props.origin);
|
|
450
466
|
nextTick(updatePosition);
|
|
451
|
-
|
|
452
|
-
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
467
|
+
window.addEventListener("scroll", scrollCallback, true);
|
|
453
468
|
window.addEventListener("resize", updatePosition);
|
|
469
|
+
observeOrigin();
|
|
454
470
|
} else {
|
|
455
|
-
|
|
456
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
471
|
+
window.removeEventListener("scroll", scrollCallback, true);
|
|
457
472
|
window.removeEventListener("resize", updatePosition);
|
|
473
|
+
unobserveOrigin();
|
|
458
474
|
}
|
|
459
475
|
});
|
|
460
476
|
onUnmounted(() => {
|
|
461
|
-
|
|
462
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
477
|
+
window.removeEventListener("scroll", scrollCallback, true);
|
|
463
478
|
window.removeEventListener("resize", updatePosition);
|
|
479
|
+
unobserveOrigin();
|
|
464
480
|
});
|
|
465
|
-
return { arrowRef, overlayRef, updatePosition };
|
|
481
|
+
return { arrowRef, overlayRef, styles, updatePosition };
|
|
466
482
|
}
|
|
467
483
|
var flexibleOverlay = "";
|
|
468
484
|
const FlexibleOverlay = defineComponent({
|
|
@@ -483,6 +499,7 @@ const FlexibleOverlay = defineComponent({
|
|
|
483
499
|
const {
|
|
484
500
|
arrowRef,
|
|
485
501
|
overlayRef,
|
|
502
|
+
styles,
|
|
486
503
|
updatePosition
|
|
487
504
|
} = useOverlay(props, emit);
|
|
488
505
|
expose({
|
|
@@ -492,7 +509,8 @@ const FlexibleOverlay = defineComponent({
|
|
|
492
509
|
var _a;
|
|
493
510
|
return props.modelValue && createVNode("div", mergeProps({
|
|
494
511
|
"ref": overlayRef,
|
|
495
|
-
"class": ns2.b()
|
|
512
|
+
"class": ns2.b(),
|
|
513
|
+
"style": styles.value
|
|
496
514
|
}, attrs, {
|
|
497
515
|
"onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
|
|
498
516
|
"onPointerup": withModifiers(() => ({}), ["stop"])
|
package/dropdown/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var se=Object.defineProperty,ue=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var q=(d,e,w)=>e in d?se(d,e,{enumerable:!0,configurable:!0,writable:!0,value:w}):d[e]=w,z=(d,e)=>{for(var w in e||(e={}))ce.call(e,w)&&q(d,w,e[w]);if(_)for(var w of _(e))fe.call(e,w)&&q(d,w,e[w]);return d},H=(d,e)=>ue(d,de(e));(function(d,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("@floating-ui/dom"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@floating-ui/dom","@vueuse/core"],e):(d=typeof globalThis!="undefined"?globalThis:d||self,e(d.index={},d.Vue,d.dom,d.core))})(this,function(d,e,w,U){"use strict";const Y={visible:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},shiftOffset:{type:Number},closeOnMouseLeaveMenu:{type:Boolean,default:!1},showAnimation:{type:Boolean,default:!0},overlayClass:{type:String,default:""},destroyOnHide:{type:Boolean,default:!0},teleport:{type:[String,Object],default:"body"}},R=Symbol("popper-trigger");function I(t){return t instanceof Element?t:t&&typeof t=="object"&&t.$el instanceof Element?t.$el:null}const O=new Map;function N(t,o,n){return t==null||t.addEventListener(o,n),()=>{t==null||t.removeEventListener(o,n)}}const X=({id:t,isOpen:o,origin:n,dropdownRef:i,props:l,emit:a})=>{let r=!1,s=!1;const{trigger:u,closeScope:f,closeOnMouseLeaveMenu:y}=e.toRefs(l),p=m=>{o.value=m,a("toggle",o.value)},E=async(m,b)=>{await new Promise(c=>setTimeout(c,50)),!(m==="origin"&&r||m==="dropdown"&&s)&&(b&&[...O.values()].reverse().forEach(c=>{setTimeout(()=>{var V;(V=c.toggle)==null||V.call(c)},0)}),p(!1))};e.watch([u,n,i],([m,b,c],V,g)=>{const h=I(b),P=[];setTimeout(()=>{P.push(N(document,"click",v=>{v.stopPropagation();const C=[...O.values()];!o.value||f.value==="none"||(c==null?void 0:c.contains(v.target))&&f.value==="blank"||C.some(x=>{var A;return(A=x.toggleEl)==null?void 0:A.contains(v.target)})&&C.some(x=>{var A;return(A=x.menuEl)==null?void 0:A.contains(v.target)})||([...O.values()].reverse().forEach(x=>{setTimeout(()=>{var A,M;((A=x.toggleEl)==null?void 0:A.contains(v.target))||(M=x.toggle)==null||M.call(x)},0)}),r=!1)}))},0),m==="click"?P.push(N(h,"click",()=>p(!o.value)),N(c,"mouseleave",v=>{var C;y.value&&!((C=O.get(t).child)==null?void 0:C.contains(v.relatedTarget))&&E("dropdown",!0)})):m==="hover"&&P.push(N(h,"mouseenter",()=>{s=!0,p(!0)}),N(h,"mouseleave",()=>{s=!1,E("origin")}),N(c,"mouseenter",()=>{r=!0,o.value=!0}),N(c,"mouseleave",v=>{var C;r=!1,!(v.relatedTarget&&((h==null?void 0:h.contains(v.relatedTarget))||((C=O.get(t).child)==null?void 0:C.contains(v.relatedTarget))))&&E("dropdown",!0)})),g(()=>P.forEach(v=>v()))})};function G(t,o,n,i,l,a){e.watch(o,(r,s)=>{s!==void 0&&(n.value=r,a("toggle",n.value))},{immediate:!0}),e.watch([n,l],([r,s])=>{var u;if(r){O.set(t,H(z({},O.get(t)),{menuEl:s,toggle:()=>{n.value=!1,a("toggle",n.value)}}));for(const f of O.values())((u=f.menuEl)==null?void 0:u.contains(i.value))&&(f.child=s)}}),e.onMounted(()=>{O.set(t,{toggleEl:i.value})}),e.onUnmounted(()=>{O.delete(t)})}function K(t,o,n){const{showAnimation:i,overlayClass:l,destroyOnHide:a}=e.toRefs(t),r=e.ref(!1),s=e.ref(!1),u=e.computed(()=>({transformOrigin:o.value==="top"?"0% 100%":"0% 0%",zIndex:"var(--devui-z-index-dropdown, 1052)"})),f=e.computed(()=>({"fade-in-bottom":i.value&&n.value&&o.value==="bottom","fade-in-top":i.value&&n.value&&o.value==="top",[`${l.value}`]:!0})),y=p=>{o.value=p.includes("top")||p.includes("right-end")||p.includes("left-end")?"top":"bottom"};return e.watch(n,p=>{r.value=a.value?p:!0,s.value=p}),{overlayModelValue:r,overlayShowValue:s,styles:u,classes:f,handlePositionChange:y}}const J={modelValue:{type:Boolean,default:!1},lockScroll:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0}};function Q(){if(document.documentElement.scrollHeight>document.documentElement.clientHeight){const t=document.documentElement.scrollTop,o=document.documentElement.getAttribute("style");return document.documentElement.style.position="fixed",document.documentElement.style.top=`-${t}px`,document.documentElement.style.width=document.documentElement.style.width||"100%",document.documentElement.style.overflowY="scroll",()=>{o?document.documentElement.setAttribute("style",o):document.documentElement.removeAttribute("style"),document.documentElement.scrollTop=t}}}function W(t,o){let n;const i=a=>{a.preventDefault(),o.emit("click",a),t.closeOnClickOverlay&&o.emit("update:modelValue",!1)},l=()=>{n==null||n()};return e.watch(()=>t.modelValue,a=>{a?t.lockScroll&&(n=Q()):l()}),e.onUnmounted(l),{onClick:i}}function B(t,o,n){let i=t;return o&&(i+=`__${o}`),n&&(i+=`--${n}`),i}function S(t,o=!1){const n=o?`.devui-${t}`:`devui-${t}`;return{b:()=>B(n),e:s=>s?B(n,s):"",m:s=>s?B(n,"",s):"",em:(s,u)=>s&&u?B(n,s,u):""}}var me="";e.defineComponent({name:"DFixedOverlay",inheritAttrs:!1,props:J,emits:["update:modelValue","click"],setup(t,o){const{modelValue:n}=e.toRefs(t),i=S("fixed-overlay"),{onClick:l}=W(t,o);return()=>e.createVNode(e.Transition,{name:i.m("fade")},{default:()=>{var a,r;return[n.value&&e.createVNode("div",e.mergeProps({class:i.b()},o.attrs,{onClick:l}),[(r=(a=o.slots).default)==null?void 0:r.call(a)])]}})}});const Z={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},offset:{type:[Number,Object],default:8},shiftOffset:{type:Number},align:{type:String,default:null},showArrow:{type:Boolean,default:!1},isArrowCenter:{type:Boolean,default:!0},clickEventBubble:{type:Boolean,default:!1}};function ee(t){const o=/(auto|scroll|hidden)/;for(let n=t;n=n.parentElement;n.parentElement!==document.body){const i=window.getComputedStyle(n);if(o.test(i.overflow+i.overflowX+i.overflowY))return n}return window}function te(t,o,n,i){let{x:l,y:a}=o;if(!t){const{width:r,height:s}=i;l&&n.includes("start")&&(l=12),l&&n.includes("end")&&(l=Math.round(r-24)),a&&n.includes("start")&&(a=10),a&&n.includes("end")&&(a=s-14)}return{x:l,y:a}}function oe(t,o){const n=e.ref(),i=e.ref();let l=null;const a=(s,u,f,y)=>{const{x:p,y:E}=te(t.isArrowCenter,f,u,y.getBoundingClientRect()),m={top:"bottom",right:"left",bottom:"top",left:"right"}[u.split("-")[0]];Object.assign(s.style,{left:p?`${p}px`:"",top:E?`${E}px`:"",right:"",bottom:"",[m]:"-4px"})},r=async()=>{const s=t.origin,u=e.unref(n.value),f=e.unref(i.value),y=[w.offset(t.offset),w.autoPlacement({alignment:t.align,allowedPlacements:t.position})];if(t.showArrow&&y.push(w.arrow({element:f})),t.shiftOffset!==void 0&&y.push(w.shift()),!u)return;const{x:p,y:E,placement:m,middlewareData:b}=await w.computePosition(s,u,{strategy:"fixed",middleware:y});let c=p,V=E;if(t.shiftOffset!==void 0){const{x:g,y:h}=b.shift;g<0&&(c-=t.shiftOffset),g>0&&(c+=t.shiftOffset),h<0&&(V-=t.shiftOffset),h>0&&(V+=t.shiftOffset)}o("positionChange",m),Object.assign(u.style,{top:`${V}px`,left:`${c}px`}),t.showArrow&&a(f,m,b.arrow,u)};return e.watch(()=>t.modelValue,()=>{t.modelValue&&t.origin?(l=ee(t.origin),e.nextTick(r),l==null||l.addEventListener("scroll",r),l!==window&&window.addEventListener("scroll",r),window.addEventListener("resize",r)):(l==null||l.removeEventListener("scroll",r),l!==window&&window.removeEventListener("scroll",r),window.removeEventListener("resize",r))}),e.onUnmounted(()=>{l==null||l.removeEventListener("scroll",r),l!==window&&window.removeEventListener("scroll",r),window.removeEventListener("resize",r)}),{arrowRef:i,overlayRef:n,updatePosition:r}}var pe="";const j=e.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:Z,emits:["update:modelValue","positionChange"],setup(t,{slots:o,attrs:n,emit:i,expose:l}){const a=S("flexible-overlay"),{clickEventBubble:r}=e.toRefs(t),{arrowRef:s,overlayRef:u,updatePosition:f}=oe(t,i);return l({updatePosition:f}),()=>{var y;return t.modelValue&&e.createVNode("div",e.mergeProps({ref:u,class:a.b()},n,{onClick:e.withModifiers(()=>({}),[r.value?"":"stop"]),onPointerup:e.withModifiers(()=>({}),["stop"])}),[(y=o.default)==null?void 0:y.call(o),t.showArrow&&e.createVNode("div",{ref:s,class:a.e("arrow")},null)])}}}),ne=t=>t!==null&&typeof t=="object",le=S("popper-trigger");function $(t){return e.h("span",{class:le.b()},t)}function L(t){for(const o of t){if(ne(o)){if(o.type===e.Comment)continue;return o.type==="svg"||o.type===e.Text?$(o):o.type===e.Fragment?L(o.children):o}return $(o)}return null}var ae=e.defineComponent({name:"DPopperTrigger",setup(t,o){const{slots:n,attrs:i}=o;return()=>{var s;const l=(s=n.default)==null?void 0:s.call(n,i),a=e.inject(R);if(!l)return null;const r=L(l);return r?e.withDirectives(e.cloneVNode(r,i),[[{mounted(u){a.value=u},updated(u){a.value=u},unmounted(){a.value=null}}]]):null}}}),ye="";let re=1;var k=e.defineComponent({name:"DDropdown",inheritAttrs:!1,props:Y,emits:["toggle"],setup(t,{slots:o,attrs:n,emit:i,expose:l}){const{visible:a,position:r,align:s,offset:u,destroyOnHide:f,shiftOffset:y,showAnimation:p,teleport:E}=e.toRefs(t),m=e.ref(),b=e.ref(),c=e.ref(),V=`dropdown_${re++}`,g=e.ref(!1),h=e.ref("bottom"),P=S("dropdown");e.provide(R,m),X({id:V,isOpen:g,origin:m,dropdownRef:b,props:t,emit:i}),G(V,a,g,m,b,i);const{overlayModelValue:v,overlayShowValue:C,styles:x,classes:A,handlePositionChange:M}=K(t,h,g);return e.watch(C,T=>{e.nextTick(()=>{!f.value&&T&&c.value.updatePosition()})}),l({updatePosition:()=>c.value.updatePosition()}),()=>e.createVNode(e.Fragment,null,[e.createVNode(ae,null,{default:()=>{var T;return[(T=o.default)==null?void 0:T.call(o)]}}),e.createVNode(e.Teleport,{to:E.value},{default:()=>[e.createVNode(e.Transition,{name:p.value?P.m(`fade-${h.value}`):""},{default:()=>[e.withDirectives(e.createVNode(j,{modelValue:v.value,"onUpdate:modelValue":T=>v.value=T,ref:c,origin:m.value,position:r.value,align:s.value,offset:u.value,shiftOffset:y==null?void 0:y.value,onPositionChange:M,"click-event-bubble":!0,class:A.value,style:x.value},{default:()=>{var T;return[e.createVNode("div",e.mergeProps({ref:b,class:P.e("menu-wrap")},n),[(T=o.menu)==null?void 0:T.call(o)])]}}),[[e.vShow,C.value]])]})]})])}});const F={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},clickOutside:{type:Function,default:()=>!0},showAnimation:{type:Boolean,default:!0},overlayClass:{type:String,default:""}};var D=e.defineComponent({name:"DDropdownMenu",inheritAttrs:!1,props:F,emits:["update:modelValue"],setup(t,{slots:o,attrs:n,emit:i}){const{modelValue:l,origin:a,position:r,align:s,offset:u,clickOutside:f,showAnimation:y,overlayClass:p}=e.toRefs(t),E=e.ref(null),m=S("dropdown");U.onClickOutside(E,g=>{var h,P;((h=f.value)==null?void 0:h.call(f))&&!((P=a==null?void 0:a.value)==null?void 0:P.contains(g.target))&&i("update:modelValue",!1)});const b=e.ref("bottom"),c=g=>{b.value=g.split("-")[0]==="top"?"top":"bottom"},V=e.computed(()=>({transformOrigin:b.value==="top"?"0% 100%":"0% 0%"}));return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:y.value?m.m(`fade-${b.value}`):""},{default:()=>[e.createVNode(j,{modelValue:l.value,"onUpdate:modelValue":g=>l.value=g,origin:a==null?void 0:a.value,position:r.value,align:s.value,offset:u.value,onPositionChange:c,class:p.value,style:V.value},{default:()=>{var g;return[e.createVNode("div",e.mergeProps({ref:E,class:m.e("menu-wrap")},n),[(g=o.default)==null?void 0:g.call(o)])]}})]})]})}}),ie={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"50%",install(t){t.component(k.name,k),t.component(D.name,D)}};d.Dropdown=k,d.DropdownMenu=D,d.default=ie,d.dropdownMenuProps=F,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
|
|
1
|
+
var ue=Object.defineProperty,ce=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var z=(m,e,V)=>e in m?ue(m,e,{enumerable:!0,configurable:!0,writable:!0,value:V}):m[e]=V,q=(m,e)=>{for(var V in e||(e={}))fe.call(e,V)&&z(m,V,e[V]);if(_)for(var V of _(e))me.call(e,V)&&z(m,V,e[V]);return m},H=(m,e)=>ce(m,de(e));(function(m,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue"),require("@floating-ui/dom"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@floating-ui/dom","@vueuse/core"],e):(m=typeof globalThis!="undefined"?globalThis:m||self,e(m.index={},m.Vue,m.dom,m.core))})(this,function(m,e,V,U){"use strict";const W={visible:{type:Boolean,default:!1},trigger:{type:String,default:"click"},closeScope:{type:String,default:"all"},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},shiftOffset:{type:Number},closeOnMouseLeaveMenu:{type:Boolean,default:!1},showAnimation:{type:Boolean,default:!0},overlayClass:{type:String,default:""},destroyOnHide:{type:Boolean,default:!0},teleport:{type:[String,Object],default:"body"}},D=Symbol("popper-trigger");function I(t){return t instanceof Element?t:t&&typeof t=="object"&&t.$el instanceof Element?t.$el:null}const x=new Map;function k(t,o,n){return t==null||t.addEventListener(o,n),()=>{t==null||t.removeEventListener(o,n)}}const G=({id:t,isOpen:o,origin:n,dropdownRef:r,props:u,emit:l})=>{let s=!1,a=!1;const{trigger:d,closeScope:w,closeOnMouseLeaveMenu:C}=e.toRefs(u),f=h=>{o.value=h,l("toggle",o.value)},O=async(h,P)=>{await new Promise(y=>setTimeout(y,50)),!(h==="origin"&&s||h==="dropdown"&&a)&&(P&&[...x.values()].reverse().forEach(y=>{setTimeout(()=>{var p;(p=y.toggle)==null||p.call(y)},0)}),f(!1))};e.watch([d,n,r],([h,P,y],p,i)=>{const c=I(P),b=[];setTimeout(()=>{b.push(k(document,"click",g=>{g.stopPropagation();const v=[...x.values()];!o.value||w.value==="none"||(y==null?void 0:y.contains(g.target))&&w.value==="blank"||v.some(E=>{var A;return(A=E.toggleEl)==null?void 0:A.contains(g.target)})&&v.some(E=>{var A;return(A=E.menuEl)==null?void 0:A.contains(g.target)})||([...x.values()].reverse().forEach(E=>{setTimeout(()=>{var A,B;((A=E.toggleEl)==null?void 0:A.contains(g.target))||(B=E.toggle)==null||B.call(E)},0)}),s=!1)}))},0),h==="click"?b.push(k(c,"click",()=>f(!o.value)),k(y,"mouseleave",g=>{var v;C.value&&!((v=x.get(t).child)==null?void 0:v.contains(g.relatedTarget))&&O("dropdown",!0)})):h==="hover"&&b.push(k(c,"mouseenter",()=>{a=!0,f(!0)}),k(c,"mouseleave",()=>{a=!1,O("origin")}),k(y,"mouseenter",()=>{s=!0,o.value=!0}),k(y,"mouseleave",g=>{var v;s=!1,!(g.relatedTarget&&((c==null?void 0:c.contains(g.relatedTarget))||((v=x.get(t).child)==null?void 0:v.contains(g.relatedTarget))))&&O("dropdown",!0)})),i(()=>b.forEach(g=>g()))})};function Y(t,o,n,r,u,l){e.watch(o,(s,a)=>{a!==void 0&&(n.value=s,l("toggle",n.value))},{immediate:!0}),e.watch([n,u],([s,a])=>{var d;if(s){x.set(t,H(q({},x.get(t)),{menuEl:a,toggle:()=>{n.value=!1,l("toggle",n.value)}}));for(const w of x.values())((d=w.menuEl)==null?void 0:d.contains(r.value))&&(w.child=a)}}),e.onMounted(()=>{x.set(t,{toggleEl:r.value})}),e.onUnmounted(()=>{x.delete(t)})}function K(t,o,n){const{showAnimation:r,overlayClass:u,destroyOnHide:l}=e.toRefs(t),s=e.ref(!1),a=e.ref(!1),d=e.computed(()=>({transformOrigin:o.value==="top"?"0% 100%":"0% 0%",zIndex:"var(--devui-z-index-dropdown, 1052)"})),w=e.computed(()=>({"fade-in-bottom":r.value&&n.value&&o.value==="bottom","fade-in-top":r.value&&n.value&&o.value==="top",[`${u.value}`]:!0})),C=f=>{o.value=f.includes("top")||f.includes("right-end")||f.includes("left-end")?"top":"bottom"};return e.watch(n,f=>{s.value=l.value?f:!0,a.value=f}),{overlayModelValue:s,overlayShowValue:a,styles:d,classes:w,handlePositionChange:C}}const X={modelValue:{type:Boolean,default:!1},lockScroll:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0}};function J(){if(document.documentElement.scrollHeight>document.documentElement.clientHeight){const t=document.documentElement.scrollTop,o=document.documentElement.getAttribute("style");return document.documentElement.style.position="fixed",document.documentElement.style.top=`-${t}px`,document.documentElement.style.width=document.documentElement.style.width||"100%",document.documentElement.style.overflowY="scroll",()=>{o?document.documentElement.setAttribute("style",o):document.documentElement.removeAttribute("style"),document.documentElement.scrollTop=t}}}function Q(t,o){let n;const r=l=>{l.preventDefault(),o.emit("click",l),t.closeOnClickOverlay&&o.emit("update:modelValue",!1)},u=()=>{n==null||n()};return e.watch(()=>t.modelValue,l=>{l?t.lockScroll&&(n=J()):u()}),e.onUnmounted(u),{onClick:r}}function R(t,o,n){let r=t;return o&&(r+=`__${o}`),n&&(r+=`--${n}`),r}function N(t,o=!1){const n=o?`.devui-${t}`:`devui-${t}`;return{b:()=>R(n),e:a=>a?R(n,a):"",m:a=>a?R(n,"",a):"",em:(a,d)=>a&&d?R(n,a,d):""}}var pe="";e.defineComponent({name:"DFixedOverlay",inheritAttrs:!1,props:X,emits:["update:modelValue","click"],setup(t,o){const{modelValue:n}=e.toRefs(t),r=N("fixed-overlay"),{onClick:u}=Q(t,o);return()=>e.createVNode(e.Transition,{name:r.m("fade")},{default:()=>{var l,s;return[n.value&&e.createVNode("div",e.mergeProps({class:r.b()},o.attrs,{onClick:u}),[(s=(l=o.slots).default)==null?void 0:s.call(l)])]}})}});const Z={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},offset:{type:[Number,Object],default:8},shiftOffset:{type:Number},align:{type:String,default:null},showArrow:{type:Boolean,default:!1},isArrowCenter:{type:Boolean,default:!0},clickEventBubble:{type:Boolean,default:!1},fitOriginWidth:{type:Boolean,default:!1}};function ee(t,o,n,r){let{x:u,y:l}=o;if(!t){const{width:s,height:a}=r;u&&n.includes("start")&&(u=12),u&&n.includes("end")&&(u=Math.round(s-24)),l&&n.includes("start")&&(l=10),l&&n.includes("end")&&(l=a-14)}return{x:u,y:l}}function te(t,o){const{fitOriginWidth:n,position:r,showArrow:u}=e.toRefs(t),l=e.ref(),s=e.ref(),a=e.ref(0);let d;const w=e.computed(()=>n.value?{width:a.value+"px"}:{}),C=(p,i,c,b)=>{const{x:g,y:v}=ee(t.isArrowCenter,c,i,b.getBoundingClientRect()),E={top:"bottom",right:"left",bottom:"top",left:"right"}[i.split("-")[0]];Object.assign(p.style,{left:g?`${g}px`:"",top:v?`${v}px`:"",right:"",bottom:"",[E]:"-4px"})},f=async()=>{const p=t.origin,i=e.unref(l.value),c=e.unref(s.value),[b,...g]=r.value,v=[V.offset(t.offset)];v.push(g.length?V.flip({fallbackPlacements:g}):V.flip()),u.value&&v.push(V.arrow({element:s.value}));const{x:E,y:A,placement:B,middlewareData:T}=await V.computePosition(p,i,{strategy:"fixed",placement:b,middleware:v});let ie=E,se=A;o("positionChange",B),Object.assign(i.style,{top:`${se}px`,left:`${ie}px`}),t.showArrow&&C(c,B,T.arrow,i)},O=p=>{var c,b;const i=p.target;(i==null?void 0:i.contains((b=(c=t.origin)==null?void 0:c.$el)!=null?b:t.origin))&&f()},h=p=>{a.value=p.getBoundingClientRect().width,f()},P=()=>{var p,i;if(n.value&&typeof window!="undefined"){const c=(i=(p=t.origin)==null?void 0:p.$el)!=null?i:t.origin;c&&(d=new window.ResizeObserver(()=>h(c)),d.observe(c))}},y=()=>{var i,c;const p=(c=(i=t.origin)==null?void 0:i.$el)!=null?c:t.origin;p&&(d==null||d.unobserve(p))};return e.watch(()=>t.modelValue,()=>{t.modelValue&&t.origin?(e.nextTick(f),window.addEventListener("scroll",O,!0),window.addEventListener("resize",f),P()):(window.removeEventListener("scroll",O,!0),window.removeEventListener("resize",f),y())}),e.onUnmounted(()=>{window.removeEventListener("scroll",O,!0),window.removeEventListener("resize",f),y()}),{arrowRef:s,overlayRef:l,styles:w,updatePosition:f}}var ge="";const $=e.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:Z,emits:["update:modelValue","positionChange"],setup(t,{slots:o,attrs:n,emit:r,expose:u}){const l=N("flexible-overlay"),{clickEventBubble:s}=e.toRefs(t),{arrowRef:a,overlayRef:d,styles:w,updatePosition:C}=te(t,r);return u({updatePosition:C}),()=>{var f;return t.modelValue&&e.createVNode("div",e.mergeProps({ref:d,class:l.b(),style:w.value},n,{onClick:e.withModifiers(()=>({}),[s.value?"":"stop"]),onPointerup:e.withModifiers(()=>({}),["stop"])}),[(f=o.default)==null?void 0:f.call(o),t.showArrow&&e.createVNode("div",{ref:a,class:l.e("arrow")},null)])}}}),oe=t=>t!==null&&typeof t=="object",ne=N("popper-trigger");function j(t){return e.h("span",{class:ne.b()},t)}function L(t){for(const o of t){if(oe(o)){if(o.type===e.Comment)continue;return o.type==="svg"||o.type===e.Text?j(o):o.type===e.Fragment?L(o.children):o}return j(o)}return null}var le=e.defineComponent({name:"DPopperTrigger",setup(t,o){const{slots:n,attrs:r}=o;return()=>{var a;const u=(a=n.default)==null?void 0:a.call(n,r),l=e.inject(D);if(!u)return null;const s=L(u);return s?e.withDirectives(e.cloneVNode(s,r),[[{mounted(d){l.value=d},updated(d){l.value=d},unmounted(){l.value=null}}]]):null}}}),ye="";let ae=1;var M=e.defineComponent({name:"DDropdown",inheritAttrs:!1,props:W,emits:["toggle"],setup(t,{slots:o,attrs:n,emit:r,expose:u}){const{visible:l,position:s,align:a,offset:d,destroyOnHide:w,shiftOffset:C,showAnimation:f,teleport:O}=e.toRefs(t),h=e.ref(),P=e.ref(),y=e.ref(),p=`dropdown_${ae++}`,i=e.ref(!1),c=e.ref("bottom"),b=N("dropdown");e.provide(D,h),G({id:p,isOpen:i,origin:h,dropdownRef:P,props:t,emit:r}),Y(p,l,i,h,P,r);const{overlayModelValue:g,overlayShowValue:v,styles:E,classes:A,handlePositionChange:B}=K(t,c,i);return e.watch(v,T=>{e.nextTick(()=>{!w.value&&T&&y.value.updatePosition()})}),u({updatePosition:()=>y.value.updatePosition()}),()=>e.createVNode(e.Fragment,null,[e.createVNode(le,null,{default:()=>{var T;return[(T=o.default)==null?void 0:T.call(o)]}}),e.createVNode(e.Teleport,{to:O.value},{default:()=>[e.createVNode(e.Transition,{name:f.value?b.m(`fade-${c.value}`):""},{default:()=>[e.withDirectives(e.createVNode($,{modelValue:g.value,"onUpdate:modelValue":T=>g.value=T,ref:y,origin:h.value,position:s.value,align:a.value,offset:d.value,shiftOffset:C==null?void 0:C.value,onPositionChange:B,"click-event-bubble":!0,class:A.value,style:E.value},{default:()=>{var T;return[e.createVNode("div",e.mergeProps({ref:P,class:b.e("menu-wrap")},n),[(T=o.menu)==null?void 0:T.call(o)])]}}),[[e.vShow,v.value]])]})]})])}});const F={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},align:{type:String,default:null},offset:{type:[Number,Object],default:4},clickOutside:{type:Function,default:()=>!0},showAnimation:{type:Boolean,default:!0},overlayClass:{type:String,default:""}};var S=e.defineComponent({name:"DDropdownMenu",inheritAttrs:!1,props:F,emits:["update:modelValue"],setup(t,{slots:o,attrs:n,emit:r}){const{modelValue:u,origin:l,position:s,align:a,offset:d,clickOutside:w,showAnimation:C,overlayClass:f}=e.toRefs(t),O=e.ref(null),h=N("dropdown");U.onClickOutside(O,i=>{var c,b;((c=w.value)==null?void 0:c.call(w))&&!((b=l==null?void 0:l.value)==null?void 0:b.contains(i.target))&&r("update:modelValue",!1)});const P=e.ref("bottom"),y=i=>{P.value=i.split("-")[0]==="top"?"top":"bottom"},p=e.computed(()=>({transformOrigin:P.value==="top"?"0% 100%":"0% 0%"}));return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:C.value?h.m(`fade-${P.value}`):""},{default:()=>[e.createVNode($,{modelValue:u.value,"onUpdate:modelValue":i=>u.value=i,origin:l==null?void 0:l.value,position:s.value,align:a.value,offset:d.value,onPositionChange:y,class:f.value,style:p.value},{default:()=>{var i;return[e.createVNode("div",e.mergeProps({ref:O,class:h.e("menu-wrap")},n),[(i=o.default)==null?void 0:i.call(o)])]}})]})]})}}),re={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"50%",install(t){t.component(M.name,M),t.component(S.name,S)}};m.Dropdown=M,m.DropdownMenu=S,m.default=re,m.dropdownMenuProps=F,Object.defineProperty(m,"__esModule",{value:!0}),m[Symbol.toStringTag]="Module"});
|
|
@@ -18,9 +18,9 @@ var __publicField = (obj, key, value) => {
|
|
|
18
18
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
19
|
return value;
|
|
20
20
|
};
|
|
21
|
-
import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, unref, nextTick, withModifiers, inject,
|
|
21
|
+
import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, unref, nextTick, withModifiers, inject, h, render, withDirectives, resolveDirective, renderSlot, useSlots, reactive, getCurrentInstance, onMounted, provide, toRef, vShow, Teleport, isVNode } from "vue";
|
|
22
22
|
import { onClickOutside } from "@vueuse/core";
|
|
23
|
-
import { offset,
|
|
23
|
+
import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
|
|
24
24
|
const editableSelectProps = {
|
|
25
25
|
modelValue: {
|
|
26
26
|
type: [String, Number]
|
|
@@ -83,6 +83,9 @@ const editableSelectProps = {
|
|
|
83
83
|
showGlowStyle: {
|
|
84
84
|
type: Boolean,
|
|
85
85
|
default: true
|
|
86
|
+
},
|
|
87
|
+
maxLength: {
|
|
88
|
+
type: Number
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
const SELECT_KEY = Symbol("EditableSelect");
|
|
@@ -227,18 +230,12 @@ const flexibleOverlayProps = {
|
|
|
227
230
|
clickEventBubble: {
|
|
228
231
|
type: Boolean,
|
|
229
232
|
default: false
|
|
233
|
+
},
|
|
234
|
+
fitOriginWidth: {
|
|
235
|
+
type: Boolean,
|
|
236
|
+
default: false
|
|
230
237
|
}
|
|
231
238
|
};
|
|
232
|
-
function getScrollParent(element) {
|
|
233
|
-
const overflowRegex = /(auto|scroll|hidden)/;
|
|
234
|
-
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
235
|
-
const style = window.getComputedStyle(parent);
|
|
236
|
-
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
237
|
-
return parent;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return window;
|
|
241
|
-
}
|
|
242
239
|
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
243
240
|
let { x, y } = point;
|
|
244
241
|
if (!isArrowCenter) {
|
|
@@ -259,9 +256,18 @@ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
|
259
256
|
return { x, y };
|
|
260
257
|
}
|
|
261
258
|
function useOverlay(props, emit) {
|
|
259
|
+
const { fitOriginWidth, position, showArrow } = toRefs(props);
|
|
262
260
|
const overlayRef = ref();
|
|
263
261
|
const arrowRef = ref();
|
|
264
|
-
|
|
262
|
+
const overlayWidth = ref(0);
|
|
263
|
+
let originObserver;
|
|
264
|
+
const styles = computed(() => {
|
|
265
|
+
if (fitOriginWidth.value) {
|
|
266
|
+
return { width: overlayWidth.value + "px" };
|
|
267
|
+
} else {
|
|
268
|
+
return {};
|
|
269
|
+
}
|
|
270
|
+
});
|
|
265
271
|
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
266
272
|
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
267
273
|
const staticSide = {
|
|
@@ -282,54 +288,67 @@ function useOverlay(props, emit) {
|
|
|
282
288
|
const hostEl = props.origin;
|
|
283
289
|
const overlayEl = unref(overlayRef.value);
|
|
284
290
|
const arrowEl = unref(arrowRef.value);
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
})
|
|
291
|
-
];
|
|
292
|
-
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
293
|
-
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
294
|
-
if (!overlayEl) {
|
|
295
|
-
return;
|
|
291
|
+
const [mainPosition, ...fallbackPosition] = position.value;
|
|
292
|
+
const middleware = [offset(props.offset)];
|
|
293
|
+
middleware.push(fallbackPosition.length ? flip({ fallbackPlacements: fallbackPosition }) : flip());
|
|
294
|
+
if (showArrow.value) {
|
|
295
|
+
middleware.push(arrow({ element: arrowRef.value }));
|
|
296
296
|
}
|
|
297
297
|
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
298
298
|
strategy: "fixed",
|
|
299
|
+
placement: mainPosition,
|
|
299
300
|
middleware
|
|
300
301
|
});
|
|
301
302
|
let applyX = x;
|
|
302
303
|
let applyY = y;
|
|
303
|
-
if (props.shiftOffset !== void 0) {
|
|
304
|
-
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
305
|
-
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
306
|
-
shiftX > 0 && (applyX += props.shiftOffset);
|
|
307
|
-
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
308
|
-
shiftY > 0 && (applyY += props.shiftOffset);
|
|
309
|
-
}
|
|
310
304
|
emit("positionChange", placement);
|
|
311
305
|
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
312
306
|
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
313
307
|
};
|
|
308
|
+
const scrollCallback = (e) => {
|
|
309
|
+
var _a, _b;
|
|
310
|
+
const scrollElement = e.target;
|
|
311
|
+
if (scrollElement == null ? void 0 : scrollElement.contains((_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin)) {
|
|
312
|
+
updatePosition();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const updateWidth = (originEl) => {
|
|
316
|
+
overlayWidth.value = originEl.getBoundingClientRect().width;
|
|
317
|
+
updatePosition();
|
|
318
|
+
};
|
|
319
|
+
const observeOrigin = () => {
|
|
320
|
+
var _a, _b;
|
|
321
|
+
if (fitOriginWidth.value && typeof window !== "undefined") {
|
|
322
|
+
const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
|
|
323
|
+
if (originEl) {
|
|
324
|
+
originObserver = new window.ResizeObserver(() => updateWidth(originEl));
|
|
325
|
+
originObserver.observe(originEl);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const unobserveOrigin = () => {
|
|
330
|
+
var _a, _b;
|
|
331
|
+
const originEl = (_b = (_a = props.origin) == null ? void 0 : _a.$el) != null ? _b : props.origin;
|
|
332
|
+
originEl && (originObserver == null ? void 0 : originObserver.unobserve(originEl));
|
|
333
|
+
};
|
|
314
334
|
watch(() => props.modelValue, () => {
|
|
315
335
|
if (props.modelValue && props.origin) {
|
|
316
|
-
originParent = getScrollParent(props.origin);
|
|
317
336
|
nextTick(updatePosition);
|
|
318
|
-
|
|
319
|
-
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
337
|
+
window.addEventListener("scroll", scrollCallback, true);
|
|
320
338
|
window.addEventListener("resize", updatePosition);
|
|
339
|
+
observeOrigin();
|
|
321
340
|
} else {
|
|
322
|
-
|
|
323
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
341
|
+
window.removeEventListener("scroll", scrollCallback, true);
|
|
324
342
|
window.removeEventListener("resize", updatePosition);
|
|
343
|
+
unobserveOrigin();
|
|
325
344
|
}
|
|
326
345
|
});
|
|
327
346
|
onUnmounted(() => {
|
|
328
|
-
|
|
329
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
347
|
+
window.removeEventListener("scroll", scrollCallback, true);
|
|
330
348
|
window.removeEventListener("resize", updatePosition);
|
|
349
|
+
unobserveOrigin();
|
|
331
350
|
});
|
|
332
|
-
return { arrowRef, overlayRef, updatePosition };
|
|
351
|
+
return { arrowRef, overlayRef, styles, updatePosition };
|
|
333
352
|
}
|
|
334
353
|
var flexibleOverlay = "";
|
|
335
354
|
const FlexibleOverlay = defineComponent({
|
|
@@ -350,6 +369,7 @@ const FlexibleOverlay = defineComponent({
|
|
|
350
369
|
const {
|
|
351
370
|
arrowRef,
|
|
352
371
|
overlayRef,
|
|
372
|
+
styles,
|
|
353
373
|
updatePosition
|
|
354
374
|
} = useOverlay(props, emit);
|
|
355
375
|
expose({
|
|
@@ -359,7 +379,8 @@ const FlexibleOverlay = defineComponent({
|
|
|
359
379
|
var _a;
|
|
360
380
|
return props.modelValue && createVNode("div", mergeProps({
|
|
361
381
|
"ref": overlayRef,
|
|
362
|
-
"class": ns.b()
|
|
382
|
+
"class": ns.b(),
|
|
383
|
+
"style": styles.value
|
|
363
384
|
}, attrs, {
|
|
364
385
|
"onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
|
|
365
386
|
"onPointerup": withModifiers(() => ({}), ["stop"])
|
|
@@ -4489,7 +4510,7 @@ var lodash = { exports: {} };
|
|
|
4489
4510
|
var delay = baseRest(function(func, wait, args) {
|
|
4490
4511
|
return baseDelay(func, toNumber(wait) || 0, args);
|
|
4491
4512
|
});
|
|
4492
|
-
function
|
|
4513
|
+
function flip2(func) {
|
|
4493
4514
|
return createWrap(func, WRAP_FLIP_FLAG);
|
|
4494
4515
|
}
|
|
4495
4516
|
function memoize(func, resolver) {
|
|
@@ -5613,7 +5634,7 @@ var lodash = { exports: {} };
|
|
|
5613
5634
|
lodash2.flatten = flatten;
|
|
5614
5635
|
lodash2.flattenDeep = flattenDeep;
|
|
5615
5636
|
lodash2.flattenDepth = flattenDepth;
|
|
5616
|
-
lodash2.flip =
|
|
5637
|
+
lodash2.flip = flip2;
|
|
5617
5638
|
lodash2.flow = flow;
|
|
5618
5639
|
lodash2.flowRight = flowRight;
|
|
5619
5640
|
lodash2.fromPairs = fromPairs;
|
|
@@ -6673,7 +6694,8 @@ var EditableSelect = defineComponent({
|
|
|
6673
6694
|
disabled,
|
|
6674
6695
|
modelValue,
|
|
6675
6696
|
position,
|
|
6676
|
-
placeholder
|
|
6697
|
+
placeholder,
|
|
6698
|
+
maxLength
|
|
6677
6699
|
} = toRefs(props);
|
|
6678
6700
|
const align = computed(() => position.value.some((item) => item.includes("start") || item.includes("end")) ? "start" : null);
|
|
6679
6701
|
const {
|
|
@@ -6786,6 +6808,7 @@ var EditableSelect = defineComponent({
|
|
|
6786
6808
|
"disabled": disabled.value,
|
|
6787
6809
|
"placeholder": placeholder.value,
|
|
6788
6810
|
"value": states.inputValue,
|
|
6811
|
+
"maxlength": maxLength == null ? void 0 : maxLength.value,
|
|
6789
6812
|
"type": "text",
|
|
6790
6813
|
"onInput": onInput,
|
|
6791
6814
|
"onFocus": handleFocus,
|