@nokecy/qc-ui 1.1.59 → 1.1.60

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.
@@ -11,6 +11,7 @@ var _icons = require("@ant-design/icons");
11
11
  var _antdV = require("@formily/antd-v5");
12
12
  var _react2 = require("@formily/react");
13
13
  var _arrayTable = _interopRequireDefault(require("../../array-table"));
14
+ var _columnGroupUtils = require("./columnGroupUtils");
14
15
  var _NameColumnRenderer = _interopRequireDefault(require("./NameColumnRenderer"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -304,7 +305,7 @@ var ColumnConfigForm = function ColumnConfigForm(_ref) {
304
305
  return /*#__PURE__*/_react.default.createElement("span", null, "-");
305
306
  }
306
307
  return /*#__PURE__*/_react.default.createElement(_antdV.Select, {
307
- value: props.value || 'custom-cell-left',
308
+ value: (0, _columnGroupUtils.normalizeCellAlign)(props.value),
308
309
  onChange: props.onChange,
309
310
  options: [{
310
311
  value: 'custom-cell-left',
@@ -178,7 +178,7 @@ var AlignmentCellRenderer = function AlignmentCellRenderer(props) {
178
178
  if (!item || item.type !== 'column') return /*#__PURE__*/_react.default.createElement("span", null, "-");
179
179
 
180
180
  // 标准化 cellClass 值,默认为左对齐
181
- var normalizedValue = item.cellClass || 'custom-cell-left';
181
+ var normalizedValue = (0, _columnGroupUtils.normalizeCellAlign)(item.cellClass);
182
182
  return /*#__PURE__*/_react.default.createElement(_antd.Select, {
183
183
  value: normalizedValue,
184
184
  onChange: function onChange(val) {
@@ -6,6 +6,11 @@ interface ColumnSettingProps {
6
6
  visible: boolean;
7
7
  onClose: () => void;
8
8
  onSaveColumnState: (state: any) => void;
9
+ /**
10
+ * 调用方自带的原始列定义(含 cellRenderer 等),优先于 Context。
11
+ * ArrayTable 不在 AgGridPlus 的 Context 里,不传会导致保存后重建出裸列、单元格空白。@author nokecy
12
+ */
13
+ allColDefs?: any[];
9
14
  }
10
15
  /**
11
16
  * 列方案管理组件 - 集成列配置和列方案管理
@@ -56,14 +56,15 @@ var ColumnSetting = function ColumnSetting(_ref) {
56
56
  gridApi = _ref.gridApi,
57
57
  visible = _ref.visible,
58
58
  onClose = _ref.onClose,
59
- onSaveColumnState = _ref.onSaveColumnState;
59
+ onSaveColumnState = _ref.onSaveColumnState,
60
+ allColDefsProp = _ref.allColDefs;
60
61
  var gridTheme = (0, _theme.useAgGridTheme)();
61
62
  // 使用新的集中式方案管理 API(包含状态数据和操作方法)
62
63
  var _useGridSchemes = (0, _useSchemeManager.useGridSchemes)(),
63
64
  columnSchemes = _useGridSchemes.columnSchemes,
64
65
  currentSchemes = _useGridSchemes.currentSchemes,
65
- allColDefs = _useGridSchemes.allColDefs,
66
- initialColumnDefs = _useGridSchemes.initialColumnDefs,
66
+ contextAllColDefs = _useGridSchemes.allColDefs,
67
+ contextInitialColumnDefs = _useGridSchemes.initialColumnDefs,
67
68
  saveColumnScheme = _useGridSchemes.saveColumnScheme,
68
69
  deleteColumnScheme = _useGridSchemes.deleteColumnScheme,
69
70
  setCurrentColumnScheme = _useGridSchemes.setCurrentColumnScheme,
@@ -73,6 +74,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
73
74
  globalConfigPermissions = _useGridSchemes.globalConfigPermissions,
74
75
  isUsingGlobalFallback = _useGridSchemes.isUsingGlobalFallback;
75
76
 
77
+ // 调用方传入的列定义优先:Context 里的属于外层 AgGridPlus 或为空 @author nokecy
78
+ var allColDefs = allColDefsProp !== null && allColDefsProp !== void 0 ? allColDefsProp : contextAllColDefs;
79
+ var initialColumnDefs = allColDefsProp !== null && allColDefsProp !== void 0 ? allColDefsProp : contextInitialColumnDefs;
80
+
76
81
  // 解构权限信息
77
82
  var canApplyToGlobal = (_globalConfigPermissi = globalConfigPermissions === null || globalConfigPermissions === void 0 ? void 0 : globalConfigPermissions.canApplyToGlobal) !== null && _globalConfigPermissi !== void 0 ? _globalConfigPermissi : false;
78
83
  var canResetAllUsers = (_globalConfigPermissi2 = globalConfigPermissions === null || globalConfigPermissions === void 0 ? void 0 : globalConfigPermissions.canResetAllUsers) !== null && _globalConfigPermissi2 !== void 0 ? _globalConfigPermissi2 : false;
@@ -95,3 +95,9 @@ export declare function isOldSchemeData(data: any[]): boolean;
95
95
  * @returns AG-Grid columnState 数组
96
96
  */
97
97
  export declare function flatConfigToColumnState(flatConfig: FlatColumnItem[], originalColumnDefs?: (ColDef | ColGroupDef)[]): any[];
98
+ /**
99
+ * 把列上的 cellClass 归一为对齐下拉的三个选项值。
100
+ * 列定义里可能是 AG-Grid 数值类型自带的 ag-right-aligned-cell、ArrayTable 的 ag-cell-right 等,
101
+ * 下拉只认 custom-cell-*,不归一就会把原始类名直接显示出来。@author nokecy
102
+ */
103
+ export declare function normalizeCellAlign(cellClass: unknown): 'custom-cell-left' | 'custom-cell-centered' | 'custom-cell-right';
@@ -13,6 +13,7 @@ exports.generateId = void 0;
13
13
  exports.gridStateToFlatConfig = gridStateToFlatConfig;
14
14
  exports.isOldSchemeData = isOldSchemeData;
15
15
  exports.migrateOldScheme = migrateOldScheme;
16
+ exports.normalizeCellAlign = normalizeCellAlign;
16
17
  exports.reorderItems = reorderItems;
17
18
  var _lodash = require("lodash");
18
19
  var _logger = require("../utils/logger");
@@ -629,4 +630,16 @@ function flatConfigToColumnState(flatConfig, originalColumnDefs) {
629
630
  }
630
631
  }
631
632
  return result;
633
+ }
634
+
635
+ /**
636
+ * 把列上的 cellClass 归一为对齐下拉的三个选项值。
637
+ * 列定义里可能是 AG-Grid 数值类型自带的 ag-right-aligned-cell、ArrayTable 的 ag-cell-right 等,
638
+ * 下拉只认 custom-cell-*,不归一就会把原始类名直接显示出来。@author nokecy
639
+ */
640
+ function normalizeCellAlign(cellClass) {
641
+ var text = Array.isArray(cellClass) ? cellClass.join(' ') : typeof cellClass === 'string' ? cellClass : '';
642
+ if (/right/.test(text)) return 'custom-cell-right';
643
+ if (/cent/.test(text)) return 'custom-cell-centered';
644
+ return 'custom-cell-left';
632
645
  }
@@ -26,6 +26,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
26
  var Setting = function Setting(props) {
27
27
  var gridKey = props.gridKey,
28
28
  gridApi = props.gridApi,
29
+ allColDefs = props.allColDefs,
29
30
  onSaveColumnState = props.onSaveColumnState,
30
31
  _props$showQuerySchem = props.showQueryScheme,
31
32
  showQueryScheme = _props$showQuerySchem === void 0 ? true : _props$showQuerySchem;
@@ -78,7 +79,8 @@ var Setting = function Setting(props) {
78
79
  onClose: function onClose() {
79
80
  return setColumnSettingVisible(false);
80
81
  },
81
- onSaveColumnState: onSaveColumnState || function () {}
82
+ onSaveColumnState: onSaveColumnState || function () {},
83
+ allColDefs: allColDefs
82
84
  }), gridKey && showQueryScheme && /*#__PURE__*/_react.default.createElement(_QuerySchemeManager.default, {
83
85
  gridKey: gridKey,
84
86
  visible: querySchemeVisible,
@@ -10,6 +10,7 @@ import { DeleteOutlined, HolderOutlined } from '@ant-design/icons';
10
10
  import { FormGrid, FormItem, FormLayout, Input, Select, NumberPicker, Switch } from '@formily/antd-v5';
11
11
  import { createSchemaField } from '@formily/react';
12
12
  import ArrayTable from "../../array-table";
13
+ import { normalizeCellAlign } from "./columnGroupUtils";
13
14
  import NameColumnRenderer from "./NameColumnRenderer";
14
15
  var SchemaField = createSchemaField({
15
16
  components: {
@@ -294,7 +295,7 @@ var ColumnConfigForm = function ColumnConfigForm(_ref) {
294
295
  return /*#__PURE__*/React.createElement("span", null, "-");
295
296
  }
296
297
  return /*#__PURE__*/React.createElement(Select, {
297
- value: props.value || 'custom-cell-left',
298
+ value: normalizeCellAlign(props.value),
298
299
  onChange: props.onChange,
299
300
  options: [{
300
301
  value: 'custom-cell-left',
@@ -23,7 +23,7 @@ import React, { useCallback, useMemo, useState, useRef, useEffect } from 'react'
23
23
  import { Button, Select, Switch, Space, Popconfirm, message, Tag } from 'antd';
24
24
  import { DeleteOutlined, FolderOutlined, FolderAddOutlined, FileOutlined } from '@ant-design/icons';
25
25
  import { AgGridReact } from 'ag-grid-react';
26
- import { generateId } from "./columnGroupUtils";
26
+ import { generateId, normalizeCellAlign } from "./columnGroupUtils";
27
27
  import { DebounceNumberInput } from "./DebounceInputs";
28
28
  import { useAgGridTheme } from "../theme";
29
29
  import { ColumnNameCellRenderer } from "./ColumnNameCellRenderer";
@@ -172,7 +172,7 @@ var AlignmentCellRenderer = function AlignmentCellRenderer(props) {
172
172
  if (!item || item.type !== 'column') return /*#__PURE__*/React.createElement("span", null, "-");
173
173
 
174
174
  // 标准化 cellClass 值,默认为左对齐
175
- var normalizedValue = item.cellClass || 'custom-cell-left';
175
+ var normalizedValue = normalizeCellAlign(item.cellClass);
176
176
  return /*#__PURE__*/React.createElement(Select, {
177
177
  value: normalizedValue,
178
178
  onChange: function onChange(val) {
@@ -6,6 +6,11 @@ interface ColumnSettingProps {
6
6
  visible: boolean;
7
7
  onClose: () => void;
8
8
  onSaveColumnState: (state: any) => void;
9
+ /**
10
+ * 调用方自带的原始列定义(含 cellRenderer 等),优先于 Context。
11
+ * ArrayTable 不在 AgGridPlus 的 Context 里,不传会导致保存后重建出裸列、单元格空白。@author nokecy
12
+ */
13
+ allColDefs?: any[];
9
14
  }
10
15
  /**
11
16
  * 列方案管理组件 - 集成列配置和列方案管理
@@ -49,14 +49,15 @@ var ColumnSetting = function ColumnSetting(_ref) {
49
49
  gridApi = _ref.gridApi,
50
50
  visible = _ref.visible,
51
51
  onClose = _ref.onClose,
52
- onSaveColumnState = _ref.onSaveColumnState;
52
+ onSaveColumnState = _ref.onSaveColumnState,
53
+ allColDefsProp = _ref.allColDefs;
53
54
  var gridTheme = useAgGridTheme();
54
55
  // 使用新的集中式方案管理 API(包含状态数据和操作方法)
55
56
  var _useGridSchemes = useGridSchemes(),
56
57
  columnSchemes = _useGridSchemes.columnSchemes,
57
58
  currentSchemes = _useGridSchemes.currentSchemes,
58
- allColDefs = _useGridSchemes.allColDefs,
59
- initialColumnDefs = _useGridSchemes.initialColumnDefs,
59
+ contextAllColDefs = _useGridSchemes.allColDefs,
60
+ contextInitialColumnDefs = _useGridSchemes.initialColumnDefs,
60
61
  saveColumnScheme = _useGridSchemes.saveColumnScheme,
61
62
  deleteColumnScheme = _useGridSchemes.deleteColumnScheme,
62
63
  setCurrentColumnScheme = _useGridSchemes.setCurrentColumnScheme,
@@ -66,6 +67,10 @@ var ColumnSetting = function ColumnSetting(_ref) {
66
67
  globalConfigPermissions = _useGridSchemes.globalConfigPermissions,
67
68
  isUsingGlobalFallback = _useGridSchemes.isUsingGlobalFallback;
68
69
 
70
+ // 调用方传入的列定义优先:Context 里的属于外层 AgGridPlus 或为空 @author nokecy
71
+ var allColDefs = allColDefsProp !== null && allColDefsProp !== void 0 ? allColDefsProp : contextAllColDefs;
72
+ var initialColumnDefs = allColDefsProp !== null && allColDefsProp !== void 0 ? allColDefsProp : contextInitialColumnDefs;
73
+
69
74
  // 解构权限信息
70
75
  var canApplyToGlobal = (_globalConfigPermissi = globalConfigPermissions === null || globalConfigPermissions === void 0 ? void 0 : globalConfigPermissions.canApplyToGlobal) !== null && _globalConfigPermissi !== void 0 ? _globalConfigPermissi : false;
71
76
  var canResetAllUsers = (_globalConfigPermissi2 = globalConfigPermissions === null || globalConfigPermissions === void 0 ? void 0 : globalConfigPermissions.canResetAllUsers) !== null && _globalConfigPermissi2 !== void 0 ? _globalConfigPermissi2 : false;
@@ -95,3 +95,9 @@ export declare function isOldSchemeData(data: any[]): boolean;
95
95
  * @returns AG-Grid columnState 数组
96
96
  */
97
97
  export declare function flatConfigToColumnState(flatConfig: FlatColumnItem[], originalColumnDefs?: (ColDef | ColGroupDef)[]): any[];
98
+ /**
99
+ * 把列上的 cellClass 归一为对齐下拉的三个选项值。
100
+ * 列定义里可能是 AG-Grid 数值类型自带的 ag-right-aligned-cell、ArrayTable 的 ag-cell-right 等,
101
+ * 下拉只认 custom-cell-*,不归一就会把原始类名直接显示出来。@author nokecy
102
+ */
103
+ export declare function normalizeCellAlign(cellClass: unknown): 'custom-cell-left' | 'custom-cell-centered' | 'custom-cell-right';
@@ -615,4 +615,16 @@ export function flatConfigToColumnState(flatConfig, originalColumnDefs) {
615
615
  }
616
616
  }
617
617
  return result;
618
+ }
619
+
620
+ /**
621
+ * 把列上的 cellClass 归一为对齐下拉的三个选项值。
622
+ * 列定义里可能是 AG-Grid 数值类型自带的 ag-right-aligned-cell、ArrayTable 的 ag-cell-right 等,
623
+ * 下拉只认 custom-cell-*,不归一就会把原始类名直接显示出来。@author nokecy
624
+ */
625
+ export function normalizeCellAlign(cellClass) {
626
+ var text = Array.isArray(cellClass) ? cellClass.join(' ') : typeof cellClass === 'string' ? cellClass : '';
627
+ if (/right/.test(text)) return 'custom-cell-right';
628
+ if (/cent/.test(text)) return 'custom-cell-centered';
629
+ return 'custom-cell-left';
618
630
  }
@@ -16,6 +16,7 @@ import QuerySchemeManager from "./QuerySchemeManager";
16
16
  var Setting = function Setting(props) {
17
17
  var gridKey = props.gridKey,
18
18
  gridApi = props.gridApi,
19
+ allColDefs = props.allColDefs,
19
20
  onSaveColumnState = props.onSaveColumnState,
20
21
  _props$showQuerySchem = props.showQueryScheme,
21
22
  showQueryScheme = _props$showQuerySchem === void 0 ? true : _props$showQuerySchem;
@@ -68,7 +69,8 @@ var Setting = function Setting(props) {
68
69
  onClose: function onClose() {
69
70
  return setColumnSettingVisible(false);
70
71
  },
71
- onSaveColumnState: onSaveColumnState || function () {}
72
+ onSaveColumnState: onSaveColumnState || function () {},
73
+ allColDefs: allColDefs
72
74
  }), gridKey && showQueryScheme && /*#__PURE__*/React.createElement(QuerySchemeManager, {
73
75
  gridKey: gridKey,
74
76
  visible: querySchemeVisible,