es-grid-template 0.0.8 → 0.0.13
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/LICENSE +21 -19
- package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
- package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
- package/es/grid-component/EditableCell.d.ts +19 -0
- package/es/grid-component/EditableCell.js +842 -0
- package/es/{FilterSearch.js → grid-component/FilterSearch.js} +1 -1
- package/es/grid-component/GridStyle.d.ts +4 -0
- package/es/grid-component/GridStyle.js +5 -0
- package/es/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -2
- package/es/grid-component/InternalTable.js +283 -0
- package/es/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
- package/es/grid-component/Message/Message.d.ts +2 -0
- package/es/grid-component/Message/Message.js +16 -0
- package/es/grid-component/Message/index.d.ts +1 -0
- package/es/grid-component/Message/index.js +1 -0
- package/{lib → es/grid-component}/TableGrid.d.ts +2 -2
- package/es/grid-component/TableGrid.js +375 -0
- package/es/grid-component/async-table-select/index.d.ts +9 -0
- package/es/grid-component/async-table-select/index.js +37 -0
- package/{lib → es/grid-component}/hooks/constant.d.ts +14 -0
- package/es/{hooks → grid-component/hooks}/constant.js +16 -1
- package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/es/grid-component/hooks/useColumns/index.js +422 -0
- package/es/grid-component/hooks/utils.d.ts +35 -0
- package/es/{hooks → grid-component/hooks}/utils.js +124 -16
- package/es/grid-component/index.d.ts +2 -0
- package/es/grid-component/index.js +2 -0
- package/es/grid-component/rc-table/Grid.d.ts +8 -0
- package/es/grid-component/rc-table/Grid.js +99 -0
- package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/es/grid-component/rc-table/GridEdit.js +706 -0
- package/es/grid-component/type.d.ts +225 -0
- package/es/grid-component/useContext.d.ts +27 -0
- package/es/grid-component/useContext.js +4 -0
- package/es/index.d.ts +1 -2
- package/es/index.js +2 -2
- package/es/table-grid/styles.scss +551 -0
- package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
- package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
- package/lib/grid-component/EditableCell.d.ts +19 -0
- package/lib/grid-component/EditableCell.js +844 -0
- package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +1 -1
- package/lib/grid-component/GridStyle.d.ts +4 -0
- package/lib/grid-component/GridStyle.js +12 -0
- package/lib/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -2
- package/lib/grid-component/InternalTable.js +292 -0
- package/lib/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
- package/lib/grid-component/Message/Message.d.ts +2 -0
- package/lib/grid-component/Message/Message.js +25 -0
- package/lib/grid-component/Message/index.d.ts +1 -0
- package/lib/grid-component/Message/index.js +16 -0
- package/{es → lib/grid-component}/TableGrid.d.ts +2 -2
- package/lib/grid-component/TableGrid.js +382 -0
- package/lib/grid-component/async-table-select/index.d.ts +9 -0
- package/lib/grid-component/async-table-select/index.js +46 -0
- package/{es → lib/grid-component}/hooks/constant.d.ts +14 -0
- package/lib/{hooks → grid-component/hooks}/constant.js +17 -2
- package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/lib/grid-component/hooks/useColumns/index.js +435 -0
- package/lib/grid-component/hooks/utils.d.ts +35 -0
- package/lib/{hooks → grid-component/hooks}/utils.js +140 -19
- package/lib/grid-component/index.d.ts +2 -0
- package/lib/grid-component/index.js +9 -0
- package/lib/grid-component/rc-table/Grid.d.ts +8 -0
- package/lib/grid-component/rc-table/Grid.js +108 -0
- package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/lib/grid-component/rc-table/GridEdit.js +715 -0
- package/lib/grid-component/type.d.ts +225 -0
- package/lib/grid-component/useContext.d.ts +27 -0
- package/lib/grid-component/useContext.js +10 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +7 -3
- package/lib/table-grid/styles.scss +551 -0
- package/package.json +15 -6
- package/es/InternalTable.js +0 -185
- package/es/TableGrid.js +0 -1055
- package/es/hooks/useColumns/index.d.ts +0 -2
- package/es/hooks/useColumns/index.js +0 -25
- package/es/hooks/utils.d.ts +0 -19
- package/es/styles.scss +0 -296
- package/es/type.d.ts +0 -100
- package/lib/InternalTable.js +0 -194
- package/lib/TableGrid.js +0 -1063
- package/lib/hooks/useColumns/index.d.ts +0 -2
- package/lib/hooks/useColumns/index.js +0 -31
- package/lib/hooks/utils.d.ts +0 -19
- package/lib/styles.scss +0 -296
- package/lib/type.d.ts +0 -100
- /package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
- /package/es/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
- /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/es/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.d.ts} +0 -0
- /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/index.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/es/{type.js → grid-component/type.js} +0 -0
- /package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
- /package/lib/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
- /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/lib/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.d.ts} +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/lib/{type.js → grid-component/type.js} +0 -0
package/es/InternalTable.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { Fragment, useEffect, useState } from 'react';
|
|
3
|
-
import { Table } from "rc-master-ui";
|
|
4
|
-
import dayjs from "dayjs";
|
|
5
|
-
import 'dayjs/locale/es';
|
|
6
|
-
import 'dayjs/locale/vi';
|
|
7
|
-
import "./styles.scss";
|
|
8
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
9
|
-
import styled from "styled-components";
|
|
10
|
-
import TableGrid from "./TableGrid";
|
|
11
|
-
import { Resizable } from "react-resizable";
|
|
12
|
-
// import {ColumnsChoose} from "./ColumnsChoose";
|
|
13
|
-
|
|
14
|
-
dayjs.extend(customParseFormat);
|
|
15
|
-
const ResizableTitle = props => {
|
|
16
|
-
const {
|
|
17
|
-
onResize,
|
|
18
|
-
width,
|
|
19
|
-
...restProps
|
|
20
|
-
} = props;
|
|
21
|
-
if (!width) {
|
|
22
|
-
return /*#__PURE__*/React.createElement("th", restProps);
|
|
23
|
-
}
|
|
24
|
-
return (
|
|
25
|
-
/*#__PURE__*/
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
React.createElement(Resizable, {
|
|
28
|
-
width: width,
|
|
29
|
-
height: 0,
|
|
30
|
-
handle: /*#__PURE__*/React.createElement("span", {
|
|
31
|
-
className: "react-resizable-handle",
|
|
32
|
-
onClick: e => {
|
|
33
|
-
e.stopPropagation();
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
onResize: onResize,
|
|
37
|
-
draggableOpts: {
|
|
38
|
-
enableUserSelectHack: false
|
|
39
|
-
}
|
|
40
|
-
}, /*#__PURE__*/React.createElement("th", restProps))
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
const GridStyle = styled.div.withConfig({
|
|
44
|
-
displayName: "GridStyle",
|
|
45
|
-
componentId: "es-grid-template__sc-1fs85vo-0"
|
|
46
|
-
})([".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);
|
|
47
|
-
const InternalTable = props => {
|
|
48
|
-
const {
|
|
49
|
-
columns,
|
|
50
|
-
// title,
|
|
51
|
-
dataSource,
|
|
52
|
-
// toolbarItems,
|
|
53
|
-
// showColumnChoose,
|
|
54
|
-
...rest
|
|
55
|
-
} = props;
|
|
56
|
-
const [tmpColumns, setColumns] = useState([]);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
const rs = columns ? [Table.SELECTION_COLUMN, ...columns] : [];
|
|
59
|
-
setColumns(rs);
|
|
60
|
-
}, [columns]);
|
|
61
|
-
const handleResize = indexPath => (e, {
|
|
62
|
-
size
|
|
63
|
-
}) => {
|
|
64
|
-
const updateColumns = (cols, path) => {
|
|
65
|
-
const [currentIndex, ...restPath] = path;
|
|
66
|
-
return cols.map((col, idx) => {
|
|
67
|
-
if (idx === currentIndex) {
|
|
68
|
-
if (restPath.length === 0) {
|
|
69
|
-
// Cập nhật width của cột cuối cùng trong path
|
|
70
|
-
// return { ...col, width: size.width }
|
|
71
|
-
|
|
72
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
73
|
-
if (col.minWidth && size.width < col.minWidth) {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
79
|
-
if (col.maxWidth && size.width > col.maxWidth) {
|
|
80
|
-
e.preventDefault();
|
|
81
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
...col,
|
|
85
|
-
width: size.width
|
|
86
|
-
};
|
|
87
|
-
} else if (col.children) {
|
|
88
|
-
// Tiếp tục cập nhật các cấp con
|
|
89
|
-
return {
|
|
90
|
-
...col,
|
|
91
|
-
children: updateColumns(col.children, restPath)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// e.preventDefault()
|
|
96
|
-
return col;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
setColumns(prevColumns => updateColumns(prevColumns, indexPath));
|
|
100
|
-
};
|
|
101
|
-
const addResizeHandlers = React.useCallback((cols, parentPath = []) => {
|
|
102
|
-
return cols.map((col, index) => {
|
|
103
|
-
const currentPath = [...parentPath, index];
|
|
104
|
-
if (!col?.dataIndex && !col.key) {
|
|
105
|
-
return col;
|
|
106
|
-
}
|
|
107
|
-
if (col.children) {
|
|
108
|
-
return {
|
|
109
|
-
...col,
|
|
110
|
-
title: col.headerText ?? col.title,
|
|
111
|
-
ellipsis: col.ellipsis !== false,
|
|
112
|
-
children: addResizeHandlers(col.children, currentPath)
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
...col,
|
|
117
|
-
title: col.headerText ?? col.title,
|
|
118
|
-
ellipsis: col.ellipsis !== false,
|
|
119
|
-
onHeaderCell: () => ({
|
|
120
|
-
width: col.width,
|
|
121
|
-
onResize: handleResize(currentPath)
|
|
122
|
-
})
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
}, []);
|
|
126
|
-
const resizableColumns = React.useMemo(() => {
|
|
127
|
-
return addResizeHandlers(tmpColumns);
|
|
128
|
-
}, [addResizeHandlers, tmpColumns]);
|
|
129
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
130
|
-
heightTable: props.style?.minHeight,
|
|
131
|
-
style: {
|
|
132
|
-
position: 'relative'
|
|
133
|
-
}
|
|
134
|
-
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
135
|
-
dataSource: dataSource,
|
|
136
|
-
components: {
|
|
137
|
-
header: {
|
|
138
|
-
cell: ResizableTitle
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
columns: resizableColumns,
|
|
142
|
-
setColumns: setColumns,
|
|
143
|
-
showSorterTooltip: {
|
|
144
|
-
target: 'sorter-icon'
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// title={() => {
|
|
148
|
-
// return (
|
|
149
|
-
// <Fragment>
|
|
150
|
-
// <div>
|
|
151
|
-
// {title?.(dataSource as any)}
|
|
152
|
-
// </div>
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
// {(toolbarItems || showColumnChoose !== false) && (
|
|
156
|
-
// <div style={{display: 'flex', justifyContent: 'space-between'}}>
|
|
157
|
-
//
|
|
158
|
-
// <Toolbar
|
|
159
|
-
// style={{width: '100%'}}
|
|
160
|
-
// items={toolbarItems ?? []}
|
|
161
|
-
// mode={'responsive'}
|
|
162
|
-
// // mode={'scroll'}
|
|
163
|
-
// onClick={(val: any) => {
|
|
164
|
-
// console.log(val)
|
|
165
|
-
// }}
|
|
166
|
-
// />
|
|
167
|
-
//
|
|
168
|
-
// {showColumnChoose && (
|
|
169
|
-
// <ColumnsChoose
|
|
170
|
-
// columns={resizableColumns}
|
|
171
|
-
// setColumns={setColumns}
|
|
172
|
-
// />
|
|
173
|
-
// )}
|
|
174
|
-
//
|
|
175
|
-
// <div />
|
|
176
|
-
// </div>
|
|
177
|
-
// )}
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
// </Fragment>
|
|
181
|
-
// )
|
|
182
|
-
// }}
|
|
183
|
-
}))));
|
|
184
|
-
};
|
|
185
|
-
export default InternalTable;
|