vue-devui 1.0.0-rc.8 → 1.0.1
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/README.md +188 -149
- package/alert/index.es.js +14 -9
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8392 -418
- package/auto-complete/index.umd.js +29 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +59 -74
- package/avatar/index.umd.js +1 -1
- package/badge/index.es.js +10 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +191 -53
- package/button/index.umd.js +17 -17
- package/button/style.css +1 -1
- package/card/index.es.js +7 -3
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +8050 -241
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{date-picker → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +213 -0
- package/collapse/index.umd.js +1 -0
- package/{date-picker → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +56 -13
- package/countdown/index.umd.js +1 -1
- package/date-picker-pro/index.d.ts +7 -0
- package/date-picker-pro/index.es.js +12022 -0
- package/date-picker-pro/index.umd.js +27 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.es.js +24 -7
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +190 -165
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +785 -145
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +399 -300
- package/form/index.umd.js +16 -16
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +2 -2
- package/fullscreen/index.umd.js +1 -1
- package/grid/index.es.js +8 -6
- package/grid/index.umd.js +1 -1
- package/icon/index.es.js +185 -23
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +2 -2
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8220 -45
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +279 -204
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +3 -3
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +53 -53
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/mention/index.d.ts +7 -0
- package/mention/index.es.js +8319 -0
- package/mention/index.umd.js +36 -0
- package/mention/package.json +7 -0
- package/mention/style.css +1 -0
- package/menu/index.d.ts +7 -0
- package/menu/index.es.js +921 -0
- package/menu/index.umd.js +1 -0
- package/menu/package.json +7 -0
- package/menu/style.css +1 -0
- package/message/index.d.ts +7 -0
- package/message/index.es.js +539 -0
- package/message/index.umd.js +1 -0
- package/message/package.json +7 -0
- package/message/style.css +1 -0
- package/modal/index.es.js +451 -173
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +212 -70
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Mention.js +3 -0
- package/nuxt/components/Menu.js +3 -0
- package/nuxt/components/MenuItem.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/SubMenu.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/iconProps.js +1 -0
- package/nuxt/components/mentionProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/paginationInjectionKey.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/treeNodeProps.js +3 -0
- package/overlay/index.es.js +89 -142
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -4
- package/pagination/index.es.js +10180 -129
- package/pagination/index.umd.js +27 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +4 -0
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +262 -229
- package/popover/index.umd.js +15 -15
- package/popover/style.css +1 -1
- package/progress/index.es.js +2 -2
- package/progress/index.umd.js +2 -2
- package/progress/style.css +1 -1
- package/radio/index.es.js +7954 -156
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +16 -8
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +170 -22
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +3829 -1042
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +9202 -495
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +89 -263
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +118 -145
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +454 -233
- package/splitter/index.umd.js +13 -13
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +34 -16
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +6 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps/index.d.ts +7 -0
- package/steps/index.es.js +387 -0
- package/steps/index.umd.js +1 -0
- package/steps/package.json +7 -0
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.es.js +7787 -62
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +5225 -1726
- package/table/index.umd.js +18 -18
- package/table/style.css +1 -1
- package/tabs/index.es.js +303 -102
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +11 -8
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +7876 -41
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +9549 -0
- package/time-picker/index.umd.js +27 -0
- package/time-picker/package.json +7 -0
- package/time-picker/style.css +1 -0
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9607 -0
- package/time-select/index.umd.js +27 -0
- package/time-select/package.json +7 -0
- package/time-select/style.css +1 -0
- package/timeline/index.es.js +170 -22
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +286 -238
- package/tooltip/index.umd.js +14 -14
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +11342 -793
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +458 -102
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +20475 -11072
- package/vue-devui.umd.js +31 -24
- package/date-picker/index.es.js +0 -1097
- package/date-picker/index.umd.js +0 -1
- package/date-picker/style.css +0 -1
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/Loading.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/formControlProps.js +0 -3
- package/nuxt/components/overlayEmits.js +0 -3
- package/nuxt/components/overlayProps.js +0 -3
package/dropdown/index.es.js
CHANGED
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { toRefs, watch, onMounted, onUnmounted, ref, computed, defineComponent, createVNode,
|
|
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
21
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
22
22
|
import { onClickOutside } from "@vueuse/core";
|
|
23
23
|
const dropdownProps = {
|
|
@@ -65,6 +65,7 @@ const dropdownProps = {
|
|
|
65
65
|
default: true
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
+
const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
|
|
68
69
|
function getElement(element) {
|
|
69
70
|
if (element instanceof Element) {
|
|
70
71
|
return element;
|
|
@@ -109,6 +110,7 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
|
109
110
|
const subscriptions = [];
|
|
110
111
|
setTimeout(() => {
|
|
111
112
|
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
113
|
+
e.stopPropagation();
|
|
112
114
|
const dropdownValues = [...dropdownMap.values()];
|
|
113
115
|
if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
114
116
|
var _a;
|
|
@@ -209,7 +211,8 @@ function useOverlayProps(props, currentPosition, isOpen) {
|
|
|
209
211
|
const overlayModelValue = ref(false);
|
|
210
212
|
const overlayShowValue = ref(false);
|
|
211
213
|
const styles = computed(() => ({
|
|
212
|
-
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
214
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
|
|
215
|
+
zIndex: "var(--devui-z-index-dropdown, 1052)"
|
|
213
216
|
}));
|
|
214
217
|
const classes = computed(() => ({
|
|
215
218
|
"fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
|
|
@@ -217,7 +220,7 @@ function useOverlayProps(props, currentPosition, isOpen) {
|
|
|
217
220
|
[`${overlayClass.value}`]: true
|
|
218
221
|
}));
|
|
219
222
|
const handlePositionChange = (pos) => {
|
|
220
|
-
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
223
|
+
currentPosition.value = pos.includes("top") || pos.includes("right-end") || pos.includes("left-end") ? "top" : "bottom";
|
|
221
224
|
};
|
|
222
225
|
watch(isOpen, (isOpenVal) => {
|
|
223
226
|
overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
|
|
@@ -225,6 +228,61 @@ function useOverlayProps(props, currentPosition, isOpen) {
|
|
|
225
228
|
});
|
|
226
229
|
return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
|
|
227
230
|
}
|
|
231
|
+
const fixedOverlayProps = {
|
|
232
|
+
modelValue: {
|
|
233
|
+
type: Boolean,
|
|
234
|
+
default: false
|
|
235
|
+
},
|
|
236
|
+
lockScroll: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default: true
|
|
239
|
+
},
|
|
240
|
+
closeOnClickOverlay: {
|
|
241
|
+
type: Boolean,
|
|
242
|
+
default: true
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
function lockScroll() {
|
|
246
|
+
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
|
|
247
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
248
|
+
const style = document.documentElement.getAttribute("style");
|
|
249
|
+
document.documentElement.style.position = "fixed";
|
|
250
|
+
document.documentElement.style.top = `-${scrollTop}px`;
|
|
251
|
+
document.documentElement.style.width = document.documentElement.style.width || "100%";
|
|
252
|
+
document.documentElement.style.overflowY = "scroll";
|
|
253
|
+
return () => {
|
|
254
|
+
if (style) {
|
|
255
|
+
document.documentElement.setAttribute("style", style);
|
|
256
|
+
} else {
|
|
257
|
+
document.documentElement.removeAttribute("style");
|
|
258
|
+
}
|
|
259
|
+
document.documentElement.scrollTop = scrollTop;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
function useFixedOverlay(props, ctx) {
|
|
265
|
+
let lockScrollCb;
|
|
266
|
+
const onClick = (event) => {
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
ctx.emit("click", event);
|
|
269
|
+
if (props.closeOnClickOverlay) {
|
|
270
|
+
ctx.emit("update:modelValue", false);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const removeBodyAdditions = () => {
|
|
274
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
275
|
+
};
|
|
276
|
+
watch(() => props.modelValue, (val) => {
|
|
277
|
+
if (val) {
|
|
278
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
279
|
+
} else {
|
|
280
|
+
removeBodyAdditions();
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
onUnmounted(removeBodyAdditions);
|
|
284
|
+
return { onClick };
|
|
285
|
+
}
|
|
228
286
|
function createBem(namespace, element, modifier) {
|
|
229
287
|
let cls = namespace;
|
|
230
288
|
if (element) {
|
|
@@ -235,8 +293,8 @@ function createBem(namespace, element, modifier) {
|
|
|
235
293
|
}
|
|
236
294
|
return cls;
|
|
237
295
|
}
|
|
238
|
-
function useNamespace(block) {
|
|
239
|
-
const namespace = `devui-${block}`;
|
|
296
|
+
function useNamespace(block, needDot = false) {
|
|
297
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
240
298
|
const b = () => createBem(namespace);
|
|
241
299
|
const e = (element) => element ? createBem(namespace, element) : "";
|
|
242
300
|
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
@@ -248,130 +306,31 @@ function useNamespace(block) {
|
|
|
248
306
|
em
|
|
249
307
|
};
|
|
250
308
|
}
|
|
251
|
-
var baseOverlay = "";
|
|
252
|
-
function _isSlot(s) {
|
|
253
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
254
|
-
}
|
|
255
|
-
const CommonOverlay = defineComponent({
|
|
256
|
-
setup(props, ctx) {
|
|
257
|
-
const ns = useNamespace("overlay");
|
|
258
|
-
return () => {
|
|
259
|
-
let _slot;
|
|
260
|
-
return createVNode(Teleport, {
|
|
261
|
-
"to": "#d-overlay-anchor"
|
|
262
|
-
}, {
|
|
263
|
-
default: () => [createVNode(Transition, {
|
|
264
|
-
"name": ns.e("fade")
|
|
265
|
-
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
266
|
-
default: () => [_slot]
|
|
267
|
-
})]
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
const overlayProps = {
|
|
273
|
-
visible: {
|
|
274
|
-
type: Boolean
|
|
275
|
-
},
|
|
276
|
-
backgroundBlock: {
|
|
277
|
-
type: Boolean,
|
|
278
|
-
default: false
|
|
279
|
-
},
|
|
280
|
-
backgroundClass: {
|
|
281
|
-
type: String,
|
|
282
|
-
default: ""
|
|
283
|
-
},
|
|
284
|
-
backgroundStyle: {
|
|
285
|
-
type: [String, Object]
|
|
286
|
-
},
|
|
287
|
-
onBackdropClick: {
|
|
288
|
-
type: Function
|
|
289
|
-
},
|
|
290
|
-
backdropClose: {
|
|
291
|
-
type: Boolean,
|
|
292
|
-
default: true
|
|
293
|
-
},
|
|
294
|
-
hasBackdrop: {
|
|
295
|
-
type: Boolean,
|
|
296
|
-
default: true
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
300
|
-
overlayStyle: {
|
|
301
|
-
type: [String, Object],
|
|
302
|
-
default: void 0
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
306
|
-
function useOverlayLogic(props, ctx) {
|
|
307
|
-
const ns = useNamespace("overlay");
|
|
308
|
-
const backgroundClass = computed(() => {
|
|
309
|
-
return [ns.e("background"), props.backgroundClass, !props.hasBackdrop ? ns.em("background", "disabled") : ns.em("background", "color")];
|
|
310
|
-
});
|
|
311
|
-
const overlayClass = computed(() => {
|
|
312
|
-
return ns.b();
|
|
313
|
-
});
|
|
314
|
-
const handleBackdropClick = (event) => {
|
|
315
|
-
var _a;
|
|
316
|
-
event.preventDefault();
|
|
317
|
-
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
318
|
-
if (props.backdropClose) {
|
|
319
|
-
ctx.emit("update:visible", false);
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
323
|
-
onMounted(() => {
|
|
324
|
-
const body = document.body;
|
|
325
|
-
const originOverflow = body.style.overflow;
|
|
326
|
-
const originPosition = body.style.position;
|
|
327
|
-
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
328
|
-
if (backgroundBlock) {
|
|
329
|
-
const top = body.getBoundingClientRect().y;
|
|
330
|
-
if (visible) {
|
|
331
|
-
body.style.overflowY = "scroll";
|
|
332
|
-
body.style.position = visible ? "fixed" : "";
|
|
333
|
-
body.style.top = `${top}px`;
|
|
334
|
-
} else {
|
|
335
|
-
body.style.overflowY = originOverflow;
|
|
336
|
-
body.style.position = originPosition;
|
|
337
|
-
body.style.top = "";
|
|
338
|
-
window.scrollTo(0, -top);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
onUnmounted(() => {
|
|
343
|
-
document.body.style.overflow = originOverflow;
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
return {
|
|
347
|
-
backgroundClass,
|
|
348
|
-
overlayClass,
|
|
349
|
-
handleBackdropClick,
|
|
350
|
-
handleOverlayBubbleCancel
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
309
|
var fixedOverlay = "";
|
|
354
310
|
defineComponent({
|
|
355
311
|
name: "DFixedOverlay",
|
|
312
|
+
inheritAttrs: false,
|
|
356
313
|
props: fixedOverlayProps,
|
|
357
|
-
emits:
|
|
314
|
+
emits: ["update:modelValue", "click"],
|
|
358
315
|
setup(props, ctx) {
|
|
359
316
|
const {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
317
|
+
modelValue
|
|
318
|
+
} = toRefs(props);
|
|
319
|
+
const ns2 = useNamespace("fixed-overlay");
|
|
320
|
+
const {
|
|
321
|
+
onClick
|
|
322
|
+
} = useFixedOverlay(props, ctx);
|
|
323
|
+
return () => createVNode(Transition, {
|
|
324
|
+
"name": ns2.m("fade")
|
|
325
|
+
}, {
|
|
326
|
+
default: () => {
|
|
327
|
+
var _a, _b;
|
|
328
|
+
return [modelValue.value && createVNode("div", mergeProps({
|
|
329
|
+
"class": ns2.b()
|
|
330
|
+
}, ctx.attrs, {
|
|
331
|
+
"onClick": onClick
|
|
332
|
+
}), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
|
|
333
|
+
}
|
|
375
334
|
});
|
|
376
335
|
}
|
|
377
336
|
});
|
|
@@ -406,6 +365,10 @@ const flexibleOverlayProps = {
|
|
|
406
365
|
isArrowCenter: {
|
|
407
366
|
type: Boolean,
|
|
408
367
|
default: true
|
|
368
|
+
},
|
|
369
|
+
clickEventBubble: {
|
|
370
|
+
type: Boolean,
|
|
371
|
+
default: false
|
|
409
372
|
}
|
|
410
373
|
};
|
|
411
374
|
function getScrollParent(element) {
|
|
@@ -519,7 +482,10 @@ const FlexibleOverlay = defineComponent({
|
|
|
519
482
|
emit,
|
|
520
483
|
expose
|
|
521
484
|
}) {
|
|
522
|
-
const
|
|
485
|
+
const ns2 = useNamespace("flexible-overlay");
|
|
486
|
+
const {
|
|
487
|
+
clickEventBubble
|
|
488
|
+
} = toRefs(props);
|
|
523
489
|
const {
|
|
524
490
|
arrowRef,
|
|
525
491
|
overlayRef,
|
|
@@ -532,14 +498,72 @@ const FlexibleOverlay = defineComponent({
|
|
|
532
498
|
var _a;
|
|
533
499
|
return props.modelValue && createVNode("div", mergeProps({
|
|
534
500
|
"ref": overlayRef,
|
|
535
|
-
"class":
|
|
536
|
-
}, attrs
|
|
501
|
+
"class": ns2.b()
|
|
502
|
+
}, attrs, {
|
|
503
|
+
"onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
|
|
504
|
+
"onPointerup": withModifiers(() => ({}), ["stop"])
|
|
505
|
+
}), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
537
506
|
"ref": arrowRef,
|
|
538
|
-
"class":
|
|
507
|
+
"class": ns2.e("arrow")
|
|
539
508
|
}, null)]);
|
|
540
509
|
};
|
|
541
510
|
}
|
|
542
511
|
});
|
|
512
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
513
|
+
const ns = useNamespace("popper-trigger");
|
|
514
|
+
function wrapContent(content) {
|
|
515
|
+
return h("span", { class: ns.b() }, content);
|
|
516
|
+
}
|
|
517
|
+
function getFirstValidChild(nodes) {
|
|
518
|
+
for (const child of nodes) {
|
|
519
|
+
if (isObject(child)) {
|
|
520
|
+
if (child.type === Comment) {
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (child.type === "svg" || child.type === Text) {
|
|
524
|
+
return wrapContent(child);
|
|
525
|
+
}
|
|
526
|
+
if (child.type === Fragment) {
|
|
527
|
+
return getFirstValidChild(child.children);
|
|
528
|
+
}
|
|
529
|
+
return child;
|
|
530
|
+
}
|
|
531
|
+
return wrapContent(child);
|
|
532
|
+
}
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
var PopperTrigger = defineComponent({
|
|
536
|
+
name: "DPopperTrigger",
|
|
537
|
+
setup(_, ctx) {
|
|
538
|
+
const {
|
|
539
|
+
slots,
|
|
540
|
+
attrs
|
|
541
|
+
} = ctx;
|
|
542
|
+
return () => {
|
|
543
|
+
var _a;
|
|
544
|
+
const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
|
|
545
|
+
const triggerRef = inject(POPPER_TRIGGER_TOKEN);
|
|
546
|
+
if (!defaultSlot) {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
const firstValidChild = getFirstValidChild(defaultSlot);
|
|
550
|
+
if (!firstValidChild) {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
return withDirectives(cloneVNode(firstValidChild, attrs), [[{
|
|
554
|
+
mounted(el) {
|
|
555
|
+
triggerRef.value = el;
|
|
556
|
+
},
|
|
557
|
+
updated(el) {
|
|
558
|
+
triggerRef.value = el;
|
|
559
|
+
},
|
|
560
|
+
unmounted() {
|
|
561
|
+
triggerRef.value = null;
|
|
562
|
+
}
|
|
563
|
+
}]]);
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
});
|
|
543
567
|
var dropdown = "";
|
|
544
568
|
let dropdownId = 1;
|
|
545
569
|
var Dropdown = defineComponent({
|
|
@@ -568,7 +592,8 @@ var Dropdown = defineComponent({
|
|
|
568
592
|
const id = `dropdown_${dropdownId++}`;
|
|
569
593
|
const isOpen = ref(false);
|
|
570
594
|
const currentPosition = ref("bottom");
|
|
571
|
-
const
|
|
595
|
+
const ns2 = useNamespace("dropdown");
|
|
596
|
+
provide(POPPER_TRIGGER_TOKEN, origin);
|
|
572
597
|
useDropdownEvent({
|
|
573
598
|
id,
|
|
574
599
|
isOpen,
|
|
@@ -595,41 +620,41 @@ var Dropdown = defineComponent({
|
|
|
595
620
|
expose({
|
|
596
621
|
updatePosition: () => overlayRef.value.updatePosition()
|
|
597
622
|
});
|
|
598
|
-
return () => {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
623
|
+
return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
|
|
624
|
+
default: () => {
|
|
625
|
+
var _a;
|
|
626
|
+
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
627
|
+
}
|
|
628
|
+
}), createVNode(Teleport, {
|
|
629
|
+
"to": "body"
|
|
630
|
+
}, {
|
|
631
|
+
default: () => [createVNode(Transition, {
|
|
632
|
+
"name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
|
|
605
633
|
}, {
|
|
606
|
-
default: () => [createVNode(
|
|
607
|
-
"
|
|
634
|
+
default: () => [withDirectives(createVNode(FlexibleOverlay, {
|
|
635
|
+
"modelValue": overlayModelValue.value,
|
|
636
|
+
"onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
|
|
637
|
+
"ref": overlayRef,
|
|
638
|
+
"origin": origin.value,
|
|
639
|
+
"position": position.value,
|
|
640
|
+
"align": align.value,
|
|
641
|
+
"offset": offset2.value,
|
|
642
|
+
"shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
|
|
643
|
+
"onPositionChange": handlePositionChange,
|
|
644
|
+
"click-event-bubble": true,
|
|
645
|
+
"class": classes.value,
|
|
646
|
+
"style": styles.value
|
|
608
647
|
}, {
|
|
609
|
-
default: () =>
|
|
610
|
-
|
|
611
|
-
"
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
"class": classes.value,
|
|
620
|
-
"style": styles.value
|
|
621
|
-
}, {
|
|
622
|
-
default: () => {
|
|
623
|
-
var _a2;
|
|
624
|
-
return [createVNode("div", mergeProps({
|
|
625
|
-
"ref": dropdownRef,
|
|
626
|
-
"class": ns.e("menu-wrap")
|
|
627
|
-
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
628
|
-
}
|
|
629
|
-
}), [[vShow, overlayShowValue.value]])]
|
|
630
|
-
})]
|
|
631
|
-
})]);
|
|
632
|
-
};
|
|
648
|
+
default: () => {
|
|
649
|
+
var _a;
|
|
650
|
+
return [createVNode("div", mergeProps({
|
|
651
|
+
"ref": dropdownRef,
|
|
652
|
+
"class": ns2.e("menu-wrap")
|
|
653
|
+
}, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
|
|
654
|
+
}
|
|
655
|
+
}), [[vShow, overlayShowValue.value]])]
|
|
656
|
+
})]
|
|
657
|
+
})]);
|
|
633
658
|
}
|
|
634
659
|
});
|
|
635
660
|
const dropdownMenuProps = {
|
|
@@ -687,7 +712,7 @@ var DropdownMenu = defineComponent({
|
|
|
687
712
|
overlayClass
|
|
688
713
|
} = toRefs(props);
|
|
689
714
|
const dropdownMenuRef = ref(null);
|
|
690
|
-
const
|
|
715
|
+
const ns2 = useNamespace("dropdown");
|
|
691
716
|
onClickOutside(dropdownMenuRef, (value) => {
|
|
692
717
|
var _a, _b;
|
|
693
718
|
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
|
|
@@ -705,7 +730,7 @@ var DropdownMenu = defineComponent({
|
|
|
705
730
|
"to": "body"
|
|
706
731
|
}, {
|
|
707
732
|
default: () => [createVNode(Transition, {
|
|
708
|
-
"name": showAnimation.value ? `
|
|
733
|
+
"name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
|
|
709
734
|
}, {
|
|
710
735
|
default: () => [createVNode(FlexibleOverlay, {
|
|
711
736
|
"modelValue": modelValue.value,
|
|
@@ -722,7 +747,7 @@ var DropdownMenu = defineComponent({
|
|
|
722
747
|
var _a;
|
|
723
748
|
return [createVNode("div", mergeProps({
|
|
724
749
|
"ref": dropdownMenuRef,
|
|
725
|
-
"class":
|
|
750
|
+
"class": ns2.e("menu-wrap")
|
|
726
751
|
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
727
752
|
}
|
|
728
753
|
})]
|
|
@@ -733,7 +758,7 @@ var DropdownMenu = defineComponent({
|
|
|
733
758
|
var index = {
|
|
734
759
|
title: "Dropdown \u4E0B\u62C9\u83DC\u5355",
|
|
735
760
|
category: "\u5BFC\u822A",
|
|
736
|
-
status: "
|
|
761
|
+
status: "50%",
|
|
737
762
|
install(app) {
|
|
738
763
|
app.component(Dropdown.name, Dropdown);
|
|
739
764
|
app.component(DropdownMenu.name, DropdownMenu);
|
package/dropdown/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ae=Object.defineProperty,le=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var _=(f,e,w)=>e in f?ae(f,e,{enumerable:!0,configurable:!0,writable:!0,value:w}):f[e]=w,j=(f,e)=>{for(var w in e||(e={}))se.call(e,w)&&_(f,w,e[w]);if(F)for(var w of F(e))ie.call(e,w)&&_(f,w,e[w]);return f},L=(f,e)=>le(f,re(e));(function(f,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):(f=typeof globalThis!="undefined"?globalThis:f||self,e(f.index={},f.Vue,f.dom,f.core))})(this,function(f,e,w,H){"use strict";const q={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}};function U(t){return t instanceof Element?t:t&&typeof t=="object"&&t.$el instanceof Element?t.$el:null}const V=new Map;function P(t,o,n){return t==null||t.addEventListener(o,n),()=>{t==null||t.removeEventListener(o,n)}}const Y=({id:t,isOpen:o,origin:n,dropdownRef:l,props:r,emit:i})=>{let a=!1,s=!1;const{trigger:c,closeScope:u,closeOnMouseLeaveMenu:y}=e.toRefs(r),d=m=>{o.value=m,i("toggle",o.value)},v=async(m,C)=>{await new Promise(g=>setTimeout(g,50)),!(m==="origin"&&a||m==="dropdown"&&s)&&(C&&[...V.values()].reverse().forEach(g=>{setTimeout(()=>{var k;(k=g.toggle)==null||k.call(g)},0)}),d(!1))};e.watch([c,n,l],([m,C,g],k,p)=>{const h=U(C),O=[];setTimeout(()=>{O.push(P(document,"click",b=>{const B=[...V.values()];!o.value||u.value==="none"||(g==null?void 0:g.contains(b.target))&&u.value==="blank"||B.some(S=>{var E;return(E=S.toggleEl)==null?void 0:E.contains(b.target)})&&B.some(S=>{var E;return(E=S.menuEl)==null?void 0:E.contains(b.target)})||([...V.values()].reverse().forEach(S=>{setTimeout(()=>{var E,N;((E=S.toggleEl)==null?void 0:E.contains(b.target))||(N=S.toggle)==null||N.call(S)},0)}),a=!1)}))},0),m==="click"?O.push(P(h,"click",()=>d(!o.value)),P(g,"mouseleave",b=>{var B;y.value&&!((B=V.get(t).child)==null?void 0:B.contains(b.relatedTarget))&&v("dropdown",!0)})):m==="hover"&&O.push(P(h,"mouseenter",()=>{s=!0,d(!0)}),P(h,"mouseleave",()=>{s=!1,v("origin")}),P(g,"mouseenter",()=>{a=!0,o.value=!0}),P(g,"mouseleave",b=>{var B;a=!1,!(b.relatedTarget&&((h==null?void 0:h.contains(b.relatedTarget))||((B=V.get(t).child)==null?void 0:B.contains(b.relatedTarget))))&&v("dropdown",!0)})),p(()=>O.forEach(b=>b()))})};function z(t,o,n,l,r,i,a){const s=c=>{const u=c.offsetHeight;window.innerHeight-l.value.getBoundingClientRect().bottom>=u?i.value="bottom":i.value="top"};e.watch(o,(c,u)=>{u!==void 0&&(n.value=c,a("toggle",n.value))},{immediate:!0}),e.watch([n,r],([c,u])=>{var y;if(c){V.set(t,L(j({},V.get(t)),{menuEl:u,toggle:()=>{n.value=!1,a("toggle",n.value)}}));for(const d of V.values())((y=d.menuEl)==null?void 0:y.contains(l.value))&&(d.child=u)}u&&s(u)}),e.onMounted(()=>{V.set(t,{toggleEl:l.value})}),e.onUnmounted(()=>{V.delete(t)})}function X(t,o,n){const{showAnimation:l,overlayClass:r,destroyOnHide:i}=e.toRefs(t),a=e.ref(!1),s=e.ref(!1),c=e.computed(()=>({transformOrigin:o.value==="top"?"0% 100%":"0% 0%"})),u=e.computed(()=>({"fade-in-bottom":l.value&&n.value&&o.value==="bottom","fade-in-top":l.value&&n.value&&o.value==="top",[`${r.value}`]:!0})),y=d=>{o.value=d.includes("top")||d.includes("end")?"top":"bottom"};return e.watch(n,d=>{a.value=i.value?d:!0,s.value=d}),{overlayModelValue:a,overlayShowValue:s,styles:c,classes:u,handlePositionChange:y}}function A(t,o,n){let l=t;return o&&(l+=`__${o}`),n&&(l+=`--${n}`),l}function x(t){const o=`devui-${t}`;return{b:()=>A(o),e:a=>a?A(o,a):"",m:a=>a?A(o,"",a):"",em:(a,s)=>a&&s?A(o,a,s):""}}var ue="";function I(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const G=e.defineComponent({setup(t,o){const n=x("overlay");return()=>{let l;return e.createVNode(e.Teleport,{to:"#d-overlay-anchor"},{default:()=>[e.createVNode(e.Transition,{name:n.e("fade")},I(l=e.renderSlot(o.slots,"default"))?l:{default:()=>[l]})]})}}}),J=L(j({},{visible:{type:Boolean},backgroundBlock:{type:Boolean,default:!1},backgroundClass:{type:String,default:""},backgroundStyle:{type:[String,Object]},onBackdropClick:{type:Function},backdropClose:{type:Boolean,default:!0},hasBackdrop:{type:Boolean,default:!0}}),{overlayStyle:{type:[String,Object],default:void 0}}),K=["update:visible","backdropClick"];function Q(t,o){const n=x("overlay"),l=e.computed(()=>[n.e("background"),t.backgroundClass,t.hasBackdrop?n.em("background","color"):n.em("background","disabled")]),r=e.computed(()=>n.b()),i=s=>{var c;s.preventDefault(),(c=t.onBackdropClick)==null||c.call(t),t.backdropClose&&o.emit("update:visible",!1)},a=s=>s.cancelBubble=!0;return e.onMounted(()=>{const s=document.body,c=s.style.overflow,u=s.style.position;e.watch([()=>t.visible,()=>t.backgroundBlock],([y,d])=>{if(d){const v=s.getBoundingClientRect().y;y?(s.style.overflowY="scroll",s.style.position=y?"fixed":"",s.style.top=`${v}px`):(s.style.overflowY=c,s.style.position=u,s.style.top="",window.scrollTo(0,-v))}}),e.onUnmounted(()=>{document.body.style.overflow=c})}),{backgroundClass:l,overlayClass:r,handleBackdropClick:i,handleOverlayBubbleCancel:a}}var de="";e.defineComponent({name:"DFixedOverlay",props:J,emits:K,setup(t,o){const{backgroundClass:n,overlayClass:l,handleBackdropClick:r,handleOverlayBubbleCancel:i}=Q(t,o);return()=>e.createVNode(G,null,{default:()=>[t.visible&&e.createVNode("div",{class:n.value,style:t.backgroundStyle,onClick:r},[e.createVNode("div",{class:l.value,style:t.overlayStyle,onClick:i},[e.renderSlot(o.slots,"default")])])]})}});const W={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}};function Z(t){const o=/(auto|scroll|hidden)/;for(let n=t;n=n.parentElement;n.parentElement!==document.body){const l=window.getComputedStyle(n);if(o.test(l.overflow+l.overflowX+l.overflowY))return n}return window}function ee(t,o,n,l){let{x:r,y:i}=o;if(!t){const{width:a,height:s}=l;r&&n.includes("start")&&(r=12),r&&n.includes("end")&&(r=Math.round(a-24)),i&&n.includes("start")&&(i=10),i&&n.includes("end")&&(i=s-14)}return{x:r,y:i}}function te(t,o){const n=e.ref(),l=e.ref();let r=null;const i=(s,c,u,y)=>{const{x:d,y:v}=ee(t.isArrowCenter,u,c,y.getBoundingClientRect()),m={top:"bottom",right:"left",bottom:"top",left:"right"}[c.split("-")[0]];Object.assign(s.style,{left:d?`${d}px`:"",top:v?`${v}px`:"",right:"",bottom:"",[m]:"-4px"})},a=async()=>{const s=t.origin,c=e.unref(n.value),u=e.unref(l.value),y=[w.offset(t.offset),w.autoPlacement({alignment:t.align,allowedPlacements:t.position})];t.showArrow&&y.push(w.arrow({element:u})),t.shiftOffset!==void 0&&y.push(w.shift());const{x:d,y:v,placement:m,middlewareData:C}=await w.computePosition(s,c,{strategy:"fixed",middleware:y});let g=d,k=v;if(t.shiftOffset!==void 0){const{x:p,y:h}=C.shift;p<0&&(g-=t.shiftOffset),p>0&&(g+=t.shiftOffset),h<0&&(k-=t.shiftOffset),h>0&&(k+=t.shiftOffset)}o("positionChange",m),Object.assign(c.style,{top:`${k}px`,left:`${g}px`}),t.showArrow&&i(u,m,C.arrow,c)};return e.watch(()=>t.modelValue,()=>{t.modelValue&&t.origin?(r=Z(t.origin),e.nextTick(a),r==null||r.addEventListener("scroll",a),r!==window&&window.addEventListener("scroll",a),window.addEventListener("resize",a)):(r==null||r.removeEventListener("scroll",a),r!==window&&window.removeEventListener("scroll",a),window.removeEventListener("resize",a))}),e.onUnmounted(()=>{r==null||r.removeEventListener("scroll",a),r!==window&&window.removeEventListener("scroll",a),window.removeEventListener("resize",a)}),{arrowRef:l,overlayRef:n,updatePosition:a}}var fe="";const R=e.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:W,emits:["update:modelValue","positionChange"],setup(t,{slots:o,attrs:n,emit:l,expose:r}){const i=x("flexible-overlay"),{arrowRef:a,overlayRef:s,updatePosition:c}=te(t,l);return r({updatePosition:c}),()=>{var u;return t.modelValue&&e.createVNode("div",e.mergeProps({ref:s,class:i.b()},n),[(u=o.default)==null?void 0:u.call(o),t.showArrow&&e.createVNode("div",{ref:a,class:i.e("arrow")},null)])}}});var ye="";let oe=1;var M=e.defineComponent({name:"DDropdown",inheritAttrs:!1,props:q,emits:["toggle"],setup(t,{slots:o,attrs:n,emit:l,expose:r}){const{visible:i,position:a,align:s,offset:c,destroyOnHide:u,shiftOffset:y,showAnimation:d}=e.toRefs(t),v=e.ref(),m=e.ref(),C=e.ref(),g=`dropdown_${oe++}`,k=e.ref(!1),p=e.ref("bottom"),h=x("dropdown");Y({id:g,isOpen:k,origin:v,dropdownRef:m,props:t,emit:l}),z(g,i,k,v,m,p,l);const{overlayModelValue:O,overlayShowValue:b,styles:B,classes:S,handlePositionChange:E}=X(t,p,k);return e.watch(b,N=>{e.nextTick(()=>{!u.value&&N&&C.value.updatePosition()})}),r({updatePosition:()=>C.value.updatePosition()}),()=>{var N;return e.createVNode(e.Fragment,null,[e.createVNode("div",{ref:v,class:h.e("toggle")},[(N=o.default)==null?void 0:N.call(o)]),e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:d.value?`devui-dropdown-fade-${p.value}`:""},{default:()=>[e.withDirectives(e.createVNode(R,{modelValue:O.value,"onUpdate:modelValue":D=>O.value=D,ref:C,origin:v.value,position:a.value,align:s.value,offset:c.value,shiftOffset:y==null?void 0:y.value,onPositionChange:E,class:S.value,style:B.value},{default:()=>{var D;return[e.createVNode("div",e.mergeProps({ref:m,class:h.e("menu-wrap")},n),[(D=o.menu)==null?void 0:D.call(o)])]}}),[[e.vShow,b.value]])]})]})])}}});const $={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 T=e.defineComponent({name:"DDropdownMenu",inheritAttrs:!1,props:$,emits:["update:modelValue"],setup(t,{slots:o,attrs:n,emit:l}){const{modelValue:r,origin:i,position:a,align:s,offset:c,clickOutside:u,showAnimation:y,overlayClass:d}=e.toRefs(t),v=e.ref(null),m=x("dropdown");H.onClickOutside(v,p=>{var h,O;((h=u.value)==null?void 0:h.call(u))&&!((O=i==null?void 0:i.value)==null?void 0:O.contains(p.target))&&l("update:modelValue",!1)});const C=e.ref("bottom"),g=p=>{C.value=p.split("-")[0]==="top"?"top":"bottom"},k=e.computed(()=>({transformOrigin:C.value==="top"?"0% 100%":"0% 0%"}));return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:y.value?`devui-dropdown-fade-${C.value}`:""},{default:()=>[e.createVNode(R,{modelValue:r.value,"onUpdate:modelValue":p=>r.value=p,origin:i==null?void 0:i.value,position:a.value,align:s.value,offset:c.value,onPositionChange:g,class:d.value,style:k.value},{default:()=>{var p;return[e.createVNode("div",e.mergeProps({ref:v,class:m.e("menu-wrap")},n),[(p=o.default)==null?void 0:p.call(o)])]}})]})]})}}),ne={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"10%",install(t){t.component(M.name,M),t.component(T.name,T)}};f.Dropdown=M,f.DropdownMenu=T,f.default=ne,f.dropdownMenuProps=$,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|
|
1
|
+
var ie=Object.defineProperty,se=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var H=(d,e,w)=>e in d?ie(d,e,{enumerable:!0,configurable:!0,writable:!0,value:w}):d[e]=w,_=(d,e)=>{for(var w in e||(e={}))ce.call(e,w)&&H(d,w,e[w]);if(F)for(var w of F(e))de.call(e,w)&&H(d,w,e[w]);return d},q=(d,e)=>se(d,ue(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,z){"use strict";const U={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}},R=Symbol("popper-trigger");function Y(t){return t instanceof Element?t:t&&typeof t=="object"&&t.$el instanceof Element?t.$el:null}const O=new Map;function B(t,o,n){return t==null||t.addEventListener(o,n),()=>{t==null||t.removeEventListener(o,n)}}const I=({id:t,isOpen:o,origin:n,dropdownRef:r,props:l,emit:a})=>{let i=!1,s=!1;const{trigger:u,closeScope:c,closeOnMouseLeaveMenu:m}=e.toRefs(l),f=g=>{o.value=g,a("toggle",o.value)},v=async(g,E)=>{await new Promise(p=>setTimeout(p,50)),!(g==="origin"&&i||g==="dropdown"&&s)&&(E&&[...O.values()].reverse().forEach(p=>{setTimeout(()=>{var V;(V=p.toggle)==null||V.call(p)},0)}),f(!1))};e.watch([u,n,r],([g,E,p],V,y)=>{const b=Y(E),P=[];setTimeout(()=>{P.push(B(document,"click",h=>{h.stopPropagation();const x=[...O.values()];!o.value||c.value==="none"||(p==null?void 0:p.contains(h.target))&&c.value==="blank"||x.some(A=>{var T;return(T=A.toggleEl)==null?void 0:T.contains(h.target)})&&x.some(A=>{var T;return(T=A.menuEl)==null?void 0:T.contains(h.target)})||([...O.values()].reverse().forEach(A=>{setTimeout(()=>{var T,C;((T=A.toggleEl)==null?void 0:T.contains(h.target))||(C=A.toggle)==null||C.call(A)},0)}),i=!1)}))},0),g==="click"?P.push(B(b,"click",()=>f(!o.value)),B(p,"mouseleave",h=>{var x;m.value&&!((x=O.get(t).child)==null?void 0:x.contains(h.relatedTarget))&&v("dropdown",!0)})):g==="hover"&&P.push(B(b,"mouseenter",()=>{s=!0,f(!0)}),B(b,"mouseleave",()=>{s=!1,v("origin")}),B(p,"mouseenter",()=>{i=!0,o.value=!0}),B(p,"mouseleave",h=>{var x;i=!1,!(h.relatedTarget&&((b==null?void 0:b.contains(h.relatedTarget))||((x=O.get(t).child)==null?void 0:x.contains(h.relatedTarget))))&&v("dropdown",!0)})),y(()=>P.forEach(h=>h()))})};function X(t,o,n,r,l,a,i){const s=u=>{const c=u.offsetHeight;window.innerHeight-r.value.getBoundingClientRect().bottom>=c?a.value="bottom":a.value="top"};e.watch(o,(u,c)=>{c!==void 0&&(n.value=u,i("toggle",n.value))},{immediate:!0}),e.watch([n,l],([u,c])=>{var m;if(u){O.set(t,q(_({},O.get(t)),{menuEl:c,toggle:()=>{n.value=!1,i("toggle",n.value)}}));for(const f of O.values())((m=f.menuEl)==null?void 0:m.contains(r.value))&&(f.child=c)}c&&s(c)}),e.onMounted(()=>{O.set(t,{toggleEl:r.value})}),e.onUnmounted(()=>{O.delete(t)})}function G(t,o,n){const{showAnimation:r,overlayClass:l,destroyOnHide:a}=e.toRefs(t),i=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)"})),c=e.computed(()=>({"fade-in-bottom":r.value&&n.value&&o.value==="bottom","fade-in-top":r.value&&n.value&&o.value==="top",[`${l.value}`]:!0})),m=f=>{o.value=f.includes("top")||f.includes("right-end")||f.includes("left-end")?"top":"bottom"};return e.watch(n,f=>{i.value=a.value?f:!0,s.value=f}),{overlayModelValue:i,overlayShowValue:s,styles:u,classes:c,handlePositionChange:m}}const K={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=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=J()):l()}),e.onUnmounted(l),{onClick:r}}function D(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:()=>D(n),e:s=>s?D(n,s):"",m:s=>s?D(n,"",s):"",em:(s,u)=>s&&u?D(n,s,u):""}}var fe="";e.defineComponent({name:"DFixedOverlay",inheritAttrs:!1,props:K,emits:["update:modelValue","click"],setup(t,o){const{modelValue:n}=e.toRefs(t),r=N("fixed-overlay"),{onClick:l}=Q(t,o);return()=>e.createVNode(e.Transition,{name:r.m("fade")},{default:()=>{var a,i;return[n.value&&e.createVNode("div",e.mergeProps({class:r.b()},o.attrs,{onClick:l}),[(i=(a=o.slots).default)==null?void 0:i.call(a)])]}})}});const W={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 Z(t){const o=/(auto|scroll|hidden)/;for(let n=t;n=n.parentElement;n.parentElement!==document.body){const r=window.getComputedStyle(n);if(o.test(r.overflow+r.overflowX+r.overflowY))return n}return window}function ee(t,o,n,r){let{x:l,y:a}=o;if(!t){const{width:i,height:s}=r;l&&n.includes("start")&&(l=12),l&&n.includes("end")&&(l=Math.round(i-24)),a&&n.includes("start")&&(a=10),a&&n.includes("end")&&(a=s-14)}return{x:l,y:a}}function te(t,o){const n=e.ref(),r=e.ref();let l=null;const a=(s,u,c,m)=>{const{x:f,y:v}=ee(t.isArrowCenter,c,u,m.getBoundingClientRect()),g={top:"bottom",right:"left",bottom:"top",left:"right"}[u.split("-")[0]];Object.assign(s.style,{left:f?`${f}px`:"",top:v?`${v}px`:"",right:"",bottom:"",[g]:"-4px"})},i=async()=>{const s=t.origin,u=e.unref(n.value),c=e.unref(r.value),m=[w.offset(t.offset),w.autoPlacement({alignment:t.align,allowedPlacements:t.position})];t.showArrow&&m.push(w.arrow({element:c})),t.shiftOffset!==void 0&&m.push(w.shift());const{x:f,y:v,placement:g,middlewareData:E}=await w.computePosition(s,u,{strategy:"fixed",middleware:m});let p=f,V=v;if(t.shiftOffset!==void 0){const{x:y,y:b}=E.shift;y<0&&(p-=t.shiftOffset),y>0&&(p+=t.shiftOffset),b<0&&(V-=t.shiftOffset),b>0&&(V+=t.shiftOffset)}o("positionChange",g),Object.assign(u.style,{top:`${V}px`,left:`${p}px`}),t.showArrow&&a(c,g,E.arrow,u)};return e.watch(()=>t.modelValue,()=>{t.modelValue&&t.origin?(l=Z(t.origin),e.nextTick(i),l==null||l.addEventListener("scroll",i),l!==window&&window.addEventListener("scroll",i),window.addEventListener("resize",i)):(l==null||l.removeEventListener("scroll",i),l!==window&&window.removeEventListener("scroll",i),window.removeEventListener("resize",i))}),e.onUnmounted(()=>{l==null||l.removeEventListener("scroll",i),l!==window&&window.removeEventListener("scroll",i),window.removeEventListener("resize",i)}),{arrowRef:r,overlayRef:n,updatePosition:i}}var me="";const k=e.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:W,emits:["update:modelValue","positionChange"],setup(t,{slots:o,attrs:n,emit:r,expose:l}){const a=N("flexible-overlay"),{clickEventBubble:i}=e.toRefs(t),{arrowRef:s,overlayRef:u,updatePosition:c}=te(t,r);return l({updatePosition:c}),()=>{var m;return t.modelValue&&e.createVNode("div",e.mergeProps({ref:u,class:a.b()},n,{onClick:e.withModifiers(()=>({}),[i.value?"":"stop"]),onPointerup:e.withModifiers(()=>({}),["stop"])}),[(m=o.default)==null?void 0:m.call(o),t.showArrow&&e.createVNode("div",{ref:s,class:a.e("arrow")},null)])}}}),oe=t=>t!==null&&typeof t=="object",ne=N("popper-trigger");function $(t){return e.h("span",{class:ne.b()},t)}function j(t){for(const o of t){if(oe(o)){if(o.type===e.Comment)continue;return o.type==="svg"||o.type===e.Text?$(o):o.type===e.Fragment?j(o.children):o}return $(o)}return null}var le=e.defineComponent({name:"DPopperTrigger",setup(t,o){const{slots:n,attrs:r}=o;return()=>{var s;const l=(s=n.default)==null?void 0:s.call(n,r),a=e.inject(R);if(!l)return null;const i=j(l);return i?e.withDirectives(e.cloneVNode(i,r),[[{mounted(u){a.value=u},updated(u){a.value=u},unmounted(){a.value=null}}]]):null}}}),pe="";let ae=1;var S=e.defineComponent({name:"DDropdown",inheritAttrs:!1,props:U,emits:["toggle"],setup(t,{slots:o,attrs:n,emit:r,expose:l}){const{visible:a,position:i,align:s,offset:u,destroyOnHide:c,shiftOffset:m,showAnimation:f}=e.toRefs(t),v=e.ref(),g=e.ref(),E=e.ref(),p=`dropdown_${ae++}`,V=e.ref(!1),y=e.ref("bottom"),b=N("dropdown");e.provide(R,v),I({id:p,isOpen:V,origin:v,dropdownRef:g,props:t,emit:r}),X(p,a,V,v,g,y,r);const{overlayModelValue:P,overlayShowValue:h,styles:x,classes:A,handlePositionChange:T}=G(t,y,V);return e.watch(h,C=>{e.nextTick(()=>{!c.value&&C&&E.value.updatePosition()})}),l({updatePosition:()=>E.value.updatePosition()}),()=>e.createVNode(e.Fragment,null,[e.createVNode(le,null,{default:()=>{var C;return[(C=o.default)==null?void 0:C.call(o)]}}),e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:f.value?b.m(`fade-${y.value}`):""},{default:()=>[e.withDirectives(e.createVNode(k,{modelValue:P.value,"onUpdate:modelValue":C=>P.value=C,ref:E,origin:v.value,position:i.value,align:s.value,offset:u.value,shiftOffset:m==null?void 0:m.value,onPositionChange:T,"click-event-bubble":!0,class:A.value,style:x.value},{default:()=>{var C;return[e.createVNode("div",e.mergeProps({ref:g,class:b.e("menu-wrap")},n),[(C=o.menu)==null?void 0:C.call(o)])]}}),[[e.vShow,h.value]])]})]})])}});const L={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 M=e.defineComponent({name:"DDropdownMenu",inheritAttrs:!1,props:L,emits:["update:modelValue"],setup(t,{slots:o,attrs:n,emit:r}){const{modelValue:l,origin:a,position:i,align:s,offset:u,clickOutside:c,showAnimation:m,overlayClass:f}=e.toRefs(t),v=e.ref(null),g=N("dropdown");z.onClickOutside(v,y=>{var b,P;((b=c.value)==null?void 0:b.call(c))&&!((P=a==null?void 0:a.value)==null?void 0:P.contains(y.target))&&r("update:modelValue",!1)});const E=e.ref("bottom"),p=y=>{E.value=y.split("-")[0]==="top"?"top":"bottom"},V=e.computed(()=>({transformOrigin:E.value==="top"?"0% 100%":"0% 0%"}));return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[e.createVNode(e.Transition,{name:m.value?g.m(`fade-${E.value}`):""},{default:()=>[e.createVNode(k,{modelValue:l.value,"onUpdate:modelValue":y=>l.value=y,origin:a==null?void 0:a.value,position:i.value,align:s.value,offset:u.value,onPositionChange:p,class:f.value,style:V.value},{default:()=>{var y;return[e.createVNode("div",e.mergeProps({ref:v,class:g.e("menu-wrap")},n),[(y=o.default)==null?void 0:y.call(o)])]}})]})]})}}),re={title:"Dropdown \u4E0B\u62C9\u83DC\u5355",category:"\u5BFC\u822A",status:"50%",install(t){t.component(S.name,S),t.component(M.name,M)}};d.Dropdown=S,d.DropdownMenu=M,d.default=re,d.dropdownMenuProps=L,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
|
package/dropdown/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
.devui-fixed-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background-color:var(--devui-shadow, rgba(37, 43, 58, .2));z-index:1050}.devui-fixed-overlay--fade-enter-active,.devui-fixed-overlay--fade-leave-active{transition:opacity .1s cubic-bezier(0,0,1,1)}.devui-fixed-overlay--fade-enter-from,.devui-fixed-overlay--fade-leave-to{opacity:0}.devui-flexible-overlay{position:fixed;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-connected-overlay-bg, #ffffff);box-shadow:var(--devui-shadow-length-connected-overlay, 0 4px 8px 0) var(--devui-shadow, rgba(37, 43, 58, .2));z-index:1000}.devui-flexible-overlay__arrow{position:absolute;width:8px;height:8px;transform:rotate(45deg);background-color:inherit}.devui-dropdown span.icon-chevron-down,.devui-dropdown span.icon-select-arrow{display:inline-block;vertical-align:text-top}.devui-dropdown__menu-wrap .devui-dropdown-menu{width:100%}.devui-dropdown-animation span.icon-chevron-down,.devui-dropdown-animation span.icon-select-arrow{transition:transform var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out-smooth, cubic-bezier(.645, .045, .355, 1))}.devui-dropdown.open span.icon-chevron-down,.devui-dropdown.open span.icon-select-arrow{transform:rotate(180deg)}.fade-in-top{animation:fadeInTop .2s cubic-bezier(.16,.75,.5,1)}.fade-in-bottom{animation:fadeInBottom .2s cubic-bezier(.16,.75,.5,1)}@keyframes fadeInTop{0%{opacity:.8;transform:scaleY(.8) translateY(4px)}to{opacity:1;transform:scaleY(.9999) translateY(0)}}@keyframes fadeInBottom{0%{opacity:.8;transform:scaleY(.8) translateY(-4px)}to{opacity:1;transform:scaleY(.9999) translateY(0)}}.devui-dropdown--fade-bottom-enter-from,.devui-dropdown--fade-bottom-leave-to{opacity:.8;transform:scaleY(.8) translateY(-4px)}.devui-dropdown--fade-bottom-enter-to,.devui-dropdown--fade-bottom-leave-from{opacity:1;transform:scaleY(.9999) translateY(0)}.devui-dropdown--fade-bottom-enter-active{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.devui-dropdown--fade-bottom-leave-active{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}.devui-dropdown--fade-top-enter-from,.devui-dropdown--fade-top-leave-to{opacity:.8;transform:scaleY(.8) translateY(4px)}.devui-dropdown--fade-top-enter-to,.devui-dropdown--fade-top-leave-from{opacity:1;transform:scaleY(.9999) translateY(0)}.devui-dropdown--fade-top-enter-active{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.devui-dropdown--fade-top-leave-active{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
|