@nokecy/qc-ui 1.1.40 → 1.1.41
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,20 @@ 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;
|
|
9
23
|
declare const buildArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
|
|
10
24
|
declare const useAddition: () => React.JSX.Element | null;
|
|
11
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
|
|
25
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField };
|
|
@@ -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.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,29 @@ var LazyAgField = function LazyAgField(params) {
|
|
|
179
179
|
node: node
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
+
});
|
|
195
205
|
};
|
|
196
206
|
|
|
197
207
|
// 在 Column 的子 schema 里递归找到内层数据字段(可读 x-component / x-pattern / x-reactions / enum) @author nokecy
|
|
@@ -6,6 +6,20 @@ 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;
|
|
9
23
|
declare const buildArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
|
|
10
24
|
declare const useAddition: () => React.JSX.Element | null;
|
|
11
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
|
|
25
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField };
|
|
@@ -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,29 @@ var LazyAgField = function LazyAgField(params) {
|
|
|
172
172
|
node: node
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
});
|
|
188
198
|
};
|
|
189
199
|
|
|
190
200
|
// 在 Column 的子 schema 里递归找到内层数据字段(可读 x-component / x-pattern / x-reactions / enum) @author nokecy
|
|
@@ -344,4 +354,4 @@ var useAddition = function useAddition() {
|
|
|
344
354
|
return addition;
|
|
345
355
|
}, null);
|
|
346
356
|
};
|
|
347
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
|
|
357
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField };
|