es-grid-template 1.3.6 → 1.3.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/assets/index.css +35 -24
- package/assets/index.scss +57 -21
- package/es/grid-component/EditableCell.js +12 -11
- package/es/grid-component/GridStyle.d.ts +5 -3
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/TableGrid.js +28 -21
- package/es/grid-component/hooks/columns/index.d.ts +1 -1
- package/es/grid-component/hooks/columns/index.js +15 -14
- package/es/grid-component/hooks/useColumns.js +12 -9
- package/es/grid-component/hooks/utils.d.ts +19 -4
- package/es/grid-component/hooks/utils.js +377 -26
- package/es/grid-component/styles.scss +57 -21
- package/es/grid-component/table/Grid.js +1 -1
- package/es/grid-component/table/GridEdit.js +383 -268
- package/es/grid-component/table/Group.js +1 -1
- package/es/grid-component/type.d.ts +4 -4
- package/lib/grid-component/EditableCell.js +12 -11
- package/lib/grid-component/GridStyle.d.ts +5 -3
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/TableGrid.js +26 -20
- package/lib/grid-component/hooks/columns/index.d.ts +1 -1
- package/lib/grid-component/hooks/columns/index.js +15 -14
- package/lib/grid-component/hooks/useColumns.js +12 -9
- package/lib/grid-component/hooks/utils.d.ts +19 -4
- package/lib/grid-component/hooks/utils.js +401 -33
- package/lib/grid-component/styles.scss +57 -21
- package/lib/grid-component/table/Grid.js +1 -1
- package/lib/grid-component/table/GridEdit.js +382 -259
- package/lib/grid-component/table/Group.js +1 -1
- package/lib/grid-component/type.d.ts +4 -4
- package/package.json +2 -2
package/assets/index.css
CHANGED
|
@@ -49,6 +49,15 @@
|
|
|
49
49
|
.ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell {
|
|
50
50
|
line-height: 22px;
|
|
51
51
|
}
|
|
52
|
+
.ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell:focus-visible {
|
|
53
|
+
outline: none;
|
|
54
|
+
}
|
|
55
|
+
.ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell.disable {
|
|
56
|
+
background-color: #f0f0f0;
|
|
57
|
+
}
|
|
58
|
+
.ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell.selected {
|
|
59
|
+
background-color: #F3F8FF !important;
|
|
60
|
+
}
|
|
52
61
|
.ui-rc-table-wrapper .ui-rc-table-tbody .ui-rc-table-cell .ui-rc-table-cell-content {
|
|
53
62
|
line-height: 22px;
|
|
54
63
|
}
|
|
@@ -207,26 +216,34 @@
|
|
|
207
216
|
top: 8px;
|
|
208
217
|
left: 8px;
|
|
209
218
|
}
|
|
219
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.rc-ui-cell-index.focus {
|
|
220
|
+
background-color: #E6EFFD;
|
|
221
|
+
font-weight: 500;
|
|
222
|
+
}
|
|
223
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.rc-ui-cell-index.selected {
|
|
224
|
+
background-color: #1869E6 !important;
|
|
225
|
+
color: #fff;
|
|
226
|
+
}
|
|
210
227
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-top {
|
|
211
228
|
border-bottom: 1px solid #0550C5;
|
|
212
229
|
}
|
|
213
230
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-bottom {
|
|
214
231
|
border-bottom: 1px solid #0550C5;
|
|
215
232
|
}
|
|
216
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-bottom {
|
|
217
|
-
border-bottom: 1px dashed #949494;
|
|
218
|
-
}
|
|
219
233
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-left {
|
|
220
234
|
border-inline-end: 1px solid #0550C5;
|
|
221
235
|
}
|
|
222
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-
|
|
223
|
-
border-inline-end: 1px
|
|
236
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-right {
|
|
237
|
+
border-inline-end: 1px solid #0550C5;
|
|
224
238
|
}
|
|
225
239
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-top {
|
|
226
|
-
border-bottom: 1px dashed #949494
|
|
240
|
+
border-bottom: 1px dashed #949494;
|
|
227
241
|
}
|
|
228
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-border-
|
|
229
|
-
border-
|
|
242
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-bottom {
|
|
243
|
+
border-bottom: 1px dashed #949494;
|
|
244
|
+
}
|
|
245
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-left {
|
|
246
|
+
border-inline-end: 1px dashed #949494;
|
|
230
247
|
}
|
|
231
248
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.cell-paste-border-right {
|
|
232
249
|
border-inline-end: 1px dashed #949494;
|
|
@@ -286,8 +303,11 @@
|
|
|
286
303
|
height: 10px;
|
|
287
304
|
position: absolute;
|
|
288
305
|
cursor: crosshair;
|
|
289
|
-
right:
|
|
290
|
-
bottom:
|
|
306
|
+
right: -1px;
|
|
307
|
+
bottom: -1px;
|
|
308
|
+
}
|
|
309
|
+
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content .dragging-point.hidden {
|
|
310
|
+
display: none;
|
|
291
311
|
}
|
|
292
312
|
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content .dragging-point .dot-point {
|
|
293
313
|
position: absolute;
|
|
@@ -295,28 +315,19 @@
|
|
|
295
315
|
height: 8px;
|
|
296
316
|
border-radius: 6px;
|
|
297
317
|
background-color: #0550C5;
|
|
298
|
-
bottom: -
|
|
299
|
-
right: -
|
|
318
|
+
bottom: -3px;
|
|
319
|
+
right: -3px;
|
|
300
320
|
}
|
|
301
321
|
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content.selected {
|
|
302
|
-
background-color: #
|
|
303
|
-
}
|
|
304
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content.disable {
|
|
305
|
-
background-color: #f0f0f0;
|
|
322
|
+
background-color: #F3F8FF;
|
|
306
323
|
}
|
|
307
324
|
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content--index.focus {
|
|
308
|
-
background-color: #
|
|
325
|
+
background-color: #E6EFFD;
|
|
309
326
|
}
|
|
310
327
|
.ui-rc-table-wrapper.grid-editable .ui-rc_cell-content--index.selected {
|
|
311
|
-
background-color: #
|
|
328
|
+
background-color: #1869E6;
|
|
312
329
|
color: #fff;
|
|
313
330
|
}
|
|
314
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row.ui-rc-table-row-selected > .ui-rc-table-cell {
|
|
315
|
-
background: #FEF2EF;
|
|
316
|
-
}
|
|
317
|
-
.ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row > .ui-rc-table-cell.ui-rc-table-cell-row-hover {
|
|
318
|
-
background: #FBDED6;
|
|
319
|
-
}
|
|
320
331
|
.ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell .ui-rc-table-row-indent {
|
|
321
332
|
position: absolute;
|
|
322
333
|
}
|
package/assets/index.scss
CHANGED
|
@@ -5,13 +5,17 @@ $rowHoverBg: #FBDED6 !default;
|
|
|
5
5
|
$rowSelectedBg: #FEF2EF !default;
|
|
6
6
|
//$tableBorderColor: red !default;
|
|
7
7
|
$tableBorderColor: #e0e0e0 !default;
|
|
8
|
+
//$tableBorderColor: #C4C4C4 !default;
|
|
8
9
|
//$tableBorderColor: #f0f0f0 !default;
|
|
9
10
|
$border-radius: 6px !default;
|
|
10
11
|
$border-selected-color: #0550C5 !default;
|
|
11
12
|
$body-color: #ffffff !default;
|
|
12
|
-
|
|
13
|
-
$cell-
|
|
14
|
-
|
|
13
|
+
//$cell-selected-bg: #E6EFFD !default;
|
|
14
|
+
$cell-selected-bg: #F3F8FF !default;
|
|
15
|
+
//$cell-index-selected-bg: #0550C5 !default;
|
|
16
|
+
$cell-index-selected-bg: #1869E6 !default;
|
|
17
|
+
//$cell-index-focus-bg: #CEDBEF !default;
|
|
18
|
+
$cell-index-focus-bg: #E6EFFD !default;
|
|
15
19
|
$rowSelectedHoverBg: 'ui-rc' !default;
|
|
16
20
|
$boxShadowColor: rgba(5, 5, 5, 0.09) !default;
|
|
17
21
|
$fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
@@ -144,6 +148,19 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
144
148
|
|
|
145
149
|
.#{$prefix}-table-cell {
|
|
146
150
|
line-height: 22px;
|
|
151
|
+
&:focus-visible {
|
|
152
|
+
outline: none;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
&.disable {
|
|
157
|
+
background-color: #f0f0f0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&.selected {
|
|
161
|
+
//background: red;
|
|
162
|
+
background-color: $cell-selected-bg !important;
|
|
163
|
+
}
|
|
147
164
|
|
|
148
165
|
.ui-rc-table-cell-content {
|
|
149
166
|
line-height: 22px;
|
|
@@ -406,7 +423,20 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
406
423
|
left: 8px;
|
|
407
424
|
}
|
|
408
425
|
|
|
426
|
+
&.rc-ui-cell-index {
|
|
427
|
+
&.focus {
|
|
428
|
+
background-color: $cell-index-focus-bg;
|
|
429
|
+
font-weight: 500;
|
|
430
|
+
}
|
|
431
|
+
&.selected {
|
|
432
|
+
background-color: $cell-index-selected-bg !important;
|
|
433
|
+
color: #fff;
|
|
434
|
+
//font-weight: 500;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
409
438
|
&.cell-editable {
|
|
439
|
+
|
|
410
440
|
&.cell-border-top {
|
|
411
441
|
border-bottom: 1px solid $border-selected-color;
|
|
412
442
|
}
|
|
@@ -415,29 +445,31 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
415
445
|
border-bottom: 1px solid $border-selected-color;
|
|
416
446
|
}
|
|
417
447
|
|
|
418
|
-
&.cell-paste-border-bottom {
|
|
419
|
-
border-bottom: 1px dashed #949494;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
448
|
&.cell-border-left {
|
|
423
449
|
border-inline-end: 1px solid $border-selected-color;
|
|
424
450
|
}
|
|
425
451
|
|
|
426
|
-
&.cell-
|
|
427
|
-
border-inline-end: 1px
|
|
452
|
+
&.cell-border-right {
|
|
453
|
+
border-inline-end: 1px solid $border-selected-color;
|
|
428
454
|
}
|
|
455
|
+
|
|
429
456
|
&.cell-paste-border-top {
|
|
430
|
-
border-bottom: 1px dashed #949494
|
|
457
|
+
border-bottom: 1px dashed #949494;
|
|
431
458
|
}
|
|
432
459
|
|
|
433
|
-
&.cell-border-
|
|
434
|
-
border-
|
|
460
|
+
&.cell-paste-border-bottom {
|
|
461
|
+
border-bottom: 1px dashed #949494;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
&.cell-paste-border-left {
|
|
465
|
+
border-inline-end: 1px dashed #949494;
|
|
435
466
|
}
|
|
436
467
|
|
|
437
468
|
&.cell-paste-border-right {
|
|
438
469
|
border-inline-end: 1px dashed #949494;
|
|
439
470
|
}
|
|
440
471
|
|
|
472
|
+
|
|
441
473
|
&.#{$prefix}-table-cell-fix-left {
|
|
442
474
|
&:has(.ui-rc_cell-content.selected) {
|
|
443
475
|
}
|
|
@@ -620,18 +652,22 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
620
652
|
height: 10px;
|
|
621
653
|
position: absolute;
|
|
622
654
|
cursor: crosshair;
|
|
623
|
-
right:
|
|
624
|
-
bottom:
|
|
655
|
+
right: -1px;
|
|
656
|
+
bottom: -1px;
|
|
625
657
|
//background: red;
|
|
626
658
|
|
|
659
|
+
&.hidden {
|
|
660
|
+
display: none;
|
|
661
|
+
}
|
|
662
|
+
|
|
627
663
|
.dot-point {
|
|
628
664
|
position: absolute;
|
|
629
665
|
width: 8px;
|
|
630
666
|
height: 8px;
|
|
631
667
|
border-radius: 6px;
|
|
632
668
|
background-color: $border-selected-color;
|
|
633
|
-
bottom: -
|
|
634
|
-
right: -
|
|
669
|
+
bottom: -3px;
|
|
670
|
+
right: -3px;
|
|
635
671
|
}
|
|
636
672
|
|
|
637
673
|
}
|
|
@@ -641,9 +677,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
641
677
|
background-color: $cell-selected-bg;
|
|
642
678
|
}
|
|
643
679
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
680
|
+
//.ui-rc_cell-content.disable {
|
|
681
|
+
// background-color: #f0f0f0;
|
|
682
|
+
//}
|
|
647
683
|
|
|
648
684
|
.ui-rc_cell-content--index {
|
|
649
685
|
&.focus {
|
|
@@ -663,12 +699,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
663
699
|
.#{$prefix}-table-row {
|
|
664
700
|
&.#{$prefix}-table-row-selected {
|
|
665
701
|
>.#{$prefix}-table-cell {
|
|
666
|
-
background: #FEF2EF;
|
|
702
|
+
//background: #FEF2EF;
|
|
667
703
|
}
|
|
668
704
|
}
|
|
669
705
|
>.#{$prefix}-table-cell {
|
|
670
706
|
&.#{$prefix}-table-cell-row-hover {
|
|
671
|
-
background: #FBDED6;
|
|
707
|
+
//background: #FBDED6;
|
|
672
708
|
}
|
|
673
709
|
}
|
|
674
710
|
|
|
@@ -62,8 +62,9 @@ const EditableCell = props => {
|
|
|
62
62
|
const dateTimePickerRef = React.useRef(null);
|
|
63
63
|
// const timePickerRef = React.useRef(null);
|
|
64
64
|
|
|
65
|
+
const cellFormat = column?.format ? typeof column?.format === 'function' ? column?.format?.(record) : column?.format : format;
|
|
65
66
|
const inputNode = (value, onChange) => {
|
|
66
|
-
const dateFormat = getDatepickerFormat(editType,
|
|
67
|
+
const dateFormat = getDatepickerFormat(editType, cellFormat);
|
|
67
68
|
const date = !isEmpty(value) ? convertDateToDayjs(new Date(value), dateFormat) : null;
|
|
68
69
|
const maxDate = convertDateToDayjs(column.maxDate, dateFormat) ?? undefined;
|
|
69
70
|
const minDate = convertDateToDayjs(column.minDate, dateFormat) ?? undefined;
|
|
@@ -205,7 +206,7 @@ const EditableCell = props => {
|
|
|
205
206
|
case 'month':
|
|
206
207
|
case 'quarter':
|
|
207
208
|
case 'year':
|
|
208
|
-
const pickerFormat = getDatepickerFormat(editType,
|
|
209
|
+
const pickerFormat = getDatepickerFormat(editType, cellFormat);
|
|
209
210
|
const maxDateValue1 = !isEmpty(column.maxDate) ? dayjs(column.maxDate, pickerFormat) : undefined;
|
|
210
211
|
const minDateValue1 = !isEmpty(column.minDate) ? dayjs(column.minDate, pickerFormat) : undefined;
|
|
211
212
|
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
@@ -226,7 +227,7 @@ const EditableCell = props => {
|
|
|
226
227
|
popupClassName: 'be-popup-container'
|
|
227
228
|
});
|
|
228
229
|
case 'week':
|
|
229
|
-
const weekFormat = getDatepickerFormat(editType,
|
|
230
|
+
const weekFormat = getDatepickerFormat(editType, cellFormat);
|
|
230
231
|
const maxWeekValue = !isEmpty(column.maxDate) ? dayjs(column.maxDate, weekFormat) : undefined;
|
|
231
232
|
const minWeekValue = !isEmpty(column.minDate) ? dayjs(column.minDate, weekFormat) : undefined;
|
|
232
233
|
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
@@ -243,7 +244,7 @@ const EditableCell = props => {
|
|
|
243
244
|
popupClassName: 'be-popup-container'
|
|
244
245
|
});
|
|
245
246
|
case 'time':
|
|
246
|
-
const timeFormat = getDatepickerFormat(editType,
|
|
247
|
+
const timeFormat = getDatepickerFormat(editType, cellFormat);
|
|
247
248
|
const maxTimeValue = !isEmpty(column.maxTime) ? dayjs(column.maxTime).format(timeFormat) : null;
|
|
248
249
|
const minTimeValue = !isEmpty(column.minTime) ? dayjs(column.minTime).format(timeFormat) : null;
|
|
249
250
|
|
|
@@ -758,8 +759,8 @@ const EditableCell = props => {
|
|
|
758
759
|
// )
|
|
759
760
|
|
|
760
761
|
case 'numeric':
|
|
761
|
-
const thousandSeparator =
|
|
762
|
-
const decimalSeparator =
|
|
762
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
763
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
763
764
|
|
|
764
765
|
// let floatValue = value
|
|
765
766
|
|
|
@@ -767,11 +768,11 @@ const EditableCell = props => {
|
|
|
767
768
|
value,
|
|
768
769
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
769
770
|
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
770
|
-
decimalScale:
|
|
771
|
-
fixedDecimalScale:
|
|
772
|
-
allowNegative:
|
|
773
|
-
prefix:
|
|
774
|
-
suffix:
|
|
771
|
+
decimalScale: cellFormat?.decimalScale ?? undefined,
|
|
772
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false,
|
|
773
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
774
|
+
prefix: cellFormat?.prefix ?? undefined,
|
|
775
|
+
suffix: cellFormat?.suffix ?? undefined
|
|
775
776
|
};
|
|
776
777
|
return /*#__PURE__*/React.createElement(NumericFormat, _extends({
|
|
777
778
|
id: `col${indexCol}-record${indexRow}`
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
heightTable?: number | string;
|
|
4
|
-
}
|
|
2
|
+
interface GridProps {
|
|
3
|
+
$heightTable?: number | string;
|
|
4
|
+
}
|
|
5
|
+
export declare const GridStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, GridProps>> & string;
|
|
6
|
+
export {};
|
|
@@ -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
|
-
})([".ui-rc-table-container{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
|
|
5
|
+
})([".ui-rc-table-container{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 ? typeof props.$heightTable === 'string' ? props.$heightTable : `${props.$heightTable}px` : undefined);
|
|
@@ -3,13 +3,16 @@ import React, { Fragment } from 'react';
|
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { numericFormatter } from "react-numeric-component";
|
|
5
5
|
import { Empty, Table, Toolbar } from "rc-master-ui";
|
|
6
|
+
// import Table from "../../core/table"
|
|
7
|
+
|
|
6
8
|
import 'dayjs/locale/es';
|
|
7
9
|
import 'dayjs/locale/vi';
|
|
8
10
|
import ContextMenu from "./ContextMenu";
|
|
9
11
|
import classNames from "classnames";
|
|
10
12
|
import { checkDecimalSeparator, checkThousandSeparator,
|
|
11
13
|
// filterDataByColumns2,
|
|
12
|
-
filterDataByColumns3,
|
|
14
|
+
// filterDataByColumns3,
|
|
15
|
+
filterDataByColumns4,
|
|
13
16
|
// convertFlatColumn,
|
|
14
17
|
isEmpty,
|
|
15
18
|
// newGuid,
|
|
@@ -365,8 +368,10 @@ const TableGrid = props => {
|
|
|
365
368
|
loading: {
|
|
366
369
|
spinning: columns && columns.length === 0 || loading === true,
|
|
367
370
|
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
368
|
-
}
|
|
369
|
-
dataSource
|
|
371
|
+
}
|
|
372
|
+
// dataSource={columns && columns.length > 0 ? filterDataByColumns3(dataSource, filterStates) : []}
|
|
373
|
+
,
|
|
374
|
+
dataSource: columns && columns.length > 0 ? filterDataByColumns4(dataSource, filterStates) : []
|
|
370
375
|
// dataSource={columns && columns.length > 0 && loading !== true ? dataSource : []}
|
|
371
376
|
// className={styles.customTable}
|
|
372
377
|
,
|
|
@@ -391,21 +396,20 @@ const TableGrid = props => {
|
|
|
391
396
|
},
|
|
392
397
|
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
393
398
|
...selectionSettings,
|
|
394
|
-
type: selectionSettings?.mode
|
|
395
|
-
|
|
399
|
+
// type: selectionSettings?.mode,
|
|
400
|
+
type: mode,
|
|
401
|
+
columnWidth: columnWidth ?? 50,
|
|
396
402
|
onChange: onSelectChange,
|
|
397
403
|
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
398
404
|
selectedRowKeys: mergedSelectedKeys,
|
|
399
|
-
defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
405
|
+
// defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
406
|
+
defaultSelectedRowKeys: defaultSelectedRowKeys,
|
|
400
407
|
preserveSelectedRowKeys: true,
|
|
401
|
-
|
|
402
|
-
// checkStrictly: false,
|
|
403
|
-
|
|
404
|
-
hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
408
|
+
hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
405
409
|
}
|
|
406
410
|
|
|
407
|
-
// onScroll={() => {
|
|
408
|
-
//
|
|
411
|
+
// onScroll={(event) => {
|
|
412
|
+
// console.log('event', event)
|
|
409
413
|
// }}
|
|
410
414
|
,
|
|
411
415
|
|
|
@@ -418,21 +422,24 @@ const TableGrid = props => {
|
|
|
418
422
|
}
|
|
419
423
|
return /*#__PURE__*/React.createElement(Table.Summary, {
|
|
420
424
|
fixed: true
|
|
421
|
-
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns([Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
+
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(!!mode ? [Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
426
|
+
const cellFormat = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format;
|
|
427
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
428
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
429
|
+
|
|
430
|
+
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
431
|
+
const dec = cellFormat?.decimalScale;
|
|
425
432
|
const sumValue = col.type === 'number' ? sumDataByField(dataSource, col?.key) : 0;
|
|
426
433
|
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
427
434
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
428
435
|
const numericFormatProps = {
|
|
429
436
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
430
437
|
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
431
|
-
allowNegative:
|
|
432
|
-
prefix:
|
|
433
|
-
suffix:
|
|
438
|
+
allowNegative: cellFormat?.allowNegative ?? false,
|
|
439
|
+
prefix: cellFormat?.prefix,
|
|
440
|
+
suffix: cellFormat?.suffix,
|
|
434
441
|
decimalScale: dec,
|
|
435
|
-
fixedDecimalScale:
|
|
442
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
436
443
|
};
|
|
437
444
|
return /*#__PURE__*/React.createElement(Table.Summary.Cell, {
|
|
438
445
|
key: col.key,
|
|
@@ -442,7 +449,7 @@ const TableGrid = props => {
|
|
|
442
449
|
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
443
450
|
})));
|
|
444
451
|
},
|
|
445
|
-
pagination: !pagination || pagination && pagination
|
|
452
|
+
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
446
453
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
447
454
|
...pagination
|
|
448
455
|
},
|
|
@@ -6,4 +6,4 @@ export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType
|
|
|
6
6
|
export declare function 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) => 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;
|
|
@@ -70,33 +70,33 @@ export function flatColumns2(columns
|
|
|
70
70
|
export const getValueCell = (column, value, format) => {
|
|
71
71
|
switch (column?.type) {
|
|
72
72
|
case 'number':
|
|
73
|
-
const thousandSeparator =
|
|
74
|
-
const decimalSeparator =
|
|
75
|
-
const dec =
|
|
73
|
+
const thousandSeparator = format?.thousandSeparator;
|
|
74
|
+
const decimalSeparator = format?.decimalSeparator;
|
|
75
|
+
const dec = format?.decimalScale;
|
|
76
76
|
|
|
77
77
|
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
78
78
|
|
|
79
79
|
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
80
|
-
const contentNumber = !isEmpty(value) ? dec || dec === 0 ? tmpval.toFixed(dec) : tmpval.toString() : '0';
|
|
80
|
+
const contentNumber = !isEmpty(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
|
|
81
81
|
const numericFormatProps = {
|
|
82
82
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
83
83
|
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
84
|
-
allowNegative:
|
|
85
|
-
prefix:
|
|
86
|
-
suffix:
|
|
87
|
-
decimalScale:
|
|
88
|
-
fixedDecimalScale:
|
|
84
|
+
allowNegative: format?.allowNegative ?? true,
|
|
85
|
+
prefix: format?.prefix,
|
|
86
|
+
suffix: format?.suffix,
|
|
87
|
+
decimalScale: dec,
|
|
88
|
+
fixedDecimalScale: format?.fixedDecimalScale ?? false
|
|
89
89
|
};
|
|
90
90
|
return !isEmpty(contentNumber) ? numericFormatter(contentNumber, numericFormatProps) : '';
|
|
91
91
|
case 'date':
|
|
92
|
-
return value ? dayjs(value).format(
|
|
92
|
+
return value ? dayjs(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
93
93
|
case 'time':
|
|
94
94
|
return value ? value : '';
|
|
95
95
|
case 'year':
|
|
96
96
|
const year = value ? moment(value).format('yyyy') : '';
|
|
97
97
|
return /*#__PURE__*/React.createElement(Fragment, null, year);
|
|
98
98
|
case 'datetime':
|
|
99
|
-
return value ? moment(value).format(
|
|
99
|
+
return value ? moment(value).format(format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
|
|
100
100
|
case 'boolean':
|
|
101
101
|
return value ? 'true' : 'false';
|
|
102
102
|
case 'color':
|
|
@@ -135,10 +135,11 @@ export const renderContent = (column, value, record, index, format) => {
|
|
|
135
135
|
field: column.field
|
|
136
136
|
}) : column.template : content);
|
|
137
137
|
};
|
|
138
|
-
export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t) => {
|
|
138
|
+
export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t, format) => {
|
|
139
|
+
const cellFormat = column.format ? typeof column.format === 'function' ? column.format({}) : column.format : format;
|
|
139
140
|
const type = getTypeFilter(column);
|
|
140
|
-
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type,
|
|
141
|
-
const dateRangeFormat = getDatepickerFormat(column?.type,
|
|
141
|
+
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, cellFormat) ?? 'DD/MM/YYYY';
|
|
142
|
+
const dateRangeFormat = getDatepickerFormat(column?.type, cellFormat) ?? 'DD/MM/YYYY';
|
|
142
143
|
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
143
144
|
const options = find ? find.data : [];
|
|
144
145
|
switch (type) {
|
|
@@ -154,8 +154,8 @@ const useColumns = config => {
|
|
|
154
154
|
const transformColumns = useCallback(columns => {
|
|
155
155
|
// >>>>>>>>>>> Support selection
|
|
156
156
|
const cloneColumns = [...columns];
|
|
157
|
-
const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && col.field !== '#' &&
|
|
158
|
-
const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && col.field !== '#' &&
|
|
157
|
+
const firstNonGroupColumn = flatColumns2(cloneColumns).find(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
158
|
+
const nonGroupColumns = flatColumns2(cloneColumns).filter(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
159
159
|
|
|
160
160
|
// ===================== Render =====================
|
|
161
161
|
|
|
@@ -191,19 +191,18 @@ const useColumns = config => {
|
|
|
191
191
|
children: convertColumns(transformedColumn.children)
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
194
|
+
if (transformedColumn.field === '#') {
|
|
195
195
|
return {
|
|
196
196
|
...transformedColumn,
|
|
197
197
|
onCell: () => ({
|
|
198
198
|
className: 'cell-number'
|
|
199
199
|
}),
|
|
200
200
|
render: (val, record) => {
|
|
201
|
-
// return rowIndex + 1
|
|
202
201
|
return findItemPath(dataSource, record, rowKey);
|
|
203
202
|
}
|
|
204
203
|
};
|
|
205
204
|
}
|
|
206
|
-
if (
|
|
205
|
+
if (transformedColumn.field === 'command') {
|
|
207
206
|
return {
|
|
208
207
|
...transformedColumn,
|
|
209
208
|
onCell: () => ({
|
|
@@ -278,20 +277,24 @@ const useColumns = config => {
|
|
|
278
277
|
};
|
|
279
278
|
},
|
|
280
279
|
render: (value, record, rowIndex) => {
|
|
280
|
+
const cellFormat = col.format ? typeof col.format === 'function' ? col.format(record) : col.format : format;
|
|
281
281
|
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
282
282
|
if (record.children) {
|
|
283
|
-
return renderContent(col, value, record, rowIndex,
|
|
283
|
+
return renderContent(col, value, record, rowIndex, cellFormat);
|
|
284
284
|
}
|
|
285
285
|
if (groupColumns?.includes(col.field)) {
|
|
286
286
|
return '';
|
|
287
287
|
}
|
|
288
|
-
return renderContent(col, value, record, rowIndex,
|
|
288
|
+
return renderContent(col, value, record, rowIndex, cellFormat);
|
|
289
289
|
}
|
|
290
290
|
if (col.field === firstNonGroupColumn?.field && record.children) {
|
|
291
291
|
const currentGroupColumn = flatColumns2(cols).find(it => it.field === record.field);
|
|
292
|
-
|
|
292
|
+
if (currentGroupColumn?.template) {
|
|
293
|
+
return renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat);
|
|
294
|
+
}
|
|
295
|
+
return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat));
|
|
293
296
|
}
|
|
294
|
-
return renderContent(col, value, record, rowIndex,
|
|
297
|
+
return renderContent(col, value, record, rowIndex, cellFormat);
|
|
295
298
|
},
|
|
296
299
|
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(col.field) ? true : transformedColumn.hidden
|
|
297
300
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import type { EditType, IColumnType, TypeFilter } from "rc-master-ui";
|
|
4
|
-
import type { ColumnTable, GetRowKey } from "../type";
|
|
4
|
+
import type { ColumnTable, GetRowKey, IFormat } from "../type";
|
|
5
5
|
import type { SelectionSettings } from "../type";
|
|
6
6
|
import type { AnyObject } from "../type";
|
|
7
7
|
import type { Key } from "react";
|
|
@@ -21,7 +21,7 @@ export declare const getVisibleColumnKeys: (columns: any[]) => string[];
|
|
|
21
21
|
export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[]): string[];
|
|
22
22
|
export declare const updateColumns: (columns: any[], includes: string[]) => any[];
|
|
23
23
|
export declare const updateColumnsByGroup: (columns: any[], columnsGroup: string[]) => any[];
|
|
24
|
-
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType,
|
|
24
|
+
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
25
25
|
export declare const customWeekStartEndFormat: (value: any, weekFormat: string) => string;
|
|
26
26
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
27
27
|
export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
|
|
@@ -83,6 +83,8 @@ export declare const filterDataByColumns: (data: any[], queries: any) => any[];
|
|
|
83
83
|
export declare const filterDataByColumns2: (data: any[], queries: any) => any[];
|
|
84
84
|
export declare const removeFieldRecursive: (data: any[], field: string) => any[];
|
|
85
85
|
export declare const filterDataByColumns3: (data: any[], queries: any[]) => any[];
|
|
86
|
+
export declare const shouldInclude: (item: any, queries: any[]) => any;
|
|
87
|
+
export declare function filterDataByColumns4(data: any[], queries: any[]): any[];
|
|
86
88
|
export declare function isDateString(str: any): boolean;
|
|
87
89
|
export declare function compareDates(date1: any, date2: any): boolean;
|
|
88
90
|
export declare function compareDate(itemValue: any, value: any): boolean;
|
|
@@ -102,5 +104,18 @@ export declare function isBottomMostInRanges(rowIndex: number, colIndex: number,
|
|
|
102
104
|
export declare const mergedSets: (arr: any[]) => Set<unknown>;
|
|
103
105
|
export declare const sortedSetASC: (setValue: any) => Set<unknown>;
|
|
104
106
|
export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
|
|
105
|
-
export declare
|
|
106
|
-
export declare
|
|
107
|
+
export declare function getBottomRowCells(cellSet: any): any[];
|
|
108
|
+
export declare function getCellsByPosition(cellSet: any, position?: string): any[];
|
|
109
|
+
export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
110
|
+
export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
111
|
+
export declare const removeBorderClass2: (className: string, id?: string) => void;
|
|
112
|
+
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string) => void;
|
|
113
|
+
export declare const onAddBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
114
|
+
export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
|
|
115
|
+
export declare const onRemoveBorderSelectedCell: (selectedCells: any, id?: string) => void;
|
|
116
|
+
export declare const addClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
|
|
117
|
+
export declare const removeClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
|
|
118
|
+
export declare const addClassCellIndexSelected: (rowsSelected: any, id?: string) => void;
|
|
119
|
+
export declare const removeClassCellIndexSelected: (rowsSelected: any, id?: string) => void;
|
|
120
|
+
export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
|
|
121
|
+
export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
|