vue-devui 1.0.0-beta.7 → 1.0.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -66
- package/accordion/index.es.js +522 -39
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +7 -8
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/{toast → auto-complete}/index.d.ts +0 -0
- package/auto-complete/index.es.js +976 -0
- package/auto-complete/index.umd.js +1 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/avatar/index.es.js +1 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.es.js +1 -1
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +13 -19
- package/badge/index.umd.js +1 -1
- package/button/index.es.js +263 -83
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.es.js +1 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.es.js +7 -6
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5393 -773
- package/cascader/index.umd.js +27 -1
- package/checkbox/index.es.js +1 -1
- package/checkbox/index.umd.js +1 -1
- package/checkbox/style.css +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +8187 -0
- package/color-picker/index.umd.js +27 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/comment/index.es.js +42 -13
- package/comment/index.umd.js +1 -1
- package/comment/style.css +1 -1
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.es.js +11 -12
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.es.js +135 -10
- package/dragdrop/index.umd.js +1 -1
- package/drawer/index.es.js +173 -203
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +412 -302
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +275 -5610
- package/editable-select/index.umd.js +1 -27
- package/editable-select/style.css +1 -1
- package/form/index.es.js +6129 -461
- package/form/index.umd.js +27 -1
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +111 -119
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/gantt/index.es.js +6 -18
- package/gantt/index.umd.js +1 -1
- package/gantt/style.css +1 -1
- package/grid/index.es.js +3 -3
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +3 -2
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +78 -20
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +5 -6
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-icon/index.es.js +6 -6
- package/input-icon/index.umd.js +1 -1
- package/input-icon/style.css +1 -1
- package/input-number/index.es.js +2 -1
- package/input-number/index.umd.js +1 -1
- package/layout/index.es.js +1 -1
- package/layout/index.umd.js +1 -1
- package/list/index.d.ts +7 -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 +3 -3
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +297 -761
- 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/notification/index.d.ts +7 -0
- package/notification/index.es.js +286 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/CarouselItem.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/List.js +3 -0
- package/nuxt/components/ListItem.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/buttonProps.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/notificationProps.js +3 -0
- package/nuxt/components/overlayEmits.js +3 -0
- package/nuxt/components/overlayProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.es.js +146 -200
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +10 -18
- package/pagination/index.es.js +4 -4
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +3 -3
- package/panel/index.umd.js +1 -1
- package/popover/index.es.js +5948 -190
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +9 -9
- package/progress/index.umd.js +3 -3
- package/quadrant-diagram/index.es.js +5405 -166
- package/quadrant-diagram/index.umd.js +27 -1
- package/radio/index.es.js +6 -6
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +1 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.es.js +21 -7
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.es.js +6 -3
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +5435 -201
- package/search/index.umd.js +27 -1
- package/search/style.css +1 -1
- package/select/index.es.js +3 -2
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +1 -1
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +3 -6
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5904 -60
- package/splitter/index.umd.js +27 -1
- package/splitter/style.css +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +267 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.es.js +2 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps-guide/index.es.js +8 -6
- package/steps-guide/index.umd.js +1 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +1 -1
- package/switch/index.umd.js +1 -1
- package/table/index.es.js +701 -359
- 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 +37 -11
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +1 -13
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.es.js +1 -1
- package/textarea/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-axis/index.es.js +5 -2
- package/time-axis/index.umd.js +1 -1
- package/time-picker/index.es.js +269 -84
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/tooltip/index.es.js +5798 -141
- package/tooltip/index.umd.js +27 -1
- package/tooltip/style.css +1 -1
- package/transfer/index.es.js +6522 -635
- package/transfer/index.umd.js +27 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +5858 -146
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/tree-select/index.es.js +130 -35
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +464 -2681
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +15597 -14569
- package/vue-devui.umd.js +16 -16
- package/toast/index.es.js +0 -2059
- package/toast/index.umd.js +0 -1
- package/toast/style.css +0 -1
package/table/index.es.js
CHANGED
|
@@ -17,7 +17,13 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
import { computed, ref, watch, defineComponent, inject, createVNode, mergeProps, toRef, provide, toRefs, onMounted, onUnmounted, Teleport, Transition, renderSlot, isVNode, nextTick, unref, Fragment, shallowRef, getCurrentInstance, withDirectives, createTextVNode, resolveDirective, reactive, onBeforeMount, h, onBeforeUnmount, render } from "vue";
|
|
25
|
+
import { offset, autoPlacement, arrow, computePosition } from "@floating-ui/dom";
|
|
26
|
+
import { onClickOutside } from "@vueuse/core";
|
|
21
27
|
const TableProps = {
|
|
22
28
|
data: {
|
|
23
29
|
type: Array,
|
|
@@ -151,7 +157,7 @@ const createColumnGenerator = () => {
|
|
|
151
157
|
const _columns = ref([]);
|
|
152
158
|
const insertColumn = (column) => {
|
|
153
159
|
_columns.value.push(column);
|
|
154
|
-
_columns.value.sort((a, b) => a.order
|
|
160
|
+
_columns.value.sort((a, b) => a.order - b.order);
|
|
155
161
|
};
|
|
156
162
|
const sortColumn = () => {
|
|
157
163
|
_columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
|
|
@@ -205,7 +211,7 @@ const createSelection = (dataSource, _data) => {
|
|
|
205
211
|
};
|
|
206
212
|
};
|
|
207
213
|
const createSorter = (dataSource, _data) => {
|
|
208
|
-
const sortData = (field, direction, compareFn = (
|
|
214
|
+
const sortData = (field, direction, compareFn = (fieldKey, a, b) => a[fieldKey] > b[fieldKey]) => {
|
|
209
215
|
if (direction === "ASC") {
|
|
210
216
|
_data.value = _data.value.sort((a, b) => compareFn(field, a, b) ? 1 : -1);
|
|
211
217
|
} else if (direction === "DESC") {
|
|
@@ -217,13 +223,13 @@ const createSorter = (dataSource, _data) => {
|
|
|
217
223
|
return { sortData };
|
|
218
224
|
};
|
|
219
225
|
const createFilter = (dataSource, _data) => {
|
|
220
|
-
const fieldSet = new Set();
|
|
226
|
+
const fieldSet = /* @__PURE__ */ new Set();
|
|
221
227
|
const filterData = (field, results) => {
|
|
222
228
|
fieldSet.add(field);
|
|
223
229
|
const fields = [...fieldSet];
|
|
224
230
|
_data.value = dataSource.value.filter((item) => {
|
|
225
|
-
return fields.reduce((prev,
|
|
226
|
-
return prev && results.indexOf(item[
|
|
231
|
+
return fields.reduce((prev, fieldKey) => {
|
|
232
|
+
return prev && results.indexOf(item[fieldKey]) !== -1;
|
|
227
233
|
}, true);
|
|
228
234
|
});
|
|
229
235
|
};
|
|
@@ -682,14 +688,7 @@ const Sort = defineComponent({
|
|
|
682
688
|
}
|
|
683
689
|
});
|
|
684
690
|
const dropdownProps = {
|
|
685
|
-
|
|
686
|
-
type: Object
|
|
687
|
-
},
|
|
688
|
-
isOpen: {
|
|
689
|
-
type: Boolean,
|
|
690
|
-
default: false
|
|
691
|
-
},
|
|
692
|
-
disabled: {
|
|
691
|
+
visible: {
|
|
693
692
|
type: Boolean,
|
|
694
693
|
default: false
|
|
695
694
|
},
|
|
@@ -701,18 +700,23 @@ const dropdownProps = {
|
|
|
701
700
|
type: String,
|
|
702
701
|
default: "all"
|
|
703
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
|
+
},
|
|
704
715
|
closeOnMouseLeaveMenu: {
|
|
705
716
|
type: Boolean,
|
|
706
717
|
default: false
|
|
707
|
-
},
|
|
708
|
-
showAnimation: {
|
|
709
|
-
type: Boolean,
|
|
710
|
-
default: true
|
|
711
718
|
}
|
|
712
719
|
};
|
|
713
|
-
function isComponent(target) {
|
|
714
|
-
return !!(target == null ? void 0 : target.$el);
|
|
715
|
-
}
|
|
716
720
|
function getElement(element) {
|
|
717
721
|
if (element instanceof Element) {
|
|
718
722
|
return element;
|
|
@@ -722,84 +726,136 @@ function getElement(element) {
|
|
|
722
726
|
}
|
|
723
727
|
return null;
|
|
724
728
|
}
|
|
729
|
+
const dropdownMap = /* @__PURE__ */ new Map();
|
|
725
730
|
function subscribeEvent(dom, type, callback) {
|
|
726
731
|
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
727
732
|
return () => {
|
|
728
733
|
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
729
734
|
};
|
|
730
735
|
}
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const dropdownElRef = ref();
|
|
739
|
-
const closeByScope = () => {
|
|
740
|
-
if (closeScope.value === "none") {
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
visible.value = false;
|
|
736
|
+
const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
737
|
+
let overlayEnter = false;
|
|
738
|
+
let originEnter = false;
|
|
739
|
+
const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
|
|
740
|
+
const toggle = (status) => {
|
|
741
|
+
isOpen.value = status;
|
|
742
|
+
emit("toggle", isOpen.value);
|
|
744
743
|
};
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (
|
|
744
|
+
const handleLeave = async (elementType, e) => {
|
|
745
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
746
|
+
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
748
747
|
return;
|
|
749
748
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
749
|
+
if (e) {
|
|
750
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
751
|
+
setTimeout(() => {
|
|
752
|
+
var _a;
|
|
753
|
+
(_a = item.toggle) == null ? void 0 : _a.call(item);
|
|
754
|
+
}, 0);
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
toggle(false);
|
|
758
|
+
};
|
|
759
|
+
watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
|
|
760
|
+
const originEl = getElement(originVal);
|
|
761
|
+
const subscriptions = [];
|
|
762
|
+
setTimeout(() => {
|
|
763
|
+
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
764
|
+
const dropdownValues = [...dropdownMap.values()];
|
|
765
|
+
if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
766
|
+
var _a;
|
|
767
|
+
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
768
|
+
}) && dropdownValues.some((item) => {
|
|
769
|
+
var _a;
|
|
770
|
+
return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
|
|
771
|
+
})) {
|
|
765
772
|
return;
|
|
766
773
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
774
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
775
|
+
setTimeout(() => {
|
|
776
|
+
var _a, _b;
|
|
777
|
+
if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
|
|
778
|
+
(_b = item.toggle) == null ? void 0 : _b.call(item);
|
|
779
|
+
}
|
|
780
|
+
}, 0);
|
|
781
|
+
});
|
|
782
|
+
overlayEnter = false;
|
|
772
783
|
}));
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
return;
|
|
784
|
+
}, 0);
|
|
785
|
+
if (triggerVal === "click") {
|
|
786
|
+
subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
787
|
+
var _a;
|
|
788
|
+
if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
789
|
+
handleLeave("dropdown", e);
|
|
780
790
|
}
|
|
781
|
-
|
|
782
|
-
|
|
791
|
+
}));
|
|
792
|
+
} else if (triggerVal === "hover") {
|
|
783
793
|
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
784
794
|
originEnter = true;
|
|
785
|
-
|
|
795
|
+
toggle(true);
|
|
786
796
|
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
787
797
|
originEnter = false;
|
|
788
|
-
|
|
789
|
-
handleLeave("origin");
|
|
790
|
-
}
|
|
798
|
+
handleLeave("origin");
|
|
791
799
|
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
792
800
|
overlayEnter = true;
|
|
793
|
-
|
|
794
|
-
}), subscribeEvent(dropdownEl, "mouseleave", () => {
|
|
801
|
+
isOpen.value = true;
|
|
802
|
+
}), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
803
|
+
var _a;
|
|
795
804
|
overlayEnter = false;
|
|
796
|
-
|
|
805
|
+
if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
handleLeave("dropdown", e);
|
|
797
809
|
}));
|
|
798
810
|
}
|
|
799
811
|
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
800
812
|
});
|
|
801
|
-
return { dropdownEl: dropdownElRef };
|
|
802
813
|
};
|
|
814
|
+
function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
|
|
815
|
+
const calcPopDirection = (dropdownEl) => {
|
|
816
|
+
const elementHeight = dropdownEl.offsetHeight;
|
|
817
|
+
const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
|
|
818
|
+
const isBottomEnough = bottomDistance >= elementHeight;
|
|
819
|
+
if (!isBottomEnough) {
|
|
820
|
+
popDirection.value = "top";
|
|
821
|
+
} else {
|
|
822
|
+
popDirection.value = "bottom";
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
watch(visible, (newVal, oldVal) => {
|
|
826
|
+
if (oldVal === void 0) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
isOpen.value = newVal;
|
|
830
|
+
emit("toggle", isOpen.value);
|
|
831
|
+
}, { immediate: true });
|
|
832
|
+
watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
|
|
833
|
+
var _a;
|
|
834
|
+
if (isOpenVal) {
|
|
835
|
+
dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
|
|
836
|
+
menuEl: dropdownEl,
|
|
837
|
+
toggle: () => {
|
|
838
|
+
isOpen.value = false;
|
|
839
|
+
emit("toggle", isOpen.value);
|
|
840
|
+
}
|
|
841
|
+
}));
|
|
842
|
+
for (const value of dropdownMap.values()) {
|
|
843
|
+
if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
|
|
844
|
+
value.child = dropdownEl;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (dropdownEl) {
|
|
849
|
+
calcPopDirection(dropdownEl);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
onMounted(() => {
|
|
853
|
+
dropdownMap.set(id, { toggleEl: origin.value });
|
|
854
|
+
});
|
|
855
|
+
onUnmounted(() => {
|
|
856
|
+
dropdownMap.delete(id);
|
|
857
|
+
});
|
|
858
|
+
}
|
|
803
859
|
var overlay = "";
|
|
804
860
|
function _isSlot(s) {
|
|
805
861
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
@@ -824,9 +880,6 @@ const overlayProps = {
|
|
|
824
880
|
visible: {
|
|
825
881
|
type: Boolean
|
|
826
882
|
},
|
|
827
|
-
"onUpdate:visible": {
|
|
828
|
-
type: Function
|
|
829
|
-
},
|
|
830
883
|
backgroundBlock: {
|
|
831
884
|
type: Boolean,
|
|
832
885
|
default: false
|
|
@@ -838,7 +891,7 @@ const overlayProps = {
|
|
|
838
891
|
backgroundStyle: {
|
|
839
892
|
type: [String, Object]
|
|
840
893
|
},
|
|
841
|
-
|
|
894
|
+
onBackdropClick: {
|
|
842
895
|
type: Function
|
|
843
896
|
},
|
|
844
897
|
backdropClose: {
|
|
@@ -850,28 +903,44 @@ const overlayProps = {
|
|
|
850
903
|
default: true
|
|
851
904
|
}
|
|
852
905
|
};
|
|
906
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
853
907
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
854
908
|
overlayStyle: {
|
|
855
909
|
type: [String, Object],
|
|
856
910
|
default: void 0
|
|
857
911
|
}
|
|
858
912
|
});
|
|
859
|
-
const flexibleOverlayProps =
|
|
913
|
+
const flexibleOverlayProps = {
|
|
914
|
+
modelValue: {
|
|
915
|
+
type: Boolean,
|
|
916
|
+
default: false
|
|
917
|
+
},
|
|
860
918
|
origin: {
|
|
861
919
|
type: Object,
|
|
862
920
|
require: true
|
|
863
921
|
},
|
|
864
922
|
position: {
|
|
865
|
-
type:
|
|
866
|
-
default:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
923
|
+
type: Array,
|
|
924
|
+
default: ["bottom"]
|
|
925
|
+
},
|
|
926
|
+
offset: {
|
|
927
|
+
type: [Number, Object],
|
|
928
|
+
default: 8
|
|
929
|
+
},
|
|
930
|
+
align: {
|
|
931
|
+
type: String,
|
|
932
|
+
default: null
|
|
933
|
+
},
|
|
934
|
+
showArrow: {
|
|
935
|
+
type: Boolean,
|
|
936
|
+
default: false
|
|
937
|
+
},
|
|
938
|
+
isArrowCenter: {
|
|
939
|
+
type: Boolean,
|
|
940
|
+
default: true
|
|
872
941
|
}
|
|
873
|
-
}
|
|
874
|
-
function useOverlayLogic(props) {
|
|
942
|
+
};
|
|
943
|
+
function useOverlayLogic(props, ctx) {
|
|
875
944
|
const backgroundClass = computed(() => {
|
|
876
945
|
return [
|
|
877
946
|
"devui-overlay-background",
|
|
@@ -883,11 +952,11 @@ function useOverlayLogic(props) {
|
|
|
883
952
|
return "devui-overlay";
|
|
884
953
|
});
|
|
885
954
|
const handleBackdropClick = (event) => {
|
|
886
|
-
var _a
|
|
955
|
+
var _a;
|
|
887
956
|
event.preventDefault();
|
|
888
|
-
(_a = props.
|
|
957
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
889
958
|
if (props.backdropClose) {
|
|
890
|
-
(
|
|
959
|
+
ctx.emit("update:visible", false);
|
|
891
960
|
}
|
|
892
961
|
};
|
|
893
962
|
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
@@ -921,18 +990,19 @@ function useOverlayLogic(props) {
|
|
|
921
990
|
handleOverlayBubbleCancel
|
|
922
991
|
};
|
|
923
992
|
}
|
|
924
|
-
|
|
993
|
+
defineComponent({
|
|
925
994
|
name: "DFixedOverlay",
|
|
926
995
|
props: fixedOverlayProps,
|
|
996
|
+
emits: overlayEmits,
|
|
927
997
|
setup(props, ctx) {
|
|
928
998
|
const {
|
|
929
999
|
backgroundClass,
|
|
930
1000
|
overlayClass,
|
|
931
1001
|
handleBackdropClick,
|
|
932
1002
|
handleOverlayBubbleCancel
|
|
933
|
-
} = useOverlayLogic(props);
|
|
1003
|
+
} = useOverlayLogic(props, ctx);
|
|
934
1004
|
return () => createVNode(CommonOverlay, null, {
|
|
935
|
-
default: () => [
|
|
1005
|
+
default: () => [props.visible && createVNode("div", {
|
|
936
1006
|
"class": backgroundClass.value,
|
|
937
1007
|
"style": props.backgroundStyle,
|
|
938
1008
|
"onClick": handleBackdropClick
|
|
@@ -940,246 +1010,289 @@ const FixedOverlay = defineComponent({
|
|
|
940
1010
|
"class": overlayClass.value,
|
|
941
1011
|
"style": props.overlayStyle,
|
|
942
1012
|
"onClick": handleOverlayBubbleCancel
|
|
943
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
});
|
|
947
|
-
const FlexibleOverlay = defineComponent({
|
|
948
|
-
name: "DFlexibleOverlay",
|
|
949
|
-
props: flexibleOverlayProps,
|
|
950
|
-
emits: ["onUpdate:visible"],
|
|
951
|
-
setup(props, ctx) {
|
|
952
|
-
const overlayRef = ref(null);
|
|
953
|
-
const positionedStyle = reactive({
|
|
954
|
-
position: "absolute"
|
|
955
|
-
});
|
|
956
|
-
onMounted(async () => {
|
|
957
|
-
const handleRectChange = (position, rect, origin) => {
|
|
958
|
-
const point = calculatePosition(position, rect, origin);
|
|
959
|
-
positionedStyle.left = `${point.x}px`;
|
|
960
|
-
positionedStyle.top = `${point.y}px`;
|
|
961
|
-
};
|
|
962
|
-
const locationElements = computed(() => {
|
|
963
|
-
const overlay2 = overlayRef.value;
|
|
964
|
-
const origin = getOrigin(props.origin);
|
|
965
|
-
if (!overlay2 || !origin) {
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
return {
|
|
969
|
-
origin,
|
|
970
|
-
overlay: overlay2
|
|
971
|
-
};
|
|
972
|
-
});
|
|
973
|
-
const visibleRef = toRef(props, "visible");
|
|
974
|
-
const positionRef = toRef(props, "position");
|
|
975
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
976
|
-
if (!visible || !locationElements2) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
const {
|
|
980
|
-
origin,
|
|
981
|
-
overlay: overlay2
|
|
982
|
-
} = locationElements2;
|
|
983
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
984
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
985
|
-
onInvalidate(() => {
|
|
986
|
-
unsubscriptions.forEach((fn) => fn());
|
|
987
|
-
});
|
|
988
|
-
});
|
|
989
|
-
});
|
|
990
|
-
const {
|
|
991
|
-
backgroundClass,
|
|
992
|
-
overlayClass,
|
|
993
|
-
handleBackdropClick,
|
|
994
|
-
handleOverlayBubbleCancel
|
|
995
|
-
} = useOverlayLogic(props);
|
|
996
|
-
return () => createVNode(CommonOverlay, null, {
|
|
997
|
-
default: () => [withDirectives(createVNode("div", {
|
|
998
|
-
"style": props.backgroundStyle,
|
|
999
|
-
"class": backgroundClass.value,
|
|
1000
|
-
"onClick": handleBackdropClick
|
|
1001
|
-
}, [createVNode("div", {
|
|
1002
|
-
"ref": overlayRef,
|
|
1003
|
-
"class": overlayClass.value,
|
|
1004
|
-
"style": positionedStyle,
|
|
1005
|
-
"onClick": handleOverlayBubbleCancel
|
|
1006
|
-
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
1013
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
1007
1014
|
});
|
|
1008
1015
|
}
|
|
1009
1016
|
});
|
|
1010
|
-
function
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
if (isComponent(origin)) {
|
|
1018
|
-
return getElement(origin);
|
|
1019
|
-
}
|
|
1020
|
-
return origin;
|
|
1021
|
-
}
|
|
1022
|
-
function calculatePosition(position, rect, origin) {
|
|
1023
|
-
const originRect = getOriginRect(origin);
|
|
1024
|
-
const originPoint = getOriginRelativePoint(originRect, position);
|
|
1025
|
-
return getOverlayPoint(originPoint, rect, position);
|
|
1026
|
-
}
|
|
1027
|
-
function getOriginRect(origin) {
|
|
1028
|
-
if (origin instanceof Element) {
|
|
1029
|
-
return origin.getBoundingClientRect();
|
|
1030
|
-
}
|
|
1031
|
-
const width = origin.width || 0;
|
|
1032
|
-
const height = origin.height || 0;
|
|
1033
|
-
return {
|
|
1034
|
-
top: origin.y,
|
|
1035
|
-
bottom: origin.y + height,
|
|
1036
|
-
left: origin.x,
|
|
1037
|
-
right: origin.x + width,
|
|
1038
|
-
height,
|
|
1039
|
-
width
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
function getOverlayPoint(originPoint, rect, position) {
|
|
1043
|
-
let x;
|
|
1044
|
-
const {
|
|
1045
|
-
width,
|
|
1046
|
-
height
|
|
1047
|
-
} = rect;
|
|
1048
|
-
if (position.overlayX == "center") {
|
|
1049
|
-
x = originPoint.x - width / 2;
|
|
1050
|
-
} else {
|
|
1051
|
-
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
1052
|
-
}
|
|
1053
|
-
let y;
|
|
1054
|
-
if (position.overlayY == "center") {
|
|
1055
|
-
y = originPoint.y - height / 2;
|
|
1056
|
-
} else {
|
|
1057
|
-
y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
|
|
1017
|
+
function getScrollParent(element) {
|
|
1018
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
1019
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
1020
|
+
const style = window.getComputedStyle(parent);
|
|
1021
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
1022
|
+
return parent;
|
|
1023
|
+
}
|
|
1058
1024
|
}
|
|
1059
|
-
return
|
|
1060
|
-
x,
|
|
1061
|
-
y
|
|
1062
|
-
};
|
|
1025
|
+
return window;
|
|
1063
1026
|
}
|
|
1064
|
-
function
|
|
1065
|
-
let x;
|
|
1066
|
-
if (
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
x
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
y
|
|
1027
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
1028
|
+
let { x, y } = point;
|
|
1029
|
+
if (!isArrowCenter) {
|
|
1030
|
+
const { width, height } = originRect;
|
|
1031
|
+
if (x && placement.includes("start")) {
|
|
1032
|
+
x = 12;
|
|
1033
|
+
}
|
|
1034
|
+
if (x && placement.includes("end")) {
|
|
1035
|
+
x = Math.round(width - 24);
|
|
1036
|
+
}
|
|
1037
|
+
if (y && placement.includes("start")) {
|
|
1038
|
+
y = 10;
|
|
1039
|
+
}
|
|
1040
|
+
if (y && placement.includes("end")) {
|
|
1041
|
+
y = height - 14;
|
|
1042
|
+
}
|
|
1078
1043
|
}
|
|
1079
|
-
return {
|
|
1080
|
-
x,
|
|
1081
|
-
y
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
function subscribeLayoutEvent(event) {
|
|
1085
|
-
window.addEventListener("scroll", event, true);
|
|
1086
|
-
window.addEventListener("resize", event);
|
|
1087
|
-
window.addEventListener("orientationchange", event);
|
|
1088
|
-
return () => {
|
|
1089
|
-
window.removeEventListener("scroll", event, true);
|
|
1090
|
-
window.removeEventListener("resize", event);
|
|
1091
|
-
window.removeEventListener("orientationchange", event);
|
|
1092
|
-
};
|
|
1044
|
+
return { x, y };
|
|
1093
1045
|
}
|
|
1094
|
-
function
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1046
|
+
function useOverlay(props, emit) {
|
|
1047
|
+
const overlayRef = ref();
|
|
1048
|
+
const arrowRef = ref();
|
|
1049
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
1050
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
1051
|
+
const staticSide = {
|
|
1052
|
+
top: "bottom",
|
|
1053
|
+
right: "left",
|
|
1054
|
+
bottom: "top",
|
|
1055
|
+
left: "right"
|
|
1056
|
+
}[placement.split("-")[0]];
|
|
1057
|
+
Object.assign(arrowEl.style, {
|
|
1058
|
+
left: x ? `${x}px` : "",
|
|
1059
|
+
top: y ? `${y}px` : "",
|
|
1060
|
+
right: "",
|
|
1061
|
+
bottom: "",
|
|
1062
|
+
[staticSide]: "-4px"
|
|
1063
|
+
});
|
|
1101
1064
|
};
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1065
|
+
const updatePosition = async () => {
|
|
1066
|
+
const hostEl = props.origin;
|
|
1067
|
+
const overlayEl = unref(overlayRef.value);
|
|
1068
|
+
const arrowEl = unref(arrowRef.value);
|
|
1069
|
+
const middleware = [
|
|
1070
|
+
offset(props.offset),
|
|
1071
|
+
autoPlacement({
|
|
1072
|
+
alignment: props.align,
|
|
1073
|
+
allowedPlacements: props.position
|
|
1074
|
+
})
|
|
1075
|
+
];
|
|
1076
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
1077
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
1078
|
+
strategy: "fixed",
|
|
1079
|
+
middleware
|
|
1108
1080
|
});
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1081
|
+
emit("positionChange", placement);
|
|
1082
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
1083
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
1112
1084
|
};
|
|
1085
|
+
watch(() => props.modelValue, () => {
|
|
1086
|
+
const originParent = getScrollParent(props.origin);
|
|
1087
|
+
if (props.modelValue && props.origin) {
|
|
1088
|
+
nextTick(updatePosition);
|
|
1089
|
+
originParent.addEventListener("scroll", updatePosition);
|
|
1090
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
1091
|
+
window.addEventListener("resize", updatePosition);
|
|
1092
|
+
} else {
|
|
1093
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
1094
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
1095
|
+
window.removeEventListener("resize", updatePosition);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
onUnmounted(() => {
|
|
1099
|
+
const originParent = getScrollParent(props.origin);
|
|
1100
|
+
originParent.removeEventListener("scroll", updatePosition);
|
|
1101
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
1102
|
+
window.removeEventListener("resize", updatePosition);
|
|
1103
|
+
});
|
|
1104
|
+
return { arrowRef, overlayRef };
|
|
1113
1105
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1106
|
+
var flexibleOverlay = "";
|
|
1107
|
+
const FlexibleOverlay = defineComponent({
|
|
1108
|
+
name: "DFlexibleOverlay",
|
|
1109
|
+
inheritAttrs: false,
|
|
1110
|
+
props: flexibleOverlayProps,
|
|
1111
|
+
emits: ["update:modelValue", "positionChange"],
|
|
1112
|
+
setup(props, {
|
|
1113
|
+
slots,
|
|
1114
|
+
attrs,
|
|
1115
|
+
emit
|
|
1116
|
+
}) {
|
|
1117
|
+
const {
|
|
1118
|
+
arrowRef,
|
|
1119
|
+
overlayRef
|
|
1120
|
+
} = useOverlay(props, emit);
|
|
1121
|
+
return () => {
|
|
1122
|
+
var _a;
|
|
1123
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
1124
|
+
"ref": overlayRef,
|
|
1125
|
+
"class": "devui-flexible-overlay"
|
|
1126
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
1127
|
+
"ref": arrowRef,
|
|
1128
|
+
"class": "devui-flexible-overlay-arrow"
|
|
1129
|
+
}, null)]);
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1120
1133
|
var dropdown = "";
|
|
1134
|
+
let dropdownId = 1;
|
|
1121
1135
|
var Dropdown = defineComponent({
|
|
1122
1136
|
name: "DDropdown",
|
|
1137
|
+
inheritAttrs: false,
|
|
1123
1138
|
props: dropdownProps,
|
|
1124
|
-
emits: [],
|
|
1125
|
-
setup(props,
|
|
1139
|
+
emits: ["toggle"],
|
|
1140
|
+
setup(props, {
|
|
1141
|
+
slots,
|
|
1142
|
+
attrs,
|
|
1143
|
+
emit
|
|
1144
|
+
}) {
|
|
1126
1145
|
const {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
closeOnMouseLeaveMenu
|
|
1146
|
+
visible,
|
|
1147
|
+
position,
|
|
1148
|
+
align,
|
|
1149
|
+
offset: offset2
|
|
1132
1150
|
} = toRefs(props);
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
originX: "center",
|
|
1141
|
-
originY: "bottom",
|
|
1142
|
-
overlayX: "center",
|
|
1143
|
-
overlayY: "top"
|
|
1151
|
+
const origin = ref();
|
|
1152
|
+
const dropdownRef = ref();
|
|
1153
|
+
const id = `dropdown_${dropdownId++}`;
|
|
1154
|
+
const isOpen = ref(false);
|
|
1155
|
+
const currentPosition = ref("bottom");
|
|
1156
|
+
const handlePositionChange = (pos) => {
|
|
1157
|
+
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
1144
1158
|
};
|
|
1145
|
-
const {
|
|
1146
|
-
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1159
|
+
const styles = computed(() => ({
|
|
1160
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
1161
|
+
}));
|
|
1162
|
+
const classes = computed(() => ({
|
|
1163
|
+
"fade-in-bottom": isOpen.value && currentPosition.value === "bottom",
|
|
1164
|
+
"fade-in-top": isOpen.value && currentPosition.value === "top"
|
|
1165
|
+
}));
|
|
1166
|
+
useDropdownEvent({
|
|
1167
|
+
id,
|
|
1168
|
+
isOpen,
|
|
1149
1169
|
origin,
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
});
|
|
1154
|
-
const animatedVisible = computed(() => {
|
|
1155
|
-
return props.showAnimation ? visible.value : true;
|
|
1170
|
+
dropdownRef,
|
|
1171
|
+
props,
|
|
1172
|
+
emit
|
|
1156
1173
|
});
|
|
1174
|
+
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
1157
1175
|
return () => {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
"
|
|
1161
|
-
"
|
|
1162
|
-
|
|
1163
|
-
"
|
|
1176
|
+
var _a;
|
|
1177
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
1178
|
+
"ref": origin,
|
|
1179
|
+
"class": "devui-dropdown-toggle"
|
|
1180
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
1181
|
+
"to": "body"
|
|
1164
1182
|
}, {
|
|
1165
1183
|
default: () => [createVNode(Transition, {
|
|
1166
|
-
"name":
|
|
1184
|
+
"name": `devui-dropdown-fade-${currentPosition.value}`
|
|
1167
1185
|
}, {
|
|
1168
|
-
default: () => {
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1186
|
+
default: () => [createVNode(FlexibleOverlay, {
|
|
1187
|
+
"modelValue": isOpen.value,
|
|
1188
|
+
"onUpdate:modelValue": ($event) => isOpen.value = $event,
|
|
1189
|
+
"origin": origin.value,
|
|
1190
|
+
"position": position.value,
|
|
1191
|
+
"align": align.value,
|
|
1192
|
+
"offset": offset2.value,
|
|
1193
|
+
"onPositionChange": handlePositionChange,
|
|
1194
|
+
"class": classes.value,
|
|
1195
|
+
"style": styles.value
|
|
1196
|
+
}, {
|
|
1197
|
+
default: () => {
|
|
1198
|
+
var _a2;
|
|
1199
|
+
return [createVNode("div", mergeProps({
|
|
1200
|
+
"ref": dropdownRef,
|
|
1201
|
+
"class": "devui-dropdown-menu-wrap"
|
|
1202
|
+
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
1203
|
+
}
|
|
1204
|
+
})]
|
|
1175
1205
|
})]
|
|
1176
1206
|
})]);
|
|
1177
1207
|
};
|
|
1178
1208
|
}
|
|
1179
1209
|
});
|
|
1180
|
-
|
|
1181
|
-
|
|
1210
|
+
const dropdownMenuProps = {
|
|
1211
|
+
modelValue: {
|
|
1212
|
+
type: Boolean,
|
|
1213
|
+
default: false
|
|
1214
|
+
},
|
|
1215
|
+
origin: {
|
|
1216
|
+
type: Object,
|
|
1217
|
+
require: true
|
|
1218
|
+
},
|
|
1219
|
+
position: {
|
|
1220
|
+
type: Array,
|
|
1221
|
+
default: ["bottom"]
|
|
1222
|
+
},
|
|
1223
|
+
align: {
|
|
1224
|
+
type: String,
|
|
1225
|
+
default: null
|
|
1226
|
+
},
|
|
1227
|
+
offset: {
|
|
1228
|
+
type: [Number, Object],
|
|
1229
|
+
default: 4
|
|
1230
|
+
},
|
|
1231
|
+
clickOutside: {
|
|
1232
|
+
type: Function,
|
|
1233
|
+
default: () => true
|
|
1234
|
+
}
|
|
1182
1235
|
};
|
|
1236
|
+
defineComponent({
|
|
1237
|
+
name: "DDropdownMenu",
|
|
1238
|
+
inheritAttrs: false,
|
|
1239
|
+
props: dropdownMenuProps,
|
|
1240
|
+
emits: ["update:modelValue"],
|
|
1241
|
+
setup(props, {
|
|
1242
|
+
slots,
|
|
1243
|
+
attrs,
|
|
1244
|
+
emit
|
|
1245
|
+
}) {
|
|
1246
|
+
const {
|
|
1247
|
+
modelValue,
|
|
1248
|
+
origin,
|
|
1249
|
+
position,
|
|
1250
|
+
align,
|
|
1251
|
+
offset: offset2,
|
|
1252
|
+
clickOutside
|
|
1253
|
+
} = toRefs(props);
|
|
1254
|
+
const dropdownMenuRef = ref(null);
|
|
1255
|
+
onClickOutside(dropdownMenuRef, (value) => {
|
|
1256
|
+
var _a;
|
|
1257
|
+
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !origin.value.contains(value.target)) {
|
|
1258
|
+
emit("update:modelValue", false);
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
const currentPosition = ref("bottom");
|
|
1262
|
+
const handlePositionChange = (pos) => {
|
|
1263
|
+
currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
|
|
1264
|
+
};
|
|
1265
|
+
const styles = computed(() => ({
|
|
1266
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
1267
|
+
}));
|
|
1268
|
+
return () => createVNode(Teleport, {
|
|
1269
|
+
"to": "body"
|
|
1270
|
+
}, {
|
|
1271
|
+
default: () => [createVNode(Transition, {
|
|
1272
|
+
"name": `devui-dropdown-fade-${currentPosition.value}`
|
|
1273
|
+
}, {
|
|
1274
|
+
default: () => [createVNode(FlexibleOverlay, {
|
|
1275
|
+
"modelValue": modelValue.value,
|
|
1276
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
1277
|
+
"origin": origin == null ? void 0 : origin.value,
|
|
1278
|
+
"position": position.value,
|
|
1279
|
+
"align": align.value,
|
|
1280
|
+
"offset": offset2.value,
|
|
1281
|
+
"onPositionChange": handlePositionChange,
|
|
1282
|
+
"style": styles.value
|
|
1283
|
+
}, {
|
|
1284
|
+
default: () => {
|
|
1285
|
+
var _a;
|
|
1286
|
+
return [createVNode("div", mergeProps({
|
|
1287
|
+
"ref": dropdownMenuRef,
|
|
1288
|
+
"class": "devui-dropdown-menu-wrap"
|
|
1289
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
1290
|
+
}
|
|
1291
|
+
})]
|
|
1292
|
+
})]
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1183
1296
|
var filter = "";
|
|
1184
1297
|
const Filter = defineComponent({
|
|
1185
1298
|
props: {
|
|
@@ -1413,48 +1526,74 @@ const TD = defineComponent({
|
|
|
1413
1526
|
}, [column.value.renderCell(props.row, props.index)]);
|
|
1414
1527
|
}
|
|
1415
1528
|
});
|
|
1416
|
-
var
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
} = useTable(props);
|
|
1429
|
-
const isEmpty = computed(() => props.data.length === 0);
|
|
1430
|
-
const fixHeaderCompo = computed(() => {
|
|
1529
|
+
var FixHeader = defineComponent({
|
|
1530
|
+
props: {
|
|
1531
|
+
classes: {
|
|
1532
|
+
type: Object,
|
|
1533
|
+
default: () => ({})
|
|
1534
|
+
},
|
|
1535
|
+
isEmpty: {
|
|
1536
|
+
type: Boolean
|
|
1537
|
+
}
|
|
1538
|
+
},
|
|
1539
|
+
setup(props) {
|
|
1540
|
+
return () => {
|
|
1431
1541
|
return createVNode("div", {
|
|
1432
1542
|
"class": "devui-table-view"
|
|
1433
1543
|
}, [createVNode("div", {
|
|
1434
|
-
"style": "overflow:
|
|
1544
|
+
"style": "overflow:hidden scroll;"
|
|
1435
1545
|
}, [createVNode("table", {
|
|
1436
|
-
"class": classes
|
|
1546
|
+
"class": props.classes,
|
|
1437
1547
|
"cellpadding": "0",
|
|
1438
1548
|
"cellspacing": "0"
|
|
1439
1549
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
|
|
1440
1550
|
"class": "scroll-view"
|
|
1441
1551
|
}, [createVNode("table", {
|
|
1442
|
-
"class": classes
|
|
1552
|
+
"class": props.classes,
|
|
1443
1553
|
"cellpadding": "0",
|
|
1444
1554
|
"cellspacing": "0"
|
|
1445
|
-
}, [createVNode(ColGroup, null, null), !isEmpty
|
|
1555
|
+
}, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
|
|
1446
1556
|
"style": "flex: 1"
|
|
1447
1557
|
}, null)])])]);
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
var NormalHeader = defineComponent({
|
|
1562
|
+
props: {
|
|
1563
|
+
classes: {
|
|
1564
|
+
type: Object,
|
|
1565
|
+
default: () => ({})
|
|
1566
|
+
},
|
|
1567
|
+
isEmpty: {
|
|
1568
|
+
type: Boolean
|
|
1569
|
+
}
|
|
1570
|
+
},
|
|
1571
|
+
setup(props) {
|
|
1572
|
+
return () => {
|
|
1450
1573
|
return createVNode("table", {
|
|
1451
|
-
"class": classes
|
|
1574
|
+
"class": props.classes,
|
|
1452
1575
|
"cellpadding": "0",
|
|
1453
1576
|
"cellspacing": "0"
|
|
1454
1577
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
|
|
1455
|
-
"style": "position:
|
|
1456
|
-
}, null), !isEmpty
|
|
1457
|
-
}
|
|
1578
|
+
"style": "position:relative"
|
|
1579
|
+
}, null), !props.isEmpty && createVNode(TableBody, null, null)]);
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
var table = "";
|
|
1584
|
+
var Table = defineComponent({
|
|
1585
|
+
name: "DTable",
|
|
1586
|
+
props: TableProps,
|
|
1587
|
+
setup(props, ctx) {
|
|
1588
|
+
const table2 = getCurrentInstance();
|
|
1589
|
+
const store = createStore(toRef(props, "data"));
|
|
1590
|
+
table2.store = store;
|
|
1591
|
+
provide(TABLE_TOKEN, table2);
|
|
1592
|
+
const {
|
|
1593
|
+
classes,
|
|
1594
|
+
style
|
|
1595
|
+
} = useTable(props);
|
|
1596
|
+
const isEmpty2 = computed(() => props.data.length === 0);
|
|
1458
1597
|
ctx.expose({
|
|
1459
1598
|
getCheckedRows() {
|
|
1460
1599
|
return store.getCheckedRows();
|
|
@@ -1463,7 +1602,13 @@ var Table = defineComponent({
|
|
|
1463
1602
|
return () => withDirectives(createVNode("div", {
|
|
1464
1603
|
"class": "devui-table-wrapper",
|
|
1465
1604
|
"style": style.value
|
|
1466
|
-
}, [ctx.slots.default(), props.fixHeader ?
|
|
1605
|
+
}, [ctx.slots.default(), props.fixHeader ? createVNode(FixHeader, {
|
|
1606
|
+
"classes": classes.value,
|
|
1607
|
+
"is-empty": isEmpty2.value
|
|
1608
|
+
}, null) : createVNode(NormalHeader, {
|
|
1609
|
+
"classes": classes.value,
|
|
1610
|
+
"is-empty": isEmpty2.value
|
|
1611
|
+
}, null), isEmpty2.value && createVNode("div", {
|
|
1467
1612
|
"class": "devui-table-empty"
|
|
1468
1613
|
}, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
|
|
1469
1614
|
}
|
|
@@ -1528,6 +1673,9 @@ function formatWidth(width) {
|
|
|
1528
1673
|
function formatMinWidth(minWidth) {
|
|
1529
1674
|
return formatWidth(minWidth) || 80;
|
|
1530
1675
|
}
|
|
1676
|
+
function defaultRenderHeader() {
|
|
1677
|
+
return h("span", { class: "title" }, this.header);
|
|
1678
|
+
}
|
|
1531
1679
|
function createColumn(props, templates) {
|
|
1532
1680
|
const {
|
|
1533
1681
|
field,
|
|
@@ -1545,31 +1693,38 @@ function createColumn(props, templates) {
|
|
|
1545
1693
|
fixedRight
|
|
1546
1694
|
} = props;
|
|
1547
1695
|
const column = reactive({});
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1696
|
+
function defaultRenderCell(rowData, index2) {
|
|
1697
|
+
var _a, _b;
|
|
1698
|
+
const value = rowData[this.field];
|
|
1699
|
+
if (templates.default) {
|
|
1700
|
+
return templates.default(rowData);
|
|
1701
|
+
}
|
|
1702
|
+
if (this.formatter) {
|
|
1703
|
+
return this.formatter(rowData, value, index2);
|
|
1704
|
+
}
|
|
1705
|
+
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1706
|
+
}
|
|
1707
|
+
watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
|
|
1708
|
+
column.field = fieldVal;
|
|
1709
|
+
column.header = headerVal;
|
|
1710
|
+
column.order = orderVal;
|
|
1552
1711
|
}, { immediate: true });
|
|
1553
|
-
watch([sortable, compareFn], ([
|
|
1554
|
-
column.sortable =
|
|
1555
|
-
column.compareFn =
|
|
1712
|
+
watch([sortable, compareFn], ([sortableVal, compareFnVal]) => {
|
|
1713
|
+
column.sortable = sortableVal;
|
|
1714
|
+
column.compareFn = compareFnVal;
|
|
1556
1715
|
});
|
|
1557
|
-
watch([
|
|
1558
|
-
filterable
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
], ([filterable2, filterList2, filterMultiple2]) => {
|
|
1562
|
-
column.filterable = filterable2;
|
|
1563
|
-
column.filterMultiple = filterMultiple2;
|
|
1564
|
-
column.filterList = filterList2;
|
|
1716
|
+
watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
|
|
1717
|
+
column.filterable = filterableVal;
|
|
1718
|
+
column.filterMultiple = filterMultipleVal;
|
|
1719
|
+
column.filterList = filterListVal;
|
|
1565
1720
|
}, { immediate: true });
|
|
1566
1721
|
watch([fixedLeft, fixedRight], ([left, right]) => {
|
|
1567
1722
|
column.fixedLeft = left;
|
|
1568
1723
|
column.fixedRight = right;
|
|
1569
1724
|
}, { immediate: true });
|
|
1570
|
-
watch([width, minWidth], ([
|
|
1571
|
-
column.width = formatWidth(
|
|
1572
|
-
column.minWidth = formatMinWidth(
|
|
1725
|
+
watch([width, minWidth], ([widthVal, minWidthVal]) => {
|
|
1726
|
+
column.width = formatWidth(widthVal);
|
|
1727
|
+
column.minWidth = formatMinWidth(minWidthVal);
|
|
1573
1728
|
column.realWidth = column.width || column.minWidth;
|
|
1574
1729
|
});
|
|
1575
1730
|
onBeforeMount(() => {
|
|
@@ -1581,17 +1736,6 @@ function createColumn(props, templates) {
|
|
|
1581
1736
|
});
|
|
1582
1737
|
return column;
|
|
1583
1738
|
}
|
|
1584
|
-
function defaultRenderHeader() {
|
|
1585
|
-
return h("span", { class: "title" }, this.header);
|
|
1586
|
-
}
|
|
1587
|
-
function defaultRenderCell(rowData, index2) {
|
|
1588
|
-
var _a, _b;
|
|
1589
|
-
const value = rowData[this.field];
|
|
1590
|
-
if (this.formatter) {
|
|
1591
|
-
return this.formatter(rowData, value, index2);
|
|
1592
|
-
}
|
|
1593
|
-
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1594
|
-
}
|
|
1595
1739
|
var Column = defineComponent({
|
|
1596
1740
|
name: "DColumn",
|
|
1597
1741
|
props: TableColumnProps,
|
|
@@ -1612,7 +1756,205 @@ var Column = defineComponent({
|
|
|
1612
1756
|
return null;
|
|
1613
1757
|
}
|
|
1614
1758
|
});
|
|
1759
|
+
class View {
|
|
1760
|
+
constructor() {
|
|
1761
|
+
__publicField(this, "top", "50%");
|
|
1762
|
+
__publicField(this, "left", "50%");
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
const componentProps = {
|
|
1766
|
+
message: String,
|
|
1767
|
+
backdrop: Boolean,
|
|
1768
|
+
view: {
|
|
1769
|
+
type: Object,
|
|
1770
|
+
default: () => new View()
|
|
1771
|
+
},
|
|
1772
|
+
zIndex: Number,
|
|
1773
|
+
isFull: {
|
|
1774
|
+
type: Boolean,
|
|
1775
|
+
default: false
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
class LoadingProps {
|
|
1779
|
+
constructor() {
|
|
1780
|
+
__publicField(this, "target");
|
|
1781
|
+
__publicField(this, "message");
|
|
1782
|
+
__publicField(this, "loadingTemplateRef");
|
|
1783
|
+
__publicField(this, "backdrop", true);
|
|
1784
|
+
__publicField(this, "positionType", "relative");
|
|
1785
|
+
__publicField(this, "view", new View());
|
|
1786
|
+
__publicField(this, "zIndex");
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
var loading = "";
|
|
1790
|
+
var Loading = defineComponent({
|
|
1791
|
+
name: "DLoading",
|
|
1792
|
+
inheritAttrs: false,
|
|
1793
|
+
props: componentProps,
|
|
1794
|
+
setup(props) {
|
|
1795
|
+
const style = {
|
|
1796
|
+
top: props.view.top,
|
|
1797
|
+
left: props.view.left,
|
|
1798
|
+
zIndex: props.zIndex
|
|
1799
|
+
};
|
|
1800
|
+
if (!props.message) {
|
|
1801
|
+
style.background = "none";
|
|
1802
|
+
}
|
|
1803
|
+
const isShow = ref(false);
|
|
1804
|
+
const open = () => {
|
|
1805
|
+
isShow.value = true;
|
|
1806
|
+
};
|
|
1807
|
+
const close = () => {
|
|
1808
|
+
isShow.value = false;
|
|
1809
|
+
};
|
|
1810
|
+
return {
|
|
1811
|
+
style,
|
|
1812
|
+
isShow,
|
|
1813
|
+
open,
|
|
1814
|
+
close
|
|
1815
|
+
};
|
|
1816
|
+
},
|
|
1817
|
+
render() {
|
|
1818
|
+
var _a;
|
|
1819
|
+
const {
|
|
1820
|
+
isShow,
|
|
1821
|
+
isFull,
|
|
1822
|
+
backdrop,
|
|
1823
|
+
style,
|
|
1824
|
+
message,
|
|
1825
|
+
$slots
|
|
1826
|
+
} = this;
|
|
1827
|
+
return isShow && createVNode("div", {
|
|
1828
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
1829
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
1830
|
+
"class": "devui-loading-wrapper"
|
|
1831
|
+
}, [backdrop ? createVNode("div", {
|
|
1832
|
+
"class": "devui-loading-mask"
|
|
1833
|
+
}, null) : null, createVNode("div", {
|
|
1834
|
+
"style": style,
|
|
1835
|
+
"class": "devui-loading-area"
|
|
1836
|
+
}, [createVNode("div", {
|
|
1837
|
+
"class": "devui-busy-default-spinner"
|
|
1838
|
+
}, [createVNode("div", {
|
|
1839
|
+
"class": "devui-loading-bar1"
|
|
1840
|
+
}, null), createVNode("div", {
|
|
1841
|
+
"class": "devui-loading-bar2"
|
|
1842
|
+
}, null), createVNode("div", {
|
|
1843
|
+
"class": "devui-loading-bar3"
|
|
1844
|
+
}, null), createVNode("div", {
|
|
1845
|
+
"class": "devui-loading-bar4"
|
|
1846
|
+
}, null)]), message ? createVNode("span", {
|
|
1847
|
+
"class": "devui-loading-text"
|
|
1848
|
+
}, [message]) : null])])]);
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
1852
|
+
function createComponent(Component, props, children = null) {
|
|
1853
|
+
const vnode = h(Component, __spreadValues({}, props), children);
|
|
1854
|
+
const container = document.createElement("div");
|
|
1855
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
1856
|
+
render(vnode, container);
|
|
1857
|
+
return vnode.component;
|
|
1858
|
+
}
|
|
1859
|
+
function unmountComponent(ComponnetInstance) {
|
|
1860
|
+
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
1861
|
+
}
|
|
1862
|
+
const loadingConstructor = defineComponent(Loading);
|
|
1863
|
+
const cacheInstance = /* @__PURE__ */ new WeakSet();
|
|
1864
|
+
const isEmpty = (val) => {
|
|
1865
|
+
if (!val)
|
|
1866
|
+
return true;
|
|
1867
|
+
if (Array.isArray(val))
|
|
1868
|
+
return val.length === 0;
|
|
1869
|
+
if (val instanceof Set || val instanceof Map)
|
|
1870
|
+
return val.size === 0;
|
|
1871
|
+
if (val instanceof Promise)
|
|
1872
|
+
return false;
|
|
1873
|
+
if (typeof val === "object") {
|
|
1874
|
+
try {
|
|
1875
|
+
return Object.keys(val).length === 0;
|
|
1876
|
+
} catch (e) {
|
|
1877
|
+
return false;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
return false;
|
|
1881
|
+
};
|
|
1882
|
+
const getType = (vari) => {
|
|
1883
|
+
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
1884
|
+
};
|
|
1885
|
+
const isPromise = (value) => {
|
|
1886
|
+
const type = getType(value);
|
|
1887
|
+
switch (type) {
|
|
1888
|
+
case "promise":
|
|
1889
|
+
return [value];
|
|
1890
|
+
case "array":
|
|
1891
|
+
if (value.some((val) => getType(val) !== "promise")) {
|
|
1892
|
+
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
1893
|
+
return "error";
|
|
1894
|
+
}
|
|
1895
|
+
return value;
|
|
1896
|
+
default:
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
const unmount = (el) => {
|
|
1901
|
+
cacheInstance.delete(el);
|
|
1902
|
+
el.instance.proxy.close();
|
|
1903
|
+
unmountComponent(el.instance);
|
|
1904
|
+
};
|
|
1905
|
+
const toggleLoading = (el, binding) => {
|
|
1906
|
+
if (binding.value) {
|
|
1907
|
+
const vals = isPromise(binding.value);
|
|
1908
|
+
if (vals === "error")
|
|
1909
|
+
return;
|
|
1910
|
+
el.instance.proxy.open();
|
|
1911
|
+
el.appendChild(el.mask);
|
|
1912
|
+
cacheInstance.add(el);
|
|
1913
|
+
if (vals) {
|
|
1914
|
+
Promise.all(vals).catch((err) => {
|
|
1915
|
+
console.error(new Error("Promise handling errors"), err);
|
|
1916
|
+
}).finally(() => {
|
|
1917
|
+
unmount(el);
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
} else {
|
|
1921
|
+
unmount(el);
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
const removeAttribute = (el) => {
|
|
1925
|
+
el.removeAttribute("zindex");
|
|
1926
|
+
el.removeAttribute("positiontype");
|
|
1927
|
+
el.removeAttribute("backdrop");
|
|
1928
|
+
el.removeAttribute("message");
|
|
1929
|
+
el.removeAttribute("view");
|
|
1930
|
+
el.removeAttribute("loadingtemplateref");
|
|
1931
|
+
};
|
|
1932
|
+
const handleProps = (el, vprops) => {
|
|
1933
|
+
const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
|
|
1934
|
+
const loadingTemplateRef = props.loadingTemplateRef;
|
|
1935
|
+
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
1936
|
+
el.style.position = props.positionType;
|
|
1937
|
+
el.options = props;
|
|
1938
|
+
el.instance = loadingInstance;
|
|
1939
|
+
el.mask = loadingInstance.proxy.$el;
|
|
1940
|
+
};
|
|
1941
|
+
const loadingDirective = {
|
|
1942
|
+
mounted: function(el, binding, vnode) {
|
|
1943
|
+
handleProps(el, vnode.props);
|
|
1944
|
+
removeAttribute(el);
|
|
1945
|
+
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
1946
|
+
},
|
|
1947
|
+
updated: function(el, binding, vnode) {
|
|
1948
|
+
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
|
|
1949
|
+
return;
|
|
1950
|
+
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
1951
|
+
removeAttribute(el);
|
|
1952
|
+
toggleLoading(el, binding);
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
defineComponent(Loading);
|
|
1615
1956
|
Table.install = function(app) {
|
|
1957
|
+
app.directive("dLoading", loadingDirective);
|
|
1616
1958
|
app.component(Table.name, Table);
|
|
1617
1959
|
app.component(Column.name, Column);
|
|
1618
1960
|
};
|