@nokecy/qc-ui 1.1.40 → 1.1.42

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.
@@ -6,6 +6,31 @@ import { ObservableColumnSource } from './interface';
6
6
  declare const isColumnComponent: (schema: Schema) => boolean;
7
7
  declare const useArrayTableSources: () => ObservableColumnSource[];
8
8
  declare const useArrayTableActions: () => ObservableColumnSource[];
9
+ /**
10
+ * 懒挂载单元格渲染器(可编辑列)。
11
+ *
12
+ * 已有行的可编辑格被 Editable 装饰器默认转成 readPretty 只读文本态(点击才进编辑),
13
+ * 但仍挂着完整 Formily 树——这是行多列多滚动卡的主因。本渲染器:
14
+ * - 新增行(_isNew,保持编辑态需即时校验) 或 已被激活(点击/导航进过)的格 -> 挂 AgField 全树;
15
+ * - 其余(存量行、没碰过) -> 只渲染廉价纯文本(复用 readOnlyFormatters),不挂 Formily 树。
16
+ *
17
+ * 激活态存放在 AG-Grid context.activeCells(Set),由 index.tsx 在点击/键盘导航时写入并 refreshCells。
18
+ * 「挂了不卸」:一旦激活保持挂载(直到行被虚拟化销毁),不做失焦退回,避开一堆边界。
19
+ *
20
+ * 校验安全:未碰过的存量格本就是 readPretty、本就不参与校验,不挂树校验语义零变化。@author nokecy
21
+ */
22
+ declare const LazyAgField: (params: any) => React.JSX.Element;
23
+ /**
24
+ * 反应式只读文本渲染器(列级 readPretty 在「可编辑表」里的展示列)。
25
+ *
26
+ * 只读纯文本快路径(valueFormatter)经 AG-Grid 缓存 params.value 取值,setValuesIn 程序化原地改值
27
+ * 不会刷新该格 → 自动带出的外码/描述等只读展示列空白。本渲染器 Observer 读可观察 record[dataKey],
28
+ * 保持 readPretty 纯文本观感(不挂 Formily 树、不可点编辑),但能跟随 setValuesIn 即时刷新。
29
+ *
30
+ * 仅用于「可编辑表的列级 readPretty 展示列」;「整表 readPretty」(明细/详情页,数据经 setValues 整体
31
+ * 加载,行引用整体替换→AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
32
+ */
33
+ declare const LazyReadOnlyText: (params: any) => React.JSX.Element;
9
34
  declare const buildArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
10
35
  declare const useAddition: () => React.JSX.Element | null;
11
- export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
36
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField, LazyReadOnlyText };
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useArrayTableSources = exports.useArrayTableActions = exports.useAddition = exports.isColumnComponent = exports.buildArrayTableColumns = void 0;
7
+ exports.useArrayTableSources = exports.useArrayTableActions = exports.useAddition = exports.isColumnComponent = exports.buildArrayTableColumns = exports.LazyReadOnlyText = exports.LazyAgField = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _react2 = require("@formily/react");
10
10
  var _shared = require("@formily/shared");
@@ -154,8 +154,8 @@ var AgField = function AgField(_ref) {
154
154
  *
155
155
  * 校验安全:未碰过的存量格本就是 readPretty、本就不参与校验,不挂树校验语义零变化。@author nokecy
156
156
  */
157
- var LazyAgField = function LazyAgField(params) {
158
- var _context$activeCells, _context$activeCells$;
157
+ var LazyAgField = exports.LazyAgField = function LazyAgField(params) {
158
+ var _context$activeCells, _context$activeCells$, _fieldSchema$name;
159
159
  var value = params.value,
160
160
  record = params.data,
161
161
  dataSource = params.dataSource,
@@ -179,19 +179,64 @@ var LazyAgField = function LazyAgField(params) {
179
179
  node: node
180
180
  });
181
181
  }
182
- var text = formatter ? formatter(value, {
183
- columnProps: columnProps,
184
- fieldSchema: fieldSchema
185
- }) : value == null ? '' : String(value);
186
- // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
187
- return /*#__PURE__*/_react.default.createElement("span", {
188
- className: "ag-array-table-lazy-text",
189
- style: {
190
- display: 'inline-block',
191
- width: '100%',
192
- cursor: 'text'
193
- }
194
- }, text);
182
+
183
+ // Observer 包裹纯文本:让未激活的廉价文本格反应式跟随内层 Formily 字段值。
184
+ // record 即 field.value[index] 的可观察对象;在 Observer 里按内层字段名直接读 record[dataKey]
185
+ // (而非 AG-Grid 渲染时快照的 params.value)建立依赖后,onFieldValueChange/setValuesIn 程序化原地
186
+ // 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
187
+ // 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
188
+ var dataKey = (_fieldSchema$name = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name !== void 0 ? _fieldSchema$name : colDef === null || colDef === void 0 ? void 0 : colDef.field;
189
+ return /*#__PURE__*/_react.default.createElement(_react2.Observer, null, function () {
190
+ var liveValue = dataKey != null && record ? record[dataKey] : value;
191
+ var text = formatter ? formatter(liveValue, {
192
+ columnProps: columnProps,
193
+ fieldSchema: fieldSchema
194
+ }) : liveValue == null ? '' : String(liveValue);
195
+ // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
196
+ return /*#__PURE__*/_react.default.createElement("span", {
197
+ className: "ag-array-table-lazy-text",
198
+ style: {
199
+ display: 'inline-block',
200
+ width: '100%',
201
+ cursor: 'text'
202
+ }
203
+ }, text);
204
+ });
205
+ };
206
+
207
+ /**
208
+ * 反应式只读文本渲染器(列级 readPretty 在「可编辑表」里的展示列)。
209
+ *
210
+ * 只读纯文本快路径(valueFormatter)经 AG-Grid 缓存 params.value 取值,setValuesIn 程序化原地改值
211
+ * 不会刷新该格 → 自动带出的外码/描述等只读展示列空白。本渲染器 Observer 读可观察 record[dataKey],
212
+ * 保持 readPretty 纯文本观感(不挂 Formily 树、不可点编辑),但能跟随 setValuesIn 即时刷新。
213
+ *
214
+ * 仅用于「可编辑表的列级 readPretty 展示列」;「整表 readPretty」(明细/详情页,数据经 setValues 整体
215
+ * 加载,行引用整体替换→AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
216
+ */
217
+ var LazyReadOnlyText = exports.LazyReadOnlyText = function LazyReadOnlyText(params) {
218
+ var _fieldSchema$name2;
219
+ var value = params.value,
220
+ record = params.data,
221
+ colDef = params.colDef,
222
+ formatter = params.formatter,
223
+ columnProps = params.columnProps,
224
+ fieldSchema = params.fieldSchema;
225
+ var dataKey = (_fieldSchema$name2 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name2 !== void 0 ? _fieldSchema$name2 : colDef === null || colDef === void 0 ? void 0 : colDef.field;
226
+ return /*#__PURE__*/_react.default.createElement(_react2.Observer, null, function () {
227
+ var liveValue = dataKey != null && record ? record[dataKey] : value;
228
+ var text = formatter ? formatter(liveValue, {
229
+ columnProps: columnProps,
230
+ fieldSchema: fieldSchema
231
+ }) : liveValue == null ? '' : String(liveValue);
232
+ return /*#__PURE__*/_react.default.createElement("span", {
233
+ className: "ag-array-table-readonly-text",
234
+ style: {
235
+ display: 'inline-block',
236
+ width: '100%'
237
+ }
238
+ }, text);
239
+ });
195
240
  };
196
241
 
197
242
  // 在 Column 的子 schema 里递归找到内层数据字段(可读 x-component / x-pattern / x-reactions / enum) @author nokecy
@@ -296,6 +341,21 @@ var buildArrayTableColumns = exports.buildArrayTableColumns = function buildArra
296
341
 
297
342
  // ① 只读纯文本
298
343
  if (readOnly && formatter) {
344
+ // 列级 readPretty 在「可编辑表」里是展示列(值可能被 setValuesIn 自动带出),静态 valueFormatter
345
+ // 读 AG-Grid 缓存值不刷新 → 反应式只读渲染。整表 readPretty(明细/详情页,数据 setValues 整体加载、
346
+ // 行引用整体替换、AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
347
+ if (arrayPattern !== 'readPretty') {
348
+ return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
349
+ valueGetter: valueGetter
350
+ } : {}), {}, {
351
+ cellRenderer: LazyReadOnlyText,
352
+ cellRendererParams: {
353
+ formatter: formatter,
354
+ columnProps: columnProps,
355
+ fieldSchema: dataField
356
+ }
357
+ }));
358
+ }
299
359
  return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
300
360
  valueGetter: valueGetter
301
361
  } : {}), {}, {
@@ -6,6 +6,31 @@ import { ObservableColumnSource } from './interface';
6
6
  declare const isColumnComponent: (schema: Schema) => boolean;
7
7
  declare const useArrayTableSources: () => ObservableColumnSource[];
8
8
  declare const useArrayTableActions: () => ObservableColumnSource[];
9
+ /**
10
+ * 懒挂载单元格渲染器(可编辑列)。
11
+ *
12
+ * 已有行的可编辑格被 Editable 装饰器默认转成 readPretty 只读文本态(点击才进编辑),
13
+ * 但仍挂着完整 Formily 树——这是行多列多滚动卡的主因。本渲染器:
14
+ * - 新增行(_isNew,保持编辑态需即时校验) 或 已被激活(点击/导航进过)的格 -> 挂 AgField 全树;
15
+ * - 其余(存量行、没碰过) -> 只渲染廉价纯文本(复用 readOnlyFormatters),不挂 Formily 树。
16
+ *
17
+ * 激活态存放在 AG-Grid context.activeCells(Set),由 index.tsx 在点击/键盘导航时写入并 refreshCells。
18
+ * 「挂了不卸」:一旦激活保持挂载(直到行被虚拟化销毁),不做失焦退回,避开一堆边界。
19
+ *
20
+ * 校验安全:未碰过的存量格本就是 readPretty、本就不参与校验,不挂树校验语义零变化。@author nokecy
21
+ */
22
+ declare const LazyAgField: (params: any) => React.JSX.Element;
23
+ /**
24
+ * 反应式只读文本渲染器(列级 readPretty 在「可编辑表」里的展示列)。
25
+ *
26
+ * 只读纯文本快路径(valueFormatter)经 AG-Grid 缓存 params.value 取值,setValuesIn 程序化原地改值
27
+ * 不会刷新该格 → 自动带出的外码/描述等只读展示列空白。本渲染器 Observer 读可观察 record[dataKey],
28
+ * 保持 readPretty 纯文本观感(不挂 Formily 树、不可点编辑),但能跟随 setValuesIn 即时刷新。
29
+ *
30
+ * 仅用于「可编辑表的列级 readPretty 展示列」;「整表 readPretty」(明细/详情页,数据经 setValues 整体
31
+ * 加载,行引用整体替换→AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
32
+ */
33
+ declare const LazyReadOnlyText: (params: any) => React.JSX.Element;
9
34
  declare const buildArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
10
35
  declare const useAddition: () => React.JSX.Element | null;
11
- export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
36
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField, LazyReadOnlyText };
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
10
  import React from 'react';
11
- import { useField, useFieldSchema, RecursionField } from '@formily/react';
11
+ import { useField, useFieldSchema, RecursionField, Observer } from '@formily/react';
12
12
  import { isArr } from '@formily/shared';
13
13
  import ArrayBase from "./arrayBase";
14
14
  import { getReadOnlyFormatter } from "./readOnlyFormatters";
@@ -148,7 +148,7 @@ var AgField = function AgField(_ref) {
148
148
  * 校验安全:未碰过的存量格本就是 readPretty、本就不参与校验,不挂树校验语义零变化。@author nokecy
149
149
  */
150
150
  var LazyAgField = function LazyAgField(params) {
151
- var _context$activeCells, _context$activeCells$;
151
+ var _context$activeCells, _context$activeCells$, _fieldSchema$name;
152
152
  var value = params.value,
153
153
  record = params.data,
154
154
  dataSource = params.dataSource,
@@ -172,19 +172,64 @@ var LazyAgField = function LazyAgField(params) {
172
172
  node: node
173
173
  });
174
174
  }
175
- var text = formatter ? formatter(value, {
176
- columnProps: columnProps,
177
- fieldSchema: fieldSchema
178
- }) : value == null ? '' : String(value);
179
- // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
180
- return /*#__PURE__*/React.createElement("span", {
181
- className: "ag-array-table-lazy-text",
182
- style: {
183
- display: 'inline-block',
184
- width: '100%',
185
- cursor: 'text'
186
- }
187
- }, text);
175
+
176
+ // Observer 包裹纯文本:让未激活的廉价文本格反应式跟随内层 Formily 字段值。
177
+ // record 即 field.value[index] 的可观察对象;在 Observer 里按内层字段名直接读 record[dataKey]
178
+ // (而非 AG-Grid 渲染时快照的 params.value)建立依赖后,onFieldValueChange/setValuesIn 程序化原地
179
+ // 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
180
+ // 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
181
+ var dataKey = (_fieldSchema$name = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name !== void 0 ? _fieldSchema$name : colDef === null || colDef === void 0 ? void 0 : colDef.field;
182
+ return /*#__PURE__*/React.createElement(Observer, null, function () {
183
+ var liveValue = dataKey != null && record ? record[dataKey] : value;
184
+ var text = formatter ? formatter(liveValue, {
185
+ columnProps: columnProps,
186
+ fieldSchema: fieldSchema
187
+ }) : liveValue == null ? '' : String(liveValue);
188
+ // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
189
+ return /*#__PURE__*/React.createElement("span", {
190
+ className: "ag-array-table-lazy-text",
191
+ style: {
192
+ display: 'inline-block',
193
+ width: '100%',
194
+ cursor: 'text'
195
+ }
196
+ }, text);
197
+ });
198
+ };
199
+
200
+ /**
201
+ * 反应式只读文本渲染器(列级 readPretty 在「可编辑表」里的展示列)。
202
+ *
203
+ * 只读纯文本快路径(valueFormatter)经 AG-Grid 缓存 params.value 取值,setValuesIn 程序化原地改值
204
+ * 不会刷新该格 → 自动带出的外码/描述等只读展示列空白。本渲染器 Observer 读可观察 record[dataKey],
205
+ * 保持 readPretty 纯文本观感(不挂 Formily 树、不可点编辑),但能跟随 setValuesIn 即时刷新。
206
+ *
207
+ * 仅用于「可编辑表的列级 readPretty 展示列」;「整表 readPretty」(明细/详情页,数据经 setValues 整体
208
+ * 加载,行引用整体替换→AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
209
+ */
210
+ var LazyReadOnlyText = function LazyReadOnlyText(params) {
211
+ var _fieldSchema$name2;
212
+ var value = params.value,
213
+ record = params.data,
214
+ colDef = params.colDef,
215
+ formatter = params.formatter,
216
+ columnProps = params.columnProps,
217
+ fieldSchema = params.fieldSchema;
218
+ var dataKey = (_fieldSchema$name2 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name2 !== void 0 ? _fieldSchema$name2 : colDef === null || colDef === void 0 ? void 0 : colDef.field;
219
+ return /*#__PURE__*/React.createElement(Observer, null, function () {
220
+ var liveValue = dataKey != null && record ? record[dataKey] : value;
221
+ var text = formatter ? formatter(liveValue, {
222
+ columnProps: columnProps,
223
+ fieldSchema: fieldSchema
224
+ }) : liveValue == null ? '' : String(liveValue);
225
+ return /*#__PURE__*/React.createElement("span", {
226
+ className: "ag-array-table-readonly-text",
227
+ style: {
228
+ display: 'inline-block',
229
+ width: '100%'
230
+ }
231
+ }, text);
232
+ });
188
233
  };
189
234
 
190
235
  // 在 Column 的子 schema 里递归找到内层数据字段(可读 x-component / x-pattern / x-reactions / enum) @author nokecy
@@ -289,6 +334,21 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
289
334
 
290
335
  // ① 只读纯文本
291
336
  if (readOnly && formatter) {
337
+ // 列级 readPretty 在「可编辑表」里是展示列(值可能被 setValuesIn 自动带出),静态 valueFormatter
338
+ // 读 AG-Grid 缓存值不刷新 → 反应式只读渲染。整表 readPretty(明细/详情页,数据 setValues 整体加载、
339
+ // 行引用整体替换、AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
340
+ if (arrayPattern !== 'readPretty') {
341
+ return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
342
+ valueGetter: valueGetter
343
+ } : {}), {}, {
344
+ cellRenderer: LazyReadOnlyText,
345
+ cellRendererParams: {
346
+ formatter: formatter,
347
+ columnProps: columnProps,
348
+ fieldSchema: dataField
349
+ }
350
+ }));
351
+ }
292
352
  return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
293
353
  valueGetter: valueGetter
294
354
  } : {}), {}, {
@@ -344,4 +404,4 @@ var useAddition = function useAddition() {
344
404
  return addition;
345
405
  }, null);
346
406
  };
347
- export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
407
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField, LazyReadOnlyText };