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