vue-devui 1.0.0-beta.8 → 1.0.0-rc.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 +6 -7
- 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/back-top/index.es.js +1 -1
- package/back-top/index.umd.js +1 -1
- package/badge/index.es.js +12 -18
- package/badge/index.umd.js +1 -1
- package/button/index.es.js +262 -82
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/carousel/index.es.js +7 -6
- package/carousel/index.umd.js +1 -1
- package/cascader/index.es.js +5392 -772
- package/cascader/index.umd.js +27 -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.es.js +27 -18
- package/countdown/index.umd.js +1 -1
- package/countdown/style.css +1 -1
- package/date-picker/index.es.js +10 -11
- 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 +169 -223
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +408 -300
- 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 +110 -118
- 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 +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +2 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.es.js +77 -19
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -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 +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/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 +2 -2
- package/modal/index.es.js +293 -759
- 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 +142 -198
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +10 -18
- package/pagination/index.es.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 +5947 -189
- package/popover/index.umd.js +27 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +8 -8
- 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 +5 -5
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/read-tip/index.es.js +17 -4
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/result/index.es.js +2 -1
- package/result/index.umd.js +1 -1
- package/ripple/index.es.js +1 -1
- package/search/index.es.js +5432 -198
- 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/slider/index.es.js +2 -5
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +5881 -36
- 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 +1 -1
- 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/table/index.es.js +698 -358
- 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 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/tag-input/index.es.js +0 -12
- package/tag-input/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/{theme → theme/theme.scss} +0 -0
- package/time-axis/index.es.js +2 -1
- 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 +5775 -192
- 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 +463 -2680
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +14630 -14010
- package/vue-devui.umd.js +18 -18
- 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
|
|
@@ -850,29 +903,44 @@ const overlayProps = {
|
|
|
850
903
|
default: true
|
|
851
904
|
}
|
|
852
905
|
};
|
|
853
|
-
const overlayEmits = ["
|
|
906
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
854
907
|
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
855
908
|
overlayStyle: {
|
|
856
909
|
type: [String, Object],
|
|
857
910
|
default: void 0
|
|
858
911
|
}
|
|
859
912
|
});
|
|
860
|
-
const flexibleOverlayProps =
|
|
913
|
+
const flexibleOverlayProps = {
|
|
914
|
+
modelValue: {
|
|
915
|
+
type: Boolean,
|
|
916
|
+
default: false
|
|
917
|
+
},
|
|
861
918
|
origin: {
|
|
862
919
|
type: Object,
|
|
863
920
|
require: true
|
|
864
921
|
},
|
|
865
922
|
position: {
|
|
866
|
-
type:
|
|
867
|
-
default:
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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
|
|
873
941
|
}
|
|
874
|
-
}
|
|
875
|
-
function useOverlayLogic(props) {
|
|
942
|
+
};
|
|
943
|
+
function useOverlayLogic(props, ctx) {
|
|
876
944
|
const backgroundClass = computed(() => {
|
|
877
945
|
return [
|
|
878
946
|
"devui-overlay-background",
|
|
@@ -884,11 +952,11 @@ function useOverlayLogic(props) {
|
|
|
884
952
|
return "devui-overlay";
|
|
885
953
|
});
|
|
886
954
|
const handleBackdropClick = (event) => {
|
|
887
|
-
var _a
|
|
955
|
+
var _a;
|
|
888
956
|
event.preventDefault();
|
|
889
957
|
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
890
958
|
if (props.backdropClose) {
|
|
891
|
-
(
|
|
959
|
+
ctx.emit("update:visible", false);
|
|
892
960
|
}
|
|
893
961
|
};
|
|
894
962
|
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
@@ -922,7 +990,7 @@ function useOverlayLogic(props) {
|
|
|
922
990
|
handleOverlayBubbleCancel
|
|
923
991
|
};
|
|
924
992
|
}
|
|
925
|
-
|
|
993
|
+
defineComponent({
|
|
926
994
|
name: "DFixedOverlay",
|
|
927
995
|
props: fixedOverlayProps,
|
|
928
996
|
emits: overlayEmits,
|
|
@@ -932,9 +1000,9 @@ const FixedOverlay = defineComponent({
|
|
|
932
1000
|
overlayClass,
|
|
933
1001
|
handleBackdropClick,
|
|
934
1002
|
handleOverlayBubbleCancel
|
|
935
|
-
} = useOverlayLogic(props);
|
|
1003
|
+
} = useOverlayLogic(props, ctx);
|
|
936
1004
|
return () => createVNode(CommonOverlay, null, {
|
|
937
|
-
default: () => [
|
|
1005
|
+
default: () => [props.visible && createVNode("div", {
|
|
938
1006
|
"class": backgroundClass.value,
|
|
939
1007
|
"style": props.backgroundStyle,
|
|
940
1008
|
"onClick": handleBackdropClick
|
|
@@ -942,246 +1010,289 @@ const FixedOverlay = defineComponent({
|
|
|
942
1010
|
"class": overlayClass.value,
|
|
943
1011
|
"style": props.overlayStyle,
|
|
944
1012
|
"onClick": handleOverlayBubbleCancel
|
|
945
|
-
}, [renderSlot(ctx.slots, "default")])])
|
|
1013
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
946
1014
|
});
|
|
947
1015
|
}
|
|
948
1016
|
});
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
position: "absolute"
|
|
957
|
-
});
|
|
958
|
-
onMounted(async () => {
|
|
959
|
-
const handleRectChange = (position, rect, origin) => {
|
|
960
|
-
const point = calculatePosition(position, rect, origin);
|
|
961
|
-
positionedStyle.left = `${point.x}px`;
|
|
962
|
-
positionedStyle.top = `${point.y}px`;
|
|
963
|
-
};
|
|
964
|
-
const locationElements = computed(() => {
|
|
965
|
-
const overlay2 = overlayRef.value;
|
|
966
|
-
const origin = getOrigin(props.origin);
|
|
967
|
-
if (!overlay2 || !origin) {
|
|
968
|
-
return;
|
|
969
|
-
}
|
|
970
|
-
return {
|
|
971
|
-
origin,
|
|
972
|
-
overlay: overlay2
|
|
973
|
-
};
|
|
974
|
-
});
|
|
975
|
-
const visibleRef = toRef(props, "visible");
|
|
976
|
-
const positionRef = toRef(props, "position");
|
|
977
|
-
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
978
|
-
if (!visible || !locationElements2) {
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
const {
|
|
982
|
-
origin,
|
|
983
|
-
overlay: overlay2
|
|
984
|
-
} = locationElements2;
|
|
985
|
-
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
986
|
-
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
987
|
-
onInvalidate(() => {
|
|
988
|
-
unsubscriptions.forEach((fn) => fn());
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
const {
|
|
993
|
-
backgroundClass,
|
|
994
|
-
overlayClass,
|
|
995
|
-
handleBackdropClick,
|
|
996
|
-
handleOverlayBubbleCancel
|
|
997
|
-
} = useOverlayLogic(props);
|
|
998
|
-
return () => createVNode(CommonOverlay, null, {
|
|
999
|
-
default: () => [withDirectives(createVNode("div", {
|
|
1000
|
-
"style": props.backgroundStyle,
|
|
1001
|
-
"class": backgroundClass.value,
|
|
1002
|
-
"onClick": handleBackdropClick
|
|
1003
|
-
}, [createVNode("div", {
|
|
1004
|
-
"ref": overlayRef,
|
|
1005
|
-
"class": overlayClass.value,
|
|
1006
|
-
"style": positionedStyle,
|
|
1007
|
-
"onClick": handleOverlayBubbleCancel
|
|
1008
|
-
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
function getOrigin(origin) {
|
|
1013
|
-
if (origin instanceof Element) {
|
|
1014
|
-
return origin;
|
|
1015
|
-
}
|
|
1016
|
-
if (isRef(origin)) {
|
|
1017
|
-
return getElement(origin.value);
|
|
1018
|
-
}
|
|
1019
|
-
if (isComponent(origin)) {
|
|
1020
|
-
return getElement(origin);
|
|
1021
|
-
}
|
|
1022
|
-
return origin;
|
|
1023
|
-
}
|
|
1024
|
-
function calculatePosition(position, rect, origin) {
|
|
1025
|
-
const originRect = getOriginRect(origin);
|
|
1026
|
-
const originPoint = getOriginRelativePoint(originRect, position);
|
|
1027
|
-
return getOverlayPoint(originPoint, rect, position);
|
|
1028
|
-
}
|
|
1029
|
-
function getOriginRect(origin) {
|
|
1030
|
-
if (origin instanceof Element) {
|
|
1031
|
-
return origin.getBoundingClientRect();
|
|
1032
|
-
}
|
|
1033
|
-
const width = origin.width || 0;
|
|
1034
|
-
const height = origin.height || 0;
|
|
1035
|
-
return {
|
|
1036
|
-
top: origin.y,
|
|
1037
|
-
bottom: origin.y + height,
|
|
1038
|
-
left: origin.x,
|
|
1039
|
-
right: origin.x + width,
|
|
1040
|
-
height,
|
|
1041
|
-
width
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
function getOverlayPoint(originPoint, rect, position) {
|
|
1045
|
-
let x;
|
|
1046
|
-
const {
|
|
1047
|
-
width,
|
|
1048
|
-
height
|
|
1049
|
-
} = rect;
|
|
1050
|
-
if (position.overlayX == "center") {
|
|
1051
|
-
x = originPoint.x - width / 2;
|
|
1052
|
-
} else {
|
|
1053
|
-
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
1054
|
-
}
|
|
1055
|
-
let y;
|
|
1056
|
-
if (position.overlayY == "center") {
|
|
1057
|
-
y = originPoint.y - height / 2;
|
|
1058
|
-
} else {
|
|
1059
|
-
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
|
+
}
|
|
1060
1024
|
}
|
|
1061
|
-
return
|
|
1062
|
-
x,
|
|
1063
|
-
y
|
|
1064
|
-
};
|
|
1025
|
+
return window;
|
|
1065
1026
|
}
|
|
1066
|
-
function
|
|
1067
|
-
let x;
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
x
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
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
|
+
}
|
|
1080
1043
|
}
|
|
1081
|
-
return {
|
|
1082
|
-
x,
|
|
1083
|
-
y
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
function subscribeLayoutEvent(event) {
|
|
1087
|
-
window.addEventListener("scroll", event, true);
|
|
1088
|
-
window.addEventListener("resize", event);
|
|
1089
|
-
window.addEventListener("orientationchange", event);
|
|
1090
|
-
return () => {
|
|
1091
|
-
window.removeEventListener("scroll", event, true);
|
|
1092
|
-
window.removeEventListener("resize", event);
|
|
1093
|
-
window.removeEventListener("orientationchange", event);
|
|
1094
|
-
};
|
|
1044
|
+
return { x, y };
|
|
1095
1045
|
}
|
|
1096
|
-
function
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
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
|
+
});
|
|
1103
1064
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
|
|
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
|
|
1110
1080
|
});
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1081
|
+
emit("positionChange", placement);
|
|
1082
|
+
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
1083
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
1114
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 };
|
|
1115
1105
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
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
|
+
});
|
|
1122
1133
|
var dropdown = "";
|
|
1134
|
+
let dropdownId = 1;
|
|
1123
1135
|
var Dropdown = defineComponent({
|
|
1124
1136
|
name: "DDropdown",
|
|
1137
|
+
inheritAttrs: false,
|
|
1125
1138
|
props: dropdownProps,
|
|
1126
|
-
emits: [],
|
|
1127
|
-
setup(props,
|
|
1139
|
+
emits: ["toggle"],
|
|
1140
|
+
setup(props, {
|
|
1141
|
+
slots,
|
|
1142
|
+
attrs,
|
|
1143
|
+
emit
|
|
1144
|
+
}) {
|
|
1128
1145
|
const {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
closeOnMouseLeaveMenu
|
|
1146
|
+
visible,
|
|
1147
|
+
position,
|
|
1148
|
+
align,
|
|
1149
|
+
offset: offset2
|
|
1134
1150
|
} = toRefs(props);
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
originX: "center",
|
|
1143
|
-
originY: "bottom",
|
|
1144
|
-
overlayX: "center",
|
|
1145
|
-
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";
|
|
1146
1158
|
};
|
|
1147
|
-
const {
|
|
1148
|
-
|
|
1149
|
-
}
|
|
1150
|
-
|
|
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,
|
|
1151
1169
|
origin,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
});
|
|
1156
|
-
const animatedVisible = computed(() => {
|
|
1157
|
-
return props.showAnimation ? visible.value : true;
|
|
1170
|
+
dropdownRef,
|
|
1171
|
+
props,
|
|
1172
|
+
emit
|
|
1158
1173
|
});
|
|
1174
|
+
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
1159
1175
|
return () => {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
"
|
|
1163
|
-
"
|
|
1164
|
-
|
|
1165
|
-
"
|
|
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"
|
|
1166
1182
|
}, {
|
|
1167
1183
|
default: () => [createVNode(Transition, {
|
|
1168
|
-
"name":
|
|
1184
|
+
"name": `devui-dropdown-fade-${currentPosition.value}`
|
|
1169
1185
|
}, {
|
|
1170
|
-
default: () => {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
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
|
+
})]
|
|
1177
1205
|
})]
|
|
1178
1206
|
})]);
|
|
1179
1207
|
};
|
|
1180
1208
|
}
|
|
1181
1209
|
});
|
|
1182
|
-
|
|
1183
|
-
|
|
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
|
+
}
|
|
1184
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
|
+
});
|
|
1185
1296
|
var filter = "";
|
|
1186
1297
|
const Filter = defineComponent({
|
|
1187
1298
|
props: {
|
|
@@ -1415,48 +1526,74 @@ const TD = defineComponent({
|
|
|
1415
1526
|
}, [column.value.renderCell(props.row, props.index)]);
|
|
1416
1527
|
}
|
|
1417
1528
|
});
|
|
1418
|
-
var
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
} = useTable(props);
|
|
1431
|
-
const isEmpty = computed(() => props.data.length === 0);
|
|
1432
|
-
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 () => {
|
|
1433
1541
|
return createVNode("div", {
|
|
1434
1542
|
"class": "devui-table-view"
|
|
1435
1543
|
}, [createVNode("div", {
|
|
1436
|
-
"style": "overflow:
|
|
1544
|
+
"style": "overflow:hidden scroll;"
|
|
1437
1545
|
}, [createVNode("table", {
|
|
1438
|
-
"class": classes
|
|
1546
|
+
"class": props.classes,
|
|
1439
1547
|
"cellpadding": "0",
|
|
1440
1548
|
"cellspacing": "0"
|
|
1441
1549
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
|
|
1442
1550
|
"class": "scroll-view"
|
|
1443
1551
|
}, [createVNode("table", {
|
|
1444
|
-
"class": classes
|
|
1552
|
+
"class": props.classes,
|
|
1445
1553
|
"cellpadding": "0",
|
|
1446
1554
|
"cellspacing": "0"
|
|
1447
|
-
}, [createVNode(ColGroup, null, null), !isEmpty
|
|
1555
|
+
}, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
|
|
1448
1556
|
"style": "flex: 1"
|
|
1449
1557
|
}, null)])])]);
|
|
1450
|
-
}
|
|
1451
|
-
|
|
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 () => {
|
|
1452
1573
|
return createVNode("table", {
|
|
1453
|
-
"class": classes
|
|
1574
|
+
"class": props.classes,
|
|
1454
1575
|
"cellpadding": "0",
|
|
1455
1576
|
"cellspacing": "0"
|
|
1456
1577
|
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
|
|
1457
|
-
"style": "position:
|
|
1458
|
-
}, null), !isEmpty
|
|
1459
|
-
}
|
|
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);
|
|
1460
1597
|
ctx.expose({
|
|
1461
1598
|
getCheckedRows() {
|
|
1462
1599
|
return store.getCheckedRows();
|
|
@@ -1465,7 +1602,13 @@ var Table = defineComponent({
|
|
|
1465
1602
|
return () => withDirectives(createVNode("div", {
|
|
1466
1603
|
"class": "devui-table-wrapper",
|
|
1467
1604
|
"style": style.value
|
|
1468
|
-
}, [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", {
|
|
1469
1612
|
"class": "devui-table-empty"
|
|
1470
1613
|
}, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
|
|
1471
1614
|
}
|
|
@@ -1530,6 +1673,9 @@ function formatWidth(width) {
|
|
|
1530
1673
|
function formatMinWidth(minWidth) {
|
|
1531
1674
|
return formatWidth(minWidth) || 80;
|
|
1532
1675
|
}
|
|
1676
|
+
function defaultRenderHeader() {
|
|
1677
|
+
return h("span", { class: "title" }, this.header);
|
|
1678
|
+
}
|
|
1533
1679
|
function createColumn(props, templates) {
|
|
1534
1680
|
const {
|
|
1535
1681
|
field,
|
|
@@ -1547,31 +1693,38 @@ function createColumn(props, templates) {
|
|
|
1547
1693
|
fixedRight
|
|
1548
1694
|
} = props;
|
|
1549
1695
|
const column = reactive({});
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
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;
|
|
1554
1711
|
}, { immediate: true });
|
|
1555
|
-
watch([sortable, compareFn], ([
|
|
1556
|
-
column.sortable =
|
|
1557
|
-
column.compareFn =
|
|
1712
|
+
watch([sortable, compareFn], ([sortableVal, compareFnVal]) => {
|
|
1713
|
+
column.sortable = sortableVal;
|
|
1714
|
+
column.compareFn = compareFnVal;
|
|
1558
1715
|
});
|
|
1559
|
-
watch([
|
|
1560
|
-
filterable
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
], ([filterable2, filterList2, filterMultiple2]) => {
|
|
1564
|
-
column.filterable = filterable2;
|
|
1565
|
-
column.filterMultiple = filterMultiple2;
|
|
1566
|
-
column.filterList = filterList2;
|
|
1716
|
+
watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
|
|
1717
|
+
column.filterable = filterableVal;
|
|
1718
|
+
column.filterMultiple = filterMultipleVal;
|
|
1719
|
+
column.filterList = filterListVal;
|
|
1567
1720
|
}, { immediate: true });
|
|
1568
1721
|
watch([fixedLeft, fixedRight], ([left, right]) => {
|
|
1569
1722
|
column.fixedLeft = left;
|
|
1570
1723
|
column.fixedRight = right;
|
|
1571
1724
|
}, { immediate: true });
|
|
1572
|
-
watch([width, minWidth], ([
|
|
1573
|
-
column.width = formatWidth(
|
|
1574
|
-
column.minWidth = formatMinWidth(
|
|
1725
|
+
watch([width, minWidth], ([widthVal, minWidthVal]) => {
|
|
1726
|
+
column.width = formatWidth(widthVal);
|
|
1727
|
+
column.minWidth = formatMinWidth(minWidthVal);
|
|
1575
1728
|
column.realWidth = column.width || column.minWidth;
|
|
1576
1729
|
});
|
|
1577
1730
|
onBeforeMount(() => {
|
|
@@ -1583,17 +1736,6 @@ function createColumn(props, templates) {
|
|
|
1583
1736
|
});
|
|
1584
1737
|
return column;
|
|
1585
1738
|
}
|
|
1586
|
-
function defaultRenderHeader() {
|
|
1587
|
-
return h("span", { class: "title" }, this.header);
|
|
1588
|
-
}
|
|
1589
|
-
function defaultRenderCell(rowData, index2) {
|
|
1590
|
-
var _a, _b;
|
|
1591
|
-
const value = rowData[this.field];
|
|
1592
|
-
if (this.formatter) {
|
|
1593
|
-
return this.formatter(rowData, value, index2);
|
|
1594
|
-
}
|
|
1595
|
-
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1596
|
-
}
|
|
1597
1739
|
var Column = defineComponent({
|
|
1598
1740
|
name: "DColumn",
|
|
1599
1741
|
props: TableColumnProps,
|
|
@@ -1614,7 +1756,205 @@ var Column = defineComponent({
|
|
|
1614
1756
|
return null;
|
|
1615
1757
|
}
|
|
1616
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);
|
|
1617
1956
|
Table.install = function(app) {
|
|
1957
|
+
app.directive("dLoading", loadingDirective);
|
|
1618
1958
|
app.component(Table.name, Table);
|
|
1619
1959
|
app.component(Column.name, Column);
|
|
1620
1960
|
};
|