es-grid-template 1.1.6 → 1.1.8
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/es/grid-component/CheckboxFilter.d.ts +1 -1
- package/es/grid-component/CheckboxFilter.js +2 -2
- package/es/grid-component/ContextMenu.js +1 -3
- package/es/grid-component/FilterSearch.d.ts +1 -1
- package/es/grid-component/FilterSearch.js +1 -1
- package/es/grid-component/InternalTable.js +130 -109
- package/es/grid-component/TableGrid.js +61 -7
- package/es/grid-component/hooks/constant.js +14 -14
- package/es/grid-component/hooks/useColumns/index.d.ts +6 -3
- package/es/grid-component/hooks/useColumns/index.js +46 -13
- package/es/grid-component/hooks/utils.d.ts +4 -2
- package/es/grid-component/hooks/utils.js +13 -2
- package/es/grid-component/styles.scss +60 -16
- package/es/grid-component/table/Grid.js +3 -1
- package/es/grid-component/table/GridEdit.js +136 -167
- package/es/grid-component/type.d.ts +3 -3
- package/lib/grid-component/CheckboxFilter.d.ts +1 -1
- package/lib/grid-component/CheckboxFilter.js +2 -2
- package/lib/grid-component/ContextMenu.js +1 -3
- package/lib/grid-component/FilterSearch.d.ts +1 -1
- package/lib/grid-component/FilterSearch.js +1 -1
- package/lib/grid-component/InternalTable.js +128 -107
- package/lib/grid-component/TableGrid.js +60 -6
- package/lib/grid-component/hooks/constant.js +14 -14
- package/lib/grid-component/hooks/useColumns/index.d.ts +6 -3
- package/lib/grid-component/hooks/useColumns/index.js +46 -12
- package/lib/grid-component/hooks/utils.d.ts +4 -2
- package/lib/grid-component/hooks/utils.js +16 -3
- package/lib/grid-component/styles.scss +60 -16
- package/lib/grid-component/table/Grid.js +3 -1
- package/lib/grid-component/table/GridEdit.js +134 -166
- package/lib/grid-component/type.d.ts +3 -3
- package/package.json +105 -105
|
@@ -106,7 +106,7 @@ const CheckboxFilter = props => {
|
|
|
106
106
|
});
|
|
107
107
|
const empty = /*#__PURE__*/React.createElement(Empty, {
|
|
108
108
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
109
|
-
description: locale
|
|
109
|
+
description: locale?.filterEmptyText,
|
|
110
110
|
imageStyle: {
|
|
111
111
|
height: 24
|
|
112
112
|
},
|
|
@@ -193,7 +193,7 @@ const CheckboxFilter = props => {
|
|
|
193
193
|
indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
|
|
194
194
|
className: `${tablePrefixCls}-filter-dropdown-checkall`,
|
|
195
195
|
onChange: onCheckAll
|
|
196
|
-
}, locale
|
|
196
|
+
}, locale?.filterCheckall) : /*#__PURE__*/React.createElement(Empty, null), /*#__PURE__*/React.createElement(Tree, {
|
|
197
197
|
checkable: true,
|
|
198
198
|
selectable: false,
|
|
199
199
|
blockNode: true,
|
|
@@ -94,9 +94,7 @@ const ContextMenu = props => {
|
|
|
94
94
|
items: contextMenuItems,
|
|
95
95
|
style: {
|
|
96
96
|
minWidth: 200,
|
|
97
|
-
|
|
98
|
-
maxHeight: pos.viewportHeight - 20,
|
|
99
|
-
width: 200
|
|
97
|
+
maxHeight: pos.viewportHeight - 20
|
|
100
98
|
},
|
|
101
99
|
rootClassName: 'popup-context-menu',
|
|
102
100
|
onClick: e => {
|
|
@@ -6,7 +6,7 @@ interface FilterSearchProps<RecordType = AnyObject> {
|
|
|
6
6
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
7
|
filterSearch: FilterSearchType<RecordType>;
|
|
8
8
|
tablePrefixCls: string;
|
|
9
|
-
locale
|
|
9
|
+
locale?: TableLocale;
|
|
10
10
|
}
|
|
11
11
|
declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element;
|
|
12
12
|
export default FilterSearch;
|
|
@@ -20,7 +20,7 @@ const FilterSearch = props => {
|
|
|
20
20
|
}
|
|
21
21
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
22
22
|
suffix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
23
|
-
placeholder: locale
|
|
23
|
+
placeholder: locale?.filterSearchPlaceholder,
|
|
24
24
|
onChange: onChange,
|
|
25
25
|
value: value,
|
|
26
26
|
autoFocus: true
|
|
@@ -5,9 +5,9 @@ import { Button, Space } from "antd";
|
|
|
5
5
|
import { SearchOutlined } from "@ant-design/icons";
|
|
6
6
|
import { Resizable } from "react-resizable";
|
|
7
7
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
8
|
-
import { numberOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
8
|
+
import { booleanOperator, getTypeFilter, numberOperator, stringOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
9
9
|
import { FilterFill } from "becoxy-icons";
|
|
10
|
-
import { renderContent, renderFilter } from "./hooks/useColumns";
|
|
10
|
+
import { flatColumns2, renderContent, renderFilter } from "./hooks/useColumns";
|
|
11
11
|
import dayjs from "dayjs";
|
|
12
12
|
import 'dayjs/locale/es';
|
|
13
13
|
import 'dayjs/locale/vi';
|
|
@@ -16,6 +16,8 @@ import vi from 'rc-master-ui/es/date-picker/locale/vi_VN';
|
|
|
16
16
|
import "./styles.scss";
|
|
17
17
|
import GridEdit from "./table/GridEdit";
|
|
18
18
|
import Grid from "./table/Grid";
|
|
19
|
+
// import useMergedState from "rc-util/lib/hooks/useMergedState";
|
|
20
|
+
|
|
19
21
|
dayjs.extend(customParseFormat);
|
|
20
22
|
const ResizableTitle = props => {
|
|
21
23
|
const {
|
|
@@ -50,6 +52,7 @@ const InternalTable = props => {
|
|
|
50
52
|
t,
|
|
51
53
|
columns: propsColumns,
|
|
52
54
|
lang,
|
|
55
|
+
locale,
|
|
53
56
|
dataSource,
|
|
54
57
|
allowResizing,
|
|
55
58
|
dataSourceFilter: propDataSourceFilter,
|
|
@@ -59,22 +62,33 @@ const InternalTable = props => {
|
|
|
59
62
|
format,
|
|
60
63
|
onDataChange,
|
|
61
64
|
sortMultiple,
|
|
65
|
+
expandable,
|
|
62
66
|
...rest
|
|
63
67
|
} = props;
|
|
64
|
-
const
|
|
68
|
+
const local = lang && lang === 'en' ? en : vi;
|
|
65
69
|
const buddhistLocale = {
|
|
66
|
-
...
|
|
70
|
+
...local,
|
|
67
71
|
lang: {
|
|
68
|
-
...
|
|
72
|
+
...local.lang
|
|
69
73
|
}
|
|
70
74
|
};
|
|
75
|
+
|
|
76
|
+
// const [mergedColumns, setMergedColumns] = useMergedState(
|
|
77
|
+
// propsColumns,
|
|
78
|
+
// {
|
|
79
|
+
// value: propsColumns,
|
|
80
|
+
// },
|
|
81
|
+
// );
|
|
82
|
+
|
|
71
83
|
const tableRef = useRef(null);
|
|
72
|
-
const [data, setData] = useState(
|
|
84
|
+
const [data, setData] = useState([]);
|
|
73
85
|
const [columns, setColumns] = useState([]);
|
|
74
86
|
const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
87
|
+
// const [expandKeys, setExpandKeys] = useState<string[]>([]);
|
|
75
88
|
const [dataSourceFilter, setDataSourceFilter] = useState(propDataSourceFilter ?? []);
|
|
76
89
|
useEffect(() => {
|
|
77
90
|
const rs = propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [];
|
|
91
|
+
// const rs = propsColumns ? [...propsColumns] : []
|
|
78
92
|
setColumns(rs);
|
|
79
93
|
}, [propsColumns]);
|
|
80
94
|
useEffect(() => {
|
|
@@ -82,7 +96,14 @@ const InternalTable = props => {
|
|
|
82
96
|
setData(dataSource || []);
|
|
83
97
|
}
|
|
84
98
|
setIsManualUpdate(false);
|
|
85
|
-
}, [dataSource]);
|
|
99
|
+
}, [dataSource, isManualUpdate]);
|
|
100
|
+
|
|
101
|
+
// const [columns, setColumns] = useMergedState(
|
|
102
|
+
// propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
103
|
+
// {
|
|
104
|
+
// value: propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
105
|
+
// },
|
|
106
|
+
// );
|
|
86
107
|
|
|
87
108
|
// ============================ RowKey ============================
|
|
88
109
|
const getRowKey = React.useMemo(() => {
|
|
@@ -92,6 +113,12 @@ const InternalTable = props => {
|
|
|
92
113
|
// @ts-ignore
|
|
93
114
|
return record => record?.[rowKey];
|
|
94
115
|
}, [rowKey]);
|
|
116
|
+
|
|
117
|
+
// useEffect(() => {
|
|
118
|
+
// const rrr = findAllChildrenKeys<any>(dataSource, getRowKey, 'children');
|
|
119
|
+
// setExpandKeys(rrr as any)
|
|
120
|
+
// }, [dataSource, getRowKey])
|
|
121
|
+
|
|
95
122
|
const handleSearch = (selectedKeys, confirm) => {
|
|
96
123
|
confirm();
|
|
97
124
|
};
|
|
@@ -116,23 +143,27 @@ const InternalTable = props => {
|
|
|
116
143
|
setSelectedKeys,
|
|
117
144
|
selectedKeys,
|
|
118
145
|
confirm,
|
|
119
|
-
close,
|
|
146
|
+
// close,
|
|
120
147
|
setOperatorKey,
|
|
121
148
|
operatorKey,
|
|
122
149
|
visible,
|
|
123
150
|
searchValue,
|
|
124
151
|
setSearchValue
|
|
125
152
|
}) => {
|
|
153
|
+
const type = getTypeFilter(column);
|
|
154
|
+
// const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
|
|
155
|
+
// const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
|
|
156
|
+
const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
|
|
126
157
|
return /*#__PURE__*/React.createElement("div", {
|
|
127
158
|
style: {
|
|
128
159
|
padding: 8,
|
|
129
160
|
minWidth: 275
|
|
130
161
|
},
|
|
131
162
|
onKeyDown: e => e.stopPropagation()
|
|
132
|
-
},
|
|
163
|
+
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/React.createElement("div", {
|
|
133
164
|
className: 'mb-1'
|
|
134
165
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
135
|
-
options: translateOption(
|
|
166
|
+
options: translateOption(operatorOptions, t),
|
|
136
167
|
style: {
|
|
137
168
|
width: '100%',
|
|
138
169
|
marginBottom: 8
|
|
@@ -145,7 +176,7 @@ const InternalTable = props => {
|
|
|
145
176
|
style: {
|
|
146
177
|
marginBottom: 8
|
|
147
178
|
}
|
|
148
|
-
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale)), /*#__PURE__*/React.createElement(Space, {
|
|
179
|
+
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t)), /*#__PURE__*/React.createElement(Space, {
|
|
149
180
|
style: {
|
|
150
181
|
justifyContent: 'end',
|
|
151
182
|
width: '100%'
|
|
@@ -163,13 +194,17 @@ const InternalTable = props => {
|
|
|
163
194
|
style: {
|
|
164
195
|
width: 90
|
|
165
196
|
}
|
|
166
|
-
},
|
|
197
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/React.createElement(Button, {
|
|
167
198
|
type: "link",
|
|
168
199
|
size: "small",
|
|
169
200
|
onClick: () => {
|
|
170
|
-
|
|
201
|
+
// setSearchValue('')
|
|
202
|
+
setSelectedKeys([]);
|
|
203
|
+
confirm();
|
|
204
|
+
// handleSearch()
|
|
205
|
+
// close()
|
|
171
206
|
}
|
|
172
|
-
}, "
|
|
207
|
+
}, t ? t("Clear") : 'Clear')));
|
|
173
208
|
},
|
|
174
209
|
filterIcon: filtered => /*#__PURE__*/React.createElement(FilterFill, {
|
|
175
210
|
fontSize: 12,
|
|
@@ -187,128 +222,114 @@ const InternalTable = props => {
|
|
|
187
222
|
}
|
|
188
223
|
}
|
|
189
224
|
}
|
|
190
|
-
}), [onFilterCallback, onFilterClick,
|
|
191
|
-
const handleResize =
|
|
225
|
+
}), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
|
|
226
|
+
const handleResize = column => (e, {
|
|
192
227
|
size
|
|
193
228
|
}) => {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (idx === currentIndex) {
|
|
198
|
-
if (restPath.length === 0) {
|
|
199
|
-
// Cập nhật width của cột cuối cùng trong path
|
|
200
|
-
// return { ...col, width: size.width }
|
|
201
|
-
|
|
202
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
203
|
-
if (col.minWidth && size.width < col.minWidth) {
|
|
204
|
-
e.preventDefault();
|
|
205
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
209
|
-
if (col.maxWidth && size.width > col.maxWidth) {
|
|
210
|
-
e.preventDefault();
|
|
211
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
...col,
|
|
215
|
-
width: size.width
|
|
216
|
-
};
|
|
217
|
-
} else if (col.children) {
|
|
218
|
-
// Tiếp tục cập nhật các cấp con
|
|
219
|
-
return {
|
|
220
|
-
...col,
|
|
221
|
-
children: updateColumns(col.children, restPath)
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// e.preventDefault()
|
|
226
|
-
return col;
|
|
227
|
-
});
|
|
229
|
+
const newColumn = {
|
|
230
|
+
...column,
|
|
231
|
+
width: size.width
|
|
228
232
|
};
|
|
229
|
-
|
|
233
|
+
const newColumns = updateArrayByKey(columns, newColumn, 'field');
|
|
234
|
+
setColumns(newColumns);
|
|
230
235
|
};
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
const convertColumns = flatColumns2(columns).map((column, colIndex) => {
|
|
237
|
+
if (!column?.dataIndex && !column.key && !column.field) {
|
|
238
|
+
return column;
|
|
239
|
+
}
|
|
240
|
+
const transformedColumn = {
|
|
241
|
+
...column,
|
|
242
|
+
dataIndex: column.field ?? column.dataIndex,
|
|
243
|
+
key: column.field ?? column.dataIndex ?? column.key,
|
|
244
|
+
title: t ? t(column.headerText ?? column.title) : column.headerText ?? column.title,
|
|
245
|
+
ellipsis: column.ellipsis !== false,
|
|
246
|
+
align: column.textAlign ?? column.align,
|
|
247
|
+
fixed: column.frozen ? column.frozen.toLowerCase() : column.fixed
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
if (["index", "#"].includes(transformedColumn.dataIndex)) {
|
|
252
|
+
return {
|
|
253
|
+
...transformedColumn,
|
|
254
|
+
onCell: () => ({
|
|
255
|
+
className: 'cell-number'
|
|
256
|
+
}),
|
|
257
|
+
render: (_, __, rowIndex) => rowIndex + 1
|
|
246
258
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
259
|
+
}
|
|
260
|
+
if (column.field === 'command') {
|
|
261
|
+
return {
|
|
262
|
+
...transformedColumn,
|
|
263
|
+
onCell: () => ({
|
|
264
|
+
className: column.field === 'command' ? "ui-rc-cell-command" : ''
|
|
265
|
+
}),
|
|
266
|
+
onHeaderCell: () => ({
|
|
267
|
+
width: column.width,
|
|
268
|
+
onResize: handleResize(column)
|
|
269
|
+
})
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
...(column.allowFiltering === false ? {} : {
|
|
274
|
+
...getColumnSearchProps(column)
|
|
275
|
+
}),
|
|
276
|
+
...transformedColumn,
|
|
277
|
+
onFilter: value => {
|
|
278
|
+
return value;
|
|
279
|
+
},
|
|
280
|
+
sorter: column.sorter === false ? undefined : {
|
|
281
|
+
compare: a => a,
|
|
282
|
+
multiple: sortMultiple ? colIndex : undefined
|
|
283
|
+
},
|
|
284
|
+
onHeaderCell: () => ({
|
|
285
|
+
width: column.width,
|
|
286
|
+
onResize: handleResize(column)
|
|
287
|
+
}),
|
|
288
|
+
render: (value, record, rowIndex) => renderContent(column, value, record, rowIndex, format)
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
const transformColumns = React.useCallback(cols => {
|
|
292
|
+
// @ts-ignore
|
|
293
|
+
return cols.map(column => {
|
|
294
|
+
const find = convertColumns.find(it => it.key === column.field);
|
|
295
|
+
if (!column?.field && !column?.key) {
|
|
296
|
+
return column;
|
|
252
297
|
}
|
|
253
|
-
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
if (["index", "#"].includes(transformedColumn.dataIndex)) {
|
|
298
|
+
if (find) {
|
|
256
299
|
return {
|
|
257
|
-
...
|
|
258
|
-
render: (_, __, rowIndex) => rowIndex + 1
|
|
300
|
+
...find
|
|
259
301
|
};
|
|
260
302
|
}
|
|
261
|
-
|
|
303
|
+
|
|
304
|
+
// Xử lý đệ quy cho children
|
|
305
|
+
if (column.children?.length) {
|
|
262
306
|
return {
|
|
263
|
-
...
|
|
264
|
-
|
|
265
|
-
className: col.field === 'command' ? "ui-rc-cell-command" : ''
|
|
266
|
-
}),
|
|
267
|
-
onHeaderCell: () => ({
|
|
268
|
-
width: col.width,
|
|
269
|
-
onResize: handleResize(currentPath)
|
|
270
|
-
})
|
|
307
|
+
...column,
|
|
308
|
+
children: transformColumns(column.children)
|
|
271
309
|
};
|
|
272
310
|
}
|
|
273
|
-
return {
|
|
274
|
-
...(col.allowFiltering === false ? {} : {
|
|
275
|
-
...getColumnSearchProps(col)
|
|
276
|
-
}),
|
|
277
|
-
...transformedColumn,
|
|
278
|
-
onFilter: value => {
|
|
279
|
-
return value;
|
|
280
|
-
},
|
|
281
|
-
sorter: col.sorter === false ? undefined : {
|
|
282
|
-
compare: a => a,
|
|
283
|
-
multiple: sortMultiple ? index : undefined
|
|
284
|
-
},
|
|
285
|
-
onHeaderCell: () => ({
|
|
286
|
-
width: col.width,
|
|
287
|
-
onResize: handleResize(currentPath)
|
|
288
|
-
}),
|
|
289
|
-
render: (value, record, rowIndex) => renderContent(col, value, record, rowIndex, format)
|
|
290
|
-
};
|
|
291
311
|
});
|
|
292
|
-
}, [
|
|
312
|
+
}, [convertColumns]);
|
|
293
313
|
const mergedColumns = React.useMemo(() => {
|
|
294
314
|
return transformColumns(columns);
|
|
295
315
|
}, [transformColumns, columns]);
|
|
296
|
-
|
|
297
|
-
// console.log('mergedColumns', mergedColumns)
|
|
298
|
-
|
|
299
316
|
const triggerChangeColumns = newColumns => {
|
|
300
317
|
setColumns(newColumns);
|
|
301
318
|
};
|
|
302
319
|
const triggerChangeData = newData => {
|
|
303
320
|
setIsManualUpdate(true);
|
|
304
321
|
setData(newData);
|
|
322
|
+
// setMergedData(newData)
|
|
305
323
|
onDataChange?.(newData);
|
|
306
324
|
};
|
|
307
325
|
const TableComponent = editAble ? GridEdit : Grid;
|
|
308
326
|
return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
309
327
|
t: t,
|
|
328
|
+
locale: locale,
|
|
310
329
|
tableRef: tableRef,
|
|
311
|
-
dataSource: data
|
|
330
|
+
dataSource: data
|
|
331
|
+
// mergedData={mergedData}
|
|
332
|
+
,
|
|
312
333
|
components: {
|
|
313
334
|
header: {
|
|
314
335
|
cell: allowResizing ? ResizableTitle : undefined
|
|
@@ -316,7 +337,7 @@ const InternalTable = props => {
|
|
|
316
337
|
},
|
|
317
338
|
format: format,
|
|
318
339
|
columns: mergedColumns
|
|
319
|
-
//
|
|
340
|
+
// defaultColumns={mergedColumns}
|
|
320
341
|
,
|
|
321
342
|
showSorterTooltip: {
|
|
322
343
|
target: 'sorter-icon'
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { Fragment, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { numericFormatter } from "react-numeric-component";
|
|
5
|
-
import { Table, Toolbar } from "rc-master-ui";
|
|
5
|
+
import { Empty, Table, Toolbar } from "rc-master-ui";
|
|
6
6
|
import 'dayjs/locale/es';
|
|
7
7
|
import 'dayjs/locale/vi';
|
|
8
8
|
import ContextMenu from "./ContextMenu";
|
|
@@ -88,6 +88,10 @@ const TableGrid = props => {
|
|
|
88
88
|
columns,
|
|
89
89
|
tableRef,
|
|
90
90
|
dataSource,
|
|
91
|
+
locale,
|
|
92
|
+
expandable,
|
|
93
|
+
rowHoverable,
|
|
94
|
+
// mergedData,
|
|
91
95
|
title,
|
|
92
96
|
format,
|
|
93
97
|
virtual = true,
|
|
@@ -133,6 +137,12 @@ const TableGrid = props => {
|
|
|
133
137
|
const menuRef = useRef(null);
|
|
134
138
|
const viewportWidth = window.innerWidth;
|
|
135
139
|
const viewportHeight = window.innerHeight;
|
|
140
|
+
|
|
141
|
+
// const defaultSelected = useMemo(() => {
|
|
142
|
+
// return defaultSelectedRowKeys ?? []
|
|
143
|
+
//
|
|
144
|
+
// }, [defaultSelectedRowKeys])
|
|
145
|
+
|
|
136
146
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
137
147
|
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
138
148
|
const [position, setPosition] = React.useState({
|
|
@@ -224,6 +234,8 @@ const TableGrid = props => {
|
|
|
224
234
|
}
|
|
225
235
|
};
|
|
226
236
|
const handleRowClick = () => () => {
|
|
237
|
+
// const key = getRowKey(record, index);
|
|
238
|
+
|
|
227
239
|
if (checkboxOnly !== true) {
|
|
228
240
|
if (type === 'single') {}
|
|
229
241
|
}
|
|
@@ -231,7 +243,6 @@ const TableGrid = props => {
|
|
|
231
243
|
|
|
232
244
|
// @ts-ignore
|
|
233
245
|
clickRef.current = setTimeout(() => {
|
|
234
|
-
// console.log("Single Click:", record);
|
|
235
246
|
clickRef.current = null;
|
|
236
247
|
}, 250);
|
|
237
248
|
};
|
|
@@ -263,6 +274,7 @@ const TableGrid = props => {
|
|
|
263
274
|
rowData: selectedRow
|
|
264
275
|
});
|
|
265
276
|
} else {
|
|
277
|
+
// @ts-ignore
|
|
266
278
|
setMergedSelectedKeys(keys);
|
|
267
279
|
rowSelected?.({
|
|
268
280
|
selected: selectedRows,
|
|
@@ -294,7 +306,15 @@ const TableGrid = props => {
|
|
|
294
306
|
contextMenuClick: contextMenuClick,
|
|
295
307
|
rowData: selectedRowData
|
|
296
308
|
}), /*#__PURE__*/React.createElement(Table, _extends({
|
|
297
|
-
ref: tableRef
|
|
309
|
+
ref: tableRef
|
|
310
|
+
}, rest, {
|
|
311
|
+
locale: {
|
|
312
|
+
...locale,
|
|
313
|
+
emptyText: /*#__PURE__*/React.createElement(Empty, {
|
|
314
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
315
|
+
description: locale?.emptyText
|
|
316
|
+
})
|
|
317
|
+
},
|
|
298
318
|
loading: {
|
|
299
319
|
spinning: columns && columns.length === 0 || loading === true,
|
|
300
320
|
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
@@ -309,7 +329,7 @@ const TableGrid = props => {
|
|
|
309
329
|
virtual: virtual,
|
|
310
330
|
columns: columns,
|
|
311
331
|
rowKey: rowKey,
|
|
312
|
-
rowHoverable:
|
|
332
|
+
rowHoverable: rowHoverable,
|
|
313
333
|
size: "small",
|
|
314
334
|
scroll: scroll ? scroll : {
|
|
315
335
|
y: 500
|
|
@@ -331,7 +351,9 @@ const TableGrid = props => {
|
|
|
331
351
|
selectedRowKeys: mergedSelectedKeys,
|
|
332
352
|
defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
333
353
|
preserveSelectedRowKeys: true,
|
|
334
|
-
...rowSelection,
|
|
354
|
+
// ...rowSelection,
|
|
355
|
+
// checkStrictly: false,
|
|
356
|
+
|
|
335
357
|
hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
336
358
|
},
|
|
337
359
|
onScroll: () => {
|
|
@@ -389,7 +411,7 @@ const TableGrid = props => {
|
|
|
389
411
|
// @ts-ignore
|
|
390
412
|
, {
|
|
391
413
|
style: {
|
|
392
|
-
width:
|
|
414
|
+
width: `calc(100% - 650px`
|
|
393
415
|
},
|
|
394
416
|
items: toolbarItems ?? [],
|
|
395
417
|
mode: 'scroll'
|
|
@@ -412,8 +434,40 @@ const TableGrid = props => {
|
|
|
412
434
|
t: t,
|
|
413
435
|
triggerChangeColumns: triggerChangeColumns
|
|
414
436
|
}))));
|
|
437
|
+
},
|
|
438
|
+
expandable: {
|
|
439
|
+
expandIconColumnIndex: 3,
|
|
440
|
+
defaultExpandAllRows: true,
|
|
441
|
+
indentSize: 25,
|
|
442
|
+
...expandable,
|
|
443
|
+
expandIcon: args => {
|
|
444
|
+
const {
|
|
445
|
+
record,
|
|
446
|
+
expanded,
|
|
447
|
+
onExpand
|
|
448
|
+
} = args;
|
|
449
|
+
|
|
450
|
+
// @ts-ignore
|
|
451
|
+
if (record?.children?.length > 0 || record?.isChildren) {
|
|
452
|
+
return expanded ? /*#__PURE__*/React.createElement("button", {
|
|
453
|
+
onClick: e => {
|
|
454
|
+
e.preventDefault();
|
|
455
|
+
e.stopPropagation();
|
|
456
|
+
onExpand(record, e);
|
|
457
|
+
},
|
|
458
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
459
|
+
}) : /*#__PURE__*/React.createElement("button", {
|
|
460
|
+
onClick: e => {
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
e.stopPropagation();
|
|
463
|
+
onExpand(record, e);
|
|
464
|
+
},
|
|
465
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
415
469
|
}
|
|
416
|
-
}
|
|
470
|
+
})), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/React.createElement(Pagination
|
|
417
471
|
// style={{padding: '0.75rem 1rem'}}
|
|
418
472
|
, _extends({
|
|
419
473
|
showSizeChanger: true,
|
|
@@ -10,29 +10,29 @@ export const numberOperator = [{
|
|
|
10
10
|
key: '>'
|
|
11
11
|
}, {
|
|
12
12
|
value: 'greaterthanorequal',
|
|
13
|
-
label: 'Greater
|
|
13
|
+
label: 'Greater than or equal',
|
|
14
14
|
key: '>='
|
|
15
15
|
}, {
|
|
16
16
|
value: 'lessthan',
|
|
17
|
-
label: 'Less
|
|
17
|
+
label: 'Less than',
|
|
18
18
|
key: '<'
|
|
19
19
|
}, {
|
|
20
20
|
value: 'lessthanorequal',
|
|
21
|
-
label: 'Less
|
|
21
|
+
label: 'Less than or equal',
|
|
22
22
|
key: '<='
|
|
23
23
|
}, {
|
|
24
24
|
value: 'notequal',
|
|
25
|
-
label: 'Not
|
|
25
|
+
label: 'Not equal',
|
|
26
26
|
key: '!='
|
|
27
27
|
}];
|
|
28
28
|
export const stringOperator = [{
|
|
29
29
|
value: 'startswith',
|
|
30
30
|
key: '_=',
|
|
31
|
-
label: 'Starts
|
|
31
|
+
label: 'Starts with'
|
|
32
32
|
}, {
|
|
33
33
|
value: 'endswith',
|
|
34
34
|
key: '|=',
|
|
35
|
-
label: 'Ends
|
|
35
|
+
label: 'Ends with'
|
|
36
36
|
}, {
|
|
37
37
|
value: 'contains',
|
|
38
38
|
key: '~=',
|
|
@@ -44,7 +44,7 @@ export const stringOperator = [{
|
|
|
44
44
|
}, {
|
|
45
45
|
value: 'notequal',
|
|
46
46
|
key: '!=',
|
|
47
|
-
label: 'Not
|
|
47
|
+
label: 'Not equal'
|
|
48
48
|
}];
|
|
49
49
|
export const dateOperator = [{
|
|
50
50
|
value: 'equal',
|
|
@@ -53,15 +53,15 @@ export const dateOperator = [{
|
|
|
53
53
|
}, {
|
|
54
54
|
value: 'notequal',
|
|
55
55
|
key: '!=',
|
|
56
|
-
label: 'Not
|
|
56
|
+
label: 'Not equal'
|
|
57
57
|
}, {
|
|
58
58
|
value: 'greaterthan',
|
|
59
59
|
key: '>',
|
|
60
|
-
label: 'Greater
|
|
60
|
+
label: 'Greater than'
|
|
61
61
|
}, {
|
|
62
62
|
value: 'lessthan',
|
|
63
63
|
key: '<',
|
|
64
|
-
label: 'Less
|
|
64
|
+
label: 'Less than'
|
|
65
65
|
}];
|
|
66
66
|
export const dateTimeOperator = [{
|
|
67
67
|
value: 'equal',
|
|
@@ -70,15 +70,15 @@ export const dateTimeOperator = [{
|
|
|
70
70
|
}, {
|
|
71
71
|
value: 'notequal',
|
|
72
72
|
key: '!=',
|
|
73
|
-
label: 'Not
|
|
73
|
+
label: 'Not equal'
|
|
74
74
|
}, {
|
|
75
75
|
value: 'greaterthan',
|
|
76
76
|
key: '>',
|
|
77
|
-
label: 'Greater
|
|
77
|
+
label: 'Greater than'
|
|
78
78
|
}, {
|
|
79
79
|
value: 'lessthan',
|
|
80
80
|
key: '<',
|
|
81
|
-
label: 'Less
|
|
81
|
+
label: 'Less than'
|
|
82
82
|
}];
|
|
83
83
|
export const booleanOperator = [{
|
|
84
84
|
value: 'equal',
|
|
@@ -87,7 +87,7 @@ export const booleanOperator = [{
|
|
|
87
87
|
}, {
|
|
88
88
|
value: 'notequal',
|
|
89
89
|
key: '!=',
|
|
90
|
-
label: 'Not
|
|
90
|
+
label: 'Not equal'
|
|
91
91
|
}];
|
|
92
92
|
export const translateOption = (options, t) => {
|
|
93
93
|
if (!t) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColumnType, IFormat } from "../../type";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
3
|
+
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
4
|
+
import type { ColumnsTable } from "../../type";
|
|
5
|
+
export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
6
|
+
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
4
7
|
export declare const getValueCell: <T>(column: ColumnType<T>, value: any, format?: IFormat) => any;
|
|
5
8
|
export declare const renderContent: <RecordType>(column: ColumnType<RecordType>, value: any, record: RecordType, index: number, format?: IFormat) => React.JSX.Element;
|
|
6
|
-
export declare const renderFilter: <RecordType>(column: ColumnType<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any) => React.JSX.Element;
|
|
9
|
+
export declare const renderFilter: <RecordType>(column: ColumnType<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any) => React.JSX.Element;
|