es-grid-template 0.1.1 → 0.1.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/ColumnsChoose.js +25 -8
- package/es/grid-component/Command.js +6 -5
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +265 -248
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +24 -16
- package/es/grid-component/TableGrid.js +4 -2
- package/es/grid-component/async-select/index.d.ts +9 -0
- package/es/grid-component/async-select/index.js +35 -0
- package/es/grid-component/hooks/constant.d.ts +10 -0
- package/es/grid-component/hooks/constant.js +11 -1
- package/es/grid-component/hooks/useColumns/index.js +11 -7
- package/es/grid-component/hooks/utils.d.ts +2 -0
- package/es/grid-component/hooks/utils.js +11 -0
- package/es/grid-component/index.d.ts +3 -2
- package/es/grid-component/styles.scss +101 -30
- package/es/grid-component/table/Grid.js +7 -7
- package/es/grid-component/table/GridEdit.d.ts +1 -1
- package/es/grid-component/table/GridEdit.js +21 -16
- package/es/grid-component/type.d.ts +6 -3
- package/es/grid-component/useContext.d.ts +2 -1
- package/es/index.d.ts +1 -1
- package/lib/grid-component/ColumnsChoose.js +25 -8
- package/lib/grid-component/Command.js +7 -5
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +262 -245
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +24 -16
- package/lib/grid-component/TableGrid.js +4 -2
- package/lib/grid-component/async-select/index.d.ts +9 -0
- package/lib/grid-component/async-select/index.js +44 -0
- package/lib/grid-component/hooks/constant.d.ts +10 -0
- package/lib/grid-component/hooks/constant.js +12 -2
- package/lib/grid-component/hooks/useColumns/index.js +11 -7
- package/lib/grid-component/hooks/utils.d.ts +2 -0
- package/lib/grid-component/hooks/utils.js +16 -3
- package/lib/grid-component/index.d.ts +3 -2
- package/lib/grid-component/styles.scss +101 -30
- package/lib/grid-component/table/Grid.js +7 -7
- package/lib/grid-component/table/GridEdit.d.ts +1 -1
- package/lib/grid-component/table/GridEdit.js +21 -16
- package/lib/grid-component/type.d.ts +6 -3
- package/lib/grid-component/useContext.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/package.json +4 -15
|
@@ -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-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;z-index:-1;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;z-index:-1;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
|
|
5
|
+
})([".ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;z-index:-1;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;z-index:-1;}}.react-resizable{position:relative;background-clip:padding-box;}.react-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, props => props.heightTable ? `${props.heightTable}px` : undefined);
|
|
@@ -56,6 +56,7 @@ const InternalTable = props => {
|
|
|
56
56
|
onFilterClick,
|
|
57
57
|
editAble,
|
|
58
58
|
rowKey,
|
|
59
|
+
onDataChange,
|
|
59
60
|
...rest
|
|
60
61
|
} = props;
|
|
61
62
|
const locale = lang && lang === 'en' ? en : vi;
|
|
@@ -86,11 +87,9 @@ const InternalTable = props => {
|
|
|
86
87
|
if (typeof rowKey === 'function') {
|
|
87
88
|
return rowKey;
|
|
88
89
|
}
|
|
89
|
-
|
|
90
90
|
// @ts-ignore
|
|
91
91
|
return record => record?.[rowKey];
|
|
92
92
|
}, [rowKey]);
|
|
93
|
-
console.log('getRowKey', getRowKey);
|
|
94
93
|
const handleSearch = (selectedKeys, confirm) => {
|
|
95
94
|
confirm();
|
|
96
95
|
};
|
|
@@ -231,32 +230,37 @@ const InternalTable = props => {
|
|
|
231
230
|
return cols.map((col, index) => {
|
|
232
231
|
const currentPath = [...parentPath, index];
|
|
233
232
|
// @ts-ignore
|
|
234
|
-
if (!col?.dataIndex && !col.key) {
|
|
233
|
+
if (!col?.dataIndex && !col.key && !col.field) {
|
|
235
234
|
return col;
|
|
236
235
|
}
|
|
236
|
+
const transformedColumn = {
|
|
237
|
+
...col,
|
|
238
|
+
dataIndex: col.field ?? col.dataIndex,
|
|
239
|
+
title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
|
|
240
|
+
ellipsis: col.ellipsis !== false,
|
|
241
|
+
align: col.textAlign ?? col.align,
|
|
242
|
+
fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed
|
|
243
|
+
};
|
|
237
244
|
if (col.children) {
|
|
238
245
|
return {
|
|
239
|
-
...
|
|
240
|
-
title: col.headerText ?? col.title,
|
|
241
|
-
ellipsis: col.ellipsis !== false,
|
|
246
|
+
...transformedColumn,
|
|
242
247
|
children: transformColumns(col.children, currentPath)
|
|
243
248
|
};
|
|
244
249
|
}
|
|
245
250
|
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.dataIndex === '#') {
|
|
246
251
|
return {
|
|
247
|
-
...
|
|
248
|
-
title: col.headerText ?? col.title,
|
|
249
|
-
ellipsis: col.ellipsis !== false
|
|
252
|
+
...transformedColumn
|
|
250
253
|
};
|
|
251
254
|
}
|
|
252
255
|
return {
|
|
253
256
|
...getColumnSearchProps(col),
|
|
254
|
-
...
|
|
255
|
-
dataIndex: col.field ?? col.dataIndex,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
...transformedColumn,
|
|
258
|
+
// dataIndex: col.field ?? col.dataIndex,
|
|
259
|
+
// key: col.field ?? col.dataIndex ?? col.key,
|
|
260
|
+
// title: col.headerText ?? col.title,
|
|
261
|
+
// ellipsis: col.ellipsis !== false,
|
|
262
|
+
// align: col.textAlign ?? col.align,
|
|
263
|
+
// fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed,
|
|
260
264
|
onFilter: (value, record) => {
|
|
261
265
|
// @ts-ignore
|
|
262
266
|
return record[col.field ?? col.dataIndex];
|
|
@@ -275,7 +279,11 @@ const InternalTable = props => {
|
|
|
275
279
|
// console.log('mergedColumns', mergedColumns)
|
|
276
280
|
|
|
277
281
|
const triggerChangeColumns = () => {};
|
|
278
|
-
const triggerChangeData =
|
|
282
|
+
const triggerChangeData = newData => {
|
|
283
|
+
setIsManualUpdate(true);
|
|
284
|
+
setData(newData);
|
|
285
|
+
onDataChange?.(newData);
|
|
286
|
+
};
|
|
279
287
|
const TableComponent = editAble ? GridEdit : Grid;
|
|
280
288
|
return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
281
289
|
tableRef: tableRef,
|
|
@@ -97,6 +97,7 @@ const TableGrid = props => {
|
|
|
97
97
|
t,
|
|
98
98
|
lang,
|
|
99
99
|
contextMenuOpen,
|
|
100
|
+
className,
|
|
100
101
|
contextMenuItems: propContextMenuItems,
|
|
101
102
|
contextMenuHidden,
|
|
102
103
|
contextMenuClick,
|
|
@@ -280,7 +281,8 @@ const TableGrid = props => {
|
|
|
280
281
|
});
|
|
281
282
|
} else {
|
|
282
283
|
// @ts-ignore
|
|
283
|
-
setMergedSelectedKeys([selectedRow[rowKey]])
|
|
284
|
+
// setMergedSelectedKeys([selectedRow[rowKey]])
|
|
285
|
+
|
|
284
286
|
rowSelected?.({
|
|
285
287
|
selected: [selectedRow],
|
|
286
288
|
type: 'rowSelected',
|
|
@@ -321,7 +323,7 @@ const TableGrid = props => {
|
|
|
321
323
|
dataSource: dataSource
|
|
322
324
|
// className={styles.customTable}
|
|
323
325
|
,
|
|
324
|
-
className: classNames(
|
|
326
|
+
className: classNames(className, {
|
|
325
327
|
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
326
328
|
}, styles.customTable),
|
|
327
329
|
bordered: true,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
|
+
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
+
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
5
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
debounceTimeout?: number;
|
|
7
|
+
defaultOptions?: OptionType[];
|
|
8
|
+
}
|
|
9
|
+
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import { Select } from "rc-master-ui";
|
|
5
|
+
export function AsyncSelect({
|
|
6
|
+
loadOptions,
|
|
7
|
+
debounceTimeout = 500,
|
|
8
|
+
defaultOptions,
|
|
9
|
+
...props
|
|
10
|
+
}) {
|
|
11
|
+
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
12
|
+
const debounceFetcher = useMemo(() => {
|
|
13
|
+
const fetchOptions = value => {
|
|
14
|
+
if (value.trim().length === 0) {
|
|
15
|
+
setOptions(defaultOptions ?? []);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (loadOptions) {
|
|
19
|
+
loadOptions(value, newOptions => {
|
|
20
|
+
setOptions(newOptions);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return debounce(fetchOptions, debounceTimeout);
|
|
25
|
+
}, [loadOptions, debounceTimeout]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setOptions(defaultOptions ?? []);
|
|
28
|
+
}, [defaultOptions]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
30
|
+
filterOption: loadOptions ? false : props?.filterOption,
|
|
31
|
+
onSearch: debounceFetcher,
|
|
32
|
+
onSelect: () => setOptions(defaultOptions ?? []),
|
|
33
|
+
options: options
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
@@ -60,3 +60,13 @@ declare const SortOrder: {
|
|
|
60
60
|
descend: string;
|
|
61
61
|
};
|
|
62
62
|
export default SortOrder;
|
|
63
|
+
export declare const valueToBoolean: {
|
|
64
|
+
true: boolean;
|
|
65
|
+
false: boolean;
|
|
66
|
+
1: boolean;
|
|
67
|
+
0: boolean;
|
|
68
|
+
};
|
|
69
|
+
export declare const booleanToValue: {
|
|
70
|
+
true: number;
|
|
71
|
+
false: number;
|
|
72
|
+
};
|
|
@@ -226,4 +226,14 @@ const SortOrder = {
|
|
|
226
226
|
*/
|
|
227
227
|
descend: 'Descending'
|
|
228
228
|
};
|
|
229
|
-
export default SortOrder;
|
|
229
|
+
export default SortOrder;
|
|
230
|
+
export const valueToBoolean = {
|
|
231
|
+
true: true,
|
|
232
|
+
false: false,
|
|
233
|
+
1: true,
|
|
234
|
+
0: false
|
|
235
|
+
};
|
|
236
|
+
export const booleanToValue = {
|
|
237
|
+
true: 1,
|
|
238
|
+
false: 0
|
|
239
|
+
};
|
|
@@ -7,6 +7,7 @@ import moment from "moment/moment";
|
|
|
7
7
|
import React, { Fragment } from "react";
|
|
8
8
|
import { DatePicker, Input, Select } from "rc-master-ui";
|
|
9
9
|
import CheckboxFilter from "../../CheckboxFilter";
|
|
10
|
+
// import {ColorPicker} from "antd";
|
|
10
11
|
const {
|
|
11
12
|
RangePicker
|
|
12
13
|
} = DatePicker;
|
|
@@ -62,13 +63,15 @@ export const getValueCell = (column, value, format) => {
|
|
|
62
63
|
case 'boolean':
|
|
63
64
|
return value ? 'true' : 'false';
|
|
64
65
|
case 'color':
|
|
65
|
-
return /*#__PURE__*/React.createElement(Fragment, null,
|
|
66
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
66
67
|
className: 'w-100 h-100',
|
|
67
68
|
style: {
|
|
68
|
-
backgroundColor: value,
|
|
69
|
-
border: '1px solid #f0f0f0'
|
|
69
|
+
backgroundColor: isColor(value) ? value : '#fff',
|
|
70
|
+
border: '1px solid #f0f0f0',
|
|
71
|
+
height: '100%',
|
|
72
|
+
minHeight: 20
|
|
70
73
|
}
|
|
71
|
-
})
|
|
74
|
+
}));
|
|
72
75
|
case 'checkbox':
|
|
73
76
|
return /*#__PURE__*/React.createElement(Input, {
|
|
74
77
|
checked: !!content,
|
|
@@ -163,8 +166,9 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
163
166
|
height: '100%'
|
|
164
167
|
},
|
|
165
168
|
value: dateValue,
|
|
166
|
-
defaultValue: dateValue
|
|
167
|
-
placeholder: column?.placeholder
|
|
169
|
+
defaultValue: dateValue
|
|
170
|
+
// placeholder={t ? t(column?.placeholder) : column?.placeholder}
|
|
171
|
+
,
|
|
168
172
|
onChange: (date, dateString) => {
|
|
169
173
|
const newDateValue = dateString ? moment(convertDayjsToDate(dateString, dateFormat)).format() : null;
|
|
170
174
|
setSelectedKeys(newDateValue ? [newDateValue] : []);
|
|
@@ -410,7 +414,7 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
410
414
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
411
415
|
className: 'mb-1'
|
|
412
416
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
413
|
-
placeholder: `Search
|
|
417
|
+
placeholder: `Search`,
|
|
414
418
|
value: selectedKeys[0],
|
|
415
419
|
onChange: e => setSelectedKeys(e.target.value ? [e.target.value] : [])
|
|
416
420
|
// onPressEnter={() => handleSearch(selectedKeys as string[], confirm)}
|
|
@@ -33,3 +33,5 @@ export declare const totalFixedWidth: <T>(columns: ColumnsType<T>, type: 'left'
|
|
|
33
33
|
export declare const isObjEmpty: (obj: any) => boolean;
|
|
34
34
|
export declare const getColumnsVisible: <T>(columns: ColumnsType<T>, index: number) => import("../type").ColumnType<T>[];
|
|
35
35
|
export declare const updateData: <Record_1 = AnyObject>(initData: Record_1[], rows: Record_1[], key: keyof Record_1) => Record_1[];
|
|
36
|
+
export declare const parseBooleanToValue: (value: boolean, type: 'boolean' | 'number') => number | boolean;
|
|
37
|
+
export declare const genPresets: (presets?: import("@ant-design/colors").PalettesProps) => import("antd/es/color-picker/interface").PresetsItem[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
2
|
import moment from "moment/moment";
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { presetPalettes } from "@ant-design/colors";
|
|
4
5
|
export const newGuid = () => {
|
|
5
6
|
for (let i = 0; i < 20; i++) {
|
|
6
7
|
// @ts-ignore
|
|
@@ -317,4 +318,14 @@ export const updateData = (initData, rows, key) => {
|
|
|
317
318
|
// Thêm các phần tử mới chưa có trong initialData
|
|
318
319
|
const newRows = rows.filter(row => !initData.some(item => item[key] === row[key]));
|
|
319
320
|
return [...updatedData, ...newRows];
|
|
321
|
+
};
|
|
322
|
+
export const parseBooleanToValue = (value, type) => {
|
|
323
|
+
return type === 'boolean' ? value : Number(value);
|
|
324
|
+
};
|
|
325
|
+
export const genPresets = (presets = presetPalettes) => {
|
|
326
|
+
return Object.entries(presets).map(([label, colors]) => ({
|
|
327
|
+
label,
|
|
328
|
+
colors,
|
|
329
|
+
key: label
|
|
330
|
+
}));
|
|
320
331
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import InternalTable from './InternalTable';
|
|
2
|
-
import type { ColumnsTable, TableProps, ColumnTable } from './type';
|
|
3
|
-
|
|
2
|
+
import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem } from './type';
|
|
3
|
+
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
4
|
+
export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem };
|
|
4
5
|
export default InternalTable;
|
|
@@ -25,31 +25,22 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
25
25
|
min-width: 200px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.react-resizable {
|
|
29
|
-
position: relative;
|
|
30
|
-
background-clip: padding-box;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.react-resizable-handle {
|
|
34
|
-
position: absolute;
|
|
35
|
-
//right: 10px;
|
|
36
|
-
right: 0px;
|
|
37
|
-
bottom: 0;
|
|
38
|
-
z-index: 1;
|
|
39
|
-
width: 5px;
|
|
40
|
-
height: 100%;
|
|
41
|
-
cursor: col-resize;
|
|
42
|
-
//transform: translateY(-50%);
|
|
43
|
-
&.none {
|
|
44
|
-
cursor: auto;
|
|
45
|
-
display: none;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
28
|
// -------------- Table -------------
|
|
50
29
|
|
|
51
30
|
.#{$prefix}-table-wrapper {
|
|
52
31
|
|
|
32
|
+
&.table-none-column-select {
|
|
33
|
+
.#{$prefix}-table-cell {
|
|
34
|
+
&.#{$prefix}-table-selection-column {
|
|
35
|
+
padding: 0 !important;
|
|
36
|
+
overflow: hidden !important;
|
|
37
|
+
border-inline-end: 0 !important;
|
|
38
|
+
//flex: 0 0 0 !important;
|
|
39
|
+
//width: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
53
44
|
.#{$prefix}-table-tbody-virtual {
|
|
54
45
|
.#{$prefix}-table-cell {
|
|
55
46
|
border-bottom: 1px solid $tableBorderColor;
|
|
@@ -302,10 +293,55 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
302
293
|
}
|
|
303
294
|
}
|
|
304
295
|
|
|
296
|
+
.ui-rc-checkbox-wrapper {
|
|
297
|
+
.ui-rc-checkbox {
|
|
298
|
+
background-color: red;
|
|
299
|
+
}
|
|
300
|
+
.ui-rc-checkbox-input {
|
|
301
|
+
&:focus-visible {
|
|
302
|
+
outline: none;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
305
307
|
|
|
306
308
|
.ant-input, .ant-picker{
|
|
307
309
|
border-radius: 0;
|
|
308
310
|
}
|
|
311
|
+
|
|
312
|
+
// color picker
|
|
313
|
+
|
|
314
|
+
.ant-color-picker-trigger{
|
|
315
|
+
height: 100%;
|
|
316
|
+
border-radius: 0;
|
|
317
|
+
.ant-color-picker-color-block {
|
|
318
|
+
height: 100%;
|
|
319
|
+
width: 100%;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
// ------------ select ---------------
|
|
326
|
+
|
|
327
|
+
.ui-rc-table-select-single .ui-rc-table-select-selector,
|
|
328
|
+
.ui-rc-select-single .ui-rc-select-selector {
|
|
329
|
+
|
|
330
|
+
border-radius: 0;
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.ui-rc-table-select-single:not(.ui-rc-table-select-customize-input) {
|
|
335
|
+
.ui-rc-table-select-selector {
|
|
336
|
+
.ui-rc-table-select-selection-search-input {
|
|
337
|
+
height: auto;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// ------------ select ---------------
|
|
343
|
+
|
|
344
|
+
|
|
309
345
|
}
|
|
310
346
|
&.cell-editable {
|
|
311
347
|
padding: 0;
|
|
@@ -321,6 +357,9 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
321
357
|
.ui-rc_content {
|
|
322
358
|
padding: 5px 8px;
|
|
323
359
|
}
|
|
360
|
+
.ui-rc_content:has(.ant-color-picker-trigger) {
|
|
361
|
+
padding: 1px 8px;
|
|
362
|
+
}
|
|
324
363
|
}
|
|
325
364
|
}
|
|
326
365
|
|
|
@@ -345,6 +384,15 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
345
384
|
}
|
|
346
385
|
}
|
|
347
386
|
}
|
|
387
|
+
//.ui-rc-checkbox-input {
|
|
388
|
+
// &:focus-visible {
|
|
389
|
+
// outline: none;
|
|
390
|
+
// }
|
|
391
|
+
//}
|
|
392
|
+
|
|
393
|
+
.ui-rc-checkbox .ui-rc-checkbox-input:focus-visible+.ui-rc-checkbox-inner {
|
|
394
|
+
outline: none;
|
|
395
|
+
}
|
|
348
396
|
|
|
349
397
|
.#{$prefix}-checkbox {
|
|
350
398
|
&.#{$prefix}-checkbox-checked {
|
|
@@ -486,6 +534,8 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
486
534
|
}
|
|
487
535
|
}
|
|
488
536
|
|
|
537
|
+
|
|
538
|
+
|
|
489
539
|
//.#{$prefix}-table-wrapper .#{$prefix}-table.#{$prefix}-table-bordered >.#{$prefix}-table-container >.#{$prefix}-table-content >table >tbody>tr>td >.#{$prefix}-table-expanded-row-fixed {
|
|
490
540
|
// border-inline-end: 1px solid $tableBorderColor;
|
|
491
541
|
//}
|
|
@@ -530,16 +580,37 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
530
580
|
}
|
|
531
581
|
|
|
532
582
|
|
|
533
|
-
.ui-rc-table-wrapper
|
|
534
|
-
.ui-rc-table
|
|
535
|
-
.ui-rc-table-
|
|
536
|
-
.ui-rc-table-
|
|
537
|
-
.ui-rc-table-
|
|
538
|
-
.ui-rc-table-
|
|
539
|
-
.ui-rc-table-
|
|
540
|
-
.ui-rc-table-
|
|
541
|
-
|
|
583
|
+
.ui-rc-table-wrapper {
|
|
584
|
+
.ui-rc-table.ui-rc-table-small {
|
|
585
|
+
.ui-rc-table-title,
|
|
586
|
+
.ui-rc-table-footer,
|
|
587
|
+
.ui-rc-table-cell,
|
|
588
|
+
.ui-rc-table-thead > tr > th,
|
|
589
|
+
.ui-rc-table-tbody > tr > th,
|
|
590
|
+
.ui-rc-table-tbody > tr > td,
|
|
591
|
+
tfoot > tr > th,
|
|
592
|
+
tfoot > tr > td {
|
|
593
|
+
padding: 5px 8px;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
542
596
|
}
|
|
597
|
+
.ui-rc-table-wrapper {
|
|
598
|
+
.ui-rc-table.ui-rc-table-small {
|
|
599
|
+
.ui-rc-table-cell {
|
|
600
|
+
&:has(.ant-color-picker-trigger) {
|
|
601
|
+
padding: 1px 8px;
|
|
602
|
+
}
|
|
603
|
+
.ant-color-picker-trigger{
|
|
604
|
+
width: 100%;
|
|
605
|
+
min-height: 20px;
|
|
606
|
+
.ant-color-picker-clear {
|
|
607
|
+
height: 20px;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
543
614
|
|
|
544
615
|
|
|
545
616
|
//ui-rc-table-ping-right
|
|
@@ -2,16 +2,16 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { Fragment, useMemo } from 'react';
|
|
3
3
|
import { GridStyle } from "../GridStyle";
|
|
4
4
|
import TableGrid from "../TableGrid";
|
|
5
|
-
import EditableCell from "../EditableCell";
|
|
6
5
|
import Command from "../Command";
|
|
6
|
+
import { renderContent } from "../hooks/useColumns";
|
|
7
7
|
const Grid = props => {
|
|
8
8
|
const {
|
|
9
9
|
columns,
|
|
10
10
|
height,
|
|
11
11
|
tableRef,
|
|
12
|
-
className,
|
|
13
12
|
components,
|
|
14
13
|
style,
|
|
14
|
+
format,
|
|
15
15
|
...rest
|
|
16
16
|
} = props;
|
|
17
17
|
const transformColumns = React.useCallback(cols => {
|
|
@@ -58,7 +58,10 @@ const Grid = props => {
|
|
|
58
58
|
}) : null))
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return {
|
|
62
|
+
...transformedColumn,
|
|
63
|
+
render: (value, record, rowIndex) => renderContent(column, value, record, rowIndex, format)
|
|
64
|
+
};
|
|
62
65
|
});
|
|
63
66
|
}, []);
|
|
64
67
|
const mergedColumns = useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
@@ -70,10 +73,7 @@ const Grid = props => {
|
|
|
70
73
|
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
71
74
|
tableRef: tableRef,
|
|
72
75
|
components: {
|
|
73
|
-
...components
|
|
74
|
-
body: {
|
|
75
|
-
cell: EditableCell
|
|
76
|
-
}
|
|
76
|
+
...components
|
|
77
77
|
},
|
|
78
78
|
columns: mergedColumns,
|
|
79
79
|
style: {
|
|
@@ -6,7 +6,7 @@ import type { GetRowKey } from "../type";
|
|
|
6
6
|
type Props<RecordType> = TableEditProps<RecordType> & {
|
|
7
7
|
tableRef: any;
|
|
8
8
|
triggerChangeColumns?: () => void;
|
|
9
|
-
triggerChangeData?: () => void;
|
|
9
|
+
triggerChangeData?: (newData: RecordType[], type: string) => void;
|
|
10
10
|
getRowKey: GetRowKey<RecordType>;
|
|
11
11
|
};
|
|
12
12
|
declare const GridEdit: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
@@ -30,11 +30,13 @@ const GridEdit = props => {
|
|
|
30
30
|
selectionSettings,
|
|
31
31
|
height,
|
|
32
32
|
format,
|
|
33
|
-
onDataChange,
|
|
33
|
+
// onDataChange,
|
|
34
|
+
triggerChangeData,
|
|
34
35
|
onCellPaste,
|
|
35
36
|
onCellChange,
|
|
36
37
|
style,
|
|
37
38
|
getRowKey,
|
|
39
|
+
className,
|
|
38
40
|
...rest
|
|
39
41
|
} = props;
|
|
40
42
|
|
|
@@ -348,6 +350,7 @@ const GridEdit = props => {
|
|
|
348
350
|
...item,
|
|
349
351
|
...row
|
|
350
352
|
});
|
|
353
|
+
triggerChangeData?.(newData, 'onChange');
|
|
351
354
|
|
|
352
355
|
// trigger DataChange
|
|
353
356
|
// setData(newData);
|
|
@@ -369,14 +372,16 @@ const GridEdit = props => {
|
|
|
369
372
|
type,
|
|
370
373
|
newState,
|
|
371
374
|
prevState,
|
|
372
|
-
option
|
|
375
|
+
option,
|
|
376
|
+
field
|
|
373
377
|
} = args;
|
|
374
378
|
|
|
375
379
|
// console.log('newState', newState)
|
|
376
380
|
//
|
|
377
381
|
// console.log('getValues()', getValues())
|
|
378
382
|
|
|
379
|
-
const newRecord = getValues()
|
|
383
|
+
// const newRecord = getValues()
|
|
384
|
+
|
|
380
385
|
if (type === 'enter') {
|
|
381
386
|
console.log('aaaaaa enter');
|
|
382
387
|
}
|
|
@@ -390,20 +395,14 @@ const GridEdit = props => {
|
|
|
390
395
|
const callbackRecord = callbackData;
|
|
391
396
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
392
397
|
setValue(name, value);
|
|
393
|
-
|
|
394
|
-
// if (listObjectDate.includes(name) && value) {
|
|
395
|
-
// setValue(name, new Date(value))
|
|
396
|
-
// } else {
|
|
397
|
-
// setValue(name, value)
|
|
398
|
-
// }
|
|
399
398
|
});
|
|
400
|
-
onSubmit(
|
|
399
|
+
onSubmit(callbackRecord);
|
|
401
400
|
};
|
|
402
401
|
if (onCellChange) {
|
|
403
402
|
if (onCellChange.length > 1) {
|
|
404
403
|
console.log('onCellChange Callback');
|
|
405
404
|
onCellChange({
|
|
406
|
-
field
|
|
405
|
+
field,
|
|
407
406
|
indexCol: 1,
|
|
408
407
|
type: 'onChange',
|
|
409
408
|
value: newState,
|
|
@@ -415,11 +414,9 @@ const GridEdit = props => {
|
|
|
415
414
|
sumValue: []
|
|
416
415
|
}, handleChangeCallback);
|
|
417
416
|
} else {
|
|
418
|
-
// const aaaa = updateData(dataSource, newRecord, rowKey as any)
|
|
419
|
-
|
|
420
417
|
console.log('onCellChange');
|
|
421
418
|
onCellChange({
|
|
422
|
-
field
|
|
419
|
+
field,
|
|
423
420
|
indexCol: 1,
|
|
424
421
|
type: 'onChange',
|
|
425
422
|
option,
|
|
@@ -693,6 +690,14 @@ const GridEdit = props => {
|
|
|
693
690
|
handleEdit(record, col, col.editType, event);
|
|
694
691
|
}
|
|
695
692
|
},
|
|
693
|
+
// onMouseDown: (event) => {
|
|
694
|
+
// handleMouseDown(rowIndex, colIndex, event)
|
|
695
|
+
// },
|
|
696
|
+
//
|
|
697
|
+
// onMouseEnter: () => {
|
|
698
|
+
// handleMouseEnter(rowIndex, colIndex)
|
|
699
|
+
// },
|
|
700
|
+
|
|
696
701
|
onClick: () => {
|
|
697
702
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
698
703
|
setEditingKey('');
|
|
@@ -727,7 +732,7 @@ const GridEdit = props => {
|
|
|
727
732
|
onMouseEnter: () => handleMouseEnter(rowIndex, colIndex)
|
|
728
733
|
}, /*#__PURE__*/React.createElement("div", {
|
|
729
734
|
className: 'ui-rc_content'
|
|
730
|
-
}, renderContent(col, value, record, rowIndex)));
|
|
735
|
+
}, renderContent(col, value, record, rowIndex, format)));
|
|
731
736
|
}
|
|
732
737
|
};
|
|
733
738
|
});
|
|
@@ -763,7 +768,7 @@ const GridEdit = props => {
|
|
|
763
768
|
cell: EditableCell
|
|
764
769
|
}
|
|
765
770
|
},
|
|
766
|
-
className: 'grid-editable',
|
|
771
|
+
className: classNames(className, 'grid-editable'),
|
|
767
772
|
rowKey: rowKey,
|
|
768
773
|
columns: resizableColumns,
|
|
769
774
|
showSorterTooltip: {
|
|
@@ -6,11 +6,13 @@ import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/in
|
|
|
6
6
|
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
7
7
|
import type { ItemType } from "rc-master-ui/es/menu/interface";
|
|
8
8
|
import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
9
|
+
import type { ColorPickerProps } from "antd";
|
|
9
10
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
10
11
|
export type AnyObject = Record<PropertyKey, any>;
|
|
11
12
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
12
13
|
export type ITextAlign = 'center' | 'left' | 'right';
|
|
13
14
|
export type Frozen = 'left' | 'right' | 'Left' | 'Right';
|
|
15
|
+
export type ContextMenuItem = ItemType & {};
|
|
14
16
|
export type ITemplateColumn = {
|
|
15
17
|
value: any;
|
|
16
18
|
column: any;
|
|
@@ -124,7 +126,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
124
126
|
format?: IFormat;
|
|
125
127
|
t?: any;
|
|
126
128
|
lang?: string;
|
|
127
|
-
contextMenuItems?:
|
|
129
|
+
contextMenuItems?: ContextMenuItem[];
|
|
128
130
|
contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
|
|
129
131
|
contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
|
|
130
132
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
@@ -153,7 +155,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
153
155
|
selected: RecordType | RecordType[];
|
|
154
156
|
}) => void;
|
|
155
157
|
dataSourceFilter?: SourceFilter[];
|
|
156
|
-
onFilterClick?: (column:
|
|
158
|
+
onFilterClick?: (column: ColumnTable<RecordType>, callback: (key: string, data: any) => void) => void;
|
|
157
159
|
loading?: boolean;
|
|
158
160
|
allowResizing?: boolean;
|
|
159
161
|
onDataChange?: (data: RecordType[]) => void;
|
|
@@ -184,7 +186,7 @@ export type CellChangeArgs<T> = {
|
|
|
184
186
|
rowsData: T[];
|
|
185
187
|
indexRow: number;
|
|
186
188
|
rowId?: string;
|
|
187
|
-
field: string;
|
|
189
|
+
field: string | undefined;
|
|
188
190
|
indexCol: any;
|
|
189
191
|
sumValue?: any[];
|
|
190
192
|
};
|
|
@@ -238,3 +240,4 @@ export type IFormat = {
|
|
|
238
240
|
yearFormat?: string;
|
|
239
241
|
};
|
|
240
242
|
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
243
|
+
export type Presets = Required<ColorPickerProps>['presets'][number];
|