ar-design 0.1.77 → 0.1.78
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.
|
@@ -13,6 +13,7 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
13
13
|
const _tableContent = useRef(null);
|
|
14
14
|
const _table = useRef(null);
|
|
15
15
|
const _checkboxItems = useRef([]);
|
|
16
|
+
const _searchTimeOut = useRef(null);
|
|
16
17
|
// className
|
|
17
18
|
const _tableClassName = ["ar-table", "scroll"];
|
|
18
19
|
// states
|
|
@@ -114,11 +115,10 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
114
115
|
const getData = useCallback(() => {
|
|
115
116
|
let _data = [...data];
|
|
116
117
|
_dataLength.current = data.length;
|
|
117
|
-
if (pagination) {
|
|
118
|
+
if (pagination && !config.isServerSide) {
|
|
118
119
|
const indexOfLastRow = currentPage * pagination.perPage;
|
|
119
120
|
const indexOfFirstRow = indexOfLastRow - pagination.perPage;
|
|
120
|
-
|
|
121
|
-
_data = data.slice(indexOfFirstRow, indexOfLastRow);
|
|
121
|
+
_data = data.slice(indexOfFirstRow, indexOfLastRow);
|
|
122
122
|
}
|
|
123
123
|
return Object.keys(searchedTexts).length > 0
|
|
124
124
|
? _data.filter((item) => {
|
|
@@ -138,16 +138,18 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
138
138
|
}, [selectionItems]);
|
|
139
139
|
useEffect(() => {
|
|
140
140
|
if (config?.isServerSide && searchedParams) {
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
// const query = Object.entries(_searchedParams ?? {})
|
|
142
|
+
// .map(([key, value]) => {
|
|
143
|
+
// return `${key}=${value}`;
|
|
144
|
+
// })
|
|
145
|
+
// .join("&");
|
|
146
|
+
const query = new URLSearchParams(_searchedParams).toString();
|
|
147
147
|
searchedParams(_searchedParams, query);
|
|
148
148
|
}
|
|
149
149
|
}, [_searchedParams]);
|
|
150
150
|
useEffect(() => {
|
|
151
|
+
if (!selections)
|
|
152
|
+
return;
|
|
151
153
|
let allChecked = false;
|
|
152
154
|
if (_checkboxItems.current.length > 0) {
|
|
153
155
|
allChecked = _checkboxItems.current.every((item) => item?.checked === true);
|
|
@@ -215,8 +217,12 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
215
217
|
}) },
|
|
216
218
|
React.createElement("input", { name: String(c.key), className: "search-input", onChange: (event) => {
|
|
217
219
|
if (config.isServerSide) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
if (_searchTimeOut.current)
|
|
221
|
+
clearTimeout(_searchTimeOut.current);
|
|
222
|
+
_searchTimeOut.current = setTimeout(() => {
|
|
223
|
+
setSearchedParams((prev) => ({ ...prev, [event.target.name]: event.target.value }));
|
|
224
|
+
pagination && pagination.onChange(1);
|
|
225
|
+
}, 750);
|
|
220
226
|
}
|
|
221
227
|
else {
|
|
222
228
|
// Bileşen bazlı arama işlemi.
|
|
@@ -289,9 +295,7 @@ const Table = function ({ children, title, description, data, columns, actions,
|
|
|
289
295
|
pagination?.perPage ?? getData().length,
|
|
290
296
|
" agreement")),
|
|
291
297
|
pagination && pagination.totalRecords > pagination.perPage && (React.createElement(Pagination, { totalRecords: pagination.totalRecords, perPage: pagination.perPage, onChange: (currentPage) => {
|
|
292
|
-
setCurrentPage(currentPage);
|
|
293
|
-
// Table tarafında yapılan sayfalamayı dışarı aktarmak için kullanılan callback.
|
|
294
|
-
pagination.onChange(currentPage);
|
|
298
|
+
!config.isServerSide ? setCurrentPage(currentPage) : pagination.onChange(currentPage);
|
|
295
299
|
} })))));
|
|
296
300
|
};
|
|
297
301
|
Table.Action = Actions;
|