es-grid-template 0.1.0 → 0.1.2-1
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.d.ts +3 -4
- package/es/grid-component/ColumnsChoose.js +28 -15
- package/es/grid-component/Command.d.ts +8 -0
- package/es/grid-component/Command.js +81 -0
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +300 -314
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +52 -28
- package/es/grid-component/TableGrid.d.ts +2 -1
- package/es/grid-component/TableGrid.js +64 -18
- 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 +7 -4
- 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 -0
- package/es/grid-component/styles.scss +282 -214
- package/es/grid-component/table/Grid.js +46 -59
- package/es/grid-component/table/GridEdit.d.ts +4 -0
- package/es/grid-component/table/GridEdit.js +106 -19
- package/es/grid-component/type.d.ts +32 -14
- package/es/grid-component/useContext.d.ts +11 -7
- package/es/grid-component/useContext.js +3 -0
- package/es/index.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.d.ts +3 -4
- package/lib/grid-component/ColumnsChoose.js +27 -14
- package/lib/grid-component/Command.d.ts +8 -0
- package/lib/grid-component/Command.js +90 -0
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +297 -311
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +51 -27
- package/lib/grid-component/TableGrid.d.ts +2 -1
- package/lib/grid-component/TableGrid.js +63 -17
- 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 +7 -4
- 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 -0
- package/lib/grid-component/styles.scss +282 -214
- package/lib/grid-component/table/Grid.js +46 -59
- package/lib/grid-component/table/GridEdit.d.ts +4 -0
- package/lib/grid-component/table/GridEdit.js +106 -19
- package/lib/grid-component/type.d.ts +32 -14
- package/lib/grid-component/useContext.d.ts +11 -7
- package/lib/grid-component/useContext.js +2 -0
- package/lib/index.d.ts +1 -0
- package/package.json +102 -112
- /package/es/{grid-component/Message → Message}/Message.d.ts +0 -0
- /package/es/{grid-component/Message → Message}/Message.js +0 -0
- /package/es/{grid-component/Message → Message}/index.d.ts +0 -0
- /package/es/{grid-component/Message → Message}/index.js +0 -0
- /package/lib/{grid-component/Message → Message}/Message.d.ts +0 -0
- /package/lib/{grid-component/Message → Message}/Message.js +0 -0
- /package/lib/{grid-component/Message → Message}/index.d.ts +0 -0
- /package/lib/{grid-component/Message → Message}/index.js +0 -0
|
@@ -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);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Select, Table } from "rc-master-ui";
|
|
4
4
|
import { Button, Space } from "antd";
|
|
5
5
|
import { SearchOutlined } from "@ant-design/icons";
|
|
6
|
-
import styled from "styled-components";
|
|
7
6
|
import { Resizable } from "react-resizable";
|
|
8
7
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
9
8
|
import { numberOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
@@ -14,9 +13,9 @@ import 'dayjs/locale/es';
|
|
|
14
13
|
import 'dayjs/locale/vi';
|
|
15
14
|
import en from 'rc-master-ui/es/date-picker/locale/en_US';
|
|
16
15
|
import vi from 'rc-master-ui/es/date-picker/locale/vi_VN';
|
|
16
|
+
import "./styles.scss";
|
|
17
17
|
import GridEdit from "./table/GridEdit";
|
|
18
18
|
import Grid from "./table/Grid";
|
|
19
|
-
import "./styles.scss";
|
|
20
19
|
dayjs.extend(customParseFormat);
|
|
21
20
|
const ResizableTitle = props => {
|
|
22
21
|
const {
|
|
@@ -46,20 +45,18 @@ const ResizableTitle = props => {
|
|
|
46
45
|
}, /*#__PURE__*/React.createElement("th", restProps))
|
|
47
46
|
);
|
|
48
47
|
};
|
|
49
|
-
const GridStyle = styled.div.withConfig({
|
|
50
|
-
displayName: "GridStyle",
|
|
51
|
-
componentId: "es-grid-template__sc-1awgu8w-0"
|
|
52
|
-
})([".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;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
|
|
53
48
|
const InternalTable = props => {
|
|
54
49
|
const {
|
|
55
50
|
t,
|
|
56
51
|
columns: propsColumns,
|
|
57
52
|
lang,
|
|
58
53
|
dataSource,
|
|
59
|
-
allowResizing
|
|
54
|
+
allowResizing,
|
|
60
55
|
dataSourceFilter: propDataSourceFilter,
|
|
61
56
|
onFilterClick,
|
|
62
57
|
editAble,
|
|
58
|
+
rowKey,
|
|
59
|
+
onDataChange,
|
|
63
60
|
...rest
|
|
64
61
|
} = props;
|
|
65
62
|
const locale = lang && lang === 'en' ? en : vi;
|
|
@@ -84,6 +81,15 @@ const InternalTable = props => {
|
|
|
84
81
|
}
|
|
85
82
|
setIsManualUpdate(false);
|
|
86
83
|
}, [dataSource]);
|
|
84
|
+
|
|
85
|
+
// ============================ RowKey ============================
|
|
86
|
+
const getRowKey = React.useMemo(() => {
|
|
87
|
+
if (typeof rowKey === 'function') {
|
|
88
|
+
return rowKey;
|
|
89
|
+
}
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
return record => record?.[rowKey];
|
|
92
|
+
}, [rowKey]);
|
|
87
93
|
const handleSearch = (selectedKeys, confirm) => {
|
|
88
94
|
confirm();
|
|
89
95
|
};
|
|
@@ -224,32 +230,40 @@ const InternalTable = props => {
|
|
|
224
230
|
return cols.map((col, index) => {
|
|
225
231
|
const currentPath = [...parentPath, index];
|
|
226
232
|
// @ts-ignore
|
|
227
|
-
if (!col?.dataIndex && !col.key) {
|
|
233
|
+
if (!col?.dataIndex && !col.key && !col.field) {
|
|
228
234
|
return col;
|
|
229
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
|
+
};
|
|
230
244
|
if (col.children) {
|
|
231
245
|
return {
|
|
232
|
-
...
|
|
233
|
-
title: col.headerText ?? col.title,
|
|
234
|
-
ellipsis: col.ellipsis !== false,
|
|
246
|
+
...transformedColumn,
|
|
235
247
|
children: transformColumns(col.children, currentPath)
|
|
236
248
|
};
|
|
237
249
|
}
|
|
238
250
|
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.dataIndex === '#') {
|
|
239
251
|
return {
|
|
240
|
-
...
|
|
241
|
-
title: col.headerText ?? col.title,
|
|
242
|
-
ellipsis: col.ellipsis !== false
|
|
252
|
+
...transformedColumn
|
|
243
253
|
};
|
|
244
254
|
}
|
|
245
255
|
return {
|
|
246
256
|
...getColumnSearchProps(col),
|
|
247
|
-
...
|
|
248
|
-
|
|
249
|
-
|
|
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,
|
|
250
264
|
onFilter: (value, record) => {
|
|
251
265
|
// @ts-ignore
|
|
252
|
-
return record[
|
|
266
|
+
return record[col.field ?? col.dataIndex];
|
|
253
267
|
},
|
|
254
268
|
onHeaderCell: () => ({
|
|
255
269
|
width: col.width,
|
|
@@ -261,13 +275,17 @@ const InternalTable = props => {
|
|
|
261
275
|
const mergedColumns = React.useMemo(() => {
|
|
262
276
|
return transformColumns(columns);
|
|
263
277
|
}, [transformColumns, columns]);
|
|
278
|
+
|
|
279
|
+
// console.log('mergedColumns', mergedColumns)
|
|
280
|
+
|
|
281
|
+
const triggerChangeColumns = () => {};
|
|
282
|
+
const triggerChangeData = newData => {
|
|
283
|
+
setIsManualUpdate(true);
|
|
284
|
+
setData(newData);
|
|
285
|
+
onDataChange?.(newData);
|
|
286
|
+
};
|
|
264
287
|
const TableComponent = editAble ? GridEdit : Grid;
|
|
265
|
-
return /*#__PURE__*/React.createElement(
|
|
266
|
-
heightTable: props.style?.minHeight,
|
|
267
|
-
style: {
|
|
268
|
-
position: 'relative'
|
|
269
|
-
}
|
|
270
|
-
}, /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
288
|
+
return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
271
289
|
tableRef: tableRef,
|
|
272
290
|
dataSource: data,
|
|
273
291
|
components: {
|
|
@@ -275,10 +293,16 @@ const InternalTable = props => {
|
|
|
275
293
|
cell: allowResizing ? ResizableTitle : undefined
|
|
276
294
|
}
|
|
277
295
|
},
|
|
278
|
-
columns: mergedColumns
|
|
296
|
+
columns: mergedColumns
|
|
297
|
+
// columns={columns}
|
|
298
|
+
,
|
|
279
299
|
showSorterTooltip: {
|
|
280
300
|
target: 'sorter-icon'
|
|
281
|
-
}
|
|
282
|
-
|
|
301
|
+
},
|
|
302
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
303
|
+
triggerChangeData: triggerChangeData,
|
|
304
|
+
rowKey: rowKey,
|
|
305
|
+
getRowKey: getRowKey
|
|
306
|
+
}));
|
|
283
307
|
};
|
|
284
308
|
export default InternalTable;
|
|
@@ -3,7 +3,8 @@ import 'dayjs/locale/es';
|
|
|
3
3
|
import 'dayjs/locale/vi';
|
|
4
4
|
import type { GridTableProps } from "./type";
|
|
5
5
|
type GridProps<T> = GridTableProps<T> & {
|
|
6
|
-
|
|
6
|
+
triggerChangeColumns?: () => void;
|
|
7
|
+
triggerChangeData?: () => void;
|
|
7
8
|
tableRef: any;
|
|
8
9
|
};
|
|
9
10
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { Fragment, useLayoutEffect,
|
|
2
|
+
import React, { Fragment, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { numericFormatter } from "react-numeric-component";
|
|
5
5
|
import { Table, Toolbar } from "rc-master-ui";
|
|
@@ -15,6 +15,9 @@ import { flatColumns } from "./hooks/useColumns";
|
|
|
15
15
|
import Pagination from "rc-master-ui/es/pagination";
|
|
16
16
|
import ComponentSpinner from "./LoadingSpinner";
|
|
17
17
|
import { ColumnsChoose } from "./ColumnsChoose";
|
|
18
|
+
// import {useMergedState} from "rc-util";
|
|
19
|
+
// import useMergedState from 'rc-util/lib/hooks/useMergedState';
|
|
20
|
+
|
|
18
21
|
const convertFilters = filters => {
|
|
19
22
|
const result = [];
|
|
20
23
|
filters.forEach(({
|
|
@@ -63,7 +66,6 @@ const convertFilters = filters => {
|
|
|
63
66
|
const useStyle = createStyles(({
|
|
64
67
|
css
|
|
65
68
|
}) => {
|
|
66
|
-
// const { antCls } = token
|
|
67
69
|
const antCls = 'ui-rc';
|
|
68
70
|
return {
|
|
69
71
|
customTable: css`
|
|
@@ -82,6 +84,8 @@ const useStyle = createStyles(({
|
|
|
82
84
|
});
|
|
83
85
|
// type OnChange = NonNullable<TableProps<any>['onChange']>;
|
|
84
86
|
|
|
87
|
+
// const EMPTY_LIST: React.Key[] = [];
|
|
88
|
+
|
|
85
89
|
const TableGrid = props => {
|
|
86
90
|
const {
|
|
87
91
|
columns,
|
|
@@ -109,20 +113,31 @@ const TableGrid = props => {
|
|
|
109
113
|
onFilterClick,
|
|
110
114
|
dataSourceFilter: propDataSourceFilter,
|
|
111
115
|
loading,
|
|
112
|
-
|
|
113
|
-
// dataSourceFilter,
|
|
116
|
+
triggerChangeColumns,
|
|
114
117
|
...rest
|
|
115
118
|
} = props;
|
|
116
119
|
const {
|
|
117
120
|
styles
|
|
118
121
|
} = useStyle();
|
|
122
|
+
const {
|
|
123
|
+
mode,
|
|
124
|
+
type,
|
|
125
|
+
checkboxOnly,
|
|
126
|
+
hideSelectAll,
|
|
127
|
+
columnWidth,
|
|
128
|
+
selectedRowKeys
|
|
129
|
+
// defaultSelectedRowKeys
|
|
130
|
+
} = selectionSettings || {};
|
|
119
131
|
const clickRef = useRef(null);
|
|
120
132
|
const menuRef = useRef(null);
|
|
121
133
|
const viewportWidth = window.innerWidth;
|
|
122
134
|
const viewportHeight = window.innerHeight;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
|
|
136
|
+
// const defaultSelected = useMemo(() => {
|
|
137
|
+
// return defaultSelectedRowKeys ?? []
|
|
138
|
+
//
|
|
139
|
+
// }, [defaultSelectedRowKeys])
|
|
140
|
+
|
|
126
141
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
127
142
|
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
128
143
|
const [position, setPosition] = React.useState({
|
|
@@ -131,7 +146,25 @@ const TableGrid = props => {
|
|
|
131
146
|
viewportWidth,
|
|
132
147
|
viewportHeight
|
|
133
148
|
});
|
|
134
|
-
|
|
149
|
+
|
|
150
|
+
// const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
|
|
151
|
+
|
|
152
|
+
// ========================= Keys =========================
|
|
153
|
+
// const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
|
|
154
|
+
// selectedRowKeys || defaultSelectedRowKeys || EMPTY_LIST,
|
|
155
|
+
// {
|
|
156
|
+
// value: selectedRowKeys,
|
|
157
|
+
// },
|
|
158
|
+
// );
|
|
159
|
+
|
|
160
|
+
// Reset if rowSelection reset
|
|
161
|
+
|
|
162
|
+
// React.useEffect(() => {
|
|
163
|
+
// if (!selectionSettings) {
|
|
164
|
+
// setMergedSelectedKeys(EMPTY_LIST);
|
|
165
|
+
// }
|
|
166
|
+
// }, [!!selectionSettings]);
|
|
167
|
+
|
|
135
168
|
const contextMenuItems = React.useMemo(() => {
|
|
136
169
|
if (typeof contextMenuHidden === "function" && propContextMenuItems && selectedRowData) {
|
|
137
170
|
const hiddenItems = contextMenuHidden({
|
|
@@ -199,7 +232,17 @@ const TableGrid = props => {
|
|
|
199
232
|
});
|
|
200
233
|
}
|
|
201
234
|
};
|
|
202
|
-
const handleRowClick = () => {
|
|
235
|
+
const handleRowClick = () => () => {
|
|
236
|
+
// console.log(data)
|
|
237
|
+
// console.log(index)
|
|
238
|
+
|
|
239
|
+
// const key = getRowKey(record, index);
|
|
240
|
+
|
|
241
|
+
// console.log('key', key)
|
|
242
|
+
|
|
243
|
+
if (checkboxOnly !== true) {
|
|
244
|
+
if (type === 'single') {}
|
|
245
|
+
}
|
|
203
246
|
if (clickRef.current) return;
|
|
204
247
|
|
|
205
248
|
// @ts-ignore
|
|
@@ -221,7 +264,7 @@ const TableGrid = props => {
|
|
|
221
264
|
};
|
|
222
265
|
const onSelectChange = (keys, selectedRows, info, selectedRow) => {
|
|
223
266
|
if (info.type === 'all') {
|
|
224
|
-
//
|
|
267
|
+
// setMergedSelectedKeys(keys)
|
|
225
268
|
rowSelected?.({
|
|
226
269
|
selected: selectedRows,
|
|
227
270
|
type: 'rowSelected',
|
|
@@ -229,7 +272,7 @@ const TableGrid = props => {
|
|
|
229
272
|
});
|
|
230
273
|
} else {
|
|
231
274
|
if (selectionSettings?.type === 'multiple') {
|
|
232
|
-
//
|
|
275
|
+
// setMergedSelectedKeys(keys)
|
|
233
276
|
rowSelected?.({
|
|
234
277
|
selected: selectedRows,
|
|
235
278
|
type: 'rowSelected',
|
|
@@ -237,7 +280,8 @@ const TableGrid = props => {
|
|
|
237
280
|
});
|
|
238
281
|
} else {
|
|
239
282
|
// @ts-ignore
|
|
240
|
-
|
|
283
|
+
// setMergedSelectedKeys([selectedRow[rowKey]])
|
|
284
|
+
|
|
241
285
|
rowSelected?.({
|
|
242
286
|
selected: [selectedRow],
|
|
243
287
|
type: 'rowSelected',
|
|
@@ -293,19 +337,21 @@ const TableGrid = props => {
|
|
|
293
337
|
onRow: (data, index) => {
|
|
294
338
|
return {
|
|
295
339
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
296
|
-
onClick: handleRowClick,
|
|
340
|
+
// onClick: handleRowClick,
|
|
341
|
+
onClick: handleRowClick(),
|
|
297
342
|
onContextMenu: onContextMenu(data)
|
|
298
343
|
};
|
|
299
344
|
},
|
|
300
345
|
rowSelection: {
|
|
301
|
-
|
|
302
|
-
|
|
346
|
+
...selectionSettings,
|
|
347
|
+
type: selectionSettings?.mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
348
|
+
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
303
349
|
onChange: onSelectChange,
|
|
304
|
-
selectedRowKeys:
|
|
350
|
+
selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
305
351
|
defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
306
352
|
preserveSelectedRowKeys: true,
|
|
307
353
|
...rowSelection,
|
|
308
|
-
hideSelectAll: !
|
|
354
|
+
hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
309
355
|
},
|
|
310
356
|
onScroll: () => {
|
|
311
357
|
setMenuVisible(false);
|
|
@@ -360,7 +406,7 @@ const TableGrid = props => {
|
|
|
360
406
|
}
|
|
361
407
|
}), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
362
408
|
columns: columns,
|
|
363
|
-
|
|
409
|
+
triggerChangeColumns: triggerChangeColumns
|
|
364
410
|
}), /*#__PURE__*/React.createElement("div", null)));
|
|
365
411
|
}
|
|
366
412
|
}, rest)), pagination && pagination.onChange && /*#__PURE__*/React.createElement(Pagination
|
|
@@ -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,
|
|
@@ -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,2 +1,5 @@
|
|
|
1
1
|
import InternalTable from './InternalTable';
|
|
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 };
|
|
2
5
|
export default InternalTable;
|