ar-design 0.2.4 → 0.2.6
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);
|
|
@@ -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
|
})),
|
|
@@ -349,7 +357,13 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
|
|
|
349
357
|
_className.push(`text-${c.config.textWrap}`);
|
|
350
358
|
return (React.createElement("td", { key: `cell-${index}-${cIndex}`, ...(_className.length > 0 && {
|
|
351
359
|
className: `${_className.map((c) => c).join(" ")}`,
|
|
352
|
-
}), ...(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 && {
|
|
353
367
|
"data-sticky-position": c.config.sticky,
|
|
354
368
|
}) }, React.isValidElement(render) ? render : String(render)));
|
|
355
369
|
}))))) : (React.createElement("tr", null,
|
|
@@ -6,7 +6,7 @@ import Chip from "../../data-display/chip";
|
|
|
6
6
|
import Checkbox from "../checkbox";
|
|
7
7
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
8
8
|
import ReactDOM from "react-dom";
|
|
9
|
-
const Select = ({ variant = "outlined", status, border = { radius: "sm" }, options, value, onChange, onCreate, multiple, placeholder, validation, upperCase, disabled, }) => {
|
|
9
|
+
const Select = ({ variant = "outlined", status, border = { radius: "sm" }, options, value, onChange, onClick, onCreate, multiple, placeholder, validation, upperCase, disabled, }) => {
|
|
10
10
|
const _selectionClassName = ["selections"];
|
|
11
11
|
// refs
|
|
12
12
|
const _arSelect = useRef(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
|
|
@@ -240,7 +242,12 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
240
242
|
multiple ? (React.createElement("div", { className: _selectionClassName.map((c) => c).join(" "), onClick: () => setOptionsOpen((x) => !x) },
|
|
241
243
|
React.createElement("div", { className: "items" }, value.length > 0 ? (value.map((_value, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", status: status?.selected?.color || status?.color, text: _value.text })))) : (React.createElement("span", { className: "placeholder" },
|
|
242
244
|
validation ? "* " : "",
|
|
243
|
-
placeholder))))) : (React.createElement(Input, { ref: _singleInput, variant: variant, status: !Utils.IsNullOrEmpty(validation?.text) ? "danger" : status, border: { radius: border.radius }, value: singleInputText, onClick: () =>
|
|
245
|
+
placeholder))))) : (React.createElement(Input, { ref: _singleInput, variant: variant, status: !Utils.IsNullOrEmpty(validation?.text) ? "danger" : status, border: { radius: border.radius }, value: singleInputText, onClick: () => {
|
|
246
|
+
onClick && onClick();
|
|
247
|
+
(() => {
|
|
248
|
+
setOptionsOpen((prev) => !prev);
|
|
249
|
+
})();
|
|
250
|
+
}, onChange: (event) => {
|
|
244
251
|
!optionsOpen && setOptionsOpen(true);
|
|
245
252
|
if (upperCase)
|
|
246
253
|
event.target.value = convertToUpperCase(event.target.value);
|