vue-devui 1.0.0-rc.4 → 1.0.0-rc.7

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.
Files changed (151) hide show
  1. package/README.md +21 -7
  2. package/auto-complete/index.es.js +26 -4
  3. package/auto-complete/index.umd.js +3 -3
  4. package/auto-complete/style.css +1 -1
  5. package/badge/index.es.js +2 -1
  6. package/badge/index.umd.js +1 -1
  7. package/button/index.es.js +4 -3
  8. package/button/index.umd.js +1 -1
  9. package/button/style.css +1 -1
  10. package/card/index.es.js +35 -29
  11. package/card/index.umd.js +1 -1
  12. package/card/style.css +1 -1
  13. package/checkbox/index.es.js +1 -1
  14. package/checkbox/index.umd.js +1 -1
  15. package/{comment → date-picker}/index.d.ts +0 -0
  16. package/date-picker/index.es.js +1145 -0
  17. package/date-picker/index.umd.js +1 -0
  18. package/date-picker/package.json +7 -0
  19. package/date-picker/style.css +1 -0
  20. package/{read-tip → drawer}/index.d.ts +0 -0
  21. package/drawer/index.es.js +236 -0
  22. package/drawer/index.umd.js +1 -0
  23. package/{comment → drawer}/package.json +1 -1
  24. package/drawer/style.css +1 -0
  25. package/{tag-input → dropdown}/index.d.ts +0 -0
  26. package/dropdown/index.es.js +718 -0
  27. package/dropdown/index.umd.js +1 -0
  28. package/{read-tip → dropdown}/package.json +1 -1
  29. package/dropdown/style.css +1 -0
  30. package/editable-select/index.es.js +14 -14
  31. package/editable-select/index.umd.js +1 -1
  32. package/editable-select/style.css +1 -1
  33. package/form/index.d.ts +7 -0
  34. package/form/index.es.js +7511 -0
  35. package/form/index.umd.js +27 -0
  36. package/{tag-input → form}/package.json +1 -1
  37. package/form/style.css +1 -0
  38. package/fullscreen/index.es.js +1 -1
  39. package/fullscreen/index.umd.js +1 -1
  40. package/image-preview/style.css +1 -1
  41. package/input/index.es.js +13 -19
  42. package/input/index.umd.js +1 -1
  43. package/input/style.css +1 -1
  44. package/input-number/index.d.ts +7 -0
  45. package/input-number/index.es.js +251 -0
  46. package/input-number/index.umd.js +1 -0
  47. package/input-number/package.json +7 -0
  48. package/input-number/style.css +1 -0
  49. package/loading/style.css +1 -1
  50. package/modal/index.es.js +15 -3
  51. package/modal/index.umd.js +1 -1
  52. package/modal/style.css +1 -1
  53. package/notification/style.css +1 -1
  54. package/nuxt/components/CheckboxGroup.js +3 -0
  55. package/nuxt/components/Column.js +3 -0
  56. package/nuxt/components/DatePicker.js +3 -0
  57. package/nuxt/components/Drawer.js +3 -0
  58. package/nuxt/components/DrawerService.js +3 -0
  59. package/nuxt/components/Dropdown.js +3 -0
  60. package/nuxt/components/DropdownMenu.js +3 -0
  61. package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
  62. package/nuxt/components/FORM_TOKEN.js +3 -0
  63. package/nuxt/components/Form.js +3 -0
  64. package/nuxt/components/FormControl.js +3 -0
  65. package/nuxt/components/FormItem.js +3 -0
  66. package/nuxt/components/FormLabel.js +3 -0
  67. package/nuxt/components/FormOperation.js +3 -0
  68. package/nuxt/components/InputNumber.js +3 -0
  69. package/nuxt/components/Select.js +3 -0
  70. package/nuxt/components/StickSlider.js +3 -0
  71. package/nuxt/components/Tab.js +3 -0
  72. package/nuxt/components/Table.js +3 -0
  73. package/nuxt/components/Tabs.js +3 -0
  74. package/nuxt/components/Tooltip.js +3 -0
  75. package/nuxt/components/Tree.js +3 -0
  76. package/nuxt/components/dropdownMenuProps.js +3 -0
  77. package/nuxt/components/formControlProps.js +3 -0
  78. package/nuxt/components/formItemProps.js +3 -0
  79. package/nuxt/components/formProps.js +3 -0
  80. package/nuxt/components/tabsProps.js +3 -0
  81. package/nuxt/components/tooltipProps.js +3 -0
  82. package/nuxt/components/treeProps.js +3 -0
  83. package/overlay/index.es.js +15 -3
  84. package/overlay/index.umd.js +1 -1
  85. package/overlay/style.css +1 -1
  86. package/package.json +2 -2
  87. package/pagination/index.es.js +80 -96
  88. package/pagination/index.umd.js +1 -1
  89. package/pagination/style.css +1 -1
  90. package/popover/index.es.js +15 -3
  91. package/popover/index.umd.js +9 -9
  92. package/popover/style.css +1 -1
  93. package/progress/index.es.js +48 -14
  94. package/progress/index.umd.js +3 -3
  95. package/progress/style.css +1 -1
  96. package/rate/index.es.js +29 -36
  97. package/rate/index.umd.js +1 -1
  98. package/rate/style.css +1 -1
  99. package/search/index.es.js +15 -19
  100. package/search/index.umd.js +12 -12
  101. package/search/style.css +1 -1
  102. package/select/index.d.ts +7 -0
  103. package/select/index.es.js +696 -0
  104. package/select/index.umd.js +1 -0
  105. package/select/package.json +7 -0
  106. package/select/style.css +1 -0
  107. package/slider/index.es.js +18 -6
  108. package/slider/index.umd.js +1 -1
  109. package/splitter/index.es.js +15 -3
  110. package/splitter/index.umd.js +11 -11
  111. package/splitter/style.css +1 -1
  112. package/style.css +1 -1
  113. package/table/index.d.ts +7 -0
  114. package/table/index.es.js +2662 -0
  115. package/table/index.umd.js +1 -0
  116. package/table/package.json +7 -0
  117. package/table/style.css +1 -0
  118. package/tabs/index.d.ts +7 -0
  119. package/tabs/index.es.js +194 -0
  120. package/tabs/index.umd.js +1 -0
  121. package/tabs/package.json +7 -0
  122. package/tabs/style.css +1 -0
  123. package/textarea/style.css +1 -1
  124. package/tooltip/index.d.ts +7 -0
  125. package/tooltip/index.es.js +5847 -0
  126. package/tooltip/index.umd.js +27 -0
  127. package/tooltip/package.json +7 -0
  128. package/tooltip/style.css +1 -0
  129. package/tree/index.d.ts +7 -0
  130. package/tree/index.es.js +1021 -0
  131. package/tree/index.umd.js +1 -0
  132. package/tree/package.json +7 -0
  133. package/tree/style.css +1 -0
  134. package/upload/style.css +1 -1
  135. package/vue-devui.es.js +11482 -6434
  136. package/vue-devui.umd.js +24 -24
  137. package/comment/index.es.js +0 -84
  138. package/comment/index.umd.js +0 -1
  139. package/comment/style.css +0 -1
  140. package/nuxt/components/Comment.js +0 -3
  141. package/nuxt/components/ReadTip.js +0 -3
  142. package/nuxt/components/TagInput.js +0 -3
  143. package/nuxt/components/commentProps.js +0 -3
  144. package/nuxt/components/readTipProps.js +0 -3
  145. package/nuxt/components/tagInputProps.js +0 -3
  146. package/read-tip/index.es.js +0 -261
  147. package/read-tip/index.umd.js +0 -1
  148. package/read-tip/style.css +0 -1
  149. package/tag-input/index.es.js +0 -328
  150. package/tag-input/index.umd.js +0 -1
  151. package/tag-input/style.css +0 -1
@@ -0,0 +1,2662 @@
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
+ "devui-btn-is-loading": props.loading
1365
+ }));
1366
+ const iconClass = computed(() => {
1367
+ if (!props.icon) {
1368
+ return "";
1369
+ }
1370
+ const origin = "devui-icon-fix icon";
1371
+ if (hasContent.value) {
1372
+ return `${origin} clear-right-5`;
1373
+ } else {
1374
+ return origin;
1375
+ }
1376
+ });
1377
+ return { classes, iconClass };
1378
+ }
1379
+ var button = "";
1380
+ var Button = defineComponent({
1381
+ name: "DButton",
1382
+ directives: {
1383
+ dLoading: loadingDirective
1384
+ },
1385
+ props: buttonProps,
1386
+ emits: ["click"],
1387
+ setup(props, ctx) {
1388
+ const {
1389
+ icon,
1390
+ disabled,
1391
+ loading: loading2
1392
+ } = toRefs(props);
1393
+ const {
1394
+ classes,
1395
+ iconClass
1396
+ } = useButton(props, ctx);
1397
+ const onClick = (e) => {
1398
+ if (loading2.value) {
1399
+ return;
1400
+ }
1401
+ ctx.emit("click", e);
1402
+ };
1403
+ return () => {
1404
+ var _a, _b;
1405
+ return withDirectives(createVNode("button", {
1406
+ "class": classes.value,
1407
+ "disabled": disabled.value,
1408
+ "onClick": onClick
1409
+ }, [icon.value && createVNode(Icon, {
1410
+ "name": icon.value,
1411
+ "size": "var(--devui-font-size, 12px)",
1412
+ "color": "",
1413
+ "class": iconClass.value
1414
+ }, null), createVNode("span", {
1415
+ "class": "button-content"
1416
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), [[resolveDirective("dLoading"), loading2.value]]);
1417
+ };
1418
+ }
1419
+ });
1420
+ var checkbox = "";
1421
+ const commonProps = {
1422
+ name: {
1423
+ type: String,
1424
+ default: void 0
1425
+ },
1426
+ halfchecked: {
1427
+ type: Boolean,
1428
+ default: false
1429
+ },
1430
+ isShowTitle: {
1431
+ type: Boolean,
1432
+ default: true
1433
+ },
1434
+ title: {
1435
+ type: String
1436
+ },
1437
+ color: {
1438
+ type: String,
1439
+ default: void 0
1440
+ },
1441
+ showAnimation: {
1442
+ type: Boolean,
1443
+ default: true
1444
+ },
1445
+ disabled: {
1446
+ type: Boolean,
1447
+ default: false
1448
+ },
1449
+ beforeChange: {
1450
+ type: Function,
1451
+ default: void 0
1452
+ }
1453
+ };
1454
+ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
1455
+ halfchecked: {
1456
+ type: Boolean,
1457
+ default: false
1458
+ },
1459
+ checked: {
1460
+ type: Boolean,
1461
+ default: false
1462
+ },
1463
+ value: {
1464
+ type: String
1465
+ },
1466
+ label: {
1467
+ type: String,
1468
+ default: void 0
1469
+ },
1470
+ title: {
1471
+ type: String,
1472
+ default: void 0
1473
+ },
1474
+ "onUpdate:checked": {
1475
+ type: Function,
1476
+ default: void 0
1477
+ },
1478
+ onChange: {
1479
+ type: Function,
1480
+ default: void 0
1481
+ },
1482
+ modelValue: {
1483
+ type: Boolean
1484
+ },
1485
+ "onUpdate:modelValue": {
1486
+ type: Function
1487
+ }
1488
+ });
1489
+ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
1490
+ modelValue: {
1491
+ type: Array,
1492
+ required: true
1493
+ },
1494
+ direction: {
1495
+ type: String,
1496
+ default: "column"
1497
+ },
1498
+ itemWidth: {
1499
+ type: Number,
1500
+ default: void 0
1501
+ },
1502
+ options: {
1503
+ type: Array,
1504
+ default: () => []
1505
+ },
1506
+ onChange: {
1507
+ type: Function,
1508
+ default: void 0
1509
+ },
1510
+ "onUpdate:modelValue": {
1511
+ type: Function,
1512
+ default: void 0
1513
+ }
1514
+ });
1515
+ const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
1516
+ var Checkbox = defineComponent({
1517
+ name: "DCheckbox",
1518
+ props: checkboxProps,
1519
+ emits: ["change", "update:checked", "update:modelValue"],
1520
+ setup(props, ctx) {
1521
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
1522
+ const isChecked = computed(() => props.checked || props.modelValue);
1523
+ const mergedDisabled = computed(() => {
1524
+ return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
1525
+ });
1526
+ const mergedChecked = computed(() => {
1527
+ var _a, _b;
1528
+ return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
1529
+ });
1530
+ const mergedIsShowTitle = computed(() => {
1531
+ var _a;
1532
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
1533
+ });
1534
+ const mergedShowAnimation = computed(() => {
1535
+ var _a;
1536
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
1537
+ });
1538
+ const mergedColor = computed(() => {
1539
+ var _a;
1540
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
1541
+ });
1542
+ const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
1543
+ const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
1544
+ const canChange = (checked, val) => {
1545
+ var _a;
1546
+ if (mergedDisabled.value) {
1547
+ return Promise.resolve(false);
1548
+ }
1549
+ const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
1550
+ if (beforeChange) {
1551
+ const res = beforeChange(checked, val);
1552
+ if (typeof res === "boolean") {
1553
+ return Promise.resolve(res);
1554
+ }
1555
+ return res;
1556
+ }
1557
+ return Promise.resolve(true);
1558
+ };
1559
+ const toggle = () => {
1560
+ const current = !isChecked.value;
1561
+ checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
1562
+ ctx.emit("update:checked", current);
1563
+ ctx.emit("update:modelValue", current);
1564
+ ctx.emit("change", current);
1565
+ };
1566
+ const handleClick = () => {
1567
+ canChange(!isChecked.value, props.label).then((res) => res && toggle());
1568
+ };
1569
+ return {
1570
+ itemWidth,
1571
+ direction,
1572
+ mergedColor,
1573
+ mergedDisabled,
1574
+ mergedIsShowTitle,
1575
+ mergedChecked,
1576
+ mergedShowAnimation,
1577
+ handleClick
1578
+ };
1579
+ },
1580
+ render() {
1581
+ var _a;
1582
+ const {
1583
+ itemWidth,
1584
+ direction,
1585
+ mergedChecked,
1586
+ mergedDisabled,
1587
+ mergedIsShowTitle,
1588
+ mergedShowAnimation,
1589
+ halfchecked,
1590
+ title,
1591
+ label,
1592
+ handleClick,
1593
+ name,
1594
+ value,
1595
+ mergedColor,
1596
+ $slots
1597
+ } = this;
1598
+ const wrapperCls = {
1599
+ "devui-checkbox-column-margin": direction === "column",
1600
+ "devui-checkbox-wrap": typeof itemWidth !== "undefined"
1601
+ };
1602
+ const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
1603
+ const checkboxCls = {
1604
+ "devui-checkbox": true,
1605
+ active: mergedChecked,
1606
+ halfchecked,
1607
+ disabled: mergedDisabled,
1608
+ unchecked: !mergedChecked
1609
+ };
1610
+ const labelTitle = mergedIsShowTitle ? title || label : "";
1611
+ const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
1612
+ const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
1613
+ const spanCls = {
1614
+ "devui-checkbox-material": true,
1615
+ "custom-color": mergedColor,
1616
+ "devui-checkbox-no-label": !label && !$slots.default,
1617
+ "devui-no-animation": !mergedShowAnimation,
1618
+ "devui-checkbox-default-background": !halfchecked
1619
+ };
1620
+ const polygonCls = {
1621
+ "devui-tick": true,
1622
+ "devui-no-animation": !mergedShowAnimation
1623
+ };
1624
+ const stopPropagation = ($event) => $event.stopPropagation();
1625
+ const inputProps = {
1626
+ indeterminate: halfchecked
1627
+ };
1628
+ return createVNode("div", {
1629
+ "class": wrapperCls,
1630
+ "style": wrapperStyle
1631
+ }, [createVNode("div", {
1632
+ "class": checkboxCls
1633
+ }, [createVNode("label", {
1634
+ "title": labelTitle,
1635
+ "onClick": handleClick
1636
+ }, [createVNode("input", mergeProps({
1637
+ "name": name || value,
1638
+ "class": "devui-checkbox-input",
1639
+ "type": "checkbox"
1640
+ }, inputProps, {
1641
+ "checked": mergedChecked,
1642
+ "disabled": mergedDisabled,
1643
+ "onClick": stopPropagation,
1644
+ "onChange": stopPropagation
1645
+ }), null), createVNode("span", {
1646
+ "style": spanStyle,
1647
+ "class": spanCls
1648
+ }, [createVNode("span", {
1649
+ "class": "devui-checkbox-halfchecked-bg"
1650
+ }, null), createVNode("svg", {
1651
+ "viewBox": "0 0 16 16",
1652
+ "version": "1.1",
1653
+ "xmlns": "http://www.w3.org/2000/svg",
1654
+ "class": "devui-checkbox-tick"
1655
+ }, [createVNode("g", {
1656
+ "stroke": "none",
1657
+ "stroke-width": "1",
1658
+ "fill": "none",
1659
+ "fill-rule": "evenodd"
1660
+ }, [createVNode("polygon", {
1661
+ "fill-rule": "nonzero",
1662
+ "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
1663
+ "class": polygonCls
1664
+ }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
1665
+ }
1666
+ });
1667
+ var checkboxGroup = "";
1668
+ defineComponent({
1669
+ name: "DCheckboxGroup",
1670
+ props: checkboxGroupProps,
1671
+ emits: ["change", "update:modelValue"],
1672
+ setup(props, ctx) {
1673
+ const valList = toRef(props, "modelValue");
1674
+ const defaultOpt = {
1675
+ checked: false,
1676
+ isShowTitle: true,
1677
+ halfchecked: false,
1678
+ showAnimation: true,
1679
+ disabled: false
1680
+ };
1681
+ const toggleGroupVal = (val) => {
1682
+ let index2 = -1;
1683
+ if (typeof valList.value[0] === "string") {
1684
+ index2 = valList.value.findIndex((item) => item === val);
1685
+ } else if (typeof valList.value[0] === "object") {
1686
+ index2 = valList.value.findIndex((item) => item.value === val);
1687
+ }
1688
+ if (index2 === -1) {
1689
+ if (typeof props.options[0] === "object") {
1690
+ const newOne = props.options.find((item) => item.value === val);
1691
+ const res2 = [...valList.value, newOne];
1692
+ ctx.emit("update:modelValue", res2);
1693
+ ctx.emit("change", res2);
1694
+ return;
1695
+ }
1696
+ const res = [...valList.value, val];
1697
+ ctx.emit("update:modelValue", res);
1698
+ ctx.emit("change", res);
1699
+ return;
1700
+ }
1701
+ valList.value.splice(index2, 1);
1702
+ ctx.emit("update:modelValue", valList.value);
1703
+ ctx.emit("change", valList.value);
1704
+ };
1705
+ const isItemChecked = (itemVal) => {
1706
+ if (typeof valList.value[0] === "string") {
1707
+ return valList.value.includes(itemVal);
1708
+ } else if (typeof valList.value[0] === "object") {
1709
+ return valList.value.some((item) => item.value === itemVal);
1710
+ }
1711
+ };
1712
+ provide(checkboxGroupInjectionKey, {
1713
+ disabled: toRef(props, "disabled"),
1714
+ isShowTitle: toRef(props, "isShowTitle"),
1715
+ color: toRef(props, "color"),
1716
+ showAnimation: toRef(props, "showAnimation"),
1717
+ beforeChange: props.beforeChange,
1718
+ isItemChecked,
1719
+ toggleGroupVal,
1720
+ itemWidth: toRef(props, "itemWidth"),
1721
+ direction: toRef(props, "direction")
1722
+ });
1723
+ return {
1724
+ defaultOpt
1725
+ };
1726
+ },
1727
+ render() {
1728
+ var _a;
1729
+ const {
1730
+ direction,
1731
+ $slots,
1732
+ defaultOpt,
1733
+ options
1734
+ } = this;
1735
+ let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
1736
+ if ((options == null ? void 0 : options.length) > 0) {
1737
+ children = options.map((opt) => {
1738
+ let mergedOpt = null;
1739
+ if (typeof opt === "string") {
1740
+ mergedOpt = Object.assign({}, defaultOpt, {
1741
+ label: opt,
1742
+ value: opt
1743
+ });
1744
+ } else if (typeof opt === "object") {
1745
+ mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
1746
+ label: opt.name
1747
+ }));
1748
+ }
1749
+ return createVNode(Checkbox, mergedOpt, null);
1750
+ });
1751
+ }
1752
+ return createVNode("div", {
1753
+ "class": "devui-checkbox-group"
1754
+ }, [createVNode("div", {
1755
+ "class": {
1756
+ "devui-checkbox-list-inline": direction === "row"
1757
+ }
1758
+ }, [children])]);
1759
+ }
1760
+ });
1761
+ function useFilterRender(ctx) {
1762
+ const showMenu = ref(false);
1763
+ const filterMenuRef = ref(null);
1764
+ const filterIconRef = ref(null);
1765
+ const singleVal = ref(null);
1766
+ const multipleVal = ref(null);
1767
+ const handleIconClick = () => {
1768
+ showMenu.value = !showMenu.value;
1769
+ };
1770
+ const handleConfirm = (val) => {
1771
+ showMenu.value = false;
1772
+ multipleVal.value = val;
1773
+ ctx.emit("filter", val);
1774
+ };
1775
+ const handleSelect = (val) => {
1776
+ showMenu.value = false;
1777
+ singleVal.value = val;
1778
+ ctx.emit("filter", val);
1779
+ };
1780
+ const iconClasses = computed(() => {
1781
+ var _a;
1782
+ return {
1783
+ "filter-icon": true,
1784
+ "filter-icon-active": Boolean(singleVal.value || ((_a = multipleVal.value) == null ? void 0 : _a.length))
1785
+ };
1786
+ });
1787
+ onClickOutside(filterMenuRef, () => {
1788
+ showMenu.value = false;
1789
+ }, {
1790
+ ignore: [filterIconRef]
1791
+ });
1792
+ return { showMenu, filterMenuRef, filterIconRef, iconClasses, handleIconClick, handleConfirm, handleSelect };
1793
+ }
1794
+ function useFilterMultiple(filterList, ctx) {
1795
+ const _checkList = ref([]);
1796
+ const _checkAllRecord = ref(false);
1797
+ const _checkAll = computed({
1798
+ get: () => _checkAllRecord.value,
1799
+ set: (val) => {
1800
+ _checkAllRecord.value = val;
1801
+ for (let i = 0; i < _checkList.value.length; i++) {
1802
+ _checkList.value[i].checked = val;
1803
+ }
1804
+ }
1805
+ });
1806
+ const _halfChecked = ref(false);
1807
+ filterList == null ? void 0 : filterList.forEach((item) => {
1808
+ _checkList.value.push(__spreadValues({ checked: false }, item));
1809
+ });
1810
+ watch(_checkList, (list2) => {
1811
+ if (!list2.length) {
1812
+ return;
1813
+ }
1814
+ let allTrue = true;
1815
+ let allFalse = true;
1816
+ for (let i = 0; i < list2.length; i++) {
1817
+ allTrue && (allTrue = Boolean(list2[i].checked));
1818
+ allFalse && (allFalse = Boolean(!list2[i].checked));
1819
+ }
1820
+ _checkAllRecord.value = allTrue;
1821
+ _halfChecked.value = !(allFalse || allTrue);
1822
+ }, { immediate: true, deep: true });
1823
+ const getCheckedItems = () => {
1824
+ return _checkList.value.filter((item) => item.checked);
1825
+ };
1826
+ const handleConfirm = () => {
1827
+ ctx.emit("confirm", getCheckedItems());
1828
+ };
1829
+ return { _checkList, _checkAll, _halfChecked, handleConfirm };
1830
+ }
1831
+ function useFilterSingle(ctx) {
1832
+ const selectedItem = ref(null);
1833
+ const handleSelect = (val) => {
1834
+ selectedItem.value = val;
1835
+ ctx.emit("select", val);
1836
+ };
1837
+ return { selectedItem, handleSelect };
1838
+ }
1839
+ var MultipleFilter = defineComponent({
1840
+ props: {
1841
+ filterList: {
1842
+ type: Array,
1843
+ default: () => []
1844
+ }
1845
+ },
1846
+ emits: ["confirm"],
1847
+ setup(props, ctx) {
1848
+ const {
1849
+ _checkList,
1850
+ _checkAll,
1851
+ _halfChecked,
1852
+ handleConfirm
1853
+ } = useFilterMultiple(props.filterList, ctx);
1854
+ return () => createVNode(Fragment, null, [createVNode("div", {
1855
+ "class": "filter-all-check"
1856
+ }, [createVNode("div", {
1857
+ "class": "filter-item"
1858
+ }, [createVNode(Checkbox, {
1859
+ "modelValue": _checkAll.value,
1860
+ "onUpdate:modelValue": ($event) => _checkAll.value = $event,
1861
+ "halfchecked": _halfChecked.value,
1862
+ "label": "\u5168\u9009"
1863
+ }, null)])]), createVNode("div", {
1864
+ "class": "filter-multiple-menu"
1865
+ }, [_checkList.value.map((item) => createVNode("div", {
1866
+ "class": "filter-item"
1867
+ }, [createVNode(Checkbox, {
1868
+ "modelValue": item.checked,
1869
+ "onUpdate:modelValue": ($event) => item.checked = $event,
1870
+ "label": item.name
1871
+ }, null)]))]), createVNode("div", {
1872
+ "class": "filter-operation"
1873
+ }, [createVNode(Button, {
1874
+ "variant": "text",
1875
+ "onClick": handleConfirm
1876
+ }, {
1877
+ default: () => [createTextVNode("\u786E\u5B9A")]
1878
+ })])]);
1879
+ }
1880
+ });
1881
+ var list = "";
1882
+ var List = defineComponent({
1883
+ name: "DList",
1884
+ setup(props, {
1885
+ slots
1886
+ }) {
1887
+ return () => {
1888
+ var _a;
1889
+ return createVNode("div", {
1890
+ "class": "devui-list"
1891
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
1892
+ };
1893
+ }
1894
+ });
1895
+ var listItem = "";
1896
+ var ListItem = defineComponent({
1897
+ name: "DListItem",
1898
+ setup(props, {
1899
+ slots
1900
+ }) {
1901
+ return () => {
1902
+ var _a;
1903
+ return createVNode("div", {
1904
+ "class": "devui-list-item"
1905
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
1906
+ };
1907
+ }
1908
+ });
1909
+ function _isSlot(s) {
1910
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
1911
+ }
1912
+ var SingleFilter = defineComponent({
1913
+ props: {
1914
+ filterList: {
1915
+ type: Array,
1916
+ default: () => []
1917
+ }
1918
+ },
1919
+ emits: ["select"],
1920
+ setup(props, ctx) {
1921
+ const {
1922
+ selectedItem,
1923
+ handleSelect
1924
+ } = useFilterSingle(ctx);
1925
+ return () => {
1926
+ let _slot;
1927
+ return createVNode(Fragment, null, [createVNode(List, {
1928
+ "class": "filter-single-menu"
1929
+ }, _isSlot(_slot = props.filterList.map((item) => createVNode(ListItem, {
1930
+ "class": ["filter-item", {
1931
+ "filter-item-active": selectedItem.value === item
1932
+ }],
1933
+ "onClick": () => {
1934
+ handleSelect(item);
1935
+ }
1936
+ }, {
1937
+ default: () => [item.name]
1938
+ }))) ? _slot : {
1939
+ default: () => [_slot]
1940
+ })]);
1941
+ };
1942
+ }
1943
+ });
1944
+ var filter = "";
1945
+ var Filter = defineComponent({
1946
+ props: filterProps,
1947
+ emits: ["filter"],
1948
+ setup(props, ctx) {
1949
+ const {
1950
+ showMenu,
1951
+ filterMenuRef,
1952
+ filterIconRef,
1953
+ iconClasses,
1954
+ handleIconClick,
1955
+ handleConfirm,
1956
+ handleSelect
1957
+ } = useFilterRender(ctx);
1958
+ return () => createVNode(Dropdown, {
1959
+ "visible": showMenu.value,
1960
+ "trigger": "manually",
1961
+ "close-scope": "none",
1962
+ "destroy-on-hide": false,
1963
+ "style": "padding-bottom: 4px;"
1964
+ }, {
1965
+ default: () => createVNode("i", {
1966
+ "ref": filterIconRef,
1967
+ "class": iconClasses.value,
1968
+ "onClick": handleIconClick
1969
+ }, [createVNode("svg", {
1970
+ "width": "16px",
1971
+ "height": "16px",
1972
+ "viewBox": "0 0 16 16",
1973
+ "version": "1.1",
1974
+ "xmlns": "http://www.w3.org/2000/svg"
1975
+ }, [createVNode("g", {
1976
+ "stroke": "none",
1977
+ "stroke-width": "1",
1978
+ "fill": "none",
1979
+ "fill-rule": "evenodd"
1980
+ }, [createVNode("g", null, [createVNode("polygon", {
1981
+ "points": "10.0085775 7 10.0085775 15 6 13 6 7 2 3 2 1 14 1 14 3"
1982
+ }, null)])])])]),
1983
+ menu: () => createVNode("div", {
1984
+ "ref": filterMenuRef,
1985
+ "class": "filter-wrapper"
1986
+ }, [props.multiple ? createVNode(MultipleFilter, {
1987
+ "filterList": props.filterList,
1988
+ "onConfirm": handleConfirm
1989
+ }, null) : createVNode(SingleFilter, {
1990
+ "filterList": props.filterList,
1991
+ "onSelect": handleSelect
1992
+ }, null)])
1993
+ });
1994
+ }
1995
+ });
1996
+ function useSort(column) {
1997
+ const table2 = inject(TABLE_TOKEN);
1998
+ const store = table2.store;
1999
+ const direction = ref(column.value.sortDirection);
2000
+ const sortClass = computed(() => ({
2001
+ "sort-active": Boolean(direction.value)
2002
+ }));
2003
+ const thInstance = getCurrentInstance();
2004
+ thInstance && store.states.thList.push(thInstance);
2005
+ onMounted(() => {
2006
+ var _a;
2007
+ column.value.sortable && column.value.sortDirection && ((_a = store.sortData) == null ? void 0 : _a.call(store, direction.value, column.value.sortMethod));
2008
+ });
2009
+ const execClearSortOrder = () => {
2010
+ store.states.thList.forEach((th) => {
2011
+ var _a, _b;
2012
+ if (th !== thInstance) {
2013
+ (_b = (_a = th.exposed) == null ? void 0 : _a.clearSortOrder) == null ? void 0 : _b.call(_a);
2014
+ }
2015
+ });
2016
+ };
2017
+ const handleSort = (val) => {
2018
+ var _a;
2019
+ direction.value = val;
2020
+ execClearSortOrder();
2021
+ (_a = store.sortData) == null ? void 0 : _a.call(store, direction.value, column.value.sortMethod);
2022
+ table2.emit("sort-change", { field: column.value.field, direction: direction.value });
2023
+ };
2024
+ const clearSortOrder = () => {
2025
+ direction.value = "";
2026
+ };
2027
+ return { direction, sortClass, handleSort, clearSortOrder };
2028
+ }
2029
+ function useFilter(column) {
2030
+ const filter2 = ref(null);
2031
+ const filterClass = computed(() => ({
2032
+ "filter-active": Boolean(filter2.value || Array.isArray(filter2.value) && filter2.value.length)
2033
+ }));
2034
+ const handleFilter = (val) => {
2035
+ filter2.value = val;
2036
+ column.value.ctx.emit("filter-change", val);
2037
+ };
2038
+ return { filterClass, handleFilter };
2039
+ }
2040
+ var TH = defineComponent({
2041
+ name: "DTableHeaderTh",
2042
+ props: {
2043
+ column: {
2044
+ type: Object,
2045
+ required: true
2046
+ }
2047
+ },
2048
+ setup(props, {
2049
+ expose
2050
+ }) {
2051
+ const table2 = inject(TABLE_TOKEN);
2052
+ const store = table2.store;
2053
+ const {
2054
+ column
2055
+ } = toRefs(props);
2056
+ const {
2057
+ direction,
2058
+ sortClass,
2059
+ handleSort,
2060
+ clearSortOrder
2061
+ } = useSort(column);
2062
+ const {
2063
+ filterClass,
2064
+ handleFilter
2065
+ } = useFilter(column);
2066
+ const {
2067
+ stickyClass,
2068
+ stickyStyle
2069
+ } = useFixedColumn(column);
2070
+ expose({
2071
+ clearSortOrder
2072
+ });
2073
+ return () => {
2074
+ var _a, _b;
2075
+ return createVNode("th", {
2076
+ "class": [stickyClass.value, sortClass.value, filterClass.value],
2077
+ "style": stickyStyle.value
2078
+ }, [createVNode("div", {
2079
+ "class": "header-container"
2080
+ }, [(_b = (_a = column.value).renderHeader) == null ? void 0 : _b.call(_a, column.value, store), column.value.filterable && createVNode(Filter, {
2081
+ "filterList": column.value.filterList,
2082
+ "multiple": column.value.filterMultiple,
2083
+ "onFilter": handleFilter
2084
+ }, null), column.value.sortable && createVNode(Sort, {
2085
+ "sort-direction": direction.value,
2086
+ "onSort": handleSort
2087
+ }, null)])]);
2088
+ };
2089
+ }
2090
+ });
2091
+ function getAllColumns(columns) {
2092
+ const result = [];
2093
+ columns.forEach((column) => {
2094
+ if (column.children) {
2095
+ result.push(column);
2096
+ result.push.apply(result, getAllColumns(column.children));
2097
+ } else {
2098
+ result.push(column);
2099
+ }
2100
+ });
2101
+ return result;
2102
+ }
2103
+ function convertToRows(originColumns) {
2104
+ let maxLevel = 1;
2105
+ const traverse = (column, parent) => {
2106
+ if (parent) {
2107
+ column.level = parent.level + 1;
2108
+ if (maxLevel < column.level) {
2109
+ maxLevel = column.level;
2110
+ }
2111
+ }
2112
+ if (column.children) {
2113
+ let colSpan = 0;
2114
+ column.children.forEach((subColumn) => {
2115
+ traverse(subColumn, column);
2116
+ colSpan += subColumn.colSpan;
2117
+ });
2118
+ column.colSpan = colSpan;
2119
+ } else {
2120
+ column.colSpan = 1;
2121
+ }
2122
+ };
2123
+ originColumns.forEach((column) => {
2124
+ column.level = 1;
2125
+ traverse(column, void 0);
2126
+ });
2127
+ const rows = [];
2128
+ for (let i = 0; i < maxLevel; i++) {
2129
+ rows.push([]);
2130
+ }
2131
+ const allColumns = getAllColumns(originColumns);
2132
+ allColumns.forEach((column) => {
2133
+ if (!column.children) {
2134
+ column.rowSpan = maxLevel - column.level + 1;
2135
+ } else {
2136
+ column.rowSpan = 1;
2137
+ column.children.forEach((col) => col.isSubColumn = true);
2138
+ }
2139
+ rows[column.level - 1].push(column);
2140
+ });
2141
+ return rows;
2142
+ }
2143
+ function useHeader() {
2144
+ const table2 = inject(TABLE_TOKEN);
2145
+ const headerRows = computed(() => convertToRows(table2 == null ? void 0 : table2.store.states._columns.value));
2146
+ return { headerRows };
2147
+ }
2148
+ var header = "";
2149
+ var body = "";
2150
+ var TableHeader = defineComponent({
2151
+ name: "DTableHeader",
2152
+ setup() {
2153
+ const ns = useNamespace("table");
2154
+ const {
2155
+ headerRows
2156
+ } = useHeader();
2157
+ return () => createVNode("thead", {
2158
+ "class": ns.e("thead")
2159
+ }, [headerRows.value.map((subColumns) => createVNode("tr", null, [subColumns.map((column, columnIndex) => createVNode(TH, {
2160
+ "key": columnIndex,
2161
+ "column": column,
2162
+ "colspan": column.colSpan,
2163
+ "rowspan": column.rowSpan
2164
+ }, null))]))]);
2165
+ }
2166
+ });
2167
+ var TD = defineComponent({
2168
+ name: "DTableBodyTd",
2169
+ props: {
2170
+ column: {
2171
+ type: Object,
2172
+ default: () => ({})
2173
+ },
2174
+ row: {
2175
+ type: Object,
2176
+ default: () => ({})
2177
+ },
2178
+ index: {
2179
+ type: Number,
2180
+ default: 0
2181
+ }
2182
+ },
2183
+ setup(props) {
2184
+ const table2 = inject(TABLE_TOKEN);
2185
+ const column = toRef(props, "column");
2186
+ const {
2187
+ stickyClass,
2188
+ stickyStyle
2189
+ } = useFixedColumn(column);
2190
+ return () => {
2191
+ var _a, _b;
2192
+ return createVNode("td", {
2193
+ "class": stickyClass.value,
2194
+ "style": stickyStyle.value
2195
+ }, [(_b = (_a = column.value).renderCell) == null ? void 0 : _b.call(_a, props.row, column.value, table2.store, props.index)]);
2196
+ };
2197
+ }
2198
+ });
2199
+ function useMergeCell() {
2200
+ const table2 = inject(TABLE_TOKEN);
2201
+ const { _data: data, _columns: columns } = table2.store.states;
2202
+ const getSpan = (row, column, rowIndex, columnIndex) => {
2203
+ const fn = table2 == null ? void 0 : table2.props.spanMethod;
2204
+ let rowspan = 1;
2205
+ let colspan = 1;
2206
+ if (typeof fn === "function") {
2207
+ const result = fn({ row, column, rowIndex, columnIndex });
2208
+ if (Array.isArray(result)) {
2209
+ rowspan = result[0];
2210
+ colspan = result[1];
2211
+ } else if (typeof result === "object") {
2212
+ rowspan = result.rowspan;
2213
+ colspan = result.colspan;
2214
+ }
2215
+ }
2216
+ return { rowspan, colspan };
2217
+ };
2218
+ const tableSpans = computed(() => {
2219
+ const result = {};
2220
+ if (table2 == null ? void 0 : table2.props.spanMethod) {
2221
+ data.value.forEach((row, rowIndex) => {
2222
+ columns.value.forEach((column, columnIndex) => {
2223
+ const { rowspan, colspan } = getSpan(row, column, rowIndex, columnIndex);
2224
+ if (rowspan > 1 || colspan > 1) {
2225
+ result[`${rowIndex}-${columnIndex}`] = [rowspan, colspan];
2226
+ }
2227
+ });
2228
+ });
2229
+ }
2230
+ return result;
2231
+ });
2232
+ const removeCells = computed(() => {
2233
+ const result = [];
2234
+ for (const indexKey of Object.keys(tableSpans.value)) {
2235
+ const indexArray = indexKey.split("-").map((item) => Number(item));
2236
+ const spans = tableSpans.value[indexKey];
2237
+ for (let i = 1; i < spans[0]; i++) {
2238
+ result.push(`${indexArray[0] + i}-${indexArray[1]}`);
2239
+ for (let j = 1; j < spans[1]; j++) {
2240
+ result.push(`${indexArray[0] + i}-${indexArray[1] + j}`);
2241
+ }
2242
+ }
2243
+ for (let i = 1; i < spans[1]; i++) {
2244
+ result.push(`${indexArray[0]}-${indexArray[1] + i}`);
2245
+ }
2246
+ }
2247
+ return result;
2248
+ });
2249
+ return { tableSpans, removeCells };
2250
+ }
2251
+ var TableBody = defineComponent({
2252
+ name: "DTableBody",
2253
+ setup() {
2254
+ const table2 = inject(TABLE_TOKEN);
2255
+ const {
2256
+ _data: data,
2257
+ flatColumns
2258
+ } = table2.store.states;
2259
+ const ns = useNamespace("table");
2260
+ const hoverEnabled = computed(() => table2.props.rowHoveredHighlight);
2261
+ const {
2262
+ tableSpans,
2263
+ removeCells
2264
+ } = useMergeCell();
2265
+ return () => createVNode("tbody", {
2266
+ "class": ns.e("tbody")
2267
+ }, [data.value.map((row, rowIndex) => {
2268
+ return createVNode("tr", {
2269
+ "key": rowIndex,
2270
+ "class": {
2271
+ "hover-enabled": hoverEnabled.value
2272
+ }
2273
+ }, [flatColumns.value.map((column, columnIndex) => {
2274
+ var _a;
2275
+ const cellId = `${rowIndex}-${columnIndex}`;
2276
+ const [rowspan, colspan] = (_a = tableSpans.value[cellId]) != null ? _a : [1, 1];
2277
+ if (removeCells.value.includes(cellId)) {
2278
+ return null;
2279
+ }
2280
+ return createVNode(TD, {
2281
+ "column": column,
2282
+ "index": rowIndex,
2283
+ "row": row,
2284
+ "rowspan": rowspan,
2285
+ "colspan": colspan
2286
+ }, null);
2287
+ })]);
2288
+ })]);
2289
+ }
2290
+ });
2291
+ var FixHeader = defineComponent({
2292
+ props: {
2293
+ classes: {
2294
+ type: Object,
2295
+ default: () => ({})
2296
+ },
2297
+ isEmpty: {
2298
+ type: Boolean
2299
+ }
2300
+ },
2301
+ setup(props) {
2302
+ const ns = useNamespace("table");
2303
+ return () => {
2304
+ return createVNode("div", {
2305
+ "class": ns.e("fix-header")
2306
+ }, [createVNode("div", {
2307
+ "style": "overflow:hidden scroll;"
2308
+ }, [createVNode("table", {
2309
+ "class": props.classes,
2310
+ "cellpadding": "0",
2311
+ "cellspacing": "0"
2312
+ }, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
2313
+ "class": ns.e("scroll-view")
2314
+ }, [createVNode("table", {
2315
+ "class": props.classes,
2316
+ "cellpadding": "0",
2317
+ "cellspacing": "0"
2318
+ }, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
2319
+ "style": "flex: 1"
2320
+ }, null)])])]);
2321
+ };
2322
+ }
2323
+ });
2324
+ var NormalHeader = defineComponent({
2325
+ props: {
2326
+ classes: {
2327
+ type: Object,
2328
+ default: () => ({})
2329
+ },
2330
+ isEmpty: {
2331
+ type: Boolean
2332
+ }
2333
+ },
2334
+ setup(props) {
2335
+ return () => {
2336
+ return createVNode("table", {
2337
+ "class": props.classes,
2338
+ "cellpadding": "0",
2339
+ "cellspacing": "0"
2340
+ }, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
2341
+ "style": "position:relative"
2342
+ }, null), !props.isEmpty && createVNode(TableBody, null, null)]);
2343
+ };
2344
+ }
2345
+ });
2346
+ defineComponent(Loading);
2347
+ var table = "";
2348
+ let tableIdInit = 1;
2349
+ var Table = defineComponent({
2350
+ name: "DTable",
2351
+ directives: {
2352
+ dLoading: loadingDirective
2353
+ },
2354
+ props: TableProps,
2355
+ emits: ["sort-change"],
2356
+ setup(props, ctx) {
2357
+ const table2 = getCurrentInstance();
2358
+ const store = createStore(toRef(props, "data"));
2359
+ const tableId = `devui-table_${tableIdInit++}`;
2360
+ table2.tableId = tableId;
2361
+ table2.store = store;
2362
+ provide(TABLE_TOKEN, table2);
2363
+ const {
2364
+ classes,
2365
+ style
2366
+ } = useTable(props);
2367
+ const isEmpty2 = computed(() => props.data.length === 0);
2368
+ const ns = useNamespace("table");
2369
+ const hiddenColumns = ref(null);
2370
+ table2.hiddenColumns = hiddenColumns;
2371
+ ctx.expose({
2372
+ getCheckedRows() {
2373
+ return store.getCheckedRows();
2374
+ }
2375
+ });
2376
+ onMounted(async () => {
2377
+ await nextTick();
2378
+ store.updateColumns();
2379
+ });
2380
+ return () => {
2381
+ var _a, _b;
2382
+ return withDirectives(createVNode("div", {
2383
+ "class": ns.b(),
2384
+ "style": style.value
2385
+ }, [createVNode("div", {
2386
+ "ref": hiddenColumns,
2387
+ "class": "hidden-columns"
2388
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.fixHeader ? createVNode(FixHeader, {
2389
+ "classes": classes.value,
2390
+ "is-empty": isEmpty2.value
2391
+ }, null) : createVNode(NormalHeader, {
2392
+ "classes": classes.value,
2393
+ "is-empty": isEmpty2.value
2394
+ }, null), isEmpty2.value && createVNode("div", {
2395
+ "class": ns.e("empty")
2396
+ }, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
2397
+ };
2398
+ }
2399
+ });
2400
+ const tableColumnProps = {
2401
+ type: {
2402
+ type: String,
2403
+ default: ""
2404
+ },
2405
+ header: {
2406
+ type: String
2407
+ },
2408
+ field: {
2409
+ type: String,
2410
+ default: ""
2411
+ },
2412
+ width: {
2413
+ type: [String, Number],
2414
+ default: ""
2415
+ },
2416
+ minWidth: {
2417
+ type: [String, Number],
2418
+ default: 80
2419
+ },
2420
+ formatter: {
2421
+ type: Function
2422
+ },
2423
+ order: {
2424
+ type: Number,
2425
+ default: 0
2426
+ },
2427
+ sortable: {
2428
+ type: Boolean,
2429
+ default: false
2430
+ },
2431
+ sortDirection: {
2432
+ type: String,
2433
+ default: ""
2434
+ },
2435
+ sortMethod: {
2436
+ type: Function
2437
+ },
2438
+ filterable: {
2439
+ type: Boolean,
2440
+ default: false
2441
+ },
2442
+ filterMultiple: {
2443
+ type: Boolean,
2444
+ default: true
2445
+ },
2446
+ filterList: {
2447
+ type: Array,
2448
+ default: []
2449
+ },
2450
+ fixedLeft: {
2451
+ type: String
2452
+ },
2453
+ fixedRight: {
2454
+ type: String
2455
+ }
2456
+ };
2457
+ function formatWidth(width) {
2458
+ if (typeof width === "number") {
2459
+ return width;
2460
+ }
2461
+ return parseInt(width, 10) || 0;
2462
+ }
2463
+ function formatMinWidth(minWidth) {
2464
+ return formatWidth(minWidth) || 80;
2465
+ }
2466
+ const cellMap = {
2467
+ checkable: {
2468
+ renderHeader(column, store) {
2469
+ return h(Checkbox, {
2470
+ modelValue: store.states._checkAll.value,
2471
+ halfchecked: store.states._halfChecked.value,
2472
+ onChange: (val) => {
2473
+ store.states._checkAll.value = val;
2474
+ }
2475
+ });
2476
+ },
2477
+ renderCell(rowData, column, store, rowIndex) {
2478
+ return h(Checkbox, {
2479
+ modelValue: store.states._checkList.value[rowIndex],
2480
+ onChange: (val) => {
2481
+ store.states._checkList.value[rowIndex] = val;
2482
+ }
2483
+ });
2484
+ }
2485
+ },
2486
+ index: {
2487
+ renderHeader(column) {
2488
+ var _a;
2489
+ return h("span", {
2490
+ class: "title"
2491
+ }, (_a = column.header) != null ? _a : "#");
2492
+ },
2493
+ renderCell(rowData, column, store, rowIndex) {
2494
+ return rowIndex + 1;
2495
+ }
2496
+ },
2497
+ default: {
2498
+ renderHeader(column) {
2499
+ var _a;
2500
+ return h("span", {
2501
+ class: "title"
2502
+ }, (_a = column.header) != null ? _a : "");
2503
+ },
2504
+ renderCell(rowData, column, store, rowIndex) {
2505
+ var _a, _b;
2506
+ const value = column.field ? rowData[column.field] : "";
2507
+ if (column.formatter) {
2508
+ return column.formatter(rowData, column, value, rowIndex);
2509
+ }
2510
+ return (_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : "";
2511
+ }
2512
+ }
2513
+ };
2514
+ function createColumn(props, slots) {
2515
+ const {
2516
+ type,
2517
+ field,
2518
+ header: header2,
2519
+ sortable,
2520
+ sortDirection,
2521
+ width,
2522
+ minWidth,
2523
+ formatter,
2524
+ sortMethod,
2525
+ filterable,
2526
+ filterList,
2527
+ filterMultiple,
2528
+ order,
2529
+ fixedLeft,
2530
+ fixedRight
2531
+ } = props;
2532
+ const column = reactive({});
2533
+ column.type = type.value;
2534
+ function renderHeader(columnItem, store) {
2535
+ if (slots.header) {
2536
+ return slots.header(columnItem);
2537
+ }
2538
+ return cellMap[type.value || "default"].renderHeader(columnItem, store);
2539
+ }
2540
+ function renderCell(rowData, columnItem, store, rowIndex) {
2541
+ if (slots.default) {
2542
+ return slots.default({ row: rowData, rowIndex });
2543
+ }
2544
+ return cellMap[type.value || "default"].renderCell(rowData, columnItem, store, rowIndex);
2545
+ }
2546
+ watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
2547
+ column.field = fieldVal;
2548
+ column.header = headerVal;
2549
+ column.order = orderVal;
2550
+ }, { immediate: true });
2551
+ watch([sortable, sortDirection, sortMethod], ([sortableVal, sortDirectionVal, sortMethodVal]) => {
2552
+ column.sortable = sortableVal;
2553
+ column.sortDirection = sortDirectionVal;
2554
+ column.sortMethod = sortMethodVal;
2555
+ }, { immediate: true });
2556
+ watch([filterable, filterList, filterMultiple], ([filterableVal, filterListVal, filterMultipleVal]) => {
2557
+ column.filterable = filterableVal;
2558
+ column.filterMultiple = filterMultipleVal;
2559
+ column.filterList = filterListVal;
2560
+ }, { immediate: true });
2561
+ watch([fixedLeft, fixedRight], ([left, right]) => {
2562
+ column.fixedLeft = left;
2563
+ column.fixedRight = right;
2564
+ }, { immediate: true });
2565
+ watch([width, minWidth], ([widthVal, minWidthVal]) => {
2566
+ column.width = formatWidth(widthVal);
2567
+ column.minWidth = formatMinWidth(minWidthVal);
2568
+ column.realWidth = column.width || column.minWidth;
2569
+ });
2570
+ onBeforeMount(() => {
2571
+ column.renderHeader = renderHeader;
2572
+ column.renderCell = renderCell;
2573
+ column.formatter = formatter == null ? void 0 : formatter.value;
2574
+ column.customFilterTemplate = slots.customFilterTemplate;
2575
+ column.subColumns = slots.subColumns;
2576
+ });
2577
+ return column;
2578
+ }
2579
+ function useRender() {
2580
+ const instance = getCurrentInstance();
2581
+ const columnOrTableParent = computed(() => {
2582
+ let parent = instance == null ? void 0 : instance.parent;
2583
+ while (parent && !parent.tableId && !parent.columnId) {
2584
+ parent = parent.parent;
2585
+ }
2586
+ return parent;
2587
+ });
2588
+ const getColumnIndex = (children, child) => {
2589
+ return Array.prototype.indexOf.call(children, child);
2590
+ };
2591
+ return { columnOrTableParent, getColumnIndex };
2592
+ }
2593
+ let columnIdInit = 1;
2594
+ var Column = defineComponent({
2595
+ name: "DColumn",
2596
+ props: tableColumnProps,
2597
+ emits: ["filter-change"],
2598
+ setup(props, ctx) {
2599
+ const instance = getCurrentInstance();
2600
+ const column = createColumn(toRefs(props), ctx.slots);
2601
+ const owner = inject(TABLE_TOKEN);
2602
+ const isSubColumn = ref(false);
2603
+ let columnId = "";
2604
+ const {
2605
+ columnOrTableParent,
2606
+ getColumnIndex
2607
+ } = useRender();
2608
+ const parent = columnOrTableParent.value;
2609
+ columnId = `${parent.tableId || parent.columnId}_column_${columnIdInit++}`;
2610
+ column.ctx = ctx;
2611
+ onBeforeMount(() => {
2612
+ isSubColumn.value = owner !== parent;
2613
+ column.id = columnId;
2614
+ });
2615
+ onMounted(() => {
2616
+ var _a;
2617
+ const children = isSubColumn.value ? parent.vnode.el.children : (_a = owner == null ? void 0 : owner.hiddenColumns.value) == null ? void 0 : _a.children;
2618
+ const columnIndex = getColumnIndex(children || [], instance.vnode.el);
2619
+ columnIndex > -1 && (owner == null ? void 0 : owner.store.insertColumn(column, isSubColumn.value ? parent.columnConfig : null));
2620
+ });
2621
+ watch(() => column.order, () => {
2622
+ owner == null ? void 0 : owner.store.sortColumn();
2623
+ });
2624
+ onBeforeUnmount(() => {
2625
+ owner == null ? void 0 : owner.store.removeColumn(column);
2626
+ });
2627
+ instance.columnId = columnId;
2628
+ instance.columnConfig = column;
2629
+ },
2630
+ render() {
2631
+ var _a, _b;
2632
+ try {
2633
+ const renderDefault = (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, {
2634
+ row: {},
2635
+ column: {},
2636
+ $index: -1
2637
+ });
2638
+ const children = [];
2639
+ if (Array.isArray(renderDefault)) {
2640
+ for (const childNode of renderDefault) {
2641
+ if (childNode.type.name === "DColumn") {
2642
+ children.push(childNode);
2643
+ }
2644
+ }
2645
+ }
2646
+ const vnode = h("div", children);
2647
+ return vnode;
2648
+ } catch {
2649
+ return h("div", []);
2650
+ }
2651
+ }
2652
+ });
2653
+ var index = {
2654
+ title: "Table \u8868\u683C",
2655
+ category: "\u6570\u636E\u5C55\u793A",
2656
+ status: "20%",
2657
+ install(app) {
2658
+ app.component(Table.name, Table);
2659
+ app.component(Column.name, Column);
2660
+ }
2661
+ };
2662
+ export { Column, Table, index as default };