es-grid-template 1.3.3 → 1.3.4
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 +10 -0
- package/assets/index.scss +15 -0
- package/es/grid-component/ContextMenu.js +4 -1
- package/es/grid-component/EditableCell.js +60 -18
- package/es/grid-component/TableGrid.js +1 -7
- package/es/grid-component/hooks/columns/index.js +13 -16
- package/es/grid-component/hooks/useColumns.js +2 -1
- package/es/grid-component/hooks/utils.d.ts +13 -0
- package/es/grid-component/hooks/utils.js +136 -4
- package/es/grid-component/number/index.d.ts +10 -0
- package/es/grid-component/number/index.js +39 -0
- package/es/grid-component/styles.scss +15 -0
- package/es/grid-component/table/GridEdit.js +575 -204
- package/es/grid-component/type.d.ts +3 -0
- package/es/grid-component/useContext.d.ts +2 -0
- package/lib/grid-component/ContextMenu.js +4 -1
- package/lib/grid-component/EditableCell.js +61 -18
- package/lib/grid-component/TableGrid.js +1 -7
- package/lib/grid-component/hooks/columns/index.js +12 -15
- package/lib/grid-component/hooks/useColumns.js +2 -1
- package/lib/grid-component/hooks/utils.d.ts +13 -0
- package/lib/grid-component/hooks/utils.js +150 -7
- package/lib/grid-component/number/index.d.ts +10 -0
- package/lib/grid-component/number/index.js +47 -0
- package/lib/grid-component/styles.scss +15 -0
- package/lib/grid-component/table/GridEdit.js +563 -200
- package/lib/grid-component/type.d.ts +3 -0
- package/lib/grid-component/useContext.d.ts +2 -0
- package/package.json +1 -1
|
@@ -108,6 +108,7 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
|
|
|
108
108
|
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
109
109
|
columnGroupText?: string;
|
|
110
110
|
textAlign?: ITextAlign;
|
|
111
|
+
headerTextAlign?: ITextAlign;
|
|
111
112
|
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
112
113
|
showTooltip?: boolean;
|
|
113
114
|
tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
@@ -149,6 +150,7 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
149
150
|
t?: any;
|
|
150
151
|
lang?: string;
|
|
151
152
|
contextMenuItems?: ContextMenuItem[];
|
|
153
|
+
showDefaultContext?: boolean;
|
|
152
154
|
contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
|
|
153
155
|
contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
|
|
154
156
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
@@ -253,6 +255,7 @@ export interface ICellPasteModel<RecordType = AnyObject> {
|
|
|
253
255
|
onPasted?: (args: IOnPastedProps, handleCallback: (callbackData: any[]) => void) => void;
|
|
254
256
|
dataChange?: (data: RecordType[]) => void;
|
|
255
257
|
getCallbackData?: (props: any) => void;
|
|
258
|
+
maxRowsPaste?: number;
|
|
256
259
|
}
|
|
257
260
|
export type SourceFilter = {
|
|
258
261
|
key: string;
|
|
@@ -108,7 +108,10 @@ const ContextMenu = props => {
|
|
|
108
108
|
maxHeight: pos.viewportHeight - 20,
|
|
109
109
|
width: 'fit-content'
|
|
110
110
|
},
|
|
111
|
-
rootClassName: 'popup-context-menu'
|
|
111
|
+
rootClassName: 'popup-context-menu'
|
|
112
|
+
// rootClassName={'be-popup-container'}
|
|
113
|
+
,
|
|
114
|
+
|
|
112
115
|
onClick: e => {
|
|
113
116
|
setOpen(false);
|
|
114
117
|
contextMenuClick?.({
|
|
@@ -23,12 +23,13 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
23
23
|
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
24
|
// import moment from "moment";
|
|
25
25
|
// import dayjs from "dayjs";
|
|
26
|
+
// import {TreeSelect} from "antd";
|
|
26
27
|
|
|
27
28
|
// import moment from "moment";
|
|
28
29
|
|
|
29
30
|
const {
|
|
30
31
|
SHOW_PARENT
|
|
31
|
-
} =
|
|
32
|
+
} = _rcMasterUi.TreeSelect;
|
|
32
33
|
const filterTreeNode = (input, treeNode) => {
|
|
33
34
|
const {
|
|
34
35
|
title,
|
|
@@ -53,7 +54,6 @@ const EditableCell = props => {
|
|
|
53
54
|
...restProps
|
|
54
55
|
} = props;
|
|
55
56
|
const {
|
|
56
|
-
rowKey,
|
|
57
57
|
format,
|
|
58
58
|
control,
|
|
59
59
|
getValues,
|
|
@@ -122,6 +122,8 @@ const EditableCell = props => {
|
|
|
122
122
|
prevState,
|
|
123
123
|
newState,
|
|
124
124
|
option: newState,
|
|
125
|
+
indexCol,
|
|
126
|
+
indexRow,
|
|
125
127
|
type: 'blur'
|
|
126
128
|
});
|
|
127
129
|
}
|
|
@@ -194,6 +196,8 @@ const EditableCell = props => {
|
|
|
194
196
|
prevState,
|
|
195
197
|
newState,
|
|
196
198
|
option: newState,
|
|
199
|
+
indexCol,
|
|
200
|
+
indexRow,
|
|
197
201
|
type: 'blur'
|
|
198
202
|
});
|
|
199
203
|
}
|
|
@@ -314,6 +318,8 @@ const EditableCell = props => {
|
|
|
314
318
|
prevState,
|
|
315
319
|
newState,
|
|
316
320
|
option: option,
|
|
321
|
+
indexCol,
|
|
322
|
+
indexRow,
|
|
317
323
|
type: 'blur'
|
|
318
324
|
});
|
|
319
325
|
},
|
|
@@ -394,6 +400,8 @@ const EditableCell = props => {
|
|
|
394
400
|
prevState,
|
|
395
401
|
newState,
|
|
396
402
|
option: option,
|
|
403
|
+
indexCol,
|
|
404
|
+
indexRow,
|
|
397
405
|
type: 'blur'
|
|
398
406
|
});
|
|
399
407
|
},
|
|
@@ -449,6 +457,8 @@ const EditableCell = props => {
|
|
|
449
457
|
prevState,
|
|
450
458
|
newState,
|
|
451
459
|
option: option,
|
|
460
|
+
indexCol,
|
|
461
|
+
indexRow,
|
|
452
462
|
type: 'blur'
|
|
453
463
|
});
|
|
454
464
|
},
|
|
@@ -519,12 +529,23 @@ const EditableCell = props => {
|
|
|
519
529
|
|
|
520
530
|
const newTreeData = (0, _hooks.convertLabelToTitle)(optionsTree);
|
|
521
531
|
// @ts-ignore
|
|
522
|
-
const valueTreeSelect = column?.editSelectSettings?.isMulti ? Array.isArray(record[column.dataIndex]) ? record[column.dataIndex] : [] : record[column.dataIndex]
|
|
523
|
-
|
|
532
|
+
// const valueTreeSelect = column?.editSelectSettings?.isMulti ? (Array.isArray(record[column.dataIndex]) ? record[column.dataIndex] : []) : record[column.dataIndex]
|
|
533
|
+
|
|
534
|
+
let valueTreeSelect = value;
|
|
535
|
+
if (fieldValue) {
|
|
536
|
+
// @ts-ignore
|
|
537
|
+
valueTreeSelect = record[fieldValue] ?? value;
|
|
538
|
+
}
|
|
539
|
+
if (isMulti || selectMode === 'checkbox') {
|
|
540
|
+
// @ts-ignore
|
|
541
|
+
valueTreeSelect = !(0, _hooks.isNullOrUndefined)(record[column.dataIndex]) && Array.isArray(record[column.dataIndex]) && record[column.dataIndex]?.length > 0 ? options.filter(val => record[column.dataIndex]?.includes(val[keySelect])) : undefined;
|
|
542
|
+
}
|
|
543
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TreeSelect, {
|
|
524
544
|
id: `col${indexCol}-record${indexRow}`,
|
|
525
545
|
className: 'be-tree-select',
|
|
526
546
|
style: {
|
|
527
|
-
width: '100%'
|
|
547
|
+
width: '100%',
|
|
548
|
+
height: '100%'
|
|
528
549
|
},
|
|
529
550
|
value: valueTreeSelect,
|
|
530
551
|
dropdownStyle: {
|
|
@@ -551,17 +572,28 @@ const EditableCell = props => {
|
|
|
551
572
|
value: keySelect,
|
|
552
573
|
children: 'children'
|
|
553
574
|
},
|
|
554
|
-
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox'
|
|
555
|
-
|
|
556
|
-
,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
575
|
+
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox',
|
|
576
|
+
filterTreeNode: filterTreeNode,
|
|
577
|
+
onSelect: (val, option) => {
|
|
578
|
+
onChange(val ?? '');
|
|
579
|
+
const formState = getValues();
|
|
580
|
+
// const itemState = getValues(dataIndex)
|
|
581
|
+
// @ts-ignore
|
|
582
|
+
const prevState = record[dataIndex];
|
|
583
|
+
const newState = val;
|
|
584
|
+
handleCellChange?.({
|
|
585
|
+
key: getRowKey?.(record, index),
|
|
586
|
+
field: column.field ?? column.dataIndex,
|
|
587
|
+
record: formState,
|
|
588
|
+
prevState,
|
|
589
|
+
newState,
|
|
590
|
+
option: option,
|
|
591
|
+
indexCol,
|
|
592
|
+
indexRow,
|
|
593
|
+
type: 'blur'
|
|
594
|
+
});
|
|
595
|
+
},
|
|
596
|
+
popupClassName: 'be-popup-container',
|
|
565
597
|
status: isInvalid ? 'error' : undefined
|
|
566
598
|
});
|
|
567
599
|
case 'checkbox':
|
|
@@ -590,6 +622,8 @@ const EditableCell = props => {
|
|
|
590
622
|
prevState: value,
|
|
591
623
|
newState: newVal,
|
|
592
624
|
field: column.field ?? column.dataIndex,
|
|
625
|
+
indexCol,
|
|
626
|
+
indexRow,
|
|
593
627
|
type: 'blur'
|
|
594
628
|
});
|
|
595
629
|
},
|
|
@@ -675,6 +709,8 @@ const EditableCell = props => {
|
|
|
675
709
|
record: formState,
|
|
676
710
|
prevState: value,
|
|
677
711
|
newState: `#${valueColor.toHex()}`,
|
|
712
|
+
indexCol,
|
|
713
|
+
indexRow,
|
|
678
714
|
type: 'blur'
|
|
679
715
|
});
|
|
680
716
|
},
|
|
@@ -774,6 +810,8 @@ const EditableCell = props => {
|
|
|
774
810
|
record: formState,
|
|
775
811
|
prevState,
|
|
776
812
|
newState,
|
|
813
|
+
indexCol,
|
|
814
|
+
indexRow,
|
|
777
815
|
type: 'blur'
|
|
778
816
|
});
|
|
779
817
|
}
|
|
@@ -811,23 +849,28 @@ const EditableCell = props => {
|
|
|
811
849
|
prevState,
|
|
812
850
|
newState,
|
|
813
851
|
field: column.field ?? column.dataIndex,
|
|
852
|
+
indexCol,
|
|
853
|
+
indexRow,
|
|
814
854
|
type: 'blur'
|
|
815
855
|
});
|
|
816
856
|
}
|
|
817
857
|
},
|
|
818
858
|
onPressEnter: () => {
|
|
859
|
+
const key = getRowKey?.(record, index);
|
|
819
860
|
const formState = getValues();
|
|
820
861
|
const newState = getValues(dataIndex);
|
|
821
862
|
// @ts-ignore
|
|
822
863
|
const prevState = record[dataIndex];
|
|
823
864
|
// @ts-ignore
|
|
824
865
|
// if (itemState !== record[dataIndex]) {
|
|
825
|
-
|
|
866
|
+
|
|
826
867
|
handleCellChange?.({
|
|
827
|
-
key:
|
|
868
|
+
key: key,
|
|
828
869
|
newState,
|
|
829
870
|
prevState,
|
|
830
871
|
record: formState,
|
|
872
|
+
indexCol,
|
|
873
|
+
indexRow,
|
|
831
874
|
type: 'enter'
|
|
832
875
|
});
|
|
833
876
|
// }
|
|
@@ -288,12 +288,6 @@ const TableGrid = props => {
|
|
|
288
288
|
if (checkboxOnly !== true) {
|
|
289
289
|
if (type === 'single') {}
|
|
290
290
|
}
|
|
291
|
-
if (clickRef.current) return;
|
|
292
|
-
|
|
293
|
-
// @ts-ignore
|
|
294
|
-
clickRef.current = setTimeout(() => {
|
|
295
|
-
clickRef.current = null;
|
|
296
|
-
}, 250);
|
|
297
291
|
};
|
|
298
292
|
const handleRowDoubleClick = (record, index) => e => {
|
|
299
293
|
if (clickRef.current) {
|
|
@@ -373,7 +367,7 @@ const TableGrid = props => {
|
|
|
373
367
|
spinning: columns && columns.length === 0 || loading === true,
|
|
374
368
|
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
375
369
|
},
|
|
376
|
-
dataSource: columns && columns.length > 0
|
|
370
|
+
dataSource: columns && columns.length > 0 ? (0, _hooks.filterDataByColumns3)(dataSource, filterStates) : []
|
|
377
371
|
// dataSource={columns && columns.length > 0 && loading !== true ? dataSource : []}
|
|
378
372
|
// className={styles.customTable}
|
|
379
373
|
,
|
|
@@ -16,6 +16,7 @@ var _rcMasterUi = require("rc-master-ui");
|
|
|
16
16
|
var _CheckboxFilter = _interopRequireDefault(require("../../CheckboxFilter"));
|
|
17
17
|
var _useSelection = require("rc-master-ui/es/table/hooks/useSelection");
|
|
18
18
|
var _numberRange = _interopRequireDefault(require("../../number-range"));
|
|
19
|
+
var _number = _interopRequireDefault(require("../../number"));
|
|
19
20
|
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); }
|
|
20
21
|
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; }
|
|
21
22
|
const {
|
|
@@ -79,7 +80,10 @@ const getValueCell = (column, value, format) => {
|
|
|
79
80
|
const thousandSeparator = column?.format?.thousandSeparator ? column?.format?.thousandSeparator : format?.thousandSeparator;
|
|
80
81
|
const decimalSeparator = column?.format?.decimalSeparator ? column?.format?.decimalSeparator : format?.decimalSeparator;
|
|
81
82
|
const dec = column?.format?.decimalScale || column?.format?.decimalScale === 0 ? column?.format?.decimalScale : format?.decimalScale;
|
|
82
|
-
|
|
83
|
+
|
|
84
|
+
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
85
|
+
|
|
86
|
+
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(value.toFixed(dec)).toString() : value.toString() : '0';
|
|
83
87
|
const numericFormatProps = {
|
|
84
88
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
85
89
|
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -89,7 +93,7 @@ const getValueCell = (column, value, format) => {
|
|
|
89
93
|
decimalScale: column?.format?.decimalScale || column?.format?.decimalScale === 0 ? column?.format?.decimalScale : format?.decimalScale,
|
|
90
94
|
fixedDecimalScale: (column?.format?.fixedDecimalScale ? column?.format?.fixedDecimalScale : format?.fixedDecimalScale) ?? false
|
|
91
95
|
};
|
|
92
|
-
return !(0, _utils.isEmpty)(
|
|
96
|
+
return !(0, _utils.isEmpty)(contentNumber) ? (0, _reactNumericComponent.numericFormatter)(contentNumber, numericFormatProps) : '';
|
|
93
97
|
case 'date':
|
|
94
98
|
return value ? (0, _dayjs.default)(value).format(column?.format?.dateFormat ?? format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
95
99
|
case 'time':
|
|
@@ -113,7 +117,7 @@ const getValueCell = (column, value, format) => {
|
|
|
113
117
|
}));
|
|
114
118
|
case 'checkbox':
|
|
115
119
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Input, {
|
|
116
|
-
checked: !!
|
|
120
|
+
checked: !!value,
|
|
117
121
|
readOnly: true,
|
|
118
122
|
type: "checkbox"
|
|
119
123
|
});
|
|
@@ -149,18 +153,11 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
149
153
|
case 'Number':
|
|
150
154
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
151
155
|
className: 'mb-1'
|
|
152
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
,
|
|
158
|
-
allowNegative: true,
|
|
159
|
-
customInput: _rcMasterUi.Input,
|
|
160
|
-
className: ' rounded-0 input-element form-control',
|
|
161
|
-
onValueChange: values => {
|
|
162
|
-
// onChangeValueFilter(type, values.floatValue)
|
|
163
|
-
setSelectedKeys(values.floatValue || values.floatValue === 0 ? [values.floatValue] : []);
|
|
156
|
+
}, /*#__PURE__*/_react.default.createElement(_number.default, {
|
|
157
|
+
t: t,
|
|
158
|
+
value: selectedKeys[0],
|
|
159
|
+
onChange: vals => {
|
|
160
|
+
setSelectedKeys(vals);
|
|
164
161
|
}
|
|
165
162
|
}))));
|
|
166
163
|
case 'NumberRange':
|
|
@@ -274,7 +274,8 @@ const useColumns = config => {
|
|
|
274
274
|
},
|
|
275
275
|
onHeaderCell: () => ({
|
|
276
276
|
width: col.width,
|
|
277
|
-
onResize: handleResize?.(col)
|
|
277
|
+
onResize: handleResize?.(col),
|
|
278
|
+
className: col.headerTextAlign === 'center' ? 'head-align-center' : col.headerTextAlign === 'right' ? 'head-align-right' : ''
|
|
278
279
|
}),
|
|
279
280
|
onCell: (data, index) => {
|
|
280
281
|
return {
|
|
@@ -80,3 +80,16 @@ export declare function isDateString(str: any): boolean;
|
|
|
80
80
|
export declare function compareDates(date1: any, date2: any): boolean;
|
|
81
81
|
export declare function compareDate(itemValue: any, value: any): boolean;
|
|
82
82
|
export declare function invalidDate(date: any): boolean;
|
|
83
|
+
export declare const isContinuous: (set: any) => boolean;
|
|
84
|
+
export declare const parseCells: (cellSet: any) => {
|
|
85
|
+
row: any;
|
|
86
|
+
col: any;
|
|
87
|
+
key: any;
|
|
88
|
+
}[];
|
|
89
|
+
export declare const buildConnectedRegions: (cells: any) => any[];
|
|
90
|
+
export declare const isBottomMostInRegion: (rowIndex: number, colIndex: number, listSelectCell: any) => boolean;
|
|
91
|
+
export declare const isTopMostInRegion: (rowIndex: number, colIndex: number, listSelectCell: any) => boolean;
|
|
92
|
+
export declare function isRightMostInRegion(rowIndex: number, colIndex: number, listSelectCell: any): boolean;
|
|
93
|
+
export declare function isEqualSet(setA: any, setB: any): boolean;
|
|
94
|
+
export declare function isBottomMostInRanges(rowIndex: number, colIndex: number, regions: any[]): boolean;
|
|
95
|
+
export declare const mergedSets: (arr: any[]) => Set<unknown>;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.addRowIdArray = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
|
-
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = void 0;
|
|
9
|
+
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
|
|
10
10
|
exports.compareDate = compareDate;
|
|
11
11
|
exports.compareDates = compareDates;
|
|
12
12
|
exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = void 0;
|
|
@@ -15,9 +15,15 @@ exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exp
|
|
|
15
15
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
16
16
|
exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
17
17
|
exports.invalidDate = invalidDate;
|
|
18
|
-
exports.
|
|
18
|
+
exports.isArraysEqual = void 0;
|
|
19
|
+
exports.isBottomMostInRanges = isBottomMostInRanges;
|
|
20
|
+
exports.isContinuous = exports.isColor = exports.isBottomMostInRegion = void 0;
|
|
19
21
|
exports.isDateString = isDateString;
|
|
20
|
-
exports.
|
|
22
|
+
exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
23
|
+
exports.isEqualSet = isEqualSet;
|
|
24
|
+
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
|
|
25
|
+
exports.isRightMostInRegion = isRightMostInRegion;
|
|
26
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
|
|
21
27
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
22
28
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
23
29
|
var _uuid = require("uuid");
|
|
@@ -1054,10 +1060,10 @@ const filterDataByColumns3 = (data, queries) => {
|
|
|
1054
1060
|
const queryStr = value?.toString().toLowerCase?.();
|
|
1055
1061
|
switch (operator.toLowerCase()) {
|
|
1056
1062
|
case "equal":
|
|
1057
|
-
condition = isDateComparison ? compareDates(itemDate, queryDate) : itemValue
|
|
1063
|
+
condition = isDateComparison ? compareDates(itemDate, queryDate) : itemValue === value;
|
|
1058
1064
|
break;
|
|
1059
1065
|
case "notequal":
|
|
1060
|
-
condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue
|
|
1066
|
+
condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
|
|
1061
1067
|
break;
|
|
1062
1068
|
case "greaterthan":
|
|
1063
1069
|
// @ts-ignore
|
|
@@ -1103,9 +1109,19 @@ const filterDataByColumns3 = (data, queries) => {
|
|
|
1103
1109
|
// ======= Helper functions ========
|
|
1104
1110
|
|
|
1105
1111
|
// Kiểm tra có phải Date object không
|
|
1112
|
+
// function isDate(value: any) {
|
|
1113
|
+
// return value instanceof Date || !isNaN(Date.parse(value));
|
|
1114
|
+
// }
|
|
1106
1115
|
exports.filterDataByColumns3 = filterDataByColumns3;
|
|
1107
1116
|
function isDate(value) {
|
|
1108
|
-
|
|
1117
|
+
if (value instanceof Date) {
|
|
1118
|
+
return !isNaN(value.getTime());
|
|
1119
|
+
}
|
|
1120
|
+
if (typeof value === "string") {
|
|
1121
|
+
// Chỉ chấp nhận định dạng yyyy-mm-dd hoặc mm/yyyy
|
|
1122
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(value) || /^\d{2}\/\d{4}$/.test(value);
|
|
1123
|
+
}
|
|
1124
|
+
return false;
|
|
1109
1125
|
}
|
|
1110
1126
|
|
|
1111
1127
|
// Chuỗi MM/YYYY → Date
|
|
@@ -1139,4 +1155,131 @@ function compareDate(itemValue, value) {
|
|
|
1139
1155
|
}
|
|
1140
1156
|
function invalidDate(date) {
|
|
1141
1157
|
return date instanceof Date && !isNaN(date.getTime());
|
|
1142
|
-
}
|
|
1158
|
+
}
|
|
1159
|
+
const isContinuous = set => {
|
|
1160
|
+
const rows = [];
|
|
1161
|
+
const cols = [];
|
|
1162
|
+
for (const item of set) {
|
|
1163
|
+
const [row, col] = item.split('-').map(Number);
|
|
1164
|
+
rows.push(row);
|
|
1165
|
+
cols.push(col);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// Lấy danh sách duy nhất và sắp xếp
|
|
1169
|
+
const uniqueSorted = arr => [...new Set(arr)].sort((a, b) => a - b);
|
|
1170
|
+
const isSequential = arr => {
|
|
1171
|
+
for (let i = 1; i < arr.length; i++) {
|
|
1172
|
+
if (arr[i] !== arr[i - 1] + 1) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return true;
|
|
1177
|
+
};
|
|
1178
|
+
const sortedRows = uniqueSorted(rows);
|
|
1179
|
+
const sortedCols = uniqueSorted(cols);
|
|
1180
|
+
return isSequential(sortedRows) && isSequential(sortedCols);
|
|
1181
|
+
};
|
|
1182
|
+
exports.isContinuous = isContinuous;
|
|
1183
|
+
const parseCells = cellSet => {
|
|
1184
|
+
return Array.from(cellSet).map(cell => {
|
|
1185
|
+
const [row, col] = cell.split('-').map(Number);
|
|
1186
|
+
return {
|
|
1187
|
+
row,
|
|
1188
|
+
col,
|
|
1189
|
+
key: cell
|
|
1190
|
+
};
|
|
1191
|
+
});
|
|
1192
|
+
};
|
|
1193
|
+
exports.parseCells = parseCells;
|
|
1194
|
+
const buildConnectedRegions = cells => {
|
|
1195
|
+
const cellMap = new Map();
|
|
1196
|
+
const visited = new Set();
|
|
1197
|
+
for (const cell of cells) {
|
|
1198
|
+
cellMap.set(cell.key, cell);
|
|
1199
|
+
}
|
|
1200
|
+
const directions = [[1, 0],
|
|
1201
|
+
// down
|
|
1202
|
+
[-1, 0],
|
|
1203
|
+
// up
|
|
1204
|
+
[0, 1],
|
|
1205
|
+
// right
|
|
1206
|
+
[0, -1] // left
|
|
1207
|
+
];
|
|
1208
|
+
const regions = [];
|
|
1209
|
+
for (const cell of cells) {
|
|
1210
|
+
if (visited.has(cell.key)) continue;
|
|
1211
|
+
const stack = [cell];
|
|
1212
|
+
const region = [];
|
|
1213
|
+
while (stack.length) {
|
|
1214
|
+
const current = stack.pop();
|
|
1215
|
+
if (visited.has(current.key)) continue;
|
|
1216
|
+
visited.add(current.key);
|
|
1217
|
+
region.push(current);
|
|
1218
|
+
for (const [dr, dc] of directions) {
|
|
1219
|
+
const neighborKey = `${current.row + dr}-${current.col + dc}`;
|
|
1220
|
+
if (cellMap.has(neighborKey) && !visited.has(neighborKey)) {
|
|
1221
|
+
stack.push(cellMap.get(neighborKey));
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
regions.push(region);
|
|
1226
|
+
}
|
|
1227
|
+
return regions;
|
|
1228
|
+
};
|
|
1229
|
+
exports.buildConnectedRegions = buildConnectedRegions;
|
|
1230
|
+
const isBottomMostInRegion = (rowIndex, colIndex, listSelectCell) => {
|
|
1231
|
+
const cells = parseCells(listSelectCell);
|
|
1232
|
+
const regions = buildConnectedRegions(cells);
|
|
1233
|
+
for (const region of regions) {
|
|
1234
|
+
if (region.some(cell => cell.row === rowIndex && cell.col === colIndex)) {
|
|
1235
|
+
const maxRow = Math.max(...region.map(cell => cell.row));
|
|
1236
|
+
return rowIndex === maxRow;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
return false;
|
|
1240
|
+
};
|
|
1241
|
+
exports.isBottomMostInRegion = isBottomMostInRegion;
|
|
1242
|
+
const isTopMostInRegion = (rowIndex, colIndex, listSelectCell) => {
|
|
1243
|
+
const cells = parseCells(listSelectCell);
|
|
1244
|
+
const regions = buildConnectedRegions(cells);
|
|
1245
|
+
for (const region of regions) {
|
|
1246
|
+
if (region.some(cell => cell.row === rowIndex && cell.col === colIndex)) {
|
|
1247
|
+
const minRow = Math.min(...region.map(cell => cell.row));
|
|
1248
|
+
return rowIndex === minRow;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return false;
|
|
1252
|
+
};
|
|
1253
|
+
exports.isTopMostInRegion = isTopMostInRegion;
|
|
1254
|
+
function isRightMostInRegion(rowIndex, colIndex, listSelectCell) {
|
|
1255
|
+
const cells = parseCells(listSelectCell);
|
|
1256
|
+
const regions = buildConnectedRegions(cells);
|
|
1257
|
+
for (const region of regions) {
|
|
1258
|
+
if (region.some(cell => cell.row === rowIndex && cell.col === colIndex)) {
|
|
1259
|
+
const maxCol = Math.max(...region.map(cell => cell.col));
|
|
1260
|
+
return colIndex === maxCol;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1265
|
+
function isEqualSet(setA, setB) {
|
|
1266
|
+
if (setA.size !== setB.size) return false;
|
|
1267
|
+
for (const item of setA) {
|
|
1268
|
+
if (!setB.has(item)) return false;
|
|
1269
|
+
}
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
function isBottomMostInRanges(rowIndex, colIndex, regions) {
|
|
1273
|
+
const ranges = regions.map(it => parseCells(it));
|
|
1274
|
+
for (const region of ranges) {
|
|
1275
|
+
if (region.some(cell => cell.row === rowIndex && cell.col === colIndex)) {
|
|
1276
|
+
const maxRow = Math.max(...region.map(cell => cell.row));
|
|
1277
|
+
return rowIndex === maxRow;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
const mergedSets = arr => {
|
|
1283
|
+
return new Set(arr.flatMap(set => Array.from(set)));
|
|
1284
|
+
};
|
|
1285
|
+
exports.mergedSets = mergedSets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IFormat } from "../type";
|
|
3
|
+
type Props = {
|
|
4
|
+
t?: any;
|
|
5
|
+
format?: IFormat;
|
|
6
|
+
value: number | string | undefined;
|
|
7
|
+
onChange?: (values: any[]) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const Number: (props: Props) => React.JSX.Element;
|
|
10
|
+
export default Number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
9
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
10
|
+
var _hooks = require("../hooks");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
const Number = props => {
|
|
14
|
+
const {
|
|
15
|
+
t,
|
|
16
|
+
value,
|
|
17
|
+
format,
|
|
18
|
+
onChange
|
|
19
|
+
} = props;
|
|
20
|
+
const values = _react.default.useMemo(() => [value], [value]);
|
|
21
|
+
|
|
22
|
+
// const [values, setValues] = React.useState<any[]>(() =>
|
|
23
|
+
// mergedValues,
|
|
24
|
+
// );
|
|
25
|
+
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNumericComponent.NumericFormat, {
|
|
27
|
+
value: values[0] ?? ''
|
|
28
|
+
// value={min}
|
|
29
|
+
,
|
|
30
|
+
thousandSeparator: (0, _hooks.checkThousandSeparator)(format?.thousandSeparator, format?.decimalSeparator),
|
|
31
|
+
decimalSeparator: (0, _hooks.checkDecimalSeparator)(format?.thousandSeparator, format?.decimalSeparator),
|
|
32
|
+
allowNegative: true,
|
|
33
|
+
customInput: _rcMasterUi.Input,
|
|
34
|
+
className: 'rounded-0 input-element',
|
|
35
|
+
onValueChange: vals => {
|
|
36
|
+
// onChangeValueFilter(type, values.floatValue, 'min')
|
|
37
|
+
|
|
38
|
+
// setValues([vals.floatValue, values[1]])
|
|
39
|
+
onChange?.([vals.floatValue]);
|
|
40
|
+
}
|
|
41
|
+
// placeholder={t ? t('Min') : 'Min'}
|
|
42
|
+
,
|
|
43
|
+
placeholder: t ? t('Enter') : 'Enter',
|
|
44
|
+
autoFocus: true
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
var _default = exports.default = Number;
|
|
@@ -26,6 +26,14 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
26
26
|
|
|
27
27
|
.popup-context-menu {
|
|
28
28
|
min-width: 200px;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
.ant-dropdown-menu.popup-context-menu {
|
|
32
|
+
.ant-dropdown-menu-submenu {
|
|
33
|
+
.ant-dropdown-menu-submenu-title {
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
// -------------- Table -------------
|
|
@@ -239,6 +247,13 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
239
247
|
.#{$prefix}-table-column-title {
|
|
240
248
|
//display: flex;
|
|
241
249
|
}
|
|
250
|
+
|
|
251
|
+
&.head-align-center {
|
|
252
|
+
text-align: center;
|
|
253
|
+
}
|
|
254
|
+
&.head-align-right {
|
|
255
|
+
text-align: right;
|
|
256
|
+
}
|
|
242
257
|
}
|
|
243
258
|
}
|
|
244
259
|
|