vue-devui 1.0.0-beta.16 → 1.0.0-beta.19
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 +29 -21
- package/accordion/index.es.js +229 -14
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +28 -30
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +133 -271
- package/auto-complete/index.umd.js +1 -1
- package/auto-complete/style.css +1 -1
- package/back-top/index.es.js +5 -3
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +13 -19
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/breadcrumb/index.es.js +2 -1
- package/button/index.es.js +95 -122
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +38 -53
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5412 -784
- package/cascader/index.umd.js +27 -1
- package/cascader/style.css +1 -1
- package/checkbox/style.css +1 -1
- package/color-picker/index.es.js +5517 -281
- package/color-picker/index.umd.js +27 -1
- package/color-picker/style.css +1 -1
- package/countdown/index.es.js +9 -8
- package/date-picker/index.es.js +44 -62
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +159 -324
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +459 -301
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +293 -5724
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6125 -535
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +112 -133
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/gantt/index.es.js +3 -15
- package/gantt/index.umd.js +1 -1
- package/gantt/style.css +1 -1
- package/grid/index.es.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +39 -57
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +2 -1
- package/input/index.es.js +4 -5
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-icon/index.es.js +42 -42
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +46 -57
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/{time-axis → list}/index.d.ts +0 -0
- package/list/index.es.js +39 -0
- package/list/index.umd.js +1 -0
- package/{toast → list}/package.json +1 -1
- package/list/style.css +1 -0
- package/loading/index.es.js +2 -2
- package/modal/index.es.js +300 -960
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.es.js +1 -675
- package/nav-sprite/index.umd.js +1 -1
- package/{toast → notification}/index.d.ts +0 -0
- package/notification/index.es.js +284 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/List.js +3 -0
- package/nuxt/components/ListItem.js +3 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +2 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/overlay/index.es.js +152 -198
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +12 -60
- package/pagination/index.es.js +11 -13
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +48 -35
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5954 -201
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/quadrant-diagram/index.es.js +5405 -166
- package/quadrant-diagram/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +6 -3
- package/read-tip/style.css +1 -1
- package/result/index.es.js +38 -53
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +10 -6
- package/search/index.es.js +5428 -200
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +43 -43
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +17 -17
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +2 -1
- package/splitter/index.es.js +5815 -99
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/status/index.es.js +1 -4
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +6 -3
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +548 -360
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +3 -4
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +2 -1
- package/tag-input/index.es.js +4 -2
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-picker/index.es.js +98 -123
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/timeline/index.d.ts +7 -0
- package/{time-axis → timeline}/index.es.js +65 -78
- package/timeline/index.umd.js +1 -0
- package/{time-axis → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +5804 -94
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +5896 -404
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5439 -814
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +11 -7
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +335 -2213
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +9709 -12248
- package/vue-devui.umd.js +20 -20
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/Toast.js +0 -3
- package/nuxt/components/ToastService.js +0 -3
- package/time-axis/index.umd.js +0 -1
- package/time-axis/style.css +0 -1
- package/toast/index.es.js +0 -2063
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
package/table/index.es.js
CHANGED
|
@@ -21,7 +21,9 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide,
|
|
24
|
+
import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide, toRefs, onMounted, onUnmounted, Teleport, Transition, renderSlot, isVNode, unref, nextTick, Fragment, withDirectives, vShow, shallowRef, getCurrentInstance, createTextVNode, resolveDirective, reactive, onBeforeMount, h, onBeforeUnmount, render } from "vue";
|
|
25
|
+
import { shift, offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
26
|
+
import { onClickOutside } from "@vueuse/core";
|
|
25
27
|
const TableProps = {
|
|
26
28
|
data: {
|
|
27
29
|
type: Array,
|
|
@@ -155,7 +157,7 @@ const createColumnGenerator = () => {
|
|
|
155
157
|
const _columns = ref([]);
|
|
156
158
|
const insertColumn = (column) => {
|
|
157
159
|
_columns.value.push(column);
|
|
158
|
-
_columns.value.sort((a, b) => a.order
|
|
160
|
+
_columns.value.sort((a, b) => a.order - b.order);
|
|
159
161
|
};
|
|
160
162
|
const sortColumn = () => {
|
|
161
163
|
_columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
|
|
@@ -209,7 +211,7 @@ const createSelection = (dataSource, _data) => {
|
|
|
209
211
|
};
|
|
210
212
|
};
|
|
211
213
|
const createSorter = (dataSource, _data) => {
|
|
212
|
-
const sortData = (field, direction, compareFn = (
|
|
214
|
+
const sortData = (field, direction, compareFn = (fieldKey, a, b) => a[fieldKey] > b[fieldKey]) => {
|
|
213
215
|
if (direction === "ASC") {
|
|
214
216
|
_data.value = _data.value.sort((a, b) => compareFn(field, a, b) ? 1 : -1);
|
|
215
217
|
} else if (direction === "DESC") {
|
|
@@ -221,13 +223,13 @@ const createSorter = (dataSource, _data) => {
|
|
|
221
223
|
return { sortData };
|
|
222
224
|
};
|
|
223
225
|
const createFilter = (dataSource, _data) => {
|
|
224
|
-
const fieldSet = new Set();
|
|
226
|
+
const fieldSet = /* @__PURE__ */ new Set();
|
|
225
227
|
const filterData = (field, results) => {
|
|
226
228
|
fieldSet.add(field);
|
|
227
229
|
const fields = [...fieldSet];
|
|
228
230
|
_data.value = dataSource.value.filter((item) => {
|
|
229
|
-
return fields.reduce((prev,
|
|
230
|
-
return prev && results.indexOf(item[
|
|
231
|
+
return fields.reduce((prev, fieldKey) => {
|
|
232
|
+
return prev && results.indexOf(item[fieldKey]) !== -1;
|
|
231
233
|
}, true);
|
|
232
234
|
});
|
|
233
235
|
};
|
|
@@ -686,14 +688,7 @@ const Sort = defineComponent({
|
|
|
686
688
|
}
|
|
687
689
|
});
|
|
688
690
|
const dropdownProps = {
|
|
689
|
-
|
|
690
|
-
type: Object
|
|
691
|
-
},
|
|
692
|
-
isOpen: {
|
|
693
|
-
type: Boolean,
|
|
694
|
-
default: false
|
|
695
|
-
},
|
|
696
|
-
disabled: {
|
|
691
|
+
visible: {
|
|
697
692
|
type: Boolean,
|
|
698
693
|
default: false
|
|
699
694
|
},
|
|
@@ -705,6 +700,18 @@ const dropdownProps = {
|
|
|
705
700
|
type: String,
|
|
706
701
|
default: "all"
|
|
707
702
|
},
|
|
703
|
+
position: {
|
|
704
|
+
type: Array,
|
|
705
|
+
default: ["bottom"]
|
|
706
|
+
},
|
|
707
|
+
align: {
|
|
708
|
+
type: String,
|
|
709
|
+
default: null
|
|
710
|
+
},
|
|
711
|
+
offset: {
|
|
712
|
+
type: [Number, Object],
|
|
713
|
+
default: 4
|
|
714
|
+
},
|
|
708
715
|
closeOnMouseLeaveMenu: {
|
|
709
716
|
type: Boolean,
|
|
710
717
|
default: false
|
|
@@ -713,14 +720,15 @@ const dropdownProps = {
|
|
|
713
720
|
type: Boolean,
|
|
714
721
|
default: true
|
|
715
722
|
},
|
|
716
|
-
|
|
717
|
-
type:
|
|
718
|
-
default: "
|
|
723
|
+
overlayClass: {
|
|
724
|
+
type: String,
|
|
725
|
+
default: ""
|
|
726
|
+
},
|
|
727
|
+
destroyOnHide: {
|
|
728
|
+
type: Boolean,
|
|
729
|
+
default: true
|
|
719
730
|
}
|
|
720
731
|
};
|
|
721
|
-
function isComponent(target) {
|
|
722
|
-
return !!(target == null ? void 0 : target.$el);
|
|
723
|
-
}
|
|
724
732
|
function getElement(element) {
|
|
725
733
|
if (element instanceof Element) {
|
|
726
734
|
return element;
|
|
@@ -730,85 +738,158 @@ function getElement(element) {
|
|
|
730
738
|
}
|
|
731
739
|
return null;
|
|
732
740
|
}
|
|
741
|
+
const dropdownMap = /* @__PURE__ */ new Map();
|
|
733
742
|
function subscribeEvent(dom, type, callback) {
|
|
734
743
|
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
735
744
|
return () => {
|
|
736
745
|
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
737
746
|
};
|
|
738
747
|
}
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
const dropdownElRef = ref();
|
|
747
|
-
const closeByScope = () => {
|
|
748
|
-
if (closeScope.value === "none") {
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
visible.value = false;
|
|
748
|
+
const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
749
|
+
let overlayEnter = false;
|
|
750
|
+
let originEnter = false;
|
|
751
|
+
const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
|
|
752
|
+
const toggle = (status) => {
|
|
753
|
+
isOpen.value = status;
|
|
754
|
+
emit("toggle", isOpen.value);
|
|
752
755
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if (
|
|
756
|
+
const handleLeave = async (elementType, closeAll) => {
|
|
757
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
758
|
+
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
756
759
|
return;
|
|
757
760
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
761
|
+
if (closeAll) {
|
|
762
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
763
|
+
setTimeout(() => {
|
|
764
|
+
var _a;
|
|
765
|
+
(_a = item.toggle) == null ? void 0 : _a.call(item);
|
|
766
|
+
}, 0);
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
toggle(false);
|
|
770
|
+
};
|
|
771
|
+
watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
|
|
772
|
+
const originEl = getElement(originVal);
|
|
773
|
+
const subscriptions = [];
|
|
774
|
+
setTimeout(() => {
|
|
775
|
+
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
776
|
+
const dropdownValues = [...dropdownMap.values()];
|
|
777
|
+
if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
778
|
+
var _a;
|
|
779
|
+
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
780
|
+
}) && dropdownValues.some((item) => {
|
|
781
|
+
var _a;
|
|
782
|
+
return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
|
|
783
|
+
})) {
|
|
773
784
|
return;
|
|
774
785
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
786
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
787
|
+
setTimeout(() => {
|
|
788
|
+
var _a, _b;
|
|
789
|
+
if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
|
|
790
|
+
(_b = item.toggle) == null ? void 0 : _b.call(item);
|
|
791
|
+
}
|
|
792
|
+
}, 0);
|
|
793
|
+
});
|
|
794
|
+
overlayEnter = false;
|
|
780
795
|
}));
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
return;
|
|
796
|
+
}, 0);
|
|
797
|
+
if (triggerVal === "click") {
|
|
798
|
+
subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
799
|
+
var _a;
|
|
800
|
+
if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
801
|
+
handleLeave("dropdown", true);
|
|
788
802
|
}
|
|
789
|
-
|
|
790
|
-
|
|
803
|
+
}));
|
|
804
|
+
} else if (triggerVal === "hover") {
|
|
791
805
|
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
792
806
|
originEnter = true;
|
|
793
|
-
|
|
807
|
+
toggle(true);
|
|
794
808
|
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
795
809
|
originEnter = false;
|
|
796
|
-
|
|
797
|
-
handleLeave("origin");
|
|
798
|
-
}
|
|
810
|
+
handleLeave("origin");
|
|
799
811
|
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
800
812
|
overlayEnter = true;
|
|
801
|
-
|
|
802
|
-
}), subscribeEvent(dropdownEl, "mouseleave", () => {
|
|
813
|
+
isOpen.value = true;
|
|
814
|
+
}), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
815
|
+
var _a;
|
|
803
816
|
overlayEnter = false;
|
|
804
|
-
|
|
817
|
+
if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
handleLeave("dropdown", true);
|
|
805
821
|
}));
|
|
806
822
|
}
|
|
807
823
|
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
808
824
|
});
|
|
809
|
-
return { dropdownEl: dropdownElRef };
|
|
810
825
|
};
|
|
811
|
-
|
|
826
|
+
function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
|
|
827
|
+
const calcPopDirection = (dropdownEl) => {
|
|
828
|
+
const elementHeight = dropdownEl.offsetHeight;
|
|
829
|
+
const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
|
|
830
|
+
const isBottomEnough = bottomDistance >= elementHeight;
|
|
831
|
+
if (!isBottomEnough) {
|
|
832
|
+
popDirection.value = "top";
|
|
833
|
+
} else {
|
|
834
|
+
popDirection.value = "bottom";
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
watch(visible, (newVal, oldVal) => {
|
|
838
|
+
if (oldVal === void 0) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
isOpen.value = newVal;
|
|
842
|
+
emit("toggle", isOpen.value);
|
|
843
|
+
}, { immediate: true });
|
|
844
|
+
watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
|
|
845
|
+
var _a;
|
|
846
|
+
if (isOpenVal) {
|
|
847
|
+
dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
|
|
848
|
+
menuEl: dropdownEl,
|
|
849
|
+
toggle: () => {
|
|
850
|
+
isOpen.value = false;
|
|
851
|
+
emit("toggle", isOpen.value);
|
|
852
|
+
}
|
|
853
|
+
}));
|
|
854
|
+
for (const value of dropdownMap.values()) {
|
|
855
|
+
if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
|
|
856
|
+
value.child = dropdownEl;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (dropdownEl) {
|
|
861
|
+
calcPopDirection(dropdownEl);
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
onMounted(() => {
|
|
865
|
+
dropdownMap.set(id, { toggleEl: origin.value });
|
|
866
|
+
});
|
|
867
|
+
onUnmounted(() => {
|
|
868
|
+
dropdownMap.delete(id);
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
function useOverlayProps(props, currentPosition, isOpen) {
|
|
872
|
+
const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
|
|
873
|
+
const overlayModelValue = ref(false);
|
|
874
|
+
const overlayShowValue = ref(false);
|
|
875
|
+
const styles = computed(() => ({
|
|
876
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
877
|
+
}));
|
|
878
|
+
const classes = computed(() => ({
|
|
879
|
+
"fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
|
|
880
|
+
"fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
|
|
881
|
+
[`${overlayClass.value}`]: true
|
|
882
|
+
}));
|
|
883
|
+
const handlePositionChange = (pos) => {
|
|
884
|
+
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
885
|
+
};
|
|
886
|
+
watch(isOpen, (isOpenVal) => {
|
|
887
|
+
overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
|
|
888
|
+
overlayShowValue.value = isOpenVal;
|
|
889
|
+
});
|
|
890
|
+
return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
|
|
891
|
+
}
|
|
892
|
+
var baseOverlay = "";
|
|
812
893
|
function _isSlot(s) {
|
|
813
894
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
814
895
|
}
|
|
@@ -855,28 +936,13 @@ const overlayProps = {
|
|
|
855
936
|
default: true
|
|
856
937
|
}
|
|
857
938
|
};
|
|
858
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
859
939
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
860
940
|
overlayStyle: {
|
|
861
941
|
type: [String, Object],
|
|
862
942
|
default: void 0
|
|
863
943
|
}
|
|
864
944
|
});
|
|
865
|
-
const
|
|
866
|
-
origin: {
|
|
867
|
-
type: Object,
|
|
868
|
-
require: true
|
|
869
|
-
},
|
|
870
|
-
position: {
|
|
871
|
-
type: Object,
|
|
872
|
-
default: () => ({
|
|
873
|
-
originX: "left",
|
|
874
|
-
originY: "top",
|
|
875
|
-
overlayX: "left",
|
|
876
|
-
overlayY: "top"
|
|
877
|
-
})
|
|
878
|
-
}
|
|
879
|
-
}, overlayProps);
|
|
945
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
880
946
|
function useOverlayLogic(props, ctx) {
|
|
881
947
|
const backgroundClass = computed(() => {
|
|
882
948
|
return [
|
|
@@ -927,7 +993,8 @@ function useOverlayLogic(props, ctx) {
|
|
|
927
993
|
handleOverlayBubbleCancel
|
|
928
994
|
};
|
|
929
995
|
}
|
|
930
|
-
|
|
996
|
+
var fixedOverlay = "";
|
|
997
|
+
defineComponent({
|
|
931
998
|
name: "DFixedOverlay",
|
|
932
999
|
props: fixedOverlayProps,
|
|
933
1000
|
emits: overlayEmits,
|
|
@@ -939,7 +1006,7 @@ const FixedOverlay = defineComponent({
|
|
|
939
1006
|
handleOverlayBubbleCancel
|
|
940
1007
|
} = useOverlayLogic(props, ctx);
|
|
941
1008
|
return () => createVNode(CommonOverlay, null, {
|
|
942
|
-
default: () => [
|
|
1009
|
+
default: () => [props.visible && createVNode("div", {
|
|
943
1010
|
"class": backgroundClass.value,
|
|
944
1011
|
"style": props.backgroundStyle,
|
|
945
1012
|
"onClick": handleBackdropClick
|
|
@@ -947,250 +1014,340 @@ const FixedOverlay = defineComponent({
|
|
|
947
1014
|
"class": overlayClass.value,
|
|
948
1015
|
"style": props.overlayStyle,
|
|
949
1016
|
"onClick": handleOverlayBubbleCancel
|
|
950
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
1017
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
951
1018
|
});
|
|
952
1019
|
}
|
|
953
1020
|
});
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
983
|
-
if (!visible || !locationElements2) {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
const {
|
|
987
|
-
origin,
|
|
988
|
-
overlay: overlay2
|
|
989
|
-
} = locationElements2;
|
|
990
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
991
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
992
|
-
onInvalidate(() => {
|
|
993
|
-
unsubscriptions.forEach((fn) => fn());
|
|
994
|
-
});
|
|
995
|
-
});
|
|
996
|
-
});
|
|
997
|
-
const {
|
|
998
|
-
backgroundClass,
|
|
999
|
-
overlayClass,
|
|
1000
|
-
handleBackdropClick,
|
|
1001
|
-
handleOverlayBubbleCancel
|
|
1002
|
-
} = useOverlayLogic(props, ctx);
|
|
1003
|
-
return () => createVNode(CommonOverlay, null, {
|
|
1004
|
-
default: () => [withDirectives(createVNode("div", {
|
|
1005
|
-
"style": props.backgroundStyle,
|
|
1006
|
-
"class": backgroundClass.value,
|
|
1007
|
-
"onClick": handleBackdropClick
|
|
1008
|
-
}, [createVNode("div", {
|
|
1009
|
-
"ref": overlayRef,
|
|
1010
|
-
"class": overlayClass.value,
|
|
1011
|
-
"style": positionedStyle,
|
|
1012
|
-
"onClick": handleOverlayBubbleCancel
|
|
1013
|
-
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
function getOrigin(origin) {
|
|
1018
|
-
if (origin instanceof Element) {
|
|
1019
|
-
return origin;
|
|
1020
|
-
}
|
|
1021
|
-
if (isRef(origin)) {
|
|
1022
|
-
return getElement(origin.value);
|
|
1023
|
-
}
|
|
1024
|
-
if (isComponent(origin)) {
|
|
1025
|
-
return getElement(origin);
|
|
1021
|
+
const flexibleOverlayProps = {
|
|
1022
|
+
modelValue: {
|
|
1023
|
+
type: Boolean,
|
|
1024
|
+
default: false
|
|
1025
|
+
},
|
|
1026
|
+
origin: {
|
|
1027
|
+
type: Object,
|
|
1028
|
+
require: true
|
|
1029
|
+
},
|
|
1030
|
+
position: {
|
|
1031
|
+
type: Array,
|
|
1032
|
+
default: ["bottom"]
|
|
1033
|
+
},
|
|
1034
|
+
offset: {
|
|
1035
|
+
type: [Number, Object],
|
|
1036
|
+
default: 8
|
|
1037
|
+
},
|
|
1038
|
+
align: {
|
|
1039
|
+
type: String,
|
|
1040
|
+
default: null
|
|
1041
|
+
},
|
|
1042
|
+
showArrow: {
|
|
1043
|
+
type: Boolean,
|
|
1044
|
+
default: false
|
|
1045
|
+
},
|
|
1046
|
+
isArrowCenter: {
|
|
1047
|
+
type: Boolean,
|
|
1048
|
+
default: true
|
|
1026
1049
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
if (origin instanceof Element) {
|
|
1036
|
-
return origin.getBoundingClientRect();
|
|
1050
|
+
};
|
|
1051
|
+
function getScrollParent(element) {
|
|
1052
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
1053
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
1054
|
+
const style = window.getComputedStyle(parent);
|
|
1055
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
1056
|
+
return parent;
|
|
1057
|
+
}
|
|
1037
1058
|
}
|
|
1038
|
-
|
|
1039
|
-
const height = origin.height || 0;
|
|
1040
|
-
return {
|
|
1041
|
-
top: origin.y,
|
|
1042
|
-
bottom: origin.y + height,
|
|
1043
|
-
left: origin.x,
|
|
1044
|
-
right: origin.x + width,
|
|
1045
|
-
height,
|
|
1046
|
-
width
|
|
1047
|
-
};
|
|
1059
|
+
return window;
|
|
1048
1060
|
}
|
|
1049
|
-
function
|
|
1050
|
-
let x;
|
|
1051
|
-
|
|
1052
|
-
width,
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
x
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
y
|
|
1063
|
-
|
|
1064
|
-
|
|
1061
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
1062
|
+
let { x, y } = point;
|
|
1063
|
+
if (!isArrowCenter) {
|
|
1064
|
+
const { width, height } = originRect;
|
|
1065
|
+
if (x && placement.includes("start")) {
|
|
1066
|
+
x = 12;
|
|
1067
|
+
}
|
|
1068
|
+
if (x && placement.includes("end")) {
|
|
1069
|
+
x = Math.round(width - 24);
|
|
1070
|
+
}
|
|
1071
|
+
if (y && placement.includes("start")) {
|
|
1072
|
+
y = 10;
|
|
1073
|
+
}
|
|
1074
|
+
if (y && placement.includes("end")) {
|
|
1075
|
+
y = height - 14;
|
|
1076
|
+
}
|
|
1065
1077
|
}
|
|
1066
|
-
return {
|
|
1067
|
-
x,
|
|
1068
|
-
y
|
|
1069
|
-
};
|
|
1078
|
+
return { x, y };
|
|
1070
1079
|
}
|
|
1071
|
-
function
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
};
|
|
1090
|
-
}
|
|
1091
|
-
function subscribeLayoutEvent(event) {
|
|
1092
|
-
window.addEventListener("scroll", event, true);
|
|
1093
|
-
window.addEventListener("resize", event);
|
|
1094
|
-
window.addEventListener("orientationchange", event);
|
|
1095
|
-
return () => {
|
|
1096
|
-
window.removeEventListener("scroll", event, true);
|
|
1097
|
-
window.removeEventListener("resize", event);
|
|
1098
|
-
window.removeEventListener("orientationchange", event);
|
|
1080
|
+
function useOverlay(props, emit) {
|
|
1081
|
+
const overlayRef = ref();
|
|
1082
|
+
const arrowRef = ref();
|
|
1083
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
1084
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
1085
|
+
const staticSide = {
|
|
1086
|
+
top: "bottom",
|
|
1087
|
+
right: "left",
|
|
1088
|
+
bottom: "top",
|
|
1089
|
+
left: "right"
|
|
1090
|
+
}[placement.split("-")[0]];
|
|
1091
|
+
Object.assign(arrowEl.style, {
|
|
1092
|
+
left: x ? `${x}px` : "",
|
|
1093
|
+
top: y ? `${y}px` : "",
|
|
1094
|
+
right: "",
|
|
1095
|
+
bottom: "",
|
|
1096
|
+
[staticSide]: "-4px"
|
|
1097
|
+
});
|
|
1099
1098
|
};
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1099
|
+
const updatePosition = async () => {
|
|
1100
|
+
const hostEl = props.origin;
|
|
1101
|
+
const overlayEl = unref(overlayRef.value);
|
|
1102
|
+
const arrowEl = unref(arrowRef.value);
|
|
1103
|
+
const middleware = [
|
|
1104
|
+
shift(),
|
|
1105
|
+
offset(props.offset),
|
|
1106
|
+
autoPlacement({
|
|
1107
|
+
alignment: props.align,
|
|
1108
|
+
allowedPlacements: props.position
|
|
1109
|
+
})
|
|
1110
|
+
];
|
|
1111
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
1112
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
1113
|
+
strategy: "fixed",
|
|
1114
|
+
middleware
|
|
1115
|
+
});
|
|
1116
|
+
emit("positionChange", placement);
|
|
1117
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
1118
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
1108
1119
|
};
|
|
1120
|
+
watch(() => props.modelValue, () => {
|
|
1121
|
+
const originParent = getScrollParent(props.origin);
|
|
1122
|
+
if (props.modelValue && props.origin) {
|
|
1123
|
+
nextTick(updatePosition);
|
|
1124
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
1125
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
1126
|
+
window.addEventListener("resize", updatePosition);
|
|
1127
|
+
} else {
|
|
1128
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
1129
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
1130
|
+
window.removeEventListener("resize", updatePosition);
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
onUnmounted(() => {
|
|
1134
|
+
const originParent = getScrollParent(props.origin);
|
|
1135
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
1136
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
1137
|
+
window.removeEventListener("resize", updatePosition);
|
|
1138
|
+
});
|
|
1139
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
1109
1140
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1141
|
+
var flexibleOverlay = "";
|
|
1142
|
+
const FlexibleOverlay = defineComponent({
|
|
1143
|
+
name: "DFlexibleOverlay",
|
|
1144
|
+
inheritAttrs: false,
|
|
1145
|
+
props: flexibleOverlayProps,
|
|
1146
|
+
emits: ["update:modelValue", "positionChange"],
|
|
1147
|
+
setup(props, {
|
|
1148
|
+
slots,
|
|
1149
|
+
attrs,
|
|
1150
|
+
emit,
|
|
1151
|
+
expose
|
|
1152
|
+
}) {
|
|
1153
|
+
const {
|
|
1154
|
+
arrowRef,
|
|
1155
|
+
overlayRef,
|
|
1156
|
+
updatePosition
|
|
1157
|
+
} = useOverlay(props, emit);
|
|
1158
|
+
expose({
|
|
1159
|
+
updatePosition
|
|
1115
1160
|
});
|
|
1116
|
-
return () =>
|
|
1161
|
+
return () => {
|
|
1162
|
+
var _a;
|
|
1163
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
1164
|
+
"ref": overlayRef,
|
|
1165
|
+
"class": "devui-flexible-overlay"
|
|
1166
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
1167
|
+
"ref": arrowRef,
|
|
1168
|
+
"class": "devui-flexible-overlay-arrow"
|
|
1169
|
+
}, null)]);
|
|
1170
|
+
};
|
|
1117
1171
|
}
|
|
1118
|
-
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
FlexibleOverlay.install = function(app) {
|
|
1122
|
-
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
1123
|
-
};
|
|
1124
|
-
FixedOverlay.install = function(app) {
|
|
1125
|
-
app.component(FixedOverlay.name, FixedOverlay);
|
|
1126
|
-
};
|
|
1172
|
+
});
|
|
1127
1173
|
var dropdown = "";
|
|
1174
|
+
let dropdownId = 1;
|
|
1128
1175
|
var Dropdown = defineComponent({
|
|
1129
1176
|
name: "DDropdown",
|
|
1177
|
+
inheritAttrs: false,
|
|
1130
1178
|
props: dropdownProps,
|
|
1131
|
-
emits: [],
|
|
1132
|
-
setup(props,
|
|
1179
|
+
emits: ["toggle"],
|
|
1180
|
+
setup(props, {
|
|
1181
|
+
slots,
|
|
1182
|
+
attrs,
|
|
1183
|
+
emit,
|
|
1184
|
+
expose
|
|
1185
|
+
}) {
|
|
1133
1186
|
const {
|
|
1187
|
+
visible,
|
|
1188
|
+
position,
|
|
1189
|
+
align,
|
|
1190
|
+
offset: offset2,
|
|
1191
|
+
showAnimation
|
|
1192
|
+
} = toRefs(props);
|
|
1193
|
+
const origin = ref();
|
|
1194
|
+
const dropdownRef = ref();
|
|
1195
|
+
const overlayRef = ref();
|
|
1196
|
+
const id = `dropdown_${dropdownId++}`;
|
|
1197
|
+
const isOpen = ref(false);
|
|
1198
|
+
const currentPosition = ref("bottom");
|
|
1199
|
+
useDropdownEvent({
|
|
1200
|
+
id,
|
|
1134
1201
|
isOpen,
|
|
1135
1202
|
origin,
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1203
|
+
dropdownRef,
|
|
1204
|
+
props,
|
|
1205
|
+
emit
|
|
1206
|
+
});
|
|
1207
|
+
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
1208
|
+
const {
|
|
1209
|
+
overlayModelValue,
|
|
1210
|
+
overlayShowValue,
|
|
1211
|
+
styles,
|
|
1212
|
+
classes,
|
|
1213
|
+
handlePositionChange
|
|
1214
|
+
} = useOverlayProps(props, currentPosition, isOpen);
|
|
1215
|
+
expose({
|
|
1216
|
+
updatePosition: () => overlayRef.value.updatePosition()
|
|
1145
1217
|
});
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1218
|
+
return () => {
|
|
1219
|
+
var _a;
|
|
1220
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
1221
|
+
"ref": origin,
|
|
1222
|
+
"class": "devui-dropdown-toggle"
|
|
1223
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
1224
|
+
"to": "body"
|
|
1225
|
+
}, {
|
|
1226
|
+
default: () => [createVNode(Transition, {
|
|
1227
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
1228
|
+
}, {
|
|
1229
|
+
default: () => [withDirectives(createVNode(FlexibleOverlay, {
|
|
1230
|
+
"modelValue": overlayModelValue.value,
|
|
1231
|
+
"onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
|
|
1232
|
+
"ref": overlayRef,
|
|
1233
|
+
"origin": origin.value,
|
|
1234
|
+
"position": position.value,
|
|
1235
|
+
"align": align.value,
|
|
1236
|
+
"offset": offset2.value,
|
|
1237
|
+
"onPositionChange": handlePositionChange,
|
|
1238
|
+
"class": classes.value,
|
|
1239
|
+
"style": styles.value
|
|
1240
|
+
}, {
|
|
1241
|
+
default: () => {
|
|
1242
|
+
var _a2;
|
|
1243
|
+
return [createVNode("div", mergeProps({
|
|
1244
|
+
"ref": dropdownRef,
|
|
1245
|
+
"class": "devui-dropdown-menu-wrap"
|
|
1246
|
+
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
1247
|
+
}
|
|
1248
|
+
}), [[vShow, overlayShowValue.value]])]
|
|
1249
|
+
})]
|
|
1250
|
+
})]);
|
|
1151
1251
|
};
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
const dropdownMenuProps = {
|
|
1255
|
+
modelValue: {
|
|
1256
|
+
type: Boolean,
|
|
1257
|
+
default: false
|
|
1258
|
+
},
|
|
1259
|
+
origin: {
|
|
1260
|
+
type: Object,
|
|
1261
|
+
require: true
|
|
1262
|
+
},
|
|
1263
|
+
position: {
|
|
1264
|
+
type: Array,
|
|
1265
|
+
default: ["bottom"]
|
|
1266
|
+
},
|
|
1267
|
+
align: {
|
|
1268
|
+
type: String,
|
|
1269
|
+
default: null
|
|
1270
|
+
},
|
|
1271
|
+
offset: {
|
|
1272
|
+
type: [Number, Object],
|
|
1273
|
+
default: 4
|
|
1274
|
+
},
|
|
1275
|
+
clickOutside: {
|
|
1276
|
+
type: Function,
|
|
1277
|
+
default: () => true
|
|
1278
|
+
},
|
|
1279
|
+
showAnimation: {
|
|
1280
|
+
type: Boolean,
|
|
1281
|
+
default: true
|
|
1282
|
+
},
|
|
1283
|
+
overlayClass: {
|
|
1284
|
+
type: String,
|
|
1285
|
+
default: ""
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
defineComponent({
|
|
1289
|
+
name: "DDropdownMenu",
|
|
1290
|
+
inheritAttrs: false,
|
|
1291
|
+
props: dropdownMenuProps,
|
|
1292
|
+
emits: ["update:modelValue"],
|
|
1293
|
+
setup(props, {
|
|
1294
|
+
slots,
|
|
1295
|
+
attrs,
|
|
1296
|
+
emit
|
|
1297
|
+
}) {
|
|
1152
1298
|
const {
|
|
1153
|
-
|
|
1154
|
-
} = useDropdown({
|
|
1155
|
-
visible,
|
|
1299
|
+
modelValue,
|
|
1156
1300
|
origin,
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
});
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1301
|
+
position,
|
|
1302
|
+
align,
|
|
1303
|
+
offset: offset2,
|
|
1304
|
+
clickOutside,
|
|
1305
|
+
showAnimation,
|
|
1306
|
+
overlayClass
|
|
1307
|
+
} = toRefs(props);
|
|
1308
|
+
const dropdownMenuRef = ref(null);
|
|
1309
|
+
onClickOutside(dropdownMenuRef, (value) => {
|
|
1310
|
+
var _a, _b;
|
|
1311
|
+
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
|
|
1312
|
+
emit("update:modelValue", false);
|
|
1313
|
+
}
|
|
1168
1314
|
});
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
"
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
"
|
|
1315
|
+
const currentPosition = ref("bottom");
|
|
1316
|
+
const handlePositionChange = (pos) => {
|
|
1317
|
+
currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
|
|
1318
|
+
};
|
|
1319
|
+
const styles = computed(() => ({
|
|
1320
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
1321
|
+
}));
|
|
1322
|
+
return () => createVNode(Teleport, {
|
|
1323
|
+
"to": "body"
|
|
1175
1324
|
}, {
|
|
1176
1325
|
default: () => [createVNode(Transition, {
|
|
1177
|
-
"name":
|
|
1326
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
1178
1327
|
}, {
|
|
1179
|
-
default: () => {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1328
|
+
default: () => [createVNode(FlexibleOverlay, {
|
|
1329
|
+
"modelValue": modelValue.value,
|
|
1330
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
1331
|
+
"origin": origin == null ? void 0 : origin.value,
|
|
1332
|
+
"position": position.value,
|
|
1333
|
+
"align": align.value,
|
|
1334
|
+
"offset": offset2.value,
|
|
1335
|
+
"onPositionChange": handlePositionChange,
|
|
1336
|
+
"class": overlayClass.value,
|
|
1337
|
+
"style": styles.value
|
|
1338
|
+
}, {
|
|
1339
|
+
default: () => {
|
|
1340
|
+
var _a;
|
|
1341
|
+
return [createVNode("div", mergeProps({
|
|
1342
|
+
"ref": dropdownMenuRef,
|
|
1343
|
+
"class": "devui-dropdown-menu-wrap"
|
|
1344
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
1345
|
+
}
|
|
1346
|
+
})]
|
|
1187
1347
|
})]
|
|
1188
1348
|
});
|
|
1189
1349
|
}
|
|
1190
1350
|
});
|
|
1191
|
-
Dropdown.install = function(app) {
|
|
1192
|
-
app.component(Dropdown.name, Dropdown);
|
|
1193
|
-
};
|
|
1194
1351
|
var filter = "";
|
|
1195
1352
|
const Filter = defineComponent({
|
|
1196
1353
|
props: {
|
|
@@ -1424,48 +1581,74 @@ const TD = defineComponent({
|
|
|
1424
1581
|
}, [column.value.renderCell(props.row, props.index)]);
|
|
1425
1582
|
}
|
|
1426
1583
|
});
|
|
1427
|
-
var
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
} = useTable(props);
|
|
1440
|
-
const isEmpty2 = computed(() => props.data.length === 0);
|
|
1441
|
-
const fixHeaderCompo = computed(() => {
|
|
1584
|
+
var FixHeader = defineComponent({
|
|
1585
|
+
props: {
|
|
1586
|
+
classes: {
|
|
1587
|
+
type: Object,
|
|
1588
|
+
default: () => ({})
|
|
1589
|
+
},
|
|
1590
|
+
isEmpty: {
|
|
1591
|
+
type: Boolean
|
|
1592
|
+
}
|
|
1593
|
+
},
|
|
1594
|
+
setup(props) {
|
|
1595
|
+
return () => {
|
|
1442
1596
|
return createVNode("div", {
|
|
1443
1597
|
"class": "devui-table-view"
|
|
1444
1598
|
}, [createVNode("div", {
|
|
1445
|
-
"style": "overflow:
|
|
1599
|
+
"style": "overflow:hidden scroll;"
|
|
1446
1600
|
}, [createVNode("table", {
|
|
1447
|
-
"class": classes
|
|
1601
|
+
"class": props.classes,
|
|
1448
1602
|
"cellpadding": "0",
|
|
1449
1603
|
"cellspacing": "0"
|
|
1450
1604
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
|
|
1451
1605
|
"class": "scroll-view"
|
|
1452
1606
|
}, [createVNode("table", {
|
|
1453
|
-
"class": classes
|
|
1607
|
+
"class": props.classes,
|
|
1454
1608
|
"cellpadding": "0",
|
|
1455
1609
|
"cellspacing": "0"
|
|
1456
|
-
}, [createVNode(ColGroup, null, null), !
|
|
1610
|
+
}, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
|
|
1457
1611
|
"style": "flex: 1"
|
|
1458
1612
|
}, null)])])]);
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
var NormalHeader = defineComponent({
|
|
1617
|
+
props: {
|
|
1618
|
+
classes: {
|
|
1619
|
+
type: Object,
|
|
1620
|
+
default: () => ({})
|
|
1621
|
+
},
|
|
1622
|
+
isEmpty: {
|
|
1623
|
+
type: Boolean
|
|
1624
|
+
}
|
|
1625
|
+
},
|
|
1626
|
+
setup(props) {
|
|
1627
|
+
return () => {
|
|
1461
1628
|
return createVNode("table", {
|
|
1462
|
-
"class": classes
|
|
1629
|
+
"class": props.classes,
|
|
1463
1630
|
"cellpadding": "0",
|
|
1464
1631
|
"cellspacing": "0"
|
|
1465
1632
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
|
|
1466
|
-
"style": "position:
|
|
1467
|
-
}, null), !
|
|
1468
|
-
}
|
|
1633
|
+
"style": "position:relative"
|
|
1634
|
+
}, null), !props.isEmpty && createVNode(TableBody, null, null)]);
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
var table = "";
|
|
1639
|
+
var Table = defineComponent({
|
|
1640
|
+
name: "DTable",
|
|
1641
|
+
props: TableProps,
|
|
1642
|
+
setup(props, ctx) {
|
|
1643
|
+
const table2 = getCurrentInstance();
|
|
1644
|
+
const store = createStore(toRef(props, "data"));
|
|
1645
|
+
table2.store = store;
|
|
1646
|
+
provide(TABLE_TOKEN, table2);
|
|
1647
|
+
const {
|
|
1648
|
+
classes,
|
|
1649
|
+
style
|
|
1650
|
+
} = useTable(props);
|
|
1651
|
+
const isEmpty2 = computed(() => props.data.length === 0);
|
|
1469
1652
|
ctx.expose({
|
|
1470
1653
|
getCheckedRows() {
|
|
1471
1654
|
return store.getCheckedRows();
|
|
@@ -1474,7 +1657,13 @@ var Table = defineComponent({
|
|
|
1474
1657
|
return () => withDirectives(createVNode("div", {
|
|
1475
1658
|
"class": "devui-table-wrapper",
|
|
1476
1659
|
"style": style.value
|
|
1477
|
-
}, [ctx.slots.default(), props.fixHeader ?
|
|
1660
|
+
}, [ctx.slots.default(), props.fixHeader ? createVNode(FixHeader, {
|
|
1661
|
+
"classes": classes.value,
|
|
1662
|
+
"is-empty": isEmpty2.value
|
|
1663
|
+
}, null) : createVNode(NormalHeader, {
|
|
1664
|
+
"classes": classes.value,
|
|
1665
|
+
"is-empty": isEmpty2.value
|
|
1666
|
+
}, null), isEmpty2.value && createVNode("div", {
|
|
1478
1667
|
"class": "devui-table-empty"
|
|
1479
1668
|
}, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
|
|
1480
1669
|
}
|
|
@@ -1539,6 +1728,9 @@ function formatWidth(width) {
|
|
|
1539
1728
|
function formatMinWidth(minWidth) {
|
|
1540
1729
|
return formatWidth(minWidth) || 80;
|
|
1541
1730
|
}
|
|
1731
|
+
function defaultRenderHeader() {
|
|
1732
|
+
return h("span", { class: "title" }, this.header);
|
|
1733
|
+
}
|
|
1542
1734
|
function createColumn(props, templates) {
|
|
1543
1735
|
const {
|
|
1544
1736
|
field,
|
|
@@ -1556,31 +1748,38 @@ function createColumn(props, templates) {
|
|
|
1556
1748
|
fixedRight
|
|
1557
1749
|
} = props;
|
|
1558
1750
|
const column = reactive({});
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1751
|
+
function defaultRenderCell(rowData, index2) {
|
|
1752
|
+
var _a, _b;
|
|
1753
|
+
const value = rowData[this.field];
|
|
1754
|
+
if (templates.default) {
|
|
1755
|
+
return templates.default(rowData);
|
|
1756
|
+
}
|
|
1757
|
+
if (this.formatter) {
|
|
1758
|
+
return this.formatter(rowData, value, index2);
|
|
1759
|
+
}
|
|
1760
|
+
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1761
|
+
}
|
|
1762
|
+
watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
|
|
1763
|
+
column.field = fieldVal;
|
|
1764
|
+
column.header = headerVal;
|
|
1765
|
+
column.order = orderVal;
|
|
1563
1766
|
}, { immediate: true });
|
|
1564
|
-
watch([sortable, compareFn], ([
|
|
1565
|
-
column.sortable =
|
|
1566
|
-
column.compareFn =
|
|
1767
|
+
watch([sortable, compareFn], ([sortableVal, compareFnVal]) => {
|
|
1768
|
+
column.sortable = sortableVal;
|
|
1769
|
+
column.compareFn = compareFnVal;
|
|
1567
1770
|
});
|
|
1568
|
-
watch([
|
|
1569
|
-
filterable
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
], ([filterable2, filterList2, filterMultiple2]) => {
|
|
1573
|
-
column.filterable = filterable2;
|
|
1574
|
-
column.filterMultiple = filterMultiple2;
|
|
1575
|
-
column.filterList = filterList2;
|
|
1771
|
+
watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
|
|
1772
|
+
column.filterable = filterableVal;
|
|
1773
|
+
column.filterMultiple = filterMultipleVal;
|
|
1774
|
+
column.filterList = filterListVal;
|
|
1576
1775
|
}, { immediate: true });
|
|
1577
1776
|
watch([fixedLeft, fixedRight], ([left, right]) => {
|
|
1578
1777
|
column.fixedLeft = left;
|
|
1579
1778
|
column.fixedRight = right;
|
|
1580
1779
|
}, { immediate: true });
|
|
1581
|
-
watch([width, minWidth], ([
|
|
1582
|
-
column.width = formatWidth(
|
|
1583
|
-
column.minWidth = formatMinWidth(
|
|
1780
|
+
watch([width, minWidth], ([widthVal, minWidthVal]) => {
|
|
1781
|
+
column.width = formatWidth(widthVal);
|
|
1782
|
+
column.minWidth = formatMinWidth(minWidthVal);
|
|
1584
1783
|
column.realWidth = column.width || column.minWidth;
|
|
1585
1784
|
});
|
|
1586
1785
|
onBeforeMount(() => {
|
|
@@ -1592,17 +1791,6 @@ function createColumn(props, templates) {
|
|
|
1592
1791
|
});
|
|
1593
1792
|
return column;
|
|
1594
1793
|
}
|
|
1595
|
-
function defaultRenderHeader() {
|
|
1596
|
-
return h("span", { class: "title" }, this.header);
|
|
1597
|
-
}
|
|
1598
|
-
function defaultRenderCell(rowData, index2) {
|
|
1599
|
-
var _a, _b;
|
|
1600
|
-
const value = rowData[this.field];
|
|
1601
|
-
if (this.formatter) {
|
|
1602
|
-
return this.formatter(rowData, value, index2);
|
|
1603
|
-
}
|
|
1604
|
-
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1605
|
-
}
|
|
1606
1794
|
var Column = defineComponent({
|
|
1607
1795
|
name: "DColumn",
|
|
1608
1796
|
props: TableColumnProps,
|
|
@@ -1727,7 +1915,7 @@ function unmountComponent(ComponnetInstance) {
|
|
|
1727
1915
|
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
1728
1916
|
}
|
|
1729
1917
|
const loadingConstructor = defineComponent(Loading);
|
|
1730
|
-
const cacheInstance = new WeakSet();
|
|
1918
|
+
const cacheInstance = /* @__PURE__ */ new WeakSet();
|
|
1731
1919
|
const isEmpty = (val) => {
|
|
1732
1920
|
if (!val)
|
|
1733
1921
|
return true;
|