ar-design 0.4.41 → 0.4.42
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/dist/components/data-display/table/IProps.d.ts +7 -4
- package/dist/components/data-display/table/PropertiesPopup.d.ts +1 -1
- package/dist/components/data-display/table/THeadCell.d.ts +1 -1
- package/dist/components/data-display/table/body/Editable.d.ts +3 -4
- package/dist/components/data-display/table/body/Editable.js +3 -2
- package/dist/components/data-display/table/body/TBody.d.ts +1 -1
- package/dist/components/data-display/table/body/TBody.js +1 -1
- package/dist/components/data-display/table/header/ActionButtons.d.ts +8 -1
- package/dist/components/data-display/table/header/ActionButtons.js +7 -2
- package/dist/components/data-display/table/header/Header.d.ts +8 -2
- package/dist/components/data-display/table/header/Header.js +2 -2
- package/dist/components/data-display/table/index.js +17 -1
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ export type Sort<T> = {
|
|
|
20
20
|
export type SearchedParam = {
|
|
21
21
|
[key: string]: FilterValue | FilterValue[];
|
|
22
22
|
};
|
|
23
|
-
export type Config<T> = {
|
|
23
|
+
export type Config<T extends object> = {
|
|
24
24
|
locale?: Intl.LocalesArgument;
|
|
25
25
|
isServerSide?: boolean;
|
|
26
26
|
isProperties?: boolean;
|
|
@@ -34,14 +34,17 @@ export type Config<T> = {
|
|
|
34
34
|
button?: boolean;
|
|
35
35
|
render?: {
|
|
36
36
|
styles: React.CSSProperties;
|
|
37
|
-
element: (item:
|
|
37
|
+
element: (item: T[]) => React.JSX.Element;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
dnd?: {
|
|
41
41
|
renderItem: React.JSX.Element;
|
|
42
42
|
};
|
|
43
43
|
isTreeView?: boolean;
|
|
44
|
-
validation?:
|
|
44
|
+
validation?: {
|
|
45
|
+
errors: Errors<T>;
|
|
46
|
+
getChangeData?: (items: T[]) => void;
|
|
47
|
+
};
|
|
45
48
|
};
|
|
46
49
|
type ImportActionType = {
|
|
47
50
|
tooltip: string;
|
|
@@ -70,7 +73,7 @@ type DeleteActionType = {
|
|
|
70
73
|
message?: string;
|
|
71
74
|
onClick: () => void;
|
|
72
75
|
};
|
|
73
|
-
interface IProps<T> extends IChildren {
|
|
76
|
+
interface IProps<T extends object> extends IChildren {
|
|
74
77
|
trackBy?: (item: T) => string;
|
|
75
78
|
title?: string;
|
|
76
79
|
description?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
2
|
import { TableColumnType } from "../../../libs/types";
|
|
3
3
|
import { Config, Sort } from "./IProps";
|
|
4
|
-
interface IProps<T> {
|
|
4
|
+
interface IProps<T extends object> {
|
|
5
5
|
refs: {
|
|
6
6
|
tableContent: MutableRefObject<HTMLDivElement | null>;
|
|
7
7
|
buttons: MutableRefObject<(HTMLSpanElement | null)[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { TableColumnType } from "../../../libs/types";
|
|
3
3
|
import { Config, Sort } from "./IProps";
|
|
4
|
-
declare const MemoizedTHeadCell: <T>({ refs, states, methods, columns, config, }: {
|
|
4
|
+
declare const MemoizedTHeadCell: <T extends object>({ refs, states, methods, columns, config, }: {
|
|
5
5
|
refs: {
|
|
6
6
|
propertiesButton: React.MutableRefObject<(HTMLSpanElement | null)[]>;
|
|
7
7
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { TableColumnType } from "../../../../libs/types";
|
|
3
3
|
import { Config } from "../IProps";
|
|
4
|
-
interface IProps<T> {
|
|
4
|
+
interface IProps<T extends object> {
|
|
5
5
|
c: TableColumnType<T>;
|
|
6
6
|
item: T;
|
|
7
7
|
trackByValue: string;
|
|
8
8
|
onEditable: (item: T, trackByValue: string, currentKey?: keyof T | null) => void;
|
|
9
|
-
validation?: Errors<T>;
|
|
10
9
|
config: Config<T>;
|
|
11
10
|
}
|
|
12
|
-
declare const Editable: <T>({ c, item, trackByValue, onEditable,
|
|
11
|
+
declare const Editable: <T extends object>({ c, item, trackByValue, onEditable, config }: IProps<T>) => React.JSX.Element | null;
|
|
13
12
|
export default Editable;
|
|
@@ -4,7 +4,7 @@ import Input from "../../../form/input";
|
|
|
4
4
|
import DatePicker from "../../../form/date-picker";
|
|
5
5
|
import Select from "../../../form/select";
|
|
6
6
|
import { ExtractKey } from "../Helpers";
|
|
7
|
-
const Editable = function ({ c, item, trackByValue, onEditable,
|
|
7
|
+
const Editable = function ({ c, item, trackByValue, onEditable, config }) {
|
|
8
8
|
// variables
|
|
9
9
|
const key = c.key;
|
|
10
10
|
const itemValue = item[c.key];
|
|
@@ -12,7 +12,8 @@ const Editable = function ({ c, item, trackByValue, onEditable, validation, conf
|
|
|
12
12
|
const selectItems = Array.isArray(itemValue)
|
|
13
13
|
? c.editable?.options?.filter((x) => itemValue.includes(x.value))
|
|
14
14
|
: [];
|
|
15
|
-
const
|
|
15
|
+
const validation = config.validation;
|
|
16
|
+
const _vText = validation?.errors?.[`${c.key}_${trackByValue}`];
|
|
16
17
|
// states
|
|
17
18
|
const [_value, setValue] = useState(itemValue);
|
|
18
19
|
// useEffects
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { TableColumnType } from "../../../../libs/types";
|
|
3
3
|
import { Config } from "../IProps";
|
|
4
|
-
interface IProps<T> {
|
|
4
|
+
interface IProps<T extends object> {
|
|
5
5
|
data: T[];
|
|
6
6
|
columns: TableColumnType<T>[];
|
|
7
7
|
refs: {
|
|
@@ -99,7 +99,7 @@ function TBody({ data, columns, refs, methods, states, config }) {
|
|
|
99
99
|
return (React.createElement("div", { key: `last-before-${i}`, style: { left: `${i + 0.65}rem` }, className: "last-before" }));
|
|
100
100
|
}),
|
|
101
101
|
React.createElement("div", { className: "before" }))),
|
|
102
|
-
React.isValidElement(render) ? (render) : column.editable && methods.onEditable ? (React.createElement(Editable, { c: column, item: item, trackByValue: methods.trackBy?.(item) ?? "", onEditable: methods.onEditable,
|
|
102
|
+
React.isValidElement(render) ? (render) : column.editable && methods.onEditable ? (React.createElement(Editable, { c: column, item: item, trackByValue: methods.trackBy?.(item) ?? "", onEditable: methods.onEditable, config: config })) : (React.createElement("span", null, render)),
|
|
103
103
|
config.isTreeView && cIndex === 0 && (React.createElement("div", { className: "after" },
|
|
104
104
|
React.createElement("div", { className: "circle" }))))));
|
|
105
105
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from "react";
|
|
1
2
|
import { Actions } from "../IProps";
|
|
2
3
|
import React from "react";
|
|
3
4
|
interface IProps {
|
|
5
|
+
states: {
|
|
6
|
+
createTrigger: {
|
|
7
|
+
get: boolean;
|
|
8
|
+
set: Dispatch<SetStateAction<boolean>>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
4
11
|
actions: Actions;
|
|
5
12
|
}
|
|
6
|
-
declare const _default: React.MemoExoticComponent<({ actions }: IProps) => React.JSX.Element>;
|
|
13
|
+
declare const _default: React.MemoExoticComponent<({ states, actions }: IProps) => React.JSX.Element>;
|
|
7
14
|
export default _default;
|
|
@@ -7,7 +7,7 @@ import Tooltip from "../../../feedback/tooltip";
|
|
|
7
7
|
import Button from "../../../form/button";
|
|
8
8
|
import { ARIcon } from "../../../icons";
|
|
9
9
|
const { Row, Column } = Grid;
|
|
10
|
-
const ActionButtons = ({ actions }) => {
|
|
10
|
+
const ActionButtons = ({ states, actions }) => {
|
|
11
11
|
// states
|
|
12
12
|
const [files, setFiles] = useState([]);
|
|
13
13
|
const [formData, setFormData] = useState(undefined);
|
|
@@ -46,7 +46,12 @@ const ActionButtons = ({ actions }) => {
|
|
|
46
46
|
React.createElement(Tooltip, { text: actions.export.tooltip },
|
|
47
47
|
React.createElement(Button, { variant: "outlined", color: "blue", icon: { element: React.createElement(ARIcon, { icon: "Download", fill: "currentcolor" }) } })))),
|
|
48
48
|
actions.create && (React.createElement(Tooltip, { text: actions.create.tooltip },
|
|
49
|
-
React.createElement(Button, { variant: "outlined", color: "green", icon: { element: React.createElement(ARIcon, { icon: "Add", size: 24 }) }, onClick:
|
|
49
|
+
React.createElement(Button, { variant: "outlined", color: "green", icon: { element: React.createElement(ARIcon, { icon: "Add", size: 24 }) }, onClick: (event) => {
|
|
50
|
+
if (!actions.create)
|
|
51
|
+
return;
|
|
52
|
+
actions.create.onClick(event);
|
|
53
|
+
states.createTrigger.set((prev) => !prev);
|
|
54
|
+
} }))),
|
|
50
55
|
actions.delete && (React.createElement(Popover, { title: actions.delete.title ?? "Siliniyor", message: actions.delete.message ??
|
|
51
56
|
"Seçtiğiniz verileri uygulamadan silebilirsiniz. Bu işlem, verilerin sistemimizden tamamen kaldırılmasını sağlar ve bu verilerle artık işlem yapılamaz.", onConfirm: (confirm) => {
|
|
52
57
|
if (!confirm)
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { Dispatch, SetStateAction } from "react";
|
|
2
2
|
import { Actions } from "../IProps";
|
|
3
3
|
interface IProps {
|
|
4
|
+
states: {
|
|
5
|
+
createTrigger: {
|
|
6
|
+
get: boolean;
|
|
7
|
+
set: Dispatch<SetStateAction<boolean>>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
4
10
|
title?: string;
|
|
5
11
|
description?: string;
|
|
6
12
|
actions?: Actions;
|
|
7
13
|
}
|
|
8
|
-
declare const _default: React.MemoExoticComponent<({ title, description, actions }: IProps) => React.JSX.Element>;
|
|
14
|
+
declare const _default: React.MemoExoticComponent<({ states, title, description, actions }: IProps) => React.JSX.Element>;
|
|
9
15
|
export default _default;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
2
|
import ActionButtons from "./ActionButtons";
|
|
3
|
-
const Header = ({ title, description, actions }) => {
|
|
3
|
+
const Header = ({ states, title, description, actions }) => {
|
|
4
4
|
return (React.createElement("div", { className: "header" },
|
|
5
5
|
React.createElement("div", { className: "title" },
|
|
6
6
|
React.createElement("h4", null, title),
|
|
7
7
|
description && React.createElement("h5", null, description)),
|
|
8
|
-
actions && React.createElement(ActionButtons, { actions: actions })));
|
|
8
|
+
actions && React.createElement(ActionButtons, { states: states, actions: actions })));
|
|
9
9
|
};
|
|
10
10
|
export default memo(Header);
|
|
@@ -49,6 +49,8 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
49
49
|
// states
|
|
50
50
|
const [selectAll, setSelectAll] = useState(false);
|
|
51
51
|
const [showSubitems, setShowSubitems] = useState({});
|
|
52
|
+
// states -> Action Buttons
|
|
53
|
+
const [createTrigger, setCreateTrigger] = useState(false);
|
|
52
54
|
// states -> Search
|
|
53
55
|
const [searchedText, setSearchedText] = useState(null);
|
|
54
56
|
const [_searchedParams, setSearchedParams] = useState(null);
|
|
@@ -566,9 +568,23 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
566
568
|
setCurrentPage(1);
|
|
567
569
|
setTimeout(() => handleScroll(), 0);
|
|
568
570
|
}, [selectedPerPage]);
|
|
571
|
+
useEffect(() => {
|
|
572
|
+
if (typeof selections !== "function" && config.validation) {
|
|
573
|
+
const updatedData = data.map((item) => {
|
|
574
|
+
if (!("trackByValue" in item) && trackBy) {
|
|
575
|
+
return { ...item, trackByValue: trackBy(item) };
|
|
576
|
+
}
|
|
577
|
+
return item;
|
|
578
|
+
});
|
|
579
|
+
config.validation?.getChangeData?.(updatedData);
|
|
580
|
+
}
|
|
581
|
+
}, [createTrigger]);
|
|
569
582
|
useEffect(() => {
|
|
570
583
|
setIsMobile(window.innerWidth <= 768);
|
|
571
584
|
window.addEventListener("resize", handleResize);
|
|
585
|
+
if (typeof selections !== "function" && config.validation) {
|
|
586
|
+
config.validation.getChangeData?.(data.map((d) => ({ ...d, trackByValue: trackBy?.(d) })) ?? []);
|
|
587
|
+
}
|
|
572
588
|
return () => {
|
|
573
589
|
window.removeEventListener("resize", handleResize);
|
|
574
590
|
};
|
|
@@ -584,7 +600,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
584
600
|
{ value: FilterOperator.NotBlank, text: t("Table.Filters.Where.Input.Item.8.Text") },
|
|
585
601
|
];
|
|
586
602
|
return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
|
|
587
|
-
(title || description || actions || React.Children.count(children) > 0) && (React.createElement(Header, { title: title, description: description, actions: actions })),
|
|
603
|
+
(title || description || actions || React.Children.count(children) > 0) && (React.createElement(Header, { states: { createTrigger: { get: createTrigger, set: setCreateTrigger } }, title: title, description: description, actions: actions })),
|
|
588
604
|
React.createElement("div", { ref: _tableContent, className: "content", onScroll: handleScroll },
|
|
589
605
|
React.createElement("table", { ref: _innerRef },
|
|
590
606
|
React.createElement("thead", null,
|