ar-design 0.2.47 → 0.2.49
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.
|
@@ -4,7 +4,7 @@ import { ARIcon } from "../../icons";
|
|
|
4
4
|
import Button from "../../form/button";
|
|
5
5
|
import Checkbox from "../../form/checkbox";
|
|
6
6
|
import Pagination from "../../navigation/pagination";
|
|
7
|
-
import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import React, { forwardRef, Fragment, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import Input from "../../form/input";
|
|
9
9
|
import Popover from "../../feedback/popover";
|
|
10
10
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
@@ -184,18 +184,23 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
184
184
|
return false;
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
|
+
const openAllSubrowsRecursively = (data, parentKey = "") => {
|
|
188
|
+
let result = {};
|
|
189
|
+
data.forEach((item, index) => {
|
|
190
|
+
const key = parentKey ? `${parentKey}.${index}` : `${index}`;
|
|
191
|
+
const subitems = item[_subrowSelector];
|
|
192
|
+
if (subitems && Array.isArray(subitems) && subitems.length > 0) {
|
|
193
|
+
const nested = openAllSubrowsRecursively(subitems, key);
|
|
194
|
+
result[key] = true;
|
|
195
|
+
result = { ...result, ...nested };
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
return result;
|
|
199
|
+
};
|
|
187
200
|
const getData = useMemo(() => {
|
|
188
201
|
let _data = [...data];
|
|
189
|
-
if (_subrowOpenAutomatically)
|
|
190
|
-
|
|
191
|
-
if (_subrowSelector in item) {
|
|
192
|
-
setShowSubitems((prev) => ({
|
|
193
|
-
...prev,
|
|
194
|
-
[`${index}`]: true,
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
202
|
+
if (_subrowOpenAutomatically)
|
|
203
|
+
setShowSubitems(openAllSubrowsRecursively(data));
|
|
199
204
|
if (searchedText && Object.keys(searchedText).length > 0) {
|
|
200
205
|
_data = _data.filter((item) => deepSearch(item, searchedText));
|
|
201
206
|
setTotalRecords(_data.length);
|
|
@@ -241,7 +246,8 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
241
246
|
};
|
|
242
247
|
const renderRow = (item, index) => {
|
|
243
248
|
const isHasSubitems = _subrowSelector in item;
|
|
244
|
-
|
|
249
|
+
// TODO: Keylere bakılacak...
|
|
250
|
+
return (React.createElement(Fragment, { key: `row-${index}` },
|
|
245
251
|
React.createElement("tr", { key: `row-${index}` },
|
|
246
252
|
selections && (React.createElement("td", { className: "sticky-left", "data-sticky-position": "left" },
|
|
247
253
|
React.createElement(Checkbox, { ref: (element) => (_checkboxItems.current[index] = element), status: "primary", checked: selectionItems.some((selectionItem) => JSON.stringify(selectionItem) === JSON.stringify(item)), onChange: (event) => {
|
|
@@ -263,8 +269,9 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
263
269
|
const SubitemList = ({ items, columns, index, depth }) => {
|
|
264
270
|
return items.map((subitem, subindex) => {
|
|
265
271
|
const _subitem = subitem[_subrowSelector];
|
|
266
|
-
|
|
267
|
-
|
|
272
|
+
// TODO: Keylere bakılacak...
|
|
273
|
+
return (React.createElement(Fragment, { key: `subitem-${index}-${subindex}-${Math.random()}` },
|
|
274
|
+
React.createElement("tr", { key: `subitem-${index}-${subindex}-${Math.random()}` },
|
|
268
275
|
_subrowSelector in subitem && _subrowButton && (React.createElement("td", { style: { paddingLeft: `${depth}rem` } },
|
|
269
276
|
React.createElement("div", { className: "subitem-open-button-wrapper" },
|
|
270
277
|
React.createElement("span", { className: `${(showSubitems[`${index}.${subindex}`] && "opened") ?? ""} ${!_subitem && "passive"}`, onClick: () => {
|
|
@@ -276,7 +283,7 @@ const Table = forwardRef(({ children, title, description, data, columns, actions
|
|
|
276
283
|
}));
|
|
277
284
|
} })))),
|
|
278
285
|
columns.map((c, cIndex) => renderCell(subitem, c, cIndex, subindex, depth * 1.5))),
|
|
279
|
-
showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { items: _subitem, columns: columns, index: subindex, depth: depth * 1.5 }))));
|
|
286
|
+
showSubitems[`${index}.${subindex}`] && _subitem && (React.createElement(SubitemList, { key: `subitem-${index}-${subindex}-${Math.random()}`, items: _subitem, columns: columns, index: subindex, depth: depth * 1.5 }))));
|
|
280
287
|
});
|
|
281
288
|
};
|
|
282
289
|
// useEffects
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "../../../assets/css/components/form/button/styles.css";
|
|
3
3
|
import IProps from "./IProps";
|
|
4
|
-
declare const Button: React.
|
|
4
|
+
declare const Button: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
export default Button;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React, { useRef } from "react";
|
|
2
|
+
import React, { forwardRef, useRef } from "react";
|
|
3
3
|
import "../../../assets/css/components/form/button/styles.css";
|
|
4
4
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
5
5
|
import Tooltip from "../../feedback/tooltip";
|
|
6
|
-
const Button = ({
|
|
6
|
+
// const Button: React.FC<IProps> = ({
|
|
7
|
+
// children,
|
|
8
|
+
// variant = "filled",
|
|
9
|
+
// shape,
|
|
10
|
+
// status = "primary",
|
|
11
|
+
// border,
|
|
12
|
+
// size = "normal",
|
|
13
|
+
// tooltip,
|
|
14
|
+
// position,
|
|
15
|
+
// icon,
|
|
16
|
+
// upperCase,
|
|
17
|
+
// ...attributes
|
|
18
|
+
// }) => {
|
|
19
|
+
const Button = forwardRef(({ children, variant = "filled", shape, status = "primary", border, size = "normal", tooltip, position, icon, upperCase, ...attributes }, ref) => {
|
|
7
20
|
// refs
|
|
8
21
|
const _button = useRef(null);
|
|
9
22
|
const _buttonClassName = ["ar-button"];
|
|
@@ -16,7 +29,7 @@ const Button = ({ children, variant = "filled", shape, status = "primary", borde
|
|
|
16
29
|
_buttonClassName.push(position.type);
|
|
17
30
|
_buttonClassName.push(position.inset.map((_inset) => _inset).join(" "));
|
|
18
31
|
}
|
|
19
|
-
const buttonElement = (React.createElement("button", { ref: _button, ...attributes, className: _buttonClassName.map((c) => c).join(" "), onClick: (event) => {
|
|
32
|
+
const buttonElement = (React.createElement("button", { ref: ref ?? _button, ...attributes, className: _buttonClassName.map((c) => c).join(" "), onClick: (event) => {
|
|
20
33
|
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
21
34
|
if (attributes.disabled)
|
|
22
35
|
return;
|
|
@@ -26,7 +39,7 @@ const Button = ({ children, variant = "filled", shape, status = "primary", borde
|
|
|
26
39
|
if (_current && !_current.classList.contains(addClass)) {
|
|
27
40
|
// Sınıf ekleniyor...
|
|
28
41
|
_current.classList.add(addClass);
|
|
29
|
-
// Sınıf
|
|
42
|
+
// Sınıf 750 milisaniye sonra kaldırlacak.
|
|
30
43
|
setTimeout(() => _current.classList.remove(addClass), 750);
|
|
31
44
|
}
|
|
32
45
|
})();
|
|
@@ -36,6 +49,6 @@ const Button = ({ children, variant = "filled", shape, status = "primary", borde
|
|
|
36
49
|
icon?.element,
|
|
37
50
|
React.createElement("span", null, !shape ? (typeof children === "string" && upperCase ? children.toLocaleUpperCase() : children) : ""))));
|
|
38
51
|
return !tooltip ? (buttonElement) : (React.createElement(Tooltip, { text: tooltip.text, direction: tooltip.direction }, buttonElement));
|
|
39
|
-
};
|
|
52
|
+
});
|
|
40
53
|
Button.displayName = "Button";
|
|
41
54
|
export default Button;
|