es-grid-template 1.5.0 → 1.5.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/es/grid-component/ColumnsChoose.js +1 -1
- package/es/grid-component/EditableCell.js +14 -12
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +15 -4
- package/es/grid-component/TableGrid.js +1 -1
- package/es/grid-component/async-select/index.d.ts +4 -2
- package/es/grid-component/async-select/index.js +3 -0
- package/es/grid-component/async-table-select/index.d.ts +4 -2
- package/es/grid-component/async-table-select/index.js +4 -1
- package/es/grid-component/hooks/columns/index.d.ts +1 -1
- package/es/grid-component/hooks/columns/index.js +19 -31
- package/es/grid-component/hooks/utils.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +85 -2
- package/es/grid-component/styles.scss +4 -0
- package/es/grid-component/table/GridEdit.js +93 -76
- package/es/grid-component/table/Group.js +11 -1
- package/es/grid-component/type.d.ts +9 -0
- package/es/grid-component/useContext.d.ts +1 -0
- package/es/grid-component/useContext.js +2 -1
- package/lib/grid-component/ColumnsChoose.js +1 -1
- package/lib/grid-component/EditableCell.js +14 -12
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +14 -3
- package/lib/grid-component/TableGrid.js +1 -1
- package/lib/grid-component/async-select/index.d.ts +4 -2
- package/lib/grid-component/async-select/index.js +3 -0
- package/lib/grid-component/async-table-select/index.d.ts +4 -2
- package/lib/grid-component/async-table-select/index.js +4 -1
- package/lib/grid-component/hooks/columns/index.d.ts +1 -1
- package/lib/grid-component/hooks/columns/index.js +17 -29
- package/lib/grid-component/hooks/utils.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +96 -7
- package/lib/grid-component/styles.scss +4 -0
- package/lib/grid-component/table/GridEdit.js +93 -76
- package/lib/grid-component/table/Group.js +11 -1
- package/lib/grid-component/type.d.ts +9 -0
- package/lib/grid-component/useContext.d.ts +1 -0
- package/lib/grid-component/useContext.js +2 -1
- package/package.json +110 -110
|
@@ -489,7 +489,7 @@ export const ColumnsChoose = props => {
|
|
|
489
489
|
autoExpandParent: autoExpandParent
|
|
490
490
|
// treeData={treeData}
|
|
491
491
|
,
|
|
492
|
-
treeData: columns,
|
|
492
|
+
treeData: columns.filter(it => !columnsGroup?.includes(it.field)),
|
|
493
493
|
defaultExpandAll: true,
|
|
494
494
|
checkable: true
|
|
495
495
|
// onSelect={(keys, info) => {
|
|
@@ -61,7 +61,8 @@ const EditableCell = props => {
|
|
|
61
61
|
getValues,
|
|
62
62
|
handleCellChange,
|
|
63
63
|
getRowKey,
|
|
64
|
-
errors
|
|
64
|
+
errors,
|
|
65
|
+
id
|
|
65
66
|
} = useContext(TableContext);
|
|
66
67
|
const datePickerRef = React.useRef(null);
|
|
67
68
|
const dateTimePickerRef = React.useRef(null);
|
|
@@ -160,7 +161,7 @@ const EditableCell = props => {
|
|
|
160
161
|
popupClassName: 'be-popup-container',
|
|
161
162
|
status: isInvalid ? 'error' : undefined,
|
|
162
163
|
"data-tooltip-content": message,
|
|
163
|
-
"data-tooltip-id":
|
|
164
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
164
165
|
});
|
|
165
166
|
case 'datetime':
|
|
166
167
|
return /*#__PURE__*/React.createElement(DatePicker
|
|
@@ -216,7 +217,7 @@ const EditableCell = props => {
|
|
|
216
217
|
popupClassName: 'be-popup-container',
|
|
217
218
|
status: isInvalid ? 'error' : undefined,
|
|
218
219
|
"data-tooltip-content": message,
|
|
219
|
-
"data-tooltip-id":
|
|
220
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
220
221
|
});
|
|
221
222
|
case 'month':
|
|
222
223
|
case 'quarter':
|
|
@@ -242,7 +243,7 @@ const EditableCell = props => {
|
|
|
242
243
|
popupClassName: 'be-popup-container',
|
|
243
244
|
status: isInvalid ? 'error' : undefined,
|
|
244
245
|
"data-tooltip-content": message,
|
|
245
|
-
"data-tooltip-id":
|
|
246
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
246
247
|
});
|
|
247
248
|
case 'week':
|
|
248
249
|
const weekFormat = getDatepickerFormat(editType, cellFormat);
|
|
@@ -262,7 +263,7 @@ const EditableCell = props => {
|
|
|
262
263
|
popupClassName: 'be-popup-container',
|
|
263
264
|
status: isInvalid ? 'error' : undefined,
|
|
264
265
|
"data-tooltip-content": message,
|
|
265
|
-
"data-tooltip-id":
|
|
266
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
266
267
|
});
|
|
267
268
|
case 'time':
|
|
268
269
|
const timeFormat = getDatepickerFormat(editType, cellFormat);
|
|
@@ -289,7 +290,7 @@ const EditableCell = props => {
|
|
|
289
290
|
popupClassName: 'be-popup-container',
|
|
290
291
|
status: isInvalid ? 'error' : undefined,
|
|
291
292
|
"data-tooltip-content": message,
|
|
292
|
-
"data-tooltip-id":
|
|
293
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
293
294
|
});
|
|
294
295
|
case 'selectTable':
|
|
295
296
|
const rr = selectColumns ?? [];
|
|
@@ -327,6 +328,7 @@ const EditableCell = props => {
|
|
|
327
328
|
options: options,
|
|
328
329
|
defaultOptions: options,
|
|
329
330
|
value: valueSelectTable,
|
|
331
|
+
rowData: record,
|
|
330
332
|
onChange: (val, option) => {
|
|
331
333
|
onChange(val ?? '');
|
|
332
334
|
const formState = getValues();
|
|
@@ -396,7 +398,7 @@ const EditableCell = props => {
|
|
|
396
398
|
label: inputKey ?? 'label'
|
|
397
399
|
},
|
|
398
400
|
"data-tooltip-content": message,
|
|
399
|
-
"data-tooltip-id":
|
|
401
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
400
402
|
});
|
|
401
403
|
case 'select':
|
|
402
404
|
let valueSelect = value;
|
|
@@ -454,7 +456,7 @@ const EditableCell = props => {
|
|
|
454
456
|
label: inputKey ?? 'label'
|
|
455
457
|
},
|
|
456
458
|
"data-tooltip-content": message,
|
|
457
|
-
"data-tooltip-id":
|
|
459
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
458
460
|
});
|
|
459
461
|
case 'asyncSelect':
|
|
460
462
|
let valueAsyncSelect = value;
|
|
@@ -551,7 +553,7 @@ const EditableCell = props => {
|
|
|
551
553
|
label: inputKey ?? 'label'
|
|
552
554
|
},
|
|
553
555
|
"data-tooltip-content": message,
|
|
554
|
-
"data-tooltip-id":
|
|
556
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
555
557
|
});
|
|
556
558
|
case 'treeSelect':
|
|
557
559
|
// let valueTreeSelect
|
|
@@ -624,7 +626,7 @@ const EditableCell = props => {
|
|
|
624
626
|
popupClassName: 'be-popup-container',
|
|
625
627
|
status: isInvalid ? 'error' : undefined,
|
|
626
628
|
"data-tooltip-content": message,
|
|
627
|
-
"data-tooltip-id":
|
|
629
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
628
630
|
});
|
|
629
631
|
case 'checkbox':
|
|
630
632
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -847,7 +849,7 @@ const EditableCell = props => {
|
|
|
847
849
|
}
|
|
848
850
|
},
|
|
849
851
|
"data-tooltip-content": message,
|
|
850
|
-
"data-tooltip-id":
|
|
852
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
851
853
|
}));
|
|
852
854
|
default:
|
|
853
855
|
return /*#__PURE__*/React.createElement(Input, {
|
|
@@ -910,7 +912,7 @@ const EditableCell = props => {
|
|
|
910
912
|
onChange: onChange,
|
|
911
913
|
status: isInvalid ? 'error' : undefined,
|
|
912
914
|
"data-tooltip-content": message,
|
|
913
|
-
"data-tooltip-id":
|
|
915
|
+
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
914
916
|
});
|
|
915
917
|
}
|
|
916
918
|
};
|
|
@@ -2,4 +2,4 @@ import styled from "styled-components";
|
|
|
2
2
|
export const GridStyle = styled.div.withConfig({
|
|
3
3
|
displayName: "GridStyle",
|
|
4
4
|
componentId: "es-grid-template__sc-sueu2e-0"
|
|
5
|
-
})(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{&:has(.ui-rc-table-tbody-virtual-scrollbar-horizontal){padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined);
|
|
5
|
+
})(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{&:has(.ui-rc-table-tbody-virtual-scrollbar-horizontal){padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}.ui-rc-table-body{&:has(.ui-rc-table-placeholder){height:", ";}table{height:100%;.ui-rc-table-placeholder{vertical-align:top;}}}.ui-rc-table-placeholder{}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll - 1}px` : undefined);
|
|
@@ -3,7 +3,7 @@ import React, { createContext, Fragment, useCallback, useContext, useState } fro
|
|
|
3
3
|
// import {Resizable} from "react-resizable";
|
|
4
4
|
import 'react-resizable/css/styles.css';
|
|
5
5
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
6
|
-
import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
6
|
+
import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
8
|
import 'dayjs/locale/es';
|
|
9
9
|
import 'dayjs/locale/vi';
|
|
@@ -11,9 +11,13 @@ import GridEdit from "./table/GridEdit";
|
|
|
11
11
|
import Grid from "./table/Grid";
|
|
12
12
|
import en from "rc-master-ui/es/date-picker/locale/en_US";
|
|
13
13
|
import vi from "rc-master-ui/es/date-picker/locale/vi_VN";
|
|
14
|
+
import enDr from "rc-master-ui/es/locales/en_US";
|
|
15
|
+
import viDr from "rc-master-ui/es/locales/vi_VN";
|
|
14
16
|
// import useColumns from "./hooks/useColumns";
|
|
15
17
|
|
|
16
18
|
import "./styles.scss";
|
|
19
|
+
// import 'rc-master-ui/assets/index.css'
|
|
20
|
+
|
|
17
21
|
import { flatColumns2, renderContent, renderFilter } from "./hooks/columns";
|
|
18
22
|
import Group from "./table/Group";
|
|
19
23
|
import Swal from "sweetalert2";
|
|
@@ -202,6 +206,7 @@ const InternalTable = props => {
|
|
|
202
206
|
// }, [height, id])
|
|
203
207
|
|
|
204
208
|
const local = lang && lang === 'en' ? en : vi;
|
|
209
|
+
const dateRangeLocale = lang && lang === 'en' ? enDr : viDr;
|
|
205
210
|
const buddhistLocale = {
|
|
206
211
|
...local,
|
|
207
212
|
lang: {
|
|
@@ -219,8 +224,13 @@ const InternalTable = props => {
|
|
|
219
224
|
});
|
|
220
225
|
const [tooltipContent, setTooltipContent] = useState('');
|
|
221
226
|
const mergedData = React.useMemo(() => {
|
|
227
|
+
// return addRowIdArray(dataSource)
|
|
228
|
+
|
|
229
|
+
if (groupSetting && groupSetting.client !== false) {
|
|
230
|
+
return groupArrayByColumns(dataSource, groupColumns);
|
|
231
|
+
}
|
|
222
232
|
return addRowIdArray(dataSource);
|
|
223
|
-
}, [dataSource]);
|
|
233
|
+
}, [dataSource, groupColumns, groupSetting]);
|
|
224
234
|
const [columns, setColumns] = React.useState([]);
|
|
225
235
|
React.useEffect(() => {
|
|
226
236
|
if (propsHeight) {
|
|
@@ -319,7 +329,7 @@ const InternalTable = props => {
|
|
|
319
329
|
style: {
|
|
320
330
|
marginBottom: 8
|
|
321
331
|
}
|
|
322
|
-
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, propDataSourceFilter ?? [], buddhistLocale, locale, t)), /*#__PURE__*/React.createElement(Space, {
|
|
332
|
+
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, propDataSourceFilter ?? [], buddhistLocale, locale, t, format, dateRangeLocale)), /*#__PURE__*/React.createElement(Space, {
|
|
323
333
|
style: {
|
|
324
334
|
justifyContent: 'end',
|
|
325
335
|
width: '100%'
|
|
@@ -491,7 +501,8 @@ const InternalTable = props => {
|
|
|
491
501
|
'cell-group': groupColumns && data.children,
|
|
492
502
|
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
493
503
|
}),
|
|
494
|
-
'data-tooltip-id': "tooltip-cell-content"
|
|
504
|
+
// 'data-tooltip-id': "tooltip-cell-content"
|
|
505
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`
|
|
495
506
|
};
|
|
496
507
|
},
|
|
497
508
|
render: (value, record, rowIndex) => {
|
|
@@ -485,7 +485,7 @@ const TableGrid = props => {
|
|
|
485
485
|
|
|
486
486
|
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
487
487
|
const dec = cellFormat?.decimalScale;
|
|
488
|
-
const sumValue = col.type === 'number' ? sumDataByField(dataSource, col?.key) : 0;
|
|
488
|
+
const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates), col?.key) : 0;
|
|
489
489
|
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
490
490
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
491
491
|
const numericFormatProps = {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -6,6 +6,7 @@ export function AsyncSelect({
|
|
|
6
6
|
loadOptions,
|
|
7
7
|
debounceTimeout = 500,
|
|
8
8
|
defaultOptions,
|
|
9
|
+
rowData,
|
|
9
10
|
...props
|
|
10
11
|
}) {
|
|
11
12
|
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
@@ -18,6 +19,8 @@ export function AsyncSelect({
|
|
|
18
19
|
if (loadOptions) {
|
|
19
20
|
loadOptions(value, newOptions => {
|
|
20
21
|
setOptions(newOptions);
|
|
22
|
+
}, {
|
|
23
|
+
rowData
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
3
|
import type { TableSelectProps } from "rc-master-ui/es/table-select";
|
|
4
|
+
import type { LoadOptionsArgs } from "../type";
|
|
4
5
|
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
5
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
6
7
|
debounceTimeout?: number;
|
|
7
8
|
defaultOptions?: OptionType[];
|
|
9
|
+
rowData?: any;
|
|
8
10
|
}
|
|
9
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
11
|
+
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -7,6 +7,7 @@ export function AsyncTableSelect({
|
|
|
7
7
|
debounceTimeout = 500,
|
|
8
8
|
defaultOptions,
|
|
9
9
|
columns,
|
|
10
|
+
rowData,
|
|
10
11
|
...props
|
|
11
12
|
}) {
|
|
12
13
|
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
@@ -19,11 +20,13 @@ export function AsyncTableSelect({
|
|
|
19
20
|
if (loadOptions) {
|
|
20
21
|
loadOptions(value, newOptions => {
|
|
21
22
|
setOptions(newOptions);
|
|
23
|
+
}, {
|
|
24
|
+
rowData
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
};
|
|
25
28
|
return debounce(fetchOptions, debounceTimeout);
|
|
26
|
-
}, [loadOptions,
|
|
29
|
+
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
27
30
|
useEffect(() => {
|
|
28
31
|
setOptions(defaultOptions ?? []);
|
|
29
32
|
}, [defaultOptions]);
|
|
@@ -6,4 +6,4 @@ export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType
|
|
|
6
6
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
7
7
|
export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, format?: IFormat) => any;
|
|
8
8
|
export declare const renderContent: <T>(column: ColumnTable<T>, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
|
|
9
|
-
export declare const renderFilter: <RecordType>(column: ColumnTable<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any, format?: IFormat) => React.JSX.Element;
|
|
9
|
+
export declare const renderFilter: <RecordType>(column: ColumnTable<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any, format?: IFormat, dateRangeLocale?: any) => React.JSX.Element;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, getDatepickerFormat, getDateString, getTypeFilter, isColor, isEmpty } from "../utils";
|
|
1
|
+
import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, convertFormat, getDatepickerFormat, getDateString, getTypeFilter, isColor, isEmpty } from "../utils";
|
|
2
2
|
import { numericFormatter } from "react-numeric-component";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
4
|
import moment from "moment/moment";
|
|
5
5
|
import React, { Fragment } from "react";
|
|
6
|
-
import { DatePicker, Empty, Input, Select } from "rc-master-ui";
|
|
6
|
+
import { CustomProvider, DatePicker, DateRangePicker, 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
9
|
import NumberRange from "../../number-range";
|
|
10
10
|
import NumberInput from "../../number";
|
|
11
11
|
// import {Typography} from "antd";
|
|
12
|
-
const {
|
|
13
|
-
RangePicker
|
|
14
|
-
} = DatePicker;
|
|
12
|
+
// const {RangePicker} = DatePicker
|
|
15
13
|
|
|
16
14
|
// const { Text } = Typography;
|
|
17
15
|
|
|
@@ -125,11 +123,11 @@ export const renderContent = (column, value, record, index, format) => {
|
|
|
125
123
|
field: column.field
|
|
126
124
|
}) : column.template : content);
|
|
127
125
|
};
|
|
128
|
-
export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t, format) => {
|
|
126
|
+
export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t, format, dateRangeLocale) => {
|
|
129
127
|
const cellFormat = column.format ? typeof column.format === 'function' ? column.format({}) : column.format : format;
|
|
130
128
|
const type = getTypeFilter(column);
|
|
131
129
|
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, cellFormat) ?? 'DD/MM/YYYY';
|
|
132
|
-
const dateRangeFormat = getDatepickerFormat(column?.type, cellFormat) ?? 'DD/MM/YYYY';
|
|
130
|
+
const dateRangeFormat = convertFormat(getDatepickerFormat(column?.type, cellFormat) ?? 'DD/MM/YYYY');
|
|
133
131
|
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
134
132
|
const options = find ? find.data : [];
|
|
135
133
|
switch (type) {
|
|
@@ -176,35 +174,25 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
176
174
|
}
|
|
177
175
|
}))));
|
|
178
176
|
case 'DateRange':
|
|
179
|
-
const dateRangeValue = [selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateRangeFormat) : '', selectedKeys[1] ? convertDateToDayjs(new Date(selectedKeys[1]), dateRangeFormat) : '']
|
|
177
|
+
// const dateRangeValue: any = [selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateRangeFormat) : '', selectedKeys[1] ? convertDateToDayjs(new Date(selectedKeys[1]), dateRangeFormat) : '']
|
|
178
|
+
const dateRangeValue = selectedKeys && selectedKeys.length > 0 ? [selectedKeys[0] ? new Date(selectedKeys[0]) : '', selectedKeys[1] ? new Date(selectedKeys[1]) : ''] : null;
|
|
180
179
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
181
180
|
className: 'mb-1'
|
|
182
|
-
}, /*#__PURE__*/React.createElement(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
value: dateRangeValue,
|
|
190
|
-
locale: buddhistLocale
|
|
191
|
-
// placeholder={['Ngày bắt đầu', 'Ngày kết thúc']}
|
|
192
|
-
,
|
|
193
|
-
popupStyle: {
|
|
194
|
-
zIndex: 9999
|
|
181
|
+
}, /*#__PURE__*/React.createElement(CustomProvider, {
|
|
182
|
+
locale: dateRangeLocale
|
|
183
|
+
}, /*#__PURE__*/React.createElement(DateRangePicker
|
|
184
|
+
// placeholder={['Ngày bắt đầu', 'Ngày bắt đầu']}
|
|
185
|
+
, {
|
|
186
|
+
style: {
|
|
187
|
+
width: 300
|
|
195
188
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
format: dateRangeFormat,
|
|
190
|
+
value: dateRangeValue,
|
|
191
|
+
onChange: value => {
|
|
192
|
+
const newDateRangeValue = value ? [value[0] ? moment(value[0]).format() : '', value[1] ? moment(value[1]).format() : ''] : [];
|
|
200
193
|
setSelectedKeys(newDateRangeValue);
|
|
201
|
-
},
|
|
202
|
-
style: {
|
|
203
|
-
width: '100%'
|
|
204
194
|
}
|
|
205
|
-
|
|
206
|
-
// getPopupContainer={() => menuRef.current}
|
|
207
|
-
}))));
|
|
195
|
+
})))));
|
|
208
196
|
case 'Week':
|
|
209
197
|
const weekValue = !isEmpty(selectedKeys[0]) ? dayjs(selectedKeys[0], dateFormat) : null;
|
|
210
198
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -36,7 +36,9 @@ export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
|
|
|
36
36
|
monthFormat: string;
|
|
37
37
|
yearFormat: string;
|
|
38
38
|
};
|
|
39
|
+
export declare function convertFormat(formatStr: string): string;
|
|
39
40
|
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
41
|
+
export declare const getDateRangeFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
40
42
|
export declare const customWeekStartEndFormat: (value: any, weekFormat: string) => string;
|
|
41
43
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
42
44
|
export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
|
|
@@ -141,3 +143,4 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
|
141
143
|
export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
142
144
|
export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
|
|
143
145
|
export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
|
|
146
|
+
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
@@ -190,12 +190,56 @@ export const getFormat = (colFormat, format) => {
|
|
|
190
190
|
yearFormat: colFormat?.yearFormat ?? format?.yearFormat
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
export function convertFormat(formatStr) {
|
|
194
|
+
// return formatStr.split('').map((char, i) => {
|
|
195
|
+
// if (char === 'D' || char === 'd') {
|
|
196
|
+
// return 'd'; // ngày: lowercase
|
|
197
|
+
// }
|
|
198
|
+
// if (char === 'Y' || char === 'y') {
|
|
199
|
+
// return 'y'; // năm: lowercase
|
|
200
|
+
// }
|
|
201
|
+
// if (char === 'M' || char === 'm') {
|
|
202
|
+
// return char; // tháng: giữ nguyên
|
|
203
|
+
// }
|
|
204
|
+
// return char; // separator
|
|
205
|
+
// }).join('');
|
|
206
|
+
|
|
207
|
+
return formatStr.split('').map(char => {
|
|
208
|
+
if (char === 'D' || char === 'd') return 'd';
|
|
209
|
+
if (char === 'Y' || char === 'y') return 'y';
|
|
210
|
+
if ('Hhmsa'.includes(char)) return char; // giờ, phút, giây, am/pm
|
|
211
|
+
if (char === 'M' || char === 'm') return char; // tháng: giữ nguyên
|
|
212
|
+
return char; // dấu phân cách
|
|
213
|
+
}).join('');
|
|
214
|
+
}
|
|
193
215
|
export const getDatepickerFormat = (type, format) => {
|
|
194
216
|
const typeFormat = type ? type.toLowerCase() : '';
|
|
195
217
|
switch (typeFormat) {
|
|
196
218
|
case "date":
|
|
197
219
|
case "daterange":
|
|
198
|
-
return format?.dateFormat ?? '
|
|
220
|
+
return format?.dateFormat ?? 'dd/MM/YYYY';
|
|
221
|
+
case "datetime":
|
|
222
|
+
return format?.datetimeFormat ?? 'dd/MM/YYYY HH:mm';
|
|
223
|
+
case "week":
|
|
224
|
+
return format?.weekFormat ?? 'dd/MM';
|
|
225
|
+
case "month":
|
|
226
|
+
return format?.monthFormat ?? 'MM/YYYY';
|
|
227
|
+
case "quarter":
|
|
228
|
+
return format?.dateFormat ?? 'dd/MM/YYYY';
|
|
229
|
+
case "year":
|
|
230
|
+
return format?.yearFormat ?? 'YYYY';
|
|
231
|
+
case "time":
|
|
232
|
+
return format?.timeFormat ?? 'HH:mm';
|
|
233
|
+
default:
|
|
234
|
+
return 'dd/MM/YYYY';
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export const getDateRangeFormat = (type, format) => {
|
|
238
|
+
const typeFormat = type ? type.toLowerCase() : '';
|
|
239
|
+
switch (typeFormat) {
|
|
240
|
+
case "date":
|
|
241
|
+
case "daterange":
|
|
242
|
+
return convertFormat(format?.dateFormat ?? 'DD/MM/YYYY');
|
|
199
243
|
case "datetime":
|
|
200
244
|
return format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm';
|
|
201
245
|
case "week":
|
|
@@ -1985,4 +2029,43 @@ export const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
|
|
|
1985
2029
|
}
|
|
1986
2030
|
const key = `${rowIndex}-${colIndex}`;
|
|
1987
2031
|
return selectedCells.has(key);
|
|
1988
|
-
};
|
|
2032
|
+
};
|
|
2033
|
+
export function groupArrayByColumns(arr, columns) {
|
|
2034
|
+
const result = [];
|
|
2035
|
+
if (columns) {
|
|
2036
|
+
arr.forEach(item => {
|
|
2037
|
+
let currentLevel = result;
|
|
2038
|
+
columns.forEach((column, index) => {
|
|
2039
|
+
const value = item[column];
|
|
2040
|
+
const existingItem = currentLevel.find(i => i[column] === value);
|
|
2041
|
+
if (existingItem) {
|
|
2042
|
+
currentLevel = existingItem.children;
|
|
2043
|
+
} else {
|
|
2044
|
+
// const newItem = {[column]: value, field: column, rowId: !isEmpty(value) ? (value) : newGuid(), parentId: !isEmpty(item[columns[index - 1]]) ? (item[columns[index - 1]]) : null, indent: index, children: [] }
|
|
2045
|
+
const newItem = {
|
|
2046
|
+
[column]: value,
|
|
2047
|
+
field: column,
|
|
2048
|
+
rowId: newGuid(),
|
|
2049
|
+
// rowId: item[column],
|
|
2050
|
+
parentId: !isEmpty(item[columns[index - 1]]) ? item[columns[index - 1]] : null,
|
|
2051
|
+
// parentId: item.rowId[index - 1],
|
|
2052
|
+
// indent: index,
|
|
2053
|
+
children: []
|
|
2054
|
+
};
|
|
2055
|
+
currentLevel.push(newItem);
|
|
2056
|
+
currentLevel = newItem.children;
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
currentLevel.push({
|
|
2060
|
+
...item,
|
|
2061
|
+
rowId: item.id ?? item.rowId,
|
|
2062
|
+
parentId: !isEmpty(columns[columns.length - 1]) ? item[columns[columns.length - 1]] : null,
|
|
2063
|
+
// parentId: item.rowId[columns.length - 1],
|
|
2064
|
+
indent: columns.length
|
|
2065
|
+
});
|
|
2066
|
+
});
|
|
2067
|
+
return result;
|
|
2068
|
+
} else {
|
|
2069
|
+
return arr;
|
|
2070
|
+
}
|
|
2071
|
+
}
|