vue-devui 1.0.0-rc.3 → 1.0.0-rc.6
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 +144 -129
- package/auto-complete/index.es.js +45 -16
- package/auto-complete/index.umd.js +3 -3
- package/auto-complete/style.css +1 -1
- package/button/index.es.js +20 -13
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/comment/index.es.js +2 -1
- package/comment/index.umd.js +1 -1
- package/{tag-input → date-picker}/index.d.ts +0 -0
- package/date-picker/index.es.js +1145 -0
- package/date-picker/index.umd.js +1 -0
- package/date-picker/package.json +7 -0
- package/date-picker/style.css +1 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +236 -0
- package/drawer/index.umd.js +1 -0
- package/{tag-input → drawer}/package.json +1 -1
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +718 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/form/index.d.ts +7 -0
- package/form/index.es.js +7881 -0
- package/form/index.umd.js +27 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/input/index.es.js +13 -19
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +251 -0
- package/input-number/index.umd.js +1 -0
- package/input-number/package.json +7 -0
- package/input-number/style.css +1 -0
- package/layout/index.es.js +3 -1
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +20 -13
- package/loading/index.umd.js +1 -1
- package/modal/index.es.js +16 -4
- package/modal/index.umd.js +1 -1
- package/notification/index.es.js +100 -10
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/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/InputNumber.js +3 -0
- package/nuxt/components/LoadingOptions.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Tab.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/modalProps.js +3 -0
- package/nuxt/components/sliderProps.js +3 -0
- package/nuxt/components/tabsProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/overlay/index.es.js +15 -3
- package/overlay/index.umd.js +1 -1
- package/package.json +2 -2
- package/popover/index.es.js +15 -3
- package/popover/index.umd.js +9 -9
- package/popover/style.css +1 -1
- package/rate/index.es.js +27 -34
- package/rate/index.umd.js +1 -1
- package/read-tip/index.es.js +32 -29
- package/read-tip/index.umd.js +1 -1
- package/read-tip/style.css +1 -1
- package/search/index.es.js +13 -19
- package/search/index.umd.js +12 -12
- package/search/style.css +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +696 -0
- package/select/index.umd.js +1 -0
- package/select/package.json +7 -0
- package/select/style.css +1 -0
- package/skeleton/index.es.js +6 -6
- package/skeleton/index.umd.js +1 -1
- package/slider/index.es.js +19 -10
- package/slider/index.umd.js +1 -1
- package/splitter/index.es.js +15 -3
- package/splitter/index.umd.js +11 -11
- package/style.css +1 -1
- package/switch/index.es.js +1 -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 +2661 -0
- package/table/index.umd.js +1 -0
- package/table/package.json +7 -0
- package/table/style.css +1 -0
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +194 -0
- package/tabs/index.umd.js +1 -0
- package/tabs/package.json +7 -0
- package/tabs/style.css +1 -0
- package/timeline/index.es.js +2 -2
- package/timeline/index.umd.js +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +5847 -0
- package/tooltip/index.umd.js +27 -0
- package/tooltip/package.json +7 -0
- package/tooltip/style.css +1 -0
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +1021 -0
- package/tree/index.umd.js +1 -0
- package/tree/package.json +7 -0
- package/tree/style.css +1 -0
- package/upload/index.es.js +100 -10
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +13211 -7394
- package/vue-devui.umd.js +24 -24
- package/nuxt/components/TagInput.js +0 -3
- package/nuxt/components/tagInputProps.js +0 -3
- package/tag-input/index.es.js +0 -328
- package/tag-input/index.umd.js +0 -1
- package/tag-input/style.css +0 -1
|
@@ -0,0 +1,2661 @@
|
|
|
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, unref, defineComponent, inject, createVNode, toRefs, onMounted, onUnmounted, Teleport, Transition, renderSlot, isVNode, nextTick, mergeProps, Fragment, withDirectives, vShow, h, render, resolveDirective, toRef, provide, createTextVNode, getCurrentInstance, reactive, onBeforeMount, onBeforeUnmount } from "vue";
|
|
25
|
+
import { offset, autoPlacement, arrow, shift, 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
|
+
default: "sm"
|
|
58
|
+
},
|
|
59
|
+
rowHoveredHighlight: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: true
|
|
62
|
+
},
|
|
63
|
+
fixHeader: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
66
|
+
},
|
|
67
|
+
checkable: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
tableLayout: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: "fixed",
|
|
74
|
+
validator(v) {
|
|
75
|
+
return v === "fixed" || v === "auto";
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
showLoading: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
82
|
+
headerBg: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false
|
|
85
|
+
},
|
|
86
|
+
spanMethod: {
|
|
87
|
+
type: Function
|
|
88
|
+
},
|
|
89
|
+
borderType: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: ""
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const TABLE_TOKEN = Symbol();
|
|
95
|
+
function createBem(namespace, element, modifier) {
|
|
96
|
+
let cls = namespace;
|
|
97
|
+
if (element) {
|
|
98
|
+
cls += `__${element}`;
|
|
99
|
+
}
|
|
100
|
+
if (modifier) {
|
|
101
|
+
cls += `--${modifier}`;
|
|
102
|
+
}
|
|
103
|
+
return cls;
|
|
104
|
+
}
|
|
105
|
+
function useNamespace(block) {
|
|
106
|
+
const namespace = `devui-${block}`;
|
|
107
|
+
const b = () => createBem(namespace);
|
|
108
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
109
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
110
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
111
|
+
return {
|
|
112
|
+
b,
|
|
113
|
+
e,
|
|
114
|
+
m,
|
|
115
|
+
em
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function useTable(props) {
|
|
119
|
+
const ns = useNamespace("table");
|
|
120
|
+
const classes = computed(() => ({
|
|
121
|
+
[ns.e("view")]: true,
|
|
122
|
+
[ns.m("striped")]: props.striped,
|
|
123
|
+
[ns.m("header-bg")]: props.headerBg,
|
|
124
|
+
[ns.m("layout-auto")]: props.tableLayout === "auto",
|
|
125
|
+
[ns.m(`${props.size}`)]: true,
|
|
126
|
+
[ns.m(`${props.borderType}`)]: Boolean(props.borderType)
|
|
127
|
+
}));
|
|
128
|
+
const style = computed(() => ({
|
|
129
|
+
maxHeight: props.maxHeight,
|
|
130
|
+
maxWidth: props.maxWidth,
|
|
131
|
+
height: props.tableHeight,
|
|
132
|
+
width: props.tableWidth
|
|
133
|
+
}));
|
|
134
|
+
return { classes, style };
|
|
135
|
+
}
|
|
136
|
+
const useFixedColumn = (column) => {
|
|
137
|
+
const ns = useNamespace("table");
|
|
138
|
+
const stickyClass = computed(() => ({
|
|
139
|
+
[ns.e("checkable-cell")]: column.value.type === "checkable",
|
|
140
|
+
[ns.m("sticky-cell")]: Boolean(column.value.fixedLeft) || Boolean(column.value.fixedRight)
|
|
141
|
+
}));
|
|
142
|
+
const stickyStyle = computed(() => ({
|
|
143
|
+
left: column.value.fixedLeft,
|
|
144
|
+
right: column.value.fixedRight
|
|
145
|
+
}));
|
|
146
|
+
return { stickyClass, stickyStyle };
|
|
147
|
+
};
|
|
148
|
+
function replaceColumn(array, column) {
|
|
149
|
+
return array.map((item) => {
|
|
150
|
+
var _a;
|
|
151
|
+
if (item.id === column.id) {
|
|
152
|
+
return column;
|
|
153
|
+
} else if ((_a = item.children) == null ? void 0 : _a.length) {
|
|
154
|
+
item.children = replaceColumn(item.children, column);
|
|
155
|
+
}
|
|
156
|
+
return item;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function doFlattenColumns(columns) {
|
|
160
|
+
const result = [];
|
|
161
|
+
columns.forEach((column) => {
|
|
162
|
+
if (column.children) {
|
|
163
|
+
result.push.apply(result, doFlattenColumns(column.children));
|
|
164
|
+
} else {
|
|
165
|
+
result.push(column);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
const createColumnGenerator = () => {
|
|
171
|
+
const _columns = ref([]);
|
|
172
|
+
const flatColumns = ref([]);
|
|
173
|
+
const sortColumn = () => {
|
|
174
|
+
_columns.value.sort((a, b) => a.order - b.order);
|
|
175
|
+
};
|
|
176
|
+
const insertColumn = (column, parent) => {
|
|
177
|
+
const array = unref(_columns);
|
|
178
|
+
let newColumns = [];
|
|
179
|
+
if (!parent) {
|
|
180
|
+
array.push(column);
|
|
181
|
+
newColumns = array;
|
|
182
|
+
} else {
|
|
183
|
+
if (parent && !parent.children) {
|
|
184
|
+
parent.children = [];
|
|
185
|
+
}
|
|
186
|
+
parent.children.push(column);
|
|
187
|
+
newColumns = replaceColumn(array, parent);
|
|
188
|
+
}
|
|
189
|
+
sortColumn();
|
|
190
|
+
_columns.value = newColumns;
|
|
191
|
+
};
|
|
192
|
+
const removeColumn = (column) => {
|
|
193
|
+
const i = _columns.value.findIndex((v) => v === column);
|
|
194
|
+
if (i === -1) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
_columns.value.splice(i, 1);
|
|
198
|
+
};
|
|
199
|
+
const updateColumns = () => {
|
|
200
|
+
flatColumns.value = [].concat(doFlattenColumns(_columns.value));
|
|
201
|
+
};
|
|
202
|
+
return { _columns, flatColumns, insertColumn, removeColumn, sortColumn, updateColumns };
|
|
203
|
+
};
|
|
204
|
+
const createSelection = (dataSource, _data) => {
|
|
205
|
+
const _checkList = ref([]);
|
|
206
|
+
const _checkAllRecord = ref(false);
|
|
207
|
+
const _checkAll = computed({
|
|
208
|
+
get: () => _checkAllRecord.value,
|
|
209
|
+
set: (val) => {
|
|
210
|
+
_checkAllRecord.value = val;
|
|
211
|
+
for (let i = 0; i < _checkList.value.length; i++) {
|
|
212
|
+
_checkList.value[i] = val;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
const _halfChecked = ref(false);
|
|
217
|
+
watch(dataSource, (value) => {
|
|
218
|
+
_checkList.value = new Array(value.length).fill(false);
|
|
219
|
+
}, { deep: true, immediate: true });
|
|
220
|
+
watch(_checkList, (list2) => {
|
|
221
|
+
if (list2.length === 0) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
let allTrue = true;
|
|
225
|
+
let allFalse = true;
|
|
226
|
+
for (let i = 0; i < list2.length; i++) {
|
|
227
|
+
allTrue && (allTrue = list2[i]);
|
|
228
|
+
allFalse && (allFalse = !list2[i]);
|
|
229
|
+
}
|
|
230
|
+
_checkAllRecord.value = allTrue;
|
|
231
|
+
_halfChecked.value = !(allFalse || allTrue);
|
|
232
|
+
}, { immediate: true, deep: true });
|
|
233
|
+
const getCheckedRows = () => {
|
|
234
|
+
return _data.value.filter((_, index2) => _checkList.value[index2]);
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
_checkList,
|
|
238
|
+
_checkAll,
|
|
239
|
+
_halfChecked,
|
|
240
|
+
getCheckedRows
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
const createSorter = (dataSource, _data) => {
|
|
244
|
+
const sortData = (direction, sortMethod) => {
|
|
245
|
+
if (direction === "ASC") {
|
|
246
|
+
_data.value = _data.value.sort((a, b) => sortMethod ? sortMethod(a, b) ? 1 : -1 : 0);
|
|
247
|
+
} else if (direction === "DESC") {
|
|
248
|
+
_data.value = _data.value.sort((a, b) => sortMethod ? sortMethod(a, b) ? -1 : 1 : 0);
|
|
249
|
+
} else {
|
|
250
|
+
_data.value = [...dataSource.value];
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const thList = [];
|
|
254
|
+
return { sortData, thList };
|
|
255
|
+
};
|
|
256
|
+
const createFixedLogic = (columns) => {
|
|
257
|
+
const isFixedLeft = computed(() => {
|
|
258
|
+
return columns.value.reduce((prev, current) => prev || !!current.fixedLeft, false);
|
|
259
|
+
});
|
|
260
|
+
return { isFixedLeft };
|
|
261
|
+
};
|
|
262
|
+
function createStore(dataSource) {
|
|
263
|
+
const _data = ref([]);
|
|
264
|
+
watch(dataSource, (value) => {
|
|
265
|
+
_data.value = [...value];
|
|
266
|
+
}, { deep: true, immediate: true });
|
|
267
|
+
const { _columns, flatColumns, insertColumn, removeColumn, sortColumn, updateColumns } = createColumnGenerator();
|
|
268
|
+
const { _checkAll, _checkList, _halfChecked, getCheckedRows } = createSelection(dataSource, _data);
|
|
269
|
+
const { sortData, thList } = createSorter(dataSource, _data);
|
|
270
|
+
const { isFixedLeft } = createFixedLogic(_columns);
|
|
271
|
+
return {
|
|
272
|
+
states: {
|
|
273
|
+
_data,
|
|
274
|
+
_columns,
|
|
275
|
+
flatColumns,
|
|
276
|
+
_checkList,
|
|
277
|
+
_checkAll,
|
|
278
|
+
_halfChecked,
|
|
279
|
+
isFixedLeft,
|
|
280
|
+
thList
|
|
281
|
+
},
|
|
282
|
+
insertColumn,
|
|
283
|
+
sortColumn,
|
|
284
|
+
removeColumn,
|
|
285
|
+
updateColumns,
|
|
286
|
+
getCheckedRows,
|
|
287
|
+
sortData
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
var ColGroup = defineComponent({
|
|
291
|
+
name: "DColGroup",
|
|
292
|
+
setup() {
|
|
293
|
+
const parent = inject(TABLE_TOKEN);
|
|
294
|
+
const columns = parent == null ? void 0 : parent.store.states._columns;
|
|
295
|
+
return () => (parent == null ? void 0 : parent.props.fixHeader) ? createVNode("colgroup", null, [columns == null ? void 0 : columns.value.map((column, index2) => {
|
|
296
|
+
return createVNode("col", {
|
|
297
|
+
"key": index2,
|
|
298
|
+
"width": column.realWidth
|
|
299
|
+
}, null);
|
|
300
|
+
})]) : null;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
const sortProps = {
|
|
304
|
+
sortDirection: {
|
|
305
|
+
type: String,
|
|
306
|
+
default: ""
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var sort = "";
|
|
310
|
+
var Sort = defineComponent({
|
|
311
|
+
props: sortProps,
|
|
312
|
+
emits: ["sort"],
|
|
313
|
+
setup(props, ctx) {
|
|
314
|
+
const directionMap = {
|
|
315
|
+
ASC: "DESC",
|
|
316
|
+
DESC: "",
|
|
317
|
+
default: "ASC"
|
|
318
|
+
};
|
|
319
|
+
const changeDirection = () => {
|
|
320
|
+
ctx.emit("sort", directionMap[props.sortDirection || "default"]);
|
|
321
|
+
};
|
|
322
|
+
return () => createVNode("span", {
|
|
323
|
+
"onClick": changeDirection,
|
|
324
|
+
"class": "sort-clickable"
|
|
325
|
+
}, [createVNode("i", {
|
|
326
|
+
"class": ["datatable-svg", {
|
|
327
|
+
"sort-icon-default": !props.sortDirection,
|
|
328
|
+
"sort-icon-asc": props.sortDirection === "ASC",
|
|
329
|
+
"sort-icon-desc": props.sortDirection === "DESC"
|
|
330
|
+
}]
|
|
331
|
+
}, [createVNode("svg", {
|
|
332
|
+
"width": "16px",
|
|
333
|
+
"height": "16px",
|
|
334
|
+
"viewBox": "0 0 16 16",
|
|
335
|
+
"version": "1.1",
|
|
336
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
337
|
+
}, [createVNode("defs", null, [createVNode("circle", {
|
|
338
|
+
"id": "sort-svg-path-1",
|
|
339
|
+
"cx": "8",
|
|
340
|
+
"cy": "8",
|
|
341
|
+
"r": "8"
|
|
342
|
+
}, null), createVNode("filter", {
|
|
343
|
+
"x": "-34.4%",
|
|
344
|
+
"y": "-21.9%",
|
|
345
|
+
"width": "168.8%",
|
|
346
|
+
"height": "168.8%",
|
|
347
|
+
"filterUnits": "objectBoundingBox",
|
|
348
|
+
"id": "filter-2"
|
|
349
|
+
}, [createVNode("feOffset", {
|
|
350
|
+
"dx": "0",
|
|
351
|
+
"dy": "2",
|
|
352
|
+
"in": "SourceAlpha",
|
|
353
|
+
"result": "shadowOffsetOuter1"
|
|
354
|
+
}, null), createVNode("feGaussianBlur", {
|
|
355
|
+
"stdDeviation": "1.5",
|
|
356
|
+
"in": "shadowOffsetOuter1",
|
|
357
|
+
"result": "shadowBlurOuter1"
|
|
358
|
+
}, null), createVNode("feColorMatrix", {
|
|
359
|
+
"values": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.085309222 0",
|
|
360
|
+
"type": "matrix",
|
|
361
|
+
"in": "shadowBlurOuter1"
|
|
362
|
+
}, null)])]), createVNode("g", {
|
|
363
|
+
"stroke": "none",
|
|
364
|
+
"stroke-width": "1",
|
|
365
|
+
"fill": "none",
|
|
366
|
+
"fill-rule": "evenodd"
|
|
367
|
+
}, [createVNode("use", {
|
|
368
|
+
"fill-rule": "evenodd",
|
|
369
|
+
"xlink:href": "#sort-svg-path-1"
|
|
370
|
+
}, null), createVNode("polygon", {
|
|
371
|
+
"points": "8 4 11 7 5 7"
|
|
372
|
+
}, null), createVNode("polygon", {
|
|
373
|
+
"points": "8 12 5 9 11 9"
|
|
374
|
+
}, null)])])])]);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
const filterProps = {
|
|
378
|
+
filterList: {
|
|
379
|
+
type: Array,
|
|
380
|
+
default: () => []
|
|
381
|
+
},
|
|
382
|
+
multiple: {
|
|
383
|
+
type: Boolean,
|
|
384
|
+
default: true
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const dropdownProps = {
|
|
388
|
+
visible: {
|
|
389
|
+
type: Boolean,
|
|
390
|
+
default: false
|
|
391
|
+
},
|
|
392
|
+
trigger: {
|
|
393
|
+
type: String,
|
|
394
|
+
default: "click"
|
|
395
|
+
},
|
|
396
|
+
closeScope: {
|
|
397
|
+
type: String,
|
|
398
|
+
default: "all"
|
|
399
|
+
},
|
|
400
|
+
position: {
|
|
401
|
+
type: Array,
|
|
402
|
+
default: ["bottom"]
|
|
403
|
+
},
|
|
404
|
+
align: {
|
|
405
|
+
type: String,
|
|
406
|
+
default: null
|
|
407
|
+
},
|
|
408
|
+
offset: {
|
|
409
|
+
type: [Number, Object],
|
|
410
|
+
default: 4
|
|
411
|
+
},
|
|
412
|
+
shiftOffset: {
|
|
413
|
+
type: Number
|
|
414
|
+
},
|
|
415
|
+
closeOnMouseLeaveMenu: {
|
|
416
|
+
type: Boolean,
|
|
417
|
+
default: false
|
|
418
|
+
},
|
|
419
|
+
showAnimation: {
|
|
420
|
+
type: Boolean,
|
|
421
|
+
default: true
|
|
422
|
+
},
|
|
423
|
+
overlayClass: {
|
|
424
|
+
type: String,
|
|
425
|
+
default: ""
|
|
426
|
+
},
|
|
427
|
+
destroyOnHide: {
|
|
428
|
+
type: Boolean,
|
|
429
|
+
default: true
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
function getElement(element) {
|
|
433
|
+
if (element instanceof Element) {
|
|
434
|
+
return element;
|
|
435
|
+
}
|
|
436
|
+
if (element && typeof element === "object" && element.$el instanceof Element) {
|
|
437
|
+
return element.$el;
|
|
438
|
+
}
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
const dropdownMap = /* @__PURE__ */ new Map();
|
|
442
|
+
function subscribeEvent(dom, type, callback) {
|
|
443
|
+
dom == null ? void 0 : dom.addEventListener(type, callback);
|
|
444
|
+
return () => {
|
|
445
|
+
dom == null ? void 0 : dom.removeEventListener(type, callback);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
449
|
+
let overlayEnter = false;
|
|
450
|
+
let originEnter = false;
|
|
451
|
+
const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
|
|
452
|
+
const toggle = (status) => {
|
|
453
|
+
isOpen.value = status;
|
|
454
|
+
emit("toggle", isOpen.value);
|
|
455
|
+
};
|
|
456
|
+
const handleLeave = async (elementType, closeAll) => {
|
|
457
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
458
|
+
if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (closeAll) {
|
|
462
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
463
|
+
setTimeout(() => {
|
|
464
|
+
var _a;
|
|
465
|
+
(_a = item.toggle) == null ? void 0 : _a.call(item);
|
|
466
|
+
}, 0);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
toggle(false);
|
|
470
|
+
};
|
|
471
|
+
watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
|
|
472
|
+
const originEl = getElement(originVal);
|
|
473
|
+
const subscriptions = [];
|
|
474
|
+
setTimeout(() => {
|
|
475
|
+
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
476
|
+
const dropdownValues = [...dropdownMap.values()];
|
|
477
|
+
if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
478
|
+
var _a;
|
|
479
|
+
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
480
|
+
}) && dropdownValues.some((item) => {
|
|
481
|
+
var _a;
|
|
482
|
+
return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
|
|
483
|
+
})) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
[...dropdownMap.values()].reverse().forEach((item) => {
|
|
487
|
+
setTimeout(() => {
|
|
488
|
+
var _a, _b;
|
|
489
|
+
if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
|
|
490
|
+
(_b = item.toggle) == null ? void 0 : _b.call(item);
|
|
491
|
+
}
|
|
492
|
+
}, 0);
|
|
493
|
+
});
|
|
494
|
+
overlayEnter = false;
|
|
495
|
+
}));
|
|
496
|
+
}, 0);
|
|
497
|
+
if (triggerVal === "click") {
|
|
498
|
+
subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
499
|
+
var _a;
|
|
500
|
+
if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
501
|
+
handleLeave("dropdown", true);
|
|
502
|
+
}
|
|
503
|
+
}));
|
|
504
|
+
} else if (triggerVal === "hover") {
|
|
505
|
+
subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
|
|
506
|
+
originEnter = true;
|
|
507
|
+
toggle(true);
|
|
508
|
+
}), subscribeEvent(originEl, "mouseleave", () => {
|
|
509
|
+
originEnter = false;
|
|
510
|
+
handleLeave("origin");
|
|
511
|
+
}), subscribeEvent(dropdownEl, "mouseenter", () => {
|
|
512
|
+
overlayEnter = true;
|
|
513
|
+
isOpen.value = true;
|
|
514
|
+
}), subscribeEvent(dropdownEl, "mouseleave", (e) => {
|
|
515
|
+
var _a;
|
|
516
|
+
overlayEnter = false;
|
|
517
|
+
if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
handleLeave("dropdown", true);
|
|
521
|
+
}));
|
|
522
|
+
}
|
|
523
|
+
onInvalidate(() => subscriptions.forEach((v) => v()));
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
|
|
527
|
+
const calcPopDirection = (dropdownEl) => {
|
|
528
|
+
const elementHeight = dropdownEl.offsetHeight;
|
|
529
|
+
const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
|
|
530
|
+
const isBottomEnough = bottomDistance >= elementHeight;
|
|
531
|
+
if (!isBottomEnough) {
|
|
532
|
+
popDirection.value = "top";
|
|
533
|
+
} else {
|
|
534
|
+
popDirection.value = "bottom";
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
watch(visible, (newVal, oldVal) => {
|
|
538
|
+
if (oldVal === void 0) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
isOpen.value = newVal;
|
|
542
|
+
emit("toggle", isOpen.value);
|
|
543
|
+
}, { immediate: true });
|
|
544
|
+
watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
|
|
545
|
+
var _a;
|
|
546
|
+
if (isOpenVal) {
|
|
547
|
+
dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
|
|
548
|
+
menuEl: dropdownEl,
|
|
549
|
+
toggle: () => {
|
|
550
|
+
isOpen.value = false;
|
|
551
|
+
emit("toggle", isOpen.value);
|
|
552
|
+
}
|
|
553
|
+
}));
|
|
554
|
+
for (const value of dropdownMap.values()) {
|
|
555
|
+
if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
|
|
556
|
+
value.child = dropdownEl;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (dropdownEl) {
|
|
561
|
+
calcPopDirection(dropdownEl);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
onMounted(() => {
|
|
565
|
+
dropdownMap.set(id, { toggleEl: origin.value });
|
|
566
|
+
});
|
|
567
|
+
onUnmounted(() => {
|
|
568
|
+
dropdownMap.delete(id);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function useOverlayProps(props, currentPosition, isOpen) {
|
|
572
|
+
const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
|
|
573
|
+
const overlayModelValue = ref(false);
|
|
574
|
+
const overlayShowValue = ref(false);
|
|
575
|
+
const styles = computed(() => ({
|
|
576
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
577
|
+
}));
|
|
578
|
+
const classes = computed(() => ({
|
|
579
|
+
"fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
|
|
580
|
+
"fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
|
|
581
|
+
[`${overlayClass.value}`]: true
|
|
582
|
+
}));
|
|
583
|
+
const handlePositionChange = (pos) => {
|
|
584
|
+
currentPosition.value = pos.includes("top") || pos.includes("end") ? "top" : "bottom";
|
|
585
|
+
};
|
|
586
|
+
watch(isOpen, (isOpenVal) => {
|
|
587
|
+
overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
|
|
588
|
+
overlayShowValue.value = isOpenVal;
|
|
589
|
+
});
|
|
590
|
+
return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
|
|
591
|
+
}
|
|
592
|
+
var baseOverlay = "";
|
|
593
|
+
function _isSlot$1(s) {
|
|
594
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
595
|
+
}
|
|
596
|
+
const CommonOverlay = defineComponent({
|
|
597
|
+
setup(props, ctx) {
|
|
598
|
+
return () => {
|
|
599
|
+
let _slot;
|
|
600
|
+
return createVNode(Teleport, {
|
|
601
|
+
"to": "#d-overlay-anchor"
|
|
602
|
+
}, {
|
|
603
|
+
default: () => [createVNode(Transition, {
|
|
604
|
+
"name": "devui-overlay-fade"
|
|
605
|
+
}, _isSlot$1(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
606
|
+
default: () => [_slot]
|
|
607
|
+
})]
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
const overlayProps = {
|
|
613
|
+
visible: {
|
|
614
|
+
type: Boolean
|
|
615
|
+
},
|
|
616
|
+
backgroundBlock: {
|
|
617
|
+
type: Boolean,
|
|
618
|
+
default: false
|
|
619
|
+
},
|
|
620
|
+
backgroundClass: {
|
|
621
|
+
type: String,
|
|
622
|
+
default: ""
|
|
623
|
+
},
|
|
624
|
+
backgroundStyle: {
|
|
625
|
+
type: [String, Object]
|
|
626
|
+
},
|
|
627
|
+
onBackdropClick: {
|
|
628
|
+
type: Function
|
|
629
|
+
},
|
|
630
|
+
backdropClose: {
|
|
631
|
+
type: Boolean,
|
|
632
|
+
default: true
|
|
633
|
+
},
|
|
634
|
+
hasBackdrop: {
|
|
635
|
+
type: Boolean,
|
|
636
|
+
default: true
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
640
|
+
overlayStyle: {
|
|
641
|
+
type: [String, Object],
|
|
642
|
+
default: void 0
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
646
|
+
function useOverlayLogic(props, ctx) {
|
|
647
|
+
const backgroundClass = computed(() => {
|
|
648
|
+
return [
|
|
649
|
+
"devui-overlay-background",
|
|
650
|
+
props.backgroundClass,
|
|
651
|
+
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
652
|
+
];
|
|
653
|
+
});
|
|
654
|
+
const overlayClass = computed(() => {
|
|
655
|
+
return "devui-overlay";
|
|
656
|
+
});
|
|
657
|
+
const handleBackdropClick = (event) => {
|
|
658
|
+
var _a;
|
|
659
|
+
event.preventDefault();
|
|
660
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
661
|
+
if (props.backdropClose) {
|
|
662
|
+
ctx.emit("update:visible", false);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
666
|
+
onMounted(() => {
|
|
667
|
+
const body2 = document.body;
|
|
668
|
+
const originOverflow = body2.style.overflow;
|
|
669
|
+
const originPosition = body2.style.position;
|
|
670
|
+
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
671
|
+
if (backgroundBlock) {
|
|
672
|
+
const top = body2.getBoundingClientRect().y;
|
|
673
|
+
if (visible) {
|
|
674
|
+
body2.style.overflowY = "scroll";
|
|
675
|
+
body2.style.position = visible ? "fixed" : "";
|
|
676
|
+
body2.style.top = `${top}px`;
|
|
677
|
+
} else {
|
|
678
|
+
body2.style.overflowY = originOverflow;
|
|
679
|
+
body2.style.position = originPosition;
|
|
680
|
+
body2.style.top = "";
|
|
681
|
+
window.scrollTo(0, -top);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
onUnmounted(() => {
|
|
686
|
+
document.body.style.overflow = originOverflow;
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
return {
|
|
690
|
+
backgroundClass,
|
|
691
|
+
overlayClass,
|
|
692
|
+
handleBackdropClick,
|
|
693
|
+
handleOverlayBubbleCancel
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
var fixedOverlay = "";
|
|
697
|
+
defineComponent({
|
|
698
|
+
name: "DFixedOverlay",
|
|
699
|
+
props: fixedOverlayProps,
|
|
700
|
+
emits: overlayEmits,
|
|
701
|
+
setup(props, ctx) {
|
|
702
|
+
const {
|
|
703
|
+
backgroundClass,
|
|
704
|
+
overlayClass,
|
|
705
|
+
handleBackdropClick,
|
|
706
|
+
handleOverlayBubbleCancel
|
|
707
|
+
} = useOverlayLogic(props, ctx);
|
|
708
|
+
return () => createVNode(CommonOverlay, null, {
|
|
709
|
+
default: () => [props.visible && createVNode("div", {
|
|
710
|
+
"class": backgroundClass.value,
|
|
711
|
+
"style": props.backgroundStyle,
|
|
712
|
+
"onClick": handleBackdropClick
|
|
713
|
+
}, [createVNode("div", {
|
|
714
|
+
"class": overlayClass.value,
|
|
715
|
+
"style": props.overlayStyle,
|
|
716
|
+
"onClick": handleOverlayBubbleCancel
|
|
717
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
const flexibleOverlayProps = {
|
|
722
|
+
modelValue: {
|
|
723
|
+
type: Boolean,
|
|
724
|
+
default: false
|
|
725
|
+
},
|
|
726
|
+
origin: {
|
|
727
|
+
type: Object,
|
|
728
|
+
require: true
|
|
729
|
+
},
|
|
730
|
+
position: {
|
|
731
|
+
type: Array,
|
|
732
|
+
default: ["bottom"]
|
|
733
|
+
},
|
|
734
|
+
offset: {
|
|
735
|
+
type: [Number, Object],
|
|
736
|
+
default: 8
|
|
737
|
+
},
|
|
738
|
+
shiftOffset: {
|
|
739
|
+
type: Number
|
|
740
|
+
},
|
|
741
|
+
align: {
|
|
742
|
+
type: String,
|
|
743
|
+
default: null
|
|
744
|
+
},
|
|
745
|
+
showArrow: {
|
|
746
|
+
type: Boolean,
|
|
747
|
+
default: false
|
|
748
|
+
},
|
|
749
|
+
isArrowCenter: {
|
|
750
|
+
type: Boolean,
|
|
751
|
+
default: true
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
function getScrollParent(element) {
|
|
755
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
756
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
757
|
+
const style = window.getComputedStyle(parent);
|
|
758
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
759
|
+
return parent;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
return window;
|
|
763
|
+
}
|
|
764
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
765
|
+
let { x, y } = point;
|
|
766
|
+
if (!isArrowCenter) {
|
|
767
|
+
const { width, height } = originRect;
|
|
768
|
+
if (x && placement.includes("start")) {
|
|
769
|
+
x = 12;
|
|
770
|
+
}
|
|
771
|
+
if (x && placement.includes("end")) {
|
|
772
|
+
x = Math.round(width - 24);
|
|
773
|
+
}
|
|
774
|
+
if (y && placement.includes("start")) {
|
|
775
|
+
y = 10;
|
|
776
|
+
}
|
|
777
|
+
if (y && placement.includes("end")) {
|
|
778
|
+
y = height - 14;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return { x, y };
|
|
782
|
+
}
|
|
783
|
+
function useOverlay(props, emit) {
|
|
784
|
+
const overlayRef = ref();
|
|
785
|
+
const arrowRef = ref();
|
|
786
|
+
let originParent = null;
|
|
787
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
788
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
789
|
+
const staticSide = {
|
|
790
|
+
top: "bottom",
|
|
791
|
+
right: "left",
|
|
792
|
+
bottom: "top",
|
|
793
|
+
left: "right"
|
|
794
|
+
}[placement.split("-")[0]];
|
|
795
|
+
Object.assign(arrowEl.style, {
|
|
796
|
+
left: x ? `${x}px` : "",
|
|
797
|
+
top: y ? `${y}px` : "",
|
|
798
|
+
right: "",
|
|
799
|
+
bottom: "",
|
|
800
|
+
[staticSide]: "-4px"
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
const updatePosition = async () => {
|
|
804
|
+
const hostEl = props.origin;
|
|
805
|
+
const overlayEl = unref(overlayRef.value);
|
|
806
|
+
const arrowEl = unref(arrowRef.value);
|
|
807
|
+
const middleware = [
|
|
808
|
+
offset(props.offset),
|
|
809
|
+
autoPlacement({
|
|
810
|
+
alignment: props.align,
|
|
811
|
+
allowedPlacements: props.position
|
|
812
|
+
})
|
|
813
|
+
];
|
|
814
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
815
|
+
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
816
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
817
|
+
strategy: "fixed",
|
|
818
|
+
middleware
|
|
819
|
+
});
|
|
820
|
+
let applyX = x;
|
|
821
|
+
let applyY = y;
|
|
822
|
+
if (props.shiftOffset !== void 0) {
|
|
823
|
+
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
824
|
+
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
825
|
+
shiftX > 0 && (applyX += props.shiftOffset);
|
|
826
|
+
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
827
|
+
shiftY > 0 && (applyY += props.shiftOffset);
|
|
828
|
+
}
|
|
829
|
+
emit("positionChange", placement);
|
|
830
|
+
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
831
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
832
|
+
};
|
|
833
|
+
watch(() => props.modelValue, () => {
|
|
834
|
+
if (props.modelValue && props.origin) {
|
|
835
|
+
originParent = getScrollParent(props.origin);
|
|
836
|
+
nextTick(updatePosition);
|
|
837
|
+
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
838
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
839
|
+
window.addEventListener("resize", updatePosition);
|
|
840
|
+
} else {
|
|
841
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
842
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
843
|
+
window.removeEventListener("resize", updatePosition);
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
onUnmounted(() => {
|
|
847
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
848
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
849
|
+
window.removeEventListener("resize", updatePosition);
|
|
850
|
+
});
|
|
851
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
852
|
+
}
|
|
853
|
+
var flexibleOverlay = "";
|
|
854
|
+
const FlexibleOverlay = defineComponent({
|
|
855
|
+
name: "DFlexibleOverlay",
|
|
856
|
+
inheritAttrs: false,
|
|
857
|
+
props: flexibleOverlayProps,
|
|
858
|
+
emits: ["update:modelValue", "positionChange"],
|
|
859
|
+
setup(props, {
|
|
860
|
+
slots,
|
|
861
|
+
attrs,
|
|
862
|
+
emit,
|
|
863
|
+
expose
|
|
864
|
+
}) {
|
|
865
|
+
const {
|
|
866
|
+
arrowRef,
|
|
867
|
+
overlayRef,
|
|
868
|
+
updatePosition
|
|
869
|
+
} = useOverlay(props, emit);
|
|
870
|
+
expose({
|
|
871
|
+
updatePosition
|
|
872
|
+
});
|
|
873
|
+
return () => {
|
|
874
|
+
var _a;
|
|
875
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
876
|
+
"ref": overlayRef,
|
|
877
|
+
"class": "devui-flexible-overlay"
|
|
878
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
879
|
+
"ref": arrowRef,
|
|
880
|
+
"class": "devui-flexible-overlay-arrow"
|
|
881
|
+
}, null)]);
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
var dropdown = "";
|
|
886
|
+
let dropdownId = 1;
|
|
887
|
+
var Dropdown = defineComponent({
|
|
888
|
+
name: "DDropdown",
|
|
889
|
+
inheritAttrs: false,
|
|
890
|
+
props: dropdownProps,
|
|
891
|
+
emits: ["toggle"],
|
|
892
|
+
setup(props, {
|
|
893
|
+
slots,
|
|
894
|
+
attrs,
|
|
895
|
+
emit,
|
|
896
|
+
expose
|
|
897
|
+
}) {
|
|
898
|
+
const {
|
|
899
|
+
visible,
|
|
900
|
+
position,
|
|
901
|
+
align,
|
|
902
|
+
offset: offset2,
|
|
903
|
+
destroyOnHide,
|
|
904
|
+
shiftOffset,
|
|
905
|
+
showAnimation
|
|
906
|
+
} = toRefs(props);
|
|
907
|
+
const origin = ref();
|
|
908
|
+
const dropdownRef = ref();
|
|
909
|
+
const overlayRef = ref();
|
|
910
|
+
const id = `dropdown_${dropdownId++}`;
|
|
911
|
+
const isOpen = ref(false);
|
|
912
|
+
const currentPosition = ref("bottom");
|
|
913
|
+
useDropdownEvent({
|
|
914
|
+
id,
|
|
915
|
+
isOpen,
|
|
916
|
+
origin,
|
|
917
|
+
dropdownRef,
|
|
918
|
+
props,
|
|
919
|
+
emit
|
|
920
|
+
});
|
|
921
|
+
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
|
|
922
|
+
const {
|
|
923
|
+
overlayModelValue,
|
|
924
|
+
overlayShowValue,
|
|
925
|
+
styles,
|
|
926
|
+
classes,
|
|
927
|
+
handlePositionChange
|
|
928
|
+
} = useOverlayProps(props, currentPosition, isOpen);
|
|
929
|
+
watch(overlayShowValue, (overlayShowValueVal) => {
|
|
930
|
+
nextTick(() => {
|
|
931
|
+
if (!destroyOnHide.value && overlayShowValueVal) {
|
|
932
|
+
overlayRef.value.updatePosition();
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
expose({
|
|
937
|
+
updatePosition: () => overlayRef.value.updatePosition()
|
|
938
|
+
});
|
|
939
|
+
return () => {
|
|
940
|
+
var _a;
|
|
941
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
942
|
+
"ref": origin,
|
|
943
|
+
"class": "devui-dropdown-toggle"
|
|
944
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
945
|
+
"to": "body"
|
|
946
|
+
}, {
|
|
947
|
+
default: () => [createVNode(Transition, {
|
|
948
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
949
|
+
}, {
|
|
950
|
+
default: () => [withDirectives(createVNode(FlexibleOverlay, {
|
|
951
|
+
"modelValue": overlayModelValue.value,
|
|
952
|
+
"onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
|
|
953
|
+
"ref": overlayRef,
|
|
954
|
+
"origin": origin.value,
|
|
955
|
+
"position": position.value,
|
|
956
|
+
"align": align.value,
|
|
957
|
+
"offset": offset2.value,
|
|
958
|
+
"shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
|
|
959
|
+
"onPositionChange": handlePositionChange,
|
|
960
|
+
"class": classes.value,
|
|
961
|
+
"style": styles.value
|
|
962
|
+
}, {
|
|
963
|
+
default: () => {
|
|
964
|
+
var _a2;
|
|
965
|
+
return [createVNode("div", mergeProps({
|
|
966
|
+
"ref": dropdownRef,
|
|
967
|
+
"class": "devui-dropdown-menu-wrap"
|
|
968
|
+
}, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
|
|
969
|
+
}
|
|
970
|
+
}), [[vShow, overlayShowValue.value]])]
|
|
971
|
+
})]
|
|
972
|
+
})]);
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
const dropdownMenuProps = {
|
|
977
|
+
modelValue: {
|
|
978
|
+
type: Boolean,
|
|
979
|
+
default: false
|
|
980
|
+
},
|
|
981
|
+
origin: {
|
|
982
|
+
type: Object,
|
|
983
|
+
require: true
|
|
984
|
+
},
|
|
985
|
+
position: {
|
|
986
|
+
type: Array,
|
|
987
|
+
default: ["bottom"]
|
|
988
|
+
},
|
|
989
|
+
align: {
|
|
990
|
+
type: String,
|
|
991
|
+
default: null
|
|
992
|
+
},
|
|
993
|
+
offset: {
|
|
994
|
+
type: [Number, Object],
|
|
995
|
+
default: 4
|
|
996
|
+
},
|
|
997
|
+
clickOutside: {
|
|
998
|
+
type: Function,
|
|
999
|
+
default: () => true
|
|
1000
|
+
},
|
|
1001
|
+
showAnimation: {
|
|
1002
|
+
type: Boolean,
|
|
1003
|
+
default: true
|
|
1004
|
+
},
|
|
1005
|
+
overlayClass: {
|
|
1006
|
+
type: String,
|
|
1007
|
+
default: ""
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
defineComponent({
|
|
1011
|
+
name: "DDropdownMenu",
|
|
1012
|
+
inheritAttrs: false,
|
|
1013
|
+
props: dropdownMenuProps,
|
|
1014
|
+
emits: ["update:modelValue"],
|
|
1015
|
+
setup(props, {
|
|
1016
|
+
slots,
|
|
1017
|
+
attrs,
|
|
1018
|
+
emit
|
|
1019
|
+
}) {
|
|
1020
|
+
const {
|
|
1021
|
+
modelValue,
|
|
1022
|
+
origin,
|
|
1023
|
+
position,
|
|
1024
|
+
align,
|
|
1025
|
+
offset: offset2,
|
|
1026
|
+
clickOutside,
|
|
1027
|
+
showAnimation,
|
|
1028
|
+
overlayClass
|
|
1029
|
+
} = toRefs(props);
|
|
1030
|
+
const dropdownMenuRef = ref(null);
|
|
1031
|
+
onClickOutside(dropdownMenuRef, (value) => {
|
|
1032
|
+
var _a, _b;
|
|
1033
|
+
if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
|
|
1034
|
+
emit("update:modelValue", false);
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
const currentPosition = ref("bottom");
|
|
1038
|
+
const handlePositionChange = (pos) => {
|
|
1039
|
+
currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
|
|
1040
|
+
};
|
|
1041
|
+
const styles = computed(() => ({
|
|
1042
|
+
transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
|
|
1043
|
+
}));
|
|
1044
|
+
return () => createVNode(Teleport, {
|
|
1045
|
+
"to": "body"
|
|
1046
|
+
}, {
|
|
1047
|
+
default: () => [createVNode(Transition, {
|
|
1048
|
+
"name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
|
|
1049
|
+
}, {
|
|
1050
|
+
default: () => [createVNode(FlexibleOverlay, {
|
|
1051
|
+
"modelValue": modelValue.value,
|
|
1052
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
1053
|
+
"origin": origin == null ? void 0 : origin.value,
|
|
1054
|
+
"position": position.value,
|
|
1055
|
+
"align": align.value,
|
|
1056
|
+
"offset": offset2.value,
|
|
1057
|
+
"onPositionChange": handlePositionChange,
|
|
1058
|
+
"class": overlayClass.value,
|
|
1059
|
+
"style": styles.value
|
|
1060
|
+
}, {
|
|
1061
|
+
default: () => {
|
|
1062
|
+
var _a;
|
|
1063
|
+
return [createVNode("div", mergeProps({
|
|
1064
|
+
"ref": dropdownMenuRef,
|
|
1065
|
+
"class": "devui-dropdown-menu-wrap"
|
|
1066
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
|
|
1067
|
+
}
|
|
1068
|
+
})]
|
|
1069
|
+
})]
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
const iconProps = {
|
|
1074
|
+
name: {
|
|
1075
|
+
type: String,
|
|
1076
|
+
default: "",
|
|
1077
|
+
required: true
|
|
1078
|
+
},
|
|
1079
|
+
size: {
|
|
1080
|
+
type: String,
|
|
1081
|
+
default: "inherit"
|
|
1082
|
+
},
|
|
1083
|
+
color: {
|
|
1084
|
+
type: String,
|
|
1085
|
+
default: "inherit"
|
|
1086
|
+
},
|
|
1087
|
+
classPrefix: {
|
|
1088
|
+
type: String,
|
|
1089
|
+
default: "icon"
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
var Icon = defineComponent({
|
|
1093
|
+
name: "DIcon",
|
|
1094
|
+
props: iconProps,
|
|
1095
|
+
setup(props) {
|
|
1096
|
+
const {
|
|
1097
|
+
name,
|
|
1098
|
+
size,
|
|
1099
|
+
color,
|
|
1100
|
+
classPrefix
|
|
1101
|
+
} = toRefs(props);
|
|
1102
|
+
return () => {
|
|
1103
|
+
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
1104
|
+
"src": name.value,
|
|
1105
|
+
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
1106
|
+
"style": {
|
|
1107
|
+
width: size.value,
|
|
1108
|
+
verticalAlign: "text-bottom"
|
|
1109
|
+
}
|
|
1110
|
+
}, null) : createVNode("i", {
|
|
1111
|
+
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
1112
|
+
"style": {
|
|
1113
|
+
fontSize: size.value,
|
|
1114
|
+
color: color.value
|
|
1115
|
+
}
|
|
1116
|
+
}, null);
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
class View {
|
|
1121
|
+
constructor() {
|
|
1122
|
+
__publicField(this, "top", "50%");
|
|
1123
|
+
__publicField(this, "left", "50%");
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
const loadingProps = {
|
|
1127
|
+
message: String,
|
|
1128
|
+
backdrop: Boolean,
|
|
1129
|
+
view: {
|
|
1130
|
+
type: Object,
|
|
1131
|
+
default: () => new View()
|
|
1132
|
+
},
|
|
1133
|
+
zIndex: Number,
|
|
1134
|
+
isFull: {
|
|
1135
|
+
type: Boolean,
|
|
1136
|
+
default: false
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
class LoadingOptions {
|
|
1140
|
+
constructor() {
|
|
1141
|
+
__publicField(this, "target");
|
|
1142
|
+
__publicField(this, "message");
|
|
1143
|
+
__publicField(this, "loadingTemplateRef");
|
|
1144
|
+
__publicField(this, "backdrop", true);
|
|
1145
|
+
__publicField(this, "positionType", "relative");
|
|
1146
|
+
__publicField(this, "view", new View());
|
|
1147
|
+
__publicField(this, "zIndex");
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
var loading = "";
|
|
1151
|
+
var Loading = defineComponent({
|
|
1152
|
+
name: "DLoading",
|
|
1153
|
+
inheritAttrs: false,
|
|
1154
|
+
props: loadingProps,
|
|
1155
|
+
setup(props) {
|
|
1156
|
+
const style = {
|
|
1157
|
+
top: props.view.top,
|
|
1158
|
+
left: props.view.left,
|
|
1159
|
+
zIndex: props.zIndex
|
|
1160
|
+
};
|
|
1161
|
+
if (!props.message) {
|
|
1162
|
+
style.background = "none";
|
|
1163
|
+
}
|
|
1164
|
+
const isShow = ref(false);
|
|
1165
|
+
const open = () => {
|
|
1166
|
+
isShow.value = true;
|
|
1167
|
+
};
|
|
1168
|
+
const close = () => {
|
|
1169
|
+
isShow.value = false;
|
|
1170
|
+
};
|
|
1171
|
+
return {
|
|
1172
|
+
style,
|
|
1173
|
+
isShow,
|
|
1174
|
+
open,
|
|
1175
|
+
close
|
|
1176
|
+
};
|
|
1177
|
+
},
|
|
1178
|
+
render() {
|
|
1179
|
+
var _a;
|
|
1180
|
+
const {
|
|
1181
|
+
isShow,
|
|
1182
|
+
isFull,
|
|
1183
|
+
backdrop,
|
|
1184
|
+
style,
|
|
1185
|
+
message,
|
|
1186
|
+
$slots
|
|
1187
|
+
} = this;
|
|
1188
|
+
return isShow && createVNode("div", {
|
|
1189
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
1190
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
1191
|
+
"class": "devui-loading-wrapper"
|
|
1192
|
+
}, [backdrop ? createVNode("div", {
|
|
1193
|
+
"class": "devui-loading-mask"
|
|
1194
|
+
}, null) : null, createVNode("div", {
|
|
1195
|
+
"style": style,
|
|
1196
|
+
"class": "devui-loading-area"
|
|
1197
|
+
}, [createVNode("div", {
|
|
1198
|
+
"class": "devui-busy-default-spinner"
|
|
1199
|
+
}, [createVNode("div", {
|
|
1200
|
+
"class": "devui-loading-bar1"
|
|
1201
|
+
}, null), createVNode("div", {
|
|
1202
|
+
"class": "devui-loading-bar2"
|
|
1203
|
+
}, null), createVNode("div", {
|
|
1204
|
+
"class": "devui-loading-bar3"
|
|
1205
|
+
}, null), createVNode("div", {
|
|
1206
|
+
"class": "devui-loading-bar4"
|
|
1207
|
+
}, null)]), message ? createVNode("span", {
|
|
1208
|
+
"class": "devui-loading-text"
|
|
1209
|
+
}, [message]) : null])])]);
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
1213
|
+
function createComponent(component, props, children = null) {
|
|
1214
|
+
const vnode = h(component, __spreadValues({}, props), children);
|
|
1215
|
+
const container = document.createElement("div");
|
|
1216
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
1217
|
+
render(vnode, container);
|
|
1218
|
+
return vnode.component;
|
|
1219
|
+
}
|
|
1220
|
+
function unmountComponent(ComponnetInstance) {
|
|
1221
|
+
render(null, ComponnetInstance == null ? void 0 : ComponnetInstance.vnode[COMPONENT_CONTAINER_SYMBOL]);
|
|
1222
|
+
}
|
|
1223
|
+
const loadingConstructor = defineComponent(Loading);
|
|
1224
|
+
const cacheInstance = /* @__PURE__ */ new WeakSet();
|
|
1225
|
+
const isEmpty = (val) => {
|
|
1226
|
+
if (!val) {
|
|
1227
|
+
return true;
|
|
1228
|
+
}
|
|
1229
|
+
if (Array.isArray(val)) {
|
|
1230
|
+
return val.length === 0;
|
|
1231
|
+
}
|
|
1232
|
+
if (val instanceof Set || val instanceof Map) {
|
|
1233
|
+
return val.size === 0;
|
|
1234
|
+
}
|
|
1235
|
+
if (val instanceof Promise) {
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
if (typeof val === "object") {
|
|
1239
|
+
try {
|
|
1240
|
+
return Object.keys(val).length === 0;
|
|
1241
|
+
} catch (e) {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return false;
|
|
1246
|
+
};
|
|
1247
|
+
const getType = (vari) => {
|
|
1248
|
+
return Object.prototype.toString.call(vari).slice(8, -1).toLowerCase();
|
|
1249
|
+
};
|
|
1250
|
+
const isPromise = (value) => {
|
|
1251
|
+
const type = getType(value);
|
|
1252
|
+
switch (type) {
|
|
1253
|
+
case "promise":
|
|
1254
|
+
return [value];
|
|
1255
|
+
case "array":
|
|
1256
|
+
if (value.some((val) => getType(val) !== "promise")) {
|
|
1257
|
+
console.error(new TypeError("Binding values should all be of type Promise"));
|
|
1258
|
+
return "error";
|
|
1259
|
+
}
|
|
1260
|
+
return value;
|
|
1261
|
+
default:
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
const unmount = (el) => {
|
|
1266
|
+
cacheInstance.delete(el);
|
|
1267
|
+
el.instance.proxy.close();
|
|
1268
|
+
unmountComponent(el.instance);
|
|
1269
|
+
};
|
|
1270
|
+
const toggleLoading = (el, binding) => {
|
|
1271
|
+
var _a, _b, _c;
|
|
1272
|
+
if (binding.value) {
|
|
1273
|
+
const vals = isPromise(binding.value);
|
|
1274
|
+
if (vals === "error") {
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
(_c = (_b = (_a = el == null ? void 0 : el.instance) == null ? void 0 : _a.proxy) == null ? void 0 : _b.open) == null ? void 0 : _c.call(_b);
|
|
1278
|
+
el.appendChild(el.mask);
|
|
1279
|
+
cacheInstance.add(el);
|
|
1280
|
+
if (vals) {
|
|
1281
|
+
Promise.all(vals).catch((err) => {
|
|
1282
|
+
console.error(new Error("Promise handling errors"), err);
|
|
1283
|
+
}).finally(() => {
|
|
1284
|
+
unmount(el);
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
} else {
|
|
1288
|
+
unmount(el);
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
const removeAttribute = (el) => {
|
|
1292
|
+
el.removeAttribute("zindex");
|
|
1293
|
+
el.removeAttribute("positiontype");
|
|
1294
|
+
el.removeAttribute("backdrop");
|
|
1295
|
+
el.removeAttribute("message");
|
|
1296
|
+
el.removeAttribute("view");
|
|
1297
|
+
el.removeAttribute("loadingtemplateref");
|
|
1298
|
+
};
|
|
1299
|
+
const handleProps = (el, vprops) => {
|
|
1300
|
+
var _a;
|
|
1301
|
+
const props = __spreadValues(__spreadValues({}, new LoadingOptions()), vprops);
|
|
1302
|
+
const loadingTemplateRef = props.loadingTemplateRef;
|
|
1303
|
+
const loadingInstance = createComponent(loadingConstructor, __spreadValues({}, props), loadingTemplateRef ? () => loadingTemplateRef : null);
|
|
1304
|
+
el.style.position = props.positionType;
|
|
1305
|
+
el.options = props;
|
|
1306
|
+
el.instance = loadingInstance;
|
|
1307
|
+
el.mask = (_a = loadingInstance == null ? void 0 : loadingInstance.proxy) == null ? void 0 : _a.$el;
|
|
1308
|
+
};
|
|
1309
|
+
const loadingDirective = {
|
|
1310
|
+
mounted: function(el, binding, vnode) {
|
|
1311
|
+
handleProps(el, vnode.props);
|
|
1312
|
+
removeAttribute(el);
|
|
1313
|
+
!isEmpty(binding.value) && toggleLoading(el, binding);
|
|
1314
|
+
},
|
|
1315
|
+
updated: function(el, binding, vnode) {
|
|
1316
|
+
if (!isEmpty(binding.value) && cacheInstance.has(el) || isEmpty(binding.value) && !cacheInstance.has(el)) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
!cacheInstance.has(el) && handleProps(el, vnode.props);
|
|
1320
|
+
removeAttribute(el);
|
|
1321
|
+
toggleLoading(el, binding);
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
const buttonProps = {
|
|
1325
|
+
variant: {
|
|
1326
|
+
type: String,
|
|
1327
|
+
default: "outline"
|
|
1328
|
+
},
|
|
1329
|
+
size: {
|
|
1330
|
+
type: String,
|
|
1331
|
+
default: "md"
|
|
1332
|
+
},
|
|
1333
|
+
color: {
|
|
1334
|
+
type: String
|
|
1335
|
+
},
|
|
1336
|
+
icon: {
|
|
1337
|
+
type: String,
|
|
1338
|
+
default: ""
|
|
1339
|
+
},
|
|
1340
|
+
loading: {
|
|
1341
|
+
type: Boolean,
|
|
1342
|
+
default: false
|
|
1343
|
+
},
|
|
1344
|
+
disabled: {
|
|
1345
|
+
type: Boolean,
|
|
1346
|
+
default: false
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
function useButton(props, ctx) {
|
|
1350
|
+
const hasContent = computed(() => ctx.slots.default);
|
|
1351
|
+
const colorMap = {
|
|
1352
|
+
solid: "primary",
|
|
1353
|
+
outline: "secondary",
|
|
1354
|
+
text: "secondary"
|
|
1355
|
+
};
|
|
1356
|
+
const defaultColor = colorMap[props.variant];
|
|
1357
|
+
const classes = computed(() => ({
|
|
1358
|
+
"devui-btn": true,
|
|
1359
|
+
[`devui-btn-${props.variant}`]: true,
|
|
1360
|
+
[`devui-btn-${props.variant}-${props.color || defaultColor}`]: true,
|
|
1361
|
+
[`devui-btn-${props.size}`]: true,
|
|
1362
|
+
"devui-btn-icon-wrap": props.icon,
|
|
1363
|
+
"devui-btn-icon": props.icon && !hasContent.value && props.variant !== "solid"
|
|
1364
|
+
}));
|
|
1365
|
+
const iconClass = computed(() => {
|
|
1366
|
+
if (!props.icon) {
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
const origin = "devui-icon-fix icon";
|
|
1370
|
+
if (hasContent.value) {
|
|
1371
|
+
return `${origin} clear-right-5`;
|
|
1372
|
+
} else {
|
|
1373
|
+
return origin;
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
return { classes, iconClass };
|
|
1377
|
+
}
|
|
1378
|
+
var button = "";
|
|
1379
|
+
var Button = defineComponent({
|
|
1380
|
+
name: "DButton",
|
|
1381
|
+
directives: {
|
|
1382
|
+
dLoading: loadingDirective
|
|
1383
|
+
},
|
|
1384
|
+
props: buttonProps,
|
|
1385
|
+
emits: ["click"],
|
|
1386
|
+
setup(props, ctx) {
|
|
1387
|
+
const {
|
|
1388
|
+
icon,
|
|
1389
|
+
disabled,
|
|
1390
|
+
loading: loading2
|
|
1391
|
+
} = toRefs(props);
|
|
1392
|
+
const {
|
|
1393
|
+
classes,
|
|
1394
|
+
iconClass
|
|
1395
|
+
} = useButton(props, ctx);
|
|
1396
|
+
const onClick = (e) => {
|
|
1397
|
+
if (loading2.value) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
ctx.emit("click", e);
|
|
1401
|
+
};
|
|
1402
|
+
return () => {
|
|
1403
|
+
var _a, _b;
|
|
1404
|
+
return withDirectives(createVNode("button", {
|
|
1405
|
+
"class": classes.value,
|
|
1406
|
+
"disabled": disabled.value,
|
|
1407
|
+
"onClick": onClick
|
|
1408
|
+
}, [icon.value && createVNode(Icon, {
|
|
1409
|
+
"name": icon.value,
|
|
1410
|
+
"size": "var(--devui-font-size, 12px)",
|
|
1411
|
+
"color": "",
|
|
1412
|
+
"class": iconClass.value
|
|
1413
|
+
}, null), createVNode("span", {
|
|
1414
|
+
"class": "button-content"
|
|
1415
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), [[resolveDirective("dLoading"), loading2.value]]);
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
var checkbox = "";
|
|
1420
|
+
const commonProps = {
|
|
1421
|
+
name: {
|
|
1422
|
+
type: String,
|
|
1423
|
+
default: void 0
|
|
1424
|
+
},
|
|
1425
|
+
halfchecked: {
|
|
1426
|
+
type: Boolean,
|
|
1427
|
+
default: false
|
|
1428
|
+
},
|
|
1429
|
+
isShowTitle: {
|
|
1430
|
+
type: Boolean,
|
|
1431
|
+
default: true
|
|
1432
|
+
},
|
|
1433
|
+
title: {
|
|
1434
|
+
type: String
|
|
1435
|
+
},
|
|
1436
|
+
color: {
|
|
1437
|
+
type: String,
|
|
1438
|
+
default: void 0
|
|
1439
|
+
},
|
|
1440
|
+
showAnimation: {
|
|
1441
|
+
type: Boolean,
|
|
1442
|
+
default: true
|
|
1443
|
+
},
|
|
1444
|
+
disabled: {
|
|
1445
|
+
type: Boolean,
|
|
1446
|
+
default: false
|
|
1447
|
+
},
|
|
1448
|
+
beforeChange: {
|
|
1449
|
+
type: Function,
|
|
1450
|
+
default: void 0
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
1454
|
+
halfchecked: {
|
|
1455
|
+
type: Boolean,
|
|
1456
|
+
default: false
|
|
1457
|
+
},
|
|
1458
|
+
checked: {
|
|
1459
|
+
type: Boolean,
|
|
1460
|
+
default: false
|
|
1461
|
+
},
|
|
1462
|
+
value: {
|
|
1463
|
+
type: String
|
|
1464
|
+
},
|
|
1465
|
+
label: {
|
|
1466
|
+
type: String,
|
|
1467
|
+
default: void 0
|
|
1468
|
+
},
|
|
1469
|
+
title: {
|
|
1470
|
+
type: String,
|
|
1471
|
+
default: void 0
|
|
1472
|
+
},
|
|
1473
|
+
"onUpdate:checked": {
|
|
1474
|
+
type: Function,
|
|
1475
|
+
default: void 0
|
|
1476
|
+
},
|
|
1477
|
+
onChange: {
|
|
1478
|
+
type: Function,
|
|
1479
|
+
default: void 0
|
|
1480
|
+
},
|
|
1481
|
+
modelValue: {
|
|
1482
|
+
type: Boolean
|
|
1483
|
+
},
|
|
1484
|
+
"onUpdate:modelValue": {
|
|
1485
|
+
type: Function
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
1489
|
+
modelValue: {
|
|
1490
|
+
type: Array,
|
|
1491
|
+
required: true
|
|
1492
|
+
},
|
|
1493
|
+
direction: {
|
|
1494
|
+
type: String,
|
|
1495
|
+
default: "column"
|
|
1496
|
+
},
|
|
1497
|
+
itemWidth: {
|
|
1498
|
+
type: Number,
|
|
1499
|
+
default: void 0
|
|
1500
|
+
},
|
|
1501
|
+
options: {
|
|
1502
|
+
type: Array,
|
|
1503
|
+
default: () => []
|
|
1504
|
+
},
|
|
1505
|
+
onChange: {
|
|
1506
|
+
type: Function,
|
|
1507
|
+
default: void 0
|
|
1508
|
+
},
|
|
1509
|
+
"onUpdate:modelValue": {
|
|
1510
|
+
type: Function,
|
|
1511
|
+
default: void 0
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
|
|
1515
|
+
var Checkbox = defineComponent({
|
|
1516
|
+
name: "DCheckbox",
|
|
1517
|
+
props: checkboxProps,
|
|
1518
|
+
emits: ["change", "update:checked", "update:modelValue"],
|
|
1519
|
+
setup(props, ctx) {
|
|
1520
|
+
const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
|
|
1521
|
+
const isChecked = computed(() => props.checked || props.modelValue);
|
|
1522
|
+
const mergedDisabled = computed(() => {
|
|
1523
|
+
return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
|
|
1524
|
+
});
|
|
1525
|
+
const mergedChecked = computed(() => {
|
|
1526
|
+
var _a, _b;
|
|
1527
|
+
return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
|
|
1528
|
+
});
|
|
1529
|
+
const mergedIsShowTitle = computed(() => {
|
|
1530
|
+
var _a;
|
|
1531
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
1532
|
+
});
|
|
1533
|
+
const mergedShowAnimation = computed(() => {
|
|
1534
|
+
var _a;
|
|
1535
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
1536
|
+
});
|
|
1537
|
+
const mergedColor = computed(() => {
|
|
1538
|
+
var _a;
|
|
1539
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
1540
|
+
});
|
|
1541
|
+
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
1542
|
+
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
1543
|
+
const canChange = (checked, val) => {
|
|
1544
|
+
var _a;
|
|
1545
|
+
if (mergedDisabled.value) {
|
|
1546
|
+
return Promise.resolve(false);
|
|
1547
|
+
}
|
|
1548
|
+
const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
|
|
1549
|
+
if (beforeChange) {
|
|
1550
|
+
const res = beforeChange(checked, val);
|
|
1551
|
+
if (typeof res === "boolean") {
|
|
1552
|
+
return Promise.resolve(res);
|
|
1553
|
+
}
|
|
1554
|
+
return res;
|
|
1555
|
+
}
|
|
1556
|
+
return Promise.resolve(true);
|
|
1557
|
+
};
|
|
1558
|
+
const toggle = () => {
|
|
1559
|
+
const current = !isChecked.value;
|
|
1560
|
+
checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
|
|
1561
|
+
ctx.emit("update:checked", current);
|
|
1562
|
+
ctx.emit("update:modelValue", current);
|
|
1563
|
+
ctx.emit("change", current);
|
|
1564
|
+
};
|
|
1565
|
+
const handleClick = () => {
|
|
1566
|
+
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
1567
|
+
};
|
|
1568
|
+
return {
|
|
1569
|
+
itemWidth,
|
|
1570
|
+
direction,
|
|
1571
|
+
mergedColor,
|
|
1572
|
+
mergedDisabled,
|
|
1573
|
+
mergedIsShowTitle,
|
|
1574
|
+
mergedChecked,
|
|
1575
|
+
mergedShowAnimation,
|
|
1576
|
+
handleClick
|
|
1577
|
+
};
|
|
1578
|
+
},
|
|
1579
|
+
render() {
|
|
1580
|
+
var _a;
|
|
1581
|
+
const {
|
|
1582
|
+
itemWidth,
|
|
1583
|
+
direction,
|
|
1584
|
+
mergedChecked,
|
|
1585
|
+
mergedDisabled,
|
|
1586
|
+
mergedIsShowTitle,
|
|
1587
|
+
mergedShowAnimation,
|
|
1588
|
+
halfchecked,
|
|
1589
|
+
title,
|
|
1590
|
+
label,
|
|
1591
|
+
handleClick,
|
|
1592
|
+
name,
|
|
1593
|
+
value,
|
|
1594
|
+
mergedColor,
|
|
1595
|
+
$slots
|
|
1596
|
+
} = this;
|
|
1597
|
+
const wrapperCls = {
|
|
1598
|
+
"devui-checkbox-column-margin": direction === "column",
|
|
1599
|
+
"devui-checkbox-wrap": typeof itemWidth !== "undefined"
|
|
1600
|
+
};
|
|
1601
|
+
const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
|
|
1602
|
+
const checkboxCls = {
|
|
1603
|
+
"devui-checkbox": true,
|
|
1604
|
+
active: mergedChecked,
|
|
1605
|
+
halfchecked,
|
|
1606
|
+
disabled: mergedDisabled,
|
|
1607
|
+
unchecked: !mergedChecked
|
|
1608
|
+
};
|
|
1609
|
+
const labelTitle = mergedIsShowTitle ? title || label : "";
|
|
1610
|
+
const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
|
|
1611
|
+
const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
|
|
1612
|
+
const spanCls = {
|
|
1613
|
+
"devui-checkbox-material": true,
|
|
1614
|
+
"custom-color": mergedColor,
|
|
1615
|
+
"devui-checkbox-no-label": !label && !$slots.default,
|
|
1616
|
+
"devui-no-animation": !mergedShowAnimation,
|
|
1617
|
+
"devui-checkbox-default-background": !halfchecked
|
|
1618
|
+
};
|
|
1619
|
+
const polygonCls = {
|
|
1620
|
+
"devui-tick": true,
|
|
1621
|
+
"devui-no-animation": !mergedShowAnimation
|
|
1622
|
+
};
|
|
1623
|
+
const stopPropagation = ($event) => $event.stopPropagation();
|
|
1624
|
+
const inputProps = {
|
|
1625
|
+
indeterminate: halfchecked
|
|
1626
|
+
};
|
|
1627
|
+
return createVNode("div", {
|
|
1628
|
+
"class": wrapperCls,
|
|
1629
|
+
"style": wrapperStyle
|
|
1630
|
+
}, [createVNode("div", {
|
|
1631
|
+
"class": checkboxCls
|
|
1632
|
+
}, [createVNode("label", {
|
|
1633
|
+
"title": labelTitle,
|
|
1634
|
+
"onClick": handleClick
|
|
1635
|
+
}, [createVNode("input", mergeProps({
|
|
1636
|
+
"name": name || value,
|
|
1637
|
+
"class": "devui-checkbox-input",
|
|
1638
|
+
"type": "checkbox"
|
|
1639
|
+
}, inputProps, {
|
|
1640
|
+
"checked": mergedChecked,
|
|
1641
|
+
"disabled": mergedDisabled,
|
|
1642
|
+
"onClick": stopPropagation,
|
|
1643
|
+
"onChange": stopPropagation
|
|
1644
|
+
}), null), createVNode("span", {
|
|
1645
|
+
"style": spanStyle,
|
|
1646
|
+
"class": spanCls
|
|
1647
|
+
}, [createVNode("span", {
|
|
1648
|
+
"class": "devui-checkbox-halfchecked-bg"
|
|
1649
|
+
}, null), createVNode("svg", {
|
|
1650
|
+
"viewBox": "0 0 16 16",
|
|
1651
|
+
"version": "1.1",
|
|
1652
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
1653
|
+
"class": "devui-checkbox-tick"
|
|
1654
|
+
}, [createVNode("g", {
|
|
1655
|
+
"stroke": "none",
|
|
1656
|
+
"stroke-width": "1",
|
|
1657
|
+
"fill": "none",
|
|
1658
|
+
"fill-rule": "evenodd"
|
|
1659
|
+
}, [createVNode("polygon", {
|
|
1660
|
+
"fill-rule": "nonzero",
|
|
1661
|
+
"points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
|
|
1662
|
+
"class": polygonCls
|
|
1663
|
+
}, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
|
|
1664
|
+
}
|
|
1665
|
+
});
|
|
1666
|
+
var checkboxGroup = "";
|
|
1667
|
+
defineComponent({
|
|
1668
|
+
name: "DCheckboxGroup",
|
|
1669
|
+
props: checkboxGroupProps,
|
|
1670
|
+
emits: ["change", "update:modelValue"],
|
|
1671
|
+
setup(props, ctx) {
|
|
1672
|
+
const valList = toRef(props, "modelValue");
|
|
1673
|
+
const defaultOpt = {
|
|
1674
|
+
checked: false,
|
|
1675
|
+
isShowTitle: true,
|
|
1676
|
+
halfchecked: false,
|
|
1677
|
+
showAnimation: true,
|
|
1678
|
+
disabled: false
|
|
1679
|
+
};
|
|
1680
|
+
const toggleGroupVal = (val) => {
|
|
1681
|
+
let index2 = -1;
|
|
1682
|
+
if (typeof valList.value[0] === "string") {
|
|
1683
|
+
index2 = valList.value.findIndex((item) => item === val);
|
|
1684
|
+
} else if (typeof valList.value[0] === "object") {
|
|
1685
|
+
index2 = valList.value.findIndex((item) => item.value === val);
|
|
1686
|
+
}
|
|
1687
|
+
if (index2 === -1) {
|
|
1688
|
+
if (typeof props.options[0] === "object") {
|
|
1689
|
+
const newOne = props.options.find((item) => item.value === val);
|
|
1690
|
+
const res2 = [...valList.value, newOne];
|
|
1691
|
+
ctx.emit("update:modelValue", res2);
|
|
1692
|
+
ctx.emit("change", res2);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
const res = [...valList.value, val];
|
|
1696
|
+
ctx.emit("update:modelValue", res);
|
|
1697
|
+
ctx.emit("change", res);
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
valList.value.splice(index2, 1);
|
|
1701
|
+
ctx.emit("update:modelValue", valList.value);
|
|
1702
|
+
ctx.emit("change", valList.value);
|
|
1703
|
+
};
|
|
1704
|
+
const isItemChecked = (itemVal) => {
|
|
1705
|
+
if (typeof valList.value[0] === "string") {
|
|
1706
|
+
return valList.value.includes(itemVal);
|
|
1707
|
+
} else if (typeof valList.value[0] === "object") {
|
|
1708
|
+
return valList.value.some((item) => item.value === itemVal);
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
provide(checkboxGroupInjectionKey, {
|
|
1712
|
+
disabled: toRef(props, "disabled"),
|
|
1713
|
+
isShowTitle: toRef(props, "isShowTitle"),
|
|
1714
|
+
color: toRef(props, "color"),
|
|
1715
|
+
showAnimation: toRef(props, "showAnimation"),
|
|
1716
|
+
beforeChange: props.beforeChange,
|
|
1717
|
+
isItemChecked,
|
|
1718
|
+
toggleGroupVal,
|
|
1719
|
+
itemWidth: toRef(props, "itemWidth"),
|
|
1720
|
+
direction: toRef(props, "direction")
|
|
1721
|
+
});
|
|
1722
|
+
return {
|
|
1723
|
+
defaultOpt
|
|
1724
|
+
};
|
|
1725
|
+
},
|
|
1726
|
+
render() {
|
|
1727
|
+
var _a;
|
|
1728
|
+
const {
|
|
1729
|
+
direction,
|
|
1730
|
+
$slots,
|
|
1731
|
+
defaultOpt,
|
|
1732
|
+
options
|
|
1733
|
+
} = this;
|
|
1734
|
+
let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
|
|
1735
|
+
if ((options == null ? void 0 : options.length) > 0) {
|
|
1736
|
+
children = options.map((opt) => {
|
|
1737
|
+
let mergedOpt = null;
|
|
1738
|
+
if (typeof opt === "string") {
|
|
1739
|
+
mergedOpt = Object.assign({}, defaultOpt, {
|
|
1740
|
+
label: opt,
|
|
1741
|
+
value: opt
|
|
1742
|
+
});
|
|
1743
|
+
} else if (typeof opt === "object") {
|
|
1744
|
+
mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
|
|
1745
|
+
label: opt.name
|
|
1746
|
+
}));
|
|
1747
|
+
}
|
|
1748
|
+
return createVNode(Checkbox, mergedOpt, null);
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
return createVNode("div", {
|
|
1752
|
+
"class": "devui-checkbox-group"
|
|
1753
|
+
}, [createVNode("div", {
|
|
1754
|
+
"class": {
|
|
1755
|
+
"devui-checkbox-list-inline": direction === "row"
|
|
1756
|
+
}
|
|
1757
|
+
}, [children])]);
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
function useFilterRender(ctx) {
|
|
1761
|
+
const showMenu = ref(false);
|
|
1762
|
+
const filterMenuRef = ref(null);
|
|
1763
|
+
const filterIconRef = ref(null);
|
|
1764
|
+
const singleVal = ref(null);
|
|
1765
|
+
const multipleVal = ref(null);
|
|
1766
|
+
const handleIconClick = () => {
|
|
1767
|
+
showMenu.value = !showMenu.value;
|
|
1768
|
+
};
|
|
1769
|
+
const handleConfirm = (val) => {
|
|
1770
|
+
showMenu.value = false;
|
|
1771
|
+
multipleVal.value = val;
|
|
1772
|
+
ctx.emit("filter", val);
|
|
1773
|
+
};
|
|
1774
|
+
const handleSelect = (val) => {
|
|
1775
|
+
showMenu.value = false;
|
|
1776
|
+
singleVal.value = val;
|
|
1777
|
+
ctx.emit("filter", val);
|
|
1778
|
+
};
|
|
1779
|
+
const iconClasses = computed(() => {
|
|
1780
|
+
var _a;
|
|
1781
|
+
return {
|
|
1782
|
+
"filter-icon": true,
|
|
1783
|
+
"filter-icon-active": Boolean(singleVal.value || ((_a = multipleVal.value) == null ? void 0 : _a.length))
|
|
1784
|
+
};
|
|
1785
|
+
});
|
|
1786
|
+
onClickOutside(filterMenuRef, () => {
|
|
1787
|
+
showMenu.value = false;
|
|
1788
|
+
}, {
|
|
1789
|
+
ignore: [filterIconRef]
|
|
1790
|
+
});
|
|
1791
|
+
return { showMenu, filterMenuRef, filterIconRef, iconClasses, handleIconClick, handleConfirm, handleSelect };
|
|
1792
|
+
}
|
|
1793
|
+
function useFilterMultiple(filterList, ctx) {
|
|
1794
|
+
const _checkList = ref([]);
|
|
1795
|
+
const _checkAllRecord = ref(false);
|
|
1796
|
+
const _checkAll = computed({
|
|
1797
|
+
get: () => _checkAllRecord.value,
|
|
1798
|
+
set: (val) => {
|
|
1799
|
+
_checkAllRecord.value = val;
|
|
1800
|
+
for (let i = 0; i < _checkList.value.length; i++) {
|
|
1801
|
+
_checkList.value[i].checked = val;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
const _halfChecked = ref(false);
|
|
1806
|
+
filterList == null ? void 0 : filterList.forEach((item) => {
|
|
1807
|
+
_checkList.value.push(__spreadValues({ checked: false }, item));
|
|
1808
|
+
});
|
|
1809
|
+
watch(_checkList, (list2) => {
|
|
1810
|
+
if (!list2.length) {
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
let allTrue = true;
|
|
1814
|
+
let allFalse = true;
|
|
1815
|
+
for (let i = 0; i < list2.length; i++) {
|
|
1816
|
+
allTrue && (allTrue = Boolean(list2[i].checked));
|
|
1817
|
+
allFalse && (allFalse = Boolean(!list2[i].checked));
|
|
1818
|
+
}
|
|
1819
|
+
_checkAllRecord.value = allTrue;
|
|
1820
|
+
_halfChecked.value = !(allFalse || allTrue);
|
|
1821
|
+
}, { immediate: true, deep: true });
|
|
1822
|
+
const getCheckedItems = () => {
|
|
1823
|
+
return _checkList.value.filter((item) => item.checked);
|
|
1824
|
+
};
|
|
1825
|
+
const handleConfirm = () => {
|
|
1826
|
+
ctx.emit("confirm", getCheckedItems());
|
|
1827
|
+
};
|
|
1828
|
+
return { _checkList, _checkAll, _halfChecked, handleConfirm };
|
|
1829
|
+
}
|
|
1830
|
+
function useFilterSingle(ctx) {
|
|
1831
|
+
const selectedItem = ref(null);
|
|
1832
|
+
const handleSelect = (val) => {
|
|
1833
|
+
selectedItem.value = val;
|
|
1834
|
+
ctx.emit("select", val);
|
|
1835
|
+
};
|
|
1836
|
+
return { selectedItem, handleSelect };
|
|
1837
|
+
}
|
|
1838
|
+
var MultipleFilter = defineComponent({
|
|
1839
|
+
props: {
|
|
1840
|
+
filterList: {
|
|
1841
|
+
type: Array,
|
|
1842
|
+
default: () => []
|
|
1843
|
+
}
|
|
1844
|
+
},
|
|
1845
|
+
emits: ["confirm"],
|
|
1846
|
+
setup(props, ctx) {
|
|
1847
|
+
const {
|
|
1848
|
+
_checkList,
|
|
1849
|
+
_checkAll,
|
|
1850
|
+
_halfChecked,
|
|
1851
|
+
handleConfirm
|
|
1852
|
+
} = useFilterMultiple(props.filterList, ctx);
|
|
1853
|
+
return () => createVNode(Fragment, null, [createVNode("div", {
|
|
1854
|
+
"class": "filter-all-check"
|
|
1855
|
+
}, [createVNode("div", {
|
|
1856
|
+
"class": "filter-item"
|
|
1857
|
+
}, [createVNode(Checkbox, {
|
|
1858
|
+
"modelValue": _checkAll.value,
|
|
1859
|
+
"onUpdate:modelValue": ($event) => _checkAll.value = $event,
|
|
1860
|
+
"halfchecked": _halfChecked.value,
|
|
1861
|
+
"label": "\u5168\u9009"
|
|
1862
|
+
}, null)])]), createVNode("div", {
|
|
1863
|
+
"class": "filter-multiple-menu"
|
|
1864
|
+
}, [_checkList.value.map((item) => createVNode("div", {
|
|
1865
|
+
"class": "filter-item"
|
|
1866
|
+
}, [createVNode(Checkbox, {
|
|
1867
|
+
"modelValue": item.checked,
|
|
1868
|
+
"onUpdate:modelValue": ($event) => item.checked = $event,
|
|
1869
|
+
"label": item.name
|
|
1870
|
+
}, null)]))]), createVNode("div", {
|
|
1871
|
+
"class": "filter-operation"
|
|
1872
|
+
}, [createVNode(Button, {
|
|
1873
|
+
"variant": "text",
|
|
1874
|
+
"onClick": handleConfirm
|
|
1875
|
+
}, {
|
|
1876
|
+
default: () => [createTextVNode("\u786E\u5B9A")]
|
|
1877
|
+
})])]);
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
var list = "";
|
|
1881
|
+
var List = defineComponent({
|
|
1882
|
+
name: "DList",
|
|
1883
|
+
setup(props, {
|
|
1884
|
+
slots
|
|
1885
|
+
}) {
|
|
1886
|
+
return () => {
|
|
1887
|
+
var _a;
|
|
1888
|
+
return createVNode("div", {
|
|
1889
|
+
"class": "devui-list"
|
|
1890
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
var listItem = "";
|
|
1895
|
+
var ListItem = defineComponent({
|
|
1896
|
+
name: "DListItem",
|
|
1897
|
+
setup(props, {
|
|
1898
|
+
slots
|
|
1899
|
+
}) {
|
|
1900
|
+
return () => {
|
|
1901
|
+
var _a;
|
|
1902
|
+
return createVNode("div", {
|
|
1903
|
+
"class": "devui-list-item"
|
|
1904
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
function _isSlot(s) {
|
|
1909
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1910
|
+
}
|
|
1911
|
+
var SingleFilter = defineComponent({
|
|
1912
|
+
props: {
|
|
1913
|
+
filterList: {
|
|
1914
|
+
type: Array,
|
|
1915
|
+
default: () => []
|
|
1916
|
+
}
|
|
1917
|
+
},
|
|
1918
|
+
emits: ["select"],
|
|
1919
|
+
setup(props, ctx) {
|
|
1920
|
+
const {
|
|
1921
|
+
selectedItem,
|
|
1922
|
+
handleSelect
|
|
1923
|
+
} = useFilterSingle(ctx);
|
|
1924
|
+
return () => {
|
|
1925
|
+
let _slot;
|
|
1926
|
+
return createVNode(Fragment, null, [createVNode(List, {
|
|
1927
|
+
"class": "filter-single-menu"
|
|
1928
|
+
}, _isSlot(_slot = props.filterList.map((item) => createVNode(ListItem, {
|
|
1929
|
+
"class": ["filter-item", {
|
|
1930
|
+
"filter-item-active": selectedItem.value === item
|
|
1931
|
+
}],
|
|
1932
|
+
"onClick": () => {
|
|
1933
|
+
handleSelect(item);
|
|
1934
|
+
}
|
|
1935
|
+
}, {
|
|
1936
|
+
default: () => [item.name]
|
|
1937
|
+
}))) ? _slot : {
|
|
1938
|
+
default: () => [_slot]
|
|
1939
|
+
})]);
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
var filter = "";
|
|
1944
|
+
var Filter = defineComponent({
|
|
1945
|
+
props: filterProps,
|
|
1946
|
+
emits: ["filter"],
|
|
1947
|
+
setup(props, ctx) {
|
|
1948
|
+
const {
|
|
1949
|
+
showMenu,
|
|
1950
|
+
filterMenuRef,
|
|
1951
|
+
filterIconRef,
|
|
1952
|
+
iconClasses,
|
|
1953
|
+
handleIconClick,
|
|
1954
|
+
handleConfirm,
|
|
1955
|
+
handleSelect
|
|
1956
|
+
} = useFilterRender(ctx);
|
|
1957
|
+
return () => createVNode(Dropdown, {
|
|
1958
|
+
"visible": showMenu.value,
|
|
1959
|
+
"trigger": "manually",
|
|
1960
|
+
"close-scope": "none",
|
|
1961
|
+
"destroy-on-hide": false,
|
|
1962
|
+
"style": "padding-bottom: 4px;"
|
|
1963
|
+
}, {
|
|
1964
|
+
default: () => createVNode("i", {
|
|
1965
|
+
"ref": filterIconRef,
|
|
1966
|
+
"class": iconClasses.value,
|
|
1967
|
+
"onClick": handleIconClick
|
|
1968
|
+
}, [createVNode("svg", {
|
|
1969
|
+
"width": "16px",
|
|
1970
|
+
"height": "16px",
|
|
1971
|
+
"viewBox": "0 0 16 16",
|
|
1972
|
+
"version": "1.1",
|
|
1973
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
1974
|
+
}, [createVNode("g", {
|
|
1975
|
+
"stroke": "none",
|
|
1976
|
+
"stroke-width": "1",
|
|
1977
|
+
"fill": "none",
|
|
1978
|
+
"fill-rule": "evenodd"
|
|
1979
|
+
}, [createVNode("g", null, [createVNode("polygon", {
|
|
1980
|
+
"points": "10.0085775 7 10.0085775 15 6 13 6 7 2 3 2 1 14 1 14 3"
|
|
1981
|
+
}, null)])])])]),
|
|
1982
|
+
menu: () => createVNode("div", {
|
|
1983
|
+
"ref": filterMenuRef,
|
|
1984
|
+
"class": "filter-wrapper"
|
|
1985
|
+
}, [props.multiple ? createVNode(MultipleFilter, {
|
|
1986
|
+
"filterList": props.filterList,
|
|
1987
|
+
"onConfirm": handleConfirm
|
|
1988
|
+
}, null) : createVNode(SingleFilter, {
|
|
1989
|
+
"filterList": props.filterList,
|
|
1990
|
+
"onSelect": handleSelect
|
|
1991
|
+
}, null)])
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
function useSort(column) {
|
|
1996
|
+
const table2 = inject(TABLE_TOKEN);
|
|
1997
|
+
const store = table2.store;
|
|
1998
|
+
const direction = ref(column.value.sortDirection);
|
|
1999
|
+
const sortClass = computed(() => ({
|
|
2000
|
+
"sort-active": Boolean(direction.value)
|
|
2001
|
+
}));
|
|
2002
|
+
const thInstance = getCurrentInstance();
|
|
2003
|
+
thInstance && store.states.thList.push(thInstance);
|
|
2004
|
+
onMounted(() => {
|
|
2005
|
+
var _a;
|
|
2006
|
+
column.value.sortable && column.value.sortDirection && ((_a = store.sortData) == null ? void 0 : _a.call(store, direction.value, column.value.sortMethod));
|
|
2007
|
+
});
|
|
2008
|
+
const execClearSortOrder = () => {
|
|
2009
|
+
store.states.thList.forEach((th) => {
|
|
2010
|
+
var _a, _b;
|
|
2011
|
+
if (th !== thInstance) {
|
|
2012
|
+
(_b = (_a = th.exposed) == null ? void 0 : _a.clearSortOrder) == null ? void 0 : _b.call(_a);
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2015
|
+
};
|
|
2016
|
+
const handleSort = (val) => {
|
|
2017
|
+
var _a;
|
|
2018
|
+
direction.value = val;
|
|
2019
|
+
execClearSortOrder();
|
|
2020
|
+
(_a = store.sortData) == null ? void 0 : _a.call(store, direction.value, column.value.sortMethod);
|
|
2021
|
+
table2.emit("sort-change", { field: column.value.field, direction: direction.value });
|
|
2022
|
+
};
|
|
2023
|
+
const clearSortOrder = () => {
|
|
2024
|
+
direction.value = "";
|
|
2025
|
+
};
|
|
2026
|
+
return { direction, sortClass, handleSort, clearSortOrder };
|
|
2027
|
+
}
|
|
2028
|
+
function useFilter(column) {
|
|
2029
|
+
const filter2 = ref(null);
|
|
2030
|
+
const filterClass = computed(() => ({
|
|
2031
|
+
"filter-active": Boolean(filter2.value || Array.isArray(filter2.value) && filter2.value.length)
|
|
2032
|
+
}));
|
|
2033
|
+
const handleFilter = (val) => {
|
|
2034
|
+
filter2.value = val;
|
|
2035
|
+
column.value.ctx.emit("filter-change", val);
|
|
2036
|
+
};
|
|
2037
|
+
return { filterClass, handleFilter };
|
|
2038
|
+
}
|
|
2039
|
+
var TH = defineComponent({
|
|
2040
|
+
name: "DTableHeaderTh",
|
|
2041
|
+
props: {
|
|
2042
|
+
column: {
|
|
2043
|
+
type: Object,
|
|
2044
|
+
required: true
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
setup(props, {
|
|
2048
|
+
expose
|
|
2049
|
+
}) {
|
|
2050
|
+
const table2 = inject(TABLE_TOKEN);
|
|
2051
|
+
const store = table2.store;
|
|
2052
|
+
const {
|
|
2053
|
+
column
|
|
2054
|
+
} = toRefs(props);
|
|
2055
|
+
const {
|
|
2056
|
+
direction,
|
|
2057
|
+
sortClass,
|
|
2058
|
+
handleSort,
|
|
2059
|
+
clearSortOrder
|
|
2060
|
+
} = useSort(column);
|
|
2061
|
+
const {
|
|
2062
|
+
filterClass,
|
|
2063
|
+
handleFilter
|
|
2064
|
+
} = useFilter(column);
|
|
2065
|
+
const {
|
|
2066
|
+
stickyClass,
|
|
2067
|
+
stickyStyle
|
|
2068
|
+
} = useFixedColumn(column);
|
|
2069
|
+
expose({
|
|
2070
|
+
clearSortOrder
|
|
2071
|
+
});
|
|
2072
|
+
return () => {
|
|
2073
|
+
var _a, _b;
|
|
2074
|
+
return createVNode("th", {
|
|
2075
|
+
"class": [stickyClass.value, sortClass.value, filterClass.value],
|
|
2076
|
+
"style": stickyStyle.value
|
|
2077
|
+
}, [createVNode("div", {
|
|
2078
|
+
"class": "header-container"
|
|
2079
|
+
}, [(_b = (_a = column.value).renderHeader) == null ? void 0 : _b.call(_a, column.value, store), column.value.filterable && createVNode(Filter, {
|
|
2080
|
+
"filterList": column.value.filterList,
|
|
2081
|
+
"multiple": column.value.filterMultiple,
|
|
2082
|
+
"onFilter": handleFilter
|
|
2083
|
+
}, null), column.value.sortable && createVNode(Sort, {
|
|
2084
|
+
"sort-direction": direction.value,
|
|
2085
|
+
"onSort": handleSort
|
|
2086
|
+
}, null)])]);
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
});
|
|
2090
|
+
function getAllColumns(columns) {
|
|
2091
|
+
const result = [];
|
|
2092
|
+
columns.forEach((column) => {
|
|
2093
|
+
if (column.children) {
|
|
2094
|
+
result.push(column);
|
|
2095
|
+
result.push.apply(result, getAllColumns(column.children));
|
|
2096
|
+
} else {
|
|
2097
|
+
result.push(column);
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
return result;
|
|
2101
|
+
}
|
|
2102
|
+
function convertToRows(originColumns) {
|
|
2103
|
+
let maxLevel = 1;
|
|
2104
|
+
const traverse = (column, parent) => {
|
|
2105
|
+
if (parent) {
|
|
2106
|
+
column.level = parent.level + 1;
|
|
2107
|
+
if (maxLevel < column.level) {
|
|
2108
|
+
maxLevel = column.level;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
if (column.children) {
|
|
2112
|
+
let colSpan = 0;
|
|
2113
|
+
column.children.forEach((subColumn) => {
|
|
2114
|
+
traverse(subColumn, column);
|
|
2115
|
+
colSpan += subColumn.colSpan;
|
|
2116
|
+
});
|
|
2117
|
+
column.colSpan = colSpan;
|
|
2118
|
+
} else {
|
|
2119
|
+
column.colSpan = 1;
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
originColumns.forEach((column) => {
|
|
2123
|
+
column.level = 1;
|
|
2124
|
+
traverse(column, void 0);
|
|
2125
|
+
});
|
|
2126
|
+
const rows = [];
|
|
2127
|
+
for (let i = 0; i < maxLevel; i++) {
|
|
2128
|
+
rows.push([]);
|
|
2129
|
+
}
|
|
2130
|
+
const allColumns = getAllColumns(originColumns);
|
|
2131
|
+
allColumns.forEach((column) => {
|
|
2132
|
+
if (!column.children) {
|
|
2133
|
+
column.rowSpan = maxLevel - column.level + 1;
|
|
2134
|
+
} else {
|
|
2135
|
+
column.rowSpan = 1;
|
|
2136
|
+
column.children.forEach((col) => col.isSubColumn = true);
|
|
2137
|
+
}
|
|
2138
|
+
rows[column.level - 1].push(column);
|
|
2139
|
+
});
|
|
2140
|
+
return rows;
|
|
2141
|
+
}
|
|
2142
|
+
function useHeader() {
|
|
2143
|
+
const table2 = inject(TABLE_TOKEN);
|
|
2144
|
+
const headerRows = computed(() => convertToRows(table2 == null ? void 0 : table2.store.states._columns.value));
|
|
2145
|
+
return { headerRows };
|
|
2146
|
+
}
|
|
2147
|
+
var header = "";
|
|
2148
|
+
var body = "";
|
|
2149
|
+
var TableHeader = defineComponent({
|
|
2150
|
+
name: "DTableHeader",
|
|
2151
|
+
setup() {
|
|
2152
|
+
const ns = useNamespace("table");
|
|
2153
|
+
const {
|
|
2154
|
+
headerRows
|
|
2155
|
+
} = useHeader();
|
|
2156
|
+
return () => createVNode("thead", {
|
|
2157
|
+
"class": ns.e("thead")
|
|
2158
|
+
}, [headerRows.value.map((subColumns) => createVNode("tr", null, [subColumns.map((column, columnIndex) => createVNode(TH, {
|
|
2159
|
+
"key": columnIndex,
|
|
2160
|
+
"column": column,
|
|
2161
|
+
"colspan": column.colSpan,
|
|
2162
|
+
"rowspan": column.rowSpan
|
|
2163
|
+
}, null))]))]);
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
var TD = defineComponent({
|
|
2167
|
+
name: "DTableBodyTd",
|
|
2168
|
+
props: {
|
|
2169
|
+
column: {
|
|
2170
|
+
type: Object,
|
|
2171
|
+
default: () => ({})
|
|
2172
|
+
},
|
|
2173
|
+
row: {
|
|
2174
|
+
type: Object,
|
|
2175
|
+
default: () => ({})
|
|
2176
|
+
},
|
|
2177
|
+
index: {
|
|
2178
|
+
type: Number,
|
|
2179
|
+
default: 0
|
|
2180
|
+
}
|
|
2181
|
+
},
|
|
2182
|
+
setup(props) {
|
|
2183
|
+
const table2 = inject(TABLE_TOKEN);
|
|
2184
|
+
const column = toRef(props, "column");
|
|
2185
|
+
const {
|
|
2186
|
+
stickyClass,
|
|
2187
|
+
stickyStyle
|
|
2188
|
+
} = useFixedColumn(column);
|
|
2189
|
+
return () => {
|
|
2190
|
+
var _a, _b;
|
|
2191
|
+
return createVNode("td", {
|
|
2192
|
+
"class": stickyClass.value,
|
|
2193
|
+
"style": stickyStyle.value
|
|
2194
|
+
}, [(_b = (_a = column.value).renderCell) == null ? void 0 : _b.call(_a, props.row, column.value, table2.store, props.index)]);
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
function useMergeCell() {
|
|
2199
|
+
const table2 = inject(TABLE_TOKEN);
|
|
2200
|
+
const { _data: data, _columns: columns } = table2.store.states;
|
|
2201
|
+
const getSpan = (row, column, rowIndex, columnIndex) => {
|
|
2202
|
+
const fn = table2 == null ? void 0 : table2.props.spanMethod;
|
|
2203
|
+
let rowspan = 1;
|
|
2204
|
+
let colspan = 1;
|
|
2205
|
+
if (typeof fn === "function") {
|
|
2206
|
+
const result = fn({ row, column, rowIndex, columnIndex });
|
|
2207
|
+
if (Array.isArray(result)) {
|
|
2208
|
+
rowspan = result[0];
|
|
2209
|
+
colspan = result[1];
|
|
2210
|
+
} else if (typeof result === "object") {
|
|
2211
|
+
rowspan = result.rowspan;
|
|
2212
|
+
colspan = result.colspan;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return { rowspan, colspan };
|
|
2216
|
+
};
|
|
2217
|
+
const tableSpans = computed(() => {
|
|
2218
|
+
const result = {};
|
|
2219
|
+
if (table2 == null ? void 0 : table2.props.spanMethod) {
|
|
2220
|
+
data.value.forEach((row, rowIndex) => {
|
|
2221
|
+
columns.value.forEach((column, columnIndex) => {
|
|
2222
|
+
const { rowspan, colspan } = getSpan(row, column, rowIndex, columnIndex);
|
|
2223
|
+
if (rowspan > 1 || colspan > 1) {
|
|
2224
|
+
result[`${rowIndex}-${columnIndex}`] = [rowspan, colspan];
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
return result;
|
|
2230
|
+
});
|
|
2231
|
+
const removeCells = computed(() => {
|
|
2232
|
+
const result = [];
|
|
2233
|
+
for (const indexKey of Object.keys(tableSpans.value)) {
|
|
2234
|
+
const indexArray = indexKey.split("-").map((item) => Number(item));
|
|
2235
|
+
const spans = tableSpans.value[indexKey];
|
|
2236
|
+
for (let i = 1; i < spans[0]; i++) {
|
|
2237
|
+
result.push(`${indexArray[0] + i}-${indexArray[1]}`);
|
|
2238
|
+
for (let j = 1; j < spans[1]; j++) {
|
|
2239
|
+
result.push(`${indexArray[0] + i}-${indexArray[1] + j}`);
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
for (let i = 1; i < spans[1]; i++) {
|
|
2243
|
+
result.push(`${indexArray[0]}-${indexArray[1] + i}`);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
return result;
|
|
2247
|
+
});
|
|
2248
|
+
return { tableSpans, removeCells };
|
|
2249
|
+
}
|
|
2250
|
+
var TableBody = defineComponent({
|
|
2251
|
+
name: "DTableBody",
|
|
2252
|
+
setup() {
|
|
2253
|
+
const table2 = inject(TABLE_TOKEN);
|
|
2254
|
+
const {
|
|
2255
|
+
_data: data,
|
|
2256
|
+
flatColumns
|
|
2257
|
+
} = table2.store.states;
|
|
2258
|
+
const ns = useNamespace("table");
|
|
2259
|
+
const hoverEnabled = computed(() => table2.props.rowHoveredHighlight);
|
|
2260
|
+
const {
|
|
2261
|
+
tableSpans,
|
|
2262
|
+
removeCells
|
|
2263
|
+
} = useMergeCell();
|
|
2264
|
+
return () => createVNode("tbody", {
|
|
2265
|
+
"class": ns.e("tbody")
|
|
2266
|
+
}, [data.value.map((row, rowIndex) => {
|
|
2267
|
+
return createVNode("tr", {
|
|
2268
|
+
"key": rowIndex,
|
|
2269
|
+
"class": {
|
|
2270
|
+
"hover-enabled": hoverEnabled.value
|
|
2271
|
+
}
|
|
2272
|
+
}, [flatColumns.value.map((column, columnIndex) => {
|
|
2273
|
+
var _a;
|
|
2274
|
+
const cellId = `${rowIndex}-${columnIndex}`;
|
|
2275
|
+
const [rowspan, colspan] = (_a = tableSpans.value[cellId]) != null ? _a : [1, 1];
|
|
2276
|
+
if (removeCells.value.includes(cellId)) {
|
|
2277
|
+
return null;
|
|
2278
|
+
}
|
|
2279
|
+
return createVNode(TD, {
|
|
2280
|
+
"column": column,
|
|
2281
|
+
"index": rowIndex,
|
|
2282
|
+
"row": row,
|
|
2283
|
+
"rowspan": rowspan,
|
|
2284
|
+
"colspan": colspan
|
|
2285
|
+
}, null);
|
|
2286
|
+
})]);
|
|
2287
|
+
})]);
|
|
2288
|
+
}
|
|
2289
|
+
});
|
|
2290
|
+
var FixHeader = defineComponent({
|
|
2291
|
+
props: {
|
|
2292
|
+
classes: {
|
|
2293
|
+
type: Object,
|
|
2294
|
+
default: () => ({})
|
|
2295
|
+
},
|
|
2296
|
+
isEmpty: {
|
|
2297
|
+
type: Boolean
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
setup(props) {
|
|
2301
|
+
const ns = useNamespace("table");
|
|
2302
|
+
return () => {
|
|
2303
|
+
return createVNode("div", {
|
|
2304
|
+
"class": ns.e("fix-header")
|
|
2305
|
+
}, [createVNode("div", {
|
|
2306
|
+
"style": "overflow:hidden scroll;"
|
|
2307
|
+
}, [createVNode("table", {
|
|
2308
|
+
"class": props.classes,
|
|
2309
|
+
"cellpadding": "0",
|
|
2310
|
+
"cellspacing": "0"
|
|
2311
|
+
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
|
|
2312
|
+
"class": ns.e("scroll-view")
|
|
2313
|
+
}, [createVNode("table", {
|
|
2314
|
+
"class": props.classes,
|
|
2315
|
+
"cellpadding": "0",
|
|
2316
|
+
"cellspacing": "0"
|
|
2317
|
+
}, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
|
|
2318
|
+
"style": "flex: 1"
|
|
2319
|
+
}, null)])])]);
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
var NormalHeader = defineComponent({
|
|
2324
|
+
props: {
|
|
2325
|
+
classes: {
|
|
2326
|
+
type: Object,
|
|
2327
|
+
default: () => ({})
|
|
2328
|
+
},
|
|
2329
|
+
isEmpty: {
|
|
2330
|
+
type: Boolean
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
setup(props) {
|
|
2334
|
+
return () => {
|
|
2335
|
+
return createVNode("table", {
|
|
2336
|
+
"class": props.classes,
|
|
2337
|
+
"cellpadding": "0",
|
|
2338
|
+
"cellspacing": "0"
|
|
2339
|
+
}, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
|
|
2340
|
+
"style": "position:relative"
|
|
2341
|
+
}, null), !props.isEmpty && createVNode(TableBody, null, null)]);
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
defineComponent(Loading);
|
|
2346
|
+
var table = "";
|
|
2347
|
+
let tableIdInit = 1;
|
|
2348
|
+
var Table = defineComponent({
|
|
2349
|
+
name: "DTable",
|
|
2350
|
+
directives: {
|
|
2351
|
+
dLoading: loadingDirective
|
|
2352
|
+
},
|
|
2353
|
+
props: TableProps,
|
|
2354
|
+
emits: ["sort-change"],
|
|
2355
|
+
setup(props, ctx) {
|
|
2356
|
+
const table2 = getCurrentInstance();
|
|
2357
|
+
const store = createStore(toRef(props, "data"));
|
|
2358
|
+
const tableId = `devui-table_${tableIdInit++}`;
|
|
2359
|
+
table2.tableId = tableId;
|
|
2360
|
+
table2.store = store;
|
|
2361
|
+
provide(TABLE_TOKEN, table2);
|
|
2362
|
+
const {
|
|
2363
|
+
classes,
|
|
2364
|
+
style
|
|
2365
|
+
} = useTable(props);
|
|
2366
|
+
const isEmpty2 = computed(() => props.data.length === 0);
|
|
2367
|
+
const ns = useNamespace("table");
|
|
2368
|
+
const hiddenColumns = ref(null);
|
|
2369
|
+
table2.hiddenColumns = hiddenColumns;
|
|
2370
|
+
ctx.expose({
|
|
2371
|
+
getCheckedRows() {
|
|
2372
|
+
return store.getCheckedRows();
|
|
2373
|
+
}
|
|
2374
|
+
});
|
|
2375
|
+
onMounted(async () => {
|
|
2376
|
+
await nextTick();
|
|
2377
|
+
store.updateColumns();
|
|
2378
|
+
});
|
|
2379
|
+
return () => {
|
|
2380
|
+
var _a, _b;
|
|
2381
|
+
return withDirectives(createVNode("div", {
|
|
2382
|
+
"class": ns.b(),
|
|
2383
|
+
"style": style.value
|
|
2384
|
+
}, [createVNode("div", {
|
|
2385
|
+
"ref": hiddenColumns,
|
|
2386
|
+
"class": "hidden-columns"
|
|
2387
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.fixHeader ? createVNode(FixHeader, {
|
|
2388
|
+
"classes": classes.value,
|
|
2389
|
+
"is-empty": isEmpty2.value
|
|
2390
|
+
}, null) : createVNode(NormalHeader, {
|
|
2391
|
+
"classes": classes.value,
|
|
2392
|
+
"is-empty": isEmpty2.value
|
|
2393
|
+
}, null), isEmpty2.value && createVNode("div", {
|
|
2394
|
+
"class": ns.e("empty")
|
|
2395
|
+
}, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
const tableColumnProps = {
|
|
2400
|
+
type: {
|
|
2401
|
+
type: String,
|
|
2402
|
+
default: ""
|
|
2403
|
+
},
|
|
2404
|
+
header: {
|
|
2405
|
+
type: String
|
|
2406
|
+
},
|
|
2407
|
+
field: {
|
|
2408
|
+
type: String,
|
|
2409
|
+
default: ""
|
|
2410
|
+
},
|
|
2411
|
+
width: {
|
|
2412
|
+
type: [String, Number],
|
|
2413
|
+
default: ""
|
|
2414
|
+
},
|
|
2415
|
+
minWidth: {
|
|
2416
|
+
type: [String, Number],
|
|
2417
|
+
default: 80
|
|
2418
|
+
},
|
|
2419
|
+
formatter: {
|
|
2420
|
+
type: Function
|
|
2421
|
+
},
|
|
2422
|
+
order: {
|
|
2423
|
+
type: Number,
|
|
2424
|
+
default: 0
|
|
2425
|
+
},
|
|
2426
|
+
sortable: {
|
|
2427
|
+
type: Boolean,
|
|
2428
|
+
default: false
|
|
2429
|
+
},
|
|
2430
|
+
sortDirection: {
|
|
2431
|
+
type: String,
|
|
2432
|
+
default: ""
|
|
2433
|
+
},
|
|
2434
|
+
sortMethod: {
|
|
2435
|
+
type: Function
|
|
2436
|
+
},
|
|
2437
|
+
filterable: {
|
|
2438
|
+
type: Boolean,
|
|
2439
|
+
default: false
|
|
2440
|
+
},
|
|
2441
|
+
filterMultiple: {
|
|
2442
|
+
type: Boolean,
|
|
2443
|
+
default: true
|
|
2444
|
+
},
|
|
2445
|
+
filterList: {
|
|
2446
|
+
type: Array,
|
|
2447
|
+
default: []
|
|
2448
|
+
},
|
|
2449
|
+
fixedLeft: {
|
|
2450
|
+
type: String
|
|
2451
|
+
},
|
|
2452
|
+
fixedRight: {
|
|
2453
|
+
type: String
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
function formatWidth(width) {
|
|
2457
|
+
if (typeof width === "number") {
|
|
2458
|
+
return width;
|
|
2459
|
+
}
|
|
2460
|
+
return parseInt(width, 10) || 0;
|
|
2461
|
+
}
|
|
2462
|
+
function formatMinWidth(minWidth) {
|
|
2463
|
+
return formatWidth(minWidth) || 80;
|
|
2464
|
+
}
|
|
2465
|
+
const cellMap = {
|
|
2466
|
+
checkable: {
|
|
2467
|
+
renderHeader(column, store) {
|
|
2468
|
+
return h(Checkbox, {
|
|
2469
|
+
modelValue: store.states._checkAll.value,
|
|
2470
|
+
halfchecked: store.states._halfChecked.value,
|
|
2471
|
+
onChange: (val) => {
|
|
2472
|
+
store.states._checkAll.value = val;
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2475
|
+
},
|
|
2476
|
+
renderCell(rowData, column, store, rowIndex) {
|
|
2477
|
+
return h(Checkbox, {
|
|
2478
|
+
modelValue: store.states._checkList.value[rowIndex],
|
|
2479
|
+
onChange: (val) => {
|
|
2480
|
+
store.states._checkList.value[rowIndex] = val;
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
},
|
|
2485
|
+
index: {
|
|
2486
|
+
renderHeader(column) {
|
|
2487
|
+
var _a;
|
|
2488
|
+
return h("span", {
|
|
2489
|
+
class: "title"
|
|
2490
|
+
}, (_a = column.header) != null ? _a : "#");
|
|
2491
|
+
},
|
|
2492
|
+
renderCell(rowData, column, store, rowIndex) {
|
|
2493
|
+
return rowIndex + 1;
|
|
2494
|
+
}
|
|
2495
|
+
},
|
|
2496
|
+
default: {
|
|
2497
|
+
renderHeader(column) {
|
|
2498
|
+
var _a;
|
|
2499
|
+
return h("span", {
|
|
2500
|
+
class: "title"
|
|
2501
|
+
}, (_a = column.header) != null ? _a : "");
|
|
2502
|
+
},
|
|
2503
|
+
renderCell(rowData, column, store, rowIndex) {
|
|
2504
|
+
var _a, _b;
|
|
2505
|
+
const value = column.field ? rowData[column.field] : "";
|
|
2506
|
+
if (column.formatter) {
|
|
2507
|
+
return column.formatter(rowData, column, value, rowIndex);
|
|
2508
|
+
}
|
|
2509
|
+
return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
function createColumn(props, slots) {
|
|
2514
|
+
const {
|
|
2515
|
+
type,
|
|
2516
|
+
field,
|
|
2517
|
+
header: header2,
|
|
2518
|
+
sortable,
|
|
2519
|
+
sortDirection,
|
|
2520
|
+
width,
|
|
2521
|
+
minWidth,
|
|
2522
|
+
formatter,
|
|
2523
|
+
sortMethod,
|
|
2524
|
+
filterable,
|
|
2525
|
+
filterList,
|
|
2526
|
+
filterMultiple,
|
|
2527
|
+
order,
|
|
2528
|
+
fixedLeft,
|
|
2529
|
+
fixedRight
|
|
2530
|
+
} = props;
|
|
2531
|
+
const column = reactive({});
|
|
2532
|
+
column.type = type.value;
|
|
2533
|
+
function renderHeader(columnItem, store) {
|
|
2534
|
+
if (slots.header) {
|
|
2535
|
+
return slots.header(columnItem);
|
|
2536
|
+
}
|
|
2537
|
+
return cellMap[type.value || "default"].renderHeader(columnItem, store);
|
|
2538
|
+
}
|
|
2539
|
+
function renderCell(rowData, columnItem, store, rowIndex) {
|
|
2540
|
+
if (slots.default) {
|
|
2541
|
+
return slots.default({ row: rowData, rowIndex });
|
|
2542
|
+
}
|
|
2543
|
+
return cellMap[type.value || "default"].renderCell(rowData, columnItem, store, rowIndex);
|
|
2544
|
+
}
|
|
2545
|
+
watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
|
|
2546
|
+
column.field = fieldVal;
|
|
2547
|
+
column.header = headerVal;
|
|
2548
|
+
column.order = orderVal;
|
|
2549
|
+
}, { immediate: true });
|
|
2550
|
+
watch([sortable, sortDirection, sortMethod], ([sortableVal, sortDirectionVal, sortMethodVal]) => {
|
|
2551
|
+
column.sortable = sortableVal;
|
|
2552
|
+
column.sortDirection = sortDirectionVal;
|
|
2553
|
+
column.sortMethod = sortMethodVal;
|
|
2554
|
+
}, { immediate: true });
|
|
2555
|
+
watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
|
|
2556
|
+
column.filterable = filterableVal;
|
|
2557
|
+
column.filterMultiple = filterMultipleVal;
|
|
2558
|
+
column.filterList = filterListVal;
|
|
2559
|
+
}, { immediate: true });
|
|
2560
|
+
watch([fixedLeft, fixedRight], ([left, right]) => {
|
|
2561
|
+
column.fixedLeft = left;
|
|
2562
|
+
column.fixedRight = right;
|
|
2563
|
+
}, { immediate: true });
|
|
2564
|
+
watch([width, minWidth], ([widthVal, minWidthVal]) => {
|
|
2565
|
+
column.width = formatWidth(widthVal);
|
|
2566
|
+
column.minWidth = formatMinWidth(minWidthVal);
|
|
2567
|
+
column.realWidth = column.width || column.minWidth;
|
|
2568
|
+
});
|
|
2569
|
+
onBeforeMount(() => {
|
|
2570
|
+
column.renderHeader = renderHeader;
|
|
2571
|
+
column.renderCell = renderCell;
|
|
2572
|
+
column.formatter = formatter == null ? void 0 : formatter.value;
|
|
2573
|
+
column.customFilterTemplate = slots.customFilterTemplate;
|
|
2574
|
+
column.subColumns = slots.subColumns;
|
|
2575
|
+
});
|
|
2576
|
+
return column;
|
|
2577
|
+
}
|
|
2578
|
+
function useRender() {
|
|
2579
|
+
const instance = getCurrentInstance();
|
|
2580
|
+
const columnOrTableParent = computed(() => {
|
|
2581
|
+
let parent = instance == null ? void 0 : instance.parent;
|
|
2582
|
+
while (parent && !parent.tableId && !parent.columnId) {
|
|
2583
|
+
parent = parent.parent;
|
|
2584
|
+
}
|
|
2585
|
+
return parent;
|
|
2586
|
+
});
|
|
2587
|
+
const getColumnIndex = (children, child) => {
|
|
2588
|
+
return Array.prototype.indexOf.call(children, child);
|
|
2589
|
+
};
|
|
2590
|
+
return { columnOrTableParent, getColumnIndex };
|
|
2591
|
+
}
|
|
2592
|
+
let columnIdInit = 1;
|
|
2593
|
+
var Column = defineComponent({
|
|
2594
|
+
name: "DColumn",
|
|
2595
|
+
props: tableColumnProps,
|
|
2596
|
+
emits: ["filter-change"],
|
|
2597
|
+
setup(props, ctx) {
|
|
2598
|
+
const instance = getCurrentInstance();
|
|
2599
|
+
const column = createColumn(toRefs(props), ctx.slots);
|
|
2600
|
+
const owner = inject(TABLE_TOKEN);
|
|
2601
|
+
const isSubColumn = ref(false);
|
|
2602
|
+
let columnId = "";
|
|
2603
|
+
const {
|
|
2604
|
+
columnOrTableParent,
|
|
2605
|
+
getColumnIndex
|
|
2606
|
+
} = useRender();
|
|
2607
|
+
const parent = columnOrTableParent.value;
|
|
2608
|
+
columnId = `${parent.tableId || parent.columnId}_column_${columnIdInit++}`;
|
|
2609
|
+
column.ctx = ctx;
|
|
2610
|
+
onBeforeMount(() => {
|
|
2611
|
+
isSubColumn.value = owner !== parent;
|
|
2612
|
+
column.id = columnId;
|
|
2613
|
+
});
|
|
2614
|
+
onMounted(() => {
|
|
2615
|
+
var _a;
|
|
2616
|
+
const children = isSubColumn.value ? parent.vnode.el.children : (_a = owner == null ? void 0 : owner.hiddenColumns.value) == null ? void 0 : _a.children;
|
|
2617
|
+
const columnIndex = getColumnIndex(children || [], instance.vnode.el);
|
|
2618
|
+
columnIndex > -1 && (owner == null ? void 0 : owner.store.insertColumn(column, isSubColumn.value ? parent.columnConfig : null));
|
|
2619
|
+
});
|
|
2620
|
+
watch(() => column.order, () => {
|
|
2621
|
+
owner == null ? void 0 : owner.store.sortColumn();
|
|
2622
|
+
});
|
|
2623
|
+
onBeforeUnmount(() => {
|
|
2624
|
+
owner == null ? void 0 : owner.store.removeColumn(column);
|
|
2625
|
+
});
|
|
2626
|
+
instance.columnId = columnId;
|
|
2627
|
+
instance.columnConfig = column;
|
|
2628
|
+
},
|
|
2629
|
+
render() {
|
|
2630
|
+
var _a, _b;
|
|
2631
|
+
try {
|
|
2632
|
+
const renderDefault = (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, {
|
|
2633
|
+
row: {},
|
|
2634
|
+
column: {},
|
|
2635
|
+
$index: -1
|
|
2636
|
+
});
|
|
2637
|
+
const children = [];
|
|
2638
|
+
if (Array.isArray(renderDefault)) {
|
|
2639
|
+
for (const childNode of renderDefault) {
|
|
2640
|
+
if (childNode.type.name === "DColumn") {
|
|
2641
|
+
children.push(childNode);
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
const vnode = h("div", children);
|
|
2646
|
+
return vnode;
|
|
2647
|
+
} catch {
|
|
2648
|
+
return h("div", []);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
});
|
|
2652
|
+
var index = {
|
|
2653
|
+
title: "Table \u8868\u683C",
|
|
2654
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
2655
|
+
status: "20%",
|
|
2656
|
+
install(app) {
|
|
2657
|
+
app.component(Table.name, Table);
|
|
2658
|
+
app.component(Column.name, Column);
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
export { Column, Table, index as default };
|