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