@nokecy/qc-ui 1.0.69 → 1.0.71
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 +394 -206
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/cjs/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.js +143 -0
- package/dist/cjs/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/errors/index.js +31 -0
- package/dist/cjs/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/cjs/ag-grid-plus/errors/types.js +137 -0
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/hooks/index.js +51 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +224 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +230 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/index.js +85 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/queryForm/index.js +18 -7
- package/dist/cjs/ag-grid-plus/queryForm/index.less +24 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +580 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +12 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +30 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +65 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +113 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +261 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +155 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +342 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +289 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +19 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.js +39 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/index.js +124 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +368 -0
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/cjs/ag-grid-plus/schemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +113 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +955 -0
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/setting/index.js +74 -111
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.js +648 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.js +276 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.js +593 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.js +287 -0
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/cjs/ag-grid-plus/storage/index.js +49 -0
- package/dist/cjs/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/cjs/ag-grid-plus/storage/types.js +5 -0
- package/dist/cjs/ag-grid-plus/types.d.ts +310 -0
- package/dist/cjs/ag-grid-plus/types.js +5 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +265 -0
- package/dist/cjs/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/cjs/ag-grid-plus/utils/constants.js +56 -0
- package/dist/cjs/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/cjs/ag-grid-plus/utils/logger.js +119 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.js +39 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +84 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +395 -206
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/esm/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.js +137 -0
- package/dist/esm/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/errors/index.js +2 -0
- package/dist/esm/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/esm/ag-grid-plus/errors/types.js +135 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/esm/ag-grid-plus/hooks/index.js +10 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +217 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +225 -0
- package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/esm/ag-grid-plus/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/index.js +4 -1
- package/dist/esm/ag-grid-plus/interface.d.ts +27 -0
- package/dist/esm/ag-grid-plus/queryForm/index.less +7 -2
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +572 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +24 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +60 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +537 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.js +20 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +256 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +144 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +334 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +281 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.js +2 -0
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/esm/ag-grid-plus/schemes/constants.js +33 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +537 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/index.js +25 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +363 -0
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/esm/ag-grid-plus/schemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +104 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +946 -0
- package/dist/esm/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/esm/ag-grid-plus/setting/index.js +69 -107
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.js +643 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.js +273 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.js +587 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.js +275 -0
- package/dist/esm/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/esm/ag-grid-plus/storage/index.js +9 -0
- package/dist/esm/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/esm/ag-grid-plus/storage/types.js +1 -0
- package/dist/esm/ag-grid-plus/types.d.ts +310 -0
- package/dist/esm/ag-grid-plus/types.js +1 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +251 -0
- package/dist/esm/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/esm/ag-grid-plus/utils/constants.js +50 -0
- package/dist/esm/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/esm/ag-grid-plus/utils/logger.js +114 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.js +32 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +8 -2
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-Grid Plus 状态管理 Hook
|
|
3
|
+
*
|
|
4
|
+
* 使用 useReducer 统一管理组件的所有状态,
|
|
5
|
+
* 替代多个 useState 调用,提高性能和可维护性
|
|
6
|
+
*/
|
|
7
|
+
import { Dispatch } from 'react';
|
|
8
|
+
import { ColumnState } from 'ag-grid-community';
|
|
9
|
+
import type { ExtendedColumnState, ColumnCellConfigMap, QueryFilterState, PaginationState, RowDataArray } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Grid 状态接口
|
|
12
|
+
*/
|
|
13
|
+
export interface GridState {
|
|
14
|
+
/** Grid 是否已就绪 */
|
|
15
|
+
ready: boolean;
|
|
16
|
+
/** 加载状态 */
|
|
17
|
+
loading: boolean;
|
|
18
|
+
/** 列状态配置 */
|
|
19
|
+
columnState?: ExtendedColumnState[];
|
|
20
|
+
/** 列单元格样式映射 */
|
|
21
|
+
columnCellClass: ColumnCellConfigMap;
|
|
22
|
+
/** 行数据 */
|
|
23
|
+
rowData: RowDataArray;
|
|
24
|
+
/** 选中的行 */
|
|
25
|
+
selectRow: any;
|
|
26
|
+
/** 查询过滤器 */
|
|
27
|
+
queryFilter: QueryFilterState;
|
|
28
|
+
/** 排序列 */
|
|
29
|
+
sortColumn?: ColumnState;
|
|
30
|
+
/** 分页配置 */
|
|
31
|
+
pagination: PaginationState;
|
|
32
|
+
/** 查询表单项顺序 */
|
|
33
|
+
queryItemsOrder: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Action 类型枚举
|
|
37
|
+
*/
|
|
38
|
+
export declare enum GridActionType {
|
|
39
|
+
SET_READY = "SET_READY",
|
|
40
|
+
SET_LOADING = "SET_LOADING",
|
|
41
|
+
SET_COLUMN_STATE = "SET_COLUMN_STATE",
|
|
42
|
+
SET_COLUMN_CELL_CLASS = "SET_COLUMN_CELL_CLASS",
|
|
43
|
+
SET_ROW_DATA = "SET_ROW_DATA",
|
|
44
|
+
SET_SELECT_ROW = "SET_SELECT_ROW",
|
|
45
|
+
SET_QUERY_FILTER = "SET_QUERY_FILTER",
|
|
46
|
+
SET_SORT_COLUMN = "SET_SORT_COLUMN",
|
|
47
|
+
SET_PAGINATION = "SET_PAGINATION",
|
|
48
|
+
UPDATE_PAGINATION = "UPDATE_PAGINATION",
|
|
49
|
+
SET_QUERY_ITEMS_ORDER = "SET_QUERY_ITEMS_ORDER",
|
|
50
|
+
RESET_STATE = "RESET_STATE"
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Action 联合类型
|
|
54
|
+
*/
|
|
55
|
+
export type GridAction = {
|
|
56
|
+
type: GridActionType.SET_READY;
|
|
57
|
+
payload: boolean;
|
|
58
|
+
} | {
|
|
59
|
+
type: GridActionType.SET_LOADING;
|
|
60
|
+
payload: boolean;
|
|
61
|
+
} | {
|
|
62
|
+
type: GridActionType.SET_COLUMN_STATE;
|
|
63
|
+
payload: ExtendedColumnState[] | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
type: GridActionType.SET_COLUMN_CELL_CLASS;
|
|
66
|
+
payload: ColumnCellConfigMap;
|
|
67
|
+
} | {
|
|
68
|
+
type: GridActionType.SET_ROW_DATA;
|
|
69
|
+
payload: RowDataArray;
|
|
70
|
+
} | {
|
|
71
|
+
type: GridActionType.SET_SELECT_ROW;
|
|
72
|
+
payload: any;
|
|
73
|
+
} | {
|
|
74
|
+
type: GridActionType.SET_QUERY_FILTER;
|
|
75
|
+
payload: QueryFilterState;
|
|
76
|
+
} | {
|
|
77
|
+
type: GridActionType.SET_SORT_COLUMN;
|
|
78
|
+
payload: ColumnState | undefined;
|
|
79
|
+
} | {
|
|
80
|
+
type: GridActionType.SET_PAGINATION;
|
|
81
|
+
payload: PaginationState;
|
|
82
|
+
} | {
|
|
83
|
+
type: GridActionType.UPDATE_PAGINATION;
|
|
84
|
+
payload: Partial<PaginationState>;
|
|
85
|
+
} | {
|
|
86
|
+
type: GridActionType.SET_QUERY_ITEMS_ORDER;
|
|
87
|
+
payload: string[];
|
|
88
|
+
} | {
|
|
89
|
+
type: GridActionType.RESET_STATE;
|
|
90
|
+
payload: Partial<GridState>;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Grid 状态 Reducer
|
|
94
|
+
*/
|
|
95
|
+
export declare function gridReducer(state: GridState, action: GridAction): GridState;
|
|
96
|
+
/**
|
|
97
|
+
* useGridState Hook 配置
|
|
98
|
+
*/
|
|
99
|
+
export interface UseGridStateConfig {
|
|
100
|
+
/** 初始加载状态 */
|
|
101
|
+
loading?: boolean;
|
|
102
|
+
/** 初始分页配置 */
|
|
103
|
+
pageSize?: number;
|
|
104
|
+
/** 是否隐藏分页 */
|
|
105
|
+
hidePagination?: boolean;
|
|
106
|
+
/** 数据源(用于计算初始 total) */
|
|
107
|
+
dataSource?: any[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* useGridState Hook 返回值
|
|
111
|
+
*/
|
|
112
|
+
export interface UseGridStateReturn {
|
|
113
|
+
/** Grid 状态 */
|
|
114
|
+
state: GridState;
|
|
115
|
+
/** Dispatch 函数 */
|
|
116
|
+
dispatch: Dispatch<GridAction>;
|
|
117
|
+
/** 便捷的 actions */
|
|
118
|
+
actions: {
|
|
119
|
+
setReady: (ready: boolean) => void;
|
|
120
|
+
setLoading: (loading: boolean) => void;
|
|
121
|
+
setColumnState: (columnState: ExtendedColumnState[] | undefined) => void;
|
|
122
|
+
setColumnCellClass: (columnCellClass: ColumnCellConfigMap) => void;
|
|
123
|
+
setRowData: (rowData: RowDataArray) => void;
|
|
124
|
+
setSelectRow: (selectRow: any) => void;
|
|
125
|
+
setQueryFilter: (queryFilter: QueryFilterState) => void;
|
|
126
|
+
setSortColumn: (sortColumn: ColumnState | undefined) => void;
|
|
127
|
+
setPagination: (pagination: PaginationState) => void;
|
|
128
|
+
updatePagination: (pagination: Partial<PaginationState>) => void;
|
|
129
|
+
setQueryItemsOrder: (order: string[]) => void;
|
|
130
|
+
resetState: (state: Partial<GridState>) => void;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* AG-Grid Plus 状态管理 Hook
|
|
135
|
+
*
|
|
136
|
+
* @param config 配置对象
|
|
137
|
+
* @returns 状态和 actions
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```tsx
|
|
141
|
+
* const { state, actions } = useGridState({
|
|
142
|
+
* loading: false,
|
|
143
|
+
* pageSize: 200,
|
|
144
|
+
* hidePagination: false
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // 使用 actions
|
|
148
|
+
* actions.setLoading(true);
|
|
149
|
+
* actions.setRowData(newData);
|
|
150
|
+
* actions.updatePagination({ current: 2 });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function useGridState(config?: UseGridStateConfig): UseGridStateReturn;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GridActionType = void 0;
|
|
7
|
+
exports.gridReducer = gridReducer;
|
|
8
|
+
exports.useGridState = useGridState;
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
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); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
|
|
22
|
+
* AG-Grid Plus 状态管理 Hook
|
|
23
|
+
*
|
|
24
|
+
* 使用 useReducer 统一管理组件的所有状态,
|
|
25
|
+
* 替代多个 useState 调用,提高性能和可维护性
|
|
26
|
+
*/
|
|
27
|
+
// ============ State 定义 ============
|
|
28
|
+
/**
|
|
29
|
+
* Grid 状态接口
|
|
30
|
+
*/
|
|
31
|
+
// ============ Action 定义 ============
|
|
32
|
+
/**
|
|
33
|
+
* Action 类型枚举
|
|
34
|
+
*/
|
|
35
|
+
var GridActionType = exports.GridActionType = /*#__PURE__*/function (GridActionType) {
|
|
36
|
+
GridActionType["SET_READY"] = "SET_READY";
|
|
37
|
+
GridActionType["SET_LOADING"] = "SET_LOADING";
|
|
38
|
+
GridActionType["SET_COLUMN_STATE"] = "SET_COLUMN_STATE";
|
|
39
|
+
GridActionType["SET_COLUMN_CELL_CLASS"] = "SET_COLUMN_CELL_CLASS";
|
|
40
|
+
GridActionType["SET_ROW_DATA"] = "SET_ROW_DATA";
|
|
41
|
+
GridActionType["SET_SELECT_ROW"] = "SET_SELECT_ROW";
|
|
42
|
+
GridActionType["SET_QUERY_FILTER"] = "SET_QUERY_FILTER";
|
|
43
|
+
GridActionType["SET_SORT_COLUMN"] = "SET_SORT_COLUMN";
|
|
44
|
+
GridActionType["SET_PAGINATION"] = "SET_PAGINATION";
|
|
45
|
+
GridActionType["UPDATE_PAGINATION"] = "UPDATE_PAGINATION";
|
|
46
|
+
GridActionType["SET_QUERY_ITEMS_ORDER"] = "SET_QUERY_ITEMS_ORDER";
|
|
47
|
+
GridActionType["RESET_STATE"] = "RESET_STATE";
|
|
48
|
+
return GridActionType;
|
|
49
|
+
}({});
|
|
50
|
+
/**
|
|
51
|
+
* Action 联合类型
|
|
52
|
+
*/
|
|
53
|
+
// ============ Reducer 定义 ============
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Grid 状态 Reducer
|
|
57
|
+
*/
|
|
58
|
+
function gridReducer(state, action) {
|
|
59
|
+
switch (action.type) {
|
|
60
|
+
case GridActionType.SET_READY:
|
|
61
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
62
|
+
ready: action.payload
|
|
63
|
+
});
|
|
64
|
+
case GridActionType.SET_LOADING:
|
|
65
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
66
|
+
loading: action.payload
|
|
67
|
+
});
|
|
68
|
+
case GridActionType.SET_COLUMN_STATE:
|
|
69
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
70
|
+
columnState: action.payload
|
|
71
|
+
});
|
|
72
|
+
case GridActionType.SET_COLUMN_CELL_CLASS:
|
|
73
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
74
|
+
columnCellClass: action.payload
|
|
75
|
+
});
|
|
76
|
+
case GridActionType.SET_ROW_DATA:
|
|
77
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
78
|
+
rowData: action.payload
|
|
79
|
+
});
|
|
80
|
+
case GridActionType.SET_SELECT_ROW:
|
|
81
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
82
|
+
selectRow: action.payload
|
|
83
|
+
});
|
|
84
|
+
case GridActionType.SET_QUERY_FILTER:
|
|
85
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
86
|
+
queryFilter: action.payload
|
|
87
|
+
});
|
|
88
|
+
case GridActionType.SET_SORT_COLUMN:
|
|
89
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
90
|
+
sortColumn: action.payload
|
|
91
|
+
});
|
|
92
|
+
case GridActionType.SET_PAGINATION:
|
|
93
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
94
|
+
pagination: action.payload
|
|
95
|
+
});
|
|
96
|
+
case GridActionType.UPDATE_PAGINATION:
|
|
97
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
98
|
+
pagination: _objectSpread(_objectSpread({}, state.pagination), action.payload)
|
|
99
|
+
});
|
|
100
|
+
case GridActionType.SET_QUERY_ITEMS_ORDER:
|
|
101
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
102
|
+
queryItemsOrder: action.payload
|
|
103
|
+
});
|
|
104
|
+
case GridActionType.RESET_STATE:
|
|
105
|
+
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
106
|
+
default:
|
|
107
|
+
return state;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ============ Hook 定义 ============
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* useGridState Hook 配置
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* useGridState Hook 返回值
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* AG-Grid Plus 状态管理 Hook
|
|
123
|
+
*
|
|
124
|
+
* @param config 配置对象
|
|
125
|
+
* @returns 状态和 actions
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* const { state, actions } = useGridState({
|
|
130
|
+
* loading: false,
|
|
131
|
+
* pageSize: 200,
|
|
132
|
+
* hidePagination: false
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* // 使用 actions
|
|
136
|
+
* actions.setLoading(true);
|
|
137
|
+
* actions.setRowData(newData);
|
|
138
|
+
* actions.updatePagination({ current: 2 });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
function useGridState() {
|
|
142
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
143
|
+
var _config$loading = config.loading,
|
|
144
|
+
initialLoading = _config$loading === void 0 ? false : _config$loading,
|
|
145
|
+
initialPageSize = config.pageSize,
|
|
146
|
+
_config$hidePaginatio = config.hidePagination,
|
|
147
|
+
hidePagination = _config$hidePaginatio === void 0 ? false : _config$hidePaginatio,
|
|
148
|
+
_config$dataSource = config.dataSource,
|
|
149
|
+
dataSource = _config$dataSource === void 0 ? [] : _config$dataSource;
|
|
150
|
+
|
|
151
|
+
// 计算初始分页配置
|
|
152
|
+
var initialPagination = {
|
|
153
|
+
pageSize: initialPageSize !== undefined ? initialPageSize : hidePagination ? 10000 : 200,
|
|
154
|
+
current: 1,
|
|
155
|
+
total: dataSource.length
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// 初始状态
|
|
159
|
+
var initialState = {
|
|
160
|
+
ready: false,
|
|
161
|
+
loading: initialLoading,
|
|
162
|
+
columnState: undefined,
|
|
163
|
+
columnCellClass: {},
|
|
164
|
+
rowData: [],
|
|
165
|
+
selectRow: {},
|
|
166
|
+
queryFilter: {},
|
|
167
|
+
sortColumn: undefined,
|
|
168
|
+
pagination: initialPagination,
|
|
169
|
+
queryItemsOrder: []
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// 使用 useReducer
|
|
173
|
+
var _useReducer = (0, _react.useReducer)(gridReducer, initialState),
|
|
174
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
175
|
+
state = _useReducer2[0],
|
|
176
|
+
dispatch = _useReducer2[1];
|
|
177
|
+
|
|
178
|
+
// 创建便捷的 actions
|
|
179
|
+
var actions = {
|
|
180
|
+
setReady: function setReady(ready) {
|
|
181
|
+
return dispatch({
|
|
182
|
+
type: GridActionType.SET_READY,
|
|
183
|
+
payload: ready
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
setLoading: function setLoading(loading) {
|
|
187
|
+
return dispatch({
|
|
188
|
+
type: GridActionType.SET_LOADING,
|
|
189
|
+
payload: loading
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
setColumnState: function setColumnState(columnState) {
|
|
193
|
+
return dispatch({
|
|
194
|
+
type: GridActionType.SET_COLUMN_STATE,
|
|
195
|
+
payload: columnState
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
setColumnCellClass: function setColumnCellClass(columnCellClass) {
|
|
199
|
+
return dispatch({
|
|
200
|
+
type: GridActionType.SET_COLUMN_CELL_CLASS,
|
|
201
|
+
payload: columnCellClass
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
setRowData: function setRowData(rowData) {
|
|
205
|
+
return dispatch({
|
|
206
|
+
type: GridActionType.SET_ROW_DATA,
|
|
207
|
+
payload: rowData
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
setSelectRow: function setSelectRow(selectRow) {
|
|
211
|
+
return dispatch({
|
|
212
|
+
type: GridActionType.SET_SELECT_ROW,
|
|
213
|
+
payload: selectRow
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
setQueryFilter: function setQueryFilter(queryFilter) {
|
|
217
|
+
return dispatch({
|
|
218
|
+
type: GridActionType.SET_QUERY_FILTER,
|
|
219
|
+
payload: queryFilter
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
setSortColumn: function setSortColumn(sortColumn) {
|
|
223
|
+
return dispatch({
|
|
224
|
+
type: GridActionType.SET_SORT_COLUMN,
|
|
225
|
+
payload: sortColumn
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
setPagination: function setPagination(pagination) {
|
|
229
|
+
return dispatch({
|
|
230
|
+
type: GridActionType.SET_PAGINATION,
|
|
231
|
+
payload: pagination
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
updatePagination: function updatePagination(pagination) {
|
|
235
|
+
return dispatch({
|
|
236
|
+
type: GridActionType.UPDATE_PAGINATION,
|
|
237
|
+
payload: pagination
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
setQueryItemsOrder: function setQueryItemsOrder(order) {
|
|
241
|
+
return dispatch({
|
|
242
|
+
type: GridActionType.SET_QUERY_ITEMS_ORDER,
|
|
243
|
+
payload: order
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
resetState: function resetState(newState) {
|
|
247
|
+
return dispatch({
|
|
248
|
+
type: GridActionType.RESET_STATE,
|
|
249
|
+
payload: newState
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
return {
|
|
254
|
+
state: state,
|
|
255
|
+
dispatch: dispatch,
|
|
256
|
+
actions: actions
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -5,3 +5,6 @@ import { useGridPlusColumnState } from "./hooks/useGridPlusColumnState";
|
|
|
5
5
|
import "./ag-grid-theme-builder.css";
|
|
6
6
|
export { AgGridPlus, AgGridColumn, GridPlusContext, useGridPlusColumnState };
|
|
7
7
|
export { dateValueFormatter, dateTimeValueFormatter, convertFilterModel, convertSortModel, flattenTreeDeep, toTree, flatten } from "./utils";
|
|
8
|
+
export { useColumnSchemes, LocalStorageAdapter, defaultStorageAdapter, validateScheme, validateSchemeName, validateSchemeDescription, checkDuplicateName, generateUniqueName, STORAGE_PREFIX, DEFAULT_SCHEME_NAME, MAX_SCHEMES_PER_GRID, MAX_SCHEME_NAME_LENGTH, SchemeSelector, SchemeManager } from "./schemes";
|
|
9
|
+
export type { ColumnScheme, SchemeManagerConfig, StorageAdapter, SchemeValidationResult, UseColumnSchemesReturn, SchemeSelectorProps, SchemeManagerProps } from "./schemes";
|
|
10
|
+
export type { GridPlusContextValue } from "./context/gridContext";
|
|
@@ -15,12 +15,60 @@ Object.defineProperty(exports, "AgGridPlus", {
|
|
|
15
15
|
return _agGridPlus.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "DEFAULT_SCHEME_NAME", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _schemes.DEFAULT_SCHEME_NAME;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "GridPlusContext", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
21
27
|
return _gridContext.GridPlusContext;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "LocalStorageAdapter", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _schemes.LocalStorageAdapter;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "MAX_SCHEMES_PER_GRID", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _schemes.MAX_SCHEMES_PER_GRID;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "MAX_SCHEME_NAME_LENGTH", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _schemes.MAX_SCHEME_NAME_LENGTH;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "STORAGE_PREFIX", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _schemes.STORAGE_PREFIX;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "SchemeManager", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _schemes.SchemeManager;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "SchemeSelector", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _schemes.SchemeSelector;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "checkDuplicateName", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _schemes.checkDuplicateName;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
24
72
|
Object.defineProperty(exports, "convertFilterModel", {
|
|
25
73
|
enumerable: true,
|
|
26
74
|
get: function get() {
|
|
@@ -45,6 +93,12 @@ Object.defineProperty(exports, "dateValueFormatter", {
|
|
|
45
93
|
return _utils.dateValueFormatter;
|
|
46
94
|
}
|
|
47
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "defaultStorageAdapter", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _schemes.defaultStorageAdapter;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
48
102
|
Object.defineProperty(exports, "flatten", {
|
|
49
103
|
enumerable: true,
|
|
50
104
|
get: function get() {
|
|
@@ -57,22 +111,53 @@ Object.defineProperty(exports, "flattenTreeDeep", {
|
|
|
57
111
|
return _utils.flattenTreeDeep;
|
|
58
112
|
}
|
|
59
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "generateUniqueName", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function get() {
|
|
117
|
+
return _schemes.generateUniqueName;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
60
120
|
Object.defineProperty(exports, "toTree", {
|
|
61
121
|
enumerable: true,
|
|
62
122
|
get: function get() {
|
|
63
123
|
return _utils.toTree;
|
|
64
124
|
}
|
|
65
125
|
});
|
|
126
|
+
Object.defineProperty(exports, "useColumnSchemes", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function get() {
|
|
129
|
+
return _schemes.useColumnSchemes;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
66
132
|
Object.defineProperty(exports, "useGridPlusColumnState", {
|
|
67
133
|
enumerable: true,
|
|
68
134
|
get: function get() {
|
|
69
135
|
return _useGridPlusColumnState.useGridPlusColumnState;
|
|
70
136
|
}
|
|
71
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "validateScheme", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function get() {
|
|
141
|
+
return _schemes.validateScheme;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "validateSchemeDescription", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function get() {
|
|
147
|
+
return _schemes.validateSchemeDescription;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "validateSchemeName", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function get() {
|
|
153
|
+
return _schemes.validateSchemeName;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
72
156
|
var _agGridPlus = _interopRequireDefault(require("./ag-gridPlus"));
|
|
73
157
|
var _interface = require("./interface");
|
|
74
158
|
var _gridContext = require("./context/gridContext");
|
|
75
159
|
var _useGridPlusColumnState = require("./hooks/useGridPlusColumnState");
|
|
76
160
|
require("./ag-grid-theme-builder.css");
|
|
77
161
|
var _utils = require("./utils");
|
|
162
|
+
var _schemes = require("./schemes");
|
|
78
163
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { GridApi, ColDef, ColGroupDef } from "ag-grid-community";
|
|
2
2
|
import { AgGridReactProps } from "ag-grid-react";
|
|
3
3
|
import React, { CSSProperties, ReactNode } from "react";
|
|
4
|
+
import type { QueryStorageAdapter } from "./querySchemes/types";
|
|
5
|
+
import type { StorageAdapter as ColumnStorageAdapter } from "./schemes/types";
|
|
6
|
+
import type { GridPlusError } from "./errors";
|
|
4
7
|
interface GridRef {
|
|
5
8
|
onRefresh: () => void;
|
|
6
9
|
}
|
|
@@ -53,6 +56,30 @@ interface GridProps extends AgGridReactProps {
|
|
|
53
56
|
* 选中行变化回调函数
|
|
54
57
|
*/
|
|
55
58
|
onSelectedRowsChange?: (selectedRows: any[]) => void;
|
|
59
|
+
/**
|
|
60
|
+
* 是否启用查询方案功能
|
|
61
|
+
*/
|
|
62
|
+
enableQuerySchemes?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 查询方案存储适配器(可选)
|
|
65
|
+
* 默认使用 LocalStorage,可传入自定义适配器实现服务端存储
|
|
66
|
+
*/
|
|
67
|
+
querySchemeStorageAdapter?: QueryStorageAdapter;
|
|
68
|
+
/**
|
|
69
|
+
* 是否启用列配置方案功能
|
|
70
|
+
* 默认值: true (自动启用)
|
|
71
|
+
*/
|
|
72
|
+
enableColumnSchemes?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 列配置方案存储适配器(可选)
|
|
75
|
+
* 默认使用 LocalStorage,可传入自定义适配器实现服务端存储
|
|
76
|
+
*/
|
|
77
|
+
columnSchemeStorageAdapter?: ColumnStorageAdapter;
|
|
78
|
+
/**
|
|
79
|
+
* 错误处理回调函数
|
|
80
|
+
* 当组件发生错误时调用,可用于自定义错误处理逻辑
|
|
81
|
+
*/
|
|
82
|
+
onError?: (error: GridPlusError) => void;
|
|
56
83
|
}
|
|
57
84
|
interface AgGridColumnPropsClone extends ColDef {
|
|
58
85
|
/**
|
|
@@ -148,6 +148,23 @@ var FormRender = function FormRender(props) {
|
|
|
148
148
|
var component = getComponent(colDef);
|
|
149
149
|
if (colDef.filter != false) {
|
|
150
150
|
var _colDef$searchCompone, _colDef$searchCompone2, _colDef$searchCompone3;
|
|
151
|
+
// 为多选下拉框添加maxTagCount配置
|
|
152
|
+
var componentProps = _objectSpread({
|
|
153
|
+
placeholder: "\u8BF7\u8F93\u5165".concat(headerName),
|
|
154
|
+
allowClear: true,
|
|
155
|
+
style: {
|
|
156
|
+
maxWidth: 200
|
|
157
|
+
}
|
|
158
|
+
}, colDef === null || colDef === void 0 ? void 0 : colDef.searchComponentProps);
|
|
159
|
+
|
|
160
|
+
// 如果是Select组件且为多选模式,添加标签数量限制
|
|
161
|
+
if (component === 'Select' && (componentProps.mode === 'multiple' || componentProps.mode === 'tags')) {
|
|
162
|
+
var _componentProps$maxTa, _componentProps$maxTa2;
|
|
163
|
+
componentProps.maxTagCount = (_componentProps$maxTa = componentProps.maxTagCount) !== null && _componentProps$maxTa !== void 0 ? _componentProps$maxTa : 2;
|
|
164
|
+
componentProps.maxTagPlaceholder = (_componentProps$maxTa2 = componentProps.maxTagPlaceholder) !== null && _componentProps$maxTa2 !== void 0 ? _componentProps$maxTa2 : function (omittedValues) {
|
|
165
|
+
return "+".concat(omittedValues.length, "...");
|
|
166
|
+
};
|
|
167
|
+
}
|
|
151
168
|
var filedSchema = {
|
|
152
169
|
type: 'string',
|
|
153
170
|
title: headerName,
|
|
@@ -155,13 +172,7 @@ var FormRender = function FormRender(props) {
|
|
|
155
172
|
default: (colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default) || (colDef === null || colDef === void 0 || (_colDef$searchCompone3 = colDef.searchComponentProps) === null || _colDef$searchCompone3 === void 0 ? void 0 : _colDef$searchCompone3.defaultValue),
|
|
156
173
|
enum: colDef === null || colDef === void 0 ? void 0 : colDef.enum,
|
|
157
174
|
"x-component": component,
|
|
158
|
-
"x-component-props":
|
|
159
|
-
placeholder: "\u8BF7\u8F93\u5165".concat(headerName),
|
|
160
|
-
allowClear: true,
|
|
161
|
-
style: {
|
|
162
|
-
maxWidth: 200
|
|
163
|
-
}
|
|
164
|
-
}, colDef === null || colDef === void 0 ? void 0 : colDef.searchComponentProps),
|
|
175
|
+
"x-component-props": componentProps,
|
|
165
176
|
"x-decorator": 'FormItem',
|
|
166
177
|
"x-decorator-props": {
|
|
167
178
|
wrapperWrap: true
|
|
@@ -33,6 +33,30 @@
|
|
|
33
33
|
justify-content: flex-start;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
// 多选下拉框标签省略样式
|
|
38
|
+
.ant-select-multiple {
|
|
39
|
+
max-width: 200px; // 限制整个选择器的最大宽度
|
|
40
|
+
|
|
41
|
+
.ant-select-selector {
|
|
42
|
+
max-width: 100%;
|
|
43
|
+
overflow: hidden; // 防止内容溢出
|
|
44
|
+
|
|
45
|
+
.ant-select-selection-overflow {
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
flex-wrap: nowrap; // 禁止换行
|
|
48
|
+
overflow: hidden; // 隐藏溢出内容
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ant-select-selection-item {
|
|
52
|
+
max-width: 100px; // 单个标签最大宽度
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
flex-shrink: 0; // 防止标签被压缩
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
36
60
|
}
|
|
37
61
|
|
|
38
62
|
@media (max-width: 575px) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UseQuerySchemesReturn, QueryFormItemWithOrder } from '../types';
|
|
3
|
+
import './QuerySchemesManager.less';
|
|
4
|
+
export interface QuerySchemesManagerProps {
|
|
5
|
+
/** 方案管理器 */
|
|
6
|
+
schemeManager: UseQuerySchemesReturn;
|
|
7
|
+
/** 表单项列表 */
|
|
8
|
+
formItems: QueryFormItemWithOrder[];
|
|
9
|
+
/** 当前查询项顺序 */
|
|
10
|
+
currentOrder: string[];
|
|
11
|
+
/** 模态框是否可见 */
|
|
12
|
+
visible: boolean;
|
|
13
|
+
/** 关闭回调 */
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
/** 顺序变更回调 */
|
|
16
|
+
onOrderChange: (order: string[]) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 查询方案管理组件
|
|
20
|
+
*/
|
|
21
|
+
export declare const QuerySchemesManager: React.FC<QuerySchemesManagerProps>;
|