es-grid-template 1.5.17 → 1.6.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/es/grid-component/CheckboxFilter2.js +0 -4
- package/es/grid-component/ColumnsChoose.js +9 -4
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/es/grid-component/EditForm/EditForm.d.ts +27 -0
- package/es/grid-component/EditForm/EditForm.js +391 -0
- package/es/grid-component/EditForm/index.d.ts +1 -0
- package/es/grid-component/EditForm/index.js +1 -0
- package/es/grid-component/EditableCell.js +72 -52
- package/es/grid-component/InternalTable.js +79 -27
- package/es/grid-component/TableGrid.js +39 -107
- package/es/grid-component/control/InputControl/InputControl.d.ts +26 -0
- package/es/grid-component/control/InputControl/InputControl.js +121 -0
- package/es/grid-component/control/InputControl/index.d.ts +1 -0
- package/es/grid-component/control/InputControl/index.js +1 -0
- package/es/grid-component/hooks/columns/index.d.ts +3 -2
- package/es/grid-component/hooks/columns/index.js +84 -8
- package/es/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/es/grid-component/hooks/content/ControlCheckbox.js +87 -0
- package/es/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/es/grid-component/hooks/content/HeaderContent.js +9 -4
- package/es/grid-component/hooks/useColumns.js +5 -5
- package/es/grid-component/hooks/utils.d.ts +28 -3
- package/es/grid-component/hooks/utils.js +544 -12
- package/es/grid-component/styles.scss +50 -1
- package/es/grid-component/table/Grid.d.ts +3 -0
- package/es/grid-component/table/GridEdit.d.ts +3 -0
- package/es/grid-component/table/GridEdit.js +353 -328
- package/es/grid-component/table/Group.d.ts +3 -0
- package/es/grid-component/table/InfiniteTable.d.ts +3 -0
- package/es/grid-component/table/InfiniteTable.js +4 -2
- package/es/grid-component/type.d.ts +28 -0
- package/es/grid-component/useContext.d.ts +0 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/select/index.d.ts +1 -1
- package/lib/grid-component/CheckboxFilter2.js +0 -4
- package/lib/grid-component/ColumnsChoose.js +9 -4
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/lib/grid-component/EditForm/EditForm.d.ts +27 -0
- package/lib/grid-component/EditForm/EditForm.js +401 -0
- package/lib/grid-component/EditForm/index.d.ts +1 -0
- package/lib/grid-component/EditForm/index.js +16 -0
- package/lib/grid-component/EditableCell.js +72 -52
- package/lib/grid-component/InternalTable.js +78 -26
- package/lib/grid-component/TableGrid.js +37 -105
- package/lib/grid-component/control/InputControl/InputControl.d.ts +26 -0
- package/lib/grid-component/control/InputControl/InputControl.js +131 -0
- package/lib/grid-component/control/InputControl/index.d.ts +1 -0
- package/lib/grid-component/control/InputControl/index.js +16 -0
- package/lib/grid-component/hooks/columns/index.d.ts +3 -2
- package/lib/grid-component/hooks/columns/index.js +86 -9
- package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/lib/grid-component/hooks/content/ControlCheckbox.js +95 -0
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/lib/grid-component/hooks/content/HeaderContent.js +9 -4
- package/lib/grid-component/hooks/useColumns.js +5 -5
- package/lib/grid-component/hooks/utils.d.ts +28 -3
- package/lib/grid-component/hooks/utils.js +565 -19
- package/lib/grid-component/styles.scss +50 -1
- package/lib/grid-component/table/Grid.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.js +343 -325
- package/lib/grid-component/table/Group.d.ts +3 -0
- package/lib/grid-component/table/InfiniteTable.d.ts +3 -0
- package/lib/grid-component/table/InfiniteTable.js +4 -2
- package/lib/grid-component/type.d.ts +28 -0
- package/lib/grid-component/useContext.d.ts +0 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/select/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _EditForm = require("./EditForm");
|
|
7
|
+
Object.keys(_EditForm).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _EditForm[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _EditForm[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -19,6 +19,7 @@ var _rcMasterUi = require("rc-master-ui");
|
|
|
19
19
|
var _asyncSelect = require("./async-select");
|
|
20
20
|
var _asyncTableSelect = require("./async-table-select");
|
|
21
21
|
var _colors = require("@ant-design/colors");
|
|
22
|
+
var _EditForm = require("./EditForm");
|
|
22
23
|
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); }
|
|
23
24
|
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; }
|
|
24
25
|
// import moment from "moment";
|
|
@@ -30,6 +31,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
30
31
|
const {
|
|
31
32
|
SHOW_PARENT
|
|
32
33
|
} = _rcMasterUi.TreeSelect;
|
|
34
|
+
const {
|
|
35
|
+
TextArea
|
|
36
|
+
} = _antd.Input;
|
|
33
37
|
const filterTreeNode = (input, treeNode) => {
|
|
34
38
|
const {
|
|
35
39
|
title,
|
|
@@ -116,8 +120,13 @@ const EditableCell = props => {
|
|
|
116
120
|
style: {
|
|
117
121
|
width: '100%',
|
|
118
122
|
height: '100%'
|
|
119
|
-
}
|
|
120
|
-
value
|
|
123
|
+
}
|
|
124
|
+
// value={date}
|
|
125
|
+
,
|
|
126
|
+
defaultValue: date
|
|
127
|
+
// preserveInvalidOnBlur
|
|
128
|
+
,
|
|
129
|
+
|
|
121
130
|
onBlur: () => {
|
|
122
131
|
const formState = getValues();
|
|
123
132
|
const itemState = getValues(dataIndex);
|
|
@@ -142,16 +151,7 @@ const EditableCell = props => {
|
|
|
142
151
|
placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
|
|
143
152
|
disabled: (0, _hooks.isDisable)(column, record) ?? false,
|
|
144
153
|
maxDate: maxDate,
|
|
145
|
-
minDate: minDate
|
|
146
|
-
|
|
147
|
-
// onOpenChange={(open) => {
|
|
148
|
-
// console.log(open)
|
|
149
|
-
// if (open) {
|
|
150
|
-
// handleSubmit(onSubmit)
|
|
151
|
-
// }
|
|
152
|
-
// }}
|
|
153
|
-
,
|
|
154
|
-
|
|
154
|
+
minDate: minDate,
|
|
155
155
|
onChange: (newDate, dateString) => {
|
|
156
156
|
const newDateValue = dateString ? (0, _moment.default)((0, _hooks.convertDayjsToDate)(dateString, dateFormat)).format() : null;
|
|
157
157
|
onChange(newDateValue);
|
|
@@ -180,15 +180,16 @@ const EditableCell = props => {
|
|
|
180
180
|
width: '100%',
|
|
181
181
|
height: '100%'
|
|
182
182
|
},
|
|
183
|
-
showTime: true
|
|
184
|
-
value
|
|
183
|
+
showTime: true
|
|
184
|
+
// value={date}
|
|
185
|
+
,
|
|
186
|
+
defaultValue: date,
|
|
185
187
|
placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
|
|
186
188
|
disabled: (0, _hooks.isDisable)(column, record) ?? false,
|
|
187
189
|
maxDate: maxDate,
|
|
188
190
|
minDate: minDate,
|
|
189
191
|
onChange: (newDate, dateString) => {
|
|
190
192
|
const newDateValue = dateString ? (0, _moment.default)((0, _hooks.convertDayjsToDate)(dateString, dateFormat)).format() : null;
|
|
191
|
-
// console.log('newDateValue', newDateValue)
|
|
192
193
|
onChange(newDateValue);
|
|
193
194
|
setTimeout(() => {
|
|
194
195
|
// @ts-ignore
|
|
@@ -710,7 +711,7 @@ const EditableCell = props => {
|
|
|
710
711
|
style: {
|
|
711
712
|
display: 'flex',
|
|
712
713
|
alignItems: 'center',
|
|
713
|
-
justifyContent: column.align ?? '
|
|
714
|
+
justifyContent: column.align ?? 'center',
|
|
714
715
|
paddingInline: 5,
|
|
715
716
|
height: '100%',
|
|
716
717
|
width: '100%'
|
|
@@ -720,7 +721,7 @@ const EditableCell = props => {
|
|
|
720
721
|
// style={{ textAlign: column.align ?? 'left' }}
|
|
721
722
|
,
|
|
722
723
|
onChange: val => {
|
|
723
|
-
const newVal = (0, _hooks.parseBooleanToValue)(val.target.checked, typeof value);
|
|
724
|
+
const newVal = typeof value === "number" ? (0, _hooks.parseBooleanToValue)(val.target.checked, typeof value) : val.target.checked;
|
|
724
725
|
onChange(newVal);
|
|
725
726
|
const key = getRowKey?.(record, index);
|
|
726
727
|
const formState = getValues();
|
|
@@ -738,36 +739,51 @@ const EditableCell = props => {
|
|
|
738
739
|
},
|
|
739
740
|
disabled: (0, _hooks.isDisable)(column, record) ?? false
|
|
740
741
|
}));
|
|
742
|
+
case 'form':
|
|
743
|
+
const valueForm = value;
|
|
744
|
+
return /*#__PURE__*/_react.default.createElement(_EditForm.EditForm, {
|
|
745
|
+
rowData: record,
|
|
746
|
+
column: column,
|
|
747
|
+
t: t,
|
|
748
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
749
|
+
value: valueForm
|
|
750
|
+
// fieldKey={'name'}
|
|
751
|
+
,
|
|
752
|
+
fieldKey: column.editFromSettings?.fieldKey
|
|
753
|
+
// recordData={record}
|
|
754
|
+
,
|
|
755
|
+
indexRow: indexRow,
|
|
756
|
+
cellFocus: column.field === cellEditing?.column.field,
|
|
757
|
+
onChange: val => {
|
|
758
|
+
const formState = getValues();
|
|
741
759
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
// />
|
|
770
|
-
// )
|
|
760
|
+
// @ts-ignore
|
|
761
|
+
const prevState = record[dataIndex];
|
|
762
|
+
const newState = val;
|
|
763
|
+
handleCellChange?.({
|
|
764
|
+
key: getRowKey?.(record, index),
|
|
765
|
+
field: column.field ?? column.dataIndex,
|
|
766
|
+
record: {
|
|
767
|
+
...formState,
|
|
768
|
+
[column.field ?? '']: val
|
|
769
|
+
},
|
|
770
|
+
prevState,
|
|
771
|
+
newState,
|
|
772
|
+
option: val,
|
|
773
|
+
indexCol,
|
|
774
|
+
indexRow,
|
|
775
|
+
type: 'blur'
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
// cellEditing={cellEditing}
|
|
779
|
+
|
|
780
|
+
// menuPortalTarget={tableContainerRef}
|
|
781
|
+
// classNamePrefix={column.classElement ?? 'select'}
|
|
782
|
+
,
|
|
783
|
+
placeholder: t ? t(column.placeholder ? column.placeholder : '') : column.placeholder ? column.placeholder : '',
|
|
784
|
+
menuWidth: column.editFromSettings?.menuWidth,
|
|
785
|
+
menuHeight: column.editFromSettings?.menuHeight
|
|
786
|
+
});
|
|
771
787
|
|
|
772
788
|
// case 'file':
|
|
773
789
|
// const valueFile = record[column.dataIndex]
|
|
@@ -931,11 +947,14 @@ const EditableCell = props => {
|
|
|
931
947
|
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
932
948
|
}));
|
|
933
949
|
default:
|
|
934
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
950
|
+
return /*#__PURE__*/_react.default.createElement(TextArea, {
|
|
935
951
|
id: `col${indexCol}-record${indexRow}`,
|
|
936
952
|
style: {
|
|
937
|
-
textAlign: column.align
|
|
953
|
+
textAlign: column.align,
|
|
954
|
+
resize: 'none',
|
|
955
|
+
height: '100%'
|
|
938
956
|
}
|
|
957
|
+
|
|
939
958
|
// @ts-ignore
|
|
940
959
|
// value={!isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : ''}
|
|
941
960
|
,
|
|
@@ -949,9 +968,6 @@ const EditableCell = props => {
|
|
|
949
968
|
// @ts-ignore
|
|
950
969
|
const prevState = record[dataIndex];
|
|
951
970
|
const newState = value;
|
|
952
|
-
//
|
|
953
|
-
// console.log('newState', newState)
|
|
954
|
-
// console.log('prevState', prevState)
|
|
955
971
|
const key = getRowKey?.(record, index);
|
|
956
972
|
// @ts-ignore
|
|
957
973
|
if (newState !== prevState) {
|
|
@@ -991,7 +1007,11 @@ const EditableCell = props => {
|
|
|
991
1007
|
onChange: onChange,
|
|
992
1008
|
status: isInvalid ? 'error' : undefined,
|
|
993
1009
|
"data-tooltip-content": message,
|
|
994
|
-
"data-tooltip-id": `${id}-tooltip-form-error
|
|
1010
|
+
"data-tooltip-id": `${id}-tooltip-form-error`,
|
|
1011
|
+
autoSize: {
|
|
1012
|
+
minRows: 1,
|
|
1013
|
+
maxRows: 1
|
|
1014
|
+
}
|
|
995
1015
|
});
|
|
996
1016
|
}
|
|
997
1017
|
};
|
|
@@ -37,6 +37,7 @@ var _sortable = require("@dnd-kit/sortable");
|
|
|
37
37
|
var _reactResizable = require("react-resizable");
|
|
38
38
|
var _faker = require("@faker-js/faker");
|
|
39
39
|
var _InfiniteTable = _interopRequireDefault(require("./table/InfiniteTable"));
|
|
40
|
+
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
40
41
|
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); }
|
|
41
42
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
42
43
|
// import {Resizable} from "react-resizable";
|
|
@@ -191,15 +192,19 @@ const InternalTable = props => {
|
|
|
191
192
|
summary,
|
|
192
193
|
infiniteScroll,
|
|
193
194
|
wrapSettings,
|
|
195
|
+
onFilter,
|
|
194
196
|
...rest
|
|
195
197
|
} = props;
|
|
196
198
|
const id = _react.default.useMemo(() => {
|
|
197
199
|
return tableId ?? _faker.faker.string.alpha(20);
|
|
198
200
|
// return tableId ?? newGuid()
|
|
199
201
|
}, [tableId]);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
|
|
203
|
+
// const rowKey = React.useMemo(() => {
|
|
204
|
+
// return propRowKey ?? 'rowId'
|
|
205
|
+
// }, [propRowKey])
|
|
206
|
+
|
|
207
|
+
const rowKey = 'rowId';
|
|
203
208
|
const [scrollHeight, setHeight] = (0, _react.useState)(0);
|
|
204
209
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
205
210
|
const dateRangeLocale = lang && lang === 'en' ? _en_US2.default : _vi_VN2.default;
|
|
@@ -219,14 +224,30 @@ const InternalTable = props => {
|
|
|
219
224
|
over: -1
|
|
220
225
|
});
|
|
221
226
|
const [tooltipContent, setTooltipContent] = (0, _react.useState)('');
|
|
222
|
-
const
|
|
223
|
-
|
|
227
|
+
const [filterStates, setFilterState] = _react.default.useState(null);
|
|
228
|
+
// const [filterData, setFilterData] = React.useState<any>(null)
|
|
224
229
|
|
|
230
|
+
const mergedData = _react.default.useMemo(() => {
|
|
225
231
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
226
232
|
return (0, _hooks.groupArrayByColumns)(dataSource, groupColumns);
|
|
227
233
|
}
|
|
228
234
|
return (0, _hooks.addRowIdArray)(dataSource);
|
|
229
235
|
}, [dataSource, groupAble, groupColumns, groupSetting]);
|
|
236
|
+
|
|
237
|
+
// ========================= Keys =========================
|
|
238
|
+
const [mergedFilterKeys, setMergedFilterKeys] = (0, _useMergedState.default)((0, _hooks.getAllRowKey)(mergedData), {
|
|
239
|
+
value: undefined
|
|
240
|
+
});
|
|
241
|
+
//
|
|
242
|
+
// const originData = React.useMemo(() => {
|
|
243
|
+
//
|
|
244
|
+
// if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
245
|
+
// return groupArrayByColumns(dataSource, groupColumns)
|
|
246
|
+
// }
|
|
247
|
+
// return addRowIdArray(dataSource)
|
|
248
|
+
//
|
|
249
|
+
// }, [dataSource, groupAble, groupColumns, groupSetting])
|
|
250
|
+
|
|
230
251
|
const [columns, setColumns] = _react.default.useState([]);
|
|
231
252
|
_react.default.useEffect(() => {
|
|
232
253
|
if (propsHeight) {
|
|
@@ -245,6 +266,20 @@ const InternalTable = props => {
|
|
|
245
266
|
_react.default.useEffect(() => {
|
|
246
267
|
setColumns(propsColumns);
|
|
247
268
|
}, [propsColumns]);
|
|
269
|
+
const handleOnFilter = queries => {
|
|
270
|
+
if (onFilter) {
|
|
271
|
+
onFilter?.((0, _hooks.convertFilters)(queries));
|
|
272
|
+
} else {
|
|
273
|
+
setFilterState((0, _hooks.convertFilters)(queries));
|
|
274
|
+
const b = (0, _hooks.filterDataByColumns4)(mergedData, (0, _hooks.convertFilters)(queries), []);
|
|
275
|
+
setMergedFilterKeys((0, _hooks.getAllRowKey)(b));
|
|
276
|
+
if (queries && queries.length > 0) {
|
|
277
|
+
// setIsFilter?.(true)
|
|
278
|
+
} else {
|
|
279
|
+
// setIsFilter?.(false)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
248
283
|
const handleResize = column => (e, {
|
|
249
284
|
size
|
|
250
285
|
}) => {
|
|
@@ -416,10 +451,11 @@ const InternalTable = props => {
|
|
|
416
451
|
})
|
|
417
452
|
}),
|
|
418
453
|
render: (val, record) => {
|
|
454
|
+
const tmpData = (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys);
|
|
419
455
|
if (pagination && pagination.onChange && pagination.currentPage && pagination.pageSize) {
|
|
420
|
-
return (0, _hooks.findItemPath)(
|
|
456
|
+
return (0, _hooks.findItemPath)(tmpData, record, rowKey, pagination.currentPage, pagination.pageSize);
|
|
421
457
|
}
|
|
422
|
-
return (0, _hooks.findItemPath)(
|
|
458
|
+
return (0, _hooks.findItemPath)(tmpData, record, rowKey);
|
|
423
459
|
}
|
|
424
460
|
};
|
|
425
461
|
}
|
|
@@ -515,28 +551,28 @@ const InternalTable = props => {
|
|
|
515
551
|
render: (value, record, rowIndex) => {
|
|
516
552
|
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
517
553
|
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
518
|
-
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
554
|
+
if (groupAble && groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
519
555
|
if (record.children) {
|
|
520
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
556
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
521
557
|
}
|
|
522
558
|
if (groupColumns?.includes(column.field)) {
|
|
523
559
|
return '';
|
|
524
560
|
}
|
|
525
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
561
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
526
562
|
}
|
|
527
|
-
if (column.field === firstNonGroupColumn?.field && record.children) {
|
|
563
|
+
if (groupAble && column.field === firstNonGroupColumn?.field && record.children) {
|
|
528
564
|
const currentGroupColumn = (0, _columns.flatColumns2)(columns).find(it => it.field === record.field);
|
|
529
565
|
if (currentGroupColumn?.template) {
|
|
530
|
-
return (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, cellFormat);
|
|
566
|
+
return (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat);
|
|
531
567
|
}
|
|
532
|
-
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, cellFormat));
|
|
568
|
+
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
533
569
|
}
|
|
534
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
570
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
535
571
|
},
|
|
536
572
|
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
|
|
537
573
|
};
|
|
538
574
|
});
|
|
539
|
-
}, [columns, t, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns,
|
|
575
|
+
}, [columns, t, id, wrapSettings, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
|
|
540
576
|
const transformColumns = _react.default.useCallback(cols => {
|
|
541
577
|
return cols.map(column => {
|
|
542
578
|
const find = convertColumns.find(it => it.field === column.field);
|
|
@@ -584,7 +620,7 @@ const InternalTable = props => {
|
|
|
584
620
|
};
|
|
585
621
|
}
|
|
586
622
|
});
|
|
587
|
-
}, [convertColumns, t]);
|
|
623
|
+
}, [convertColumns, id, t, wrapSettings]);
|
|
588
624
|
const mergedColumns = _react.default.useMemo(() => {
|
|
589
625
|
return transformColumns(columns);
|
|
590
626
|
}, [columns, transformColumns]);
|
|
@@ -602,9 +638,9 @@ const InternalTable = props => {
|
|
|
602
638
|
});
|
|
603
639
|
}
|
|
604
640
|
onChooseColumns?.({
|
|
605
|
-
showColumns: [],
|
|
606
|
-
columns: [],
|
|
607
|
-
flattenColumns: []
|
|
641
|
+
showColumns: (0, _hooks.removeInvisibleColumns)([...newColumns]),
|
|
642
|
+
columns: [...newColumns],
|
|
643
|
+
flattenColumns: (0, _hooks.convertFlatColumn)([...newColumns])
|
|
608
644
|
});
|
|
609
645
|
};
|
|
610
646
|
const onDragEnd = ({
|
|
@@ -683,7 +719,9 @@ const InternalTable = props => {
|
|
|
683
719
|
rowData,
|
|
684
720
|
index
|
|
685
721
|
} = args;
|
|
686
|
-
|
|
722
|
+
|
|
723
|
+
// const tmpData = [...mergedData]
|
|
724
|
+
const tmpData = (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys);
|
|
687
725
|
if (idCommand === 'DELETE') {
|
|
688
726
|
// bật modal confirm
|
|
689
727
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
@@ -709,7 +747,7 @@ const InternalTable = props => {
|
|
|
709
747
|
|
|
710
748
|
let newData = [];
|
|
711
749
|
if (rowData?.parentId) {
|
|
712
|
-
const parent = (0, _hooks.findItemByKey)(
|
|
750
|
+
const parent = (0, _hooks.findItemByKey)(tmpData, rowKey, rowData.parentId);
|
|
713
751
|
const childData = parent?.children ? [...parent.children] : [];
|
|
714
752
|
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
715
753
|
childData.splice(Number(findIndex), 1);
|
|
@@ -846,8 +884,13 @@ const InternalTable = props => {
|
|
|
846
884
|
t: t,
|
|
847
885
|
id: id,
|
|
848
886
|
locale: locale,
|
|
849
|
-
tableRef: tableRef
|
|
850
|
-
dataSource
|
|
887
|
+
tableRef: tableRef
|
|
888
|
+
// dataSource={mergedData}
|
|
889
|
+
,
|
|
890
|
+
originData: mergedData
|
|
891
|
+
// dataSource={filterStates && filterStates.length ? filterData : mergedData}
|
|
892
|
+
,
|
|
893
|
+
dataSource: (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys),
|
|
851
894
|
format: format,
|
|
852
895
|
columns: mergedColumns,
|
|
853
896
|
showSorterTooltip: {
|
|
@@ -887,14 +930,23 @@ const InternalTable = props => {
|
|
|
887
930
|
cell: TableBodyCell
|
|
888
931
|
}
|
|
889
932
|
},
|
|
890
|
-
setTooltipContent: setTooltipContent
|
|
933
|
+
setTooltipContent: setTooltipContent,
|
|
934
|
+
onFilter: val => {
|
|
935
|
+
handleOnFilter(val);
|
|
936
|
+
// triggerFilter?.(convertFilters(val))
|
|
937
|
+
// onFilter?.(convertFilters(val))
|
|
938
|
+
},
|
|
939
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
940
|
+
mergedFilterKeys: mergedFilterKeys,
|
|
941
|
+
wrapSettings: wrapSettings
|
|
891
942
|
})))), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, {
|
|
892
943
|
style: {
|
|
893
|
-
|
|
944
|
+
minWidth: 100,
|
|
945
|
+
width: columns[columns.findIndex(i => i.field === dragIndex.active)]?.width
|
|
894
946
|
}
|
|
895
947
|
}, /*#__PURE__*/_react.default.createElement("th", {
|
|
896
948
|
style: {
|
|
897
|
-
backgroundColor: '#
|
|
949
|
+
backgroundColor: '#f0f0f0',
|
|
898
950
|
padding: 6,
|
|
899
951
|
borderRadius: 6,
|
|
900
952
|
fontWeight: 500
|
|
@@ -28,87 +28,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
28
28
|
|
|
29
29
|
// import {ConfigProvider} from "antd";
|
|
30
30
|
|
|
31
|
-
const convertFilters = filters => {
|
|
32
|
-
const result = [];
|
|
33
|
-
filters.forEach(({
|
|
34
|
-
key,
|
|
35
|
-
column,
|
|
36
|
-
filteredKeys,
|
|
37
|
-
operator
|
|
38
|
-
}) => {
|
|
39
|
-
if (!filteredKeys || filteredKeys.length === 0) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
|
|
43
|
-
result.push({
|
|
44
|
-
key,
|
|
45
|
-
field: column?.dataIndex,
|
|
46
|
-
value: filteredKeys[0],
|
|
47
|
-
predicate: "and",
|
|
48
|
-
operator: "greaterthanorequal"
|
|
49
|
-
}, {
|
|
50
|
-
key,
|
|
51
|
-
field: column?.dataIndex,
|
|
52
|
-
value: filteredKeys[1],
|
|
53
|
-
predicate: "and",
|
|
54
|
-
operator: "lessthanorequal"
|
|
55
|
-
});
|
|
56
|
-
} else if (column?.typeFilter === "NumberRange") {
|
|
57
|
-
if ((filteredKeys[0] || filteredKeys[0] === 0) && !filteredKeys[1]) {
|
|
58
|
-
result.push({
|
|
59
|
-
key,
|
|
60
|
-
field: column?.dataIndex,
|
|
61
|
-
value: filteredKeys[0],
|
|
62
|
-
predicate: "and",
|
|
63
|
-
operator: "greaterthanorequal"
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if ((filteredKeys[1] || filteredKeys[1] === 0) && !filteredKeys[0]) {
|
|
67
|
-
result.push({
|
|
68
|
-
key,
|
|
69
|
-
field: column?.dataIndex,
|
|
70
|
-
value: filteredKeys[1],
|
|
71
|
-
predicate: "and",
|
|
72
|
-
operator: "lessthanorequal"
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if ((filteredKeys[0] || filteredKeys[0] === 0) && (filteredKeys[1] || filteredKeys[1] === 0)) {
|
|
76
|
-
result.push({
|
|
77
|
-
key,
|
|
78
|
-
field: column?.dataIndex,
|
|
79
|
-
value: filteredKeys[0],
|
|
80
|
-
predicate: "and",
|
|
81
|
-
operator: "greaterthanorequal"
|
|
82
|
-
}, {
|
|
83
|
-
key,
|
|
84
|
-
field: column?.dataIndex,
|
|
85
|
-
value: filteredKeys[1],
|
|
86
|
-
predicate: "and",
|
|
87
|
-
operator: "lessthanorequal"
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
} else if (column?.typeFilter === 'Checkbox') {
|
|
91
|
-
filteredKeys.forEach(value => {
|
|
92
|
-
result.push({
|
|
93
|
-
key,
|
|
94
|
-
field: column?.dataIndex,
|
|
95
|
-
value,
|
|
96
|
-
predicate: "or",
|
|
97
|
-
operator
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
} else {
|
|
101
|
-
result.push({
|
|
102
|
-
key,
|
|
103
|
-
field: column?.dataIndex,
|
|
104
|
-
value: filteredKeys[0],
|
|
105
|
-
predicate: 'and',
|
|
106
|
-
operator
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return result;
|
|
111
|
-
};
|
|
112
31
|
const useStyle = (0, _antdStyle.createStyles)(({
|
|
113
32
|
css
|
|
114
33
|
}) => {
|
|
@@ -154,7 +73,7 @@ const TableGrid = props => {
|
|
|
154
73
|
toolbarItems,
|
|
155
74
|
showColumnChoose,
|
|
156
75
|
showAdvanceFilter,
|
|
157
|
-
onFilter,
|
|
76
|
+
// onFilter,
|
|
158
77
|
triggerFilter,
|
|
159
78
|
selectionSettings,
|
|
160
79
|
rowSelection,
|
|
@@ -177,7 +96,7 @@ const TableGrid = props => {
|
|
|
177
96
|
groupColumns,
|
|
178
97
|
groupToolbar,
|
|
179
98
|
showEmptyText,
|
|
180
|
-
setIsFilter,
|
|
99
|
+
// setIsFilter,
|
|
181
100
|
actionTemplate,
|
|
182
101
|
...rest
|
|
183
102
|
} = props;
|
|
@@ -205,7 +124,8 @@ const TableGrid = props => {
|
|
|
205
124
|
viewportWidth,
|
|
206
125
|
viewportHeight
|
|
207
126
|
});
|
|
208
|
-
|
|
127
|
+
|
|
128
|
+
// const [filterStates, setFilterState] = React.useState<any>(null)
|
|
209
129
|
|
|
210
130
|
// const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
|
|
211
131
|
|
|
@@ -349,18 +269,22 @@ const TableGrid = props => {
|
|
|
349
269
|
const handleChange = sorter => {
|
|
350
270
|
onSorter?.(sorter);
|
|
351
271
|
};
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
272
|
+
|
|
273
|
+
// const handleOnFilter = (queries: any) => {
|
|
274
|
+
//
|
|
275
|
+
// if (onFilter) {
|
|
276
|
+
// onFilter?.(convertFilters(queries))
|
|
277
|
+
// } else {
|
|
278
|
+
// setFilterState(convertFilters(queries))
|
|
279
|
+
// if (queries && queries.length > 0) {
|
|
280
|
+
// // setIsFilter?.(true)
|
|
281
|
+
// } else {
|
|
282
|
+
// // setIsFilter?.(false)
|
|
283
|
+
// }
|
|
284
|
+
// }
|
|
285
|
+
//
|
|
286
|
+
// }
|
|
287
|
+
|
|
364
288
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
|
|
365
289
|
open: menuVisible,
|
|
366
290
|
pos: position,
|
|
@@ -385,8 +309,10 @@ const TableGrid = props => {
|
|
|
385
309
|
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
386
310
|
}
|
|
387
311
|
// dataSource={columns && columns.length > 0 ? filterDataByColumns3(dataSource, filterStates) : []}
|
|
312
|
+
|
|
313
|
+
// dataSource={columns && columns.length > 0 ? filterDataByColumns4(dataSource, filterStates) : []}
|
|
388
314
|
,
|
|
389
|
-
dataSource:
|
|
315
|
+
dataSource: dataSource,
|
|
390
316
|
className: (0, _classnames.default)(className, {
|
|
391
317
|
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
392
318
|
}, styles.customTable),
|
|
@@ -423,13 +349,15 @@ const TableGrid = props => {
|
|
|
423
349
|
// onScroll={(event) => {
|
|
424
350
|
// console.log('event', event)
|
|
425
351
|
// }}
|
|
352
|
+
|
|
353
|
+
// onFilter={(val: any) => {
|
|
354
|
+
// handleOnFilter(val)
|
|
355
|
+
// // triggerFilter?.(convertFilters(val))
|
|
356
|
+
// // onFilter?.(convertFilters(val))
|
|
357
|
+
//
|
|
358
|
+
// }}
|
|
426
359
|
,
|
|
427
360
|
|
|
428
|
-
onFilter: val => {
|
|
429
|
-
handleOnFilter(val);
|
|
430
|
-
// triggerFilter?.(convertFilters(val))
|
|
431
|
-
// onFilter?.(convertFilters(val))
|
|
432
|
-
},
|
|
433
361
|
onChange: (paging, filters, sorter) => handleChange(sorter),
|
|
434
362
|
title: showToolbar === false ? undefined : () => {
|
|
435
363
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, title?.(dataSource)), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -499,9 +427,12 @@ const TableGrid = props => {
|
|
|
499
427
|
|
|
500
428
|
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
501
429
|
const dec = cellFormat?.decimalScale;
|
|
502
|
-
|
|
430
|
+
|
|
431
|
+
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
432
|
+
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)((0, _hooks.filterDataByColumns4)(dataSource, [], []), col?.field) : 0;
|
|
503
433
|
const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
504
434
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
435
|
+
const numberValue = Number(value);
|
|
505
436
|
const numericFormatProps = {
|
|
506
437
|
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
507
438
|
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -516,7 +447,7 @@ const TableGrid = props => {
|
|
|
516
447
|
index: index,
|
|
517
448
|
align: col.align ?? 'right',
|
|
518
449
|
className: 'ui-rc-table-cell-ellipsis'
|
|
519
|
-
}, col.summaryTemplate ? col.summaryTemplate(
|
|
450
|
+
}, col.summaryTemplate ? col.summaryTemplate(numberValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
520
451
|
})));
|
|
521
452
|
},
|
|
522
453
|
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
@@ -536,7 +467,8 @@ const TableGrid = props => {
|
|
|
536
467
|
}, pagination)), bottomToolbar?.(), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
537
468
|
id: `${id}-tooltip-header`,
|
|
538
469
|
style: {
|
|
539
|
-
zIndex: 1999
|
|
470
|
+
zIndex: 1999,
|
|
471
|
+
maxWidth: 350
|
|
540
472
|
}
|
|
541
473
|
}));
|
|
542
474
|
};
|