vue-devui 1.0.0-rc.12 → 1.0.0-rc.13

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 (77) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +7 -0
  3. package/auto-complete/index.es.js +3 -2
  4. package/auto-complete/index.umd.js +7 -7
  5. package/auto-complete/style.css +1 -1
  6. package/button/index.es.js +2 -1
  7. package/button/index.umd.js +1 -1
  8. package/button/style.css +1 -1
  9. package/checkbox/index.es.js +1 -1
  10. package/checkbox/index.umd.js +4 -4
  11. package/checkbox/style.css +1 -1
  12. package/date-picker-pro/index.es.js +40 -29
  13. package/date-picker-pro/index.umd.js +6 -6
  14. package/date-picker-pro/style.css +1 -1
  15. package/dropdown/index.es.js +8 -1
  16. package/editable-select/index.es.js +7 -7
  17. package/editable-select/index.umd.js +1 -1
  18. package/form/index.es.js +1 -1
  19. package/form/index.umd.js +4 -4
  20. package/icon/index.es.js +2 -1
  21. package/icon/index.umd.js +1 -1
  22. package/icon/style.css +1 -1
  23. package/image-preview/style.css +1 -1
  24. package/input/index.es.js +3 -2
  25. package/input/index.umd.js +4 -4
  26. package/input/style.css +1 -1
  27. package/input-number/index.es.js +1 -4
  28. package/input-number/index.umd.js +1 -1
  29. package/modal/index.es.js +2 -1
  30. package/modal/index.umd.js +1 -1
  31. package/modal/style.css +1 -1
  32. package/notification/index.es.js +29 -32
  33. package/notification/index.umd.js +1 -1
  34. package/notification/style.css +1 -1
  35. package/package.json +1 -1
  36. package/radio/index.es.js +1 -1
  37. package/radio/index.umd.js +4 -4
  38. package/result/index.es.js +2 -1
  39. package/result/index.umd.js +1 -1
  40. package/result/style.css +1 -1
  41. package/search/index.es.js +4 -3
  42. package/search/index.umd.js +4 -4
  43. package/search/style.css +1 -1
  44. package/select/index.es.js +72 -35
  45. package/select/index.umd.js +14 -14
  46. package/select/style.css +1 -1
  47. package/steps/index.es.js +2 -1
  48. package/steps/index.umd.js +1 -1
  49. package/steps/style.css +1 -1
  50. package/style.css +1 -1
  51. package/switch/index.es.js +1 -1
  52. package/switch/index.umd.js +4 -4
  53. package/table/index.es.js +158 -36
  54. package/table/index.umd.js +14 -14
  55. package/table/style.css +1 -1
  56. package/tabs/index.es.js +21 -11
  57. package/tabs/index.umd.js +1 -1
  58. package/tabs/style.css +1 -1
  59. package/textarea/index.es.js +1 -1
  60. package/textarea/index.umd.js +4 -4
  61. package/time-picker/index.es.js +42 -28
  62. package/time-picker/index.umd.js +13 -13
  63. package/time-picker/style.css +1 -1
  64. package/time-select/index.es.js +72 -35
  65. package/time-select/index.umd.js +11 -11
  66. package/time-select/style.css +1 -1
  67. package/timeline/index.es.js +2 -1
  68. package/timeline/index.umd.js +1 -1
  69. package/timeline/style.css +1 -1
  70. package/tree/index.es.js +98 -39
  71. package/tree/index.umd.js +11 -11
  72. package/tree/style.css +1 -1
  73. package/upload/index.es.js +29 -32
  74. package/upload/index.umd.js +1 -1
  75. package/upload/style.css +1 -1
  76. package/vue-devui.es.js +406 -172
  77. package/vue-devui.umd.js +20 -20
package/table/index.es.js CHANGED
@@ -33,7 +33,7 @@ var __publicField = (obj, key, value) => {
33
33
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
34
  return value;
35
35
  };
36
- import { computed, ref, watchEffect, watch, getCurrentInstance, unref, defineComponent, inject, createVNode, toRefs, onMounted, onUnmounted, Transition, mergeProps, nextTick, Comment, Text, h, Fragment, withDirectives, cloneVNode, provide, Teleport, vShow, resolveDynamicComponent, render, resolveDirective, toRef, reactive, createTextVNode, onBeforeUnmount, isVNode, onBeforeMount } from "vue";
36
+ import { computed, ref, watchEffect, watch, getCurrentInstance, unref, defineComponent, inject, createVNode, mergeProps, toRefs, onMounted, onUnmounted, Transition, nextTick, Comment, Text, h, Fragment, withDirectives, cloneVNode, provide, Teleport, vShow, resolveDynamicComponent, render, resolveDirective, toRef, reactive, createTextVNode, onBeforeUnmount, isVNode, onBeforeMount, onUpdated } from "vue";
37
37
  import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
38
38
  import { onClickOutside } from "@vueuse/core";
39
39
  const tableProps = {
@@ -429,6 +429,32 @@ function useExpand(dataSource, table2) {
429
429
  toggleRowExpansion
430
430
  };
431
431
  }
432
+ function useEditTableCell() {
433
+ const tableInstance = getCurrentInstance();
434
+ const rowKey = tableInstance.props.rowKey || "";
435
+ const tableCellModeMap = ref(/* @__PURE__ */ new Map());
436
+ const setCellMode = (row, rowIndex, fields, cellMode) => {
437
+ if (Array.isArray(fields)) {
438
+ fields.forEach((item) => {
439
+ const cellKey = `${getRowIdentity(row, rowKey, rowIndex)}-${item}-cell`;
440
+ tableCellModeMap.value.set(cellKey, cellMode);
441
+ });
442
+ } else {
443
+ const cellKey = `${getRowIdentity(row, rowKey, rowIndex)}-${fields}-cell`;
444
+ tableCellModeMap.value.set(cellKey, cellMode);
445
+ }
446
+ };
447
+ const resetCellMode = () => {
448
+ for (const item of tableCellModeMap.value.keys()) {
449
+ tableCellModeMap.value.set(item, "readonly");
450
+ }
451
+ };
452
+ return {
453
+ tableCellModeMap,
454
+ setCellMode,
455
+ resetCellMode
456
+ };
457
+ }
432
458
  function replaceColumn(array4, column2) {
433
459
  return array4.map((item) => {
434
460
  var _a;
@@ -461,6 +487,7 @@ function createColumnGenerator() {
461
487
  });
462
488
  };
463
489
  const insertColumn = (column2, parent) => {
490
+ var _a;
464
491
  const array4 = unref(_columns);
465
492
  let newColumns = [];
466
493
  if (!parent) {
@@ -470,7 +497,7 @@ function createColumnGenerator() {
470
497
  if (parent && !parent.children) {
471
498
  parent.children = [];
472
499
  }
473
- parent.children.push(column2);
500
+ (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.push(column2);
474
501
  newColumns = replaceColumn(array4, parent);
475
502
  }
476
503
  sortColumn();
@@ -639,6 +666,7 @@ function createStore(dataSource, table2) {
639
666
  const { sortData, thList } = createSorter(dataSource, flatRows);
640
667
  const { isFixedLeft } = createFixedLogic(_columns);
641
668
  const { isRowExpanded, updateExpandRows, setExpandRows, toggleRowExpansion } = useExpand(_data, table2);
669
+ const { tableCellModeMap, setCellMode, resetCellMode } = useEditTableCell();
642
670
  watch(dataSource, (value) => {
643
671
  _data.value = [...value];
644
672
  updateExpandRows();
@@ -657,7 +685,8 @@ function createStore(dataSource, table2) {
657
685
  _halfChecked,
658
686
  isFixedLeft,
659
687
  thList,
660
- firstDefaultColumn
688
+ firstDefaultColumn,
689
+ tableCellModeMap
661
690
  },
662
691
  insertColumn,
663
692
  sortColumn,
@@ -672,7 +701,9 @@ function createStore(dataSource, table2) {
672
701
  setExpandRows,
673
702
  toggleRowExpansion,
674
703
  toggleRowSelection,
675
- updateFirstDefaultColumn
704
+ updateFirstDefaultColumn,
705
+ setCellMode,
706
+ resetCellMode
676
707
  };
677
708
  }
678
709
  var ColGroup = defineComponent({
@@ -697,6 +728,9 @@ const sortProps = {
697
728
  }
698
729
  };
699
730
  var sort = "";
731
+ const XLINK_HREF = {
732
+ "xlink:href": "#sort-svg-path-1"
733
+ };
700
734
  var Sort = defineComponent({
701
735
  props: sortProps,
702
736
  emits: ["sort"],
@@ -755,10 +789,9 @@ var Sort = defineComponent({
755
789
  "stroke-width": "1",
756
790
  "fill": "none",
757
791
  "fill-rule": "evenodd"
758
- }, [createVNode("use", {
759
- "fill-rule": "evenodd",
760
- "xlink:href": "#sort-svg-path-1"
761
- }, null), createVNode("polygon", {
792
+ }, [createVNode("use", mergeProps({
793
+ "fill-rule": "evenodd"
794
+ }, XLINK_HREF), null), createVNode("polygon", {
762
795
  "points": "8 4 11 7 5 7"
763
796
  }, null), createVNode("polygon", {
764
797
  "points": "8 12 5 9 11 9"
@@ -828,7 +861,14 @@ function subscribeEvent(dom, type4, callback) {
828
861
  dom == null ? void 0 : dom.removeEventListener(type4, callback);
829
862
  };
830
863
  }
831
- const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
864
+ const useDropdownEvent = ({
865
+ id,
866
+ isOpen,
867
+ origin,
868
+ dropdownRef,
869
+ props,
870
+ emit
871
+ }) => {
832
872
  let overlayEnter = false;
833
873
  let originEnter = false;
834
874
  const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
@@ -1550,7 +1590,8 @@ function useIconDom(props, ctx) {
1550
1590
  "class": [(rotate == null ? void 0 : rotate.value) === "infinite" && ns2.m("spin")],
1551
1591
  "style": {
1552
1592
  width: iconSize.value || "",
1553
- transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`
1593
+ transform: `rotate(${rotate == null ? void 0 : rotate.value}deg)`,
1594
+ verticalAlign: "middle"
1554
1595
  }
1555
1596
  }, ctx.attrs), null);
1556
1597
  };
@@ -9261,7 +9302,7 @@ function useFormItemValidate(props, _rules) {
9261
9302
  return rule.trigger === triggerVal;
9262
9303
  }
9263
9304
  }).map((_a) => {
9264
- var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
9305
+ var rule = __objRest(_a, []);
9265
9306
  return rule;
9266
9307
  });
9267
9308
  };
@@ -10174,14 +10215,21 @@ function useDragColumnWidth(elementRef, column2) {
10174
10215
  };
10175
10216
  return { resizing, dragClass, onMousedown };
10176
10217
  }
10218
+ const headerThProps = {
10219
+ column: {
10220
+ type: Object,
10221
+ required: true
10222
+ },
10223
+ colspan: {
10224
+ type: Number
10225
+ },
10226
+ rowspan: {
10227
+ type: Number
10228
+ }
10229
+ };
10177
10230
  var TH = defineComponent({
10178
10231
  name: "DTableHeaderTh",
10179
- props: {
10180
- column: {
10181
- type: Object,
10182
- required: true
10183
- }
10184
- },
10232
+ props: headerThProps,
10185
10233
  setup(props, {
10186
10234
  expose
10187
10235
  }) {
@@ -10267,7 +10315,7 @@ function convertToRows(originColumns) {
10267
10315
  let colSpan = 0;
10268
10316
  column2.children.forEach((subColumn) => {
10269
10317
  traverse(subColumn, column2);
10270
- colSpan += subColumn.colSpan;
10318
+ colSpan += subColumn.colSpan || 0;
10271
10319
  });
10272
10320
  column2.colSpan = colSpan;
10273
10321
  } else {
@@ -10285,7 +10333,7 @@ function convertToRows(originColumns) {
10285
10333
  const allColumns = getAllColumns(originColumns);
10286
10334
  allColumns.forEach((column2) => {
10287
10335
  if (!column2.children) {
10288
- column2.rowSpan = maxLevel - column2.level + 1;
10336
+ column2.rowSpan = maxLevel - (column2.level || 0) + 1;
10289
10337
  } else {
10290
10338
  column2.rowSpan = 1;
10291
10339
  column2.children.forEach((col) => col.isSubColumn = true);
@@ -10329,6 +10377,12 @@ const bodyTdProps = {
10329
10377
  type: Object,
10330
10378
  default: () => ({})
10331
10379
  },
10380
+ rowspan: {
10381
+ type: Number
10382
+ },
10383
+ colspan: {
10384
+ type: Number
10385
+ },
10332
10386
  index: {
10333
10387
  type: Number,
10334
10388
  default: 0
@@ -10484,11 +10538,12 @@ var Tooltip = defineComponent({
10484
10538
  })]);
10485
10539
  }
10486
10540
  });
10487
- function useBodyTd(props) {
10541
+ function useBodyTd(props, ctx) {
10488
10542
  const tooltipContent = ref();
10489
10543
  const isShowTooltip = ref(false);
10490
10544
  const tdRef = ref();
10491
10545
  let observer;
10546
+ const table2 = inject(TABLE_TOKEN);
10492
10547
  function getTooltipContent() {
10493
10548
  var _a, _b;
10494
10549
  return ((_a = tdRef.value) == null ? void 0 : _a.innerText) || ((_b = tdRef.value) == null ? void 0 : _b.textContent);
@@ -10502,24 +10557,50 @@ function useBodyTd(props) {
10502
10557
  range3.setEnd(tdRef.value, tdRef.value.childNodes.length);
10503
10558
  const rangeWidth = range3.getBoundingClientRect().width;
10504
10559
  const padding = parseInt(window.getComputedStyle(tdRef.value)["paddingLeft"], 10) + parseInt(window.getComputedStyle(tdRef.value)["paddingRight"], 10);
10505
- isShowTooltip.value = props.column.showOverflowTooltip && rangeWidth + padding > tdRef.value.offsetWidth;
10560
+ isShowTooltip.value = !!(props.column.showOverflowTooltip && rangeWidth + padding > tdRef.value.offsetWidth);
10506
10561
  }
10507
10562
  onMounted(() => {
10508
10563
  if (inBrowser && window.ResizeObserver && props.column.showOverflowTooltip) {
10509
- const observer2 = new window.ResizeObserver(shouldShowTooltip);
10510
- tdRef.value && observer2.observe(tdRef.value);
10564
+ const innerObserver = new window.ResizeObserver(shouldShowTooltip);
10565
+ tdRef.value && innerObserver.observe(tdRef.value);
10511
10566
  }
10512
10567
  tooltipContent.value = getTooltipContent();
10513
10568
  });
10514
10569
  onBeforeMount(() => {
10515
10570
  tdRef.value && observer.unobserve(tdRef.value);
10516
10571
  });
10517
- return { tdRef, isShowTooltip, tooltipContent };
10572
+ onUpdated(() => {
10573
+ const modeMap = table2.store.states.tableCellModeMap.value;
10574
+ for (const child of modeMap.keys()) {
10575
+ modeMap.set(child, "readonly");
10576
+ }
10577
+ });
10578
+ const getCellKsy = () => {
10579
+ return `${getRowIdentity(props.row, table2.props.rowKey, props.index)}-${props.column.field}-cell`;
10580
+ };
10581
+ const cellMode = computed(() => {
10582
+ const cellKey = getCellKsy();
10583
+ const mode = table2.store.states.tableCellModeMap.value.get(cellKey);
10584
+ return mode || "readonly";
10585
+ });
10586
+ const onCellClick = () => {
10587
+ const modeMap = table2.store.states.tableCellModeMap.value;
10588
+ const cellKey = getCellKsy();
10589
+ for (const child of modeMap.keys()) {
10590
+ modeMap.set(child, "readonly");
10591
+ }
10592
+ if (props.column.type === "editable" && modeMap.get(cellKey) === "edit") {
10593
+ return;
10594
+ }
10595
+ ctx.emit("cellClick");
10596
+ };
10597
+ return { tdRef, isShowTooltip, tooltipContent, cellMode, onCellClick };
10518
10598
  }
10519
10599
  var TD = defineComponent({
10520
10600
  name: "DTableBodyTd",
10521
10601
  inheritAttrs: false,
10522
10602
  props: bodyTdProps,
10603
+ emits: ["cellClick"],
10523
10604
  setup(props, ctx) {
10524
10605
  const column2 = toRef(props, "column");
10525
10606
  const table2 = inject(TABLE_TOKEN);
@@ -10530,8 +10611,10 @@ var TD = defineComponent({
10530
10611
  const {
10531
10612
  tdRef,
10532
10613
  isShowTooltip,
10533
- tooltipContent
10534
- } = useBodyTd(props);
10614
+ tooltipContent,
10615
+ cellMode,
10616
+ onCellClick
10617
+ } = useBodyTd(props, ctx);
10535
10618
  return () => {
10536
10619
  return createVNode(Tooltip, {
10537
10620
  "content": tooltipContent.value,
@@ -10543,7 +10626,9 @@ var TD = defineComponent({
10543
10626
  "ref": tdRef,
10544
10627
  "class": stickyClass.value,
10545
10628
  "style": stickyStyle.value
10546
- }, ctx.attrs), [(_b = (_a = props.column).renderCell) == null ? void 0 : _b.call(_a, props.row, props.column, table2.store, props.index, table2.props)])];
10629
+ }, ctx.attrs, {
10630
+ "onClick": onCellClick
10631
+ }), [(_b = (_a = props.column).renderCell) == null ? void 0 : _b.call(_a, props.row, props.column, table2.store, props.index, table2.props, cellMode)])];
10547
10632
  }
10548
10633
  });
10549
10634
  };
@@ -10664,7 +10749,7 @@ var TableBody = defineComponent({
10664
10749
  "row": row,
10665
10750
  "rowspan": rowspan,
10666
10751
  "colspan": colspan,
10667
- "onClick": () => onCellClick({
10752
+ "onCellClick": () => onCellClick({
10668
10753
  rowIndex,
10669
10754
  columnIndex,
10670
10755
  column: column2,
@@ -10965,7 +11050,7 @@ const cellMap = {
10965
11050
  renderHeader() {
10966
11051
  return createVNode("span", null, null);
10967
11052
  },
10968
- renderCell(rowData, column2, store, rowIndex) {
11053
+ renderCell(rowData, column2, store) {
10969
11054
  return createVNode(Icon, {
10970
11055
  "name": "chevron-right",
10971
11056
  "class": "icon-expand-row",
@@ -10975,6 +11060,44 @@ const cellMap = {
10975
11060
  }, null);
10976
11061
  }
10977
11062
  },
11063
+ editable: {
11064
+ renderHeader(column2) {
11065
+ var _a;
11066
+ return h("span", {
11067
+ class: "title"
11068
+ }, (_a = column2.header) != null ? _a : "");
11069
+ },
11070
+ renderCell(rowData, column2, store, rowIndex, props, cellMode, ctx) {
11071
+ var _a, _b;
11072
+ let columnValue;
11073
+ if (cellMode.value === "edit") {
11074
+ columnValue = ctx.slots.cellEdit ? ctx.slots.cellEdit({
11075
+ row: rowData,
11076
+ rowIndex
11077
+ }) : "";
11078
+ } else {
11079
+ if (ctx.slots.cell) {
11080
+ columnValue = createVNode("div", {
11081
+ "class": "cell-text"
11082
+ }, [ctx.slots.cell({
11083
+ row: rowData,
11084
+ rowIndex
11085
+ })]);
11086
+ } else {
11087
+ const value = column2.field ? rowData[column2.field] : "";
11088
+ if (column2.formatter) {
11089
+ columnValue = column2.formatter(rowData, column2, value, rowIndex);
11090
+ }
11091
+ columnValue = createVNode("div", {
11092
+ "class": "cell-text"
11093
+ }, [(_b = (_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) != null ? _b : ""]);
11094
+ }
11095
+ }
11096
+ return h("div", {
11097
+ class: [ns.e("cell"), column2.type === "editable" && (cellMode == null ? void 0 : cellMode.value) === "readonly" && "editable-cell"]
11098
+ }, columnValue);
11099
+ }
11100
+ },
10978
11101
  default: {
10979
11102
  renderHeader(column2) {
10980
11103
  var _a;
@@ -10982,7 +11105,7 @@ const cellMap = {
10982
11105
  class: "title"
10983
11106
  }, (_a = column2.header) != null ? _a : "");
10984
11107
  },
10985
- renderCell(rowData, column2, store, rowIndex, props, ctx) {
11108
+ renderCell(rowData, column2, store, rowIndex, props, cellMode, ctx) {
10986
11109
  var _a, _b, _c;
10987
11110
  let columnValue;
10988
11111
  if (ctx.slots.default) {
@@ -11063,11 +11186,11 @@ function createColumn(id, props, ctx) {
11063
11186
  }
11064
11187
  return cellMap[type4.value || "default"].renderHeader(columnItem, store);
11065
11188
  }
11066
- function renderCell(rowData, columnItem, store, rowIndex, tableProps2) {
11189
+ function renderCell(rowData, columnItem, store, rowIndex, tableProps2, cellMode) {
11067
11190
  if (ctx.slots.default && columnItem.type === "index") {
11068
11191
  return ctx.slots.default({ row: rowData, rowIndex });
11069
11192
  }
11070
- return cellMap[type4.value || "default"].renderCell(rowData, columnItem, store, rowIndex, tableProps2, ctx);
11193
+ return cellMap[type4.value || "default"].renderCell(rowData, columnItem, store, rowIndex, tableProps2, cellMode, ctx);
11071
11194
  }
11072
11195
  watch([field, header2, order], ([fieldVal, headerVal, orderVal]) => {
11073
11196
  column2.field = fieldVal;
@@ -11135,7 +11258,6 @@ var Column = defineComponent({
11135
11258
  props: tableColumnProps,
11136
11259
  emits: ["filter-change", "resize-start", "resizing", "resize-end"],
11137
11260
  setup(props, ctx) {
11138
- toRefs(props);
11139
11261
  const owner = inject(TABLE_TOKEN);
11140
11262
  const isSubColumn = ref(false);
11141
11263
  const {
@@ -11151,8 +11273,8 @@ var Column = defineComponent({
11151
11273
  isSubColumn.value = owner !== parent;
11152
11274
  });
11153
11275
  onMounted(() => {
11154
- var _a;
11155
- const children = isSubColumn.value ? parent.vnode.el.children : (_a = owner == null ? void 0 : owner.hiddenColumns.value) == null ? void 0 : _a.children;
11276
+ var _a, _b, _c;
11277
+ const children = isSubColumn.value ? (_b = (_a = parent == null ? void 0 : parent.vnode) == null ? void 0 : _a.el) == null ? void 0 : _b.children : (_c = owner == null ? void 0 : owner.hiddenColumns.value) == null ? void 0 : _c.children;
11156
11278
  const columnIndex = getColumnIndex(children || [], instance.vnode.el);
11157
11279
  columnIndex > -1 && (owner == null ? void 0 : owner.store.insertColumn(column2, isSubColumn.value ? parent.columnConfig : null));
11158
11280
  if (typeof props.checkable === "function") {
@@ -11176,7 +11298,7 @@ var Column = defineComponent({
11176
11298
  column: {},
11177
11299
  $index: -1
11178
11300
  });
11179
- return createVNode("div", null, [Array.isArray(defaultSlot) ? defaultSlot.filter((child) => child.type.name === "DColumn").map((child) => createVNode(Fragment, null, [child])) : createVNode("div", null, null)]);
11301
+ return createVNode("div", null, [defaultSlot && Array.isArray(defaultSlot) ? defaultSlot.filter((child) => child.type.name === "DColumn").map((child) => createVNode(Fragment, null, [child])) : createVNode("div", null, null)]);
11180
11302
  };
11181
11303
  }
11182
11304
  });