es-grid-template 1.1.8 → 1.2.1
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/assets/index.css +679 -0
- package/assets/index.scss +1006 -0
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +64 -29
- package/es/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +223 -0
- package/es/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/es/grid-component/ColumnsGroup/index.js +1 -0
- package/es/grid-component/ConvertColumnTable.d.ts +7 -0
- package/es/grid-component/ConvertColumnTable.js +143 -0
- package/es/grid-component/EditableCell.js +1 -1
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +148 -244
- package/es/grid-component/TableGrid.d.ts +7 -2
- package/es/grid-component/TableGrid.js +33 -55
- package/es/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/es/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/es/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/es/grid-component/hooks/content/HeaderContent.js +80 -0
- package/es/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/es/grid-component/hooks/content/TooltipContent.js +74 -0
- package/es/grid-component/hooks/useColumns.d.ts +16 -0
- package/es/grid-component/hooks/useColumns.js +272 -0
- package/es/grid-component/hooks/utils.d.ts +50 -1
- package/es/grid-component/hooks/utils.js +782 -2
- package/es/grid-component/index.js +3 -1
- package/es/grid-component/styles.scss +354 -63
- package/es/grid-component/table/Grid.d.ts +5 -0
- package/es/grid-component/table/Grid.js +1 -7
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +768 -264
- package/es/grid-component/table/Group.d.ts +13 -0
- package/es/grid-component/table/Group.js +154 -0
- package/es/grid-component/type.d.ts +43 -2
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +63 -28
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +234 -0
- package/lib/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/grid-component/ColumnsGroup/index.js +16 -0
- package/lib/grid-component/ConvertColumnTable.d.ts +7 -0
- package/lib/grid-component/ConvertColumnTable.js +152 -0
- package/lib/grid-component/EditableCell.js +1 -1
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +142 -244
- package/lib/grid-component/TableGrid.d.ts +7 -2
- package/lib/grid-component/TableGrid.js +27 -53
- package/lib/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/lib/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +87 -0
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/lib/grid-component/hooks/content/TooltipContent.js +81 -0
- package/lib/grid-component/hooks/useColumns.d.ts +16 -0
- package/lib/grid-component/hooks/useColumns.js +283 -0
- package/lib/grid-component/hooks/utils.d.ts +50 -1
- package/lib/grid-component/hooks/utils.js +809 -5
- package/lib/grid-component/index.js +2 -1
- package/lib/grid-component/styles.scss +354 -63
- package/lib/grid-component/table/Grid.d.ts +5 -0
- package/lib/grid-component/table/Grid.js +1 -7
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +764 -261
- package/lib/grid-component/table/Group.d.ts +13 -0
- package/lib/grid-component/table/Group.js +163 -0
- package/lib/grid-component/type.d.ts +43 -2
- package/package.json +106 -105
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColumnsTable, GridTableProps } from "../type";
|
|
3
|
+
import type { GetRowKey } from "../type";
|
|
4
|
+
type Props<T> = GridTableProps<T> & {
|
|
5
|
+
tableRef: any;
|
|
6
|
+
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
|
+
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
|
+
getRowKey: GetRowKey<T>;
|
|
9
|
+
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
10
|
+
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
13
|
+
export default Group;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
|
+
import { GridStyle } from "../GridStyle";
|
|
4
|
+
import TableGrid from "../TableGrid";
|
|
5
|
+
// import type {ColumnsTable} from "../type";
|
|
6
|
+
|
|
7
|
+
import { findAllChildrenKeys } from "../hooks";
|
|
8
|
+
import { ColumnsGroup } from "../ColumnsGroup/ColumnsGroup";
|
|
9
|
+
import { flatColumns2 } from "../hooks/columns";
|
|
10
|
+
import { Collapse2, Expand2 } from "becoxy-icons";
|
|
11
|
+
const Group = props => {
|
|
12
|
+
const {
|
|
13
|
+
t,
|
|
14
|
+
columns,
|
|
15
|
+
height,
|
|
16
|
+
style,
|
|
17
|
+
rowHoverable,
|
|
18
|
+
groupAble,
|
|
19
|
+
expandable,
|
|
20
|
+
dataSource,
|
|
21
|
+
getRowKey,
|
|
22
|
+
groupSetting,
|
|
23
|
+
groupColumns,
|
|
24
|
+
triggerGroupColumns,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
defaultExpandedRowKeys,
|
|
29
|
+
defaultExpandAllRows
|
|
30
|
+
} = expandable || {};
|
|
31
|
+
const childrenColumnName = 'children';
|
|
32
|
+
const [innerExpandedKeys, setInnerExpandedKeys] = React.useState(() => {
|
|
33
|
+
if (defaultExpandedRowKeys) {
|
|
34
|
+
return defaultExpandedRowKeys;
|
|
35
|
+
}
|
|
36
|
+
if (defaultExpandAllRows) {
|
|
37
|
+
return findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? [];
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
});
|
|
41
|
+
const mergedExpandedKeys = React.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
|
|
42
|
+
const onTriggerExpand = React.useCallback(record => {
|
|
43
|
+
const key = getRowKey(record, dataSource.indexOf(record));
|
|
44
|
+
let newExpandedKeys;
|
|
45
|
+
const hasKey = mergedExpandedKeys.has(key);
|
|
46
|
+
if (hasKey) {
|
|
47
|
+
mergedExpandedKeys.delete(key);
|
|
48
|
+
newExpandedKeys = [...mergedExpandedKeys];
|
|
49
|
+
} else {
|
|
50
|
+
newExpandedKeys = [...mergedExpandedKeys, key];
|
|
51
|
+
}
|
|
52
|
+
setInnerExpandedKeys(newExpandedKeys);
|
|
53
|
+
}, [getRowKey, mergedExpandedKeys, dataSource]);
|
|
54
|
+
const handleExpandAllGroup = () => {
|
|
55
|
+
setInnerExpandedKeys(findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? []);
|
|
56
|
+
};
|
|
57
|
+
const handleCollapseAllGroup = () => {
|
|
58
|
+
setInnerExpandedKeys([]);
|
|
59
|
+
};
|
|
60
|
+
const handleOnGroup = value => {
|
|
61
|
+
triggerGroupColumns?.(value);
|
|
62
|
+
};
|
|
63
|
+
const groupToolbar = () => {
|
|
64
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
style: {
|
|
66
|
+
display: 'flex',
|
|
67
|
+
gap: '10px',
|
|
68
|
+
marginRight: 10
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/React.createElement(ColumnsGroup, {
|
|
71
|
+
t: t
|
|
72
|
+
// defaultGroupColumns={['name']}
|
|
73
|
+
,
|
|
74
|
+
unClearableLevel: groupSetting?.unClearableLevel
|
|
75
|
+
// unClearableLevel={2}
|
|
76
|
+
,
|
|
77
|
+
columns: columns ? flatColumns2(columns) : [],
|
|
78
|
+
columnsGrouped: groupColumns,
|
|
79
|
+
onSubmit: handleOnGroup
|
|
80
|
+
}), /*#__PURE__*/React.createElement(Fragment, null, innerExpandedKeys.length > 0 ? /*#__PURE__*/React.createElement(Collapse2, {
|
|
81
|
+
fontSize: 18,
|
|
82
|
+
color: '#555555',
|
|
83
|
+
onClick: handleCollapseAllGroup
|
|
84
|
+
}) : /*#__PURE__*/React.createElement(Expand2, {
|
|
85
|
+
fontSize: 18,
|
|
86
|
+
color: '#555555',
|
|
87
|
+
onClick: handleExpandAllGroup
|
|
88
|
+
})));
|
|
89
|
+
};
|
|
90
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
91
|
+
heightTable: height,
|
|
92
|
+
style: {
|
|
93
|
+
position: 'relative'
|
|
94
|
+
}
|
|
95
|
+
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
96
|
+
t: t,
|
|
97
|
+
columns: columns,
|
|
98
|
+
style: {
|
|
99
|
+
...style,
|
|
100
|
+
minHeight: height
|
|
101
|
+
},
|
|
102
|
+
rowHoverable: rowHoverable ?? true,
|
|
103
|
+
dataSource: dataSource,
|
|
104
|
+
getRowKey: getRowKey,
|
|
105
|
+
groupAble: groupAble,
|
|
106
|
+
groupSetting: groupSetting,
|
|
107
|
+
expandable: {
|
|
108
|
+
expandIconColumnIndex: 3,
|
|
109
|
+
defaultExpandAllRows: true,
|
|
110
|
+
indentSize: 25,
|
|
111
|
+
expandIcon: args => {
|
|
112
|
+
const {
|
|
113
|
+
record,
|
|
114
|
+
expanded,
|
|
115
|
+
onExpand
|
|
116
|
+
} = args;
|
|
117
|
+
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
if (record?.children?.length > 0 || record?.isChildren) {
|
|
120
|
+
return expanded ? /*#__PURE__*/React.createElement("button", {
|
|
121
|
+
onClick: e => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
onExpand(record, e);
|
|
125
|
+
if (groupAble) {
|
|
126
|
+
onTriggerExpand(record);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
130
|
+
}) : /*#__PURE__*/React.createElement("button", {
|
|
131
|
+
onClick: e => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
onExpand(record, e);
|
|
135
|
+
if (groupAble) {
|
|
136
|
+
onTriggerExpand(record);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
143
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
expandedRowKeys: groupAble ? innerExpandedKeys : undefined,
|
|
148
|
+
...expandable
|
|
149
|
+
},
|
|
150
|
+
groupToolbar: groupToolbar,
|
|
151
|
+
groupColumns: groupColumns
|
|
152
|
+
}))));
|
|
153
|
+
};
|
|
154
|
+
export default Group;
|
|
@@ -3,12 +3,16 @@ import type React from "react";
|
|
|
3
3
|
import type { IOperator } from "./hooks";
|
|
4
4
|
import type { TypeFilter, TableProps as RcTableProps, TableColumnType as RcColumnType, EditType } from "rc-master-ui";
|
|
5
5
|
import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/interface";
|
|
6
|
-
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
6
|
+
import type { ToolbarItem as RcToolbarItem } from "rc-master-ui/es/toolbar";
|
|
7
7
|
import type { ItemType } from "rc-master-ui/es/menu/interface";
|
|
8
8
|
import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
9
9
|
import type { ColorPickerProps } from "antd";
|
|
10
10
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
11
11
|
export type AnyObject = Record<PropertyKey, any>;
|
|
12
|
+
export type ToolbarItem = Omit<RcToolbarItem, 'position'> & {
|
|
13
|
+
position?: 'Top' | 'Bottom';
|
|
14
|
+
onClick?: (args: any) => void;
|
|
15
|
+
};
|
|
12
16
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
13
17
|
export type ITextAlign = 'center' | 'left' | 'right';
|
|
14
18
|
export type Frozen = 'left' | 'right' | 'Left' | 'Right';
|
|
@@ -80,6 +84,7 @@ export type ToolbarClick = {
|
|
|
80
84
|
};
|
|
81
85
|
export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTemplate'> & {
|
|
82
86
|
field?: string;
|
|
87
|
+
key?: any;
|
|
83
88
|
type?: IColumnType;
|
|
84
89
|
isSummary?: boolean;
|
|
85
90
|
summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
|
|
@@ -92,8 +97,11 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
92
97
|
placeholder?: string;
|
|
93
98
|
showInColumnChoose?: boolean;
|
|
94
99
|
typeFilter?: TypeFilter;
|
|
100
|
+
source?: any[];
|
|
95
101
|
showFilterSearch?: boolean;
|
|
96
102
|
headerText?: string;
|
|
103
|
+
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
104
|
+
columnGroupText?: string;
|
|
97
105
|
textAlign?: ITextAlign;
|
|
98
106
|
frozen?: Frozen;
|
|
99
107
|
template?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
@@ -103,7 +111,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
103
111
|
commandItems?: CommandItem[];
|
|
104
112
|
children?: ColumnType<RecordType>[];
|
|
105
113
|
};
|
|
106
|
-
export type ColumnEditType<RecordType> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
114
|
+
export type ColumnEditType<RecordType = AnyObject> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
107
115
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
108
116
|
disable?: boolean | ((rowData: any) => boolean);
|
|
109
117
|
isClearable?: boolean;
|
|
@@ -122,6 +130,11 @@ export type ColumnTable<RecordType = AnyObject> = ColumnEditType<RecordType> | C
|
|
|
122
130
|
export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
|
|
123
131
|
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
124
132
|
editAble?: boolean;
|
|
133
|
+
groupAble?: boolean;
|
|
134
|
+
groupColumns?: string[];
|
|
135
|
+
groupSetting?: IGroupSetting;
|
|
136
|
+
onChooseColumns?: (props: IOnChooseColumns) => void;
|
|
137
|
+
showCustomTooltip?: boolean;
|
|
125
138
|
sortMultiple?: boolean;
|
|
126
139
|
dataSource: RecordType[];
|
|
127
140
|
columns: ColumnsTable<RecordType>;
|
|
@@ -163,13 +176,24 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
163
176
|
allowResizing?: boolean;
|
|
164
177
|
showToolbar?: boolean;
|
|
165
178
|
onDataChange?: (data: RecordType[]) => void;
|
|
179
|
+
defaultValue?: AnyObject | (() => AnyObject);
|
|
166
180
|
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
167
181
|
}
|
|
168
182
|
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
169
183
|
columns: ColumnsTable<RecordType>;
|
|
170
184
|
onCellPaste?: ICellPasteModel<RecordType>;
|
|
171
185
|
onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
|
|
186
|
+
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
172
187
|
}
|
|
188
|
+
export type ICellClick = {
|
|
189
|
+
index: number;
|
|
190
|
+
indexCol?: number;
|
|
191
|
+
rowId: string | number;
|
|
192
|
+
type: 'Editing' | 'Default';
|
|
193
|
+
field: string;
|
|
194
|
+
cellValue: any;
|
|
195
|
+
rowData: any;
|
|
196
|
+
};
|
|
173
197
|
export type GridTableProps<RecordType = AnyObject> = TableProps<RecordType> | TableEditProps<RecordType>;
|
|
174
198
|
export interface CommandItem {
|
|
175
199
|
id: string;
|
|
@@ -183,6 +207,22 @@ export interface CommandItem {
|
|
|
183
207
|
client?: boolean;
|
|
184
208
|
confirmDialog?: boolean;
|
|
185
209
|
}
|
|
210
|
+
export type IGroupSetting = {
|
|
211
|
+
client?: boolean;
|
|
212
|
+
onGroup?: (props: IOnGroup) => void;
|
|
213
|
+
hiddenColumnGroup?: boolean;
|
|
214
|
+
unClearableLevel?: 1 | 2 | 3 | undefined;
|
|
215
|
+
};
|
|
216
|
+
type IOnGroup = {
|
|
217
|
+
columnGrouped: string[];
|
|
218
|
+
columns: ColumnsTable;
|
|
219
|
+
flattenColumns: ColumnsTable;
|
|
220
|
+
};
|
|
221
|
+
export type IOnChooseColumns = {
|
|
222
|
+
columns: ColumnsTable;
|
|
223
|
+
showColumns: ColumnsTable;
|
|
224
|
+
flattenColumns: ColumnsTable;
|
|
225
|
+
};
|
|
186
226
|
export type CellChangeArgs<T> = {
|
|
187
227
|
type: 'onPaste' | 'onChange' | 'onCellPaste';
|
|
188
228
|
value: any;
|
|
@@ -246,3 +286,4 @@ export type IFormat = {
|
|
|
246
286
|
};
|
|
247
287
|
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
248
288
|
export type Presets = Required<ColorPickerProps>['presets'][number];
|
|
289
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import type { ColumnsTable } from "./type";
|
|
3
3
|
export type IColumnsChoose<RecordType> = {
|
|
4
4
|
columns: ColumnsTable<RecordType>;
|
|
5
|
+
columnsGroup?: string[];
|
|
5
6
|
triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void;
|
|
6
7
|
t?: any;
|
|
7
8
|
};
|
|
@@ -12,6 +12,7 @@ var _icons = require("@ant-design/icons");
|
|
|
12
12
|
var _hooks = require("./hooks");
|
|
13
13
|
var _tree = _interopRequireDefault(require("rc-master-ui/es/tree"));
|
|
14
14
|
var _SearchOutlined = _interopRequireDefault(require("@ant-design/icons/SearchOutlined"));
|
|
15
|
+
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
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; }
|
|
17
18
|
// import type {TableColumnsType} from "rc-master-ui";
|
|
@@ -24,7 +25,8 @@ const ColumnsChoose = props => {
|
|
|
24
25
|
const {
|
|
25
26
|
columns: propsColumns,
|
|
26
27
|
triggerChangeColumns,
|
|
27
|
-
t
|
|
28
|
+
t,
|
|
29
|
+
columnsGroup
|
|
28
30
|
} = props;
|
|
29
31
|
|
|
30
32
|
// const dataList: { key: React.Key; title: string }[] = [];
|
|
@@ -37,8 +39,10 @@ const ColumnsChoose = props => {
|
|
|
37
39
|
// const searchRef: any = useRef()
|
|
38
40
|
|
|
39
41
|
// const [columns, setColumns] = useState<TableColumnsType>([])
|
|
40
|
-
|
|
41
|
-
const [
|
|
42
|
+
|
|
43
|
+
// const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
|
|
44
|
+
|
|
45
|
+
// const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
42
46
|
|
|
43
47
|
// useEffect(() => {
|
|
44
48
|
//
|
|
@@ -48,24 +52,42 @@ const ColumnsChoose = props => {
|
|
|
48
52
|
// }, [propsColumns])
|
|
49
53
|
|
|
50
54
|
const columns = (0, _react.useMemo)(() => {
|
|
51
|
-
return
|
|
55
|
+
// return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
|
|
56
|
+
return propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false);
|
|
52
57
|
// setColumns(defaultColumns as TableColumnsType)
|
|
53
|
-
}, [propsColumns]);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
}, [columnsGroup, propsColumns]);
|
|
59
|
+
|
|
60
|
+
// useEffect(() => {
|
|
61
|
+
//
|
|
62
|
+
// const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
63
|
+
//
|
|
64
|
+
// const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
|
|
65
|
+
//
|
|
66
|
+
// if (!isManualUpdate) {
|
|
67
|
+
// setSelectedKeys(defaultSelectedKeys)
|
|
68
|
+
// }
|
|
69
|
+
// setIsManualUpdate(false);
|
|
70
|
+
//
|
|
71
|
+
//
|
|
72
|
+
// }, [isManualUpdate, propsColumns])
|
|
73
|
+
|
|
74
|
+
const defaultSelectedKeys = _react.default.useMemo(() => {
|
|
75
|
+
const rs = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
76
|
+
return (0, _hooks.getVisibleColumnKeys)(rs);
|
|
77
|
+
}, [columnsGroup, propsColumns]);
|
|
78
|
+
const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)(defaultSelectedKeys || [], {
|
|
79
|
+
value: defaultSelectedKeys
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
//
|
|
83
|
+
// const defaultSelectedKeys = useMemo(() => {
|
|
84
|
+
//
|
|
85
|
+
// return getVisibleColumnKeys(propsColumns)
|
|
86
|
+
//
|
|
87
|
+
// }, [propsColumns])
|
|
88
|
+
|
|
65
89
|
const [clicked, setClicked] = (0, _react.useState)(false);
|
|
66
90
|
const [autoExpandParent, setAutoExpandParent] = (0, _react.useState)(true);
|
|
67
|
-
// const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
68
|
-
// const [searchValue, setSearchValue] = useState('');
|
|
69
91
|
|
|
70
92
|
// const treeData = useMemo(() => {
|
|
71
93
|
// const loop = (data: TreeDataNode[]): TreeDataNode[] =>
|
|
@@ -141,16 +163,19 @@ const ColumnsChoose = props => {
|
|
|
141
163
|
setAutoExpandParent(true);
|
|
142
164
|
};
|
|
143
165
|
const onCheck = keys => {
|
|
144
|
-
|
|
145
|
-
|
|
166
|
+
console.log('keys', keys);
|
|
167
|
+
// setSelectedKeys(keys)
|
|
168
|
+
setMergedSelectedKeys(keys);
|
|
169
|
+
// setIsManualUpdate(true)
|
|
146
170
|
};
|
|
147
171
|
const handleAccept = () => {
|
|
148
|
-
const rs1
|
|
172
|
+
// const rs1 = updateColumns(propsColumns, selectedKeys)
|
|
173
|
+
const rs1 = (0, _hooks.updateColumns)(propsColumns, mergedSelectedKeys);
|
|
149
174
|
triggerChangeColumns?.(rs1, 'columnChoose');
|
|
150
175
|
hide();
|
|
151
176
|
};
|
|
152
177
|
const handleCancel = () => {
|
|
153
|
-
setSelectedKeys(defaultSelectedKeys)
|
|
178
|
+
// setSelectedKeys(defaultSelectedKeys)
|
|
154
179
|
hide();
|
|
155
180
|
};
|
|
156
181
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_antd.Popover, {
|
|
@@ -163,7 +188,7 @@ const ColumnsChoose = props => {
|
|
|
163
188
|
style: {
|
|
164
189
|
marginBottom: 8
|
|
165
190
|
},
|
|
166
|
-
placeholder: "Search",
|
|
191
|
+
placeholder: t ? t("Search") : 'Search',
|
|
167
192
|
prefix: /*#__PURE__*/_react.default.createElement(_SearchOutlined.default, null),
|
|
168
193
|
onChange: onChange
|
|
169
194
|
}), /*#__PURE__*/_react.default.createElement(_tree.default, {
|
|
@@ -197,12 +222,15 @@ const ColumnsChoose = props => {
|
|
|
197
222
|
// }}
|
|
198
223
|
,
|
|
199
224
|
onCheck: keys => onCheck(keys),
|
|
200
|
-
multiple: true
|
|
201
|
-
checkedKeys
|
|
202
|
-
|
|
225
|
+
multiple: true
|
|
226
|
+
// checkedKeys={selectedKeys}
|
|
227
|
+
,
|
|
228
|
+
|
|
229
|
+
defaultCheckedKeys: mergedSelectedKeys
|
|
203
230
|
// defaultCheckedKeys={defaultSelectedKeys}
|
|
231
|
+
// selectedKeys={[]}
|
|
204
232
|
,
|
|
205
|
-
|
|
233
|
+
|
|
206
234
|
height: window.innerHeight - 200
|
|
207
235
|
}), /*#__PURE__*/_react.default.createElement(BoxAction, {
|
|
208
236
|
className: 'px-1'
|
|
@@ -224,6 +252,13 @@ const ColumnsChoose = props => {
|
|
|
224
252
|
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
|
|
225
253
|
arrow: false,
|
|
226
254
|
title: 'Cài đặt'
|
|
227
|
-
}, /*#__PURE__*/_react.default.createElement(_icons.SettingOutlined,
|
|
255
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.SettingOutlined, {
|
|
256
|
+
size: 16,
|
|
257
|
+
color: '#555555',
|
|
258
|
+
style: {
|
|
259
|
+
fontSize: 16,
|
|
260
|
+
color: '#555555'
|
|
261
|
+
}
|
|
262
|
+
}))));
|
|
228
263
|
};
|
|
229
264
|
exports.ColumnsChoose = ColumnsChoose;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type IColumnsGroup = {
|
|
3
|
+
columns: any[];
|
|
4
|
+
dataSource?: string[];
|
|
5
|
+
onSubmit: (value: any) => void;
|
|
6
|
+
t?: any;
|
|
7
|
+
columnsGrouped?: string[];
|
|
8
|
+
unClearableLevel?: number;
|
|
9
|
+
defaultGroupColumns?: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const ColumnsGroup: (props: IColumnsGroup) => React.JSX.Element;
|
|
12
|
+
export {};
|