es-grid-template 1.2.7 → 1.2.9
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/AdvanceFilter.d.ts +11 -7
- package/es/grid-component/AdvanceFilter.js +419 -509
- package/es/grid-component/EditableCell.d.ts +2 -2
- package/es/grid-component/TableGrid.js +11 -2
- package/es/grid-component/checkbox-control/index.d.ts +13 -0
- package/es/grid-component/checkbox-control/index.js +40 -0
- package/es/grid-component/hooks/columns/index.d.ts +4 -4
- package/es/grid-component/hooks/columns/index.js +6 -1
- package/es/grid-component/hooks/useColumns.js +3 -2
- package/es/grid-component/hooks/utils.d.ts +9 -7
- package/es/grid-component/hooks/utils.js +10 -1
- package/es/grid-component/table/GridEdit.d.ts +2 -3
- package/es/grid-component/table/GridEdit.js +35 -11
- package/es/grid-component/type.d.ts +8 -27
- package/lib/grid-component/AdvanceFilter.d.ts +11 -7
- package/lib/grid-component/AdvanceFilter.js +415 -506
- package/lib/grid-component/EditableCell.d.ts +2 -2
- package/lib/grid-component/TableGrid.js +11 -2
- package/lib/grid-component/checkbox-control/index.d.ts +13 -0
- package/lib/grid-component/checkbox-control/index.js +48 -0
- package/lib/grid-component/hooks/columns/index.d.ts +4 -4
- package/lib/grid-component/hooks/columns/index.js +6 -1
- package/lib/grid-component/hooks/useColumns.js +3 -2
- package/lib/grid-component/hooks/utils.d.ts +9 -7
- package/lib/grid-component/hooks/utils.js +15 -4
- package/lib/grid-component/table/GridEdit.d.ts +2 -3
- package/lib/grid-component/table/GridEdit.js +34 -9
- package/lib/grid-component/type.d.ts +8 -27
- package/package.json +108 -108
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ColumnTable, IFormat } from "./type";
|
|
3
3
|
import type { EditType } from "rc-master-ui";
|
|
4
4
|
interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
|
|
5
5
|
t?: any;
|
|
@@ -10,7 +10,7 @@ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement>
|
|
|
10
10
|
record: DataType;
|
|
11
11
|
index: number;
|
|
12
12
|
format?: IFormat;
|
|
13
|
-
column:
|
|
13
|
+
column: ColumnTable<DataType>;
|
|
14
14
|
indexRow: number;
|
|
15
15
|
indexCol: number;
|
|
16
16
|
rowKey: any;
|
|
@@ -20,6 +20,7 @@ var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
|
20
20
|
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
21
21
|
var _ColumnsChoose = require("./ColumnsChoose");
|
|
22
22
|
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
23
|
+
var _AdvanceFilter = _interopRequireDefault(require("./AdvanceFilter"));
|
|
23
24
|
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); }
|
|
24
25
|
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; }
|
|
25
26
|
// import {ConfigProvider} from "antd";
|
|
@@ -112,6 +113,7 @@ const TableGrid = props => {
|
|
|
112
113
|
recordDoubleClick,
|
|
113
114
|
toolbarItems,
|
|
114
115
|
showColumnChoose,
|
|
116
|
+
showAdvanceFilter,
|
|
115
117
|
onFilter,
|
|
116
118
|
selectionSettings,
|
|
117
119
|
rowSelection,
|
|
@@ -403,7 +405,8 @@ const TableGrid = props => {
|
|
|
403
405
|
style: {
|
|
404
406
|
display: 'flex',
|
|
405
407
|
justifyContent: 'space-between',
|
|
406
|
-
alignItems: 'center'
|
|
408
|
+
alignItems: 'center',
|
|
409
|
+
gap: '.75rem'
|
|
407
410
|
}
|
|
408
411
|
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
409
412
|
style: {
|
|
@@ -420,7 +423,8 @@ const TableGrid = props => {
|
|
|
420
423
|
style: {
|
|
421
424
|
display: 'flex',
|
|
422
425
|
justifyContent: 'space-between',
|
|
423
|
-
alignItems: 'center'
|
|
426
|
+
alignItems: 'center',
|
|
427
|
+
gap: '.75rem'
|
|
424
428
|
}
|
|
425
429
|
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
426
430
|
showSizeChanger: true,
|
|
@@ -435,6 +439,11 @@ const TableGrid = props => {
|
|
|
435
439
|
t: t,
|
|
436
440
|
columnsGroup: groupColumns,
|
|
437
441
|
triggerChangeColumns: triggerChangeColumns
|
|
442
|
+
}), showAdvanceFilter && /*#__PURE__*/_react.default.createElement(_AdvanceFilter.default, {
|
|
443
|
+
columns: columns,
|
|
444
|
+
t: t
|
|
445
|
+
// columnsGroup={groupColumns}
|
|
446
|
+
// triggerChangeColumns={triggerChangeColumns}
|
|
438
447
|
}))));
|
|
439
448
|
},
|
|
440
449
|
expandable: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type OptionType = {
|
|
3
|
+
value: any;
|
|
4
|
+
label: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
type Props<T> = {
|
|
8
|
+
options: T[];
|
|
9
|
+
value: any[];
|
|
10
|
+
onChange?: (value: any[]) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const CheckboxControl: <T extends OptionType>(props: Props<T>) => React.JSX.Element;
|
|
13
|
+
export default CheckboxControl;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 _rcMasterUi = require("rc-master-ui");
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
const CheckboxControl = props => {
|
|
12
|
+
const {
|
|
13
|
+
options,
|
|
14
|
+
value,
|
|
15
|
+
onChange
|
|
16
|
+
} = props;
|
|
17
|
+
const selected = (0, _react.useMemo)(() => {
|
|
18
|
+
return value ? value : [];
|
|
19
|
+
}, [value]);
|
|
20
|
+
const list = (0, _react.useMemo)(() => {
|
|
21
|
+
return options ? options : [];
|
|
22
|
+
}, [options]);
|
|
23
|
+
const onChangeValue = val => {
|
|
24
|
+
const findIndex = selected.findIndex(it => it === val);
|
|
25
|
+
if (findIndex > -1) {
|
|
26
|
+
const newVal = selected.filter(it => it !== val);
|
|
27
|
+
onChange?.(newVal);
|
|
28
|
+
} else {
|
|
29
|
+
const newVal = [...selected, val];
|
|
30
|
+
onChange?.(newVal);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
className: "d-flex flex-column gap-50",
|
|
35
|
+
style: {}
|
|
36
|
+
}, list.map((it, index) => {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
key: index,
|
|
39
|
+
className: "d-flex align-items-center"
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Checkbox, {
|
|
41
|
+
checked: selected.includes(it.value),
|
|
42
|
+
type: "checkbox",
|
|
43
|
+
className: "cursor-pointer me-50",
|
|
44
|
+
onChange: () => onChangeValue(it.value)
|
|
45
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, it.label));
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
var _default = exports.default = CheckboxControl;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColumnTable, IFormat } from "../../type";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
4
4
|
import type { ColumnsTable } from "../../type";
|
|
5
5
|
export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
6
6
|
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType>): ColumnsTable<RecordType>;
|
|
7
|
-
export declare const getValueCell: <T>(column:
|
|
8
|
-
export declare const renderContent: (column:
|
|
9
|
-
export declare const renderFilter: <RecordType>(column:
|
|
7
|
+
export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, format?: IFormat) => any;
|
|
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;
|
|
@@ -130,7 +130,12 @@ exports.getValueCell = getValueCell;
|
|
|
130
130
|
const renderContent = (column, value, record, index, format) => {
|
|
131
131
|
const cellValue = value instanceof Date ? (0, _utils.getDateString)(column, value) : value;
|
|
132
132
|
const content = getValueCell(column, cellValue, format);
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, column?.template ? typeof column.template === "function" ? column.template(
|
|
133
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, column?.template ? typeof column.template === "function" ? column.template({
|
|
134
|
+
value,
|
|
135
|
+
index,
|
|
136
|
+
rowData: record,
|
|
137
|
+
field: column.field
|
|
138
|
+
}) : column.template : content);
|
|
134
139
|
};
|
|
135
140
|
exports.renderContent = renderContent;
|
|
136
141
|
const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t) => {
|
|
@@ -257,11 +257,12 @@ const useColumns = config => {
|
|
|
257
257
|
width: col.width,
|
|
258
258
|
onResize: handleResize?.(col)
|
|
259
259
|
}),
|
|
260
|
-
onCell: data => {
|
|
260
|
+
onCell: (data, index) => {
|
|
261
261
|
return {
|
|
262
262
|
colSpan: groupColumns && data.children && col.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === col.field ? 0 : 1,
|
|
263
263
|
zIndex: data.children && col.field === firstNonGroupColumn?.field ? 11 : undefined,
|
|
264
|
-
|
|
264
|
+
...transformedColumn?.onCell?.(data, index),
|
|
265
|
+
className: (0, _classnames.default)(transformedColumn?.onCell?.(data, index).className ?? '', {
|
|
265
266
|
'cell-group': groupColumns && data.children,
|
|
266
267
|
'cell-group-fixed': groupColumns && data.children && col.field === firstNonGroupColumn?.field
|
|
267
268
|
})
|
|
@@ -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 {
|
|
4
|
+
import type { ColumnTable, GetRowKey } from "../type";
|
|
5
5
|
import type { SelectionSettings } from "../type";
|
|
6
6
|
import type { AnyObject } from "../type";
|
|
7
7
|
import type { Key } from "react";
|
|
@@ -26,15 +26,15 @@ export declare const customWeekStartEndFormat: (value: any, weekFormat: string)
|
|
|
26
26
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
27
27
|
export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
|
|
28
28
|
export declare const getDateString: <T>(column: ColumnTable<T>, value: any) => string;
|
|
29
|
-
export declare const getEditType: <T>(column:
|
|
30
|
-
export declare const isDisable: <T>(column:
|
|
29
|
+
export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
|
|
30
|
+
export declare const isDisable: <T>(column: ColumnTable<T>, rowData?: any) => boolean;
|
|
31
31
|
export declare const checkFieldKey: (key: string | undefined) => string;
|
|
32
32
|
export declare const convertLabelToTitle: (data: any[]) => any[];
|
|
33
33
|
export declare const convertArrayWithIndent: (inputArray: any[], parentIndent?: number) => any[];
|
|
34
34
|
export declare const getTemplate: (template: any) => React.ReactNode | React.ReactElement;
|
|
35
|
-
export declare const totalFixedWidth: <T>(columns:
|
|
35
|
+
export declare const totalFixedWidth: <T>(columns: ColumnsTable<T>, type: 'left' | 'right', selectionSettings?: SelectionSettings) => number;
|
|
36
36
|
export declare const isObjEmpty: (obj: any) => boolean;
|
|
37
|
-
export declare const getColumnsVisible: <T>(columns:
|
|
37
|
+
export declare const getColumnsVisible: <T>(columns: ColumnsTable<T>, index: number) => ColumnTable<T>[];
|
|
38
38
|
export declare const updateData: <Record_1 = AnyObject>(initData: Record_1[], rows: Record_1[], key: keyof Record_1) => Record_1[];
|
|
39
39
|
export declare const parseBooleanToValue: (value: boolean, type: 'boolean' | 'number') => number | boolean;
|
|
40
40
|
export declare const genPresets: (presets?: import("@ant-design/colors").PalettesProps) => import("antd/es/color-picker/interface").PresetsItem[];
|
|
@@ -64,8 +64,10 @@ export declare function addRows8(arr: any, n: number): {
|
|
|
64
64
|
};
|
|
65
65
|
export declare const transformColumns: <RecordType>(cols: ColumnsTable<RecordType>, convertColumns: any[], t?: any) => ColumnsTable<RecordType>;
|
|
66
66
|
export declare const transformColumns1: <RecordType>(cols: ColumnsTable<RecordType>, sortMultiple?: boolean) => ColumnsTable<RecordType>;
|
|
67
|
-
export declare const removeColumns: <RecordType>(columns:
|
|
67
|
+
export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType>[], groupColumns: string[]) => ColumnsTable<RecordType>;
|
|
68
68
|
export declare const convertFlatColumn: (array: ColumnsTable) => ColumnsTable[];
|
|
69
69
|
export declare const convertColumns: <RecordType>(cols: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
70
70
|
export declare const checkChild: (inputArray: any[]) => boolean;
|
|
71
|
-
export declare const isEditable: <RecordType>(column:
|
|
71
|
+
export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
|
|
72
|
+
export declare const isArraysEqual: (arr1: any[], arr2: any[]) => boolean;
|
|
73
|
+
export declare const editAbleColumns: <T>(columns: ColumnsTable<T>) => ColumnTable<T>[];
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.addRowIdArray = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
|
-
exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = void 0;
|
|
9
|
+
exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = void 0;
|
|
10
10
|
exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
11
11
|
exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemByKey = void 0;
|
|
12
12
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
13
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isEditable = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
13
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isEditable = exports.isDisable = exports.isColor = exports.isArraysEqual = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
14
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
15
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
16
16
|
var _uuid = require("uuid");
|
|
@@ -760,7 +760,7 @@ const removeColumns = (columns, groupColumns) => {
|
|
|
760
760
|
const newCol = {
|
|
761
761
|
...column
|
|
762
762
|
};
|
|
763
|
-
if (newCol.
|
|
763
|
+
if (newCol?.children && newCol?.children.length > 0) {
|
|
764
764
|
newCol.children = removeColumns(newCol.children, groupColumns);
|
|
765
765
|
}
|
|
766
766
|
return newCol;
|
|
@@ -839,4 +839,15 @@ const isEditable = (column, rowData) => {
|
|
|
839
839
|
}
|
|
840
840
|
return column?.editEnable;
|
|
841
841
|
};
|
|
842
|
-
exports.isEditable = isEditable;
|
|
842
|
+
exports.isEditable = isEditable;
|
|
843
|
+
const isArraysEqual = (arr1, arr2) => {
|
|
844
|
+
if (arr1.length !== arr2.length) {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
return arr1.every((element, index) => element === arr2[index]);
|
|
848
|
+
};
|
|
849
|
+
exports.isArraysEqual = isArraysEqual;
|
|
850
|
+
const editAbleColumns = columns => {
|
|
851
|
+
return columns.filter(col => col.field !== '#' && col.field !== 'index' && col.field !== 'command' && col.visible !== false);
|
|
852
|
+
};
|
|
853
|
+
exports.editAbleColumns = editAbleColumns;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'dayjs/locale/es';
|
|
3
3
|
import 'dayjs/locale/vi';
|
|
4
|
-
import type { AnyObject } from "../type";
|
|
5
|
-
import type { TableEditProps } from "../type";
|
|
4
|
+
import type { AnyObject, TableProps } from "../type";
|
|
6
5
|
import type { ColumnsTable } from "../type";
|
|
7
6
|
import type { GetRowKey } from "../type";
|
|
8
|
-
type Props<RecordType> =
|
|
7
|
+
type Props<RecordType> = TableProps<RecordType> & {
|
|
9
8
|
tableRef: any;
|
|
10
9
|
triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void;
|
|
11
10
|
triggerChangeData?: (newData: RecordType[], type: string) => void;
|
|
@@ -764,8 +764,9 @@ const GridEdit = props => {
|
|
|
764
764
|
};
|
|
765
765
|
const handleClickRowHeader = (row, col) => {
|
|
766
766
|
const newSelectedCells = new Set();
|
|
767
|
+
const tCols = (0, _hooks.editAbleColumns)(columns);
|
|
767
768
|
for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
|
|
768
|
-
for (let c = Math.min(
|
|
769
|
+
for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
|
|
769
770
|
newSelectedCells.add(`${r}-${c}`);
|
|
770
771
|
}
|
|
771
772
|
}
|
|
@@ -1272,6 +1273,29 @@ const GridEdit = props => {
|
|
|
1272
1273
|
return {
|
|
1273
1274
|
...column,
|
|
1274
1275
|
className: 'rc-ui-cell-editable',
|
|
1276
|
+
onCell: (record, rowIndex) => {
|
|
1277
|
+
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
1278
|
+
return {
|
|
1279
|
+
onPaste: event => {
|
|
1280
|
+
if (editingKey === '') {
|
|
1281
|
+
handlePaste(record, colIndex + 1, rowNumber, event);
|
|
1282
|
+
event.preventDefault();
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
onCopy: e => {
|
|
1286
|
+
if (editingKey === '') {
|
|
1287
|
+
handleCopy(e);
|
|
1288
|
+
e.preventDefault();
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
onClick: () => {
|
|
1292
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1293
|
+
setEditingKey('');
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
tabIndex: (rowIndex ?? 0) * columns.length + colIndex
|
|
1297
|
+
};
|
|
1298
|
+
},
|
|
1275
1299
|
render: (value, record, rowIndex) => {
|
|
1276
1300
|
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
1277
1301
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1301,7 +1325,7 @@ const GridEdit = props => {
|
|
|
1301
1325
|
onKeyDown: event => {
|
|
1302
1326
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1303
1327
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1304
|
-
if (record[rowKey] !== editingKey) {
|
|
1328
|
+
if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
|
|
1305
1329
|
// ~~ khi editingKey = ''
|
|
1306
1330
|
event.preventDefault();
|
|
1307
1331
|
event.stopPropagation();
|
|
@@ -1377,14 +1401,14 @@ const GridEdit = props => {
|
|
|
1377
1401
|
}
|
|
1378
1402
|
},
|
|
1379
1403
|
onDoubleClick: event => {
|
|
1380
|
-
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
1404
|
+
if (!isEditing(record) && record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
|
|
1381
1405
|
handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
|
|
1382
1406
|
handleCellClick(rowNumber, record, column);
|
|
1383
1407
|
}
|
|
1384
1408
|
},
|
|
1385
1409
|
onClick: () => {
|
|
1386
1410
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1387
|
-
|
|
1411
|
+
setEditingKey('');
|
|
1388
1412
|
}
|
|
1389
1413
|
},
|
|
1390
1414
|
// className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
@@ -1396,8 +1420,9 @@ const GridEdit = props => {
|
|
|
1396
1420
|
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
1397
1421
|
'data-col-index': colIndex,
|
|
1398
1422
|
'data-row-index': rowNumber,
|
|
1399
|
-
editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record)
|
|
1423
|
+
editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
|
|
1400
1424
|
cellEditing,
|
|
1425
|
+
t,
|
|
1401
1426
|
// editing: isEditing(record) && rowEditable?.(record) !== false,
|
|
1402
1427
|
tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
|
|
1403
1428
|
style: isPasteDragging ? {
|
|
@@ -1469,10 +1494,10 @@ const GridEdit = props => {
|
|
|
1469
1494
|
width: '100%'
|
|
1470
1495
|
},
|
|
1471
1496
|
items: toolbarItemsBottom ?? [],
|
|
1472
|
-
mode: 'scroll'
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1497
|
+
mode: 'scroll',
|
|
1498
|
+
onClick: ({}) => {
|
|
1499
|
+
setEditingKey('');
|
|
1500
|
+
}
|
|
1476
1501
|
}));
|
|
1477
1502
|
};
|
|
1478
1503
|
const onSelectChange = keys => {
|
|
@@ -84,7 +84,7 @@ export type ToolbarClick = {
|
|
|
84
84
|
item: any;
|
|
85
85
|
column: any;
|
|
86
86
|
};
|
|
87
|
-
export type
|
|
87
|
+
export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title'> & {
|
|
88
88
|
field?: string;
|
|
89
89
|
key?: any;
|
|
90
90
|
type?: IColumnType;
|
|
@@ -111,9 +111,9 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
111
111
|
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
112
112
|
showTooltip?: boolean;
|
|
113
113
|
tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
114
|
-
headerTemplate?: React.ReactNode | React.ReactElement | ((column:
|
|
114
|
+
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
|
|
115
115
|
commandItems?: CommandItem[];
|
|
116
|
-
children?:
|
|
116
|
+
children?: ColumnTable<RecordType>[];
|
|
117
117
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
118
118
|
disable?: boolean | ((rowData: any) => boolean);
|
|
119
119
|
editEnable?: boolean | ((rowData: any) => boolean);
|
|
@@ -133,25 +133,8 @@ export type ColumnTemplate<RecordType> = {
|
|
|
133
133
|
index: number;
|
|
134
134
|
field: string;
|
|
135
135
|
};
|
|
136
|
-
export type
|
|
137
|
-
|
|
138
|
-
disable?: boolean | ((rowData: any) => boolean);
|
|
139
|
-
editEnable?: boolean | ((rowData: any) => boolean);
|
|
140
|
-
isClearable?: boolean;
|
|
141
|
-
maxDate?: any;
|
|
142
|
-
minDate?: any;
|
|
143
|
-
maxTime?: any;
|
|
144
|
-
minTime?: any;
|
|
145
|
-
max?: number;
|
|
146
|
-
min?: number;
|
|
147
|
-
editSelectSettings?: IEditSelectSettings;
|
|
148
|
-
children?: ColumnEditType<RecordType>[];
|
|
149
|
-
};
|
|
150
|
-
export type ColumnsType<RecordType = AnyObject> = ColumnType<RecordType>[];
|
|
151
|
-
export type ColumnsEditType<RecordType = AnyObject> = ColumnEditType<RecordType>[];
|
|
152
|
-
export type ColumnTable<RecordType = AnyObject> = ColumnEditType<RecordType> | ColumnType<RecordType>;
|
|
153
|
-
export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
|
|
154
|
-
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
136
|
+
export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
|
|
137
|
+
export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
155
138
|
editAble?: boolean;
|
|
156
139
|
groupAble?: boolean;
|
|
157
140
|
groupColumns?: string[];
|
|
@@ -172,6 +155,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
172
155
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
|
|
173
156
|
toolbarItems?: ToolbarItem[];
|
|
174
157
|
showColumnChoose?: boolean;
|
|
158
|
+
showAdvanceFilter?: boolean;
|
|
175
159
|
onFilter?: (query: {
|
|
176
160
|
field: string;
|
|
177
161
|
key: string;
|
|
@@ -180,7 +164,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
180
164
|
value: any;
|
|
181
165
|
}[]) => void;
|
|
182
166
|
onSorter?: (args: {
|
|
183
|
-
column:
|
|
167
|
+
column: ColumnTable<RecordType>;
|
|
184
168
|
columnKey: string;
|
|
185
169
|
field: string;
|
|
186
170
|
direction: 'Ascending' | 'Descending' | null;
|
|
@@ -203,9 +187,6 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
203
187
|
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
204
188
|
showEmptyText?: boolean;
|
|
205
189
|
commandSettings?: CommandSettings;
|
|
206
|
-
}
|
|
207
|
-
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
208
|
-
columns: ColumnsTable<RecordType>;
|
|
209
190
|
onCellPaste?: ICellPasteModel<RecordType>;
|
|
210
191
|
onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
|
|
211
192
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
@@ -220,7 +201,7 @@ export type ICellClick = {
|
|
|
220
201
|
cellValue: any;
|
|
221
202
|
rowData: any;
|
|
222
203
|
};
|
|
223
|
-
export type GridTableProps<RecordType = AnyObject> = TableProps<RecordType
|
|
204
|
+
export type GridTableProps<RecordType = AnyObject> = TableProps<RecordType>;
|
|
224
205
|
export interface CommandItem {
|
|
225
206
|
id: string;
|
|
226
207
|
type?: string;
|