@nokecy/qc-ui 1.1.56 → 1.1.58

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.
Files changed (37) hide show
  1. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +16 -21
  2. package/dist/cjs/ag-grid-plus/index.less +4 -4
  3. package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.js +2 -1
  4. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +2 -1
  5. package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +3 -2
  6. package/dist/cjs/ag-grid-plus/theme.d.ts +5 -0
  7. package/dist/cjs/ag-grid-plus/theme.js +33 -1
  8. package/dist/cjs/ag-grid-plus/toolBar/index.js +2 -6
  9. package/dist/cjs/ag-grid-plus/toolBar/style.js +28 -5
  10. package/dist/cjs/ag-grid-plus/utils/aggregation.d.ts +9 -0
  11. package/dist/cjs/ag-grid-plus/utils/aggregation.js +15 -1
  12. package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +4 -2
  13. package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +14 -7
  14. package/dist/cjs/array-table/index.js +2 -1
  15. package/dist/cjs/array-table/preview.js +2 -1
  16. package/dist/cjs/array-table/theme.d.ts +2 -10
  17. package/dist/cjs/array-table/theme.js +18 -18
  18. package/dist/esm/ag-grid-plus/ag-gridPlus.js +19 -24
  19. package/dist/esm/ag-grid-plus/index.less +4 -4
  20. package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.js +3 -2
  21. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +3 -2
  22. package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +4 -3
  23. package/dist/esm/ag-grid-plus/theme.d.ts +5 -0
  24. package/dist/esm/ag-grid-plus/theme.js +32 -1
  25. package/dist/esm/ag-grid-plus/toolBar/index.js +2 -6
  26. package/dist/esm/ag-grid-plus/toolBar/style.js +28 -5
  27. package/dist/esm/ag-grid-plus/utils/aggregation.d.ts +9 -0
  28. package/dist/esm/ag-grid-plus/utils/aggregation.js +14 -0
  29. package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +4 -2
  30. package/dist/esm/ag-grid-plus/utils/columnProcessors.js +13 -7
  31. package/dist/esm/array-table/index.js +2 -1
  32. package/dist/esm/array-table/preview.js +2 -1
  33. package/dist/esm/array-table/theme.d.ts +2 -10
  34. package/dist/esm/array-table/theme.js +17 -18
  35. package/dist/umd/qc-ui.min.css +1 -1
  36. package/dist/umd/qc-ui.min.js +1 -1
  37. package/package.json +1 -1
@@ -28,7 +28,7 @@ import { AllEnterpriseModule } from "ag-grid-enterprise";
28
28
  ModuleRegistry.registerModules([AllEnterpriseModule]);
29
29
 
30
30
  // 导入 AG-Grid v33 主题
31
- import { agGridTheme } from "./theme";
31
+ import { useAgGridTheme } from "./theme";
32
32
  import { useTypeInferenceRow } from "./hooks/useTypeInferenceRow";
33
33
  import "./index.less";
34
34
  import FormRender from "./queryForm";
@@ -36,7 +36,7 @@ import ToolBar from "./toolBar";
36
36
  import SettingItem from "./settingItem";
37
37
  import { RedoOutlined, FilterOutlined } from '@ant-design/icons';
38
38
  import { convertFilterModel, dateTimeValueFormatter, dateValueFormatter, flatten, toTree } from "./utils";
39
- import { processEnumColumn, toColumnType } from "./utils/columnProcessors";
39
+ import { mergeInferredColumnType, processEnumColumn } from "./utils/columnProcessors";
40
40
  import AdvancedQueryBuilder from "./queryForm/AdvancedQueryBuilder";
41
41
  import { v4 as uuidv4 } from 'uuid';
42
42
  import Setting from "./setting";
@@ -55,7 +55,7 @@ import { QueryFormContext } from "./context/queryFormContext";
55
55
  import { useGridSchemes } from "./context/useSchemeManager";
56
56
  import { useSchemeDataFlow } from "./context/useSchemeDataFlow";
57
57
  import { extractItemsOrder, extractHiddenFields } from "./shared/utils/schemeDataMigration";
58
- import { computeAggregationRow } from "./utils/aggregation";
58
+ import { computeAggregationRow, getCalculationColumns } from "./utils/aggregation";
59
59
  import { sortFormItemsByOrder, filterHiddenFormItems } from "./utils/queryFormDerivation";
60
60
  import { filterVisibleSelectedRows } from "./utils/rowSelection";
61
61
  import { buildFilterString, pageToSkipCount } from "./utils/requestParams";
@@ -78,6 +78,7 @@ function useDeepCompareStable(value) {
78
78
  return ref.current;
79
79
  }
80
80
  function AgGridPlus(props) {
81
+ var gridTheme = useAgGridTheme();
81
82
  var style = props.style,
82
83
  loadingProps = props.loading,
83
84
  gridParams = props.params,
@@ -432,11 +433,10 @@ function AgGridPlus(props) {
432
433
  // 辅助函数: 获取数据类型
433
434
  var getDataType = function getDataType(data, colName, valueEnum) {
434
435
  if (typeof data[colName] === 'number') {
435
- // 如果有枚举值,说明是分类数据,不进行计算;否则默认求和
436
- var shouldCalculate = !valueEnum || valueEnum.length === 0;
436
+ // 数值只用于列对齐;底部合计必须由 calculateType 显式声明。@author nokecy
437
437
  return {
438
438
  type: "number",
439
- calculateType: shouldCalculate ? "sum" : false
439
+ calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
440
440
  };
441
441
  }
442
442
  return undefined;
@@ -464,11 +464,11 @@ function AgGridPlus(props) {
464
464
  return processEnumColumn(col, dataType);
465
465
  }
466
466
  if (col.type || typeof col.cellRenderer == "string") {
467
- return _objectSpread({}, col);
467
+ return mergeInferredColumnType(col, dataType);
468
468
  }
469
469
  //@ts-ignore
470
470
  if (col !== null && col !== void 0 && col.ellipsis) {
471
- return _objectSpread(_objectSpread({}, col), {}, {
471
+ return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
472
472
  cellRenderer: function cellRenderer(_ref) {
473
473
  var value = _ref.value;
474
474
  return /*#__PURE__*/React.createElement(Text, {
@@ -485,12 +485,12 @@ function AgGridPlus(props) {
485
485
  });
486
486
  }
487
487
  if (col.cellRenderer) {
488
- return _objectSpread(_objectSpread({}, col), {}, {
488
+ return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
489
489
  customCellRenderer: col.cellRenderer,
490
490
  cellRenderer: cellRenderer
491
491
  });
492
492
  }
493
- return _objectSpread(_objectSpread(_objectSpread({}, toColumnType(dataType)), col), {}, {
493
+ return _objectSpread(_objectSpread({}, mergeInferredColumnType(col, dataType)), {}, {
494
494
  customCellRenderer: col.cellRenderer,
495
495
  cellRenderer: cellRenderer
496
496
  });
@@ -940,6 +940,7 @@ function AgGridPlus(props) {
940
940
  }
941
941
  };
942
942
  var calculateSum = useCallback(function () {
943
+ if (props.pinnedBottomRowData !== undefined) return;
943
944
  var displayedData = [];
944
945
  if (apiRef.current) {
945
946
  apiRef.current.forEachNodeAfterFilter(function (node) {
@@ -951,22 +952,16 @@ function AgGridPlus(props) {
951
952
  (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.setGridOption('pinnedBottomRowData', undefined);
952
953
  return;
953
954
  }
954
- var calcColFields = allColDefs.filter(function (col) {
955
- return col.calculateType;
956
- }).map(function (col) {
957
- return {
958
- field: col.field,
959
- calculateType: col.calculateType,
960
- transactionAmount: col.transactionAmount || 2,
961
- formatWithCommas: col.formatWithCommas
962
- };
963
- });
955
+ var calcColFields = getCalculationColumns(allColDefs);
964
956
  if (calcColFields.length > 0) {
965
957
  var _apiRef$current5;
966
958
  var calculatedValues = computeAggregationRow(calcColFields, displayedData);
967
959
  (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 || _apiRef$current5.setGridOption('pinnedBottomRowData', calculatedValues);
960
+ } else {
961
+ var _apiRef$current6;
962
+ (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 || _apiRef$current6.setGridOption('pinnedBottomRowData', undefined);
968
963
  }
969
- }, [allColDefs]);
964
+ }, [allColDefs, props.pinnedBottomRowData]);
970
965
  var onFilterChanged = function onFilterChanged(event) {
971
966
  calculateSum();
972
967
  };
@@ -1312,7 +1307,7 @@ function AgGridPlus(props) {
1312
1307
  }
1313
1308
  }, /*#__PURE__*/React.createElement(FilterOutlined, null)))) : null].filter(Boolean)
1314
1309
  }), /*#__PURE__*/React.createElement(AgGridReact, _extends({
1315
- theme: agGridTheme
1310
+ theme: gridTheme
1316
1311
  }, rest, {
1317
1312
  localeText: localeText,
1318
1313
  gridOptions: {
@@ -1360,8 +1355,8 @@ function AgGridPlus(props) {
1360
1355
  },
1361
1356
  onDragStopped: function onDragStopped(e) {
1362
1357
  if (apiRef.current) {
1363
- var _apiRef$current6;
1364
- var _columnState = (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.getColumnState();
1358
+ var _apiRef$current7;
1359
+ var _columnState = (_apiRef$current7 = apiRef.current) === null || _apiRef$current7 === void 0 ? void 0 : _apiRef$current7.getColumnState();
1365
1360
  setColumnState(_columnState);
1366
1361
 
1367
1362
  // onColumnStateChanged && onColumnStateChanged(columnState)
@@ -28,12 +28,12 @@
28
28
  }
29
29
 
30
30
  .ag-root-wrapper-body .ag-center-cols-viewport .ag-center-cols-container .ag-checkbox .ag-checkbox-input-wrapper {
31
- width: 18px !important;
32
- height: 18px !important;
31
+ width: 16px !important;
32
+ height: 16px !important;
33
33
  }
34
34
  .ag-root-wrapper-body .ag-header-viewport .ag-checkbox .ag-checkbox-input-wrapper {
35
- width: 18px !important;
36
- height: 18px !important;
35
+ width: 16px !important;
36
+ height: 16px !important;
37
37
  }
38
38
 
39
39
  // 列内容对齐方式样式
@@ -25,7 +25,7 @@ import { DeleteOutlined, FolderOutlined, FolderAddOutlined, FileOutlined } from
25
25
  import { AgGridReact } from 'ag-grid-react';
26
26
  import { generateId } from "./columnGroupUtils";
27
27
  import { DebounceNumberInput } from "./DebounceInputs";
28
- import { agGridTheme } from "../theme";
28
+ import { useAgGridTheme } from "../theme";
29
29
  import { ColumnNameCellRenderer } from "./ColumnNameCellRenderer";
30
30
  // ==================== Cell Renderers ====================
31
31
 
@@ -238,6 +238,7 @@ var ColumnConfigTable = function ColumnConfigTable(_ref2) {
238
238
  simple = _ref2$simple === void 0 ? false : _ref2$simple,
239
239
  _ref2$scrollY = _ref2.scrollY,
240
240
  scrollY = _ref2$scrollY === void 0 ? 480 : _ref2$scrollY;
241
+ var gridTheme = useAgGridTheme();
241
242
  var _useState = useState(items),
242
243
  _useState2 = _slicedToArray(_useState, 2),
243
244
  localItems = _useState2[0],
@@ -706,7 +707,7 @@ var ColumnConfigTable = function ColumnConfigTable(_ref2) {
706
707
  height: scrollY
707
708
  }
708
709
  }, /*#__PURE__*/React.createElement(AgGridReact, {
709
- theme: agGridTheme,
710
+ theme: gridTheme,
710
711
  rowData: visibleItems,
711
712
  columnDefs: columnDefs,
712
713
  getRowId: function getRowId(params) {
@@ -30,7 +30,7 @@ import { SaveOutlined, ReloadOutlined, EditOutlined, DeleteOutlined, StarOutline
30
30
  // 全局配置相关图标
31
31
  GlobalOutlined, RollbackOutlined, ClearOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
32
32
  import { AgGridReact } from 'ag-grid-react';
33
- import { agGridTheme } from "../theme";
33
+ import { useAgGridTheme } from "../theme";
34
34
  import { localeText } from "../locale";
35
35
  import { createForm, onFormInit } from '@formily/core';
36
36
  import { gridStateToFlatConfig, flatConfigToGridState, flatConfigToColumnState, dropQueryOnlyItems, excludeQueryOnlyColumns, isOldSchemeData, migrateOldScheme, generateId } from "./columnGroupUtils";
@@ -50,6 +50,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
50
50
  visible = _ref.visible,
51
51
  onClose = _ref.onClose,
52
52
  onSaveColumnState = _ref.onSaveColumnState;
53
+ var gridTheme = useAgGridTheme();
53
54
  // 使用新的集中式方案管理 API(包含状态数据和操作方法)
54
55
  var _useGridSchemes = useGridSchemes(),
55
56
  columnSchemes = _useGridSchemes.columnSchemes,
@@ -1247,7 +1248,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
1247
1248
  marginTop: 100
1248
1249
  }
1249
1250
  }) : /*#__PURE__*/React.createElement(AgGridReact, {
1250
- theme: agGridTheme,
1251
+ theme: gridTheme,
1251
1252
  localeText: localeText,
1252
1253
  rowData: filteredSchemes,
1253
1254
  columnDefs: schemeColumnDefs,
@@ -33,7 +33,7 @@ import { useGridSchemes } from "../context/useSchemeManager";
33
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
- import { agGridTheme } from "../theme";
36
+ import { useAgGridTheme } from "../theme";
37
37
 
38
38
  /**
39
39
  * 查询项数据结构
@@ -50,6 +50,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
50
50
  var gridKey = _ref.gridKey,
51
51
  visible = _ref.visible,
52
52
  onClose = _ref.onClose;
53
+ var gridTheme = useAgGridTheme();
53
54
  // 获取方案管理 API
54
55
  var _useGridSchemes = useGridSchemes(),
55
56
  querySchemes = _useGridSchemes.querySchemes,
@@ -753,7 +754,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
753
754
  }
754
755
  }, /*#__PURE__*/React.createElement(AgGridReact, {
755
756
  ref: queryGridRef,
756
- theme: agGridTheme,
757
+ theme: gridTheme,
757
758
  rowData: queryItemsData,
758
759
  columnDefs: queryColumnDefs,
759
760
  defaultColDef: {
@@ -801,7 +802,7 @@ var QuerySchemeManager = function QuerySchemeManager(_ref) {
801
802
  }
802
803
  }, /*#__PURE__*/React.createElement(AgGridReact, {
803
804
  ref: schemeGridRef,
804
- theme: agGridTheme,
805
+ theme: gridTheme,
805
806
  rowData: schemes,
806
807
  columnDefs: schemeColumnDefs,
807
808
  defaultColDef: {
@@ -3,3 +3,8 @@
3
3
  * 使用 themeQuartz API 替代 CSS 变量方式
4
4
  */
5
5
  export declare const agGridTheme: import("ag-grid-community").Theme<import("ag-grid-community").ThemeDefaultParams>;
6
+ /**
7
+ * 根据当前 Ant Design ConfigProvider 主题生成 AgGrid 主题色。
8
+ * 复选框、行选中和悬停等强调状态与 antd 主色同步。@author nokecy
9
+ */
10
+ export declare function useAgGridTheme(): import("ag-grid-community").Theme<import("ag-grid-community").ThemeDefaultParams>;
@@ -4,6 +4,8 @@
4
4
  */
5
5
 
6
6
  import { themeQuartz } from 'ag-grid-community';
7
+ import { theme as antdTheme } from 'antd';
8
+ import { useMemo } from 'react';
7
9
  export var agGridTheme = themeQuartz.withParams({
8
10
  // 基础颜色
9
11
  backgroundColor: '#FFFFFF',
@@ -69,4 +71,33 @@ export var agGridTheme = themeQuartz.withParams({
69
71
  // 侧边栏配置
70
72
  sideBarPanelWidth: 250,
71
73
  spacing: 6
72
- });
74
+ });
75
+
76
+ /**
77
+ * 根据当前 Ant Design ConfigProvider 主题生成 AgGrid 主题色。
78
+ * 复选框、行选中和悬停等强调状态与 antd 主色同步。@author nokecy
79
+ */
80
+ export function useAgGridTheme() {
81
+ var _antdTheme$useToken = antdTheme.useToken(),
82
+ token = _antdTheme$useToken.token;
83
+ return useMemo(function () {
84
+ return agGridTheme.withParams({
85
+ accentColor: token.colorPrimary,
86
+ rowHoverColor: token.colorPrimaryBg,
87
+ selectedRowBackgroundColor: token.colorPrimaryBgHover,
88
+ columnHoverColor: token.colorPrimaryBg,
89
+ rangeSelectionBorderColor: token.colorPrimary,
90
+ rangeSelectionBackgroundColor: token.colorPrimaryBgHover,
91
+ focusShadow: "0 0 0 3px ".concat(token.colorPrimaryBg),
92
+ checkboxUncheckedBackgroundColor: token.colorBgContainer,
93
+ checkboxUncheckedBorderColor: token.colorBorder,
94
+ checkboxCheckedBackgroundColor: token.colorPrimary,
95
+ checkboxCheckedBorderColor: token.colorPrimary,
96
+ checkboxCheckedShapeColor: token.colorWhite,
97
+ checkboxIndeterminateBackgroundColor: token.colorPrimary,
98
+ checkboxIndeterminateBorderColor: token.colorPrimary,
99
+ checkboxIndeterminateShapeColor: token.colorWhite,
100
+ toggleButtonOnBackgroundColor: token.colorPrimary
101
+ });
102
+ }, [token.colorBgContainer, token.colorBorder, token.colorPrimary, token.colorPrimaryBg, token.colorPrimaryBgHover, token.colorWhite]);
103
+ }
@@ -75,11 +75,7 @@ var ListToolBar = function ListToolBar(_ref) {
75
75
  return null;
76
76
  }
77
77
  return /*#__PURE__*/React.createElement("div", {
78
- style: {
79
- display: 'flex',
80
- alignItems: 'center',
81
- gap: 8
82
- }
78
+ className: "".concat(prefixCls, "-actions ").concat(hashId)
83
79
  }, actions.map(function (action, index) {
84
80
  if (! /*#__PURE__*/React.isValidElement(action)) {
85
81
  // eslint-disable-next-line react/no-array-index-key
@@ -92,7 +88,7 @@ var ListToolBar = function ListToolBar(_ref) {
92
88
  key: index
93
89
  }, action === null || action === void 0 ? void 0 : action.props));
94
90
  }));
95
- }, [actions]);
91
+ }, [actions, hashId, prefixCls]);
96
92
  var hasRight = useMemo(function () {
97
93
  return hasTitle || actionDom || (settings === null || settings === void 0 ? void 0 : settings.length);
98
94
  }, [actionDom, hasTitle, settings === null || settings === void 0 ? void 0 : settings.length]);
@@ -11,6 +11,8 @@ var genProListStyle = function genProListStyle(token) {
11
11
  "&-container": {
12
12
  display: "flex",
13
13
  justifyContent: "space-between",
14
+ alignItems: "center",
15
+ minWidth: 0,
14
16
  paddingBlock: 8,
15
17
  //token.padding,
16
18
  paddingInline: 0,
@@ -48,29 +50,47 @@ var genProListStyle = function genProListStyle(token) {
48
50
  },
49
51
  "&-left": _defineProperty(_defineProperty({
50
52
  display: "flex",
51
- flexWrap: "wrap",
53
+ flexWrap: "nowrap",
52
54
  alignItems: "center",
53
55
  gap: token.marginXS,
54
56
  justifyContent: "flex-start",
55
- maxWidth: "calc(100% - 200px)",
56
- flex: 1
57
+ minWidth: 0,
58
+ flex: "0 1 auto"
57
59
  }, "".concat(token.antCls, "-tabs"), {
58
60
  width: "100%"
59
61
  }), "&-has-tabs", {
60
62
  overflow: "hidden"
61
63
  }),
62
64
  "&-right": {
63
- flex: 1,
65
+ flex: "1 1 0",
66
+ minWidth: 0,
64
67
  display: "flex",
65
- flexWrap: "wrap",
68
+ flexWrap: "nowrap",
69
+ alignItems: "center",
66
70
  justifyContent: "flex-end",
67
71
  gap: token.marginXS
68
72
  },
73
+ // @author nokecy:按钮单行呈现,空间不足时只在操作区内滚动,不撑开页面。
74
+ "&-actions": {
75
+ display: "flex",
76
+ alignItems: "center",
77
+ gap: token.marginXS,
78
+ minWidth: 0,
79
+ flex: "0 1 auto",
80
+ overflowX: "auto",
81
+ overflowY: "hidden",
82
+ scrollbarWidth: "none",
83
+ whiteSpace: "nowrap",
84
+ "&::-webkit-scrollbar": {
85
+ display: "none"
86
+ }
87
+ },
69
88
  "&-extra-line": {
70
89
  marginBlockEnd: token.margin
71
90
  },
72
91
  "&-setting-items": {
73
92
  display: "flex",
93
+ flex: "0 0 auto",
74
94
  gap: token.marginXS,
75
95
  lineHeight: "32px",
76
96
  alignItems: "center"
@@ -121,6 +141,9 @@ var genProListStyle = function genProListStyle(token) {
121
141
  "&-left": {
122
142
  marginBlockEnd: "8px",
123
143
  maxWidth: "100%"
144
+ },
145
+ "&-right": {
146
+ width: "100%"
124
147
  }
125
148
  })));
126
149
  };
@@ -9,6 +9,15 @@ export interface CalculationColumnConfig {
9
9
  formatWithCommas?: boolean;
10
10
  cellRenderer?: any;
11
11
  }
12
+ export interface CalculationColumnDefinition {
13
+ field?: string;
14
+ calculateType?: CalculationColumnConfig['calculateType'] | false;
15
+ transactionAmount?: number;
16
+ formatWithCommas?: boolean;
17
+ children?: CalculationColumnDefinition[];
18
+ }
19
+ /** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
20
+ export declare const getCalculationColumns: (columns: CalculationColumnDefinition[]) => CalculationColumnConfig[];
12
21
  export declare const isValidNumber: (value: any) => boolean;
13
22
  export declare const sumField: (field: string, data: any[]) => number;
14
23
  export declare const avgField: (field: string, data: any[]) => number;
@@ -5,6 +5,20 @@ import _, { uniqueId } from 'lodash';
5
5
  * @author nokecy
6
6
  */
7
7
 
8
+ /** 分组表头只是展示结构;原生固定合计行要读取所有叶子数值列。@author nokecy */
9
+ export var getCalculationColumns = function getCalculationColumns(columns) {
10
+ return columns.flatMap(function (column) {
11
+ var _column$transactionAm;
12
+ if (column.children) return getCalculationColumns(column.children);
13
+ if (!column.field || !column.calculateType) return [];
14
+ return [{
15
+ field: column.field,
16
+ calculateType: column.calculateType,
17
+ transactionAmount: (_column$transactionAm = column.transactionAmount) !== null && _column$transactionAm !== void 0 ? _column$transactionAm : 2,
18
+ formatWithCommas: column.formatWithCommas
19
+ }];
20
+ });
21
+ };
8
22
  export var isValidNumber = function isValidNumber(value) {
9
23
  return typeof value === 'number' && !isNaN(value);
10
24
  };
@@ -56,8 +56,8 @@ export declare function inferDataType(data: any, colName: string, valueEnum?: Va
56
56
  * 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
57
57
  * 根本没有叫 number 的类型,这个字段一直没生效。
58
58
  *
59
- * 数量型数值列真正该有的是右对齐:位数对齐了才能一眼比大小。只有 calculateType 为真
60
- * (可求和的数量型)才右对齐;用 valueEnum 表示分类的数值列(状态码之类)不动。
59
+ * 普通数值列右对齐;合计另由 calculateType 显式控制。
60
+ * 用 valueEnum 表示分类的数值列(状态码之类)不动。
61
61
  *
62
62
  * @author nokecy
63
63
  */
@@ -65,6 +65,8 @@ export declare function toColumnType(dataType?: DataTypeInference): {
65
65
  calculateType?: any;
66
66
  type?: string;
67
67
  };
68
+ /** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
69
+ export declare function mergeInferredColumnType<T extends object>(column: T, dataType?: DataTypeInference): T & ReturnType<typeof toColumnType>;
68
70
  /**
69
71
  * 处理枚举列定义 —— **枚举列渲染的唯一实现**。
70
72
  *
@@ -60,11 +60,10 @@ export function handleGridPlusColumnState(columnState) {
60
60
  export function inferDataType(data, colName, valueEnum) {
61
61
  var value = data[colName];
62
62
  if (typeof value === 'number') {
63
- // 如果有枚举值,说明是分类数据,不进行计算
64
- var shouldCalculate = !valueEnum || valueEnum.length === 0;
63
+ // 数值只决定对齐;合计必须由列定义显式声明。@author nokecy
65
64
  return {
66
65
  type: 'number',
67
- calculateType: shouldCalculate ? 'sum' : false
66
+ calculateType: valueEnum !== null && valueEnum !== void 0 && valueEnum.length ? false : undefined
68
67
  };
69
68
  }
70
69
  if (typeof value === 'boolean') {
@@ -89,17 +88,19 @@ export function inferDataType(data, colName, valueEnum) {
89
88
  * 早先是把整个 dataType 摊进 colDef,等于给列设了 type:"number"——而注册的 columnTypes 里
90
89
  * 根本没有叫 number 的类型,这个字段一直没生效。
91
90
  *
92
- * 数量型数值列真正该有的是右对齐:位数对齐了才能一眼比大小。只有 calculateType 为真
93
- * (可求和的数量型)才右对齐;用 valueEnum 表示分类的数值列(状态码之类)不动。
91
+ * 普通数值列右对齐;合计另由 calculateType 显式控制。
92
+ * 用 valueEnum 表示分类的数值列(状态码之类)不动。
94
93
  *
95
94
  * @author nokecy
96
95
  */
97
96
  export function toColumnType(dataType) {
98
97
  if (!dataType) return {};
99
- if (dataType.type === 'number' && dataType.calculateType) {
100
- return {
98
+ if (dataType.type === 'number' && dataType.calculateType !== false) {
99
+ return dataType.calculateType ? {
101
100
  calculateType: dataType.calculateType,
102
101
  type: 'rightAligned'
102
+ } : {
103
+ type: 'rightAligned'
103
104
  };
104
105
  }
105
106
  return {
@@ -107,6 +108,11 @@ export function toColumnType(dataType) {
107
108
  };
108
109
  }
109
110
 
111
+ /** 显式列类型只控制显示方式,不遮蔽数值对齐或显式合计配置。@author nokecy */
112
+ export function mergeInferredColumnType(column, dataType) {
113
+ return _objectSpread(_objectSpread({}, toColumnType(dataType)), column);
114
+ }
115
+
110
116
  /**
111
117
  * 处理枚举列定义 —— **枚举列渲染的唯一实现**。
112
118
  *
@@ -28,7 +28,7 @@ import Setting from "../ag-grid-plus/setting";
28
28
  import { flatConfigToColumnState, flatConfigToGridState } from "../ag-grid-plus/setting/columnGroupUtils";
29
29
 
30
30
  // AG-Grid v33 主题:行高、单元格居中、去聚焦/选区视觉(编辑态与阅读态共用一份,见 theme.ts)
31
- import { arrayTableTheme, ARRAY_TABLE_ROW_HEIGHT } from "./theme";
31
+ import { useArrayTableTheme, ARRAY_TABLE_ROW_HEIGHT } from "./theme";
32
32
  import { useGridSchemes } from "../ag-grid-plus";
33
33
 
34
34
  //@ts-ignore
@@ -36,6 +36,7 @@ var ArrayTableInner = observer(function (props) {
36
36
  var _addition$props;
37
37
  var height = props.height,
38
38
  gridKey = props.gridKey;
39
+ var arrayTableTheme = useArrayTableTheme(true);
39
40
 
40
41
  // 【新增】运行时验证 gridKey
41
42
  if (!gridKey) {
@@ -2,10 +2,11 @@ import React from "react";
2
2
  import { useField } from "@formily/react";
3
3
  import { buildArrayTableColumns, useArrayTableSources } from "./utils";
4
4
  import { AgGridPlus } from "../ag-grid-plus";
5
- import { arrayTablePreviewTheme, ARRAY_TABLE_ROW_HEIGHT } from "./theme";
5
+ import { useArrayTableTheme, ARRAY_TABLE_ROW_HEIGHT } from "./theme";
6
6
  //@ts-ignore
7
7
  var ArrayTable = function ArrayTable(props) {
8
8
  var height = props.height;
9
+ var arrayTablePreviewTheme = useArrayTableTheme();
9
10
  var field = useField();
10
11
  var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
11
12
  var sources = useArrayTableSources();
@@ -4,13 +4,5 @@
4
4
  * 只设网格选项会让文字的行盒仍是主题默认行高(29.6-3=26.6px),顶在 37px 的格子上方(偏上约 4.5px)。
5
5
  */
6
6
  export declare const ARRAY_TABLE_ROW_HEIGHT = 38;
7
- /** 阅读态主题:共用主题 + 行高 + 单元格居中 */
8
- export declare const arrayTablePreviewTheme: import("ag-grid-community").Theme<import("ag-grid-community").CoreParams & import("ag-grid-community").ButtonStyleParams & import("ag-grid-community").CheckboxStyleParams & import("ag-grid-community").TabStyleParams & import("ag-grid-community").InputStyleParams & {}>;
9
- /**
10
- * 编辑态主题:在阅读态主题上去掉单元格聚焦/选区视觉(行内编辑更干净)。
11
- * focusShadow -> 聚焦光环
12
- * rangeSelectionBorder -> 单格点击形成的 1×1 选区蓝边
13
- * rangeSelectionBackground -> 选区淡蓝填充
14
- * 仅去视觉,不动焦点功能——键盘导航/点击进编辑仍依赖 cell focus。
15
- */
16
- export declare const arrayTableTheme: import("ag-grid-community").Theme<import("ag-grid-community").CoreParams & import("ag-grid-community").ButtonStyleParams & import("ag-grid-community").CheckboxStyleParams & import("ag-grid-community").TabStyleParams & import("ag-grid-community").InputStyleParams & {}>;
7
+ /** 根据当前 antd 主题生成编辑态或阅读态明细表格主题。@author nokecy */
8
+ export declare function useArrayTableTheme(editable?: boolean): import("ag-grid-community").Theme<import("ag-grid-community").CoreParams & import("ag-grid-community").ButtonStyleParams & import("ag-grid-community").CheckboxStyleParams & import("ag-grid-community").TabStyleParams & import("ag-grid-community").InputStyleParams & {}>;
@@ -4,7 +4,8 @@
4
4
  * @author nokecy
5
5
  */
6
6
  import { createPart } from 'ag-grid-community';
7
- import { agGridTheme } from "../ag-grid-plus/theme";
7
+ import { useMemo } from 'react';
8
+ import { useAgGridTheme } from "../ag-grid-plus/theme";
8
9
 
9
10
  /**
10
11
  * 行高 38:放得下 32px 高的输入框。网格选项 rowHeight 与主题参数 rowHeight 必须同值——
@@ -25,20 +26,18 @@ var arrayTableCellFit = createPart({
25
26
  css: "\n .ag-cell .ag-cell-wrapper { height: 100%; }\n .ag-cell .ant-formily-item { margin-bottom: 0; }\n .ag-cell .ant-formily-item-help { position: absolute; }\n "
26
27
  });
27
28
 
28
- /** 阅读态主题:共用主题 + 行高 + 单元格居中 */
29
- export var arrayTablePreviewTheme = agGridTheme.withParams({
30
- rowHeight: ARRAY_TABLE_ROW_HEIGHT
31
- }).withPart(arrayTableCellFit);
32
-
33
- /**
34
- * 编辑态主题:在阅读态主题上去掉单元格聚焦/选区视觉(行内编辑更干净)。
35
- * focusShadow -> 聚焦光环
36
- * rangeSelectionBorder -> 单格点击形成的 1×1 选区蓝边
37
- * rangeSelectionBackground -> 选区淡蓝填充
38
- * 仅去视觉,不动焦点功能——键盘导航/点击进编辑仍依赖 cell focus。
39
- */
40
- export var arrayTableTheme = arrayTablePreviewTheme.withParams({
41
- focusShadow: 'none',
42
- rangeSelectionBorderColor: 'transparent',
43
- rangeSelectionBackgroundColor: 'transparent'
44
- });
29
+ /** 根据当前 antd 主题生成编辑态或阅读态明细表格主题。@author nokecy */
30
+ export function useArrayTableTheme() {
31
+ var editable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
32
+ var agGridTheme = useAgGridTheme();
33
+ return useMemo(function () {
34
+ var previewTheme = agGridTheme.withParams({
35
+ rowHeight: ARRAY_TABLE_ROW_HEIGHT
36
+ }).withPart(arrayTableCellFit);
37
+ return editable ? previewTheme.withParams({
38
+ focusShadow: 'none',
39
+ rangeSelectionBorderColor: 'transparent',
40
+ rangeSelectionBackgroundColor: 'transparent'
41
+ }) : previewTheme;
42
+ }, [agGridTheme, editable]);
43
+ }