@nokecy/qc-ui 1.1.39 → 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.
- package/dist/cjs/adapters/abpPagedApiAdapter.d.ts +8 -0
- package/dist/cjs/adapters/abpPagedApiAdapter.js +35 -0
- package/dist/cjs/adapters/index.d.ts +6 -0
- package/dist/cjs/adapters/index.js +12 -0
- package/dist/cjs/adapters/pagedApiAdapter.d.ts +25 -0
- package/dist/cjs/adapters/pagedApiAdapter.js +5 -0
- package/dist/cjs/ag-grid-plus/ag-gridPlus.js +51 -205
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/context/queryFormContext.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/context/queryFormContext.js +25 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +1 -3
- package/dist/cjs/ag-grid-plus/hooks/index.js +7 -39
- package/dist/cjs/ag-grid-plus/hooks/useRowId.d.ts +13 -0
- package/dist/cjs/ag-grid-plus/hooks/useRowId.js +57 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +6 -6
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +2 -3
- package/dist/cjs/ag-grid-plus/types.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/utils/aggregation.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/utils/aggregation.js +101 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +2 -2
- package/dist/cjs/ag-grid-plus/utils/entityExtensionColumns.d.ts +12 -3
- package/dist/cjs/ag-grid-plus/utils/entityExtensionColumns.js +20 -5
- package/dist/cjs/ag-grid-plus/utils/queryFormDerivation.d.ts +19 -0
- package/dist/cjs/ag-grid-plus/utils/queryFormDerivation.js +49 -0
- package/dist/cjs/ag-grid-plus/utils/requestParams.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/requestParams.js +31 -0
- package/dist/cjs/ag-grid-plus/utils/rowSelection.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/utils/rowSelection.js +24 -0
- package/dist/cjs/ag-grid-plus/utils.js +2 -2
- package/dist/cjs/array-table/arrayBase.js +2 -0
- package/dist/cjs/array-table/utils.d.ts +15 -1
- package/dist/cjs/array-table/utils.js +48 -20
- package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +2 -3
- package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +1 -0
- package/dist/cjs/components/RegexEditor/validation/types.d.ts +1 -3
- package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +0 -2
- package/dist/cjs/dashboard/dashboard/index.js +8 -11
- package/dist/cjs/dashboard/dashboard/utils.js +3 -6
- package/dist/cjs/dashboard/widget/index.js +3 -3
- package/dist/cjs/dashboard/widget/selector/index.js +5 -7
- package/dist/cjs/dashboard/widget/utils.js +3 -4
- package/dist/cjs/dialogSelect/index.d.ts +3 -0
- package/dist/cjs/dialogSelect/index.js +16 -13
- package/dist/cjs/generatedListPage/GeneratedListPage.js +20 -19
- package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
- package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.js +26 -0
- package/dist/cjs/generatedListPage/types.d.ts +3 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +57 -0
- package/dist/cjs/standardFormDialog/types.d.ts +7 -0
- package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/cjs/standardFormDialog/withStandardForm.js +5 -4
- package/dist/esm/adapters/abpPagedApiAdapter.d.ts +8 -0
- package/dist/esm/adapters/abpPagedApiAdapter.js +29 -0
- package/dist/esm/adapters/index.d.ts +6 -0
- package/dist/esm/adapters/index.js +6 -0
- package/dist/esm/adapters/pagedApiAdapter.d.ts +25 -0
- package/dist/esm/adapters/pagedApiAdapter.js +1 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +49 -203
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +3 -0
- package/dist/esm/ag-grid-plus/context/queryFormContext.d.ts +20 -0
- package/dist/esm/ag-grid-plus/context/queryFormContext.js +19 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +1 -3
- package/dist/esm/ag-grid-plus/hooks/index.js +2 -6
- package/dist/esm/ag-grid-plus/hooks/useRowId.d.ts +13 -0
- package/dist/esm/ag-grid-plus/hooks/useRowId.js +52 -0
- package/dist/esm/ag-grid-plus/interface.d.ts +9 -0
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +6 -6
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +7 -6
- package/dist/esm/ag-grid-plus/types.d.ts +9 -0
- package/dist/esm/ag-grid-plus/utils/aggregation.d.ts +17 -0
- package/dist/esm/ag-grid-plus/utils/aggregation.js +93 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +2 -2
- package/dist/esm/ag-grid-plus/utils/entityExtensionColumns.d.ts +12 -3
- package/dist/esm/ag-grid-plus/utils/entityExtensionColumns.js +20 -5
- package/dist/esm/ag-grid-plus/utils/queryFormDerivation.d.ts +19 -0
- package/dist/esm/ag-grid-plus/utils/queryFormDerivation.js +42 -0
- package/dist/esm/ag-grid-plus/utils/requestParams.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/requestParams.js +24 -0
- package/dist/esm/ag-grid-plus/utils/rowSelection.d.ts +9 -0
- package/dist/esm/ag-grid-plus/utils/rowSelection.js +18 -0
- package/dist/esm/ag-grid-plus/utils.js +2 -2
- package/dist/esm/array-table/arrayBase.js +2 -0
- package/dist/esm/array-table/utils.d.ts +15 -1
- package/dist/esm/array-table/utils.js +48 -20
- package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +2 -2
- package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +1 -0
- package/dist/esm/components/RegexEditor/validation/types.d.ts +0 -1
- package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +0 -1
- package/dist/esm/dashboard/dashboard/index.js +8 -11
- package/dist/esm/dashboard/dashboard/utils.js +3 -2
- package/dist/esm/dashboard/widget/index.js +3 -3
- package/dist/esm/dashboard/widget/selector/index.js +5 -7
- package/dist/esm/dashboard/widget/utils.js +3 -3
- package/dist/esm/dialogSelect/index.d.ts +3 -0
- package/dist/esm/dialogSelect/index.js +16 -13
- package/dist/esm/generatedListPage/GeneratedListPage.js +20 -19
- package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
- package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.js +20 -0
- package/dist/esm/generatedListPage/types.d.ts +3 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/standardFormDialog/types.d.ts +7 -0
- package/dist/esm/standardFormDialog/withStandardForm.js +5 -4
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +52 -13
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +0 -88
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +0 -224
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +0 -91
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +0 -230
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +0 -153
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +0 -258
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +0 -88
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +0 -217
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +0 -91
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +0 -225
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +0 -153
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +0 -258
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 查询表单上下文。
|
|
5
|
+
*
|
|
6
|
+
* 从 GridPlusContext 中拆出"查询表单"相关字段(查询项列表/顺序/更新函数),
|
|
7
|
+
* 使查询表单的高频变化(如拖动调整顺序)不再触发 GridPlusContext 全量重渲染。
|
|
8
|
+
* 当前仅 QuerySchemeManager 消费;由 AgGridPlus 内部 Provider 提供。
|
|
9
|
+
* @author nokecy
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export var QueryFormContext = /*#__PURE__*/React.createContext({
|
|
13
|
+
queryFormItems: []
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** 读取查询表单上下文。@author nokecy */
|
|
17
|
+
export var useQueryForm = function useQueryForm() {
|
|
18
|
+
return React.useContext(QueryFormContext);
|
|
19
|
+
};
|
|
@@ -2,9 +2,5 @@
|
|
|
2
2
|
* AG-Grid Plus Hooks
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export * from "./useGridState";
|
|
8
|
-
|
|
9
|
-
// 导出 useGridPlusColumnState (已存在)
|
|
10
|
-
export { useGridPlusColumnState } from "./useGridPlusColumnState";
|
|
5
|
+
export { useGridPlusColumnState } from "./useGridPlusColumnState";
|
|
6
|
+
export { useRowId } from "./useRowId";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 行唯一 ID 生成 Hook(从 ag-gridPlus.tsx 抽出,逻辑原样)。
|
|
3
|
+
*
|
|
4
|
+
* 策略(按优先级):
|
|
5
|
+
* 1. 常见 ID 字段 id/_id/key/uid/uuid(基本类型直取;对象取 value 或 id 属性)
|
|
6
|
+
* 2. WeakMap 缓存命中
|
|
7
|
+
* 3. 生成 `${gridKey|grid}-row-{counter}-{timestamp}` 并缓存
|
|
8
|
+
*
|
|
9
|
+
* @author nokecy
|
|
10
|
+
*/
|
|
11
|
+
export declare function useRowId(gridKey?: string): {
|
|
12
|
+
generateUniqueRowId: (data: any) => string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 行唯一 ID 生成 Hook(从 ag-gridPlus.tsx 抽出,逻辑原样)。
|
|
6
|
+
*
|
|
7
|
+
* 策略(按优先级):
|
|
8
|
+
* 1. 常见 ID 字段 id/_id/key/uid/uuid(基本类型直取;对象取 value 或 id 属性)
|
|
9
|
+
* 2. WeakMap 缓存命中
|
|
10
|
+
* 3. 生成 `${gridKey|grid}-row-{counter}-{timestamp}` 并缓存
|
|
11
|
+
*
|
|
12
|
+
* @author nokecy
|
|
13
|
+
*/
|
|
14
|
+
export function useRowId(gridKey) {
|
|
15
|
+
var rowIdCacheRef = useRef(new WeakMap());
|
|
16
|
+
var rowIdCounterRef = useRef(0);
|
|
17
|
+
var generateUniqueRowId = useCallback(function (data) {
|
|
18
|
+
if (!data || _typeof(data) !== 'object') {
|
|
19
|
+
return "row-empty-".concat(rowIdCounterRef.current++);
|
|
20
|
+
}
|
|
21
|
+
var commonIdFields = ['id', '_id', 'key', 'uid', 'uuid'];
|
|
22
|
+
for (var _i = 0, _commonIdFields = commonIdFields; _i < _commonIdFields.length; _i++) {
|
|
23
|
+
var field = _commonIdFields[_i];
|
|
24
|
+
var value = data[field];
|
|
25
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
26
|
+
var fieldId = void 0;
|
|
27
|
+
if (_typeof(value) === 'object' && value !== null) {
|
|
28
|
+
if (value.value !== undefined) {
|
|
29
|
+
fieldId = String(value.value);
|
|
30
|
+
} else if (value.id !== undefined) {
|
|
31
|
+
fieldId = String(value.id);
|
|
32
|
+
} else {
|
|
33
|
+
fieldId = "".concat(field, "-").concat(JSON.stringify(value));
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
fieldId = String(value);
|
|
37
|
+
}
|
|
38
|
+
return fieldId;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
var cachedId = rowIdCacheRef.current.get(data);
|
|
42
|
+
if (cachedId) {
|
|
43
|
+
return cachedId;
|
|
44
|
+
}
|
|
45
|
+
var uniqueId = "".concat(gridKey || 'grid', "-row-").concat(rowIdCounterRef.current++, "-").concat(Date.now());
|
|
46
|
+
rowIdCacheRef.current.set(data, uniqueId);
|
|
47
|
+
return uniqueId;
|
|
48
|
+
}, [gridKey]);
|
|
49
|
+
return {
|
|
50
|
+
generateUniqueRowId: generateUniqueRowId
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -19,9 +19,18 @@ interface GridProps extends AgGridReactProps {
|
|
|
19
19
|
headerTitle?: React.ReactNode;
|
|
20
20
|
columnDefs?: (AgGridColumnPropsClone | ColGroupDef<any>)[] | null;
|
|
21
21
|
toolBarRender?: (gridApi?: GridApi, filter?: string, queryFilter?: any, paginationInfo?: {
|
|
22
|
+
/** @deprecated 改用 page */
|
|
22
23
|
current: number;
|
|
24
|
+
/** @deprecated 改用 page/pageSize */
|
|
23
25
|
skipCount: number;
|
|
26
|
+
/** @deprecated 改用 page/pageSize */
|
|
24
27
|
maxResultCount: number;
|
|
28
|
+
/** 当前页码(1-based)
|
|
29
|
+
* @author nokecy */
|
|
30
|
+
page?: number;
|
|
31
|
+
/** 每页条数
|
|
32
|
+
* @author nokecy */
|
|
33
|
+
pageSize?: number;
|
|
25
34
|
}) => React.ReactNode[];
|
|
26
35
|
defaultSearchExpand?: Boolean;
|
|
27
36
|
/**
|
|
@@ -30,7 +30,7 @@ import DraggableModal from "../../draggableModal";
|
|
|
30
30
|
import { EditOutlined, DeleteOutlined, StarOutlined, StarFilled } from '@ant-design/icons';
|
|
31
31
|
import { AgGridReact } from 'ag-grid-react';
|
|
32
32
|
import { useGridSchemes } from "../context/useSchemeManager";
|
|
33
|
-
import {
|
|
33
|
+
import { useQueryForm } from "../context/queryFormContext";
|
|
34
34
|
import { v4 as uuidv4 } from 'uuid';
|
|
35
35
|
import { extractItemsOrder, extractHiddenFields, buildQueryConfig } from "../shared/utils/schemeDataMigration";
|
|
36
36
|
import { agGridTheme } from "../theme";
|
|
@@ -58,11 +58,11 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
|
|
|
58
58
|
deleteQueryScheme = _useGridSchemes.deleteQueryScheme,
|
|
59
59
|
setCurrentQueryScheme = _useGridSchemes.setCurrentQueryScheme;
|
|
60
60
|
|
|
61
|
-
//
|
|
62
|
-
var
|
|
63
|
-
queryFormItems =
|
|
64
|
-
currentQueryOrder =
|
|
65
|
-
updateQueryOrder =
|
|
61
|
+
// 从查询表单 Context 获取查询表单项和当前顺序(已从 GridPlusContext 拆出)
|
|
62
|
+
var _useQueryForm = useQueryForm(),
|
|
63
|
+
queryFormItems = _useQueryForm.queryFormItems,
|
|
64
|
+
currentQueryOrder = _useQueryForm.currentQueryOrder,
|
|
65
|
+
updateQueryOrder = _useQueryForm.updateQueryOrder;
|
|
66
66
|
|
|
67
67
|
// 获取当前表格的查询方案列表
|
|
68
68
|
var schemes = (querySchemes === null || querySchemes === void 0 ? void 0 : querySchemes[gridKey]) || [];
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
import _uniqueId from "lodash/uniqueId";
|
|
3
|
-
/**
|
|
4
|
-
* 表头分组配置工具函数
|
|
5
|
-
* 负责 Grid State 与扁平化配置之间的转换
|
|
6
|
-
*/
|
|
7
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -16,12 +11,18 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
16
11
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
17
12
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
/**
|
|
15
|
+
* 表头分组配置工具函数
|
|
16
|
+
* 负责 Grid State 与扁平化配置之间的转换
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { uniqueId } from 'lodash';
|
|
19
20
|
import { logger } from "../utils/logger";
|
|
20
21
|
/**
|
|
21
22
|
* 生成唯一 ID
|
|
22
23
|
*/
|
|
23
24
|
export var generateId = function generateId() {
|
|
24
|
-
return
|
|
25
|
+
return uniqueId('col_');
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -176,9 +176,18 @@ export interface ToolBarRenderParams {
|
|
|
176
176
|
queryFilter?: QueryFilterState;
|
|
177
177
|
/** 分页信息 */
|
|
178
178
|
paginationInfo?: {
|
|
179
|
+
/** @deprecated 改用 page */
|
|
179
180
|
current: number;
|
|
181
|
+
/** @deprecated 改用 page/pageSize */
|
|
180
182
|
skipCount: number;
|
|
183
|
+
/** @deprecated 改用 page/pageSize */
|
|
181
184
|
maxResultCount: number;
|
|
185
|
+
/** 当前页码(1-based)
|
|
186
|
+
* @author nokecy */
|
|
187
|
+
page?: number;
|
|
188
|
+
/** 每页条数
|
|
189
|
+
* @author nokecy */
|
|
190
|
+
pageSize?: number;
|
|
182
191
|
};
|
|
183
192
|
}
|
|
184
193
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-Grid 底部汇总聚合纯函数(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
export interface CalculationColumnConfig {
|
|
6
|
+
field: string;
|
|
7
|
+
calculateType: 'sum' | 'avg' | 'standardDeviation';
|
|
8
|
+
transactionAmount: number;
|
|
9
|
+
formatWithCommas?: boolean;
|
|
10
|
+
cellRenderer?: any;
|
|
11
|
+
}
|
|
12
|
+
export declare const isValidNumber: (value: any) => boolean;
|
|
13
|
+
export declare const sumField: (field: string, data: any[]) => number;
|
|
14
|
+
export declare const avgField: (field: string, data: any[]) => number;
|
|
15
|
+
export declare const stdDevField: (field: string, data: any[]) => number;
|
|
16
|
+
export declare const formatWithCommas: (value: number) => string;
|
|
17
|
+
export declare const computeAggregationRow: (calcColFields: CalculationColumnConfig[], data: any[]) => any[];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _, { uniqueId } from 'lodash';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AG-Grid 底部汇总聚合纯函数(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
5
|
+
* @author nokecy
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export var isValidNumber = function isValidNumber(value) {
|
|
9
|
+
return typeof value === 'number' && !isNaN(value);
|
|
10
|
+
};
|
|
11
|
+
export var sumField = function sumField(field, data) {
|
|
12
|
+
return _.sumBy(data, function (cur) {
|
|
13
|
+
if (cur && isValidNumber(cur[field])) {
|
|
14
|
+
return cur[field];
|
|
15
|
+
}
|
|
16
|
+
return 0;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export var avgField = function avgField(field, data) {
|
|
20
|
+
// 分子分母口径统一为「有效数字」,避免除零得 NaN
|
|
21
|
+
var validValues = data.filter(function (cur) {
|
|
22
|
+
return cur && isValidNumber(cur[field]);
|
|
23
|
+
});
|
|
24
|
+
if (validValues.length === 0) return 0;
|
|
25
|
+
var sum = _.sumBy(validValues, function (cur) {
|
|
26
|
+
return cur[field];
|
|
27
|
+
});
|
|
28
|
+
return sum / validValues.length;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 注:现存口径小瑕疵——mean 的分母用有效值数,sumField 对全部行求和(无效计 0);
|
|
32
|
+
// variance 遍历全部行且判定用 !== undefined/null(非 isValidNumber)。首刀只保持原行为,不修正。
|
|
33
|
+
export var stdDevField = function stdDevField(field, data) {
|
|
34
|
+
var validValues = data.filter(function (cur) {
|
|
35
|
+
return isValidNumber(cur[field]);
|
|
36
|
+
});
|
|
37
|
+
var count = validValues.length;
|
|
38
|
+
if (count === 0) return 0;
|
|
39
|
+
var mean = sumField(field, data) / count;
|
|
40
|
+
var variance = _.sumBy(data, function (cur) {
|
|
41
|
+
if (cur && cur[field] !== undefined && cur[field] !== null) {
|
|
42
|
+
var diff = cur[field] - mean;
|
|
43
|
+
return diff * diff;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
}) / count;
|
|
47
|
+
return Math.sqrt(variance);
|
|
48
|
+
};
|
|
49
|
+
export var formatWithCommas = function formatWithCommas(value) {
|
|
50
|
+
return (value / 1).toLocaleString(undefined, {
|
|
51
|
+
minimumFractionDigits: 2,
|
|
52
|
+
maximumFractionDigits: 2
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// sum 求和 / avg 平均值 / standardDeviation 标准差
|
|
57
|
+
export var computeAggregationRow = function computeAggregationRow(calcColFields, data) {
|
|
58
|
+
var calculateArrCopy = [];
|
|
59
|
+
var calculateData = {
|
|
60
|
+
id: uniqueId()
|
|
61
|
+
};
|
|
62
|
+
calcColFields.forEach(function (i) {
|
|
63
|
+
if (!i.cellRenderer) {
|
|
64
|
+
switch (i.calculateType) {
|
|
65
|
+
case 'sum':
|
|
66
|
+
{
|
|
67
|
+
var sumPrecision = typeof i.transactionAmount === 'number' ? i.transactionAmount : 2;
|
|
68
|
+
var sumValue = Number(sumField(i.field, data).toFixed(sumPrecision));
|
|
69
|
+
calculateData[i.field] = i.formatWithCommas ? formatWithCommas(sumValue) : sumValue;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case 'avg':
|
|
73
|
+
{
|
|
74
|
+
var avgPrecision = typeof i.transactionAmount === 'number' ? i.transactionAmount : 2;
|
|
75
|
+
calculateData[i.field] = Number(avgField(i.field, data).toFixed(avgPrecision));
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case 'standardDeviation':
|
|
79
|
+
{
|
|
80
|
+
var stdPrecision = typeof i.transactionAmount === 'number' ? i.transactionAmount : 2;
|
|
81
|
+
calculateData[i.field] = Number(stdDevField(i.field, data).toFixed(stdPrecision));
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (Object.keys(calculateData).length > 0) {
|
|
90
|
+
calculateArrCopy.push(calculateData);
|
|
91
|
+
}
|
|
92
|
+
return calculateArrCopy;
|
|
93
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _isArray from "lodash/isArray";
|
|
2
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -8,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import { Typography } from 'antd';
|
|
10
9
|
import { Select } from '@formily/antd-v5';
|
|
10
|
+
import { isArray } from 'lodash';
|
|
11
11
|
import { DEFAULT_SEARCH_SORT_ORDER } from "./constants";
|
|
12
12
|
var Text = Typography.Text;
|
|
13
13
|
|
|
@@ -35,7 +35,7 @@ var Text = Typography.Text;
|
|
|
35
35
|
*/
|
|
36
36
|
export function handleGridPlusColumnState(columnState) {
|
|
37
37
|
var cellConfigMap = {};
|
|
38
|
-
if (
|
|
38
|
+
if (isArray(columnState)) {
|
|
39
39
|
columnState.forEach(function (item) {
|
|
40
40
|
if (item.field && (item.cellClass || item.suppressHeaderFilterButton !== undefined || item.groupName)) {
|
|
41
41
|
cellConfigMap[item.field] = {
|
|
@@ -7,17 +7,26 @@
|
|
|
7
7
|
import type { ExtendedColDef, EntityExtensionField, HostEntityExtensions } from '../types';
|
|
8
8
|
/**
|
|
9
9
|
* 将单个扩展字段转换为列定义
|
|
10
|
-
* 使用
|
|
10
|
+
* 使用 {extraPropertiesPath}.xxx 嵌套路径访问数据
|
|
11
11
|
*
|
|
12
12
|
* @param field 扩展字段定义
|
|
13
|
+
* @param extraPropertiesPath 扩展属性的路径前缀,默认 'extraProperties'(保持向后兼容)
|
|
13
14
|
* @returns AG-Grid 列定义
|
|
15
|
+
* @author nokecy
|
|
16
|
+
*
|
|
17
|
+
* @warning 请勿将此函数直接传给 Array.prototype.map()。
|
|
18
|
+
* Array.map 会将 (element, index, array) 全部传入,index(数字)会绑定到
|
|
19
|
+
* extraPropertiesPath,导致 field 路径变为 '0.foo'、'1.bar' 等非法值。
|
|
20
|
+
* 请始终用箭头函数包装:someArray.map((f) => fieldToColumnDef(f, path))
|
|
14
21
|
*/
|
|
15
|
-
export declare function fieldToColumnDef(field: EntityExtensionField): ExtendedColDef;
|
|
22
|
+
export declare function fieldToColumnDef(field: EntityExtensionField, extraPropertiesPath?: string): ExtendedColDef;
|
|
16
23
|
/**
|
|
17
24
|
* 获取指定实体的扩展列定义
|
|
18
25
|
*
|
|
19
26
|
* @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
|
|
20
27
|
* @param extensions 实体扩展配置映射
|
|
28
|
+
* @param extraPropertiesPath 扩展属性的路径前缀,默认 'extraProperties'(保持向后兼容)
|
|
21
29
|
* @returns 扩展列定义数组,按 sortOrder 排序
|
|
30
|
+
* @author nokecy
|
|
22
31
|
*/
|
|
23
|
-
export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions): ExtendedColDef[];
|
|
32
|
+
export declare function getEntityExtensionColumns(entityType: string | undefined, extensions?: HostEntityExtensions, extraPropertiesPath?: string): ExtendedColDef[];
|
|
@@ -86,19 +86,29 @@ var dataTypeColumnConfig = {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* 将单个扩展字段转换为列定义
|
|
89
|
-
* 使用
|
|
89
|
+
* 使用 {extraPropertiesPath}.xxx 嵌套路径访问数据
|
|
90
90
|
*
|
|
91
91
|
* @param field 扩展字段定义
|
|
92
|
+
* @param extraPropertiesPath 扩展属性的路径前缀,默认 'extraProperties'(保持向后兼容)
|
|
92
93
|
* @returns AG-Grid 列定义
|
|
94
|
+
* @author nokecy
|
|
95
|
+
*
|
|
96
|
+
* @warning 请勿将此函数直接传给 Array.prototype.map()。
|
|
97
|
+
* Array.map 会将 (element, index, array) 全部传入,index(数字)会绑定到
|
|
98
|
+
* extraPropertiesPath,导致 field 路径变为 '0.foo'、'1.bar' 等非法值。
|
|
99
|
+
* 请始终用箭头函数包装:someArray.map((f) => fieldToColumnDef(f, path))
|
|
93
100
|
*/
|
|
94
101
|
export function fieldToColumnDef(field) {
|
|
102
|
+
var extraPropertiesPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'extraProperties';
|
|
103
|
+
// 防御 Array.map 将 index(number)传入第二参数的情况,回退到默认路径
|
|
104
|
+
var resolvedPath = typeof extraPropertiesPath === 'string' ? extraPropertiesPath : 'extraProperties';
|
|
95
105
|
var config = dataTypeColumnConfig[field.dataType] || {
|
|
96
106
|
width: 150,
|
|
97
107
|
hideInSearch: false
|
|
98
108
|
};
|
|
99
109
|
var colDef = _objectSpread(_objectSpread({
|
|
100
|
-
//
|
|
101
|
-
field: "
|
|
110
|
+
// 使用可配置前缀的嵌套路径访问扩展属性数据
|
|
111
|
+
field: "".concat(resolvedPath, ".").concat(field.name),
|
|
102
112
|
headerName: field.displayName,
|
|
103
113
|
width: config.width,
|
|
104
114
|
hideInSearch: config.hideInSearch
|
|
@@ -115,9 +125,12 @@ export function fieldToColumnDef(field) {
|
|
|
115
125
|
*
|
|
116
126
|
* @param entityType 实体类型全名 (如 "Burn.Product.Domain.Product")
|
|
117
127
|
* @param extensions 实体扩展配置映射
|
|
128
|
+
* @param extraPropertiesPath 扩展属性的路径前缀,默认 'extraProperties'(保持向后兼容)
|
|
118
129
|
* @returns 扩展列定义数组,按 sortOrder 排序
|
|
130
|
+
* @author nokecy
|
|
119
131
|
*/
|
|
120
132
|
export function getEntityExtensionColumns(entityType, extensions) {
|
|
133
|
+
var extraPropertiesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'extraProperties';
|
|
121
134
|
// 边界情况处理:无效输入直接返回空数组
|
|
122
135
|
var entityConfig = entityType ? extensions === null || extensions === void 0 ? void 0 : extensions[entityType] : undefined;
|
|
123
136
|
var fields = entityConfig === null || entityConfig === void 0 ? void 0 : entityConfig.fields;
|
|
@@ -125,9 +138,11 @@ export function getEntityExtensionColumns(entityType, extensions) {
|
|
|
125
138
|
return [];
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
// 按 sortOrder
|
|
141
|
+
// 按 sortOrder 排序后转换为列定义,透传路径前缀
|
|
129
142
|
return _toConsumableArray(fields).sort(function (a, b) {
|
|
130
143
|
var _a$sortOrder, _b$sortOrder;
|
|
131
144
|
return ((_a$sortOrder = a.sortOrder) !== null && _a$sortOrder !== void 0 ? _a$sortOrder : 0) - ((_b$sortOrder = b.sortOrder) !== null && _b$sortOrder !== void 0 ? _b$sortOrder : 0);
|
|
132
|
-
}).map(
|
|
145
|
+
}).map(function (f) {
|
|
146
|
+
return fieldToColumnDef(f, extraPropertiesPath);
|
|
147
|
+
});
|
|
133
148
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查询表单项派生纯函数(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 按 itemsOrder 数组对查询表单项排序。
|
|
7
|
+
* - itemsOrder 为空/未传:原样返回(同一引用,memo 友好)。
|
|
8
|
+
* - 未在 itemsOrder 中的项排到末尾,两者都不在则保持相对顺序。
|
|
9
|
+
*/
|
|
10
|
+
export declare function sortFormItemsByOrder<T extends {
|
|
11
|
+
field: string;
|
|
12
|
+
}>(items: T[], itemsOrder?: string[]): T[];
|
|
13
|
+
/**
|
|
14
|
+
* 过滤掉 hiddenFields 中的查询表单项。
|
|
15
|
+
* - hiddenFields 为空:原样返回(同一引用,memo 友好)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function filterHiddenFormItems<T extends {
|
|
18
|
+
field: string;
|
|
19
|
+
}>(items: T[], hiddenFields: string[]): T[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
/**
|
|
8
|
+
* 查询表单项派生纯函数(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
9
|
+
* @author nokecy
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 按 itemsOrder 数组对查询表单项排序。
|
|
14
|
+
* - itemsOrder 为空/未传:原样返回(同一引用,memo 友好)。
|
|
15
|
+
* - 未在 itemsOrder 中的项排到末尾,两者都不在则保持相对顺序。
|
|
16
|
+
*/
|
|
17
|
+
export function sortFormItemsByOrder(items, itemsOrder) {
|
|
18
|
+
if (!itemsOrder || itemsOrder.length === 0) {
|
|
19
|
+
return items;
|
|
20
|
+
}
|
|
21
|
+
return _toConsumableArray(items).sort(function (a, b) {
|
|
22
|
+
var indexA = itemsOrder.indexOf(a.field);
|
|
23
|
+
var indexB = itemsOrder.indexOf(b.field);
|
|
24
|
+
if (indexA === -1 && indexB === -1) return 0;
|
|
25
|
+
if (indexA === -1) return 1;
|
|
26
|
+
if (indexB === -1) return -1;
|
|
27
|
+
return indexA - indexB;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 过滤掉 hiddenFields 中的查询表单项。
|
|
33
|
+
* - hiddenFields 为空:原样返回(同一引用,memo 友好)。
|
|
34
|
+
*/
|
|
35
|
+
export function filterHiddenFormItems(items, hiddenFields) {
|
|
36
|
+
if (hiddenFields.length === 0) {
|
|
37
|
+
return items;
|
|
38
|
+
}
|
|
39
|
+
return items.filter(function (item) {
|
|
40
|
+
return !hiddenFields.includes(item.field);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { QueryFilterState, ExtendedColDef } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 请求参数构建纯函数(从 ag-gridPlus.tsx onRequest 抽出,行为原样)。
|
|
4
|
+
* @author nokecy
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 根据查询模式构建过滤字符串:
|
|
8
|
+
* - 高级模式(__advancedMode__ 且有 __rules__):走规则转换 convertRulesToFilterString。
|
|
9
|
+
* - 简单模式:走 convertFilterModel。
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildFilterString(queryFilter: QueryFilterState, columnDefs: ExtendedColDef[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* 页码 → ABP skipCount。第 1 页为 0,其余为 (current-1)*pageSize。
|
|
14
|
+
*/
|
|
15
|
+
export declare function pageToSkipCount(current: number, pageSize: number): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { convertFilterModel, convertRulesToFilterString } from "../utils";
|
|
2
|
+
/**
|
|
3
|
+
* 请求参数构建纯函数(从 ag-gridPlus.tsx onRequest 抽出,行为原样)。
|
|
4
|
+
* @author nokecy
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 根据查询模式构建过滤字符串:
|
|
9
|
+
* - 高级模式(__advancedMode__ 且有 __rules__):走规则转换 convertRulesToFilterString。
|
|
10
|
+
* - 简单模式:走 convertFilterModel。
|
|
11
|
+
*/
|
|
12
|
+
export function buildFilterString(queryFilter, columnDefs) {
|
|
13
|
+
if (queryFilter.__advancedMode__ && queryFilter.__rules__) {
|
|
14
|
+
return convertRulesToFilterString(queryFilter.__rules__, columnDefs);
|
|
15
|
+
}
|
|
16
|
+
return convertFilterModel(queryFilter, columnDefs);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 页码 → ABP skipCount。第 1 页为 0,其余为 (current-1)*pageSize。
|
|
21
|
+
*/
|
|
22
|
+
export function pageToSkipCount(current, pageSize) {
|
|
23
|
+
return current === 1 ? 0 : (current - 1) * pageSize;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 行选择纯逻辑(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 只保留「既被选中、又在当前显示行中」的行(按 getId 计算的行 ID 比对)。
|
|
7
|
+
* id 为空(falsy)的行不计入匹配。
|
|
8
|
+
*/
|
|
9
|
+
export declare function filterVisibleSelectedRows<T>(selectedRows: T[], displayedRows: T[], getId: (row: T) => string): T[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 行选择纯逻辑(从 ag-gridPlus.tsx 抽出,行为原样)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 只保留「既被选中、又在当前显示行中」的行(按 getId 计算的行 ID 比对)。
|
|
8
|
+
* id 为空(falsy)的行不计入匹配。
|
|
9
|
+
*/
|
|
10
|
+
export function filterVisibleSelectedRows(selectedRows, displayedRows, getId) {
|
|
11
|
+
return selectedRows.filter(function (selectedRow) {
|
|
12
|
+
return displayedRows.some(function (displayedRow) {
|
|
13
|
+
var selectedRowId = getId(selectedRow);
|
|
14
|
+
var displayedRowId = getId(displayedRow);
|
|
15
|
+
return selectedRowId && displayedRowId && selectedRowId === displayedRowId;
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -12,6 +11,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
|
12
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
13
|
import dayjs from 'dayjs';
|
|
14
|
+
import { cloneDeep } from 'lodash';
|
|
15
15
|
import { GridifyQueryBuilder, ConditionalOperator as GridifyOp } from 'gridify-client';
|
|
16
16
|
|
|
17
17
|
// Gridify 值转义函数
|
|
@@ -249,7 +249,7 @@ var flattenTreeDeep = function flattenTreeDeep(treeData) {
|
|
|
249
249
|
});
|
|
250
250
|
return res;
|
|
251
251
|
};
|
|
252
|
-
var data =
|
|
252
|
+
var data = cloneDeep(treeData);
|
|
253
253
|
var res = [];
|
|
254
254
|
flattenData(data, res, null, childrenName);
|
|
255
255
|
return res;
|
|
@@ -51,7 +51,9 @@ ArrayBase.Item = function (_ref) {
|
|
|
51
51
|
}, children);
|
|
52
52
|
};
|
|
53
53
|
ArrayBase.Index = function (props) {
|
|
54
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Formily 复合组件,ArrayBase.Index 实为函数组件,误报
|
|
54
55
|
var index = useIndex();
|
|
56
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- 同上
|
|
55
57
|
var prefixCls = usePrefixCls('formily-array-base');
|
|
56
58
|
return /*#__PURE__*/React.createElement("span", _extends({}, props, {
|
|
57
59
|
className: "".concat(prefixCls, "-index")
|
|
@@ -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 };
|