qidian-vue-ui 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -13,7 +13,7 @@ function isProxyable(value) {
13
13
  const prototype = Object.getPrototypeOf(value);
14
14
  return prototype === Object.prototype || prototype === null;
15
15
  }
16
- function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellValue) {
16
+ function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellValue, onChange) {
17
17
  const proxies = /* @__PURE__ */ new WeakMap();
18
18
  function syncValue(path, value) {
19
19
  const editedRow = getEditedRow();
@@ -22,7 +22,14 @@ function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellV
22
22
  isUpdateCurrentRow: true,
23
23
  [path]: value
24
24
  });
25
- if (path === colKey) updateEditedCellValue(value);
25
+ if (path === colKey) {
26
+ updateEditedCellValue(value);
27
+ queueMicrotask(() => {
28
+ onChange?.(value);
29
+ set(sourceRow, path, value);
30
+ if (editedRow !== sourceRow) set(editedRow, path, value);
31
+ });
32
+ }
26
33
  }
27
34
  function wrap(target, parentPath = "") {
28
35
  const cachedByPath = proxies.get(target) ?? /* @__PURE__ */ new Map();
@@ -107,7 +114,9 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
107
114
  setup(props, {
108
115
  attrs
109
116
  }) {
110
- const currentContext = computed(() => createRowEditContext(props.sourceRow ?? props.row, () => props.row, props.colKey, props.updateEditedCellValue));
117
+ const currentContext = computed(() => createRowEditContext(props.sourceRow ?? props.row, () => props.row, props.colKey, props.updateEditedCellValue, (value) => {
118
+ if (typeof attrs.onChange === "function") attrs.onChange(value);
119
+ }));
111
120
  const {
112
121
  t
113
122
  } = useConfig("form");
@@ -1,43 +1,46 @@
1
- .qd-service-table[data-v-1dbd9e8f] {
1
+ .qd-service-table[data-v-c56c6716] {
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  }
6
- .qd-service-table[data-v-1dbd9e8f] > .t-table__content {
6
+ .qd-service-table[data-v-c56c6716] > .t-table__content {
7
7
  flex: 1;
8
8
  }
9
- .qd-service-table[data-v-1dbd9e8f] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
9
+ .qd-service-table[data-v-c56c6716] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
10
10
  margin-left: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
11
11
  }
12
- .qd-service-table[data-v-1dbd9e8f] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
12
+ .qd-service-table[data-v-c56c6716] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
13
13
  width: calc(var(--td-font-size-body-large) + var(--td-comp-margin-s));
14
14
  }
15
- .qd-service-table[data-v-1dbd9e8f] .t-affix > .t-table__affixed-header-elm-wrap,
16
- .qd-service-table[data-v-1dbd9e8f] .t-affix > .t-table__scrollbar--obvious {
17
- transform: var(--bc68c016);
15
+ .qd-service-table[data-v-c56c6716] .t-affix > .t-table__affixed-header-elm-wrap,
16
+ .qd-service-table[data-v-c56c6716] .t-affix > .t-table__scrollbar--obvious {
17
+ transform: var(--v05eb2f2a);
18
18
  }
19
- .qd-service-table--horizontal-bar-static[data-v-1dbd9e8f] .t-table__scrollbar--obvious {
19
+ .qd-service-table--horizontal-bar-static[data-v-c56c6716] .t-table__scrollbar--obvious {
20
20
  visibility: hidden;
21
21
  pointer-events: none;
22
22
  }
23
- .qd-service-table[data-v-1dbd9e8f] .t-table__affixed-header-elm-wrap {
23
+ .qd-service-table[data-v-c56c6716] .t-table__affixed-header-elm-wrap {
24
24
  height: auto !important;
25
25
  }
26
- .qd-service-table[data-v-1dbd9e8f] .t-table__affixed-header-elm {
26
+ .qd-service-table[data-v-c56c6716] .t-table__affixed-header-elm {
27
27
  position: relative;
28
28
  scrollbar-width: none;
29
29
  }
30
- .qd-service-table[data-v-1dbd9e8f] .t-table__affixed-header-elm::-webkit-scrollbar {
30
+ .qd-service-table[data-v-c56c6716] .t-table__affixed-header-elm::-webkit-scrollbar {
31
31
  display: none;
32
32
  width: 0;
33
33
  height: 0;
34
34
  }
35
- .qd-service-table[data-v-1dbd9e8f] .t-table__virtual-scroll-cursor + table {
35
+ .qd-service-table[data-v-c56c6716] .t-table__virtual-scroll-cursor + table {
36
36
  border-collapse: separate;
37
37
  }
38
- .qd-service-table[data-v-1dbd9e8f] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
38
+ .qd-service-table[data-v-c56c6716] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
39
39
  width: 100%;
40
40
  }
41
- .qd-service-table--disable-horizontal-scroll[data-v-1dbd9e8f] colgroup > col {
41
+ .qd-service-table[data-v-c56c6716] .qd-service-table__non-editable-col {
42
+ background-color: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent);
43
+ }
44
+ .qd-service-table--disable-horizontal-scroll[data-v-c56c6716] colgroup > col {
42
45
  width: auto !important;
43
46
  }
@@ -2,7 +2,7 @@ import './index.css'
2
2
  import _sfc_main from "./index.vue2.mjs";
3
3
  /* empty css */
4
4
  import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
5
- const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1dbd9e8f"]]);
5
+ const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c56c6716"]]);
6
6
  export {
7
7
  QdServiceTable as default
8
8
  };
@@ -318,7 +318,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
318
318
  emit: __emit
319
319
  }) {
320
320
  useCssVars((_ctx) => ({
321
- "bc68c016": affixedHeaderTransform.value
321
+ "v05eb2f2a": affixedHeaderTransform.value
322
322
  }));
323
323
  const props = __props;
324
324
  const emit = __emit;
@@ -934,9 +934,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
934
934
  const formItem = column.formItem;
935
935
  if (!formItem) return false;
936
936
  if (formItem.lazy !== void 0) return formItem.lazy;
937
- if (getQdFormComponentName(formItem.component).includes("upload")) return false;
937
+ if (/upload|switch|radio|checkbox/.test(getQdFormComponentName(formItem.component))) {
938
+ return false;
939
+ }
938
940
  return props.lazyForm;
939
941
  }
942
+ function resolveFormItemIfRender(column, row) {
943
+ const formItem = column.formItem;
944
+ const ifRender = formItem?.ifRender;
945
+ if (!formItem || isEmpty(ifRender)) return true;
946
+ if (typeof ifRender === "function" && ifRender.__qdCompute) {
947
+ return ifRender(row, formItem.crudMode);
948
+ }
949
+ return ifRender !== false;
950
+ }
940
951
  function resolveFormItemVirtualRender(column) {
941
952
  const formItem = column.formItem;
942
953
  if (!formItem) return false;
@@ -1437,7 +1448,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1437
1448
  children: wrapFormItemColumns(children)
1438
1449
  } : {}
1439
1450
  };
1440
- if (!formItem) return reColumn;
1451
+ const columnClassName = reColumn.className === void 0 ? [] : Array.isArray(reColumn.className) ? reColumn.className : [reColumn.className];
1452
+ if (!formItem) {
1453
+ if (!children && formItemColumns.value.length) {
1454
+ reColumn.className = [...columnClassName, (context) => context.type === "td" ? "qd-service-table__non-editable-col" : ""];
1455
+ }
1456
+ return reColumn;
1457
+ }
1441
1458
  const columnAttrs = column.attrs;
1442
1459
  reColumn.attrs = (context) => {
1443
1460
  const attrs = typeof columnAttrs === "function" ? columnAttrs(context) : columnAttrs;
@@ -1454,7 +1471,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1454
1471
  }
1455
1472
  };
1456
1473
  };
1457
- reColumn.className = reColumn.className === void 0 ? "qd-service-table__form-item-col" : [reColumn.className, "qd-service-table__form-item-col"];
1474
+ reColumn.className = [...columnClassName, "qd-service-table__form-item-col", (context) => context.type === "td" && !resolveFormItemIfRender(column, context.row) ? "qd-service-table__non-editable-col" : ""];
1458
1475
  const generatedEdit = {
1459
1476
  component: QdServiceTableEditCell,
1460
1477
  showEditIcon: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",