vue-devui 1.0.0-alpha.6 → 1.0.0-beta.12
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 +32 -35
- package/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +508 -1
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +178 -1
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/anchor/index.es.js +263 -1
- package/anchor/index.umd.js +1 -1
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +301 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +95 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/index.es.js +127 -1
- package/breadcrumb/index.umd.js +1 -1
- package/button/index.d.ts +7 -0
- package/button/index.es.js +392 -1
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +61 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +329 -1
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1343 -1
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +377 -1
- package/checkbox/index.umd.js +1 -1
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- 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.d.ts +7 -0
- package/date-picker/index.es.js +1172 -1
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +32 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +287 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +535 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5857 -1
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2244 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +163 -1
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +75 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +498 -1
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +190 -1
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +240 -1
- package/input-number/index.umd.js +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +100 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +256 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +1225 -1
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nav-sprite/index.es.js +742 -0
- package/nav-sprite/index.umd.js +1 -0
- package/nav-sprite/package.json +7 -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/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/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.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/Dropdown.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/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/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/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/Toast.js +3 -0
- package/nuxt/components/ToastService.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/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +368 -1
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +6 -47
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +642 -1
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +205 -1
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +236 -1
- package/popover/index.umd.js +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +153 -1
- package/progress/index.umd.js +3 -1
- package/quadrant-diagram/index.d.ts +7 -0
- package/quadrant-diagram/index.es.js +489 -1
- package/quadrant-diagram/index.umd.js +1 -1
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +225 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +220 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- 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.d.ts +7 -0
- package/ripple/index.es.js +181 -1
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +543 -1
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +706 -1
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +297 -1
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +199 -1
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +636 -1
- package/splitter/index.umd.js +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +42 -1
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +239 -1
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/sticky/index.es.js +197 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +100 -1
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1836 -1
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +195 -1
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +329 -1
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +299 -0
- package/time-axis/index.umd.js +1 -0
- package/time-axis/package.json +7 -0
- package/time-axis/style.css +1 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +1260 -1
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +2060 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +171 -1
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +1725 -1
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +907 -1
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +2834 -1
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +27777 -1
- package/vue-devui.umd.js +29 -1
package/table/index.es.js
CHANGED
|
@@ -1 +1,1836 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
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, Teleport, Transition, renderSlot, isVNode, onMounted, onUnmounted, withDirectives, vShow, reactive, isRef, toRefs, Fragment, shallowRef, getCurrentInstance, createTextVNode, resolveDirective, onBeforeMount, h, onBeforeUnmount, render } from "vue";
|
|
25
|
+
const TableProps = {
|
|
26
|
+
data: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: []
|
|
29
|
+
},
|
|
30
|
+
striped: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
scrollable: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
maxWidth: {
|
|
39
|
+
type: String
|
|
40
|
+
},
|
|
41
|
+
maxHeight: {
|
|
42
|
+
type: String
|
|
43
|
+
},
|
|
44
|
+
tableWidth: {
|
|
45
|
+
type: String
|
|
46
|
+
},
|
|
47
|
+
tableHeight: {
|
|
48
|
+
type: String
|
|
49
|
+
},
|
|
50
|
+
size: {
|
|
51
|
+
type: String,
|
|
52
|
+
validator(value) {
|
|
53
|
+
return value === "sm" || value === "md" || value === "lg";
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
rowHoveredHighlight: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
fixHeader: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false
|
|
63
|
+
},
|
|
64
|
+
checkable: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: true
|
|
67
|
+
},
|
|
68
|
+
tableLayout: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: "auto",
|
|
71
|
+
validator(v) {
|
|
72
|
+
return v === "fixed" || v === "auto";
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
showLoading: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
headerBg: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const TABLE_TOKEN = Symbol();
|
|
85
|
+
function useTable(props) {
|
|
86
|
+
const classes = computed(() => ({
|
|
87
|
+
"devui-table": true,
|
|
88
|
+
"devui-table-striped": props.striped,
|
|
89
|
+
"header-bg": props.headerBg,
|
|
90
|
+
"table-layout-auto": props.tableLayout === "auto"
|
|
91
|
+
}));
|
|
92
|
+
const style = computed(() => ({
|
|
93
|
+
maxHeight: props.maxHeight,
|
|
94
|
+
maxWidth: props.maxWidth,
|
|
95
|
+
height: props.tableHeight,
|
|
96
|
+
width: props.tableWidth
|
|
97
|
+
}));
|
|
98
|
+
return { classes, style };
|
|
99
|
+
}
|
|
100
|
+
const useFixedColumn = (column) => {
|
|
101
|
+
const stickyCell = computed(() => {
|
|
102
|
+
const col = column.value;
|
|
103
|
+
if (col.fixedLeft) {
|
|
104
|
+
return `devui-sticky-cell left`;
|
|
105
|
+
}
|
|
106
|
+
if (col.fixedRight) {
|
|
107
|
+
return `devui-sticky-cell right`;
|
|
108
|
+
}
|
|
109
|
+
return void 0;
|
|
110
|
+
});
|
|
111
|
+
const offsetStyle = computed(() => {
|
|
112
|
+
const col = column.value;
|
|
113
|
+
if (col.fixedLeft) {
|
|
114
|
+
return `left:${col.fixedLeft}`;
|
|
115
|
+
}
|
|
116
|
+
if (col.fixedRight) {
|
|
117
|
+
return `right:${col.fixedRight}`;
|
|
118
|
+
}
|
|
119
|
+
return void 0;
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
stickyCell,
|
|
123
|
+
offsetStyle
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
function createStore(dataSource) {
|
|
127
|
+
const _data = ref([]);
|
|
128
|
+
watch(dataSource, (value) => {
|
|
129
|
+
_data.value = [...value];
|
|
130
|
+
}, { deep: true, immediate: true });
|
|
131
|
+
const { _columns, insertColumn, removeColumn, sortColumn } = createColumnGenerator();
|
|
132
|
+
const { _checkAll, _checkList, _halfChecked, getCheckedRows } = createSelection(dataSource, _data);
|
|
133
|
+
const { sortData } = createSorter(dataSource, _data);
|
|
134
|
+
const { filterData, resetFilterData } = createFilter(dataSource, _data);
|
|
135
|
+
const { isFixedLeft } = createFixedLogic(_columns);
|
|
136
|
+
return {
|
|
137
|
+
states: {
|
|
138
|
+
_data,
|
|
139
|
+
_columns,
|
|
140
|
+
_checkList,
|
|
141
|
+
_checkAll,
|
|
142
|
+
_halfChecked,
|
|
143
|
+
isFixedLeft
|
|
144
|
+
},
|
|
145
|
+
insertColumn,
|
|
146
|
+
sortColumn,
|
|
147
|
+
removeColumn,
|
|
148
|
+
getCheckedRows,
|
|
149
|
+
sortData,
|
|
150
|
+
filterData,
|
|
151
|
+
resetFilterData
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const createColumnGenerator = () => {
|
|
155
|
+
const _columns = ref([]);
|
|
156
|
+
const insertColumn = (column) => {
|
|
157
|
+
_columns.value.push(column);
|
|
158
|
+
_columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
|
|
159
|
+
};
|
|
160
|
+
const sortColumn = () => {
|
|
161
|
+
_columns.value.sort((a, b) => a.order > b.order ? 1 : -1);
|
|
162
|
+
};
|
|
163
|
+
const removeColumn = (column) => {
|
|
164
|
+
const i = _columns.value.findIndex((v) => v === column);
|
|
165
|
+
if (i === -1) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
_columns.value.splice(i, 1);
|
|
169
|
+
};
|
|
170
|
+
return { _columns, insertColumn, removeColumn, sortColumn };
|
|
171
|
+
};
|
|
172
|
+
const createSelection = (dataSource, _data) => {
|
|
173
|
+
const _checkList = ref([]);
|
|
174
|
+
const _checkAllRecord = ref(false);
|
|
175
|
+
const _checkAll = computed({
|
|
176
|
+
get: () => _checkAllRecord.value,
|
|
177
|
+
set: (val) => {
|
|
178
|
+
_checkAllRecord.value = val;
|
|
179
|
+
for (let i = 0; i < _checkList.value.length; i++) {
|
|
180
|
+
_checkList.value[i] = val;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const _halfChecked = ref(false);
|
|
185
|
+
watch(dataSource, (value) => {
|
|
186
|
+
_checkList.value = new Array(value.length).fill(false);
|
|
187
|
+
}, { deep: true, immediate: true });
|
|
188
|
+
watch(_checkList, (list) => {
|
|
189
|
+
if (list.length === 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
let allTrue = true;
|
|
193
|
+
let allFalse = true;
|
|
194
|
+
for (let i = 0; i < list.length; i++) {
|
|
195
|
+
allTrue && (allTrue = list[i]);
|
|
196
|
+
allFalse && (allFalse = !list[i]);
|
|
197
|
+
}
|
|
198
|
+
_checkAllRecord.value = allTrue;
|
|
199
|
+
_halfChecked.value = !(allFalse || allTrue);
|
|
200
|
+
}, { immediate: true, deep: true });
|
|
201
|
+
const getCheckedRows = () => {
|
|
202
|
+
return _data.value.filter((_, index2) => _checkList.value[index2]);
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
_checkList,
|
|
206
|
+
_checkAll,
|
|
207
|
+
_halfChecked,
|
|
208
|
+
getCheckedRows
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
const createSorter = (dataSource, _data) => {
|
|
212
|
+
const sortData = (field, direction, compareFn = (field2, a, b) => a[field2] > b[field2]) => {
|
|
213
|
+
if (direction === "ASC") {
|
|
214
|
+
_data.value = _data.value.sort((a, b) => compareFn(field, a, b) ? 1 : -1);
|
|
215
|
+
} else if (direction === "DESC") {
|
|
216
|
+
_data.value = _data.value.sort((a, b) => !compareFn(field, a, b) ? 1 : -1);
|
|
217
|
+
} else {
|
|
218
|
+
_data.value = [...dataSource.value];
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
return { sortData };
|
|
222
|
+
};
|
|
223
|
+
const createFilter = (dataSource, _data) => {
|
|
224
|
+
const fieldSet = new Set();
|
|
225
|
+
const filterData = (field, results) => {
|
|
226
|
+
fieldSet.add(field);
|
|
227
|
+
const fields = [...fieldSet];
|
|
228
|
+
_data.value = dataSource.value.filter((item) => {
|
|
229
|
+
return fields.reduce((prev, field2) => {
|
|
230
|
+
return prev && results.indexOf(item[field2]) !== -1;
|
|
231
|
+
}, true);
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
const resetFilterData = () => {
|
|
235
|
+
fieldSet.clear();
|
|
236
|
+
_data.value = [...dataSource.value];
|
|
237
|
+
};
|
|
238
|
+
return { filterData, resetFilterData };
|
|
239
|
+
};
|
|
240
|
+
const createFixedLogic = (columns) => {
|
|
241
|
+
const isFixedLeft = computed(() => {
|
|
242
|
+
return columns.value.reduce((prev, current) => prev || !!current.fixedLeft, false);
|
|
243
|
+
});
|
|
244
|
+
return { isFixedLeft };
|
|
245
|
+
};
|
|
246
|
+
var ColGroup = defineComponent({
|
|
247
|
+
name: "DColGroup",
|
|
248
|
+
setup() {
|
|
249
|
+
const parent = inject(TABLE_TOKEN);
|
|
250
|
+
const columns = parent.store.states._columns;
|
|
251
|
+
return () => parent.props.tableLayout === "fixed" ? createVNode("colgroup", null, [parent.props.checkable ? createVNode("col", {
|
|
252
|
+
"width": 36
|
|
253
|
+
}, null) : null, columns.value.map((column, index2) => {
|
|
254
|
+
return createVNode("col", {
|
|
255
|
+
"key": index2,
|
|
256
|
+
"width": column.realWidth
|
|
257
|
+
}, null);
|
|
258
|
+
})]) : null;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
var checkbox = "";
|
|
262
|
+
const commonProps = {
|
|
263
|
+
name: {
|
|
264
|
+
type: String,
|
|
265
|
+
default: void 0
|
|
266
|
+
},
|
|
267
|
+
halfchecked: {
|
|
268
|
+
type: Boolean,
|
|
269
|
+
default: false
|
|
270
|
+
},
|
|
271
|
+
isShowTitle: {
|
|
272
|
+
type: Boolean,
|
|
273
|
+
default: true
|
|
274
|
+
},
|
|
275
|
+
title: {
|
|
276
|
+
type: String
|
|
277
|
+
},
|
|
278
|
+
color: {
|
|
279
|
+
type: String,
|
|
280
|
+
default: void 0
|
|
281
|
+
},
|
|
282
|
+
showAnimation: {
|
|
283
|
+
type: Boolean,
|
|
284
|
+
default: true
|
|
285
|
+
},
|
|
286
|
+
disabled: {
|
|
287
|
+
type: Boolean,
|
|
288
|
+
default: false
|
|
289
|
+
},
|
|
290
|
+
beforeChange: {
|
|
291
|
+
type: Function,
|
|
292
|
+
default: void 0
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
296
|
+
halfchecked: {
|
|
297
|
+
type: Boolean,
|
|
298
|
+
default: false
|
|
299
|
+
},
|
|
300
|
+
checked: {
|
|
301
|
+
type: Boolean,
|
|
302
|
+
default: false
|
|
303
|
+
},
|
|
304
|
+
value: {
|
|
305
|
+
type: String
|
|
306
|
+
},
|
|
307
|
+
label: {
|
|
308
|
+
type: String,
|
|
309
|
+
default: void 0
|
|
310
|
+
},
|
|
311
|
+
title: {
|
|
312
|
+
type: String,
|
|
313
|
+
default: void 0
|
|
314
|
+
},
|
|
315
|
+
"onUpdate:checked": {
|
|
316
|
+
type: Function,
|
|
317
|
+
default: void 0
|
|
318
|
+
},
|
|
319
|
+
onChange: {
|
|
320
|
+
type: Function,
|
|
321
|
+
default: void 0
|
|
322
|
+
},
|
|
323
|
+
modelValue: {
|
|
324
|
+
type: Boolean
|
|
325
|
+
},
|
|
326
|
+
"onUpdate:modelValue": {
|
|
327
|
+
type: Function
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
331
|
+
modelValue: {
|
|
332
|
+
type: Array,
|
|
333
|
+
required: true
|
|
334
|
+
},
|
|
335
|
+
direction: {
|
|
336
|
+
type: String,
|
|
337
|
+
default: "column"
|
|
338
|
+
},
|
|
339
|
+
itemWidth: {
|
|
340
|
+
type: Number,
|
|
341
|
+
default: void 0
|
|
342
|
+
},
|
|
343
|
+
options: {
|
|
344
|
+
type: Array,
|
|
345
|
+
default: () => []
|
|
346
|
+
},
|
|
347
|
+
onChange: {
|
|
348
|
+
type: Function,
|
|
349
|
+
default: void 0
|
|
350
|
+
},
|
|
351
|
+
"onUpdate:modelValue": {
|
|
352
|
+
type: Function,
|
|
353
|
+
default: void 0
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
|
|
357
|
+
var Checkbox = defineComponent({
|
|
358
|
+
name: "DCheckbox",
|
|
359
|
+
props: checkboxProps,
|
|
360
|
+
emits: ["change", "update:checked", "update:modelValue"],
|
|
361
|
+
setup(props, ctx) {
|
|
362
|
+
const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
|
|
363
|
+
const isChecked = computed(() => props.checked || props.modelValue);
|
|
364
|
+
const mergedDisabled = computed(() => {
|
|
365
|
+
return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
|
|
366
|
+
});
|
|
367
|
+
const mergedChecked = computed(() => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
|
|
370
|
+
});
|
|
371
|
+
const mergedIsShowTitle = computed(() => {
|
|
372
|
+
var _a;
|
|
373
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
374
|
+
});
|
|
375
|
+
const mergedShowAnimation = computed(() => {
|
|
376
|
+
var _a;
|
|
377
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
378
|
+
});
|
|
379
|
+
const mergedColor = computed(() => {
|
|
380
|
+
var _a;
|
|
381
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
382
|
+
});
|
|
383
|
+
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
384
|
+
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
385
|
+
const canChange = (isChecked2, val) => {
|
|
386
|
+
var _a;
|
|
387
|
+
if (mergedDisabled.value) {
|
|
388
|
+
return Promise.resolve(false);
|
|
389
|
+
}
|
|
390
|
+
const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
|
|
391
|
+
if (beforeChange) {
|
|
392
|
+
const res = beforeChange(isChecked2, val);
|
|
393
|
+
if (typeof res === "boolean") {
|
|
394
|
+
return Promise.resolve(res);
|
|
395
|
+
}
|
|
396
|
+
return res;
|
|
397
|
+
}
|
|
398
|
+
return Promise.resolve(true);
|
|
399
|
+
};
|
|
400
|
+
const toggle = () => {
|
|
401
|
+
const current = !isChecked.value;
|
|
402
|
+
checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
|
|
403
|
+
ctx.emit("update:checked", current);
|
|
404
|
+
ctx.emit("update:modelValue", current);
|
|
405
|
+
ctx.emit("change", current);
|
|
406
|
+
};
|
|
407
|
+
const handleClick = () => {
|
|
408
|
+
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
itemWidth,
|
|
412
|
+
direction,
|
|
413
|
+
mergedColor,
|
|
414
|
+
mergedDisabled,
|
|
415
|
+
mergedIsShowTitle,
|
|
416
|
+
mergedChecked,
|
|
417
|
+
mergedShowAnimation,
|
|
418
|
+
handleClick
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
render() {
|
|
422
|
+
var _a;
|
|
423
|
+
const {
|
|
424
|
+
itemWidth,
|
|
425
|
+
direction,
|
|
426
|
+
mergedChecked,
|
|
427
|
+
mergedDisabled,
|
|
428
|
+
mergedIsShowTitle,
|
|
429
|
+
mergedShowAnimation,
|
|
430
|
+
halfchecked,
|
|
431
|
+
title,
|
|
432
|
+
label,
|
|
433
|
+
handleClick,
|
|
434
|
+
name,
|
|
435
|
+
value,
|
|
436
|
+
mergedColor,
|
|
437
|
+
$slots
|
|
438
|
+
} = this;
|
|
439
|
+
const wrapperCls = {
|
|
440
|
+
"devui-checkbox-column-margin": direction === "column",
|
|
441
|
+
"devui-checkbox-wrap": typeof itemWidth !== "undefined"
|
|
442
|
+
};
|
|
443
|
+
const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
|
|
444
|
+
const checkboxCls = {
|
|
445
|
+
"devui-checkbox": true,
|
|
446
|
+
active: mergedChecked,
|
|
447
|
+
halfchecked,
|
|
448
|
+
disabled: mergedDisabled,
|
|
449
|
+
unchecked: !mergedChecked
|
|
450
|
+
};
|
|
451
|
+
const labelTitle = mergedIsShowTitle ? title || label : "";
|
|
452
|
+
const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
|
|
453
|
+
const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
|
|
454
|
+
const spanCls = {
|
|
455
|
+
"devui-checkbox-material": true,
|
|
456
|
+
"custom-color": mergedColor,
|
|
457
|
+
"devui-checkbox-no-label": !label && !$slots.default,
|
|
458
|
+
"devui-no-animation": !mergedShowAnimation,
|
|
459
|
+
"devui-checkbox-default-background": !halfchecked
|
|
460
|
+
};
|
|
461
|
+
const polygonCls = {
|
|
462
|
+
"devui-tick": true,
|
|
463
|
+
"devui-no-animation": !mergedShowAnimation
|
|
464
|
+
};
|
|
465
|
+
const stopPropagation = ($event) => $event.stopPropagation();
|
|
466
|
+
const inputProps = {
|
|
467
|
+
indeterminate: halfchecked
|
|
468
|
+
};
|
|
469
|
+
return createVNode("div", {
|
|
470
|
+
"class": wrapperCls,
|
|
471
|
+
"style": wrapperStyle
|
|
472
|
+
}, [createVNode("div", {
|
|
473
|
+
"class": checkboxCls
|
|
474
|
+
}, [createVNode("label", {
|
|
475
|
+
"title": labelTitle,
|
|
476
|
+
"onClick": handleClick
|
|
477
|
+
}, [createVNode("input", mergeProps({
|
|
478
|
+
"name": name || value,
|
|
479
|
+
"class": "devui-checkbox-input",
|
|
480
|
+
"type": "checkbox"
|
|
481
|
+
}, inputProps, {
|
|
482
|
+
"checked": mergedChecked,
|
|
483
|
+
"disabled": mergedDisabled,
|
|
484
|
+
"onClick": stopPropagation,
|
|
485
|
+
"onChange": stopPropagation
|
|
486
|
+
}), null), createVNode("span", {
|
|
487
|
+
"style": spanStyle,
|
|
488
|
+
"class": spanCls
|
|
489
|
+
}, [createVNode("span", {
|
|
490
|
+
"class": "devui-checkbox-halfchecked-bg"
|
|
491
|
+
}, null), createVNode("svg", {
|
|
492
|
+
"viewBox": "0 0 16 16",
|
|
493
|
+
"version": "1.1",
|
|
494
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
495
|
+
"class": "devui-checkbox-tick"
|
|
496
|
+
}, [createVNode("g", {
|
|
497
|
+
"stroke": "none",
|
|
498
|
+
"stroke-width": "1",
|
|
499
|
+
"fill": "none",
|
|
500
|
+
"fill-rule": "evenodd"
|
|
501
|
+
}, [createVNode("polygon", {
|
|
502
|
+
"fill-rule": "nonzero",
|
|
503
|
+
"points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
|
|
504
|
+
"class": polygonCls
|
|
505
|
+
}, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
var checkboxGroup = "";
|
|
509
|
+
var CheckboxGroup = defineComponent({
|
|
510
|
+
name: "DCheckboxGroup",
|
|
511
|
+
props: checkboxGroupProps,
|
|
512
|
+
emits: ["change", "update:modelValue"],
|
|
513
|
+
setup(props, ctx) {
|
|
514
|
+
const valList = toRef(props, "modelValue");
|
|
515
|
+
const defaultOpt = {
|
|
516
|
+
checked: false,
|
|
517
|
+
isShowTitle: true,
|
|
518
|
+
halfchecked: false,
|
|
519
|
+
showAnimation: true,
|
|
520
|
+
disabled: false
|
|
521
|
+
};
|
|
522
|
+
const toggleGroupVal = (val) => {
|
|
523
|
+
let index2 = -1;
|
|
524
|
+
if (typeof valList.value[0] === "string") {
|
|
525
|
+
index2 = valList.value.findIndex((item) => item === val);
|
|
526
|
+
} else if (typeof valList.value[0] === "object") {
|
|
527
|
+
index2 = valList.value.findIndex((item) => item.value === val);
|
|
528
|
+
}
|
|
529
|
+
if (index2 === -1) {
|
|
530
|
+
if (typeof props.options[0] === "object") {
|
|
531
|
+
const newOne = props.options.find((item) => item.value === val);
|
|
532
|
+
const res2 = [...valList.value, newOne];
|
|
533
|
+
ctx.emit("update:modelValue", res2);
|
|
534
|
+
ctx.emit("change", res2);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const res = [...valList.value, val];
|
|
538
|
+
ctx.emit("update:modelValue", res);
|
|
539
|
+
ctx.emit("change", res);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
valList.value.splice(index2, 1);
|
|
543
|
+
ctx.emit("update:modelValue", valList.value);
|
|
544
|
+
ctx.emit("change", valList.value);
|
|
545
|
+
};
|
|
546
|
+
const isItemChecked = (itemVal) => {
|
|
547
|
+
if (typeof valList.value[0] === "string") {
|
|
548
|
+
return valList.value.includes(itemVal);
|
|
549
|
+
} else if (typeof valList.value[0] === "object") {
|
|
550
|
+
return valList.value.some((item) => item.value === itemVal);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
provide(checkboxGroupInjectionKey, {
|
|
554
|
+
disabled: toRef(props, "disabled"),
|
|
555
|
+
isShowTitle: toRef(props, "isShowTitle"),
|
|
556
|
+
color: toRef(props, "color"),
|
|
557
|
+
showAnimation: toRef(props, "showAnimation"),
|
|
558
|
+
beforeChange: props.beforeChange,
|
|
559
|
+
isItemChecked,
|
|
560
|
+
toggleGroupVal,
|
|
561
|
+
itemWidth: toRef(props, "itemWidth"),
|
|
562
|
+
direction: toRef(props, "direction")
|
|
563
|
+
});
|
|
564
|
+
return {
|
|
565
|
+
defaultOpt
|
|
566
|
+
};
|
|
567
|
+
},
|
|
568
|
+
render() {
|
|
569
|
+
var _a;
|
|
570
|
+
const {
|
|
571
|
+
direction,
|
|
572
|
+
$slots,
|
|
573
|
+
defaultOpt,
|
|
574
|
+
options
|
|
575
|
+
} = this;
|
|
576
|
+
let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
|
|
577
|
+
if ((options == null ? void 0 : options.length) > 0) {
|
|
578
|
+
children = options.map((opt) => {
|
|
579
|
+
let mergedOpt = null;
|
|
580
|
+
if (typeof opt === "string") {
|
|
581
|
+
mergedOpt = Object.assign({}, defaultOpt, {
|
|
582
|
+
label: opt,
|
|
583
|
+
value: opt
|
|
584
|
+
});
|
|
585
|
+
} else if (typeof opt === "object") {
|
|
586
|
+
mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
|
|
587
|
+
label: opt.name
|
|
588
|
+
}));
|
|
589
|
+
}
|
|
590
|
+
return createVNode(Checkbox, mergedOpt, null);
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return createVNode("div", {
|
|
594
|
+
"class": "devui-checkbox-group"
|
|
595
|
+
}, [createVNode("div", {
|
|
596
|
+
"class": {
|
|
597
|
+
"devui-checkbox-list-inline": direction === "row"
|
|
598
|
+
}
|
|
599
|
+
}, [children])]);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
Checkbox.install = function(app) {
|
|
603
|
+
app.component(Checkbox.name, Checkbox);
|
|
604
|
+
};
|
|
605
|
+
CheckboxGroup.install = function(app) {
|
|
606
|
+
app.component(CheckboxGroup.name, CheckboxGroup);
|
|
607
|
+
};
|
|
608
|
+
var sort = "";
|
|
609
|
+
const Sort = defineComponent({
|
|
610
|
+
props: {
|
|
611
|
+
modelValue: {
|
|
612
|
+
type: String,
|
|
613
|
+
default: ""
|
|
614
|
+
},
|
|
615
|
+
"onUpdate:modelValue": {
|
|
616
|
+
type: Function
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
emits: ["update:modelValue"],
|
|
620
|
+
setup(props, ctx) {
|
|
621
|
+
const changeDirection = () => {
|
|
622
|
+
let direction = "";
|
|
623
|
+
if (props.modelValue === "ASC") {
|
|
624
|
+
direction = "DESC";
|
|
625
|
+
} else if (props.modelValue === "DESC") {
|
|
626
|
+
direction = "";
|
|
627
|
+
} else {
|
|
628
|
+
direction = "ASC";
|
|
629
|
+
}
|
|
630
|
+
ctx.emit("update:modelValue", direction);
|
|
631
|
+
};
|
|
632
|
+
return () => createVNode("span", {
|
|
633
|
+
"onClick": changeDirection,
|
|
634
|
+
"class": "sort-clickable"
|
|
635
|
+
}, [createVNode("i", {
|
|
636
|
+
"class": ["datatable-svg", {
|
|
637
|
+
"sort-icon-default": !props.modelValue,
|
|
638
|
+
"sort-icon-asc": props.modelValue === "ASC",
|
|
639
|
+
"sort-icon-desc": props.modelValue === "DESC"
|
|
640
|
+
}]
|
|
641
|
+
}, [createVNode("svg", {
|
|
642
|
+
"width": "16px",
|
|
643
|
+
"height": "16px",
|
|
644
|
+
"viewBox": "0 0 16 16",
|
|
645
|
+
"version": "1.1",
|
|
646
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
647
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
648
|
+
}, [createVNode("defs", null, [createVNode("circle", {
|
|
649
|
+
"id": "sort-svg-path-1",
|
|
650
|
+
"cx": "8",
|
|
651
|
+
"cy": "8",
|
|
652
|
+
"r": "8"
|
|
653
|
+
}, null), createVNode("filter", {
|
|
654
|
+
"x": "-34.4%",
|
|
655
|
+
"y": "-21.9%",
|
|
656
|
+
"width": "168.8%",
|
|
657
|
+
"height": "168.8%",
|
|
658
|
+
"filterUnits": "objectBoundingBox",
|
|
659
|
+
"id": "filter-2"
|
|
660
|
+
}, [createVNode("feOffset", {
|
|
661
|
+
"dx": "0",
|
|
662
|
+
"dy": "2",
|
|
663
|
+
"in": "SourceAlpha",
|
|
664
|
+
"result": "shadowOffsetOuter1"
|
|
665
|
+
}, null), createVNode("feGaussianBlur", {
|
|
666
|
+
"stdDeviation": "1.5",
|
|
667
|
+
"in": "shadowOffsetOuter1",
|
|
668
|
+
"result": "shadowBlurOuter1"
|
|
669
|
+
}, null), createVNode("feColorMatrix", {
|
|
670
|
+
"values": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.085309222 0",
|
|
671
|
+
"type": "matrix",
|
|
672
|
+
"in": "shadowBlurOuter1"
|
|
673
|
+
}, null)])]), createVNode("g", {
|
|
674
|
+
"stroke": "none",
|
|
675
|
+
"stroke-width": "1",
|
|
676
|
+
"fill": "none",
|
|
677
|
+
"fill-rule": "evenodd"
|
|
678
|
+
}, [createVNode("use", {
|
|
679
|
+
"fill-rule": "evenodd",
|
|
680
|
+
"xlink:href": "#sort-svg-path-1"
|
|
681
|
+
}, null), createVNode("polygon", {
|
|
682
|
+
"points": "8 4 11 7 5 7"
|
|
683
|
+
}, null), createVNode("polygon", {
|
|
684
|
+
"points": "8 12 5 9 11 9"
|
|
685
|
+
}, null)])])])]);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
const dropdownProps = {
|
|
689
|
+
origin: {
|
|
690
|
+
type: Object
|
|
691
|
+
},
|
|
692
|
+
isOpen: {
|
|
693
|
+
type: Boolean,
|
|
694
|
+
default: false
|
|
695
|
+
},
|
|
696
|
+
disabled: {
|
|
697
|
+
type: Boolean,
|
|
698
|
+
default: false
|
|
699
|
+
},
|
|
700
|
+
trigger: {
|
|
701
|
+
type: String,
|
|
702
|
+
default: "click"
|
|
703
|
+
},
|
|
704
|
+
closeScope: {
|
|
705
|
+
type: String,
|
|
706
|
+
default: "all"
|
|
707
|
+
},
|
|
708
|
+
closeOnMouseLeaveMenu: {
|
|
709
|
+
type: Boolean,
|
|
710
|
+
default: false
|
|
711
|
+
},
|
|
712
|
+
showAnimation: {
|
|
713
|
+
type: Boolean,
|
|
714
|
+
default: true
|
|
715
|
+
},
|
|
716
|
+
width: {
|
|
717
|
+
type: [Number, String],
|
|
718
|
+
default: "102px"
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
function isComponent(target) {
|
|
722
|
+
return !!(target == null ? void 0 : target.$el);
|
|
723
|
+
}
|
|
724
|
+
function getElement(element) {
|
|
725
|
+
if (element instanceof Element) {
|
|
726
|
+
return element;
|
|
727
|
+
}
|
|
728
|
+
if (element && typeof element === "object" && element.$el instanceof Element) {
|
|
729
|
+
return element.$el;
|
|
730
|
+
}
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
function subscribeEvent(dom, type, callback) {
|
|
734
|
+
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
735
|
+
return () => {
|
|
736
|
+
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
const useDropdown = ({
|
|
740
|
+
visible,
|
|
741
|
+
trigger,
|
|
742
|
+
origin,
|
|
743
|
+
closeScope,
|
|
744
|
+
closeOnMouseLeaveMenu
|
|
745
|
+
}) => {
|
|
746
|
+
const dropdownElRef = ref();
|
|
747
|
+
const closeByScope = () => {
|
|
748
|
+
if (closeScope.value === "none") {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
visible.value = false;
|
|
752
|
+
};
|
|
753
|
+
watch([trigger, origin, dropdownElRef], ([trigger2, origin2, dropdownEl], ov, onInvalidate) => {
|
|
754
|
+
const originEl = getElement(origin2);
|
|
755
|
+
if (!originEl || !dropdownEl) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
const subscriptions = [
|
|
759
|
+
subscribeEvent(dropdownEl, "click", () => {
|
|
760
|
+
if (closeScope.value === "all") {
|
|
761
|
+
visible.value = false;
|
|
762
|
+
}
|
|
763
|
+
})
|
|
764
|
+
];
|
|
765
|
+
if (trigger2 === "click") {
|
|
766
|
+
subscriptions.push(subscribeEvent(originEl, "click", () => visible.value = !visible.value), subscribeEvent(document, "click", (e) => {
|
|
767
|
+
if (!visible.value) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const target = e.target;
|
|
771
|
+
const isContain = originEl.contains(target) || dropdownEl.contains(target);
|
|
772
|
+
if (isContain) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
closeByScope();
|
|
776
|
+
}), subscribeEvent(dropdownEl, "mouseleave", () => {
|
|
777
|
+
if (closeOnMouseLeaveMenu.value) {
|
|
778
|
+
visible.value = false;
|
|
779
|
+
}
|
|
780
|
+
}));
|
|
781
|
+
} else if (trigger2 === "hover") {
|
|
782
|
+
let overlayEnter = false;
|
|
783
|
+
let originEnter = false;
|
|
784
|
+
const handleLeave = async (elementType) => {
|
|
785
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
786
|
+
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
closeByScope();
|
|
790
|
+
};
|
|
791
|
+
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
792
|
+
originEnter = true;
|
|
793
|
+
visible.value = true;
|
|
794
|
+
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
795
|
+
originEnter = false;
|
|
796
|
+
if (!closeOnMouseLeaveMenu.value) {
|
|
797
|
+
handleLeave("origin");
|
|
798
|
+
}
|
|
799
|
+
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
800
|
+
overlayEnter = true;
|
|
801
|
+
visible.value = true;
|
|
802
|
+
}), subscribeEvent(dropdownEl, "mouseleave", () => {
|
|
803
|
+
overlayEnter = false;
|
|
804
|
+
handleLeave("dropdown");
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
808
|
+
});
|
|
809
|
+
return { dropdownEl: dropdownElRef };
|
|
810
|
+
};
|
|
811
|
+
var overlay = "";
|
|
812
|
+
function _isSlot(s) {
|
|
813
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
814
|
+
}
|
|
815
|
+
const CommonOverlay = defineComponent({
|
|
816
|
+
setup(props, ctx) {
|
|
817
|
+
return () => {
|
|
818
|
+
let _slot;
|
|
819
|
+
return createVNode(Teleport, {
|
|
820
|
+
"to": "#d-overlay-anchor"
|
|
821
|
+
}, {
|
|
822
|
+
default: () => [createVNode(Transition, {
|
|
823
|
+
"name": "devui-overlay-fade"
|
|
824
|
+
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
825
|
+
default: () => [_slot]
|
|
826
|
+
})]
|
|
827
|
+
});
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
const overlayProps = {
|
|
832
|
+
visible: {
|
|
833
|
+
type: Boolean
|
|
834
|
+
},
|
|
835
|
+
backgroundBlock: {
|
|
836
|
+
type: Boolean,
|
|
837
|
+
default: false
|
|
838
|
+
},
|
|
839
|
+
backgroundClass: {
|
|
840
|
+
type: String,
|
|
841
|
+
default: ""
|
|
842
|
+
},
|
|
843
|
+
backgroundStyle: {
|
|
844
|
+
type: [String, Object]
|
|
845
|
+
},
|
|
846
|
+
onBackdropClick: {
|
|
847
|
+
type: Function
|
|
848
|
+
},
|
|
849
|
+
backdropClose: {
|
|
850
|
+
type: Boolean,
|
|
851
|
+
default: true
|
|
852
|
+
},
|
|
853
|
+
hasBackdrop: {
|
|
854
|
+
type: Boolean,
|
|
855
|
+
default: true
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
859
|
+
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
860
|
+
overlayStyle: {
|
|
861
|
+
type: [String, Object],
|
|
862
|
+
default: void 0
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
const flexibleOverlayProps = __spreadValues({
|
|
866
|
+
origin: {
|
|
867
|
+
type: Object,
|
|
868
|
+
require: true
|
|
869
|
+
},
|
|
870
|
+
position: {
|
|
871
|
+
type: Object,
|
|
872
|
+
default: () => ({
|
|
873
|
+
originX: "left",
|
|
874
|
+
originY: "top",
|
|
875
|
+
overlayX: "left",
|
|
876
|
+
overlayY: "top"
|
|
877
|
+
})
|
|
878
|
+
}
|
|
879
|
+
}, overlayProps);
|
|
880
|
+
function useOverlayLogic(props, ctx) {
|
|
881
|
+
const backgroundClass = computed(() => {
|
|
882
|
+
return [
|
|
883
|
+
"devui-overlay-background",
|
|
884
|
+
props.backgroundClass,
|
|
885
|
+
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
886
|
+
];
|
|
887
|
+
});
|
|
888
|
+
const overlayClass = computed(() => {
|
|
889
|
+
return "devui-overlay";
|
|
890
|
+
});
|
|
891
|
+
const handleBackdropClick = (event) => {
|
|
892
|
+
var _a;
|
|
893
|
+
event.preventDefault();
|
|
894
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
895
|
+
if (props.backdropClose) {
|
|
896
|
+
ctx.emit("update:visible", false);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
900
|
+
onMounted(() => {
|
|
901
|
+
const body2 = document.body;
|
|
902
|
+
const originOverflow = body2.style.overflow;
|
|
903
|
+
const originPosition = body2.style.position;
|
|
904
|
+
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
905
|
+
if (backgroundBlock) {
|
|
906
|
+
const top = body2.getBoundingClientRect().y;
|
|
907
|
+
if (visible) {
|
|
908
|
+
body2.style.overflowY = "scroll";
|
|
909
|
+
body2.style.position = visible ? "fixed" : "";
|
|
910
|
+
body2.style.top = `${top}px`;
|
|
911
|
+
} else {
|
|
912
|
+
body2.style.overflowY = originOverflow;
|
|
913
|
+
body2.style.position = originPosition;
|
|
914
|
+
body2.style.top = "";
|
|
915
|
+
window.scrollTo(0, -top);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
onUnmounted(() => {
|
|
920
|
+
document.body.style.overflow = originOverflow;
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
return {
|
|
924
|
+
backgroundClass,
|
|
925
|
+
overlayClass,
|
|
926
|
+
handleBackdropClick,
|
|
927
|
+
handleOverlayBubbleCancel
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
const FixedOverlay = defineComponent({
|
|
931
|
+
name: "DFixedOverlay",
|
|
932
|
+
props: fixedOverlayProps,
|
|
933
|
+
emits: overlayEmits,
|
|
934
|
+
setup(props, ctx) {
|
|
935
|
+
const {
|
|
936
|
+
backgroundClass,
|
|
937
|
+
overlayClass,
|
|
938
|
+
handleBackdropClick,
|
|
939
|
+
handleOverlayBubbleCancel
|
|
940
|
+
} = useOverlayLogic(props, ctx);
|
|
941
|
+
return () => createVNode(CommonOverlay, null, {
|
|
942
|
+
default: () => [withDirectives(createVNode("div", {
|
|
943
|
+
"class": backgroundClass.value,
|
|
944
|
+
"style": props.backgroundStyle,
|
|
945
|
+
"onClick": handleBackdropClick
|
|
946
|
+
}, [createVNode("div", {
|
|
947
|
+
"class": overlayClass.value,
|
|
948
|
+
"style": props.overlayStyle,
|
|
949
|
+
"onClick": handleOverlayBubbleCancel
|
|
950
|
+
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
const FlexibleOverlay = defineComponent({
|
|
955
|
+
name: "DFlexibleOverlay",
|
|
956
|
+
props: flexibleOverlayProps,
|
|
957
|
+
emits: overlayEmits,
|
|
958
|
+
setup(props, ctx) {
|
|
959
|
+
const overlayRef = ref(null);
|
|
960
|
+
const positionedStyle = reactive({
|
|
961
|
+
position: "absolute"
|
|
962
|
+
});
|
|
963
|
+
onMounted(async () => {
|
|
964
|
+
const handleRectChange = (position, rect, origin) => {
|
|
965
|
+
const point = calculatePosition(position, rect, origin);
|
|
966
|
+
positionedStyle.left = `${point.x}px`;
|
|
967
|
+
positionedStyle.top = `${point.y}px`;
|
|
968
|
+
};
|
|
969
|
+
const locationElements = computed(() => {
|
|
970
|
+
const overlay2 = overlayRef.value;
|
|
971
|
+
const origin = getOrigin(props.origin);
|
|
972
|
+
if (!overlay2 || !origin) {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
origin,
|
|
977
|
+
overlay: overlay2
|
|
978
|
+
};
|
|
979
|
+
});
|
|
980
|
+
const visibleRef = toRef(props, "visible");
|
|
981
|
+
const positionRef = toRef(props, "position");
|
|
982
|
+
watch([locationElements, visibleRef, positionRef], async ([locationElements2, visible, position], ov, onInvalidate) => {
|
|
983
|
+
if (!visible || !locationElements2) {
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
const {
|
|
987
|
+
origin,
|
|
988
|
+
overlay: overlay2
|
|
989
|
+
} = locationElements2;
|
|
990
|
+
handleRectChange(position, overlay2.getBoundingClientRect(), origin);
|
|
991
|
+
const unsubscriptions = [subscribeLayoutEvent(() => handleRectChange(position, overlay2.getBoundingClientRect(), origin)), subscribeOverlayResize(overlay2, (entries) => handleRectChange(position, entries[0].contentRect, origin)), subscribeOriginResize(origin, () => handleRectChange(position, overlay2.getBoundingClientRect(), origin))];
|
|
992
|
+
onInvalidate(() => {
|
|
993
|
+
unsubscriptions.forEach((fn) => fn());
|
|
994
|
+
});
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
const {
|
|
998
|
+
backgroundClass,
|
|
999
|
+
overlayClass,
|
|
1000
|
+
handleBackdropClick,
|
|
1001
|
+
handleOverlayBubbleCancel
|
|
1002
|
+
} = useOverlayLogic(props, ctx);
|
|
1003
|
+
return () => createVNode(CommonOverlay, null, {
|
|
1004
|
+
default: () => [withDirectives(createVNode("div", {
|
|
1005
|
+
"style": props.backgroundStyle,
|
|
1006
|
+
"class": backgroundClass.value,
|
|
1007
|
+
"onClick": handleBackdropClick
|
|
1008
|
+
}, [createVNode("div", {
|
|
1009
|
+
"ref": overlayRef,
|
|
1010
|
+
"class": overlayClass.value,
|
|
1011
|
+
"style": positionedStyle,
|
|
1012
|
+
"onClick": handleOverlayBubbleCancel
|
|
1013
|
+
}, [renderSlot(ctx.slots, "default")])]), [[vShow, props.visible]])]
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
function getOrigin(origin) {
|
|
1018
|
+
if (origin instanceof Element) {
|
|
1019
|
+
return origin;
|
|
1020
|
+
}
|
|
1021
|
+
if (isRef(origin)) {
|
|
1022
|
+
return getElement(origin.value);
|
|
1023
|
+
}
|
|
1024
|
+
if (isComponent(origin)) {
|
|
1025
|
+
return getElement(origin);
|
|
1026
|
+
}
|
|
1027
|
+
return origin;
|
|
1028
|
+
}
|
|
1029
|
+
function calculatePosition(position, rect, origin) {
|
|
1030
|
+
const originRect = getOriginRect(origin);
|
|
1031
|
+
const originPoint = getOriginRelativePoint(originRect, position);
|
|
1032
|
+
return getOverlayPoint(originPoint, rect, position);
|
|
1033
|
+
}
|
|
1034
|
+
function getOriginRect(origin) {
|
|
1035
|
+
if (origin instanceof Element) {
|
|
1036
|
+
return origin.getBoundingClientRect();
|
|
1037
|
+
}
|
|
1038
|
+
const width = origin.width || 0;
|
|
1039
|
+
const height = origin.height || 0;
|
|
1040
|
+
return {
|
|
1041
|
+
top: origin.y,
|
|
1042
|
+
bottom: origin.y + height,
|
|
1043
|
+
left: origin.x,
|
|
1044
|
+
right: origin.x + width,
|
|
1045
|
+
height,
|
|
1046
|
+
width
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
function getOverlayPoint(originPoint, rect, position) {
|
|
1050
|
+
let x;
|
|
1051
|
+
const {
|
|
1052
|
+
width,
|
|
1053
|
+
height
|
|
1054
|
+
} = rect;
|
|
1055
|
+
if (position.overlayX == "center") {
|
|
1056
|
+
x = originPoint.x - width / 2;
|
|
1057
|
+
} else {
|
|
1058
|
+
x = position.overlayX == "left" ? originPoint.x : originPoint.x - width;
|
|
1059
|
+
}
|
|
1060
|
+
let y;
|
|
1061
|
+
if (position.overlayY == "center") {
|
|
1062
|
+
y = originPoint.y - height / 2;
|
|
1063
|
+
} else {
|
|
1064
|
+
y = position.overlayY == "top" ? originPoint.y : originPoint.y - height;
|
|
1065
|
+
}
|
|
1066
|
+
return {
|
|
1067
|
+
x,
|
|
1068
|
+
y
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
function getOriginRelativePoint(originRect, position) {
|
|
1072
|
+
let x;
|
|
1073
|
+
if (position.originX == "center") {
|
|
1074
|
+
x = originRect.left + originRect.width / 2;
|
|
1075
|
+
} else {
|
|
1076
|
+
const startX = originRect.left;
|
|
1077
|
+
const endX = originRect.right;
|
|
1078
|
+
x = position.originX == "left" ? startX : endX;
|
|
1079
|
+
}
|
|
1080
|
+
let y;
|
|
1081
|
+
if (position.originY == "center") {
|
|
1082
|
+
y = originRect.top + originRect.height / 2;
|
|
1083
|
+
} else {
|
|
1084
|
+
y = position.originY == "top" ? originRect.top : originRect.bottom;
|
|
1085
|
+
}
|
|
1086
|
+
return {
|
|
1087
|
+
x,
|
|
1088
|
+
y
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
function subscribeLayoutEvent(event) {
|
|
1092
|
+
window.addEventListener("scroll", event, true);
|
|
1093
|
+
window.addEventListener("resize", event);
|
|
1094
|
+
window.addEventListener("orientationchange", event);
|
|
1095
|
+
return () => {
|
|
1096
|
+
window.removeEventListener("scroll", event, true);
|
|
1097
|
+
window.removeEventListener("resize", event);
|
|
1098
|
+
window.removeEventListener("orientationchange", event);
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
function subscribeOverlayResize(overlay2, callback) {
|
|
1102
|
+
if (overlay2 instanceof Element) {
|
|
1103
|
+
const resizeObserver = new ResizeObserver(callback);
|
|
1104
|
+
resizeObserver.observe(overlay2);
|
|
1105
|
+
return () => resizeObserver.disconnect();
|
|
1106
|
+
}
|
|
1107
|
+
return () => {
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function subscribeOriginResize(origin, callback) {
|
|
1111
|
+
if (origin instanceof Element) {
|
|
1112
|
+
const observer = new MutationObserver(callback);
|
|
1113
|
+
observer.observe(origin, {
|
|
1114
|
+
attributeFilter: ["style"]
|
|
1115
|
+
});
|
|
1116
|
+
return () => observer.disconnect();
|
|
1117
|
+
}
|
|
1118
|
+
return () => {
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
FlexibleOverlay.install = function(app) {
|
|
1122
|
+
app.component(FlexibleOverlay.name, FlexibleOverlay);
|
|
1123
|
+
};
|
|
1124
|
+
FixedOverlay.install = function(app) {
|
|
1125
|
+
app.component(FixedOverlay.name, FixedOverlay);
|
|
1126
|
+
};
|
|
1127
|
+
var dropdown = "";
|
|
1128
|
+
var Dropdown = defineComponent({
|
|
1129
|
+
name: "DDropdown",
|
|
1130
|
+
props: dropdownProps,
|
|
1131
|
+
emits: [],
|
|
1132
|
+
setup(props, ctx) {
|
|
1133
|
+
const {
|
|
1134
|
+
isOpen,
|
|
1135
|
+
origin,
|
|
1136
|
+
trigger,
|
|
1137
|
+
closeScope,
|
|
1138
|
+
closeOnMouseLeaveMenu
|
|
1139
|
+
} = toRefs(props);
|
|
1140
|
+
const visible = ref(false);
|
|
1141
|
+
watch(isOpen, (value) => {
|
|
1142
|
+
visible.value = value;
|
|
1143
|
+
}, {
|
|
1144
|
+
immediate: true
|
|
1145
|
+
});
|
|
1146
|
+
const position = {
|
|
1147
|
+
originX: "center",
|
|
1148
|
+
originY: "bottom",
|
|
1149
|
+
overlayX: "center",
|
|
1150
|
+
overlayY: "top"
|
|
1151
|
+
};
|
|
1152
|
+
const {
|
|
1153
|
+
dropdownEl
|
|
1154
|
+
} = useDropdown({
|
|
1155
|
+
visible,
|
|
1156
|
+
origin,
|
|
1157
|
+
trigger,
|
|
1158
|
+
closeScope,
|
|
1159
|
+
closeOnMouseLeaveMenu
|
|
1160
|
+
});
|
|
1161
|
+
const animatedVisible = computed(() => {
|
|
1162
|
+
return props.showAnimation ? visible.value : true;
|
|
1163
|
+
});
|
|
1164
|
+
const wrapStyle = computed(() => typeof props.width === "string" ? {
|
|
1165
|
+
width: props.width
|
|
1166
|
+
} : {
|
|
1167
|
+
width: `${props.width}px`
|
|
1168
|
+
});
|
|
1169
|
+
return () => createVNode(FlexibleOverlay, {
|
|
1170
|
+
"origin": props.origin,
|
|
1171
|
+
"visible": visible.value,
|
|
1172
|
+
"onUpdate:visible": ($event) => visible.value = $event,
|
|
1173
|
+
"position": position,
|
|
1174
|
+
"hasBackdrop": false
|
|
1175
|
+
}, {
|
|
1176
|
+
default: () => [createVNode(Transition, {
|
|
1177
|
+
"name": "devui-dropdown-fade"
|
|
1178
|
+
}, {
|
|
1179
|
+
default: () => {
|
|
1180
|
+
var _a, _b;
|
|
1181
|
+
return [withDirectives(createVNode("div", {
|
|
1182
|
+
"ref": dropdownEl,
|
|
1183
|
+
"class": "devui-dropdown-menu-wrap",
|
|
1184
|
+
"style": wrapStyle.value
|
|
1185
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), [[vShow, animatedVisible.value]])];
|
|
1186
|
+
}
|
|
1187
|
+
})]
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
Dropdown.install = function(app) {
|
|
1192
|
+
app.component(Dropdown.name, Dropdown);
|
|
1193
|
+
};
|
|
1194
|
+
var filter = "";
|
|
1195
|
+
const Filter = defineComponent({
|
|
1196
|
+
props: {
|
|
1197
|
+
modelValue: {
|
|
1198
|
+
type: Array,
|
|
1199
|
+
default: []
|
|
1200
|
+
},
|
|
1201
|
+
"onUpdate:modelValue": {
|
|
1202
|
+
type: Function
|
|
1203
|
+
},
|
|
1204
|
+
customTemplate: {
|
|
1205
|
+
type: Function
|
|
1206
|
+
},
|
|
1207
|
+
filterList: {
|
|
1208
|
+
type: Array,
|
|
1209
|
+
required: true
|
|
1210
|
+
},
|
|
1211
|
+
filterMultiple: {
|
|
1212
|
+
type: Boolean,
|
|
1213
|
+
default: true
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
emits: ["update:modelValue"],
|
|
1217
|
+
setup(props) {
|
|
1218
|
+
const filterOrigin = ref(null);
|
|
1219
|
+
const onUpdateChecked = (config, value) => {
|
|
1220
|
+
const checkedList = props.modelValue;
|
|
1221
|
+
const update = props["onUpdate:modelValue"];
|
|
1222
|
+
const contained = !!checkedList.find((item) => item === config.value);
|
|
1223
|
+
if (value && !contained) {
|
|
1224
|
+
update == null ? void 0 : update([...checkedList, config.value]);
|
|
1225
|
+
} else if (!value && contained) {
|
|
1226
|
+
update == null ? void 0 : update(checkedList.filter((item) => config.value !== item));
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
const updateSingleChecked = (config) => {
|
|
1230
|
+
var _a;
|
|
1231
|
+
(_a = props["onUpdate:modelValue"]) == null ? void 0 : _a.call(props, [config.value]);
|
|
1232
|
+
};
|
|
1233
|
+
const dropdownContent = computed(() => {
|
|
1234
|
+
const checkedList = props.modelValue;
|
|
1235
|
+
const isContained = (config) => !!checkedList.find((item) => item === config.value);
|
|
1236
|
+
return () => createVNode("ul", {
|
|
1237
|
+
"class": "devui-dropdown-menu data-table-column-filter-content",
|
|
1238
|
+
"style": "padding:10px"
|
|
1239
|
+
}, [props.filterList.map((item, index2) => {
|
|
1240
|
+
return createVNode("li", {
|
|
1241
|
+
"style": index2 > 0 ? "margin-top:10px" : ""
|
|
1242
|
+
}, [props.filterMultiple ? createVNode(Checkbox, {
|
|
1243
|
+
"modelValue": isContained(item),
|
|
1244
|
+
"onUpdate:modelValue": (value) => onUpdateChecked(item, value)
|
|
1245
|
+
}, {
|
|
1246
|
+
default: () => [item.name]
|
|
1247
|
+
}) : createVNode("span", {
|
|
1248
|
+
"onClick": () => updateSingleChecked(item)
|
|
1249
|
+
}, [item.name])]);
|
|
1250
|
+
})]);
|
|
1251
|
+
});
|
|
1252
|
+
return () => createVNode(Fragment, null, [createVNode("span", {
|
|
1253
|
+
"ref": filterOrigin
|
|
1254
|
+
}, [createVNode("i", {
|
|
1255
|
+
"class": ["filter-icon", {
|
|
1256
|
+
"filter-icon-active": true
|
|
1257
|
+
}]
|
|
1258
|
+
}, [createVNode("svg", {
|
|
1259
|
+
"width": "16px",
|
|
1260
|
+
"height": "16px",
|
|
1261
|
+
"viewBox": "0 0 16 16",
|
|
1262
|
+
"version": "1.1",
|
|
1263
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
1264
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
1265
|
+
}, [createVNode("g", {
|
|
1266
|
+
"stroke": "none",
|
|
1267
|
+
"stroke-width": "1",
|
|
1268
|
+
"fill": "none",
|
|
1269
|
+
"fill-rule": "evenodd"
|
|
1270
|
+
}, [createVNode("g", null, [createVNode("polygon", {
|
|
1271
|
+
"points": "10.0085775 7 10.0085775 15 6 13 6 7 2 3 2 1 14 1 14 3"
|
|
1272
|
+
}, null)])])])])]), createVNode(Dropdown, {
|
|
1273
|
+
"origin": filterOrigin.value,
|
|
1274
|
+
"closeScope": "blank"
|
|
1275
|
+
}, {
|
|
1276
|
+
default: () => {
|
|
1277
|
+
var _a, _b;
|
|
1278
|
+
return [(_b = (_a = props.customTemplate) == null ? void 0 : _a.call(props, {
|
|
1279
|
+
value: props.modelValue,
|
|
1280
|
+
onChange: props["onUpdate:modelValue"]
|
|
1281
|
+
})) != null ? _b : dropdownContent.value()];
|
|
1282
|
+
}
|
|
1283
|
+
})]);
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
var header = "";
|
|
1287
|
+
var body = "";
|
|
1288
|
+
const useSort = (store, column) => {
|
|
1289
|
+
const directionRef = ref("DESC");
|
|
1290
|
+
watch([directionRef, column], ([direction, column2]) => {
|
|
1291
|
+
if (column2.sortable) {
|
|
1292
|
+
store.sortData(column2.field, direction, column2.compareFn);
|
|
1293
|
+
}
|
|
1294
|
+
}, { immediate: true });
|
|
1295
|
+
return directionRef;
|
|
1296
|
+
};
|
|
1297
|
+
const useFliter = (store, column) => {
|
|
1298
|
+
const filteredRef = shallowRef();
|
|
1299
|
+
watch(filteredRef, (results) => {
|
|
1300
|
+
store.filterData(column.value.field, results);
|
|
1301
|
+
});
|
|
1302
|
+
return filteredRef;
|
|
1303
|
+
};
|
|
1304
|
+
var TableHeader = defineComponent({
|
|
1305
|
+
name: "DTableHeader",
|
|
1306
|
+
setup() {
|
|
1307
|
+
const table2 = inject(TABLE_TOKEN);
|
|
1308
|
+
const {
|
|
1309
|
+
_checkAll: checkAll,
|
|
1310
|
+
_halfChecked: halfChecked,
|
|
1311
|
+
_columns: columns,
|
|
1312
|
+
isFixedLeft
|
|
1313
|
+
} = table2.store.states;
|
|
1314
|
+
const thAttrs = computed(() => isFixedLeft.value ? {
|
|
1315
|
+
class: "devui-sticky-cell left",
|
|
1316
|
+
style: "left:0;"
|
|
1317
|
+
} : null);
|
|
1318
|
+
const checkbox2 = computed(() => table2.props.checkable ? createVNode("th", thAttrs.value, [createVNode(Checkbox, {
|
|
1319
|
+
"style": "padding:10px;",
|
|
1320
|
+
"modelValue": checkAll.value,
|
|
1321
|
+
"onUpdate:modelValue": ($event) => checkAll.value = $event,
|
|
1322
|
+
"halfchecked": halfChecked.value
|
|
1323
|
+
}, null)]) : null);
|
|
1324
|
+
return () => {
|
|
1325
|
+
return createVNode("thead", {
|
|
1326
|
+
"class": "devui-thead"
|
|
1327
|
+
}, [createVNode("tr", null, [checkbox2.value, columns.value.map((column, index2) => createVNode(Th, {
|
|
1328
|
+
"key": index2,
|
|
1329
|
+
"column": column
|
|
1330
|
+
}, null))])]);
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
const Th = defineComponent({
|
|
1335
|
+
props: {
|
|
1336
|
+
column: {
|
|
1337
|
+
type: Object,
|
|
1338
|
+
required: true
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
setup(props) {
|
|
1342
|
+
const table2 = inject(TABLE_TOKEN);
|
|
1343
|
+
const {
|
|
1344
|
+
column
|
|
1345
|
+
} = toRefs(props);
|
|
1346
|
+
const directionRef = useSort(table2.store, column);
|
|
1347
|
+
const filteredRef = useFliter(table2.store, column);
|
|
1348
|
+
const {
|
|
1349
|
+
stickyCell,
|
|
1350
|
+
offsetStyle
|
|
1351
|
+
} = useFixedColumn(column);
|
|
1352
|
+
return () => createVNode("th", {
|
|
1353
|
+
"class": stickyCell.value,
|
|
1354
|
+
"style": offsetStyle.value
|
|
1355
|
+
}, [createVNode("div", {
|
|
1356
|
+
"class": "header-container"
|
|
1357
|
+
}, [props.column.renderHeader(), props.column.filterable && createVNode(Filter, {
|
|
1358
|
+
"modelValue": filteredRef.value,
|
|
1359
|
+
"onUpdate:modelValue": ($event) => filteredRef.value = $event,
|
|
1360
|
+
"filterList": props.column.filterList,
|
|
1361
|
+
"customTemplate": props.column.customFilterTemplate
|
|
1362
|
+
}, null)]), props.column.sortable && createVNode(Sort, {
|
|
1363
|
+
"modelValue": directionRef.value,
|
|
1364
|
+
"onUpdate:modelValue": ($event) => directionRef.value = $event
|
|
1365
|
+
}, null)]);
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
var TableBody = defineComponent({
|
|
1369
|
+
name: "DTableBody",
|
|
1370
|
+
setup() {
|
|
1371
|
+
const table2 = inject(TABLE_TOKEN);
|
|
1372
|
+
const {
|
|
1373
|
+
_data: data,
|
|
1374
|
+
_columns: columns,
|
|
1375
|
+
_checkList: checkList,
|
|
1376
|
+
isFixedLeft
|
|
1377
|
+
} = table2.store.states;
|
|
1378
|
+
const hoverEnabled = computed(() => table2.props.rowHoveredHighlight);
|
|
1379
|
+
const tdAttrs = computed(() => isFixedLeft.value ? {
|
|
1380
|
+
class: "devui-sticky-cell left",
|
|
1381
|
+
style: "left:0;"
|
|
1382
|
+
} : null);
|
|
1383
|
+
const renderCheckbox = (index2) => table2.props.checkable ? createVNode("td", tdAttrs.value, [createVNode(Checkbox, {
|
|
1384
|
+
"modelValue": checkList.value[index2],
|
|
1385
|
+
"onUpdate:modelValue": ($event) => checkList.value[index2] = $event
|
|
1386
|
+
}, null)]) : null;
|
|
1387
|
+
return () => createVNode("tbody", {
|
|
1388
|
+
"class": "devui-tbody"
|
|
1389
|
+
}, [data.value.map((row, rowIndex) => {
|
|
1390
|
+
return createVNode("tr", {
|
|
1391
|
+
"key": rowIndex,
|
|
1392
|
+
"class": {
|
|
1393
|
+
"hover-enabled": hoverEnabled.value
|
|
1394
|
+
}
|
|
1395
|
+
}, [renderCheckbox(rowIndex), columns.value.map((column, index2) => createVNode(TD, {
|
|
1396
|
+
"column": column,
|
|
1397
|
+
"index": index2,
|
|
1398
|
+
"row": row
|
|
1399
|
+
}, null))]);
|
|
1400
|
+
})]);
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
const TD = defineComponent({
|
|
1404
|
+
props: {
|
|
1405
|
+
column: {
|
|
1406
|
+
type: Object
|
|
1407
|
+
},
|
|
1408
|
+
row: {
|
|
1409
|
+
type: Object
|
|
1410
|
+
},
|
|
1411
|
+
index: {
|
|
1412
|
+
type: Number
|
|
1413
|
+
}
|
|
1414
|
+
},
|
|
1415
|
+
setup(props) {
|
|
1416
|
+
const column = toRef(props, "column");
|
|
1417
|
+
const {
|
|
1418
|
+
stickyCell,
|
|
1419
|
+
offsetStyle
|
|
1420
|
+
} = useFixedColumn(column);
|
|
1421
|
+
return () => createVNode("td", {
|
|
1422
|
+
"class": stickyCell.value,
|
|
1423
|
+
"style": offsetStyle.value
|
|
1424
|
+
}, [column.value.renderCell(props.row, props.index)]);
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
var table = "";
|
|
1428
|
+
var Table = defineComponent({
|
|
1429
|
+
name: "DTable",
|
|
1430
|
+
props: TableProps,
|
|
1431
|
+
setup(props, ctx) {
|
|
1432
|
+
const table2 = getCurrentInstance();
|
|
1433
|
+
const store = createStore(toRef(props, "data"));
|
|
1434
|
+
table2.store = store;
|
|
1435
|
+
provide(TABLE_TOKEN, table2);
|
|
1436
|
+
const {
|
|
1437
|
+
classes,
|
|
1438
|
+
style
|
|
1439
|
+
} = useTable(props);
|
|
1440
|
+
const isEmpty2 = computed(() => props.data.length === 0);
|
|
1441
|
+
const fixHeaderCompo = computed(() => {
|
|
1442
|
+
return createVNode("div", {
|
|
1443
|
+
"class": "devui-table-view"
|
|
1444
|
+
}, [createVNode("div", {
|
|
1445
|
+
"style": "overflow: hidden scroll;"
|
|
1446
|
+
}, [createVNode("table", {
|
|
1447
|
+
"class": classes.value,
|
|
1448
|
+
"cellpadding": "0",
|
|
1449
|
+
"cellspacing": "0"
|
|
1450
|
+
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
|
|
1451
|
+
"class": "scroll-view"
|
|
1452
|
+
}, [createVNode("table", {
|
|
1453
|
+
"class": classes.value,
|
|
1454
|
+
"cellpadding": "0",
|
|
1455
|
+
"cellspacing": "0"
|
|
1456
|
+
}, [createVNode(ColGroup, null, null), !isEmpty2.value && createVNode(TableBody, {
|
|
1457
|
+
"style": "flex: 1"
|
|
1458
|
+
}, null)])])]);
|
|
1459
|
+
});
|
|
1460
|
+
const normalHeaderCompo = computed(() => {
|
|
1461
|
+
return createVNode("table", {
|
|
1462
|
+
"class": classes.value,
|
|
1463
|
+
"cellpadding": "0",
|
|
1464
|
+
"cellspacing": "0"
|
|
1465
|
+
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
|
|
1466
|
+
"style": "position: relative"
|
|
1467
|
+
}, null), !isEmpty2.value && createVNode(TableBody, null, null)]);
|
|
1468
|
+
});
|
|
1469
|
+
ctx.expose({
|
|
1470
|
+
getCheckedRows() {
|
|
1471
|
+
return store.getCheckedRows();
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
return () => withDirectives(createVNode("div", {
|
|
1475
|
+
"class": "devui-table-wrapper",
|
|
1476
|
+
"style": style.value
|
|
1477
|
+
}, [ctx.slots.default(), props.fixHeader ? fixHeaderCompo.value : normalHeaderCompo.value, isEmpty2.value && createVNode("div", {
|
|
1478
|
+
"class": "devui-table-empty"
|
|
1479
|
+
}, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
const TableColumnProps = {
|
|
1483
|
+
header: {
|
|
1484
|
+
type: String,
|
|
1485
|
+
default: ""
|
|
1486
|
+
},
|
|
1487
|
+
field: {
|
|
1488
|
+
type: String,
|
|
1489
|
+
default: ""
|
|
1490
|
+
},
|
|
1491
|
+
width: {
|
|
1492
|
+
type: [String, Number],
|
|
1493
|
+
default: ""
|
|
1494
|
+
},
|
|
1495
|
+
minWidth: {
|
|
1496
|
+
type: [String, Number],
|
|
1497
|
+
default: 80
|
|
1498
|
+
},
|
|
1499
|
+
formatter: {
|
|
1500
|
+
type: Function
|
|
1501
|
+
},
|
|
1502
|
+
order: {
|
|
1503
|
+
type: Number,
|
|
1504
|
+
default: 0
|
|
1505
|
+
},
|
|
1506
|
+
sortable: {
|
|
1507
|
+
type: Boolean,
|
|
1508
|
+
default: false
|
|
1509
|
+
},
|
|
1510
|
+
compareFn: {
|
|
1511
|
+
type: Function,
|
|
1512
|
+
default: (field, a, b) => a[field] < b[field]
|
|
1513
|
+
},
|
|
1514
|
+
filterable: {
|
|
1515
|
+
type: Boolean,
|
|
1516
|
+
default: false
|
|
1517
|
+
},
|
|
1518
|
+
filterMultiple: {
|
|
1519
|
+
type: Boolean,
|
|
1520
|
+
default: false
|
|
1521
|
+
},
|
|
1522
|
+
filterList: {
|
|
1523
|
+
type: Array,
|
|
1524
|
+
default: []
|
|
1525
|
+
},
|
|
1526
|
+
fixedLeft: {
|
|
1527
|
+
type: String
|
|
1528
|
+
},
|
|
1529
|
+
fixedRight: {
|
|
1530
|
+
type: String
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
function formatWidth(width) {
|
|
1534
|
+
if (typeof width === "number") {
|
|
1535
|
+
return width;
|
|
1536
|
+
}
|
|
1537
|
+
return parseInt(width, 10) || 0;
|
|
1538
|
+
}
|
|
1539
|
+
function formatMinWidth(minWidth) {
|
|
1540
|
+
return formatWidth(minWidth) || 80;
|
|
1541
|
+
}
|
|
1542
|
+
function createColumn(props, templates) {
|
|
1543
|
+
const {
|
|
1544
|
+
field,
|
|
1545
|
+
header: header2,
|
|
1546
|
+
sortable,
|
|
1547
|
+
width,
|
|
1548
|
+
minWidth,
|
|
1549
|
+
formatter,
|
|
1550
|
+
compareFn,
|
|
1551
|
+
filterable,
|
|
1552
|
+
filterList,
|
|
1553
|
+
filterMultiple,
|
|
1554
|
+
order,
|
|
1555
|
+
fixedLeft,
|
|
1556
|
+
fixedRight
|
|
1557
|
+
} = props;
|
|
1558
|
+
const column = reactive({});
|
|
1559
|
+
watch([field, header2, order], ([field2, header22, order2]) => {
|
|
1560
|
+
column.field = field2;
|
|
1561
|
+
column.header = header22;
|
|
1562
|
+
column.order = order2;
|
|
1563
|
+
}, { immediate: true });
|
|
1564
|
+
watch([sortable, compareFn], ([sortable2, compareFn2]) => {
|
|
1565
|
+
column.sortable = sortable2;
|
|
1566
|
+
column.compareFn = compareFn2;
|
|
1567
|
+
});
|
|
1568
|
+
watch([
|
|
1569
|
+
filterable,
|
|
1570
|
+
filterList,
|
|
1571
|
+
filterMultiple
|
|
1572
|
+
], ([filterable2, filterList2, filterMultiple2]) => {
|
|
1573
|
+
column.filterable = filterable2;
|
|
1574
|
+
column.filterMultiple = filterMultiple2;
|
|
1575
|
+
column.filterList = filterList2;
|
|
1576
|
+
}, { immediate: true });
|
|
1577
|
+
watch([fixedLeft, fixedRight], ([left, right]) => {
|
|
1578
|
+
column.fixedLeft = left;
|
|
1579
|
+
column.fixedRight = right;
|
|
1580
|
+
}, { immediate: true });
|
|
1581
|
+
watch([width, minWidth], ([width2, minWidth2]) => {
|
|
1582
|
+
column.width = formatWidth(width2);
|
|
1583
|
+
column.minWidth = formatMinWidth(minWidth2);
|
|
1584
|
+
column.realWidth = column.width || column.minWidth;
|
|
1585
|
+
});
|
|
1586
|
+
onBeforeMount(() => {
|
|
1587
|
+
column.renderHeader = defaultRenderHeader;
|
|
1588
|
+
column.renderCell = defaultRenderCell;
|
|
1589
|
+
column.formatter = formatter.value;
|
|
1590
|
+
column.customFilterTemplate = templates.customFilterTemplate;
|
|
1591
|
+
column.subColumns = templates.subColumns;
|
|
1592
|
+
});
|
|
1593
|
+
return column;
|
|
1594
|
+
}
|
|
1595
|
+
function defaultRenderHeader() {
|
|
1596
|
+
return h("span", { class: "title" }, this.header);
|
|
1597
|
+
}
|
|
1598
|
+
function defaultRenderCell(rowData, index2) {
|
|
1599
|
+
var _a, _b;
|
|
1600
|
+
const value = rowData[this.field];
|
|
1601
|
+
if (this.formatter) {
|
|
1602
|
+
return this.formatter(rowData, value, index2);
|
|
1603
|
+
}
|
|
1604
|
+
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
1605
|
+
}
|
|
1606
|
+
var Column = defineComponent({
|
|
1607
|
+
name: "DColumn",
|
|
1608
|
+
props: TableColumnProps,
|
|
1609
|
+
setup(props, ctx) {
|
|
1610
|
+
const column = createColumn(toRefs(props), ctx.slots);
|
|
1611
|
+
const parent = inject(TABLE_TOKEN);
|
|
1612
|
+
onMounted(() => {
|
|
1613
|
+
parent.store.insertColumn(column);
|
|
1614
|
+
watch(() => column.order, () => {
|
|
1615
|
+
parent.store.sortColumn();
|
|
1616
|
+
});
|
|
1617
|
+
});
|
|
1618
|
+
onBeforeUnmount(() => {
|
|
1619
|
+
parent.store.removeColumn(column);
|
|
1620
|
+
});
|
|
1621
|
+
},
|
|
1622
|
+
render() {
|
|
1623
|
+
return null;
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
class View {
|
|
1627
|
+
constructor() {
|
|
1628
|
+
__publicField(this, "top", "50%");
|
|
1629
|
+
__publicField(this, "left", "50%");
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
const componentProps = {
|
|
1633
|
+
message: String,
|
|
1634
|
+
backdrop: Boolean,
|
|
1635
|
+
view: {
|
|
1636
|
+
type: Object,
|
|
1637
|
+
default: () => new View()
|
|
1638
|
+
},
|
|
1639
|
+
zIndex: Number,
|
|
1640
|
+
isFull: {
|
|
1641
|
+
type: Boolean,
|
|
1642
|
+
default: false
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
class LoadingProps {
|
|
1646
|
+
constructor() {
|
|
1647
|
+
__publicField(this, "target");
|
|
1648
|
+
__publicField(this, "message");
|
|
1649
|
+
__publicField(this, "loadingTemplateRef");
|
|
1650
|
+
__publicField(this, "backdrop", true);
|
|
1651
|
+
__publicField(this, "positionType", "relative");
|
|
1652
|
+
__publicField(this, "view", new View());
|
|
1653
|
+
__publicField(this, "zIndex");
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
var loading = "";
|
|
1657
|
+
var Loading = defineComponent({
|
|
1658
|
+
name: "DLoading",
|
|
1659
|
+
inheritAttrs: false,
|
|
1660
|
+
props: componentProps,
|
|
1661
|
+
setup(props) {
|
|
1662
|
+
const style = {
|
|
1663
|
+
top: props.view.top,
|
|
1664
|
+
left: props.view.left,
|
|
1665
|
+
zIndex: props.zIndex
|
|
1666
|
+
};
|
|
1667
|
+
if (!props.message) {
|
|
1668
|
+
style.background = "none";
|
|
1669
|
+
}
|
|
1670
|
+
const isShow = ref(false);
|
|
1671
|
+
const open = () => {
|
|
1672
|
+
isShow.value = true;
|
|
1673
|
+
};
|
|
1674
|
+
const close = () => {
|
|
1675
|
+
isShow.value = false;
|
|
1676
|
+
};
|
|
1677
|
+
return {
|
|
1678
|
+
style,
|
|
1679
|
+
isShow,
|
|
1680
|
+
open,
|
|
1681
|
+
close
|
|
1682
|
+
};
|
|
1683
|
+
},
|
|
1684
|
+
render() {
|
|
1685
|
+
var _a;
|
|
1686
|
+
const {
|
|
1687
|
+
isShow,
|
|
1688
|
+
isFull,
|
|
1689
|
+
backdrop,
|
|
1690
|
+
style,
|
|
1691
|
+
message,
|
|
1692
|
+
$slots
|
|
1693
|
+
} = this;
|
|
1694
|
+
return isShow && createVNode("div", {
|
|
1695
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
1696
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
1697
|
+
"class": "devui-loading-wrapper"
|
|
1698
|
+
}, [backdrop ? createVNode("div", {
|
|
1699
|
+
"class": "devui-loading-mask"
|
|
1700
|
+
}, null) : null, createVNode("div", {
|
|
1701
|
+
"style": style,
|
|
1702
|
+
"class": "devui-loading-area"
|
|
1703
|
+
}, [createVNode("div", {
|
|
1704
|
+
"class": "devui-busy-default-spinner"
|
|
1705
|
+
}, [createVNode("div", {
|
|
1706
|
+
"class": "devui-loading-bar1"
|
|
1707
|
+
}, null), createVNode("div", {
|
|
1708
|
+
"class": "devui-loading-bar2"
|
|
1709
|
+
}, null), createVNode("div", {
|
|
1710
|
+
"class": "devui-loading-bar3"
|
|
1711
|
+
}, null), createVNode("div", {
|
|
1712
|
+
"class": "devui-loading-bar4"
|
|
1713
|
+
}, null)]), message ? createVNode("span", {
|
|
1714
|
+
"class": "devui-loading-text"
|
|
1715
|
+
}, [message]) : null])])]);
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
1719
|
+
function createComponent(Component, props, children = null) {
|
|
1720
|
+
const vnode = h(Component, __spreadValues({}, props), children);
|
|
1721
|
+
const container = document.createElement("div");
|
|
1722
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
1723
|
+
render(vnode, container);
|
|
1724
|
+
return vnode.component;
|
|
1725
|
+
}
|
|
1726
|
+
function unmountComponent(ComponnetInstance) {
|
|
1727
|
+
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
1728
|
+
}
|
|
1729
|
+
const loadingConstructor = defineComponent(Loading);
|
|
1730
|
+
const cacheInstance = new WeakSet();
|
|
1731
|
+
const isEmpty = (val) => {
|
|
1732
|
+
if (!val)
|
|
1733
|
+
return true;
|
|
1734
|
+
if (Array.isArray(val))
|
|
1735
|
+
return val.length === 0;
|
|
1736
|
+
if (val instanceof Set || val instanceof Map)
|
|
1737
|
+
return val.size === 0;
|
|
1738
|
+
if (val instanceof Promise)
|
|
1739
|
+
return false;
|
|
1740
|
+
if (typeof val === "object") {
|
|
1741
|
+
try {
|
|
1742
|
+
return Object.keys(val).length === 0;
|
|
1743
|
+
} catch (e) {
|
|
1744
|
+
return false;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
return false;
|
|
1748
|
+
};
|
|
1749
|
+
const getType = (vari) => {
|
|
1750
|
+
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
1751
|
+
};
|
|
1752
|
+
const isPromise = (value) => {
|
|
1753
|
+
const type = getType(value);
|
|
1754
|
+
switch (type) {
|
|
1755
|
+
case "promise":
|
|
1756
|
+
return [value];
|
|
1757
|
+
case "array":
|
|
1758
|
+
if (value.some((val) => getType(val) !== "promise")) {
|
|
1759
|
+
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
1760
|
+
return "error";
|
|
1761
|
+
}
|
|
1762
|
+
return value;
|
|
1763
|
+
default:
|
|
1764
|
+
return false;
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
const unmount = (el) => {
|
|
1768
|
+
cacheInstance.delete(el);
|
|
1769
|
+
el.instance.proxy.close();
|
|
1770
|
+
unmountComponent(el.instance);
|
|
1771
|
+
};
|
|
1772
|
+
const toggleLoading = (el, binding) => {
|
|
1773
|
+
if (binding.value) {
|
|
1774
|
+
const vals = isPromise(binding.value);
|
|
1775
|
+
if (vals === "error")
|
|
1776
|
+
return;
|
|
1777
|
+
el.instance.proxy.open();
|
|
1778
|
+
el.appendChild(el.mask);
|
|
1779
|
+
cacheInstance.add(el);
|
|
1780
|
+
if (vals) {
|
|
1781
|
+
Promise.all(vals).catch((err) => {
|
|
1782
|
+
console.error(new Error("Promise handling errors"), err);
|
|
1783
|
+
}).finally(() => {
|
|
1784
|
+
unmount(el);
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
} else {
|
|
1788
|
+
unmount(el);
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
const removeAttribute = (el) => {
|
|
1792
|
+
el.removeAttribute("zindex");
|
|
1793
|
+
el.removeAttribute("positiontype");
|
|
1794
|
+
el.removeAttribute("backdrop");
|
|
1795
|
+
el.removeAttribute("message");
|
|
1796
|
+
el.removeAttribute("view");
|
|
1797
|
+
el.removeAttribute("loadingtemplateref");
|
|
1798
|
+
};
|
|
1799
|
+
const handleProps = (el, vprops) => {
|
|
1800
|
+
const props = __spreadValues(__spreadValues({}, new LoadingProps()), vprops);
|
|
1801
|
+
const loadingTemplateRef = props.loadingTemplateRef;
|
|
1802
|
+
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
1803
|
+
el.style.position = props.positionType;
|
|
1804
|
+
el.options = props;
|
|
1805
|
+
el.instance = loadingInstance;
|
|
1806
|
+
el.mask = loadingInstance.proxy.$el;
|
|
1807
|
+
};
|
|
1808
|
+
const loadingDirective = {
|
|
1809
|
+
mounted: function(el, binding, vnode) {
|
|
1810
|
+
handleProps(el, vnode.props);
|
|
1811
|
+
removeAttribute(el);
|
|
1812
|
+
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
1813
|
+
},
|
|
1814
|
+
updated: function(el, binding, vnode) {
|
|
1815
|
+
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el))
|
|
1816
|
+
return;
|
|
1817
|
+
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
1818
|
+
removeAttribute(el);
|
|
1819
|
+
toggleLoading(el, binding);
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
defineComponent(Loading);
|
|
1823
|
+
Table.install = function(app) {
|
|
1824
|
+
app.directive("dLoading", loadingDirective);
|
|
1825
|
+
app.component(Table.name, Table);
|
|
1826
|
+
app.component(Column.name, Column);
|
|
1827
|
+
};
|
|
1828
|
+
var index = {
|
|
1829
|
+
title: "Table \u8868\u683C",
|
|
1830
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
1831
|
+
status: "10%",
|
|
1832
|
+
install(app) {
|
|
1833
|
+
app.use(Table);
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
export { Column, Table, index as default };
|