es-grid-template 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/index.css +16 -0
- package/assets/index.scss +37 -3
- package/es/grid-component/CheckboxFilter.js +4 -0
- package/es/grid-component/CheckboxFilter2.d.ts +20 -0
- package/es/grid-component/CheckboxFilter2.js +248 -0
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +4 -4
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/ConvertColumnTable.js +1 -0
- package/es/grid-component/EditableCell.js +11 -8
- package/es/grid-component/InternalTable.js +47 -11
- package/es/grid-component/TableGrid.d.ts +3 -0
- package/es/grid-component/TableGrid.js +71 -7
- package/es/grid-component/hooks/columns/index.js +14 -45
- package/es/grid-component/hooks/content/HeaderContent.js +54 -58
- package/es/grid-component/hooks/useColumns.d.ts +4 -2
- package/es/grid-component/hooks/useColumns.js +32 -13
- package/es/grid-component/hooks/utils.d.ts +9 -0
- package/es/grid-component/hooks/utils.js +278 -1
- package/es/grid-component/number-range/index.d.ts +10 -0
- package/es/grid-component/number-range/index.js +59 -0
- package/es/grid-component/styles.scss +24 -0
- package/es/grid-component/table/Grid.d.ts +3 -0
- package/es/grid-component/table/GridEdit.js +360 -106
- package/es/grid-component/table/Group.d.ts +1 -0
- package/es/grid-component/table/Group.js +1 -1
- package/es/grid-component/type.d.ts +2 -1
- package/lib/grid-component/CheckboxFilter.js +4 -0
- package/lib/grid-component/CheckboxFilter2.d.ts +20 -0
- package/lib/grid-component/CheckboxFilter2.js +257 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +4 -4
- package/lib/grid-component/ContextMenu.js +1 -0
- package/lib/grid-component/ConvertColumnTable.js +1 -0
- package/lib/grid-component/EditableCell.js +11 -8
- package/lib/grid-component/InternalTable.js +41 -10
- package/lib/grid-component/TableGrid.d.ts +3 -0
- package/lib/grid-component/TableGrid.js +68 -7
- package/lib/grid-component/hooks/columns/index.js +14 -45
- package/lib/grid-component/hooks/content/HeaderContent.js +53 -55
- package/lib/grid-component/hooks/useColumns.d.ts +4 -2
- package/lib/grid-component/hooks/useColumns.js +31 -12
- package/lib/grid-component/hooks/utils.d.ts +9 -0
- package/lib/grid-component/hooks/utils.js +293 -4
- package/lib/grid-component/number-range/index.d.ts +10 -0
- package/lib/grid-component/number-range/index.js +67 -0
- package/lib/grid-component/styles.scss +24 -0
- package/lib/grid-component/table/Grid.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.js +358 -104
- package/lib/grid-component/table/Group.d.ts +1 -0
- package/lib/grid-component/table/Group.js +1 -1
- package/lib/grid-component/type.d.ts +2 -1
- package/package.json +109 -108
|
@@ -5,12 +5,15 @@ import type { ColumnsTable, GetRowKey, GridTableProps } from "./type";
|
|
|
5
5
|
type GridProps<T> = GridTableProps<T> & {
|
|
6
6
|
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
7
|
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
|
+
triggerFilter?: (queries: any) => void;
|
|
8
9
|
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
9
10
|
tableRef: any;
|
|
10
11
|
bottomToolbar?: () => React.ReactElement;
|
|
11
12
|
getRowKey: GetRowKey<T>;
|
|
12
13
|
rowSelection?: any;
|
|
13
14
|
groupToolbar?: () => React.ReactNode;
|
|
15
|
+
isFilter?: boolean;
|
|
16
|
+
setIsFilter?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
17
|
};
|
|
15
18
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
16
19
|
export default TableGrid;
|
|
@@ -8,8 +8,11 @@ import 'dayjs/locale/vi';
|
|
|
8
8
|
import ContextMenu from "./ContextMenu";
|
|
9
9
|
import classNames from "classnames";
|
|
10
10
|
import { checkDecimalSeparator, checkThousandSeparator,
|
|
11
|
+
// filterDataByColumns2,
|
|
12
|
+
filterDataByColumns3,
|
|
11
13
|
// convertFlatColumn,
|
|
12
14
|
isEmpty,
|
|
15
|
+
// newGuid,
|
|
13
16
|
// removeColumns,
|
|
14
17
|
sumDataByField
|
|
15
18
|
// updateArrayByKey
|
|
@@ -21,6 +24,7 @@ import ComponentSpinner from "./LoadingSpinner";
|
|
|
21
24
|
import { ColumnsChoose } from "./ColumnsChoose";
|
|
22
25
|
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
23
26
|
import AdvanceFilter from "./AdvanceFilter";
|
|
27
|
+
import { Tooltip } from "react-tooltip";
|
|
24
28
|
const convertFilters = filters => {
|
|
25
29
|
const result = [];
|
|
26
30
|
filters.forEach(({
|
|
@@ -44,6 +48,40 @@ const convertFilters = filters => {
|
|
|
44
48
|
predicate: "and",
|
|
45
49
|
operator: "lessthanorequal"
|
|
46
50
|
});
|
|
51
|
+
} else if (column?.typeFilter === "NumberRange") {
|
|
52
|
+
if ((filteredKeys[0] || filteredKeys[0] === 0) && !filteredKeys[1]) {
|
|
53
|
+
result.push({
|
|
54
|
+
key,
|
|
55
|
+
field: column?.dataIndex,
|
|
56
|
+
value: filteredKeys[0],
|
|
57
|
+
predicate: "and",
|
|
58
|
+
operator: "greaterthanorequal"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if ((filteredKeys[1] || filteredKeys[1] === 0) && !filteredKeys[0]) {
|
|
62
|
+
result.push({
|
|
63
|
+
key,
|
|
64
|
+
field: column?.dataIndex,
|
|
65
|
+
value: filteredKeys[1],
|
|
66
|
+
predicate: "and",
|
|
67
|
+
operator: "lessthanorequal"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if ((filteredKeys[0] || filteredKeys[0] === 0) && (filteredKeys[1] || filteredKeys[1] === 0)) {
|
|
71
|
+
result.push({
|
|
72
|
+
key,
|
|
73
|
+
field: column?.dataIndex,
|
|
74
|
+
value: filteredKeys[0],
|
|
75
|
+
predicate: "and",
|
|
76
|
+
operator: "greaterthanorequal"
|
|
77
|
+
}, {
|
|
78
|
+
key,
|
|
79
|
+
field: column?.dataIndex,
|
|
80
|
+
value: filteredKeys[1],
|
|
81
|
+
predicate: "and",
|
|
82
|
+
operator: "lessthanorequal"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
47
85
|
} else if (column?.typeFilter === 'Checkbox') {
|
|
48
86
|
filteredKeys.forEach(value => {
|
|
49
87
|
result.push({
|
|
@@ -111,6 +149,7 @@ const TableGrid = props => {
|
|
|
111
149
|
showColumnChoose,
|
|
112
150
|
showAdvanceFilter,
|
|
113
151
|
onFilter,
|
|
152
|
+
triggerFilter,
|
|
114
153
|
selectionSettings,
|
|
115
154
|
rowSelection,
|
|
116
155
|
rowSelected,
|
|
@@ -132,6 +171,7 @@ const TableGrid = props => {
|
|
|
132
171
|
groupColumns,
|
|
133
172
|
groupToolbar,
|
|
134
173
|
showEmptyText,
|
|
174
|
+
setIsFilter,
|
|
135
175
|
...rest
|
|
136
176
|
} = props;
|
|
137
177
|
const {
|
|
@@ -158,6 +198,7 @@ const TableGrid = props => {
|
|
|
158
198
|
viewportWidth,
|
|
159
199
|
viewportHeight
|
|
160
200
|
});
|
|
201
|
+
const [filterStates, setFilterState] = React.useState(null);
|
|
161
202
|
|
|
162
203
|
// const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
|
|
163
204
|
|
|
@@ -294,6 +335,18 @@ const TableGrid = props => {
|
|
|
294
335
|
const handleChange = sorter => {
|
|
295
336
|
onSorter?.(sorter);
|
|
296
337
|
};
|
|
338
|
+
const handleOnFilter = queries => {
|
|
339
|
+
if (onFilter) {
|
|
340
|
+
onFilter?.(convertFilters(queries));
|
|
341
|
+
} else {
|
|
342
|
+
setFilterState(convertFilters(queries));
|
|
343
|
+
if (queries && queries.length > 0) {
|
|
344
|
+
setIsFilter?.(true);
|
|
345
|
+
} else {
|
|
346
|
+
setIsFilter?.(false);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
297
350
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
298
351
|
open: menuVisible,
|
|
299
352
|
pos: position,
|
|
@@ -305,6 +358,9 @@ const TableGrid = props => {
|
|
|
305
358
|
}), /*#__PURE__*/React.createElement(Table, _extends({
|
|
306
359
|
ref: tableRef
|
|
307
360
|
}, rest, {
|
|
361
|
+
tableLayout: 'fixed'
|
|
362
|
+
// id={newGuid()}
|
|
363
|
+
,
|
|
308
364
|
locale: {
|
|
309
365
|
...locale,
|
|
310
366
|
emptyText: showEmptyText !== false ? /*#__PURE__*/React.createElement(Empty, {
|
|
@@ -316,7 +372,8 @@ const TableGrid = props => {
|
|
|
316
372
|
spinning: columns && columns.length === 0 || loading === true,
|
|
317
373
|
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
318
374
|
},
|
|
319
|
-
dataSource: columns && columns.length > 0 && loading !== true ? dataSource : []
|
|
375
|
+
dataSource: columns && columns.length > 0 && loading !== true ? filterDataByColumns3(dataSource, filterStates) : []
|
|
376
|
+
// dataSource={columns && columns.length > 0 && loading !== true ? dataSource : []}
|
|
320
377
|
// className={styles.customTable}
|
|
321
378
|
,
|
|
322
379
|
className: classNames(className, {
|
|
@@ -351,10 +408,13 @@ const TableGrid = props => {
|
|
|
351
408
|
// checkStrictly: false,
|
|
352
409
|
|
|
353
410
|
hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// onScroll={() => {
|
|
414
|
+
// setMenuVisible(false)
|
|
415
|
+
// }}
|
|
416
|
+
,
|
|
417
|
+
|
|
358
418
|
summary: () => {
|
|
359
419
|
if (typeof summary === 'function') {
|
|
360
420
|
return summary(dataSource);
|
|
@@ -393,7 +453,9 @@ const TableGrid = props => {
|
|
|
393
453
|
...pagination
|
|
394
454
|
},
|
|
395
455
|
onFilter: val => {
|
|
396
|
-
|
|
456
|
+
handleOnFilter(val);
|
|
457
|
+
// triggerFilter?.(convertFilters(val))
|
|
458
|
+
// onFilter?.(convertFilters(val))
|
|
397
459
|
},
|
|
398
460
|
onChange: (paging, filters, sorter) => handleChange(sorter),
|
|
399
461
|
title: showToolbar === false ? undefined : () => {
|
|
@@ -455,6 +517,8 @@ const TableGrid = props => {
|
|
|
455
517
|
// @ts-ignore
|
|
456
518
|
,
|
|
457
519
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
458
|
-
}, pagination)), bottomToolbar?.()
|
|
520
|
+
}, pagination)), bottomToolbar?.(), /*#__PURE__*/React.createElement(Tooltip, {
|
|
521
|
+
id: "tooltip-header"
|
|
522
|
+
}));
|
|
459
523
|
};
|
|
460
524
|
export default TableGrid;
|
|
@@ -6,6 +6,7 @@ import React, { Fragment } from "react";
|
|
|
6
6
|
import { DatePicker, Empty, Input, Select } from "rc-master-ui";
|
|
7
7
|
import CheckboxFilter from "../../CheckboxFilter";
|
|
8
8
|
import { SELECTION_COLUMN } from "rc-master-ui/es/table/hooks/useSelection";
|
|
9
|
+
import NumberRange from "../../number-range";
|
|
9
10
|
const {
|
|
10
11
|
RangePicker
|
|
11
12
|
} = DatePicker;
|
|
@@ -131,11 +132,6 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
131
132
|
const dateRangeFormat = getDatepickerFormat(column?.type, column) ?? 'DD/MM/YYYY';
|
|
132
133
|
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
133
134
|
const options = find ? find.data : [];
|
|
134
|
-
|
|
135
|
-
// console.log('dataSourceFilter', dataSourceFilter)
|
|
136
|
-
// console.log('options', options)
|
|
137
|
-
// console.log('column', column)
|
|
138
|
-
|
|
139
135
|
switch (type) {
|
|
140
136
|
case 'Number':
|
|
141
137
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -155,39 +151,15 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
155
151
|
}
|
|
156
152
|
}))));
|
|
157
153
|
case 'NumberRange':
|
|
158
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumberRange, {
|
|
155
|
+
t: t,
|
|
156
|
+
min: selectedKeys[0],
|
|
157
|
+
max: selectedKeys[1],
|
|
158
|
+
onChange: vals => {
|
|
159
|
+
console.log('NumberRange', vals);
|
|
160
|
+
setSelectedKeys(vals);
|
|
163
161
|
}
|
|
164
|
-
}
|
|
165
|
-
value: selectedKeys[0]
|
|
166
|
-
// thousandSeparator={checkThousandSeparator(thousandSeparator, decimalSeparator)}
|
|
167
|
-
// decimalSeparator={checkDecimalSeparator(thousandSeparator, decimalSeparator)}
|
|
168
|
-
,
|
|
169
|
-
allowNegative: true,
|
|
170
|
-
customInput: Input,
|
|
171
|
-
className: ' rounded-0 input-element form-control'
|
|
172
|
-
// onValueChange={(values: any) => {
|
|
173
|
-
// onChangeValueFilter(type, values.floatValue, 'min')
|
|
174
|
-
// }}
|
|
175
|
-
,
|
|
176
|
-
placeholder: t ? t('Min') : 'Min',
|
|
177
|
-
autoFocus: true
|
|
178
|
-
})), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
|
|
179
|
-
value: selectedKeys[1]
|
|
180
|
-
// thousandSeparator={checkThousandSeparator(thousandSeparator, decimalSeparator)}
|
|
181
|
-
// decimalSeparator={checkDecimalSeparator(thousandSeparator, decimalSeparator)}
|
|
182
|
-
,
|
|
183
|
-
allowNegative: true,
|
|
184
|
-
customInput: Input,
|
|
185
|
-
className: ' rounded-0 input-element form-control',
|
|
186
|
-
onValueChange: () => {
|
|
187
|
-
// onChangeValueFilter(type, values.floatValue, 'max')
|
|
188
|
-
},
|
|
189
|
-
placeholder: t ? t('Max') : 'Max'
|
|
190
|
-
})))));
|
|
162
|
+
})));
|
|
191
163
|
case 'Date':
|
|
192
164
|
const dateValue = selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateFormat) : null;
|
|
193
165
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -438,16 +410,13 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
438
410
|
case 'Checkbox':
|
|
439
411
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
440
412
|
className: 'mb-1'
|
|
441
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CheckboxFilter
|
|
442
|
-
// locale={{
|
|
443
|
-
// filterTitle: 'Chọn tất cả',
|
|
444
|
-
// filterCheckall: 'Chọn tất cả'
|
|
445
|
-
// }}
|
|
446
|
-
, {
|
|
413
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CheckboxFilter, {
|
|
447
414
|
locale: locale,
|
|
448
415
|
selectedKeys: selectedKeys,
|
|
449
|
-
onSelect: setSelectedKeys
|
|
450
|
-
|
|
416
|
+
onSelect: setSelectedKeys
|
|
417
|
+
// options={options}
|
|
418
|
+
,
|
|
419
|
+
options: column.source ? column.source : options ?? [],
|
|
451
420
|
filterMultiple: true,
|
|
452
421
|
open: visible,
|
|
453
422
|
searchValue: searchValue,
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { Fragment, useState } from "react";
|
|
1
|
+
import React, { Fragment } from "react";
|
|
3
2
|
import classnames from "classnames";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
} from "@floating-ui/react";
|
|
7
|
-
import styled from "styled-components";
|
|
3
|
+
|
|
4
|
+
// import styled from "styled-components";
|
|
8
5
|
import { getTemplate } from "../utils";
|
|
9
|
-
const TooltipStyle = styled.div
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
// const TooltipStyle = styled.div`
|
|
7
|
+
// width: max-content;
|
|
8
|
+
// background-color: #444;
|
|
9
|
+
// color: white;
|
|
10
|
+
// font-size: 90%;
|
|
11
|
+
// padding: 4px 8px;
|
|
12
|
+
// border-radius: 4px;
|
|
13
|
+
// opacity: 0.9;
|
|
14
|
+
// z-index: 9999;
|
|
15
|
+
// max-width: 450px;
|
|
16
|
+
// `
|
|
17
|
+
|
|
13
18
|
const HeaderContent = props => {
|
|
14
19
|
const {
|
|
15
20
|
t
|
|
@@ -26,54 +31,45 @@ const HeaderContent = props => {
|
|
|
26
31
|
const tooltip = React.useMemo(() => {
|
|
27
32
|
return headerTooltip ?? columnGroupText ?? headerText;
|
|
28
33
|
}, [columnGroupText, headerText, headerTooltip]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
wordBreak: 'keep-all'
|
|
64
|
-
}
|
|
34
|
+
//
|
|
35
|
+
//
|
|
36
|
+
// const [isOpen, setIsOpen] = useState(false)
|
|
37
|
+
//
|
|
38
|
+
// const { refs, floatingStyles, context } = useFloating({
|
|
39
|
+
// open: isOpen,
|
|
40
|
+
// onOpenChange: setIsOpen,
|
|
41
|
+
// placement: "top",
|
|
42
|
+
// whileElementsMounted: autoUpdate,
|
|
43
|
+
// middleware: [
|
|
44
|
+
// offset(5),
|
|
45
|
+
// flip({
|
|
46
|
+
// fallbackAxisSideDirection: "start"
|
|
47
|
+
// }),
|
|
48
|
+
// shift()
|
|
49
|
+
// ]
|
|
50
|
+
// })
|
|
51
|
+
//
|
|
52
|
+
// const hover = useHover(context, { move: false })
|
|
53
|
+
// const focus = useFocus(context)
|
|
54
|
+
// const dismiss = useDismiss(context)
|
|
55
|
+
// const role = useRole(context, { role: "tooltip" })
|
|
56
|
+
//
|
|
57
|
+
// const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
58
|
+
// hover,
|
|
59
|
+
// focus,
|
|
60
|
+
// dismiss,
|
|
61
|
+
// role
|
|
62
|
+
// ])
|
|
63
|
+
|
|
64
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
// ref={refs.setReference}
|
|
66
|
+
// tabIndex={-1}
|
|
67
|
+
// style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
|
|
65
68
|
// style={{flex: 1}}
|
|
66
|
-
,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
className: "Tooltip",
|
|
72
|
-
ref: refs.setFloating,
|
|
73
|
-
style: {
|
|
74
|
-
...floatingStyles,
|
|
75
|
-
zIndex: 1999
|
|
76
|
-
}
|
|
77
|
-
}, getFloatingProps()), headerTooltip && typeof headerTooltip === 'function' ? headerTooltip() : t ? t(tooltip) : tooltip)));
|
|
69
|
+
className: classnames('', {}),
|
|
70
|
+
"data-tooltip-id": "tooltip-header",
|
|
71
|
+
"data-tooltip-content": tooltip,
|
|
72
|
+
"data-tooltip-offset": 16
|
|
73
|
+
}, headerTemplate ? getTemplate(headerTemplate) : t ? t(text) : text));
|
|
78
74
|
};
|
|
79
75
|
export default HeaderContent;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AnyObject, IGroupSetting } from "../type";
|
|
2
2
|
export declare const SELECTION_COLUMN: {};
|
|
3
|
-
interface UseColumnsConfig {
|
|
3
|
+
interface UseColumnsConfig<RecordType> {
|
|
4
4
|
t?: any;
|
|
5
|
+
dataSource: RecordType[];
|
|
5
6
|
buddhistLocale?: any;
|
|
6
7
|
dataSourceFilter?: any;
|
|
7
8
|
locale?: any;
|
|
@@ -11,6 +12,7 @@ interface UseColumnsConfig {
|
|
|
11
12
|
groupAble?: boolean;
|
|
12
13
|
groupSetting?: IGroupSetting;
|
|
13
14
|
groupColumns?: string[];
|
|
15
|
+
rowKey?: any;
|
|
14
16
|
}
|
|
15
|
-
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig) => readonly [any];
|
|
17
|
+
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
|
|
16
18
|
export default useColumns;
|
|
@@ -4,7 +4,7 @@ import { Fragment, useCallback } from 'react';
|
|
|
4
4
|
// import Command from "../Command";
|
|
5
5
|
import { Button, Space } from "antd";
|
|
6
6
|
import { Select } from "rc-master-ui";
|
|
7
|
-
import { getTypeFilter } from "./utils";
|
|
7
|
+
import { findItemPath, getTypeFilter } from "./utils";
|
|
8
8
|
import { booleanOperator, numberOperator, stringOperator, translateOption } from "./constant";
|
|
9
9
|
import { flatColumns2, renderContent, renderFilter } from "./columns";
|
|
10
10
|
import { SearchOutlined } from "@ant-design/icons";
|
|
@@ -39,14 +39,31 @@ const useColumns = config => {
|
|
|
39
39
|
handleResize,
|
|
40
40
|
groupAble,
|
|
41
41
|
groupColumns,
|
|
42
|
-
groupSetting
|
|
42
|
+
groupSetting,
|
|
43
|
+
dataSource,
|
|
44
|
+
rowKey
|
|
43
45
|
} = config;
|
|
44
46
|
|
|
47
|
+
// const mergedColumns = React.useMemo(
|
|
48
|
+
// () => getMergedColumns<RecordType>(rawMergedColumns || []),
|
|
49
|
+
// [rawMergedColumns],
|
|
50
|
+
// );
|
|
51
|
+
//
|
|
52
|
+
// const [filterStates, setFilterStates] = React.useState<FilterState<RecordType>[]>(() =>
|
|
53
|
+
// collectFilterStates(mergedColumns, true),
|
|
54
|
+
// );
|
|
55
|
+
|
|
45
56
|
// ====================== Selections ======================
|
|
46
57
|
|
|
47
|
-
const handleSearch = (
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
// const handleSearch = (
|
|
59
|
+
// selectedKeys: string[],
|
|
60
|
+
// confirm: any,
|
|
61
|
+
// ) => {
|
|
62
|
+
//
|
|
63
|
+
// confirm()
|
|
64
|
+
//
|
|
65
|
+
// }
|
|
66
|
+
|
|
50
67
|
const getColumnSearchProps = useCallback(column => ({
|
|
51
68
|
filterDropdown: ({
|
|
52
69
|
setSelectedKeys,
|
|
@@ -93,10 +110,9 @@ const useColumns = config => {
|
|
|
93
110
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
94
111
|
type: "primary",
|
|
95
112
|
onClick: () => {
|
|
96
|
-
confirm({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
handleSearch(selectedKeys, confirm);
|
|
113
|
+
// confirm({closeDropdown: false})
|
|
114
|
+
confirm();
|
|
115
|
+
// handleSearch(selectedKeys as string[], confirm)
|
|
100
116
|
},
|
|
101
117
|
icon: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
102
118
|
size: "small",
|
|
@@ -138,8 +154,8 @@ const useColumns = config => {
|
|
|
138
154
|
const transformColumns = useCallback(columns => {
|
|
139
155
|
// >>>>>>>>>>> Support selection
|
|
140
156
|
const cloneColumns = [...columns];
|
|
141
|
-
const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
142
|
-
const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
157
|
+
const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
158
|
+
const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
143
159
|
|
|
144
160
|
// ===================== Render =====================
|
|
145
161
|
|
|
@@ -181,10 +197,13 @@ const useColumns = config => {
|
|
|
181
197
|
onCell: () => ({
|
|
182
198
|
className: 'cell-number'
|
|
183
199
|
}),
|
|
184
|
-
render: (
|
|
200
|
+
render: (val, record) => {
|
|
201
|
+
// return rowIndex + 1
|
|
202
|
+
return findItemPath(dataSource, record, rowKey);
|
|
203
|
+
}
|
|
185
204
|
};
|
|
186
205
|
}
|
|
187
|
-
if (col.
|
|
206
|
+
if (col.field === 'command') {
|
|
188
207
|
return {
|
|
189
208
|
...transformedColumn,
|
|
190
209
|
onCell: () => ({
|
|
@@ -71,3 +71,12 @@ export declare const checkChild: (inputArray: any[]) => boolean;
|
|
|
71
71
|
export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
|
|
72
72
|
export declare const isArraysEqual: (arr1: any[], arr2: any[]) => boolean;
|
|
73
73
|
export declare const editAbleColumns: <T>(columns: ColumnsTable<T>) => ColumnTable<T>[];
|
|
74
|
+
export declare const findItemPath: (tree: any[], targetItem: any, rowKey: any) => any;
|
|
75
|
+
export declare const filterDataByColumns: (data: any[], queries: any) => any[];
|
|
76
|
+
export declare const filterDataByColumns2: (data: any[], queries: any) => any[];
|
|
77
|
+
export declare const removeFieldRecursive: (data: any[], field: string) => any[];
|
|
78
|
+
export declare const filterDataByColumns3: (data: any[], queries: any[]) => any[];
|
|
79
|
+
export declare function isDateString(str: any): boolean;
|
|
80
|
+
export declare function compareDates(date1: any, date2: any): boolean;
|
|
81
|
+
export declare function compareDate(itemValue: any, value: any): boolean;
|
|
82
|
+
export declare function invalidDate(date: any): boolean;
|