qidian-vue-ui 2.0.0-beta.9 → 2.0.0

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.
@@ -14,4 +14,4 @@ export declare function createVModelBinding(context: Record<string, unknown>, vM
14
14
  'onUpdate:modelValue': (value: unknown) => void;
15
15
  };
16
16
  export declare function resolveVModelBinding(context: Record<string, unknown>, vModel?: string, defaultValue?: unknown): Record<string, unknown>;
17
- export declare function wrapFunctionalRenderer(fn: Component): import("vue").DefineComponent<{}, () => unknown, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
+ export declare function wrapFunctionalRenderer(fn: Component): Component;
@@ -41,8 +41,11 @@ function resolveVModelBinding(context, vModel, defaultValue) {
41
41
  return bindings;
42
42
  }
43
43
  const RENDERER_INTERNAL_KEYS = /* @__PURE__ */ new Set(["context", "config", "crudMode", "fnInjectCtx"]);
44
+ const functionalRendererCache = /* @__PURE__ */ new WeakMap();
44
45
  function wrapFunctionalRenderer(fn) {
45
- return defineComponent({
46
+ const cached = functionalRendererCache.get(fn);
47
+ if (cached) return cached;
48
+ const wrapped = defineComponent({
46
49
  name: "QdFunctionalRenderer",
47
50
  inheritAttrs: false,
48
51
  setup(_props, { attrs }) {
@@ -60,6 +63,8 @@ function wrapFunctionalRenderer(fn) {
60
63
  };
61
64
  }
62
65
  });
66
+ functionalRendererCache.set(fn, wrapped);
67
+ return wrapped;
63
68
  }
64
69
  export {
65
70
  createVModelBinding,
@@ -39,6 +39,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
39
39
  type: PropType<TableEditableCellPropsParams<TableRowData>["updateEditedCellValue"]>;
40
40
  required: true;
41
41
  };
42
+ notifyDataChange: {
43
+ type: PropType<() => void>;
44
+ required: true;
45
+ };
42
46
  sourceRow: {
43
47
  type: PropType<TableRowData>;
44
48
  default: undefined;
@@ -79,6 +83,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
79
83
  type: PropType<TableEditableCellPropsParams<TableRowData>["updateEditedCellValue"]>;
80
84
  required: true;
81
85
  };
86
+ notifyDataChange: {
87
+ type: PropType<() => void>;
88
+ required: true;
89
+ };
82
90
  sourceRow: {
83
91
  type: PropType<TableRowData>;
84
92
  default: undefined;
@@ -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, onChange) {
16
+ function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellValue, notifyDataChange, onChange) {
17
17
  const proxies = /* @__PURE__ */ new WeakMap();
18
18
  function syncValue(path, value) {
19
19
  const editedRow = getEditedRow();
@@ -28,8 +28,11 @@ function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellV
28
28
  onChange?.(value);
29
29
  set(sourceRow, path, value);
30
30
  if (editedRow !== sourceRow) set(editedRow, path, value);
31
+ notifyDataChange();
31
32
  });
33
+ return;
32
34
  }
35
+ notifyDataChange();
33
36
  }
34
37
  function wrap(target, parentPath = "") {
35
38
  const cachedByPath = proxies.get(target) ?? /* @__PURE__ */ new Map();
@@ -58,6 +61,7 @@ function createRowEditContext(sourceRow, getEditedRow, colKey, updateEditedCellV
58
61
  [path]: void 0
59
62
  });
60
63
  if (path === colKey) updateEditedCellValue(void 0);
64
+ notifyDataChange();
61
65
  return result;
62
66
  }
63
67
  });
@@ -106,6 +110,10 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
106
110
  type: Function,
107
111
  required: true
108
112
  },
113
+ notifyDataChange: {
114
+ type: Function,
115
+ required: true
116
+ },
109
117
  sourceRow: {
110
118
  type: Object,
111
119
  default: void 0
@@ -114,7 +122,7 @@ const QdServiceTableEditCell = /* @__PURE__ */ defineComponent({
114
122
  setup(props, {
115
123
  attrs
116
124
  }) {
117
- const currentContext = computed(() => createRowEditContext(props.sourceRow ?? props.row, () => props.row, props.colKey, props.updateEditedCellValue, (value) => {
125
+ const currentContext = computed(() => createRowEditContext(props.sourceRow ?? props.row, () => props.row, props.colKey, props.updateEditedCellValue, props.notifyDataChange, (value) => {
118
126
  if (typeof attrs.onChange === "function") attrs.onChange(value);
119
127
  }));
120
128
  const {
@@ -1,58 +1,58 @@
1
- .qd-service-table[data-v-6da291b2] {
1
+ .qd-service-table[data-v-ae90af38] {
2
2
  height: 100%;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  }
6
- .qd-service-table[data-v-6da291b2] > .t-table__content {
6
+ .qd-service-table[data-v-ae90af38] > .t-table__content {
7
7
  flex: 1;
8
8
  }
9
- .qd-service-table[data-v-6da291b2] .t-table__tree-col:not(:has(.t-table__tree-op-icon)) {
9
+ .qd-service-table[data-v-ae90af38] .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-6da291b2] .t-table__tree-leaf-node .t-table__tree-op-icon:empty {
12
+ .qd-service-table[data-v-ae90af38] .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-6da291b2] .t-affix > .t-table__affixed-header-elm-wrap,
16
- .qd-service-table[data-v-6da291b2] .t-affix > .t-table__scrollbar--obvious {
17
- transform: var(--v22394fa6);
15
+ .qd-service-table[data-v-ae90af38] .t-affix > .t-table__affixed-header-elm-wrap,
16
+ .qd-service-table[data-v-ae90af38] .t-affix > .t-table__scrollbar--obvious {
17
+ transform: var(--v42be12ab);
18
18
  }
19
- .qd-service-table--horizontal-bar-static[data-v-6da291b2] .t-table__scrollbar--obvious {
19
+ .qd-service-table--horizontal-bar-static[data-v-ae90af38] .t-table__scrollbar--obvious {
20
20
  visibility: hidden;
21
21
  pointer-events: none;
22
22
  }
23
- .qd-service-table[data-v-6da291b2] .t-table__affixed-header-elm-wrap {
23
+ .qd-service-table[data-v-ae90af38] .t-table__affixed-header-elm-wrap {
24
24
  height: auto !important;
25
25
  }
26
- .qd-service-table[data-v-6da291b2] .t-table__affixed-header-elm {
26
+ .qd-service-table[data-v-ae90af38] .t-table__affixed-header-elm {
27
27
  position: relative;
28
28
  scrollbar-width: none;
29
29
  }
30
- .qd-service-table[data-v-6da291b2] .t-table__affixed-header-elm::-webkit-scrollbar {
30
+ .qd-service-table[data-v-ae90af38] .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-6da291b2] .t-table__virtual-scroll-cursor + table {
35
+ .qd-service-table[data-v-ae90af38] .t-table__virtual-scroll-cursor + table {
36
36
  border-collapse: separate;
37
37
  }
38
- .qd-service-table[data-v-6da291b2] .t-table__expanded-row-inner {
38
+ .qd-service-table[data-v-ae90af38] .t-table__expanded-row-inner {
39
39
  position: sticky;
40
40
  left: 0;
41
- width: var(--f583163c) !important;
41
+ width: var(--cf433440) !important;
42
42
  }
43
- .qd-service-table[data-v-6da291b2] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
43
+ .qd-service-table[data-v-ae90af38] .t-table__cell-wrap > *:not(.t-switch):not(.t-tag):not(.t-icon):not(.qd-file-icon) {
44
44
  width: 100%;
45
45
  }
46
- .qd-service-table[data-v-6da291b2] .qd-service-table__non-editable-col {
47
- background-color: color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent);
46
+ .qd-service-table[data-v-ae90af38] .qd-service-table__non-editable-col {
47
+ background-color: color-mix(in srgb, var(--td-bg-color-component) 50%, transparent);
48
48
  }
49
- .qd-service-table[data-v-6da291b2] .qd-service-table__non-editable-col:is(
49
+ .qd-service-table[data-v-ae90af38] .qd-service-table__non-editable-col:is(
50
50
  .t-table__cell--fixed-left,
51
51
  .t-table__cell--fixed-right
52
52
  ) {
53
53
  background-color: inherit;
54
54
  background-image: linear-gradient(color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent), color-mix(in srgb, var(--td-bg-color-secondarycontainer) 50%, transparent));
55
55
  }
56
- .qd-service-table--disable-horizontal-scroll[data-v-6da291b2] colgroup > col {
56
+ .qd-service-table--disable-horizontal-scroll[data-v-ae90af38] colgroup > col {
57
57
  width: auto !important;
58
58
  }
@@ -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-6da291b2"]]);
5
+ const QdServiceTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ae90af38"]]);
6
6
  export {
7
7
  QdServiceTable as default
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import './index.css'
2
2
  import { defineComponent, mergeDefaults, useCssVars, computed, ref, useSlots, useTemplateRef, shallowRef, inject, getCurrentInstance, reactive, createVNode, watch, nextTick, onMounted, onActivated, onDeactivated, onBeforeUnmount, withDirectives, createBlock, openBlock, resolveDynamicComponent, unref, mergeProps, isRef, createSlots, withCtx, renderList, renderSlot, normalizeProps, guardReactiveProps, render, h } from "vue";
3
3
  import { useVModels, useElementSize, useElementBounding, useIntersectionObserver } from "../../../node_modules/.pnpm/@vueuse_core@14.2.0_vue@3.5.26_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.mjs";
4
- import { useTimer, easyCopy, isEmpty, suspectedWrapperPromise, useServicePagination, createExposeProxy, resizeDirective, getScrollEl } from "qidian-shared";
4
+ import { useActivated, useTimer, easyCopy, isEmpty, suspectedWrapperPromise, useServicePagination, createExposeProxy, resizeDirective, getScrollEl } from "qidian-shared";
5
5
  import { LoadingIcon, AddRectangleIcon, MinusRectangleIcon } from "tdesign-icons-vue-next";
6
6
  import { EnhancedTable, Table, Empty } from "tdesign-vue-next";
7
7
  import { useModal } from "../../../hooks/useModal.mjs";
@@ -318,8 +318,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
318
318
  emit: __emit
319
319
  }) {
320
320
  useCssVars((_ctx) => ({
321
- "v22394fa6": affixedHeaderTransform.value,
322
- "f583163c": expandedRowWidth.value
321
+ "v42be12ab": affixedHeaderTransform.value,
322
+ "cf433440": expandedRowWidth.value
323
323
  }));
324
324
  const props = __props;
325
325
  const emit = __emit;
@@ -373,6 +373,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
373
373
  const treeLoadIds = ref([]);
374
374
  const editingCells = shallowRef([]);
375
375
  const activeEditingCell = shallowRef();
376
+ let dataChangePending = false;
377
+ const {
378
+ activated
379
+ } = useActivated();
376
380
  const formItemColumns = computed(() => flattenFormItemColumns(props.columns || []));
377
381
  const editableColumns = computed(() => flattenEditableColumns(props.columns || []));
378
382
  const parentAddBeforeSubmitQueue = inject(PROVIDE_FORM_ADD_BEFORE_SUBMIT_QUEUE, void 0);
@@ -387,6 +391,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
387
391
  message: context.firstError
388
392
  };
389
393
  });
394
+ function notifyDataChange() {
395
+ if (dataChangePending) return;
396
+ dataChangePending = true;
397
+ queueMicrotask(() => {
398
+ dataChangePending = false;
399
+ data.value = [...data.value];
400
+ });
401
+ }
390
402
  const isVirtualScroll = computed(() => props.scroll?.type === "virtual");
391
403
  const currentInstance = getCurrentInstance();
392
404
  const offscreenAppContext = currentInstance ? {
@@ -1054,6 +1066,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1054
1066
  return slots["cell-empty-content"]?.(context) ?? value;
1055
1067
  }
1056
1068
  function handleDocumentKeydown(event) {
1069
+ if (!activated.value) return;
1057
1070
  if (event.key !== "Escape" || !activeEditingCell.value || event.defaultPrevented) return;
1058
1071
  const target = event.target;
1059
1072
  if (target?.closest(".t-select-input--popup-visible, .t-popup__content, .t-dialog, .t-drawer, .t-image-viewer, .qd-multi-file-viewer")) {
@@ -1062,13 +1075,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1062
1075
  exitActiveEditingCell();
1063
1076
  }
1064
1077
  function handleDocumentClick(event) {
1065
- if (!editingCells.value.length) return;
1066
- const target = event.target;
1067
- if (!target) return;
1068
- if (target.closest("td")) return;
1069
- if (target.closest(".t-popup, .t-dialog, .t-drawer, .t-image-viewer, .qd-multi-file-viewer, [data-popper-placement]")) {
1070
- return;
1071
- }
1078
+ if (!activated.value || !editingCells.value.length) return;
1079
+ const hasVisibleDialog = Array.from(document.querySelectorAll(".t-dialog")).some((element) => element.getClientRects().length);
1080
+ const hasVisibleDrawer = Array.from(document.querySelectorAll(".t-drawer")).some((element) => element.classList.contains("t-drawer--open") || element.getAnimations({
1081
+ subtree: true
1082
+ }).some((animation) => animation.playState === "running"));
1083
+ if (hasVisibleDialog || hasVisibleDrawer) return;
1084
+ const insideInteractiveArea = event.composedPath().some((target) => target instanceof Element && target.matches("td, .t-popup, .qd-dialog, .t-dialog, .t-drawer, .t-image-viewer, .qd-multi-file-viewer, [data-popper-placement]"));
1085
+ if (insideInteractiveArea) return;
1072
1086
  void exitAllEditingCells();
1073
1087
  }
1074
1088
  function getFirstValidationError(results) {
@@ -1521,6 +1535,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1521
1535
  label: column.title,
1522
1536
  sourceRow: props.data?.find((item) => getRowValue(item) === rowValue) ?? data.value.find((item) => getRowValue(item) === rowValue) ?? row,
1523
1537
  updateEditedCellValue: context.updateEditedCellValue,
1538
+ notifyDataChange,
1524
1539
  lazy: resolveFormItemLazy(column),
1525
1540
  active: !!activeEditingCell.value && isSameEditingCell(activeEditingCell.value, {
1526
1541
  row,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qidian-vue-ui",
3
- "version": "2.0.0-beta.9",
3
+ "version": "2.0.0",
4
4
  "description": "基于 TDesign 的 QiDian Vue UI 组件库",
5
5
  "author": "qidian",
6
6
  "license": "MIT",