es-grid-template 1.9.71 → 1.9.73
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/ali-table/Grid.d.ts +2 -1
- package/es/ali-table/Grid.js +12 -5
- package/es/ali-table/InternalTable.js +45 -94
- package/es/ali-table/base-table/cell/HeaderEditCell.js +4 -1
- package/es/ali-table/base-table/renderFilter.js +13 -5
- package/es/ali-table/base-table/styles.d.ts +6 -0
- package/es/ali-table/base-table/styles.js +5 -2
- package/es/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/es/ali-table/pipeline/features/columnCustom.js +38 -25
- package/es/ali-table/pipeline/features/hiddenColumns.d.ts +1 -0
- package/es/ali-table/pipeline/features/hiddenColumns.js +9 -3
- package/es/ali-table/pipeline/features/treeSelect.js +3 -3
- package/es/ali-table/utils/constants.d.ts +3 -1
- package/es/ali-table/utils/constants.js +5 -2
- package/es/ali-table/utils/utility.d.ts +1 -0
- package/es/ali-table/utils/utility.js +8 -1
- package/es/grid-component/hooks/constant.js +4 -0
- package/es/group-component/hook/useColumns.js +2 -2
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/group-component/hook/utils.js +3 -0
- package/es/table-component/ColumnsConfig.js +6 -4
- package/es/table-component/TableContainer.js +1 -0
- package/es/table-component/TableContainerEdit.js +1 -0
- package/es/table-component/hook/utils.js +3 -0
- package/es/table-component/table/Grid.js +2 -2
- package/es/table-component/table/TableWrapper.js +97 -33
- package/es/table-virtuoso/hook/utils.js +3 -0
- package/lib/ali-table/Grid.d.ts +2 -1
- package/lib/ali-table/Grid.js +12 -4
- package/lib/ali-table/InternalTable.js +45 -94
- package/lib/ali-table/base-table/cell/HeaderEditCell.js +4 -1
- package/lib/ali-table/base-table/renderFilter.js +13 -5
- package/lib/ali-table/base-table/styles.d.ts +6 -0
- package/lib/ali-table/base-table/styles.js +5 -2
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +38 -25
- package/lib/ali-table/pipeline/features/hiddenColumns.d.ts +1 -0
- package/lib/ali-table/pipeline/features/hiddenColumns.js +9 -3
- package/lib/ali-table/pipeline/features/treeSelect.js +3 -3
- package/lib/ali-table/utils/constants.d.ts +3 -1
- package/lib/ali-table/utils/constants.js +6 -3
- package/lib/ali-table/utils/utility.d.ts +1 -0
- package/lib/ali-table/utils/utility.js +10 -2
- package/lib/grid-component/hooks/constant.js +4 -0
- package/lib/group-component/hook/useColumns.js +2 -2
- package/lib/group-component/hook/utils.js +3 -0
- package/lib/table-component/ColumnsConfig.js +6 -4
- package/lib/table-component/TableContainer.js +1 -0
- package/lib/table-component/TableContainerEdit.js +1 -0
- package/lib/table-component/hook/utils.js +3 -0
- package/lib/table-component/table/Grid.js +2 -2
- package/lib/table-component/table/TableWrapper.js +97 -33
- package/lib/table-virtuoso/hook/utils.js +3 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.addRowIdArray = void 0;
|
|
7
7
|
exports.filterDataByColumns1 = filterDataByColumns1;
|
|
8
8
|
exports.filterVisibleColumns = filterVisibleColumns;
|
|
9
|
-
exports.getMaxDepth = exports.flattenArray = void 0;
|
|
9
|
+
exports.getOnlyInA = exports.getMaxDepth = exports.flattenArray = void 0;
|
|
10
10
|
exports.getVisibleColumnFields = getVisibleColumnFields;
|
|
11
11
|
exports.sortByType = exports.shouldIncludeOptimized = void 0;
|
|
12
12
|
exports.sortData = sortData;
|
|
@@ -111,6 +111,9 @@ const shouldIncludeOptimized = (item, queries, ignoreAccents = true) => {
|
|
|
111
111
|
case 'contains':
|
|
112
112
|
condition = ignoreAccents === false ? itemValue?.includes(value) : itemStr.includes(compareValue);
|
|
113
113
|
break;
|
|
114
|
+
case 'notcontains':
|
|
115
|
+
condition = ignoreAccents === false ? !itemValue?.includes(value) : !itemStr.includes(compareValue);
|
|
116
|
+
break;
|
|
114
117
|
case 'startswith':
|
|
115
118
|
condition = ignoreAccents === false ? itemValue?.startsWith(value) : itemStr.startsWith(compareValue);
|
|
116
119
|
break;
|
|
@@ -715,4 +718,9 @@ function getVisibleColumnFields(columns) {
|
|
|
715
718
|
};
|
|
716
719
|
traverse(columns);
|
|
717
720
|
return result;
|
|
718
|
-
}
|
|
721
|
+
}
|
|
722
|
+
const getOnlyInA = (a, b) => {
|
|
723
|
+
const setB = new Set(b);
|
|
724
|
+
return a.filter(item => !setB.has(item));
|
|
725
|
+
};
|
|
726
|
+
exports.getOnlyInA = getOnlyInA;
|
|
@@ -215,12 +215,12 @@ const toggleRowSelection = props => {
|
|
|
215
215
|
} else {
|
|
216
216
|
// chưa selected
|
|
217
217
|
|
|
218
|
-
const checkedRows = [...prevSelected, row];
|
|
218
|
+
const checkedRows = [...prevSelected, row.original];
|
|
219
219
|
setIsSelectionChange({
|
|
220
220
|
isChange: true,
|
|
221
221
|
type: 'rowSelected',
|
|
222
222
|
rowData: row.original,
|
|
223
|
-
rowsData: selectionSettings?.type === 'single' ? [row] : checkedRows
|
|
223
|
+
rowsData: selectionSettings?.type === 'single' ? [row.original] : checkedRows
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
return;
|
|
@@ -893,6 +893,9 @@ const shouldInclude = (item, queries) => {
|
|
|
893
893
|
case "contains":
|
|
894
894
|
condition = itemStr?.includes(queryStr);
|
|
895
895
|
break;
|
|
896
|
+
case "notcontains":
|
|
897
|
+
condition = !itemStr?.includes(queryStr);
|
|
898
|
+
break;
|
|
896
899
|
case "startswith":
|
|
897
900
|
condition = itemStr?.startsWith(queryStr);
|
|
898
901
|
break;
|
|
@@ -69,6 +69,7 @@ const ColumnsConfig = props => {
|
|
|
69
69
|
};
|
|
70
70
|
const handleAccept = () => {
|
|
71
71
|
triggerChangeColumns?.(tmpColumn, [], 'columnChoose');
|
|
72
|
+
setCurrentRow('');
|
|
72
73
|
onClose();
|
|
73
74
|
};
|
|
74
75
|
const handleChange = newElemt => {
|
|
@@ -118,10 +119,11 @@ const ColumnsConfig = props => {
|
|
|
118
119
|
return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Input, {
|
|
119
120
|
defaultValue: value,
|
|
120
121
|
allowClear: true,
|
|
122
|
+
autoFocus: true,
|
|
121
123
|
onBlur: e => {
|
|
122
124
|
const newData = {
|
|
123
125
|
...rowData,
|
|
124
|
-
|
|
126
|
+
headerText: e.target.value
|
|
125
127
|
};
|
|
126
128
|
handleChange(newData);
|
|
127
129
|
}
|
|
@@ -218,7 +220,7 @@ const ColumnsConfig = props => {
|
|
|
218
220
|
} = args;
|
|
219
221
|
if (currentRow === rowData.field) {
|
|
220
222
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.InputNumber, {
|
|
221
|
-
defaultValue: value,
|
|
223
|
+
defaultValue: value ?? 150,
|
|
222
224
|
style: {
|
|
223
225
|
width: '100%'
|
|
224
226
|
},
|
|
@@ -226,13 +228,13 @@ const ColumnsConfig = props => {
|
|
|
226
228
|
onBlur: e => {
|
|
227
229
|
const newData = {
|
|
228
230
|
...rowData,
|
|
229
|
-
|
|
231
|
+
width: e.target.value ? Number(e.target.value) : 150
|
|
230
232
|
};
|
|
231
233
|
handleChange(newData);
|
|
232
234
|
}
|
|
233
235
|
});
|
|
234
236
|
}
|
|
235
|
-
return /*#__PURE__*/_react.default.createElement("span", null, value);
|
|
237
|
+
return /*#__PURE__*/_react.default.createElement("span", null, value ?? 150, "px");
|
|
236
238
|
}
|
|
237
239
|
}];
|
|
238
240
|
const handleReset = () => {
|
|
@@ -1183,6 +1183,9 @@ const shouldInclude = (item, queries, ignoreAccents) => {
|
|
|
1183
1183
|
case "contains":
|
|
1184
1184
|
condition = ignoreAccents === false ? itemValue?.includes(value) : itemStr?.includes(queryStr);
|
|
1185
1185
|
break;
|
|
1186
|
+
case "notcontains":
|
|
1187
|
+
condition = ignoreAccents === false ? !itemValue?.includes(value) : !itemStr?.includes(queryStr);
|
|
1188
|
+
break;
|
|
1186
1189
|
case "startswith":
|
|
1187
1190
|
condition = ignoreAccents === false ? itemValue?.startsWith(value) : itemStr?.startsWith(queryStr);
|
|
1188
1191
|
break;
|
|
@@ -69,8 +69,8 @@ const Grid = props => {
|
|
|
69
69
|
const [columnResizeMode] = _react.default.useState('onChange');
|
|
70
70
|
const [columnResizeDirection] = _react.default.useState('ltr');
|
|
71
71
|
const [paginationState, setPagination] = _react.default.useState({
|
|
72
|
-
pageIndex: pagination && pagination
|
|
73
|
-
pageSize: pagination && pagination
|
|
72
|
+
pageIndex: pagination && pagination?.currentPage ? pagination.currentPage - 1 : 0,
|
|
73
|
+
pageSize: pagination && pagination?.pageSize ? pagination.pageSize : 20
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
|
|
@@ -14,7 +14,6 @@ var _reactTooltip = require("react-tooltip");
|
|
|
14
14
|
var _ContextMenu = _interopRequireDefault(require("../ContextMenu"));
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
var _useContext = require("../useContext");
|
|
17
|
-
var _utils = require("../hook/utils");
|
|
18
17
|
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); }
|
|
19
18
|
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; }
|
|
20
19
|
const TableWrapper = props => {
|
|
@@ -49,6 +48,12 @@ const TableWrapper = props => {
|
|
|
49
48
|
const menuRef = _react.default.useRef(null);
|
|
50
49
|
const loadingRef = _react.default.useRef(false);
|
|
51
50
|
const hasMoreRef = _react.default.useRef(true);
|
|
51
|
+
const pendingPageRef = _react.default.useRef(null);
|
|
52
|
+
const pendingDataLengthRef = _react.default.useRef(0);
|
|
53
|
+
const sawLoadingRef = _react.default.useRef(false);
|
|
54
|
+
const lastScrollTopRef = _react.default.useRef(0);
|
|
55
|
+
// const directionRef = React.useRef<'up' | 'down' | null>(null);
|
|
56
|
+
|
|
52
57
|
const {
|
|
53
58
|
windowSize
|
|
54
59
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
@@ -57,6 +62,23 @@ const TableWrapper = props => {
|
|
|
57
62
|
pageSize,
|
|
58
63
|
total
|
|
59
64
|
} = pagination ?? {};
|
|
65
|
+
_react.default.useEffect(() => {
|
|
66
|
+
if (pendingPageRef.current === null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (loading) {
|
|
70
|
+
sawLoadingRef.current = true;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const pageLoaded = currentPage >= pendingPageRef.current;
|
|
74
|
+
const dataLoaded = dataSource.length !== pendingDataLengthRef.current;
|
|
75
|
+
const requestFinished = sawLoadingRef.current;
|
|
76
|
+
if (pageLoaded || dataLoaded || requestFinished) {
|
|
77
|
+
loadingRef.current = false;
|
|
78
|
+
pendingPageRef.current = null;
|
|
79
|
+
sawLoadingRef.current = false;
|
|
80
|
+
}
|
|
81
|
+
}, [currentPage, dataSource.length, loading]);
|
|
60
82
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
61
83
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(undefined);
|
|
62
84
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -83,46 +105,88 @@ const TableWrapper = props => {
|
|
|
83
105
|
const loadData = page => {
|
|
84
106
|
if (!hasMoreRef.current || loadingRef.current || loading) return;
|
|
85
107
|
loadingRef.current = true;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, 10);
|
|
108
|
+
pendingPageRef.current = page;
|
|
109
|
+
pendingDataLengthRef.current = dataSource.length;
|
|
110
|
+
next?.();
|
|
111
|
+
if (pageSize && total && page * pageSize >= total) {
|
|
112
|
+
hasMoreRef.current = false;
|
|
113
|
+
}
|
|
93
114
|
};
|
|
94
115
|
const handleNext = () => {
|
|
95
116
|
loadData(currentPage + 1);
|
|
96
117
|
};
|
|
97
118
|
const handleScroll = e => {
|
|
98
|
-
if (infiniteScroll) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
e.preventDefault();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const {
|
|
105
|
-
scrollHeight: tbScrollHeight,
|
|
106
|
-
scrollTop,
|
|
107
|
-
clientHeight
|
|
108
|
-
} = e.currentTarget;
|
|
109
|
-
const abc = clientHeight * ((0, _utils.isNullOrUndefined)(onEndReachedThreshold) ? 0.1 : onEndReachedThreshold ?? 0);
|
|
119
|
+
// if (infiniteScroll) {
|
|
120
|
+
// const current = e.currentTarget.scrollTop;
|
|
121
|
+
// const last = lastScrollTopRef.current;
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
// if (loadingRef.current || loading || dataSource?.length === 0 || current === last) {
|
|
124
|
+
|
|
125
|
+
// e.stopPropagation()
|
|
126
|
+
// e.preventDefault()
|
|
127
|
+
// return
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
// const { scrollHeight: tbScrollHeight, scrollTop, clientHeight } = e.currentTarget;
|
|
131
|
+
|
|
132
|
+
// const abc = clientHeight * (isNullOrUndefined(onEndReachedThreshold) ? 0.1 : onEndReachedThreshold ?? 0)
|
|
133
|
+
|
|
134
|
+
// // const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
|
|
135
|
+
// const isEnd = scrollTop + clientHeight >= tbScrollHeight - abc;
|
|
136
|
+
|
|
137
|
+
// if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
|
|
138
|
+
|
|
139
|
+
// handleNext()
|
|
140
|
+
|
|
141
|
+
// }
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
// if (e.target.scrollLeft >= 0 && e.target.scrollLeft + e.target.clientWidth < e.target.scrollWidth) {
|
|
145
|
+
// e.target.classList.add('ui-rc-table-ping-right')
|
|
146
|
+
// } else {
|
|
147
|
+
// e.target.classList.remove('ui-rc-table-ping-right')
|
|
148
|
+
// }
|
|
149
|
+
|
|
150
|
+
// if ((e.target.scrollLeft ?? 0) > 0) {
|
|
151
|
+
// e.target.classList.add('ui-rc-table-ping-left')
|
|
152
|
+
// } else {
|
|
153
|
+
// e.target.classList.remove('ui-rc-table-ping-left')
|
|
154
|
+
// }
|
|
155
|
+
|
|
156
|
+
const target = e.currentTarget;
|
|
157
|
+
|
|
158
|
+
// Horizontal scroll
|
|
159
|
+
const {
|
|
160
|
+
scrollLeft,
|
|
161
|
+
clientWidth,
|
|
162
|
+
scrollWidth,
|
|
163
|
+
clientHeight
|
|
164
|
+
} = target;
|
|
165
|
+
target.classList.toggle('ui-rc-table-ping-left', scrollLeft > 0);
|
|
166
|
+
target.classList.toggle('ui-rc-table-ping-right', scrollLeft + clientWidth < scrollWidth);
|
|
167
|
+
if (!infiniteScroll) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const {
|
|
171
|
+
scrollTop,
|
|
172
|
+
scrollHeight
|
|
173
|
+
} = target;
|
|
174
|
+
const last = lastScrollTopRef.current;
|
|
175
|
+
|
|
176
|
+
// Update ngay
|
|
177
|
+
lastScrollTopRef.current = scrollTop;
|
|
178
|
+
|
|
179
|
+
// Chỉ xử lý khi scroll DOWN
|
|
180
|
+
if (scrollTop <= last) {
|
|
181
|
+
return;
|
|
116
182
|
}
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
} else {
|
|
120
|
-
e.target.classList.remove('ui-rc-table-ping-right');
|
|
183
|
+
if (loadingRef.current || loading || !dataSource?.length || !hasMoreRef.current) {
|
|
184
|
+
return;
|
|
121
185
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
186
|
+
const thresholdRatio = onEndReachedThreshold ?? 0.1;
|
|
187
|
+
const threshold = clientHeight * thresholdRatio;
|
|
188
|
+
if (scrollTop + clientHeight >= scrollHeight - threshold) {
|
|
189
|
+
handleNext();
|
|
126
190
|
}
|
|
127
191
|
};
|
|
128
192
|
const onContextMenu = args => event => {
|
|
@@ -948,6 +948,9 @@ const shouldInclude = (item, queries) => {
|
|
|
948
948
|
case "contains":
|
|
949
949
|
condition = itemStr?.includes(queryStr);
|
|
950
950
|
break;
|
|
951
|
+
case "notcontains":
|
|
952
|
+
condition = !itemStr?.includes(queryStr);
|
|
953
|
+
break;
|
|
951
954
|
case "startswith":
|
|
952
955
|
condition = itemStr?.startsWith(queryStr);
|
|
953
956
|
break;
|