vue-devui 1.0.0-rc.8 → 1.0.0-rc.9

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 (123) hide show
  1. package/alert/index.es.js +2 -2
  2. package/alert/index.umd.js +1 -1
  3. package/auto-complete/index.es.js +282 -84
  4. package/auto-complete/index.umd.js +3 -5
  5. package/auto-complete/style.css +1 -1
  6. package/avatar/index.es.js +59 -74
  7. package/avatar/index.umd.js +1 -1
  8. package/badge/index.es.js +2 -2
  9. package/badge/index.umd.js +1 -1
  10. package/button/index.es.js +111 -38
  11. package/button/index.umd.js +15 -15
  12. package/button/style.css +1 -1
  13. package/card/index.es.js +2 -2
  14. package/card/index.umd.js +1 -1
  15. package/checkbox/index.es.js +340 -228
  16. package/checkbox/index.umd.js +1 -1
  17. package/checkbox/style.css +1 -1
  18. package/date-picker/index.es.js +264 -63
  19. package/date-picker/index.umd.js +1 -1
  20. package/date-picker/style.css +1 -1
  21. package/drawer/index.es.js +2 -2
  22. package/drawer/index.umd.js +1 -1
  23. package/dropdown/index.es.js +104 -48
  24. package/dropdown/index.umd.js +1 -1
  25. package/dropdown/style.css +1 -1
  26. package/editable-select/index.es.js +423 -8
  27. package/editable-select/index.umd.js +1 -1
  28. package/editable-select/style.css +1 -1
  29. package/form/index.es.js +304 -184
  30. package/form/index.umd.js +15 -15
  31. package/form/style.css +1 -1
  32. package/fullscreen/index.es.js +2 -2
  33. package/fullscreen/index.umd.js +1 -1
  34. package/grid/index.es.js +8 -6
  35. package/grid/index.umd.js +1 -1
  36. package/icon/index.es.js +109 -13
  37. package/icon/index.umd.js +1 -1
  38. package/icon/style.css +1 -0
  39. package/image-preview/index.es.js +2 -2
  40. package/image-preview/index.umd.js +1 -1
  41. package/input/index.es.js +278 -30
  42. package/input/index.umd.js +1 -1
  43. package/input/style.css +1 -1
  44. package/input-number/index.es.js +272 -199
  45. package/input-number/index.umd.js +1 -1
  46. package/input-number/style.css +1 -1
  47. package/layout/index.es.js +2 -2
  48. package/layout/index.umd.js +1 -1
  49. package/loading/index.es.js +2 -2
  50. package/loading/index.umd.js +1 -1
  51. package/modal/index.es.js +105 -32
  52. package/modal/index.umd.js +1 -1
  53. package/modal/style.css +1 -1
  54. package/notification/index.es.js +105 -32
  55. package/notification/index.umd.js +1 -1
  56. package/notification/style.css +1 -1
  57. package/nuxt/components/CheckboxButton.js +3 -0
  58. package/nuxt/components/Icon.js +1 -0
  59. package/nuxt/components/LABEL_DATA.js +3 -0
  60. package/nuxt/components/Option.js +3 -0
  61. package/nuxt/components/iconProps.js +1 -0
  62. package/nuxt/components/svgIconProps.js +3 -0
  63. package/overlay/index.es.js +2 -2
  64. package/overlay/index.umd.js +1 -1
  65. package/package.json +2 -1
  66. package/pagination/index.es.js +2 -2
  67. package/pagination/index.umd.js +1 -1
  68. package/popover/index.es.js +153 -67
  69. package/popover/index.umd.js +15 -15
  70. package/popover/style.css +1 -1
  71. package/progress/index.es.js +2 -2
  72. package/progress/index.umd.js +2 -2
  73. package/radio/index.es.js +139 -143
  74. package/radio/index.umd.js +1 -1
  75. package/rate/index.es.js +16 -8
  76. package/rate/index.umd.js +1 -1
  77. package/result/index.es.js +108 -12
  78. package/result/index.umd.js +1 -1
  79. package/result/style.css +1 -1
  80. package/search/index.es.js +316 -60
  81. package/search/index.umd.js +16 -16
  82. package/search/style.css +1 -1
  83. package/select/index.es.js +7334 -574
  84. package/select/index.umd.js +27 -1
  85. package/select/style.css +1 -1
  86. package/skeleton/index.es.js +2 -2
  87. package/skeleton/index.umd.js +1 -1
  88. package/slider/index.es.js +2 -2
  89. package/slider/index.umd.js +1 -1
  90. package/splitter/index.es.js +178 -89
  91. package/splitter/index.umd.js +17 -17
  92. package/splitter/style.css +1 -1
  93. package/status/index.es.js +2 -2
  94. package/status/index.umd.js +1 -1
  95. package/style.css +1 -1
  96. package/switch/index.es.js +2 -2
  97. package/switch/index.umd.js +1 -1
  98. package/table/index.es.js +1301 -524
  99. package/table/index.umd.js +18 -18
  100. package/table/style.css +1 -1
  101. package/tabs/index.es.js +114 -72
  102. package/tabs/index.umd.js +1 -1
  103. package/tabs/style.css +1 -1
  104. package/tag/index.es.js +6 -7
  105. package/tag/index.umd.js +1 -1
  106. package/textarea/index.es.js +5545 -11
  107. package/textarea/index.umd.js +35 -1
  108. package/timeline/index.es.js +108 -12
  109. package/timeline/index.umd.js +1 -1
  110. package/timeline/style.css +1 -1
  111. package/tooltip/index.es.js +168 -79
  112. package/tooltip/index.umd.js +15 -15
  113. package/tooltip/style.css +1 -1
  114. package/tree/index.es.js +338 -227
  115. package/tree/index.umd.js +1 -1
  116. package/tree/style.css +1 -1
  117. package/upload/index.es.js +105 -32
  118. package/upload/index.umd.js +1 -1
  119. package/upload/style.css +1 -1
  120. package/vue-devui.es.js +3269 -1742
  121. package/vue-devui.umd.js +29 -23
  122. package/nuxt/components/FormControl.js +0 -3
  123. package/nuxt/components/FormLabel.js +0 -3
package/table/index.es.js CHANGED
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
21
21
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
22
  return value;
23
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, provide, toRef, createTextVNode, getCurrentInstance, reactive, onBeforeMount, onBeforeUnmount } from "vue";
24
+ import { computed, ref, watch, unref, defineComponent, inject, createVNode, toRefs, onMounted, onUnmounted, Teleport, Transition, renderSlot, isVNode, nextTick, mergeProps, Comment, Text, h, Fragment, withDirectives, cloneVNode, provide, vShow, resolveDynamicComponent, render, resolveDirective, toRef, createTextVNode, getCurrentInstance, onBeforeMount, reactive, onBeforeUnmount } from "vue";
25
25
  import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
26
26
  import { onClickOutside } from "@vueuse/core";
27
27
  const TableProps = {
@@ -89,6 +89,20 @@ const TableProps = {
89
89
  borderType: {
90
90
  type: String,
91
91
  default: ""
92
+ },
93
+ empty: {
94
+ type: String,
95
+ default: "No Data"
96
+ },
97
+ showHeader: {
98
+ type: Boolean,
99
+ default: true
100
+ },
101
+ rowKey: {
102
+ type: String
103
+ },
104
+ trackBy: {
105
+ type: Function
92
106
  }
93
107
  };
94
108
  const TABLE_TOKEN = Symbol();
@@ -102,8 +116,8 @@ function createBem(namespace, element, modifier) {
102
116
  }
103
117
  return cls;
104
118
  }
105
- function useNamespace(block) {
106
- const namespace = `devui-${block}`;
119
+ function useNamespace(block, needDot = false) {
120
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
107
121
  const b = () => createBem(namespace);
108
122
  const e = (element) => element ? createBem(namespace, element) : "";
109
123
  const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
@@ -115,29 +129,32 @@ function useNamespace(block) {
115
129
  em
116
130
  };
117
131
  }
118
- function useTable(props) {
119
- const ns = useNamespace("table");
132
+ function useTable(props, tableWidth) {
133
+ const ns2 = useNamespace("table");
120
134
  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)
135
+ [ns2.e("view")]: true,
136
+ [ns2.m("striped")]: props.striped,
137
+ [ns2.m("header-bg")]: props.headerBg,
138
+ [ns2.m("layout-auto")]: props.tableLayout === "auto",
139
+ [ns2.m(`${props.size}`)]: true,
140
+ [ns2.m(`${props.borderType}`)]: Boolean(props.borderType)
127
141
  }));
128
- const style = computed(() => ({
142
+ const styles = computed(() => ({
129
143
  maxHeight: props.maxHeight,
130
144
  maxWidth: props.maxWidth,
131
145
  height: props.tableHeight,
132
- width: props.tableWidth
146
+ width: tableWidth.value ? `${tableWidth.value}px` : props.tableWidth
133
147
  }));
134
- return { classes, style };
148
+ return { classes, styles };
135
149
  }
136
150
  const useFixedColumn = (column) => {
137
- const ns = useNamespace("table");
151
+ const ns2 = useNamespace("table");
138
152
  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)
153
+ [ns2.e("checkable-cell")]: column.value.type === "checkable",
154
+ [ns2.m("sticky-cell")]: Boolean(column.value.fixedLeft) || Boolean(column.value.fixedRight),
155
+ left: Boolean(column.value.fixedLeft),
156
+ right: Boolean(column.value.fixedRight),
157
+ [`is-${column.value.align}`]: true
141
158
  }));
142
159
  const stickyStyle = computed(() => ({
143
160
  left: column.value.fixedLeft,
@@ -145,6 +162,73 @@ const useFixedColumn = (column) => {
145
162
  }));
146
163
  return { stickyClass, stickyStyle };
147
164
  };
165
+ function useTableLayout(table2) {
166
+ const tableWidth = ref();
167
+ const updateColgroupWidth = () => {
168
+ var _a, _b;
169
+ const cols = ((_b = (_a = table2 == null ? void 0 : table2.vnode) == null ? void 0 : _a.el) == null ? void 0 : _b.querySelectorAll("colgroup > col")) || [];
170
+ if (!cols.length) {
171
+ return;
172
+ }
173
+ const flatColumns = table2.store.states.flatColumns;
174
+ const columnMap = {};
175
+ flatColumns.value.forEach((column) => {
176
+ columnMap[column.id] = column;
177
+ });
178
+ for (let i = 0, len = cols.length; i < len; i++) {
179
+ const col = cols[i];
180
+ const columnId = col.getAttribute("column-id");
181
+ const column = columnMap[columnId];
182
+ if (column) {
183
+ col.setAttribute("width", column.realWidth);
184
+ }
185
+ }
186
+ };
187
+ const updateColumnWidth = () => {
188
+ var _a, _b;
189
+ const tableClientWidth = (_b = (_a = table2 == null ? void 0 : table2.vnode) == null ? void 0 : _a.el) == null ? void 0 : _b.clientWidth;
190
+ let tableMinWidth = 0;
191
+ const flatColumns = table2.store.states.flatColumns;
192
+ const flexColumns = flatColumns.value.filter((column) => typeof column.width !== "number");
193
+ if (flexColumns.length) {
194
+ flatColumns.value.forEach((column) => {
195
+ tableMinWidth += Number(column.width || 80);
196
+ });
197
+ if (tableMinWidth <= tableClientWidth) {
198
+ const totalFlexWidth = tableClientWidth - tableMinWidth;
199
+ if (flexColumns.length === 1) {
200
+ flexColumns[0].realWidth = Number(flexColumns[0].width || 80) + totalFlexWidth;
201
+ } else {
202
+ const allFlexColumnWidth = flexColumns.reduce((pre, column) => pre + Number(column.width || 80), 0);
203
+ const flexWidthPercent = totalFlexWidth / allFlexColumnWidth;
204
+ let exceptFistWidth = 0;
205
+ flexColumns.forEach((column, index2) => {
206
+ if (index2 === 0) {
207
+ return;
208
+ }
209
+ const perFlexWidth = Math.floor(Number(column.width || 80) * flexWidthPercent);
210
+ exceptFistWidth += perFlexWidth;
211
+ column.realWidth = Number(column.width || 80) + perFlexWidth;
212
+ });
213
+ flexColumns[0].realWidth = Number(flexColumns[0].width || 80) + totalFlexWidth - exceptFistWidth;
214
+ }
215
+ } else {
216
+ flexColumns.forEach((column) => {
217
+ column.realWidth = Number(column.width || 80);
218
+ });
219
+ }
220
+ tableWidth.value = Math.max(tableMinWidth, tableClientWidth);
221
+ } else {
222
+ flatColumns.value.forEach((column) => {
223
+ column.realWidth = column.width || 80;
224
+ tableMinWidth += Number(column.realWidth);
225
+ });
226
+ tableWidth.value = tableMinWidth;
227
+ }
228
+ updateColgroupWidth();
229
+ };
230
+ return { tableWidth, updateColumnWidth };
231
+ }
148
232
  function replaceColumn(array, column) {
149
233
  return array.map((item) => {
150
234
  var _a;
@@ -171,7 +255,10 @@ const createColumnGenerator = () => {
171
255
  const _columns = ref([]);
172
256
  const flatColumns = ref([]);
173
257
  const sortColumn = () => {
174
- _columns.value.sort((a, b) => a.order - b.order);
258
+ _columns.value.sort((a, b) => {
259
+ var _a, _b;
260
+ return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
261
+ });
175
262
  };
176
263
  const insertColumn = (column, parent) => {
177
264
  const array = unref(_columns);
@@ -201,43 +288,57 @@ const createColumnGenerator = () => {
201
288
  };
202
289
  return { _columns, flatColumns, insertColumn, removeColumn, sortColumn, updateColumns };
203
290
  };
204
- const createSelection = (dataSource, _data) => {
205
- const _checkList = ref([]);
291
+ const createSelection = (dataSource, trackBy) => {
292
+ const _checkSet = ref(/* @__PURE__ */ new Set());
293
+ const checkRow = (toggle, row) => {
294
+ if (toggle) {
295
+ _checkSet.value.add(trackBy(row));
296
+ } else {
297
+ _checkSet.value.delete(trackBy(row));
298
+ }
299
+ };
300
+ const isRowChecked = (row) => {
301
+ return _checkSet.value.has(trackBy(row));
302
+ };
303
+ const getCheckedRows = () => {
304
+ return dataSource.value.filter((item) => isRowChecked(item));
305
+ };
206
306
  const _checkAllRecord = ref(false);
207
307
  const _checkAll = computed({
208
308
  get: () => _checkAllRecord.value,
209
309
  set: (val) => {
210
310
  _checkAllRecord.value = val;
211
- for (let i = 0; i < _checkList.value.length; i++) {
212
- _checkList.value[i] = val;
213
- }
311
+ dataSource.value.forEach((item) => {
312
+ checkRow(val, item);
313
+ });
214
314
  }
215
315
  });
216
316
  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) {
317
+ watch(_checkSet, (set) => {
318
+ if (set.size === 0) {
222
319
  return;
223
320
  }
224
321
  let allTrue = true;
225
322
  let allFalse = true;
226
- for (let i = 0; i < list2.length; i++) {
227
- allTrue && (allTrue = list2[i]);
228
- allFalse && (allFalse = !list2[i]);
323
+ const items = dataSource.value;
324
+ for (let i = 0; i < items.length; i++) {
325
+ const checked = isRowChecked(items[i]);
326
+ allTrue && (allTrue = checked);
327
+ allFalse && (allFalse = !checked);
229
328
  }
230
329
  _checkAllRecord.value = allTrue;
231
330
  _halfChecked.value = !(allFalse || allTrue);
232
331
  }, { immediate: true, deep: true });
233
- const getCheckedRows = () => {
234
- return _data.value.filter((_, index2) => _checkList.value[index2]);
235
- };
332
+ watch(dataSource, (value) => {
333
+ _checkAllRecord.value = value.findIndex((item) => !isRowChecked(item)) === -1;
334
+ });
236
335
  return {
237
- _checkList,
336
+ _checkSet,
238
337
  _checkAll,
239
338
  _halfChecked,
240
- getCheckedRows
339
+ getCheckedRows,
340
+ checkRow,
341
+ isRowChecked
241
342
  };
242
343
  };
243
344
  const createSorter = (dataSource, _data) => {
@@ -259,45 +360,104 @@ const createFixedLogic = (columns) => {
259
360
  });
260
361
  return { isFixedLeft };
261
362
  };
262
- function createStore(dataSource) {
363
+ const createExpandRow = (dataSource, trackBy) => {
364
+ const _expandedRows = ref(/* @__PURE__ */ new Set());
365
+ const isRowExpanded = (row) => {
366
+ return _expandedRows.value.has(trackBy(row));
367
+ };
368
+ const toggleRow = (row) => {
369
+ if (isRowExpanded(row)) {
370
+ _expandedRows.value.delete(trackBy(row));
371
+ } else {
372
+ _expandedRows.value.add(trackBy(row));
373
+ }
374
+ };
375
+ const getExpandedRows = () => {
376
+ return dataSource.value.filter((item) => isRowExpanded(item));
377
+ };
378
+ const expandAllRows = () => {
379
+ dataSource.value.forEach((item) => {
380
+ _expandedRows.value.add(trackBy(item));
381
+ });
382
+ };
383
+ return {
384
+ _expandedRows,
385
+ toggleRow,
386
+ isRowExpanded,
387
+ getExpandedRows,
388
+ expandAllRows
389
+ };
390
+ };
391
+ function createStore(dataSource, table2) {
263
392
  const _data = ref([]);
264
393
  watch(dataSource, (value) => {
265
394
  _data.value = [...value];
266
395
  }, { deep: true, immediate: true });
267
- const { _columns, flatColumns, insertColumn, removeColumn, sortColumn, updateColumns } = createColumnGenerator();
268
- const { _checkAll, _checkList, _halfChecked, getCheckedRows } = createSelection(dataSource, _data);
396
+ const {
397
+ _columns,
398
+ flatColumns,
399
+ insertColumn,
400
+ removeColumn,
401
+ sortColumn,
402
+ updateColumns
403
+ } = createColumnGenerator();
404
+ const {
405
+ _checkAll,
406
+ _checkSet,
407
+ _halfChecked,
408
+ getCheckedRows,
409
+ isRowChecked,
410
+ checkRow
411
+ } = createSelection(_data, table2.props.trackBy);
269
412
  const { sortData, thList } = createSorter(dataSource, _data);
270
413
  const { isFixedLeft } = createFixedLogic(_columns);
414
+ const {
415
+ _expandedRows,
416
+ toggleRow,
417
+ isRowExpanded,
418
+ getExpandedRows,
419
+ expandAllRows
420
+ } = createExpandRow(dataSource, table2.props.trackBy);
271
421
  return {
422
+ _table: table2,
272
423
  states: {
273
424
  _data,
274
425
  _columns,
275
426
  flatColumns,
276
- _checkList,
427
+ _checkSet,
277
428
  _checkAll,
278
429
  _halfChecked,
279
430
  isFixedLeft,
280
- thList
431
+ thList,
432
+ _expandedRows
281
433
  },
282
434
  insertColumn,
283
435
  sortColumn,
284
436
  removeColumn,
285
437
  updateColumns,
286
438
  getCheckedRows,
287
- sortData
439
+ toggleRow,
440
+ isRowExpanded,
441
+ getExpandedRows,
442
+ expandAllRows,
443
+ sortData,
444
+ isRowChecked,
445
+ checkRow
288
446
  };
289
447
  }
290
448
  var ColGroup = defineComponent({
291
449
  name: "DColGroup",
292
450
  setup() {
293
451
  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) => {
452
+ const columns = parent == null ? void 0 : parent.store.states.flatColumns;
453
+ const isFixed = computed(() => (parent == null ? void 0 : parent.props.tableLayout) === "fixed");
454
+ return () => createVNode("colgroup", null, [columns == null ? void 0 : columns.value.map((column, index2) => {
296
455
  return createVNode("col", {
297
456
  "key": index2,
298
- "width": column.realWidth
457
+ "column-id": isFixed.value ? column.id : "",
458
+ "width": column.type === "expand" ? 60 : isFixed.value ? column.realWidth : column.width || ""
299
459
  }, null);
300
- })]) : null;
460
+ })]);
301
461
  }
302
462
  });
303
463
  const sortProps = {
@@ -429,6 +589,7 @@ const dropdownProps = {
429
589
  default: true
430
590
  }
431
591
  };
592
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
432
593
  function getElement(element) {
433
594
  if (element instanceof Element) {
434
595
  return element;
@@ -595,14 +756,14 @@ function _isSlot$1(s) {
595
756
  }
596
757
  const CommonOverlay = defineComponent({
597
758
  setup(props, ctx) {
598
- const ns = useNamespace("overlay");
759
+ const ns2 = useNamespace("overlay");
599
760
  return () => {
600
761
  let _slot;
601
762
  return createVNode(Teleport, {
602
763
  "to": "#d-overlay-anchor"
603
764
  }, {
604
765
  default: () => [createVNode(Transition, {
605
- "name": ns.e("fade")
766
+ "name": ns2.e("fade")
606
767
  }, _isSlot$1(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
607
768
  default: () => [_slot]
608
769
  })]
@@ -645,12 +806,12 @@ const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
645
806
  });
646
807
  const overlayEmits = ["update:visible", "backdropClick"];
647
808
  function useOverlayLogic(props, ctx) {
648
- const ns = useNamespace("overlay");
809
+ const ns2 = useNamespace("overlay");
649
810
  const backgroundClass = computed(() => {
650
- return [ns.e("background"), props.backgroundClass, !props.hasBackdrop ? ns.em("background", "disabled") : ns.em("background", "color")];
811
+ return [ns2.e("background"), props.backgroundClass, !props.hasBackdrop ? ns2.em("background", "disabled") : ns2.em("background", "color")];
651
812
  });
652
813
  const overlayClass = computed(() => {
653
- return ns.b();
814
+ return ns2.b();
654
815
  });
655
816
  const handleBackdropClick = (event) => {
656
817
  var _a;
@@ -860,7 +1021,7 @@ const FlexibleOverlay = defineComponent({
860
1021
  emit,
861
1022
  expose
862
1023
  }) {
863
- const ns = useNamespace("flexible-overlay");
1024
+ const ns2 = useNamespace("flexible-overlay");
864
1025
  const {
865
1026
  arrowRef,
866
1027
  overlayRef,
@@ -873,14 +1034,70 @@ const FlexibleOverlay = defineComponent({
873
1034
  var _a;
874
1035
  return props.modelValue && createVNode("div", mergeProps({
875
1036
  "ref": overlayRef,
876
- "class": ns.b()
1037
+ "class": ns2.b()
877
1038
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
878
1039
  "ref": arrowRef,
879
- "class": ns.e("arrow")
1040
+ "class": ns2.e("arrow")
880
1041
  }, null)]);
881
1042
  };
882
1043
  }
883
1044
  });
1045
+ const inBrowser = typeof window !== "undefined";
1046
+ const isObject = (val) => val !== null && typeof val === "object";
1047
+ const ns = useNamespace("popper-trigger");
1048
+ function wrapContent(content) {
1049
+ return h("span", { class: ns.b() }, content);
1050
+ }
1051
+ function getFirstValidChild(nodes) {
1052
+ for (const child of nodes) {
1053
+ if (isObject(child)) {
1054
+ if (child.type === Comment) {
1055
+ continue;
1056
+ }
1057
+ if (child.type === "svg" || child.type === Text) {
1058
+ return wrapContent(child);
1059
+ }
1060
+ if (child.type === Fragment) {
1061
+ return getFirstValidChild(child.children);
1062
+ }
1063
+ return child;
1064
+ }
1065
+ return wrapContent(child);
1066
+ }
1067
+ return null;
1068
+ }
1069
+ var PopperTrigger = defineComponent({
1070
+ name: "DPopperTrigger",
1071
+ setup(_, ctx) {
1072
+ const {
1073
+ slots,
1074
+ attrs
1075
+ } = ctx;
1076
+ return () => {
1077
+ var _a;
1078
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
1079
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
1080
+ if (!defaultSlot) {
1081
+ return null;
1082
+ }
1083
+ const firstValidChild = getFirstValidChild(defaultSlot);
1084
+ if (!firstValidChild) {
1085
+ return null;
1086
+ }
1087
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
1088
+ mounted(el) {
1089
+ triggerRef.value = el;
1090
+ },
1091
+ updated(el) {
1092
+ triggerRef.value = el;
1093
+ },
1094
+ unmounted() {
1095
+ triggerRef.value = null;
1096
+ }
1097
+ }]]);
1098
+ };
1099
+ }
1100
+ });
884
1101
  var dropdown = "";
885
1102
  let dropdownId = 1;
886
1103
  var Dropdown = defineComponent({
@@ -909,7 +1126,8 @@ var Dropdown = defineComponent({
909
1126
  const id = `dropdown_${dropdownId++}`;
910
1127
  const isOpen = ref(false);
911
1128
  const currentPosition = ref("bottom");
912
- const ns = useNamespace("dropdown");
1129
+ const ns2 = useNamespace("dropdown");
1130
+ provide(POPPER_TRIGGER_TOKEN, origin);
913
1131
  useDropdownEvent({
914
1132
  id,
915
1133
  isOpen,
@@ -936,41 +1154,40 @@ var Dropdown = defineComponent({
936
1154
  expose({
937
1155
  updatePosition: () => overlayRef.value.updatePosition()
938
1156
  });
939
- return () => {
940
- var _a;
941
- return createVNode(Fragment, null, [createVNode("div", {
942
- "ref": origin,
943
- "class": ns.e("toggle")
944
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
945
- "to": "body"
1157
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
1158
+ default: () => {
1159
+ var _a;
1160
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
1161
+ }
1162
+ }), createVNode(Teleport, {
1163
+ "to": "body"
1164
+ }, {
1165
+ default: () => [createVNode(Transition, {
1166
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
946
1167
  }, {
947
- default: () => [createVNode(Transition, {
948
- "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
1168
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
1169
+ "modelValue": overlayModelValue.value,
1170
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
1171
+ "ref": overlayRef,
1172
+ "origin": origin.value,
1173
+ "position": position.value,
1174
+ "align": align.value,
1175
+ "offset": offset2.value,
1176
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
1177
+ "onPositionChange": handlePositionChange,
1178
+ "class": classes.value,
1179
+ "style": styles.value
949
1180
  }, {
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": ns.e("menu-wrap")
968
- }, attrs), [(_a2 = slots.menu) == null ? void 0 : _a2.call(slots)])];
969
- }
970
- }), [[vShow, overlayShowValue.value]])]
971
- })]
972
- })]);
973
- };
1181
+ default: () => {
1182
+ var _a;
1183
+ return [createVNode("div", mergeProps({
1184
+ "ref": dropdownRef,
1185
+ "class": ns2.e("menu-wrap")
1186
+ }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
1187
+ }
1188
+ }), [[vShow, overlayShowValue.value]])]
1189
+ })]
1190
+ })]);
974
1191
  }
975
1192
  });
976
1193
  const dropdownMenuProps = {
@@ -1028,7 +1245,7 @@ defineComponent({
1028
1245
  overlayClass
1029
1246
  } = toRefs(props);
1030
1247
  const dropdownMenuRef = ref(null);
1031
- const ns = useNamespace("dropdown");
1248
+ const ns2 = useNamespace("dropdown");
1032
1249
  onClickOutside(dropdownMenuRef, (value) => {
1033
1250
  var _a, _b;
1034
1251
  if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
@@ -1046,7 +1263,7 @@ defineComponent({
1046
1263
  "to": "body"
1047
1264
  }, {
1048
1265
  default: () => [createVNode(Transition, {
1049
- "name": showAnimation.value ? `devui-dropdown-fade-${currentPosition.value}` : ""
1266
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
1050
1267
  }, {
1051
1268
  default: () => [createVNode(FlexibleOverlay, {
1052
1269
  "modelValue": modelValue.value,
@@ -1063,7 +1280,7 @@ defineComponent({
1063
1280
  var _a;
1064
1281
  return [createVNode("div", mergeProps({
1065
1282
  "ref": dropdownMenuRef,
1066
- "class": ns.e("menu-wrap")
1283
+ "class": ns2.e("menu-wrap")
1067
1284
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
1068
1285
  }
1069
1286
  })]
@@ -1071,6 +1288,10 @@ defineComponent({
1071
1288
  });
1072
1289
  }
1073
1290
  });
1291
+ function isUrl(value) {
1292
+ return /^((http|https):)?\/\//.test(value);
1293
+ }
1294
+ const DEFAULT_PREFIX = "icon";
1074
1295
  const iconProps = {
1075
1296
  name: {
1076
1297
  type: String,
@@ -1078,43 +1299,112 @@ const iconProps = {
1078
1299
  required: true
1079
1300
  },
1080
1301
  size: {
1081
- type: String,
1302
+ type: [Number, String],
1082
1303
  default: "inherit"
1083
1304
  },
1084
1305
  color: {
1085
1306
  type: String,
1086
1307
  default: "inherit"
1087
1308
  },
1309
+ component: {
1310
+ type: Object,
1311
+ default: null
1312
+ },
1088
1313
  classPrefix: {
1089
1314
  type: String,
1090
- default: "icon"
1315
+ default: DEFAULT_PREFIX
1316
+ }
1317
+ };
1318
+ const svgIconProps = {
1319
+ name: {
1320
+ type: String,
1321
+ default: "",
1322
+ required: true
1323
+ },
1324
+ color: {
1325
+ type: String,
1326
+ default: "inherit"
1327
+ },
1328
+ size: {
1329
+ type: [Number, String],
1330
+ default: "inherit"
1091
1331
  }
1092
1332
  };
1333
+ var icon = "";
1334
+ var svgIcon = defineComponent({
1335
+ name: "DSvgIcon",
1336
+ props: svgIconProps,
1337
+ setup(props) {
1338
+ const {
1339
+ name,
1340
+ color,
1341
+ size
1342
+ } = toRefs(props);
1343
+ const ns2 = useNamespace("svg-icon");
1344
+ const iconName = computed(() => `#icon-${name.value}`);
1345
+ const iconSize = computed(() => {
1346
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
1347
+ });
1348
+ const styles = {
1349
+ width: iconSize.value,
1350
+ height: iconSize.value
1351
+ };
1352
+ return () => {
1353
+ return createVNode("svg", {
1354
+ "class": ns2.b(),
1355
+ "style": styles
1356
+ }, [createVNode("use", {
1357
+ "xlink:href": iconName.value,
1358
+ "fill": color.value
1359
+ }, null)]);
1360
+ };
1361
+ }
1362
+ });
1093
1363
  var Icon = defineComponent({
1094
1364
  name: "DIcon",
1095
1365
  props: iconProps,
1096
- setup(props) {
1366
+ setup(props, {
1367
+ attrs
1368
+ }) {
1097
1369
  const {
1370
+ component,
1098
1371
  name,
1099
1372
  size,
1100
1373
  color,
1101
1374
  classPrefix
1102
1375
  } = toRefs(props);
1103
- return () => {
1104
- return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
1376
+ const IconComponent = component.value ? resolveDynamicComponent(component.value) : resolveDynamicComponent(svgIcon);
1377
+ const iconSize = computed(() => {
1378
+ return typeof size.value === "number" ? `${size.value}px` : size.value;
1379
+ });
1380
+ const svgIconDom = () => {
1381
+ return createVNode(IconComponent, mergeProps({
1382
+ "name": name.value,
1383
+ "color": color.value,
1384
+ "size": iconSize.value
1385
+ }, attrs), null);
1386
+ };
1387
+ const imgIconDom = () => {
1388
+ return createVNode("img", mergeProps({
1105
1389
  "src": name.value,
1106
1390
  "alt": name.value.split("/")[name.value.split("/").length - 1],
1107
1391
  "style": {
1108
- width: size.value,
1109
- verticalAlign: "text-bottom"
1392
+ width: iconSize.value || ""
1110
1393
  }
1111
- }, null) : createVNode("i", {
1112
- "class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
1394
+ }, attrs), null);
1395
+ };
1396
+ const fontIconDom = () => {
1397
+ const fontIconClass = /^icon-/.test(name.value) ? name.value : `${classPrefix.value}-${name.value}`;
1398
+ return createVNode("i", mergeProps({
1399
+ "class": [classPrefix.value, fontIconClass],
1113
1400
  "style": {
1114
- fontSize: size.value,
1401
+ fontSize: iconSize.value,
1115
1402
  color: color.value
1116
1403
  }
1117
- }, null);
1404
+ }, attrs), null);
1405
+ };
1406
+ return () => {
1407
+ return component.value ? svgIconDom() : isUrl(name.value) ? imgIconDom() : fontIconDom();
1118
1408
  };
1119
1409
  }
1120
1410
  });
@@ -1186,28 +1476,28 @@ var Loading = defineComponent({
1186
1476
  message,
1187
1477
  $slots
1188
1478
  } = this;
1189
- const ns = useNamespace("loading");
1479
+ const ns2 = useNamespace("loading");
1190
1480
  return isShow && createVNode("div", {
1191
- "class": [ns.b(), isFull ? ns.m("full") : ""]
1481
+ "class": [ns2.b(), isFull ? ns2.m("full") : ""]
1192
1482
  }, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
1193
- "class": ns.e("wrapper")
1483
+ "class": ns2.e("wrapper")
1194
1484
  }, [backdrop ? createVNode("div", {
1195
- "class": ns.e("mask")
1485
+ "class": ns2.e("mask")
1196
1486
  }, null) : null, createVNode("div", {
1197
1487
  "style": style,
1198
- "class": ns.e("area")
1488
+ "class": ns2.e("area")
1199
1489
  }, [createVNode("div", {
1200
- "class": ns.e("busy-default-spinner")
1490
+ "class": ns2.e("busy-default-spinner")
1201
1491
  }, [createVNode("div", {
1202
- "class": ns.e("bar1")
1492
+ "class": ns2.e("bar1")
1203
1493
  }, null), createVNode("div", {
1204
- "class": ns.e("bar2")
1494
+ "class": ns2.e("bar2")
1205
1495
  }, null), createVNode("div", {
1206
- "class": ns.e("bar3")
1496
+ "class": ns2.e("bar3")
1207
1497
  }, null), createVNode("div", {
1208
- "class": ns.e("bar4")
1498
+ "class": ns2.e("bar4")
1209
1499
  }, null)]), message ? createVNode("span", {
1210
- "class": ns.e("text")
1500
+ "class": ns2.e("text")
1211
1501
  }, [message]) : null])])]);
1212
1502
  }
1213
1503
  });
@@ -2100,7 +2390,7 @@ var lodash = { exports: {} };
2100
2390
  function object() {
2101
2391
  }
2102
2392
  return function(proto) {
2103
- if (!isObject(proto)) {
2393
+ if (!isObject2(proto)) {
2104
2394
  return {};
2105
2395
  }
2106
2396
  if (objectCreate) {
@@ -2462,7 +2752,7 @@ var lodash = { exports: {} };
2462
2752
  if (result2 !== undefined$1) {
2463
2753
  return result2;
2464
2754
  }
2465
- if (!isObject(value)) {
2755
+ if (!isObject2(value)) {
2466
2756
  return value;
2467
2757
  }
2468
2758
  var isArr = isArray(value);
@@ -2809,7 +3099,7 @@ var lodash = { exports: {} };
2809
3099
  return true;
2810
3100
  }
2811
3101
  function baseIsNative(value) {
2812
- if (!isObject(value) || isMasked(value)) {
3102
+ if (!isObject2(value) || isMasked(value)) {
2813
3103
  return false;
2814
3104
  }
2815
3105
  var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
@@ -2849,7 +3139,7 @@ var lodash = { exports: {} };
2849
3139
  return result2;
2850
3140
  }
2851
3141
  function baseKeysIn(object) {
2852
- if (!isObject(object)) {
3142
+ if (!isObject2(object)) {
2853
3143
  return nativeKeysIn(object);
2854
3144
  }
2855
3145
  var isProto = isPrototype(object), result2 = [];
@@ -2894,7 +3184,7 @@ var lodash = { exports: {} };
2894
3184
  }
2895
3185
  baseFor(source, function(srcValue, key) {
2896
3186
  stack || (stack = new Stack());
2897
- if (isObject(srcValue)) {
3187
+ if (isObject2(srcValue)) {
2898
3188
  baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
2899
3189
  } else {
2900
3190
  var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : undefined$1;
@@ -2934,7 +3224,7 @@ var lodash = { exports: {} };
2934
3224
  newValue = objValue;
2935
3225
  if (isArguments(objValue)) {
2936
3226
  newValue = toPlainObject(objValue);
2937
- } else if (!isObject(objValue) || isFunction(objValue)) {
3227
+ } else if (!isObject2(objValue) || isFunction(objValue)) {
2938
3228
  newValue = initCloneObject(srcValue);
2939
3229
  }
2940
3230
  } else {
@@ -3073,7 +3363,7 @@ var lodash = { exports: {} };
3073
3363
  return shuffleSelf(array, baseClamp(n, 0, array.length));
3074
3364
  }
3075
3365
  function baseSet(object, path, value, customizer) {
3076
- if (!isObject(object)) {
3366
+ if (!isObject2(object)) {
3077
3367
  return object;
3078
3368
  }
3079
3369
  path = castPath(path, object);
@@ -3087,7 +3377,7 @@ var lodash = { exports: {} };
3087
3377
  var objValue = nested[key];
3088
3378
  newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
3089
3379
  if (newValue === undefined$1) {
3090
- newValue = isObject(objValue) ? objValue : isIndex(path[index2 + 1]) ? [] : {};
3380
+ newValue = isObject2(objValue) ? objValue : isIndex(path[index2 + 1]) ? [] : {};
3091
3381
  }
3092
3382
  }
3093
3383
  assignValue(nested, key, newValue);
@@ -3318,7 +3608,7 @@ var lodash = { exports: {} };
3318
3608
  end = end === undefined$1 ? length : end;
3319
3609
  return !start && end >= length ? array : baseSlice(array, start, end);
3320
3610
  }
3321
- var clearTimeout = ctxClearTimeout || function(id) {
3611
+ var clearTimeout2 = ctxClearTimeout || function(id) {
3322
3612
  return root.clearTimeout(id);
3323
3613
  };
3324
3614
  function cloneBuffer(buffer, isDeep) {
@@ -3537,7 +3827,7 @@ var lodash = { exports: {} };
3537
3827
  return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
3538
3828
  }
3539
3829
  var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
3540
- return isObject(result2) ? result2 : thisBinding;
3830
+ return isObject2(result2) ? result2 : thisBinding;
3541
3831
  };
3542
3832
  }
3543
3833
  function createCurry(func, bitmask, arity) {
@@ -3851,7 +4141,7 @@ var lodash = { exports: {} };
3851
4141
  return objValue;
3852
4142
  }
3853
4143
  function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
3854
- if (isObject(objValue) && isObject(srcValue)) {
4144
+ if (isObject2(objValue) && isObject2(srcValue)) {
3855
4145
  stack.set(srcValue, objValue);
3856
4146
  baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
3857
4147
  stack["delete"](srcValue);
@@ -4199,7 +4489,7 @@ var lodash = { exports: {} };
4199
4489
  return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
4200
4490
  }
4201
4491
  function isIterateeCall(value, index2, object) {
4202
- if (!isObject(object)) {
4492
+ if (!isObject2(object)) {
4203
4493
  return false;
4204
4494
  }
4205
4495
  var type = typeof index2;
@@ -4242,7 +4532,7 @@ var lodash = { exports: {} };
4242
4532
  return value === proto;
4243
4533
  }
4244
4534
  function isStrictComparable(value) {
4245
- return value === value && !isObject(value);
4535
+ return value === value && !isObject2(value);
4246
4536
  }
4247
4537
  function matchesStrictComparable(key, srcValue) {
4248
4538
  return function(object) {
@@ -5124,7 +5414,7 @@ var lodash = { exports: {} };
5124
5414
  throw new TypeError2(FUNC_ERROR_TEXT);
5125
5415
  }
5126
5416
  wait = toNumber(wait) || 0;
5127
- if (isObject(options)) {
5417
+ if (isObject2(options)) {
5128
5418
  leading = !!options.leading;
5129
5419
  maxing = "maxWait" in options;
5130
5420
  maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
@@ -5167,7 +5457,7 @@ var lodash = { exports: {} };
5167
5457
  }
5168
5458
  function cancel() {
5169
5459
  if (timerId !== undefined$1) {
5170
- clearTimeout(timerId);
5460
+ clearTimeout2(timerId);
5171
5461
  }
5172
5462
  lastInvokeTime = 0;
5173
5463
  lastArgs = lastCallTime = lastThis = timerId = undefined$1;
@@ -5185,7 +5475,7 @@ var lodash = { exports: {} };
5185
5475
  return leadingEdge(lastCallTime);
5186
5476
  }
5187
5477
  if (maxing) {
5188
- clearTimeout(timerId);
5478
+ clearTimeout2(timerId);
5189
5479
  timerId = setTimeout2(timerExpired, wait);
5190
5480
  return invokeFunc(lastCallTime);
5191
5481
  }
@@ -5294,7 +5584,7 @@ var lodash = { exports: {} };
5294
5584
  if (typeof func != "function") {
5295
5585
  throw new TypeError2(FUNC_ERROR_TEXT);
5296
5586
  }
5297
- if (isObject(options)) {
5587
+ if (isObject2(options)) {
5298
5588
  leading = "leading" in options ? !!options.leading : leading;
5299
5589
  trailing = "trailing" in options ? !!options.trailing : trailing;
5300
5590
  }
@@ -5402,7 +5692,7 @@ var lodash = { exports: {} };
5402
5692
  return typeof value == "number" && nativeIsFinite(value);
5403
5693
  }
5404
5694
  function isFunction(value) {
5405
- if (!isObject(value)) {
5695
+ if (!isObject2(value)) {
5406
5696
  return false;
5407
5697
  }
5408
5698
  var tag = baseGetTag(value);
@@ -5414,7 +5704,7 @@ var lodash = { exports: {} };
5414
5704
  function isLength(value) {
5415
5705
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
5416
5706
  }
5417
- function isObject(value) {
5707
+ function isObject2(value) {
5418
5708
  var type = typeof value;
5419
5709
  return value != null && (type == "object" || type == "function");
5420
5710
  }
@@ -5521,9 +5811,9 @@ var lodash = { exports: {} };
5521
5811
  if (isSymbol(value)) {
5522
5812
  return NAN;
5523
5813
  }
5524
- if (isObject(value)) {
5814
+ if (isObject2(value)) {
5525
5815
  var other = typeof value.valueOf == "function" ? value.valueOf() : value;
5526
- value = isObject(other) ? other + "" : other;
5816
+ value = isObject2(other) ? other + "" : other;
5527
5817
  }
5528
5818
  if (typeof value != "string") {
5529
5819
  return value === 0 ? value : +value;
@@ -5744,7 +6034,7 @@ var lodash = { exports: {} };
5744
6034
  var Ctor = object && object.constructor;
5745
6035
  if (isArrLike) {
5746
6036
  accumulator = isArr ? new Ctor() : [];
5747
- } else if (isObject(object)) {
6037
+ } else if (isObject2(object)) {
5748
6038
  accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
5749
6039
  } else {
5750
6040
  accumulator = {};
@@ -6026,7 +6316,7 @@ var lodash = { exports: {} };
6026
6316
  }
6027
6317
  function truncate(string, options) {
6028
6318
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
6029
- if (isObject(options)) {
6319
+ if (isObject2(options)) {
6030
6320
  var separator = "separator" in options ? options.separator : separator;
6031
6321
  length = "length" in options ? toInteger(options.length) : length;
6032
6322
  omission = "omission" in options ? baseToString(options.omission) : omission;
@@ -6156,13 +6446,13 @@ var lodash = { exports: {} };
6156
6446
  });
6157
6447
  function mixin(object, source, options) {
6158
6448
  var props = keys(source), methodNames = baseFunctions(source, props);
6159
- if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
6449
+ if (options == null && !(isObject2(source) && (methodNames.length || !props.length))) {
6160
6450
  options = source;
6161
6451
  source = object;
6162
6452
  object = this;
6163
6453
  methodNames = baseFunctions(source, keys(source));
6164
6454
  }
6165
- var chain2 = !(isObject(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object);
6455
+ var chain2 = !(isObject2(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object);
6166
6456
  arrayEach(methodNames, function(methodName) {
6167
6457
  var func = source[methodName];
6168
6458
  object[methodName] = func;
@@ -6508,7 +6798,7 @@ var lodash = { exports: {} };
6508
6798
  lodash2.isNil = isNil;
6509
6799
  lodash2.isNull = isNull;
6510
6800
  lodash2.isNumber = isNumber;
6511
- lodash2.isObject = isObject;
6801
+ lodash2.isObject = isObject2;
6512
6802
  lodash2.isObjectLike = isObjectLike;
6513
6803
  lodash2.isPlainObject = isPlainObject;
6514
6804
  lodash2.isRegExp = isRegExp;
@@ -6771,7 +7061,7 @@ var lodash = { exports: {} };
6771
7061
  }).call(commonjsGlobal);
6772
7062
  })(lodash, lodash.exports);
6773
7063
  function useButton(props, ctx) {
6774
- const ns = useNamespace("button");
7064
+ const ns2 = useNamespace("button");
6775
7065
  const hasContent = computed(() => ctx.slots.default);
6776
7066
  const colorMap = {
6777
7067
  solid: "primary",
@@ -6784,20 +7074,20 @@ function useButton(props, ctx) {
6784
7074
  return (buttonGroupConf == null ? void 0 : buttonGroupConf.size.value) || props.size;
6785
7075
  });
6786
7076
  const classes = computed(() => ({
6787
- [ns.b()]: true,
6788
- [ns.m(props.variant)]: true,
6789
- [`${ns.m(props.variant)}--${props.color || defaultColor}`]: true,
6790
- [ns.m(buttonSize.value)]: true,
6791
- [ns.e("icon-wrap")]: props.icon,
6792
- [ns.e("icon")]: props.icon && !hasContent.value,
6793
- [ns.m("is-loading")]: props.loading,
6794
- [ns.m(props.shape || "")]: props.shape && lodash.exports.isString(props.shape) ? true : false
7077
+ [ns2.b()]: true,
7078
+ [ns2.m(props.variant)]: true,
7079
+ [`${ns2.m(props.variant)}--${props.color || defaultColor}`]: true,
7080
+ [ns2.m(buttonSize.value)]: true,
7081
+ [ns2.e("icon-wrap")]: props.icon,
7082
+ [ns2.e("icon")]: props.icon && !hasContent.value,
7083
+ [ns2.m("is-loading")]: props.loading,
7084
+ [ns2.m(props.shape || "")]: props.shape && lodash.exports.isString(props.shape) ? true : false
6795
7085
  }));
6796
7086
  const iconClass = computed(() => {
6797
7087
  if (!props.icon) {
6798
7088
  return "";
6799
7089
  }
6800
- const origin = `${ns.e("icon-fix")} icon`;
7090
+ const origin = `${ns2.e("icon-fix")} icon`;
6801
7091
  if (hasContent.value) {
6802
7092
  return `${origin} clear-right-5`;
6803
7093
  } else {
@@ -6816,7 +7106,7 @@ var Button = defineComponent({
6816
7106
  emits: ["click"],
6817
7107
  setup(props, ctx) {
6818
7108
  const {
6819
- icon,
7109
+ icon: icon2,
6820
7110
  disabled,
6821
7111
  loading: loading2
6822
7112
  } = toRefs(props);
@@ -6836,8 +7126,8 @@ var Button = defineComponent({
6836
7126
  "class": classes.value,
6837
7127
  "disabled": disabled.value,
6838
7128
  "onClick": onClick
6839
- }, [icon.value && createVNode(Icon, {
6840
- "name": icon.value,
7129
+ }, [icon2.value && createVNode(Icon, {
7130
+ "name": icon2.value,
6841
7131
  "size": "var(--devui-font-size, 12px)",
6842
7132
  "color": "",
6843
7133
  "class": iconClass.value
@@ -6854,13 +7144,13 @@ defineComponent({
6854
7144
  setup(props, {
6855
7145
  slots
6856
7146
  }) {
6857
- const ns = useNamespace("button-group");
7147
+ const ns2 = useNamespace("button-group");
6858
7148
  provide(buttonGroupInjectionKey, {
6859
7149
  size: toRef(props, "size")
6860
7150
  });
6861
7151
  return () => {
6862
7152
  return createVNode("div", {
6863
- "class": ns.b()
7153
+ "class": ns2.b()
6864
7154
  }, [slots.default && slots.default()]);
6865
7155
  };
6866
7156
  }
@@ -6896,6 +7186,10 @@ const commonProps = {
6896
7186
  beforeChange: {
6897
7187
  type: Function,
6898
7188
  default: void 0
7189
+ },
7190
+ size: {
7191
+ type: String,
7192
+ default: "md"
6899
7193
  }
6900
7194
  };
6901
7195
  const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
@@ -6904,11 +7198,11 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
6904
7198
  default: false
6905
7199
  },
6906
7200
  value: {
6907
- type: String
7201
+ type: [Number, String]
6908
7202
  },
6909
7203
  label: {
6910
7204
  type: String,
6911
- default: void 0
7205
+ default: ""
6912
7206
  },
6913
7207
  "onUpdate:checked": {
6914
7208
  type: Function,
@@ -6923,6 +7217,10 @@ const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
6923
7217
  },
6924
7218
  "onUpdate:modelValue": {
6925
7219
  type: Function
7220
+ },
7221
+ border: {
7222
+ type: Boolean,
7223
+ default: false
6926
7224
  }
6927
7225
  });
6928
7226
  const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
@@ -6949,163 +7247,261 @@ const checkboxGroupProps = __spreadProps(__spreadValues({}, commonProps), {
6949
7247
  "onUpdate:modelValue": {
6950
7248
  type: Function,
6951
7249
  default: void 0
7250
+ },
7251
+ border: {
7252
+ type: Boolean,
7253
+ default: false
7254
+ },
7255
+ max: {
7256
+ type: Number,
7257
+ default: void 0
7258
+ },
7259
+ textColor: {
7260
+ type: String,
7261
+ default: ""
6952
7262
  }
6953
7263
  });
6954
7264
  const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
7265
+ function useCheckbox(props, ctx) {
7266
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
7267
+ const isChecked = computed(() => props.checked || props.modelValue);
7268
+ const mergedChecked = computed(() => {
7269
+ var _a, _b;
7270
+ return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
7271
+ });
7272
+ const isLimitDisabled = computed(() => {
7273
+ const max = checkboxGroupConf == null ? void 0 : checkboxGroupConf.max.value;
7274
+ return !!max && (checkboxGroupConf == null ? void 0 : checkboxGroupConf.modelValue.value.length) >= max && !mergedChecked.value;
7275
+ });
7276
+ const mergedDisabled = computed(() => {
7277
+ return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled || isLimitDisabled.value;
7278
+ });
7279
+ const mergedIsShowTitle = computed(() => {
7280
+ var _a;
7281
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
7282
+ });
7283
+ const mergedShowAnimation = computed(() => {
7284
+ var _a;
7285
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
7286
+ });
7287
+ const mergedColor = computed(() => {
7288
+ var _a;
7289
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
7290
+ });
7291
+ const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
7292
+ const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
7293
+ const canChange = (checked, val) => {
7294
+ var _a;
7295
+ if (mergedDisabled.value) {
7296
+ return Promise.resolve(false);
7297
+ }
7298
+ const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
7299
+ if (beforeChange) {
7300
+ const res = beforeChange(checked, val);
7301
+ if (typeof res === "boolean") {
7302
+ return Promise.resolve(res);
7303
+ }
7304
+ return res;
7305
+ }
7306
+ return Promise.resolve(true);
7307
+ };
7308
+ const toggle = () => {
7309
+ const current = !isChecked.value;
7310
+ checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
7311
+ ctx.emit("update:checked", current);
7312
+ ctx.emit("update:modelValue", current);
7313
+ ctx.emit("change", current);
7314
+ };
7315
+ const handleClick = () => {
7316
+ canChange(!isChecked.value, props.label).then((res) => res && toggle());
7317
+ };
7318
+ const size = computed(() => {
7319
+ var _a;
7320
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.size.value) != null ? _a : props.size;
7321
+ });
7322
+ const border = computed(() => {
7323
+ var _a;
7324
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.border.value) != null ? _a : props.border;
7325
+ });
7326
+ return {
7327
+ mergedChecked,
7328
+ mergedDisabled,
7329
+ mergedIsShowTitle,
7330
+ mergedShowAnimation,
7331
+ mergedColor,
7332
+ itemWidth,
7333
+ direction,
7334
+ handleClick,
7335
+ size,
7336
+ border
7337
+ };
7338
+ }
7339
+ function useCheckboxGroup(props, ctx) {
7340
+ const valList = toRef(props, "modelValue");
7341
+ const defaultOpt = {
7342
+ checked: false,
7343
+ isShowTitle: true,
7344
+ halfChecked: false,
7345
+ showAnimation: true,
7346
+ disabled: false
7347
+ };
7348
+ const toggleGroupVal = (val) => {
7349
+ let index2 = -1;
7350
+ if (["string", "number"].includes(typeof valList.value[0])) {
7351
+ index2 = valList.value.findIndex((item) => item === val);
7352
+ } else if (typeof valList.value[0] === "object") {
7353
+ index2 = valList.value.findIndex((item) => item.value === val);
7354
+ }
7355
+ if (index2 === -1) {
7356
+ if (typeof props.options[0] === "object") {
7357
+ const newOne = props.options.find((item) => item.value === val);
7358
+ const res2 = [...valList.value, newOne];
7359
+ ctx.emit("update:modelValue", res2);
7360
+ ctx.emit("change", res2);
7361
+ return;
7362
+ }
7363
+ const res = [...valList.value, val];
7364
+ ctx.emit("update:modelValue", res);
7365
+ ctx.emit("change", res);
7366
+ return;
7367
+ }
7368
+ valList.value.splice(index2, 1);
7369
+ ctx.emit("update:modelValue", valList.value);
7370
+ ctx.emit("change", valList.value);
7371
+ };
7372
+ const isItemChecked = (itemVal) => {
7373
+ if (["string", "number"].includes(typeof valList.value[0])) {
7374
+ return valList.value.includes(itemVal);
7375
+ } else if (typeof valList.value[0] === "object") {
7376
+ return valList.value.some((item) => item.value === itemVal);
7377
+ }
7378
+ };
7379
+ provide(checkboxGroupInjectionKey, {
7380
+ disabled: toRef(props, "disabled"),
7381
+ isShowTitle: toRef(props, "isShowTitle"),
7382
+ color: toRef(props, "color"),
7383
+ showAnimation: toRef(props, "showAnimation"),
7384
+ beforeChange: props.beforeChange,
7385
+ isItemChecked,
7386
+ toggleGroupVal,
7387
+ itemWidth: toRef(props, "itemWidth"),
7388
+ direction: toRef(props, "direction"),
7389
+ size: toRef(props, "size"),
7390
+ border: toRef(props, "border"),
7391
+ max: toRef(props, "max"),
7392
+ modelValue: toRef(props, "modelValue"),
7393
+ textColor: toRef(props, "textColor")
7394
+ });
7395
+ return { defaultOpt };
7396
+ }
7397
+ function useCheckboxButton() {
7398
+ const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
7399
+ const mergedTextColor = computed(() => {
7400
+ var _a;
7401
+ return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.textColor.value) != null ? _a : void 0;
7402
+ });
7403
+ return {
7404
+ mergedTextColor
7405
+ };
7406
+ }
6955
7407
  var checkbox = "";
6956
7408
  var Checkbox = defineComponent({
6957
7409
  name: "DCheckbox",
6958
7410
  props: checkboxProps,
6959
7411
  emits: ["change", "update:checked", "update:modelValue"],
6960
7412
  setup(props, ctx) {
6961
- const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
6962
- const ns = useNamespace("checkbox");
6963
- const isChecked = computed(() => props.checked || props.modelValue);
6964
- const mergedDisabled = computed(() => {
6965
- return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
6966
- });
6967
- const mergedChecked = computed(() => {
6968
- var _a, _b;
6969
- return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
6970
- });
6971
- const mergedIsShowTitle = computed(() => {
6972
- var _a;
6973
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
6974
- });
6975
- const mergedShowAnimation = computed(() => {
6976
- var _a;
6977
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
6978
- });
6979
- const mergedColor = computed(() => {
6980
- var _a;
6981
- return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
6982
- });
6983
- const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
6984
- const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
6985
- const canChange = (checked, val) => {
6986
- var _a;
6987
- if (mergedDisabled.value) {
6988
- return Promise.resolve(false);
6989
- }
6990
- const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
6991
- if (beforeChange) {
6992
- const res = beforeChange(checked, val);
6993
- if (typeof res === "boolean") {
6994
- return Promise.resolve(res);
6995
- }
6996
- return res;
6997
- }
6998
- return Promise.resolve(true);
6999
- };
7000
- const toggle = () => {
7001
- const current = !isChecked.value;
7002
- checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
7003
- ctx.emit("update:checked", current);
7004
- ctx.emit("update:modelValue", current);
7005
- ctx.emit("change", current);
7006
- };
7007
- const handleClick = () => {
7008
- canChange(!isChecked.value, props.label).then((res) => res && toggle());
7009
- };
7010
- return {
7011
- itemWidth,
7012
- direction,
7013
- mergedColor,
7014
- mergedDisabled,
7015
- mergedIsShowTitle,
7016
- mergedChecked,
7017
- mergedShowAnimation,
7018
- handleClick,
7019
- ns
7020
- };
7021
- },
7022
- render() {
7023
- var _a;
7413
+ const ns2 = useNamespace("checkbox");
7024
7414
  const {
7025
- itemWidth,
7026
- direction,
7027
7415
  mergedChecked,
7028
7416
  mergedDisabled,
7029
7417
  mergedIsShowTitle,
7030
7418
  mergedShowAnimation,
7031
- halfChecked,
7032
- title,
7033
- label,
7034
- handleClick,
7035
- name,
7036
- value,
7037
7419
  mergedColor,
7038
- ns,
7039
- $slots
7040
- } = this;
7041
- const wrapperCls = {
7042
- [ns.e("column-margin")]: direction === "column",
7043
- [ns.e("wrap")]: typeof itemWidth !== "undefined"
7044
- };
7045
- const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
7046
- const checkboxCls = {
7047
- [ns.b()]: true,
7048
- active: mergedChecked,
7049
- "half-checked": halfChecked,
7050
- disabled: mergedDisabled,
7051
- unchecked: !mergedChecked
7052
- };
7053
- const labelTitle = mergedIsShowTitle ? title || label : "";
7054
- const bgImgStyle = mergedColor && halfChecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
7055
- const spanStyle = [`border-color:${(mergedChecked || halfChecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfChecked ? mergedColor : ""}`];
7056
- const spanCls = {
7057
- [ns.e("material")]: true,
7058
- "custom-color": mergedColor,
7059
- [ns.m("no-label")]: !label && !$slots.default,
7060
- [ns.m("no-animation")]: !mergedShowAnimation,
7061
- [ns.e("default-background")]: !halfChecked
7062
- };
7063
- const polygonCls = {
7064
- [ns.e("tick")]: true,
7065
- [ns.m("no-animation")]: !mergedShowAnimation
7066
- };
7067
- const stopPropagation = ($event) => $event.stopPropagation();
7068
- const inputProps = {
7069
- indeterminate: halfChecked
7070
- };
7071
- return createVNode("div", {
7072
- "class": wrapperCls,
7073
- "style": wrapperStyle
7074
- }, [createVNode("div", {
7075
- "class": checkboxCls
7076
- }, [createVNode("label", {
7077
- "title": labelTitle,
7078
- "onClick": handleClick
7079
- }, [createVNode("input", mergeProps({
7080
- "name": name || value,
7081
- "class": ns.e("input"),
7082
- "type": "checkbox"
7083
- }, inputProps, {
7084
- "checked": mergedChecked,
7085
- "disabled": mergedDisabled,
7086
- "onClick": stopPropagation,
7087
- "onChange": stopPropagation
7088
- }), null), createVNode("span", {
7089
- "style": spanStyle,
7090
- "class": spanCls
7091
- }, [createVNode("span", {
7092
- "class": ns.e("halfchecked-bg")
7093
- }, null), createVNode("svg", {
7094
- "viewBox": "0 0 16 16",
7095
- "version": "1.1",
7096
- "xmlns": "http://www.w3.org/2000/svg",
7097
- "class": ns.e("tick-wrap")
7098
- }, [createVNode("g", {
7099
- "stroke": "none",
7100
- "stroke-width": "1",
7101
- "fill": "none",
7102
- "fill-rule": "evenodd"
7103
- }, [createVNode("polygon", {
7104
- "fill-rule": "nonzero",
7105
- "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
7106
- "class": polygonCls
7107
- }, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
7108
- }
7420
+ itemWidth,
7421
+ direction,
7422
+ handleClick,
7423
+ size,
7424
+ border
7425
+ } = useCheckbox(props, ctx);
7426
+ return () => {
7427
+ var _a, _b;
7428
+ const wrapperCls = {
7429
+ [ns2.e("column-margin")]: direction === "column",
7430
+ [ns2.e("wrap")]: typeof itemWidth !== "undefined"
7431
+ };
7432
+ const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
7433
+ const checkboxCls = {
7434
+ [ns2.b()]: true,
7435
+ active: mergedChecked.value,
7436
+ "half-checked": props.halfChecked,
7437
+ disabled: mergedDisabled.value,
7438
+ unchecked: !mergedChecked.value
7439
+ };
7440
+ const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
7441
+ const bgImgStyle = mergedColor.value && props.halfChecked || mergedColor.value ? `linear-gradient(${mergedColor.value}, ${mergedColor.value})` : "";
7442
+ const spanStyle = [`border-color:${(mergedChecked.value || props.halfChecked) && mergedColor.value ? mergedColor.value : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor.value && props.halfChecked ? mergedColor.value : ""}`];
7443
+ const spanCls = {
7444
+ [ns2.e("material")]: true,
7445
+ "custom-color": mergedColor.value,
7446
+ [ns2.m("no-label")]: !props.label && !ctx.slots.default,
7447
+ [ns2.m("no-animation")]: !mergedShowAnimation.value,
7448
+ [ns2.e("default-background")]: !props.halfChecked
7449
+ };
7450
+ const polygonCls = {
7451
+ [ns2.e("tick")]: true,
7452
+ [ns2.m("no-animation")]: !mergedShowAnimation.value
7453
+ };
7454
+ const labelCls = {
7455
+ [ns2.m(size.value)]: border.value,
7456
+ [ns2.m("bordered")]: border.value
7457
+ };
7458
+ const stopPropagation = ($event) => $event.stopPropagation();
7459
+ const inputProps = {
7460
+ indeterminate: props.halfChecked
7461
+ };
7462
+ return createVNode("div", {
7463
+ "class": wrapperCls,
7464
+ "style": wrapperStyle
7465
+ }, [createVNode("div", {
7466
+ "class": checkboxCls
7467
+ }, [createVNode("label", {
7468
+ "title": labelTitle,
7469
+ "onClick": handleClick,
7470
+ "class": labelCls,
7471
+ "style": {
7472
+ width: itemWidth ? "100%" : "auto"
7473
+ }
7474
+ }, [createVNode("input", mergeProps({
7475
+ "name": props.name || props.value,
7476
+ "class": ns2.e("input"),
7477
+ "type": "checkbox"
7478
+ }, inputProps, {
7479
+ "checked": mergedChecked.value,
7480
+ "disabled": mergedDisabled.value,
7481
+ "onClick": stopPropagation,
7482
+ "onChange": stopPropagation
7483
+ }), null), createVNode("span", {
7484
+ "style": spanStyle,
7485
+ "class": spanCls
7486
+ }, [createVNode("span", {
7487
+ "class": ns2.e("halfchecked-bg")
7488
+ }, null), createVNode("svg", {
7489
+ "viewBox": "0 0 16 16",
7490
+ "version": "1.1",
7491
+ "xmlns": "http://www.w3.org/2000/svg",
7492
+ "class": ns2.e("tick-wrap")
7493
+ }, [createVNode("g", {
7494
+ "stroke": "none",
7495
+ "stroke-width": "1",
7496
+ "fill": "none",
7497
+ "fill-rule": "evenodd"
7498
+ }, [createVNode("polygon", {
7499
+ "fill-rule": "nonzero",
7500
+ "points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
7501
+ "class": polygonCls
7502
+ }, null)])])]), props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])])]);
7503
+ };
7504
+ }
7109
7505
  });
7110
7506
  var checkboxGroup = "";
7111
7507
  defineComponent({
@@ -7113,92 +7509,97 @@ defineComponent({
7113
7509
  props: checkboxGroupProps,
7114
7510
  emits: ["change", "update:modelValue"],
7115
7511
  setup(props, ctx) {
7116
- const valList = toRef(props, "modelValue");
7117
- const defaultOpt = {
7118
- checked: false,
7119
- isShowTitle: true,
7120
- halfChecked: false,
7121
- showAnimation: true,
7122
- disabled: false
7123
- };
7124
- const toggleGroupVal = (val) => {
7125
- let index2 = -1;
7126
- if (typeof valList.value[0] === "string") {
7127
- index2 = valList.value.findIndex((item) => item === val);
7128
- } else if (typeof valList.value[0] === "object") {
7129
- index2 = valList.value.findIndex((item) => item.value === val);
7130
- }
7131
- if (index2 === -1) {
7132
- if (typeof props.options[0] === "object") {
7133
- const newOne = props.options.find((item) => item.value === val);
7134
- const res2 = [...valList.value, newOne];
7135
- ctx.emit("update:modelValue", res2);
7136
- ctx.emit("change", res2);
7137
- return;
7138
- }
7139
- const res = [...valList.value, val];
7140
- ctx.emit("update:modelValue", res);
7141
- ctx.emit("change", res);
7142
- return;
7143
- }
7144
- valList.value.splice(index2, 1);
7145
- ctx.emit("update:modelValue", valList.value);
7146
- ctx.emit("change", valList.value);
7147
- };
7148
- const isItemChecked = (itemVal) => {
7149
- if (typeof valList.value[0] === "string") {
7150
- return valList.value.includes(itemVal);
7151
- } else if (typeof valList.value[0] === "object") {
7152
- return valList.value.some((item) => item.value === itemVal);
7153
- }
7154
- };
7155
- provide(checkboxGroupInjectionKey, {
7156
- disabled: toRef(props, "disabled"),
7157
- isShowTitle: toRef(props, "isShowTitle"),
7158
- color: toRef(props, "color"),
7159
- showAnimation: toRef(props, "showAnimation"),
7160
- beforeChange: props.beforeChange,
7161
- isItemChecked,
7162
- toggleGroupVal,
7163
- itemWidth: toRef(props, "itemWidth"),
7164
- direction: toRef(props, "direction")
7165
- });
7166
- return {
7512
+ const ns2 = useNamespace("checkbox");
7513
+ const {
7167
7514
  defaultOpt
7515
+ } = useCheckboxGroup(props, ctx);
7516
+ return () => {
7517
+ var _a, _b;
7518
+ let children = (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a);
7519
+ const getContent = () => {
7520
+ var _a2;
7521
+ if (children) {
7522
+ return children;
7523
+ } else {
7524
+ if (((_a2 = props.options) == null ? void 0 : _a2.length) > 0) {
7525
+ children = props.options.map((opt) => {
7526
+ let mergedOpt = null;
7527
+ if (typeof opt === "string") {
7528
+ mergedOpt = Object.assign({}, defaultOpt, {
7529
+ label: opt,
7530
+ value: opt
7531
+ });
7532
+ } else if (typeof opt === "object") {
7533
+ mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
7534
+ label: opt.name
7535
+ }));
7536
+ }
7537
+ return createVNode(Checkbox, mergedOpt, null);
7538
+ });
7539
+ }
7540
+ return children;
7541
+ }
7542
+ };
7543
+ return createVNode("div", {
7544
+ "class": ns2.e("group")
7545
+ }, [createVNode("div", {
7546
+ "class": {
7547
+ [ns2.m("list-inline")]: props.direction === "row"
7548
+ }
7549
+ }, [getContent()])]);
7168
7550
  };
7169
- },
7170
- render() {
7171
- var _a;
7551
+ }
7552
+ });
7553
+ var checkboxButton = "";
7554
+ defineComponent({
7555
+ name: "DCheckboxButton",
7556
+ props: checkboxProps,
7557
+ emits: ["change", "update:checked", "update:modelValue"],
7558
+ setup(props, ctx) {
7559
+ const ns2 = useNamespace("checkbox-button");
7172
7560
  const {
7173
- direction,
7174
- $slots,
7175
- defaultOpt,
7176
- options
7177
- } = this;
7178
- let children = (_a = $slots.default) == null ? void 0 : _a.call($slots);
7179
- if ((options == null ? void 0 : options.length) > 0) {
7180
- children = options.map((opt) => {
7181
- let mergedOpt = null;
7182
- if (typeof opt === "string") {
7183
- mergedOpt = Object.assign({}, defaultOpt, {
7184
- label: opt,
7185
- value: opt
7186
- });
7187
- } else if (typeof opt === "object") {
7188
- mergedOpt = Object.assign({}, defaultOpt, __spreadProps(__spreadValues({}, opt), {
7189
- label: opt.name
7190
- }));
7191
- }
7192
- return createVNode(Checkbox, mergedOpt, null);
7193
- });
7194
- }
7195
- return createVNode("div", {
7196
- "class": "devui-checkbox-group"
7197
- }, [createVNode("div", {
7198
- "class": {
7199
- "devui-checkbox-list-inline": direction === "row"
7200
- }
7201
- }, [children])]);
7561
+ mergedChecked,
7562
+ mergedDisabled,
7563
+ mergedIsShowTitle,
7564
+ mergedColor,
7565
+ handleClick,
7566
+ size
7567
+ } = useCheckbox(props, ctx);
7568
+ const {
7569
+ mergedTextColor
7570
+ } = useCheckboxButton();
7571
+ return () => {
7572
+ var _a, _b;
7573
+ const labelTitle = mergedIsShowTitle.value ? props.title || props.label : "";
7574
+ const spanStyle = [`border-color:${mergedChecked.value && mergedColor.value ? mergedColor.value : ""}`, `background-color:${mergedChecked.value && mergedColor.value ? mergedColor.value : ""}`, `color:${mergedChecked.value && mergedTextColor.value ? mergedTextColor.value : ""}`];
7575
+ const labelCls = {
7576
+ [ns2.b()]: true,
7577
+ active: mergedChecked.value,
7578
+ disabled: mergedDisabled.value,
7579
+ unchecked: !mergedChecked.value
7580
+ };
7581
+ const spanCls = {
7582
+ [ns2.e("content")]: true,
7583
+ [ns2.m(size.value)]: true
7584
+ };
7585
+ const stopPropagation = ($event) => $event.stopPropagation();
7586
+ return createVNode("label", {
7587
+ "title": labelTitle,
7588
+ "onClick": handleClick,
7589
+ "class": labelCls
7590
+ }, [createVNode("input", {
7591
+ "name": props.name || props.value,
7592
+ "class": ns2.e("input"),
7593
+ "type": "checkbox",
7594
+ "checked": mergedChecked.value,
7595
+ "disabled": mergedDisabled.value,
7596
+ "onClick": stopPropagation,
7597
+ "onChange": stopPropagation
7598
+ }, null), createVNode("span", {
7599
+ "style": spanStyle,
7600
+ "class": spanCls
7601
+ }, [props.label || ((_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a))])]);
7602
+ };
7202
7603
  }
7203
7604
  });
7204
7605
  function useFilterRender(ctx) {
@@ -7301,7 +7702,7 @@ var MultipleFilter = defineComponent({
7301
7702
  }, [createVNode(Checkbox, {
7302
7703
  "modelValue": _checkAll.value,
7303
7704
  "onUpdate:modelValue": ($event) => _checkAll.value = $event,
7304
- "halfchecked": _halfChecked.value,
7705
+ "halfChecked": _halfChecked.value,
7305
7706
  "label": "\u5168\u9009"
7306
7707
  }, null)])]), createVNode("div", {
7307
7708
  "class": "filter-multiple-menu"
@@ -7327,11 +7728,11 @@ var List = defineComponent({
7327
7728
  setup(props, {
7328
7729
  slots
7329
7730
  }) {
7330
- const ns = useNamespace("list");
7731
+ const ns2 = useNamespace("list");
7331
7732
  return () => {
7332
7733
  var _a;
7333
7734
  return createVNode("div", {
7334
- "class": ns.b()
7735
+ "class": ns2.b()
7335
7736
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
7336
7737
  };
7337
7738
  }
@@ -7342,11 +7743,11 @@ var ListItem = defineComponent({
7342
7743
  setup(props, {
7343
7744
  slots
7344
7745
  }) {
7345
- const ns = useNamespace("list-item");
7746
+ const ns2 = useNamespace("list-item");
7346
7747
  return () => {
7347
7748
  var _a;
7348
7749
  return createVNode("div", {
7349
- "class": ns.b()
7750
+ "class": ns2.b()
7350
7751
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
7351
7752
  };
7352
7753
  }
@@ -7438,6 +7839,13 @@ var Filter = defineComponent({
7438
7839
  });
7439
7840
  }
7440
7841
  });
7842
+ function useBaseRender(column) {
7843
+ const baseClass = computed(() => ({
7844
+ operable: column.value.filterable || column.value.sortable || column.value.resizeable,
7845
+ resizeable: column.value.resizeable
7846
+ }));
7847
+ return { baseClass };
7848
+ }
7441
7849
  function useSort(column) {
7442
7850
  const table2 = inject(TABLE_TOKEN);
7443
7851
  const store = table2.store;
@@ -7482,6 +7890,79 @@ function useFilter(column) {
7482
7890
  };
7483
7891
  return { filterClass, handleFilter };
7484
7892
  }
7893
+ function handleWidth(width) {
7894
+ if (!width) {
7895
+ return;
7896
+ }
7897
+ if (typeof width === "number") {
7898
+ return width;
7899
+ }
7900
+ return parseInt(width, 10);
7901
+ }
7902
+ function getFinalWidth(newWidth, minWidth, maxWidth) {
7903
+ const realMinWidth = handleWidth(minWidth);
7904
+ const realMaxWidth = handleWidth(maxWidth);
7905
+ const overMinWidth = !realMinWidth || newWidth >= realMinWidth;
7906
+ const underMaxWidth = !realMaxWidth || newWidth <= realMaxWidth;
7907
+ const finalWidth = !overMinWidth ? realMinWidth : !underMaxWidth ? realMaxWidth : newWidth;
7908
+ return finalWidth;
7909
+ }
7910
+ function useDragColumnWidth(elementRef, column) {
7911
+ let initialWidth = 0;
7912
+ let mouseDownScreenX = 0;
7913
+ let resizeBarElement;
7914
+ const table2 = inject(TABLE_TOKEN);
7915
+ const dragClass = ref("");
7916
+ const resizing = ref(false);
7917
+ const tableElement = table2.tableRef;
7918
+ const onMousemove = (e) => {
7919
+ const movementX = e.clientX - mouseDownScreenX;
7920
+ const newWidth = initialWidth + movementX;
7921
+ const finalWidth = getFinalWidth(newWidth, column.value.minWidth, column.value.maxWidth);
7922
+ if (resizeBarElement) {
7923
+ resizeBarElement.style.left = `${finalWidth + elementRef.value.offsetLeft}px`;
7924
+ }
7925
+ column.value.ctx.emit("resizing", { width: finalWidth });
7926
+ };
7927
+ const onMouseup = (e) => {
7928
+ const movementX = e.clientX - mouseDownScreenX;
7929
+ const newWidth = initialWidth + movementX;
7930
+ const finalWidth = getFinalWidth(newWidth, column.value.minWidth, column.value.maxWidth);
7931
+ column.value.width = finalWidth;
7932
+ column.value.realWidth = finalWidth;
7933
+ table2.updateColumnWidth();
7934
+ resizing.value = false;
7935
+ tableElement == null ? void 0 : tableElement.value.classList.remove("table-selector");
7936
+ dragClass.value = "";
7937
+ tableElement == null ? void 0 : tableElement.value.removeChild(resizeBarElement);
7938
+ column.value.ctx.emit("resize-end", { width: finalWidth, beforeWidth: initialWidth });
7939
+ document.removeEventListener("mouseup", onMouseup);
7940
+ document.removeEventListener("mousemove", onMousemove);
7941
+ };
7942
+ const onMousedown = (e) => {
7943
+ const isHandle = e.target.classList.contains("resize-handle");
7944
+ if (isHandle) {
7945
+ column.value.ctx.emit("resize-start");
7946
+ const initialOffset = elementRef.value.offsetLeft;
7947
+ initialWidth = elementRef.value.clientWidth;
7948
+ mouseDownScreenX = e.clientX;
7949
+ e.stopPropagation();
7950
+ resizing.value = true;
7951
+ tableElement == null ? void 0 : tableElement.value.classList.add("table-selector");
7952
+ resizeBarElement = document.createElement("div");
7953
+ resizeBarElement.classList.add("resize-bar");
7954
+ if (tableElement.value) {
7955
+ resizeBarElement.style.display = "block";
7956
+ resizeBarElement.style.left = initialOffset + initialWidth + "px";
7957
+ tableElement.value.appendChild(resizeBarElement);
7958
+ }
7959
+ dragClass.value = "hover-bg";
7960
+ document.addEventListener("mouseup", onMouseup);
7961
+ document.addEventListener("mousemove", onMousemove);
7962
+ }
7963
+ };
7964
+ return { resizing, dragClass, onMousedown };
7965
+ }
7485
7966
  var TH = defineComponent({
7486
7967
  name: "DTableHeaderTh",
7487
7968
  props: {
@@ -7495,9 +7976,13 @@ var TH = defineComponent({
7495
7976
  }) {
7496
7977
  const table2 = inject(TABLE_TOKEN);
7497
7978
  const store = table2.store;
7979
+ const headerContainerRef = ref();
7498
7980
  const {
7499
7981
  column
7500
7982
  } = toRefs(props);
7983
+ const {
7984
+ baseClass
7985
+ } = useBaseRender(column);
7501
7986
  const {
7502
7987
  direction,
7503
7988
  sortClass,
@@ -7512,16 +7997,23 @@ var TH = defineComponent({
7512
7997
  stickyClass,
7513
7998
  stickyStyle
7514
7999
  } = useFixedColumn(column);
8000
+ const {
8001
+ resizing,
8002
+ dragClass,
8003
+ onMousedown
8004
+ } = useDragColumnWidth(headerContainerRef, column);
7515
8005
  expose({
7516
8006
  clearSortOrder
7517
8007
  });
7518
8008
  return () => {
7519
8009
  var _a, _b;
7520
8010
  return createVNode("th", {
7521
- "class": [stickyClass.value, sortClass.value, filterClass.value],
8011
+ "class": [baseClass.value, stickyClass.value, sortClass.value, filterClass.value, dragClass.value],
7522
8012
  "style": stickyStyle.value
7523
8013
  }, [createVNode("div", {
7524
- "class": "header-container"
8014
+ "ref": headerContainerRef,
8015
+ "class": "header-container",
8016
+ "onMousedown": onMousedown
7525
8017
  }, [(_b = (_a = column.value).renderHeader) == null ? void 0 : _b.call(_a, column.value, store), column.value.filterable && createVNode(Filter, {
7526
8018
  "filterList": column.value.filterList,
7527
8019
  "multiple": column.value.filterMultiple,
@@ -7529,6 +8021,12 @@ var TH = defineComponent({
7529
8021
  }, null), column.value.sortable && createVNode(Sort, {
7530
8022
  "sort-direction": direction.value,
7531
8023
  "onSort": handleSort
8024
+ }, null), column.value.resizeable && createVNode("span", {
8025
+ "class": "resize-handle",
8026
+ "onClick": (e) => e.stopPropagation()
8027
+ }, null), column.value.resizeable && resizing.value && createVNode("div", {
8028
+ "class": "resize-overlay",
8029
+ "onClick": (e) => e.stopPropagation()
7532
8030
  }, null)])]);
7533
8031
  };
7534
8032
  }
@@ -7595,49 +8093,248 @@ var body = "";
7595
8093
  var TableHeader = defineComponent({
7596
8094
  name: "DTableHeader",
7597
8095
  setup() {
7598
- const ns = useNamespace("table");
8096
+ const ns2 = useNamespace("table");
7599
8097
  const {
7600
8098
  headerRows
7601
8099
  } = useHeader();
7602
8100
  return () => createVNode("thead", {
7603
- "class": ns.e("thead")
7604
- }, [headerRows.value.map((subColumns) => createVNode("tr", null, [subColumns.map((column, columnIndex) => createVNode(TH, {
7605
- "key": columnIndex,
7606
- "column": column,
7607
- "colspan": column.colSpan,
7608
- "rowspan": column.rowSpan
7609
- }, null))]))]);
8101
+ "class": ns2.e("thead")
8102
+ }, [headerRows.value.map((subColumns) => createVNode("tr", null, [subColumns.map((column, columnIndex) => {
8103
+ return createVNode(TH, {
8104
+ "key": columnIndex,
8105
+ "column": column,
8106
+ "colspan": column.colSpan,
8107
+ "rowspan": column.rowSpan
8108
+ }, null);
8109
+ })]))]);
7610
8110
  }
7611
8111
  });
8112
+ const bodyTdProps = {
8113
+ column: {
8114
+ type: Object,
8115
+ default: () => ({})
8116
+ },
8117
+ row: {
8118
+ type: Object,
8119
+ default: () => ({})
8120
+ },
8121
+ index: {
8122
+ type: Number,
8123
+ default: 0
8124
+ }
8125
+ };
8126
+ const tooltipProps = {
8127
+ content: {
8128
+ type: String,
8129
+ default: ""
8130
+ },
8131
+ position: {
8132
+ type: [String, Array],
8133
+ default: "top"
8134
+ },
8135
+ showAnimation: {
8136
+ type: Boolean,
8137
+ default: true
8138
+ },
8139
+ mouseEnterDelay: {
8140
+ type: Number,
8141
+ default: 150
8142
+ },
8143
+ mouseLeaveDelay: {
8144
+ type: Number,
8145
+ default: 100
8146
+ },
8147
+ enterable: {
8148
+ type: Boolean,
8149
+ default: true
8150
+ },
8151
+ disabled: {
8152
+ type: Boolean,
8153
+ default: false
8154
+ },
8155
+ hideAfter: {
8156
+ type: Number,
8157
+ default: 0
8158
+ }
8159
+ };
8160
+ const TransformOriginMap = {
8161
+ top: "50% calc(100% + 8px)",
8162
+ bottom: "50% -8px",
8163
+ left: "calc(100% + 8px)",
8164
+ right: "-8px 50%"
8165
+ };
8166
+ function useTooltip(origin, props) {
8167
+ const { position, mouseEnterDelay, mouseLeaveDelay, enterable, disabled, hideAfter } = toRefs(props);
8168
+ const visible = ref(false);
8169
+ const isEnter = ref(false);
8170
+ const positionArr = computed(() => typeof position.value === "string" ? [position.value] : position.value);
8171
+ const placement = ref(positionArr.value[0]);
8172
+ const overlayStyles = computed(() => ({
8173
+ transformOrigin: TransformOriginMap[placement.value]
8174
+ }));
8175
+ const enter = lodash.exports.debounce(() => {
8176
+ isEnter.value && (visible.value = true);
8177
+ }, mouseEnterDelay.value);
8178
+ const leave = lodash.exports.debounce(() => {
8179
+ !isEnter.value && (visible.value = false);
8180
+ }, mouseLeaveDelay.value);
8181
+ const onMouseenter = () => {
8182
+ if (disabled.value) {
8183
+ return;
8184
+ }
8185
+ isEnter.value = true;
8186
+ enter();
8187
+ };
8188
+ const onMouseleave = () => {
8189
+ isEnter.value = false;
8190
+ leave();
8191
+ };
8192
+ const onPositionChange = (pos) => {
8193
+ placement.value = pos;
8194
+ };
8195
+ const quickLeave = () => {
8196
+ isEnter.value = false;
8197
+ visible.value = false;
8198
+ };
8199
+ const onMouseenterOverlay = () => {
8200
+ if (!enterable.value) {
8201
+ quickLeave();
8202
+ } else {
8203
+ onMouseenter();
8204
+ }
8205
+ };
8206
+ onMounted(() => {
8207
+ origin.value.addEventListener("mouseenter", onMouseenter);
8208
+ origin.value.addEventListener("mouseleave", onMouseleave);
8209
+ });
8210
+ let timer;
8211
+ watch(visible, (newVal) => {
8212
+ if (newVal && hideAfter.value) {
8213
+ timer && clearTimeout(timer);
8214
+ timer = setTimeout(quickLeave, hideAfter.value);
8215
+ }
8216
+ });
8217
+ return { visible, placement, positionArr, overlayStyles, onPositionChange, onMouseenter, onMouseleave, onMouseenterOverlay };
8218
+ }
8219
+ var tooltip = "";
8220
+ var Tooltip = defineComponent({
8221
+ name: "DTooltip",
8222
+ props: tooltipProps,
8223
+ setup(props, {
8224
+ slots
8225
+ }) {
8226
+ const {
8227
+ showAnimation,
8228
+ content
8229
+ } = toRefs(props);
8230
+ const origin = ref();
8231
+ const tooltipRef = ref();
8232
+ const {
8233
+ visible,
8234
+ placement,
8235
+ positionArr,
8236
+ overlayStyles,
8237
+ onPositionChange,
8238
+ onMouseleave,
8239
+ onMouseenterOverlay
8240
+ } = useTooltip(origin, props);
8241
+ const ns2 = useNamespace("tooltip");
8242
+ provide(POPPER_TRIGGER_TOKEN, origin);
8243
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
8244
+ default: () => {
8245
+ var _a;
8246
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
8247
+ }
8248
+ }), createVNode(Teleport, {
8249
+ "to": "body"
8250
+ }, {
8251
+ default: () => [createVNode(Transition, {
8252
+ "name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
8253
+ }, {
8254
+ default: () => [createVNode(FlexibleOverlay, {
8255
+ "modelValue": visible.value,
8256
+ "onUpdate:modelValue": ($event) => visible.value = $event,
8257
+ "ref": tooltipRef,
8258
+ "class": ns2.b(),
8259
+ "origin": origin.value,
8260
+ "position": positionArr.value,
8261
+ "offset": 6,
8262
+ "show-arrow": true,
8263
+ "style": overlayStyles.value,
8264
+ "onPositionChange": onPositionChange,
8265
+ "onMouseenter": onMouseenterOverlay,
8266
+ "onMouseleave": onMouseleave
8267
+ }, {
8268
+ default: () => [createVNode("span", {
8269
+ "innerHTML": content.value
8270
+ }, null)]
8271
+ })]
8272
+ })]
8273
+ })]);
8274
+ }
8275
+ });
8276
+ function useBodyTd(props) {
8277
+ const tooltipContent = ref();
8278
+ const isShowTooltip = ref(false);
8279
+ const tdRef = ref();
8280
+ let observer;
8281
+ function getTooltipContent() {
8282
+ var _a, _b;
8283
+ return ((_a = tdRef.value) == null ? void 0 : _a.innerText) || ((_b = tdRef.value) == null ? void 0 : _b.textContent);
8284
+ }
8285
+ function shouldShowTooltip() {
8286
+ if (!tdRef.value) {
8287
+ return;
8288
+ }
8289
+ const range = document.createRange();
8290
+ range.setStart(tdRef.value, 0);
8291
+ range.setEnd(tdRef.value, tdRef.value.childNodes.length);
8292
+ const rangeWidth = range.getBoundingClientRect().width;
8293
+ const padding = parseInt(window.getComputedStyle(tdRef.value)["paddingLeft"], 10) + parseInt(window.getComputedStyle(tdRef.value)["paddingRight"], 10);
8294
+ isShowTooltip.value = props.column.showOverflowTooltip && rangeWidth + padding > tdRef.value.offsetWidth;
8295
+ }
8296
+ onMounted(() => {
8297
+ if (inBrowser && window.ResizeObserver && props.column.showOverflowTooltip) {
8298
+ const observer2 = new window.ResizeObserver(shouldShowTooltip);
8299
+ tdRef.value && observer2.observe(tdRef.value);
8300
+ }
8301
+ tooltipContent.value = getTooltipContent();
8302
+ });
8303
+ onBeforeMount(() => {
8304
+ tdRef.value && observer.unobserve(tdRef.value);
8305
+ });
8306
+ return { tdRef, isShowTooltip, tooltipContent };
8307
+ }
7612
8308
  var TD = defineComponent({
7613
8309
  name: "DTableBodyTd",
7614
- props: {
7615
- column: {
7616
- type: Object,
7617
- default: () => ({})
7618
- },
7619
- row: {
7620
- type: Object,
7621
- default: () => ({})
7622
- },
7623
- index: {
7624
- type: Number,
7625
- default: 0
7626
- }
7627
- },
7628
- setup(props) {
7629
- const table2 = inject(TABLE_TOKEN);
8310
+ inheritAttrs: false,
8311
+ props: bodyTdProps,
8312
+ setup(props, ctx) {
7630
8313
  const column = toRef(props, "column");
8314
+ const table2 = inject(TABLE_TOKEN);
7631
8315
  const {
7632
8316
  stickyClass,
7633
8317
  stickyStyle
7634
8318
  } = useFixedColumn(column);
8319
+ const {
8320
+ tdRef,
8321
+ isShowTooltip,
8322
+ tooltipContent
8323
+ } = useBodyTd(props);
7635
8324
  return () => {
7636
- var _a, _b;
7637
- return createVNode("td", {
7638
- "class": stickyClass.value,
7639
- "style": stickyStyle.value
7640
- }, [(_b = (_a = column.value).renderCell) == null ? void 0 : _b.call(_a, props.row, column.value, table2.store, props.index)]);
8325
+ return createVNode(Tooltip, {
8326
+ "content": tooltipContent.value,
8327
+ "disabled": !isShowTooltip.value
8328
+ }, {
8329
+ default: () => {
8330
+ var _a, _b;
8331
+ return [createVNode("td", mergeProps({
8332
+ "ref": tdRef,
8333
+ "class": stickyClass.value,
8334
+ "style": stickyStyle.value
8335
+ }, ctx.attrs), [(_b = (_a = props.column).renderCell) == null ? void 0 : _b.call(_a, props.row, props.column, table2.store, props.index)])];
8336
+ }
8337
+ });
7641
8338
  };
7642
8339
  }
7643
8340
  });
@@ -7701,35 +8398,56 @@ var TableBody = defineComponent({
7701
8398
  _data: data,
7702
8399
  flatColumns
7703
8400
  } = table2.store.states;
7704
- const ns = useNamespace("table");
8401
+ const ns2 = useNamespace("table");
7705
8402
  const hoverEnabled = computed(() => table2.props.rowHoveredHighlight);
7706
8403
  const {
7707
8404
  tableSpans,
7708
8405
  removeCells
7709
8406
  } = useMergeCell();
8407
+ const onCellClick = (cellClickArg) => {
8408
+ table2.emit("cell-click", cellClickArg);
8409
+ };
7710
8410
  return () => createVNode("tbody", {
7711
- "class": ns.e("tbody")
8411
+ "class": ns2.e("tbody")
7712
8412
  }, [data.value.map((row, rowIndex) => {
7713
- return createVNode("tr", {
7714
- "key": rowIndex,
7715
- "class": {
7716
- "hover-enabled": hoverEnabled.value
7717
- }
7718
- }, [flatColumns.value.map((column, columnIndex) => {
7719
- var _a;
7720
- const cellId = `${rowIndex}-${columnIndex}`;
7721
- const [rowspan, colspan] = (_a = tableSpans.value[cellId]) != null ? _a : [1, 1];
7722
- if (removeCells.value.includes(cellId)) {
7723
- return null;
7724
- }
7725
- return createVNode(TD, {
7726
- "column": column,
7727
- "index": rowIndex,
7728
- "row": row,
7729
- "rowspan": rowspan,
7730
- "colspan": colspan
7731
- }, null);
7732
- })]);
8413
+ const tableRow = () => {
8414
+ return createVNode("tr", {
8415
+ "key": rowIndex,
8416
+ "class": {
8417
+ "hover-enabled": hoverEnabled.value,
8418
+ "expanded": table2.store.isRowExpanded(row)
8419
+ }
8420
+ }, [flatColumns.value.map((column, columnIndex) => {
8421
+ var _a;
8422
+ const cellId = `${rowIndex}-${columnIndex}`;
8423
+ const [rowspan, colspan] = (_a = tableSpans.value[cellId]) != null ? _a : [1, 1];
8424
+ if (removeCells.value.includes(cellId)) {
8425
+ return null;
8426
+ }
8427
+ return createVNode(TD, {
8428
+ "column": column,
8429
+ "index": rowIndex,
8430
+ "row": row,
8431
+ "rowspan": rowspan,
8432
+ "colspan": colspan,
8433
+ "onClick": () => onCellClick({
8434
+ rowIndex,
8435
+ columnIndex,
8436
+ column,
8437
+ row
8438
+ })
8439
+ }, null);
8440
+ })]);
8441
+ };
8442
+ const expandedRow = () => {
8443
+ var _a, _b, _c, _d;
8444
+ return flatColumns.value.some((column) => column.type === "expand") && createVNode("tr", null, [createVNode("td", {
8445
+ "colspan": flatColumns.value.length
8446
+ }, [(_d = (_c = (_b = (_a = flatColumns.value.filter((column) => column.type === "expand")) == null ? void 0 : _a[0]) == null ? void 0 : _b.slots) == null ? void 0 : _c.default) == null ? void 0 : _d.call(_c, {
8447
+ row
8448
+ })])]);
8449
+ };
8450
+ return createVNode(Fragment, null, [tableRow(), table2.store.isRowExpanded(row) && expandedRow()]);
7733
8451
  })]);
7734
8452
  }
7735
8453
  });
@@ -7744,26 +8462,26 @@ var FixHeader = defineComponent({
7744
8462
  }
7745
8463
  },
7746
8464
  setup(props) {
7747
- const ns = useNamespace("table");
7748
- return () => {
7749
- return createVNode("div", {
7750
- "class": ns.e("fix-header")
7751
- }, [createVNode("div", {
7752
- "style": "overflow:hidden scroll;"
7753
- }, [createVNode("table", {
7754
- "class": props.classes,
7755
- "cellpadding": "0",
7756
- "cellspacing": "0"
7757
- }, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
7758
- "class": ns.e("scroll-view")
7759
- }, [createVNode("table", {
7760
- "class": props.classes,
7761
- "cellpadding": "0",
7762
- "cellspacing": "0"
7763
- }, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
7764
- "style": "flex: 1"
7765
- }, null)])])]);
7766
- };
8465
+ const ns2 = useNamespace("table");
8466
+ const table2 = inject(TABLE_TOKEN, void 0);
8467
+ const showHeader = computed(() => Boolean(table2 == null ? void 0 : table2.props.showHeader));
8468
+ return () => createVNode("div", {
8469
+ "class": ns2.e("fix-header")
8470
+ }, [showHeader.value && createVNode("div", {
8471
+ "style": "overflow:hidden scroll;"
8472
+ }, [createVNode("table", {
8473
+ "class": props.classes,
8474
+ "cellpadding": "0",
8475
+ "cellspacing": "0"
8476
+ }, [createVNode(ColGroup, null, null), createVNode(TableHeader, null, null)])]), createVNode("div", {
8477
+ "class": ns2.e("scroll-view")
8478
+ }, [createVNode("table", {
8479
+ "class": props.classes,
8480
+ "cellpadding": "0",
8481
+ "cellspacing": "0"
8482
+ }, [createVNode(ColGroup, null, null), !props.isEmpty && createVNode(TableBody, {
8483
+ "style": "flex: 1"
8484
+ }, null)])])]);
7767
8485
  }
7768
8486
  });
7769
8487
  var NormalHeader = defineComponent({
@@ -7777,15 +8495,15 @@ var NormalHeader = defineComponent({
7777
8495
  }
7778
8496
  },
7779
8497
  setup(props) {
7780
- return () => {
7781
- return createVNode("table", {
7782
- "class": props.classes,
7783
- "cellpadding": "0",
7784
- "cellspacing": "0"
7785
- }, [createVNode(ColGroup, null, null), createVNode(TableHeader, {
7786
- "style": "position:relative"
7787
- }, null), !props.isEmpty && createVNode(TableBody, null, null)]);
7788
- };
8498
+ const table2 = inject(TABLE_TOKEN, void 0);
8499
+ const showHeader = computed(() => Boolean(table2 == null ? void 0 : table2.props.showHeader));
8500
+ return () => createVNode("table", {
8501
+ "class": props.classes,
8502
+ "cellpadding": "0",
8503
+ "cellspacing": "0"
8504
+ }, [createVNode(ColGroup, null, null), showHeader.value && createVNode(TableHeader, {
8505
+ "style": "position:relative"
8506
+ }, null), !props.isEmpty && createVNode(TableBody, null, null)]);
7789
8507
  }
7790
8508
  });
7791
8509
  defineComponent(Loading);
@@ -7797,36 +8515,48 @@ var Table = defineComponent({
7797
8515
  dLoading: loadingDirective
7798
8516
  },
7799
8517
  props: TableProps,
7800
- emits: ["sort-change"],
8518
+ emits: ["sort-change", "cell-click", "check-change", "check-all-change", "expand-change"],
7801
8519
  setup(props, ctx) {
7802
8520
  const table2 = getCurrentInstance();
7803
- const store = createStore(toRef(props, "data"));
8521
+ const store = createStore(toRef(props, "data"), table2);
7804
8522
  const tableId = `devui-table_${tableIdInit++}`;
8523
+ const tableRef = ref();
7805
8524
  table2.tableId = tableId;
7806
8525
  table2.store = store;
7807
8526
  provide(TABLE_TOKEN, table2);
8527
+ const {
8528
+ tableWidth,
8529
+ updateColumnWidth
8530
+ } = useTableLayout(table2);
7808
8531
  const {
7809
8532
  classes,
7810
- style
7811
- } = useTable(props);
8533
+ styles
8534
+ } = useTable(props, tableWidth);
7812
8535
  const isEmpty2 = computed(() => props.data.length === 0);
7813
- const ns = useNamespace("table");
8536
+ const ns2 = useNamespace("table");
7814
8537
  const hiddenColumns = ref(null);
7815
8538
  table2.hiddenColumns = hiddenColumns;
8539
+ table2.tableRef = tableRef;
8540
+ table2.updateColumnWidth = updateColumnWidth;
7816
8541
  ctx.expose({
7817
8542
  getCheckedRows() {
7818
8543
  return store.getCheckedRows();
8544
+ },
8545
+ expandAllRows() {
8546
+ store.expandAllRows();
7819
8547
  }
7820
8548
  });
7821
8549
  onMounted(async () => {
7822
8550
  await nextTick();
7823
8551
  store.updateColumns();
8552
+ updateColumnWidth();
7824
8553
  });
7825
8554
  return () => {
7826
8555
  var _a, _b;
7827
8556
  return withDirectives(createVNode("div", {
7828
- "class": ns.b(),
7829
- "style": style.value
8557
+ "ref": tableRef,
8558
+ "class": ns2.b(),
8559
+ "style": styles.value
7830
8560
  }, [createVNode("div", {
7831
8561
  "ref": hiddenColumns,
7832
8562
  "class": "hidden-columns"
@@ -7837,8 +8567,8 @@ var Table = defineComponent({
7837
8567
  "classes": classes.value,
7838
8568
  "is-empty": isEmpty2.value
7839
8569
  }, null), isEmpty2.value && createVNode("div", {
7840
- "class": ns.e("empty")
7841
- }, [createTextVNode("No Data")])]), [[resolveDirective("dLoading"), props.showLoading]]);
8570
+ "class": ns2.e("empty")
8571
+ }, [ctx.slots.empty ? ctx.slots.empty() : props.empty])]), [[resolveDirective("dLoading"), props.showLoading]]);
7842
8572
  };
7843
8573
  }
7844
8574
  });
@@ -7860,7 +8590,11 @@ const tableColumnProps = {
7860
8590
  },
7861
8591
  minWidth: {
7862
8592
  type: [String, Number],
7863
- default: 80
8593
+ default: ""
8594
+ },
8595
+ maxWidth: {
8596
+ type: [String, Number],
8597
+ default: ""
7864
8598
  },
7865
8599
  formatter: {
7866
8600
  type: Function
@@ -7897,16 +8631,35 @@ const tableColumnProps = {
7897
8631
  },
7898
8632
  fixedRight: {
7899
8633
  type: String
8634
+ },
8635
+ align: {
8636
+ type: String,
8637
+ default: "left"
8638
+ },
8639
+ showOverflowTooltip: {
8640
+ type: Boolean,
8641
+ default: false
8642
+ },
8643
+ checkable: {
8644
+ type: Function
8645
+ },
8646
+ resizeable: {
8647
+ type: Boolean,
8648
+ default: false
8649
+ },
8650
+ reserveCheck: {
8651
+ type: Boolean,
8652
+ default: false
7900
8653
  }
7901
8654
  };
7902
8655
  function formatWidth(width) {
8656
+ if (width === "") {
8657
+ return width;
8658
+ }
7903
8659
  if (typeof width === "number") {
7904
8660
  return width;
7905
8661
  }
7906
- return parseInt(width, 10) || 0;
7907
- }
7908
- function formatMinWidth(minWidth) {
7909
- return formatWidth(minWidth) || 80;
8662
+ return parseInt(width, 10) || 80;
7910
8663
  }
7911
8664
  const cellMap = {
7912
8665
  checkable: {
@@ -7916,14 +8669,16 @@ const cellMap = {
7916
8669
  halfchecked: store.states._halfChecked.value,
7917
8670
  onChange: (val) => {
7918
8671
  store.states._checkAll.value = val;
8672
+ store._table.emit("check-all-change", val);
7919
8673
  }
7920
8674
  });
7921
8675
  },
7922
8676
  renderCell(rowData, column, store, rowIndex) {
7923
8677
  return h(Checkbox, {
7924
- modelValue: store.states._checkList.value[rowIndex],
8678
+ modelValue: store.isRowChecked(rowData),
7925
8679
  onChange: (val) => {
7926
- store.states._checkList.value[rowIndex] = val;
8680
+ store.checkRow(val, rowData);
8681
+ store._table.emit("check-change", val, store.states._data.value[rowIndex]);
7927
8682
  }
7928
8683
  });
7929
8684
  }
@@ -7939,6 +8694,21 @@ const cellMap = {
7939
8694
  return rowIndex + 1;
7940
8695
  }
7941
8696
  },
8697
+ expand: {
8698
+ renderHeader() {
8699
+ return createVNode("span", null, null);
8700
+ },
8701
+ renderCell(rowData, column, store, rowIndex) {
8702
+ return createVNode(Icon, {
8703
+ "name": "chevron-right",
8704
+ "class": "icon-expand-row",
8705
+ "onClick": () => {
8706
+ store.toggleRow(rowData);
8707
+ store._table.emit("expand-change", rowData, store.getExpandedRows());
8708
+ }
8709
+ }, null);
8710
+ }
8711
+ },
7942
8712
  default: {
7943
8713
  renderHeader(column) {
7944
8714
  var _a;
@@ -7956,7 +8726,7 @@ const cellMap = {
7956
8726
  }
7957
8727
  }
7958
8728
  };
7959
- function createColumn(props, slots) {
8729
+ function createColumn(id, props, ctx) {
7960
8730
  const {
7961
8731
  type,
7962
8732
  field,
@@ -7965,6 +8735,7 @@ function createColumn(props, slots) {
7965
8735
  sortDirection,
7966
8736
  width,
7967
8737
  minWidth,
8738
+ maxWidth,
7968
8739
  formatter,
7969
8740
  sortMethod,
7970
8741
  filterable,
@@ -7972,19 +8743,22 @@ function createColumn(props, slots) {
7972
8743
  filterMultiple,
7973
8744
  order,
7974
8745
  fixedLeft,
7975
- fixedRight
8746
+ fixedRight,
8747
+ align,
8748
+ showOverflowTooltip,
8749
+ resizeable
7976
8750
  } = props;
7977
- const column = reactive({});
8751
+ const column = reactive({ id });
7978
8752
  column.type = type.value;
7979
8753
  function renderHeader(columnItem, store) {
7980
- if (slots.header) {
7981
- return slots.header(columnItem);
8754
+ if (ctx.slots.header) {
8755
+ return ctx.slots.header(columnItem);
7982
8756
  }
7983
8757
  return cellMap[type.value || "default"].renderHeader(columnItem, store);
7984
8758
  }
7985
8759
  function renderCell(rowData, columnItem, store, rowIndex) {
7986
- if (slots.default) {
7987
- return slots.default({ row: rowData, rowIndex });
8760
+ if (ctx.slots.default && columnItem.type !== "expand") {
8761
+ return ctx.slots.default({ row: rowData, rowIndex });
7988
8762
  }
7989
8763
  return cellMap[type.value || "default"].renderCell(rowData, columnItem, store, rowIndex);
7990
8764
  }
@@ -8007,17 +8781,29 @@ function createColumn(props, slots) {
8007
8781
  column.fixedLeft = left;
8008
8782
  column.fixedRight = right;
8009
8783
  }, { immediate: true });
8010
- watch([width, minWidth], ([widthVal, minWidthVal]) => {
8784
+ watch(align, (alignVal) => {
8785
+ column.align = alignVal;
8786
+ }, { immediate: true });
8787
+ watch(showOverflowTooltip, (showVal) => {
8788
+ column.showOverflowTooltip = showVal;
8789
+ }, { immediate: true });
8790
+ watch(resizeable, (resizeVal) => {
8791
+ column.resizeable = resizeVal;
8792
+ }, { immediate: true });
8793
+ watch([width, minWidth, maxWidth], ([widthVal, minWidthVal, maxWidthVal]) => {
8011
8794
  column.width = formatWidth(widthVal);
8012
- column.minWidth = formatMinWidth(minWidthVal);
8013
- column.realWidth = column.width || column.minWidth;
8014
- });
8795
+ column.minWidth = minWidthVal;
8796
+ column.maxWidth = maxWidthVal;
8797
+ column.realWidth = column.width;
8798
+ }, { immediate: true });
8015
8799
  onBeforeMount(() => {
8800
+ column.id = id;
8016
8801
  column.renderHeader = renderHeader;
8017
8802
  column.renderCell = renderCell;
8018
8803
  column.formatter = formatter == null ? void 0 : formatter.value;
8019
- column.customFilterTemplate = slots.customFilterTemplate;
8020
- column.subColumns = slots.subColumns;
8804
+ column.customFilterTemplate = ctx.slots.customFilterTemplate;
8805
+ column.subColumns = ctx.slots.subColumns;
8806
+ column.slots = ctx.slots;
8021
8807
  });
8022
8808
  return column;
8023
8809
  }
@@ -8039,29 +8825,35 @@ let columnIdInit = 1;
8039
8825
  var Column = defineComponent({
8040
8826
  name: "DColumn",
8041
8827
  props: tableColumnProps,
8042
- emits: ["filter-change"],
8828
+ emits: ["filter-change", "resize-start", "resizing", "resize-end"],
8043
8829
  setup(props, ctx) {
8044
- const instance = getCurrentInstance();
8045
- const column = createColumn(toRefs(props), ctx.slots);
8830
+ toRefs(props);
8046
8831
  const owner = inject(TABLE_TOKEN);
8047
8832
  const isSubColumn = ref(false);
8048
- let columnId = "";
8049
8833
  const {
8050
8834
  columnOrTableParent,
8051
8835
  getColumnIndex
8052
8836
  } = useRender();
8053
8837
  const parent = columnOrTableParent.value;
8054
- columnId = `${parent.tableId || parent.columnId}_column_${columnIdInit++}`;
8055
- column.ctx = ctx;
8838
+ const instance = getCurrentInstance();
8839
+ instance.columnId = `${parent.tableId || parent.columnId}_column_${columnIdInit++}`;
8840
+ const column = createColumn(instance.columnId, toRefs(props), ctx);
8841
+ instance.columnConfig = column;
8056
8842
  onBeforeMount(() => {
8057
8843
  isSubColumn.value = owner !== parent;
8058
- column.id = columnId;
8059
8844
  });
8060
8845
  onMounted(() => {
8061
8846
  var _a;
8062
8847
  const children = isSubColumn.value ? parent.vnode.el.children : (_a = owner == null ? void 0 : owner.hiddenColumns.value) == null ? void 0 : _a.children;
8063
8848
  const columnIndex = getColumnIndex(children || [], instance.vnode.el);
8064
8849
  columnIndex > -1 && (owner == null ? void 0 : owner.store.insertColumn(column, isSubColumn.value ? parent.columnConfig : null));
8850
+ if (typeof props.checkable === "function") {
8851
+ for (const [rowIndex, row] of owner == null ? void 0 : owner.store.states._data.value.entries()) {
8852
+ if (props.checkable(row, rowIndex)) {
8853
+ owner.store.checkRow(true, row);
8854
+ }
8855
+ }
8856
+ }
8065
8857
  });
8066
8858
  watch(() => column.order, () => {
8067
8859
  owner == null ? void 0 : owner.store.sortColumn();
@@ -8069,30 +8861,15 @@ var Column = defineComponent({
8069
8861
  onBeforeUnmount(() => {
8070
8862
  owner == null ? void 0 : owner.store.removeColumn(column);
8071
8863
  });
8072
- instance.columnId = columnId;
8073
- instance.columnConfig = column;
8074
- },
8075
- render() {
8076
- var _a, _b;
8077
- try {
8078
- const renderDefault = (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, {
8864
+ return () => {
8865
+ var _a, _b;
8866
+ const defaultSlot = (_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a, {
8079
8867
  row: {},
8080
8868
  column: {},
8081
8869
  $index: -1
8082
8870
  });
8083
- const children = [];
8084
- if (Array.isArray(renderDefault)) {
8085
- for (const childNode of renderDefault) {
8086
- if (childNode.type.name === "DColumn") {
8087
- children.push(childNode);
8088
- }
8089
- }
8090
- }
8091
- const vnode = h("div", children);
8092
- return vnode;
8093
- } catch {
8094
- return h("div", []);
8095
- }
8871
+ return createVNode("div", null, [Array.isArray(defaultSlot) ? defaultSlot.filter((child) => child.type.name === "DColumn").map((child) => createVNode(Fragment, null, [child])) : createVNode("div", null, null)]);
8872
+ };
8096
8873
  }
8097
8874
  });
8098
8875
  var index = {