@nokecy/qc-ui 1.1.0 → 1.1.2
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/ag-grid-plus/ag-gridPlus.js +47 -0
- package/dist/cjs/array-table/index.js +43 -43
- package/dist/cjs/draggableModal/index.js +27 -3
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +47 -0
- package/dist/esm/array-table/index.js +43 -43
- package/dist/esm/draggableModal/index.js +28 -4
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -376,6 +376,53 @@ function AgGridPlus(props) {
|
|
|
376
376
|
};
|
|
377
377
|
}, [gridKey, currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id, derivedColumnState, ready // 添加 ready 依赖,确保 Grid 初始化完成后再应用方案
|
|
378
378
|
]);
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 【新增】监听当前方案 ID 变化,当方案被删除时重置列状态
|
|
382
|
+
*
|
|
383
|
+
* 场景:
|
|
384
|
+
* - 用户删除当前正在使用的方案
|
|
385
|
+
* - currentColumnScheme?.id 从有值变为 null
|
|
386
|
+
*
|
|
387
|
+
* 行为:
|
|
388
|
+
* - 重置列状态为初始状态(默认顺序、宽度等)
|
|
389
|
+
* - 清除所有过滤器
|
|
390
|
+
* - 清除列样式配置
|
|
391
|
+
*
|
|
392
|
+
* 优势:
|
|
393
|
+
* - 符合单向数据流架构
|
|
394
|
+
* - 适用于所有方案切换场景(删除/取消选择)
|
|
395
|
+
* - 用户体验好,自动恢复到初始状态
|
|
396
|
+
*/
|
|
397
|
+
var prevSchemeIdRef = (0, _react.useRef)(currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id);
|
|
398
|
+
(0, _react.useEffect)(function () {
|
|
399
|
+
if (!gridKey || !apiRef.current || !ready) return;
|
|
400
|
+
var prevSchemeId = prevSchemeIdRef.current;
|
|
401
|
+
var currentSchemeId = currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id;
|
|
402
|
+
// 检测方案被删除:从有值变为 null/undefined
|
|
403
|
+
if (prevSchemeId && !currentSchemeId) {
|
|
404
|
+
Promise.resolve().then(function () {
|
|
405
|
+
if (!apiRef.current) return;
|
|
406
|
+
|
|
407
|
+
// 1. 重置列状态为初始状态
|
|
408
|
+
|
|
409
|
+
apiRef.current.resetColumnState();
|
|
410
|
+
|
|
411
|
+
// 2. 清除所有过滤器
|
|
412
|
+
|
|
413
|
+
apiRef.current.setFilterModel(null);
|
|
414
|
+
|
|
415
|
+
// 3. 清除列样式配置
|
|
416
|
+
setColumnCellClass({});
|
|
417
|
+
}).catch(function (error) {
|
|
418
|
+
console.error('[AgGridPlus] 重置列状态失败:', error);
|
|
419
|
+
_logger.logger.error('[AgGridPlus] 重置列状态失败', error);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// 更新引用
|
|
424
|
+
prevSchemeIdRef.current = currentSchemeId;
|
|
425
|
+
}, [gridKey, currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id, ready]);
|
|
379
426
|
(0, _react.useEffect)(function () {
|
|
380
427
|
setRowData(dataSource || propRowData || []);
|
|
381
428
|
}, [dataSource, propRowData]);
|
|
@@ -17,8 +17,6 @@ var _preview = _interopRequireDefault(require("./preview"));
|
|
|
17
17
|
var _antd = require("antd");
|
|
18
18
|
var _setting = _interopRequireDefault(require("../ag-grid-plus/setting"));
|
|
19
19
|
var _gridContext = require("../ag-grid-plus/context/gridContext");
|
|
20
|
-
var _useSchemeManager = require("../ag-grid-plus/context/useSchemeManager");
|
|
21
|
-
var _localStorageAdapter = require("../ag-grid-plus/shared/storage/localStorageAdapter");
|
|
22
20
|
var _columnGroupUtils = require("../ag-grid-plus/setting/columnGroupUtils");
|
|
23
21
|
var _theme = require("../ag-grid-plus/theme");
|
|
24
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -38,7 +36,14 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
38
36
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // 导入 AG-Grid v33 主题
|
|
39
37
|
//@ts-ignore
|
|
40
38
|
var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
41
|
-
var height = props.height
|
|
39
|
+
var height = props.height,
|
|
40
|
+
gridKey = props.gridKey;
|
|
41
|
+
|
|
42
|
+
// 【新增】运行时验证 gridKey
|
|
43
|
+
if (!gridKey) {
|
|
44
|
+
console.error('[ArrayTable] gridKey 是必需的属性,用于方案管理和状态持久化');
|
|
45
|
+
throw new Error('[ArrayTable] gridKey 属性是必需的。请在 x-component-props 中提供 gridKey');
|
|
46
|
+
}
|
|
42
47
|
var _useState = (0, _react.useState)(false),
|
|
43
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
49
|
isAdd = _useState2[0],
|
|
@@ -71,10 +76,12 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
71
76
|
var _useRowDrag = (0, _hooks.useRowDrag)(field),
|
|
72
77
|
handleRowDragMove = _useRowDrag.handleRowDragMove;
|
|
73
78
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
// 直接使用 Context 获取方案管理状态
|
|
80
|
+
// ArrayTable 外层已经提供了完整的 GridPlusContext.Provider
|
|
81
|
+
var context = (0, _react.useContext)(_gridContext.GridPlusContext);
|
|
82
|
+
var _ref = context || {},
|
|
83
|
+
currentSchemes = _ref.currentSchemes,
|
|
84
|
+
columnSchemes = _ref.columnSchemes;
|
|
78
85
|
|
|
79
86
|
// 获取当前表格的激活方案
|
|
80
87
|
var currentScheme = (0, _react.useMemo)(function () {
|
|
@@ -294,8 +301,8 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
294
301
|
' <span data-ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon"></span>' + ' <span data-ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon"></span>' + ' <span data-ref="eSortNone" class="ag-header-icon ag-sort-none-icon"></span>' + " </div>" + "</div>"
|
|
295
302
|
}
|
|
296
303
|
},
|
|
297
|
-
getRowId: function getRowId(
|
|
298
|
-
var data =
|
|
304
|
+
getRowId: function getRowId(_ref2) {
|
|
305
|
+
var data = _ref2.data;
|
|
299
306
|
return data._id || data.id;
|
|
300
307
|
}
|
|
301
308
|
// rowDragEntireRow={true}
|
|
@@ -329,43 +336,36 @@ var ArrayTableInner = (0, _react2.observer)(function (props) {
|
|
|
329
336
|
ArrayTableInner.displayName = "ArrayTableInner";
|
|
330
337
|
|
|
331
338
|
/**
|
|
332
|
-
* ArrayTable 组件
|
|
339
|
+
* ArrayTable 组件
|
|
340
|
+
*
|
|
341
|
+
* 注意:需要在外部使用 GridPlusContext.Provider 包裹以提供方案管理功能
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```tsx
|
|
345
|
+
* const adapter = useMemo(() => new LocalStorageSchemeAdapter({
|
|
346
|
+
* storageKey: `array-table-schemes-${gridKey}`
|
|
347
|
+
* }), [gridKey]);
|
|
348
|
+
*
|
|
349
|
+
* const schemeManager = useSchemeManager({ adapter, autoLoad: true });
|
|
350
|
+
*
|
|
351
|
+
* const contextValue = useMemo(() => ({
|
|
352
|
+
* extensibleColumns: [],
|
|
353
|
+
* columnState: undefined,
|
|
354
|
+
* onSaveColumnState: () => {},
|
|
355
|
+
* applyToGlobal: () => {},
|
|
356
|
+
* resetCurrent: () => {},
|
|
357
|
+
* resetAll: () => {},
|
|
358
|
+
* queryFormItems: [],
|
|
359
|
+
* ...schemeManager
|
|
360
|
+
* }), [schemeManager]);
|
|
333
361
|
*
|
|
334
|
-
*
|
|
362
|
+
* <GridPlusContext.Provider value={contextValue}>
|
|
363
|
+
* <ArrayTable gridKey="my-table" height={400} />
|
|
364
|
+
* </GridPlusContext.Provider>
|
|
365
|
+
* ```
|
|
335
366
|
*/
|
|
336
367
|
//@ts-ignore
|
|
337
|
-
var ArrayTable =
|
|
338
|
-
// 创建 LocalStorage 适配器实例 (使用 useMemo 避免重复创建)
|
|
339
|
-
var adapter = (0, _react.useMemo)(function () {
|
|
340
|
-
return new _localStorageAdapter.LocalStorageSchemeAdapter({
|
|
341
|
-
storageKey: "array-table-schemes-".concat(props.gridKey || 'default'),
|
|
342
|
-
enableDebugLog: false
|
|
343
|
-
});
|
|
344
|
-
}, [props.gridKey]);
|
|
345
|
-
|
|
346
|
-
// 初始化方案管理器
|
|
347
|
-
var schemeManager = (0, _useSchemeManager.useSchemeManager)({
|
|
348
|
-
adapter: adapter,
|
|
349
|
-
autoLoad: true,
|
|
350
|
-
showErrorMessage: true
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// 构建 Context Value
|
|
354
|
-
var contextValue = (0, _react.useMemo)(function () {
|
|
355
|
-
return _objectSpread({
|
|
356
|
-
extensibleColumns: [],
|
|
357
|
-
columnState: undefined,
|
|
358
|
-
onSaveColumnState: function onSaveColumnState() {},
|
|
359
|
-
applyToGlobal: function applyToGlobal() {},
|
|
360
|
-
resetCurrent: function resetCurrent() {},
|
|
361
|
-
resetAll: function resetAll() {},
|
|
362
|
-
queryFormItems: []
|
|
363
|
-
}, schemeManager);
|
|
364
|
-
}, [schemeManager]);
|
|
365
|
-
return /*#__PURE__*/_react.default.createElement(_gridContext.GridPlusContext.Provider, {
|
|
366
|
-
value: contextValue
|
|
367
|
-
}, /*#__PURE__*/_react.default.createElement(ArrayTableInner, props));
|
|
368
|
-
});
|
|
368
|
+
var ArrayTable = ArrayTableInner;
|
|
369
369
|
ArrayTable.displayName = "ArrayTable";
|
|
370
370
|
ArrayTable.Column = function () {
|
|
371
371
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null);
|
|
@@ -9,7 +9,7 @@ var _antd = require("antd");
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactDraggable = _interopRequireDefault(require("react-draggable"));
|
|
11
11
|
require("./style.less");
|
|
12
|
-
var _excluded = ["wrapClassName", "width"];
|
|
12
|
+
var _excluded = ["wrapClassName", "width", "open"];
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
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); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -42,6 +42,7 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
42
42
|
bounds = _useState4[0],
|
|
43
43
|
setBounds = _useState4[1];
|
|
44
44
|
var draggleRef = (0, _react.useRef)(null);
|
|
45
|
+
var modalContentRef = (0, _react.useRef)(null);
|
|
45
46
|
|
|
46
47
|
// 调整大小相关状态
|
|
47
48
|
var _useState5 = (0, _react.useState)(false),
|
|
@@ -67,10 +68,24 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
67
68
|
modalPosition = _useState12[0],
|
|
68
69
|
setModalPosition = _useState12[1];
|
|
69
70
|
|
|
70
|
-
// 解构 props,分离出 wrapClassName
|
|
71
|
+
// 解构 props,分离出 wrapClassName 和 open
|
|
71
72
|
var propsWrapClassName = props.wrapClassName,
|
|
72
73
|
width = props.width,
|
|
74
|
+
open = props.open,
|
|
73
75
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
76
|
+
|
|
77
|
+
// 修复 AgGrid 等组件在 Modal 中高度不展开的问题
|
|
78
|
+
// 当 Modal 打开时触发 window resize 事件
|
|
79
|
+
(0, _react.useEffect)(function () {
|
|
80
|
+
if (open) {
|
|
81
|
+
// 使用 requestAnimationFrame 和 setTimeout 确保 DOM 完全渲染
|
|
82
|
+
requestAnimationFrame(function () {
|
|
83
|
+
setTimeout(function () {
|
|
84
|
+
window.dispatchEvent(new Event('resize'));
|
|
85
|
+
}, 100);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [open]);
|
|
74
89
|
var _onStart = function onStart(_event, uiData) {
|
|
75
90
|
var _draggleRef$current;
|
|
76
91
|
var _window$document$docu = window.document.documentElement,
|
|
@@ -167,12 +182,20 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
167
182
|
x: newLeft,
|
|
168
183
|
y: newTop
|
|
169
184
|
});
|
|
185
|
+
|
|
186
|
+
// 触发 window resize 事件,通知内部组件(如 AgGrid)重新计算尺寸
|
|
187
|
+
window.dispatchEvent(new Event('resize'));
|
|
170
188
|
};
|
|
171
189
|
var handleMouseUp = function handleMouseUp() {
|
|
172
190
|
setIsResizing(false);
|
|
173
191
|
setResizeDirection('');
|
|
174
192
|
document.removeEventListener('mousemove', handleMouseMove);
|
|
175
193
|
document.removeEventListener('mouseup', handleMouseUp);
|
|
194
|
+
|
|
195
|
+
// 拖拽结束后再次触发 resize 事件,确保内部组件完全更新
|
|
196
|
+
setTimeout(function () {
|
|
197
|
+
window.dispatchEvent(new Event('resize'));
|
|
198
|
+
}, 50);
|
|
176
199
|
};
|
|
177
200
|
document.addEventListener('mousemove', handleMouseMove);
|
|
178
201
|
document.addEventListener('mouseup', handleMouseUp);
|
|
@@ -183,7 +206,8 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
183
206
|
var mergedWrapClassName = [propsWrapClassName, resizingClass].filter(Boolean).join(' ');
|
|
184
207
|
return /*#__PURE__*/_react.default.createElement(_antd.Modal, _extends({
|
|
185
208
|
maskClosable: false,
|
|
186
|
-
width: width
|
|
209
|
+
width: width,
|
|
210
|
+
open: open
|
|
187
211
|
}, restProps, {
|
|
188
212
|
wrapClassName: mergedWrapClassName,
|
|
189
213
|
title: /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -368,6 +368,53 @@ function AgGridPlus(props) {
|
|
|
368
368
|
};
|
|
369
369
|
}, [gridKey, currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id, derivedColumnState, ready // 添加 ready 依赖,确保 Grid 初始化完成后再应用方案
|
|
370
370
|
]);
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* 【新增】监听当前方案 ID 变化,当方案被删除时重置列状态
|
|
374
|
+
*
|
|
375
|
+
* 场景:
|
|
376
|
+
* - 用户删除当前正在使用的方案
|
|
377
|
+
* - currentColumnScheme?.id 从有值变为 null
|
|
378
|
+
*
|
|
379
|
+
* 行为:
|
|
380
|
+
* - 重置列状态为初始状态(默认顺序、宽度等)
|
|
381
|
+
* - 清除所有过滤器
|
|
382
|
+
* - 清除列样式配置
|
|
383
|
+
*
|
|
384
|
+
* 优势:
|
|
385
|
+
* - 符合单向数据流架构
|
|
386
|
+
* - 适用于所有方案切换场景(删除/取消选择)
|
|
387
|
+
* - 用户体验好,自动恢复到初始状态
|
|
388
|
+
*/
|
|
389
|
+
var prevSchemeIdRef = useRef(currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id);
|
|
390
|
+
useEffect(function () {
|
|
391
|
+
if (!gridKey || !apiRef.current || !ready) return;
|
|
392
|
+
var prevSchemeId = prevSchemeIdRef.current;
|
|
393
|
+
var currentSchemeId = currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id;
|
|
394
|
+
// 检测方案被删除:从有值变为 null/undefined
|
|
395
|
+
if (prevSchemeId && !currentSchemeId) {
|
|
396
|
+
Promise.resolve().then(function () {
|
|
397
|
+
if (!apiRef.current) return;
|
|
398
|
+
|
|
399
|
+
// 1. 重置列状态为初始状态
|
|
400
|
+
|
|
401
|
+
apiRef.current.resetColumnState();
|
|
402
|
+
|
|
403
|
+
// 2. 清除所有过滤器
|
|
404
|
+
|
|
405
|
+
apiRef.current.setFilterModel(null);
|
|
406
|
+
|
|
407
|
+
// 3. 清除列样式配置
|
|
408
|
+
setColumnCellClass({});
|
|
409
|
+
}).catch(function (error) {
|
|
410
|
+
console.error('[AgGridPlus] 重置列状态失败:', error);
|
|
411
|
+
logger.error('[AgGridPlus] 重置列状态失败', error);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// 更新引用
|
|
416
|
+
prevSchemeIdRef.current = currentSchemeId;
|
|
417
|
+
}, [gridKey, currentColumnScheme === null || currentColumnScheme === void 0 ? void 0 : currentColumnScheme.id, ready]);
|
|
371
418
|
useEffect(function () {
|
|
372
419
|
setRowData(dataSource || propRowData || []);
|
|
373
420
|
}, [dataSource, propRowData]);
|
|
@@ -25,8 +25,6 @@ import PreviewArrayTable from "./preview";
|
|
|
25
25
|
import { Space } from "antd";
|
|
26
26
|
import Setting from "../ag-grid-plus/setting";
|
|
27
27
|
import { GridPlusContext } from "../ag-grid-plus/context/gridContext";
|
|
28
|
-
import { useSchemeManager } from "../ag-grid-plus/context/useSchemeManager";
|
|
29
|
-
import { LocalStorageSchemeAdapter } from "../ag-grid-plus/shared/storage/localStorageAdapter";
|
|
30
28
|
import { flatConfigToColumnState, flatConfigToGridState } from "../ag-grid-plus/setting/columnGroupUtils";
|
|
31
29
|
|
|
32
30
|
// 导入 AG-Grid v33 主题
|
|
@@ -34,7 +32,14 @@ import { agGridTheme } from "../ag-grid-plus/theme";
|
|
|
34
32
|
|
|
35
33
|
//@ts-ignore
|
|
36
34
|
var ArrayTableInner = observer(function (props) {
|
|
37
|
-
var height = props.height
|
|
35
|
+
var height = props.height,
|
|
36
|
+
gridKey = props.gridKey;
|
|
37
|
+
|
|
38
|
+
// 【新增】运行时验证 gridKey
|
|
39
|
+
if (!gridKey) {
|
|
40
|
+
console.error('[ArrayTable] gridKey 是必需的属性,用于方案管理和状态持久化');
|
|
41
|
+
throw new Error('[ArrayTable] gridKey 属性是必需的。请在 x-component-props 中提供 gridKey');
|
|
42
|
+
}
|
|
38
43
|
var _useState = useState(false),
|
|
39
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
45
|
isAdd = _useState2[0],
|
|
@@ -67,10 +72,12 @@ var ArrayTableInner = observer(function (props) {
|
|
|
67
72
|
var _useRowDrag = useRowDrag(field),
|
|
68
73
|
handleRowDragMove = _useRowDrag.handleRowDragMove;
|
|
69
74
|
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
// 直接使用 Context 获取方案管理状态
|
|
76
|
+
// ArrayTable 外层已经提供了完整的 GridPlusContext.Provider
|
|
77
|
+
var context = useContext(GridPlusContext);
|
|
78
|
+
var _ref = context || {},
|
|
79
|
+
currentSchemes = _ref.currentSchemes,
|
|
80
|
+
columnSchemes = _ref.columnSchemes;
|
|
74
81
|
|
|
75
82
|
// 获取当前表格的激活方案
|
|
76
83
|
var currentScheme = useMemo(function () {
|
|
@@ -290,8 +297,8 @@ var ArrayTableInner = observer(function (props) {
|
|
|
290
297
|
' <span data-ref="eSortAsc" class="ag-header-icon ag-sort-ascending-icon"></span>' + ' <span data-ref="eSortDesc" class="ag-header-icon ag-sort-descending-icon"></span>' + ' <span data-ref="eSortNone" class="ag-header-icon ag-sort-none-icon"></span>' + " </div>" + "</div>"
|
|
291
298
|
}
|
|
292
299
|
},
|
|
293
|
-
getRowId: function getRowId(
|
|
294
|
-
var data =
|
|
300
|
+
getRowId: function getRowId(_ref2) {
|
|
301
|
+
var data = _ref2.data;
|
|
295
302
|
return data._id || data.id;
|
|
296
303
|
}
|
|
297
304
|
// rowDragEntireRow={true}
|
|
@@ -325,43 +332,36 @@ var ArrayTableInner = observer(function (props) {
|
|
|
325
332
|
ArrayTableInner.displayName = "ArrayTableInner";
|
|
326
333
|
|
|
327
334
|
/**
|
|
328
|
-
* ArrayTable 组件
|
|
335
|
+
* ArrayTable 组件
|
|
336
|
+
*
|
|
337
|
+
* 注意:需要在外部使用 GridPlusContext.Provider 包裹以提供方案管理功能
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```tsx
|
|
341
|
+
* const adapter = useMemo(() => new LocalStorageSchemeAdapter({
|
|
342
|
+
* storageKey: `array-table-schemes-${gridKey}`
|
|
343
|
+
* }), [gridKey]);
|
|
344
|
+
*
|
|
345
|
+
* const schemeManager = useSchemeManager({ adapter, autoLoad: true });
|
|
346
|
+
*
|
|
347
|
+
* const contextValue = useMemo(() => ({
|
|
348
|
+
* extensibleColumns: [],
|
|
349
|
+
* columnState: undefined,
|
|
350
|
+
* onSaveColumnState: () => {},
|
|
351
|
+
* applyToGlobal: () => {},
|
|
352
|
+
* resetCurrent: () => {},
|
|
353
|
+
* resetAll: () => {},
|
|
354
|
+
* queryFormItems: [],
|
|
355
|
+
* ...schemeManager
|
|
356
|
+
* }), [schemeManager]);
|
|
329
357
|
*
|
|
330
|
-
*
|
|
358
|
+
* <GridPlusContext.Provider value={contextValue}>
|
|
359
|
+
* <ArrayTable gridKey="my-table" height={400} />
|
|
360
|
+
* </GridPlusContext.Provider>
|
|
361
|
+
* ```
|
|
331
362
|
*/
|
|
332
363
|
//@ts-ignore
|
|
333
|
-
var ArrayTable =
|
|
334
|
-
// 创建 LocalStorage 适配器实例 (使用 useMemo 避免重复创建)
|
|
335
|
-
var adapter = useMemo(function () {
|
|
336
|
-
return new LocalStorageSchemeAdapter({
|
|
337
|
-
storageKey: "array-table-schemes-".concat(props.gridKey || 'default'),
|
|
338
|
-
enableDebugLog: false
|
|
339
|
-
});
|
|
340
|
-
}, [props.gridKey]);
|
|
341
|
-
|
|
342
|
-
// 初始化方案管理器
|
|
343
|
-
var schemeManager = useSchemeManager({
|
|
344
|
-
adapter: adapter,
|
|
345
|
-
autoLoad: true,
|
|
346
|
-
showErrorMessage: true
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// 构建 Context Value
|
|
350
|
-
var contextValue = useMemo(function () {
|
|
351
|
-
return _objectSpread({
|
|
352
|
-
extensibleColumns: [],
|
|
353
|
-
columnState: undefined,
|
|
354
|
-
onSaveColumnState: function onSaveColumnState() {},
|
|
355
|
-
applyToGlobal: function applyToGlobal() {},
|
|
356
|
-
resetCurrent: function resetCurrent() {},
|
|
357
|
-
resetAll: function resetAll() {},
|
|
358
|
-
queryFormItems: []
|
|
359
|
-
}, schemeManager);
|
|
360
|
-
}, [schemeManager]);
|
|
361
|
-
return /*#__PURE__*/React.createElement(GridPlusContext.Provider, {
|
|
362
|
-
value: contextValue
|
|
363
|
-
}, /*#__PURE__*/React.createElement(ArrayTableInner, props));
|
|
364
|
-
});
|
|
364
|
+
var ArrayTable = ArrayTableInner;
|
|
365
365
|
ArrayTable.displayName = "ArrayTable";
|
|
366
366
|
ArrayTable.Column = function () {
|
|
367
367
|
return /*#__PURE__*/React.createElement(Fragment, null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["wrapClassName", "width"];
|
|
1
|
+
var _excluded = ["wrapClassName", "width", "open"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -9,7 +9,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { Modal } from 'antd';
|
|
12
|
-
import React, { useRef, useState } from 'react';
|
|
12
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
13
13
|
import Draggable from 'react-draggable';
|
|
14
14
|
import "./style.less";
|
|
15
15
|
|
|
@@ -33,6 +33,7 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
33
33
|
bounds = _useState4[0],
|
|
34
34
|
setBounds = _useState4[1];
|
|
35
35
|
var draggleRef = useRef(null);
|
|
36
|
+
var modalContentRef = useRef(null);
|
|
36
37
|
|
|
37
38
|
// 调整大小相关状态
|
|
38
39
|
var _useState5 = useState(false),
|
|
@@ -58,10 +59,24 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
58
59
|
modalPosition = _useState12[0],
|
|
59
60
|
setModalPosition = _useState12[1];
|
|
60
61
|
|
|
61
|
-
// 解构 props,分离出 wrapClassName
|
|
62
|
+
// 解构 props,分离出 wrapClassName 和 open
|
|
62
63
|
var propsWrapClassName = props.wrapClassName,
|
|
63
64
|
width = props.width,
|
|
65
|
+
open = props.open,
|
|
64
66
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
67
|
+
|
|
68
|
+
// 修复 AgGrid 等组件在 Modal 中高度不展开的问题
|
|
69
|
+
// 当 Modal 打开时触发 window resize 事件
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
if (open) {
|
|
72
|
+
// 使用 requestAnimationFrame 和 setTimeout 确保 DOM 完全渲染
|
|
73
|
+
requestAnimationFrame(function () {
|
|
74
|
+
setTimeout(function () {
|
|
75
|
+
window.dispatchEvent(new Event('resize'));
|
|
76
|
+
}, 100);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, [open]);
|
|
65
80
|
var _onStart = function onStart(_event, uiData) {
|
|
66
81
|
var _draggleRef$current;
|
|
67
82
|
var _window$document$docu = window.document.documentElement,
|
|
@@ -158,12 +173,20 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
158
173
|
x: newLeft,
|
|
159
174
|
y: newTop
|
|
160
175
|
});
|
|
176
|
+
|
|
177
|
+
// 触发 window resize 事件,通知内部组件(如 AgGrid)重新计算尺寸
|
|
178
|
+
window.dispatchEvent(new Event('resize'));
|
|
161
179
|
};
|
|
162
180
|
var handleMouseUp = function handleMouseUp() {
|
|
163
181
|
setIsResizing(false);
|
|
164
182
|
setResizeDirection('');
|
|
165
183
|
document.removeEventListener('mousemove', handleMouseMove);
|
|
166
184
|
document.removeEventListener('mouseup', handleMouseUp);
|
|
185
|
+
|
|
186
|
+
// 拖拽结束后再次触发 resize 事件,确保内部组件完全更新
|
|
187
|
+
setTimeout(function () {
|
|
188
|
+
window.dispatchEvent(new Event('resize'));
|
|
189
|
+
}, 50);
|
|
167
190
|
};
|
|
168
191
|
document.addEventListener('mousemove', handleMouseMove);
|
|
169
192
|
document.addEventListener('mouseup', handleMouseUp);
|
|
@@ -174,7 +197,8 @@ var DraggableModal = function DraggableModal(props) {
|
|
|
174
197
|
var mergedWrapClassName = [propsWrapClassName, resizingClass].filter(Boolean).join(' ');
|
|
175
198
|
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
176
199
|
maskClosable: false,
|
|
177
|
-
width: width
|
|
200
|
+
width: width,
|
|
201
|
+
open: open
|
|
178
202
|
}, restProps, {
|
|
179
203
|
wrapClassName: mergedWrapClassName,
|
|
180
204
|
title: /*#__PURE__*/React.createElement("div", {
|