ar-design 0.2.3 → 0.2.5
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.
|
@@ -18,12 +18,12 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
18
18
|
// refs -> Search
|
|
19
19
|
const _searchTextInputs = useRef([]);
|
|
20
20
|
const _searchTimeOut = useRef(null);
|
|
21
|
-
// const _searchFilterFirstLoad = useRef<boolean>(false);
|
|
22
21
|
// className
|
|
23
22
|
const _tableClassName = ["ar-table", "scroll"];
|
|
24
23
|
// states
|
|
25
24
|
const [selectAll, setSelectAll] = useState(false);
|
|
26
25
|
const [selectionItems, setSelectionItems] = useState([]);
|
|
26
|
+
const [thWidths, setThWidths] = useState([]);
|
|
27
27
|
// states -> Search
|
|
28
28
|
const [searchedText, setSearchedText] = useState(undefined);
|
|
29
29
|
const [_searchedParams, setSearchedParams] = useState(undefined);
|
|
@@ -149,19 +149,6 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
149
149
|
};
|
|
150
150
|
});
|
|
151
151
|
}, []);
|
|
152
|
-
const handleChecboxFilter = async () => {
|
|
153
|
-
if (config.isServerSide) {
|
|
154
|
-
if (_searchTimeOut.current)
|
|
155
|
-
clearTimeout(_searchTimeOut.current);
|
|
156
|
-
setSearchedParams(checkboxSelectedParams);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
setSearchedText(checkboxSelectedParams);
|
|
160
|
-
}
|
|
161
|
-
setCurrentPage(1);
|
|
162
|
-
pagination && pagination.onChange(1);
|
|
163
|
-
setSelectedfilterCheckboxItems(_filterCheckboxItems.current.filter((x) => x?.checked).length);
|
|
164
|
-
};
|
|
165
152
|
// Derinlemesine arama yapmak için özyinelemeli bir fonksiyon tanımlayalım.
|
|
166
153
|
const deepSearch = (item, searchedText) => {
|
|
167
154
|
if (!searchedText)
|
|
@@ -224,6 +211,19 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
224
211
|
searchedParams(_searchedParams, query);
|
|
225
212
|
}
|
|
226
213
|
}, [_searchedParams]);
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (config.isServerSide) {
|
|
216
|
+
if (_searchTimeOut.current)
|
|
217
|
+
clearTimeout(_searchTimeOut.current);
|
|
218
|
+
setSearchedParams(checkboxSelectedParams);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
setSearchedText(checkboxSelectedParams);
|
|
222
|
+
}
|
|
223
|
+
setCurrentPage(1);
|
|
224
|
+
pagination && pagination.onChange(1);
|
|
225
|
+
setSelectedfilterCheckboxItems(_filterCheckboxItems.current.filter((x) => x?.checked).length);
|
|
226
|
+
}, [checkboxSelectedParams]);
|
|
227
227
|
useEffect(() => {
|
|
228
228
|
if (!selections)
|
|
229
229
|
return;
|
|
@@ -233,6 +233,12 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
233
233
|
}
|
|
234
234
|
setSelectAll(allChecked);
|
|
235
235
|
}, [currentPage]);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (!_tableContent.current)
|
|
238
|
+
return;
|
|
239
|
+
const th = _tableContent.current?.querySelectorAll("table > thead > tr:first-child > th");
|
|
240
|
+
th.forEach((item) => setThWidths((prev) => [...prev, item.getBoundingClientRect().width]));
|
|
241
|
+
}, []);
|
|
236
242
|
return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
|
|
237
243
|
(title || description || actions || React.Children.count(children) > 0) && (React.createElement("div", { className: "header" },
|
|
238
244
|
React.createElement("div", { className: "title" },
|
|
@@ -271,9 +277,11 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
271
277
|
}
|
|
272
278
|
return (React.createElement("th", { key: `column-${cIndex}-${Math.random()}`, ...(_className.length > 0 && {
|
|
273
279
|
className: `${_className.map((c) => c).join(" ")}`,
|
|
274
|
-
}), ...(c.config?.width
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
}), ...(c.config?.width
|
|
281
|
+
? {
|
|
282
|
+
style: { minWidth: c.config.width },
|
|
283
|
+
}
|
|
284
|
+
: { style: { maxWidth: thWidths[cIndex], minWidth: thWidths[cIndex] } }), ...(c.config?.sticky && {
|
|
277
285
|
"data-sticky-position": c.config.sticky,
|
|
278
286
|
}) }, c.title));
|
|
279
287
|
})),
|
|
@@ -299,10 +307,7 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
299
307
|
React.createElement("div", null, c.filters.map((filter, fIndex) => {
|
|
300
308
|
const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
|
|
301
309
|
return (React.createElement("div", null,
|
|
302
|
-
React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary", value: filter.value, checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) =>
|
|
303
|
-
await handleCheckboxChange(event);
|
|
304
|
-
await handleChecboxFilter();
|
|
305
|
-
} })));
|
|
310
|
+
React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary", value: filter.value, checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
|
|
306
311
|
}))), windowBlur: true },
|
|
307
312
|
(selectedfilterCheckboxItems ?? 0) > 0 && (React.createElement("div", { style: {
|
|
308
313
|
position: "absolute",
|
|
@@ -352,7 +357,13 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
352
357
|
_className.push(`text-${c.config.textWrap}`);
|
|
353
358
|
return (React.createElement("td", { key: `cell-${index}-${cIndex}`, ...(_className.length > 0 && {
|
|
354
359
|
className: `${_className.map((c) => c).join(" ")}`,
|
|
355
|
-
}), ...(c.config?.
|
|
360
|
+
}), ...(c.config?.width
|
|
361
|
+
? {
|
|
362
|
+
style: { minWidth: c.config.width },
|
|
363
|
+
}
|
|
364
|
+
: {
|
|
365
|
+
style: { maxWidth: thWidths[cIndex], minWidth: thWidths[cIndex] },
|
|
366
|
+
}), ...(c.config?.sticky && {
|
|
356
367
|
"data-sticky-position": c.config.sticky,
|
|
357
368
|
}) }, React.isValidElement(render) ? render : String(render)));
|
|
358
369
|
}))))) : (React.createElement("tr", null,
|
|
@@ -77,7 +77,7 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
77
77
|
_options.current.style.visibility = "visible";
|
|
78
78
|
_options.current.style.opacity = "1";
|
|
79
79
|
_options.current.style.top = `${(InpuRect.top > screenCenter
|
|
80
|
-
? InpuRect.top - optionRect.height - (multiple ?
|
|
80
|
+
? InpuRect.top - optionRect.height - (multiple ? 0 : 5)
|
|
81
81
|
: InpuRect.top + InpuRect.height) + sy}px`;
|
|
82
82
|
_options.current.style.left = `${InpuRect.left + sx}px`;
|
|
83
83
|
_options.current.style.minWidth = "200px";
|
|
@@ -217,6 +217,8 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
217
217
|
// Arama yapılması durumunda arama sonuçlarından ilk olan değeri işaretle.
|
|
218
218
|
const optionItems = _optionItems.current.filter((optionItem) => optionItem !== null);
|
|
219
219
|
optionItems[_navigationIndex.current]?.classList.add("navigate-with-arrow-keys");
|
|
220
|
+
// Yeniden konumlandır.
|
|
221
|
+
setTimeout(() => handlePosition(), 0);
|
|
220
222
|
}, [searchText]);
|
|
221
223
|
useEffect(() => {
|
|
222
224
|
// Seçilen öğeye 'navigate-with-arrow-keys' sınıfını ekle
|