ar-design 0.4.32 → 0.4.33
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/FilterPopup.js +1 -0
- package/dist/components/data-display/table/PropertiesPopup.d.ts +3 -2
- package/dist/components/data-display/table/PropertiesPopup.js +7 -4
- package/dist/components/data-display/table/index.js +17 -26
- package/dist/libs/core/application/hooks/useTranslation.d.ts +2 -1
- package/dist/libs/core/application/hooks/useTranslation.js +7 -5
- package/dist/libs/core/application/locales/table/ITableLocale.d.ts +17 -0
- package/dist/libs/core/application/locales/table/ITableLocale.js +1 -0
- package/dist/libs/core/application/locales/table/en.d.ts +3 -0
- package/dist/libs/core/application/locales/table/en.js +20 -0
- package/dist/libs/core/application/locales/table/tr.d.ts +3 -0
- package/dist/libs/core/application/locales/table/tr.js +20 -0
- package/dist/libs/infrastructure/shared/DATE.d.ts +2 -2
- package/dist/libs/infrastructure/shared/DATE.js +4 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
2
|
import { TableColumnType } from "../../../libs/types";
|
|
3
|
-
import { Sort } from "./IProps";
|
|
3
|
+
import { Config, Sort } from "./IProps";
|
|
4
4
|
interface IProps<T> {
|
|
5
5
|
refs: {
|
|
6
6
|
tableContent: MutableRefObject<HTMLDivElement | null>;
|
|
@@ -24,7 +24,8 @@ interface IProps<T> {
|
|
|
24
24
|
x: number;
|
|
25
25
|
y: number;
|
|
26
26
|
};
|
|
27
|
+
config: Config<T>;
|
|
27
28
|
}
|
|
28
|
-
declare function PropertiesPopup<T extends object>({ refs, states, methods, coordinate }: IProps<T>): false | React.ReactPortal;
|
|
29
|
+
declare function PropertiesPopup<T extends object>({ refs, states, methods, coordinate, config }: IProps<T>): false | React.ReactPortal;
|
|
29
30
|
declare const _default: typeof PropertiesPopup;
|
|
30
31
|
export default _default;
|
|
@@ -3,9 +3,12 @@ import React, { memo, useEffect, useMemo, useRef } from "react";
|
|
|
3
3
|
import ReactDOM from "react-dom";
|
|
4
4
|
import { ARIcon } from "../../icons";
|
|
5
5
|
import { ExtractKey } from "./Helpers";
|
|
6
|
-
|
|
6
|
+
import { useTranslation } from "../../../libs/core/application/hooks";
|
|
7
|
+
function PropertiesPopup({ refs, states, methods, coordinate, config }) {
|
|
7
8
|
// refs
|
|
8
9
|
const _arTablePropertiesPopup = useRef(null);
|
|
10
|
+
// hooks
|
|
11
|
+
const { t } = useTranslation(String(config.locale ?? "tr"));
|
|
9
12
|
// methods
|
|
10
13
|
const handleClickOutSide = (event) => {
|
|
11
14
|
const target = event.target;
|
|
@@ -80,17 +83,17 @@ function PropertiesPopup({ refs, states, methods, coordinate }) {
|
|
|
80
83
|
currentSort && (!currentSort.direction || currentSort.direction === "desc") && (React.createElement("li", { onClick: () => handleSort(currentKey, "asc") },
|
|
81
84
|
React.createElement("span", null,
|
|
82
85
|
React.createElement(ARIcon, { icon: "ArrowUp" })),
|
|
83
|
-
React.createElement("span", null, "
|
|
86
|
+
React.createElement("span", null, t("Table.Properties.Asc.Text")))),
|
|
84
87
|
currentSort && (!currentSort.direction || currentSort.direction === "asc") && (React.createElement("li", { onClick: () => handleSort(currentKey, "desc") },
|
|
85
88
|
React.createElement("span", null,
|
|
86
89
|
React.createElement(ARIcon, { icon: "ArrowDown" })),
|
|
87
|
-
React.createElement("span", null, "
|
|
90
|
+
React.createElement("span", null, t("Table.Properties.Desc.Text")))),
|
|
88
91
|
currentSort && currentSort.direction && (React.createElement("li", { onClick: () => {
|
|
89
92
|
states.sort.set((prev) => prev.filter((s) => s.key !== currentKey));
|
|
90
93
|
states.open.set(false);
|
|
91
94
|
} },
|
|
92
95
|
React.createElement("span", null,
|
|
93
96
|
React.createElement(ARIcon, { icon: "ChevronExpand" })),
|
|
94
|
-
React.createElement("span", null, "
|
|
97
|
+
React.createElement("span", null, t("Table.Properties.ClearSort.Text")))))), document.body));
|
|
95
98
|
}
|
|
96
99
|
export default memo(PropertiesPopup);
|
|
@@ -19,16 +19,7 @@ import { ExtractKey } from "./Helpers";
|
|
|
19
19
|
import Header from "./header/Header";
|
|
20
20
|
import TBody from "./body/TBody";
|
|
21
21
|
import DatePicker from "../../form/date-picker";
|
|
22
|
-
|
|
23
|
-
{ value: FilterOperator.Contains, text: "İçerir" },
|
|
24
|
-
{ value: FilterOperator.DoesNotContains, text: "İçermez" },
|
|
25
|
-
{ value: FilterOperator.Equals, text: "Eşittir" },
|
|
26
|
-
{ value: FilterOperator.DoesNotEquals, text: "Eşit değildir" },
|
|
27
|
-
{ value: FilterOperator.BeginsWith, text: "İle başlar" },
|
|
28
|
-
{ value: FilterOperator.EndsWith, text: "İle biter" },
|
|
29
|
-
{ value: FilterOperator.Blank, text: "Boş" },
|
|
30
|
-
{ value: FilterOperator.NotBlank, text: "Boş değil" },
|
|
31
|
-
];
|
|
22
|
+
import { useTranslation } from "../../../libs/core/application/hooks";
|
|
32
23
|
const { Row, Column } = Grid;
|
|
33
24
|
const Table = forwardRef(({ children, trackBy, title, description, data, columns, actions, rowBackgroundColor, selections, previousSelections, sortedParams, searchedParams, onEditable, onDnD, pagination, config = { isSearchable: false }, }, ref) => {
|
|
34
25
|
// refs
|
|
@@ -88,6 +79,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
88
79
|
// states -> Mobil
|
|
89
80
|
const [isMobile, setIsMobile] = useState(false);
|
|
90
81
|
// hooks
|
|
82
|
+
const { t } = useTranslation(String(config.locale ?? "tr"));
|
|
91
83
|
// Dışarıdan gelen ref'i _innerRef'e bağla.
|
|
92
84
|
useImperativeHandle(ref, () => _innerRef.current);
|
|
93
85
|
if (config && Object.keys(config.scroll || {}).length > 0) {
|
|
@@ -236,14 +228,14 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
236
228
|
React.createElement(Column, { size: 12 },
|
|
237
229
|
React.createElement(Select, { value: filterOption.find((x) => x.value === filterPopupOption?.option?.value && filterPopupOption.key === c.key) ?? filterOption[0], options: filterOption, onChange: (option) => {
|
|
238
230
|
setFilterPopupOption({ key: c.key, option: option });
|
|
239
|
-
}, placeholder: "
|
|
231
|
+
}, placeholder: t("Table.Filters.Where.Input.Placeholder") })),
|
|
240
232
|
React.createElement(Column, { size: 12 },
|
|
241
|
-
React.createElement(Input, { value: value ?? "", onChange: (event) => handleChange(event.target.value), placeholder: "
|
|
233
|
+
React.createElement(Input, { value: value ?? "", onChange: (event) => handleChange(event.target.value), placeholder: t("Table.Filters.Search.Input.Placeholder") }))));
|
|
242
234
|
case "object":
|
|
243
235
|
case "boolean":
|
|
244
236
|
return (React.createElement(Row, null,
|
|
245
237
|
React.createElement(Column, { size: 12 },
|
|
246
|
-
React.createElement(Input, {
|
|
238
|
+
React.createElement(Input, { value: value ?? "", onChange: (event) => setFilterPopupOptionSearchText(event.target.value), placeholder: t("Table.Filters.Search.Input.Placeholder") })),
|
|
247
239
|
React.createElement(Column, { size: 12 }, c.filters
|
|
248
240
|
?.filter((filter) => filter.text.toLocaleLowerCase().includes(filterPopupOptionSearchText?.toLocaleLowerCase() ?? ""))
|
|
249
241
|
?.map((filter, fIndex) => {
|
|
@@ -577,6 +569,16 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
577
569
|
window.removeEventListener("resize", handleResize);
|
|
578
570
|
};
|
|
579
571
|
}, []);
|
|
572
|
+
const filterOption = [
|
|
573
|
+
{ value: FilterOperator.Contains, text: t("Table.Filters.Where.Input.Item.1.Text") },
|
|
574
|
+
{ value: FilterOperator.DoesNotContains, text: t("Table.Filters.Where.Input.Item.2.Text") },
|
|
575
|
+
{ value: FilterOperator.Equals, text: t("Table.Filters.Where.Input.Item.3.Text") },
|
|
576
|
+
{ value: FilterOperator.DoesNotEquals, text: t("Table.Filters.Where.Input.Item.4.Text") },
|
|
577
|
+
{ value: FilterOperator.BeginsWith, text: t("Table.Filters.Where.Input.Item.5.Text") },
|
|
578
|
+
{ value: FilterOperator.EndsWith, text: t("Table.Filters.Where.Input.Item.6.Text") },
|
|
579
|
+
{ value: FilterOperator.Blank, text: t("Table.Filters.Where.Input.Item.7.Text") },
|
|
580
|
+
{ value: FilterOperator.NotBlank, text: t("Table.Filters.Where.Input.Item.8.Text") },
|
|
581
|
+
];
|
|
580
582
|
return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
|
|
581
583
|
(title || description || actions || React.Children.count(children) > 0) && (React.createElement(Header, { title: title, description: description, actions: actions })),
|
|
582
584
|
React.createElement("div", { ref: _tableContent, className: "content", onScroll: handleScroll },
|
|
@@ -682,7 +684,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
682
684
|
}, states: {
|
|
683
685
|
open: { get: openProperties, set: setOpenProperties },
|
|
684
686
|
sort: { get: sortConfig, set: setSortConfig, currentColumn: sortCurrentColumn },
|
|
685
|
-
}, methods: { handleScroll }, coordinate: propertiesButtonCoordinate })),
|
|
687
|
+
}, methods: { handleScroll }, coordinate: propertiesButtonCoordinate, config: config })),
|
|
686
688
|
React.createElement("div", { className: "footer" },
|
|
687
689
|
React.createElement("span", null, isMobile ? (React.createElement(React.Fragment, null,
|
|
688
690
|
React.createElement("strong", null,
|
|
@@ -692,18 +694,7 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
|
|
|
692
694
|
Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length),
|
|
693
695
|
" of",
|
|
694
696
|
" ",
|
|
695
|
-
pagination?.totalRecords || getData.length))) : (
|
|
696
|
-
React.createElement("strong", null,
|
|
697
|
-
"Showing ",
|
|
698
|
-
(currentPage - 1) * selectedPerPage + 1,
|
|
699
|
-
" to",
|
|
700
|
-
" ",
|
|
701
|
-
Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length)),
|
|
702
|
-
" ",
|
|
703
|
-
React.createElement("span", null,
|
|
704
|
-
"of ",
|
|
705
|
-
pagination?.totalRecords || getData.length,
|
|
706
|
-
" agreements")))),
|
|
697
|
+
pagination?.totalRecords || getData.length))) : (t("Table.Pagination.Information.Text", (currentPage - 1) * selectedPerPage + 1, Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length), pagination?.totalRecords || getData.length))),
|
|
707
698
|
pagination && (React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : (totalRecords ?? 0), currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
|
|
708
699
|
setCurrentPage(currentPage);
|
|
709
700
|
setSelectedPerPage(perPage);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { INotificationLocale } from "../locales";
|
|
2
|
+
import ITableLocale from "../locales/table/ITableLocale";
|
|
2
3
|
type LocaleMap = Record<string, Record<string, any>>;
|
|
3
4
|
declare const useTranslation: <TBaseLocale>(currentLanguage: string | undefined, translations?: LocaleMap) => {
|
|
4
|
-
t: (key: Extract<keyof TBaseLocale | keyof INotificationLocale, string>, ...args: any[]) => string;
|
|
5
|
+
t: (key: Extract<keyof TBaseLocale | keyof ITableLocale | keyof INotificationLocale, string>, ...args: any[]) => string;
|
|
5
6
|
currentLanguage: string | undefined;
|
|
6
7
|
};
|
|
7
8
|
export default useTranslation;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import Utils from "../../../infrastructure/shared/Utils";
|
|
2
2
|
import { NotificationEN, NotificationTR } from "../locales";
|
|
3
|
+
import TableEN from "../locales/table/en";
|
|
4
|
+
import TableTR from "../locales/table/tr";
|
|
3
5
|
const useTranslation = function (currentLanguage, translations = {}) {
|
|
4
6
|
const merged = {};
|
|
5
|
-
const
|
|
6
|
-
tr: NotificationTR,
|
|
7
|
-
en: NotificationEN,
|
|
7
|
+
const ExtraLocales = {
|
|
8
|
+
tr: { ...TableTR, ...NotificationTR },
|
|
9
|
+
en: { ...TableEN, ...NotificationEN },
|
|
8
10
|
};
|
|
9
|
-
const allLanguages = new Set([...Object.keys(translations), ...Object.keys(
|
|
11
|
+
const allLanguages = new Set([...Object.keys(translations), ...Object.keys(ExtraLocales)]);
|
|
10
12
|
allLanguages.forEach((lang) => {
|
|
11
13
|
merged[lang] = {
|
|
12
14
|
...translations[lang],
|
|
13
|
-
...
|
|
15
|
+
...ExtraLocales[lang],
|
|
14
16
|
};
|
|
15
17
|
});
|
|
16
18
|
const t = (key, ...args) => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface ITableLocale {
|
|
2
|
+
"Table.Properties.Asc.Text": string;
|
|
3
|
+
"Table.Properties.Desc.Text": string;
|
|
4
|
+
"Table.Properties.ClearSort.Text": string;
|
|
5
|
+
"Table.Filters.Where.Input.Placeholder": string;
|
|
6
|
+
"Table.Filters.Where.Input.Item.1.Text": string;
|
|
7
|
+
"Table.Filters.Where.Input.Item.2.Text": string;
|
|
8
|
+
"Table.Filters.Where.Input.Item.3.Text": string;
|
|
9
|
+
"Table.Filters.Where.Input.Item.4.Text": string;
|
|
10
|
+
"Table.Filters.Where.Input.Item.5.Text": string;
|
|
11
|
+
"Table.Filters.Where.Input.Item.6.Text": string;
|
|
12
|
+
"Table.Filters.Where.Input.Item.7.Text": string;
|
|
13
|
+
"Table.Filters.Where.Input.Item.8.Text": string;
|
|
14
|
+
"Table.Filters.Search.Input.Placeholder": string;
|
|
15
|
+
"Table.Pagination.Information.Text": string;
|
|
16
|
+
}
|
|
17
|
+
export default ITableLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const TableEN = {
|
|
2
|
+
// Properties
|
|
3
|
+
"Table.Properties.Asc.Text": "Sort Ascending",
|
|
4
|
+
"Table.Properties.Desc.Text": "Sort Descending",
|
|
5
|
+
"Table.Properties.ClearSort.Text": "Clear Sort",
|
|
6
|
+
// Filters
|
|
7
|
+
"Table.Filters.Where.Input.Placeholder": "Where",
|
|
8
|
+
"Table.Filters.Where.Input.Item.1.Text": "Contains",
|
|
9
|
+
"Table.Filters.Where.Input.Item.2.Text": "Does Not Contain",
|
|
10
|
+
"Table.Filters.Where.Input.Item.3.Text": "Equals",
|
|
11
|
+
"Table.Filters.Where.Input.Item.4.Text": "Does Not Equal",
|
|
12
|
+
"Table.Filters.Where.Input.Item.5.Text": "Starts With",
|
|
13
|
+
"Table.Filters.Where.Input.Item.6.Text": "Ends With",
|
|
14
|
+
"Table.Filters.Where.Input.Item.7.Text": "Is Empty",
|
|
15
|
+
"Table.Filters.Where.Input.Item.8.Text": "Is Not Empty",
|
|
16
|
+
"Table.Filters.Search.Input.Placeholder": "Search",
|
|
17
|
+
// Pagination
|
|
18
|
+
"Table.Pagination.Information.Text": "Showing {0} to {1} of {2} agreements",
|
|
19
|
+
};
|
|
20
|
+
export default TableEN;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const TableTR = {
|
|
2
|
+
// Properties
|
|
3
|
+
"Table.Properties.Asc.Text": "Artan Sırada Sırala",
|
|
4
|
+
"Table.Properties.Desc.Text": "Azalan Sırada Sırala",
|
|
5
|
+
"Table.Properties.ClearSort.Text": "Sıralamayı Temizle",
|
|
6
|
+
// Filters
|
|
7
|
+
"Table.Filters.Where.Input.Placeholder": "Koşul",
|
|
8
|
+
"Table.Filters.Where.Input.Item.1.Text": "İçerir",
|
|
9
|
+
"Table.Filters.Where.Input.Item.2.Text": "İçermez",
|
|
10
|
+
"Table.Filters.Where.Input.Item.3.Text": "Eşittir",
|
|
11
|
+
"Table.Filters.Where.Input.Item.4.Text": "Eşit değildir",
|
|
12
|
+
"Table.Filters.Where.Input.Item.5.Text": "İle başlar",
|
|
13
|
+
"Table.Filters.Where.Input.Item.6.Text": "İle biter",
|
|
14
|
+
"Table.Filters.Where.Input.Item.7.Text": "Boş",
|
|
15
|
+
"Table.Filters.Where.Input.Item.8.Text": "Boş değil",
|
|
16
|
+
"Table.Filters.Search.Input.Placeholder": "Ara",
|
|
17
|
+
// Pagination
|
|
18
|
+
"Table.Pagination.Information.Text": "{2} kayıt içerisinden {0} - {1} aralığı listeleniyor",
|
|
19
|
+
};
|
|
20
|
+
export default TableTR;
|
|
@@ -20,8 +20,8 @@ declare class DATE {
|
|
|
20
20
|
* @param locale
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
|
-
Verbose: (date: Date, locale?: string) => string;
|
|
24
|
-
WithTime: (date: Date, locale?: string) => string;
|
|
23
|
+
Verbose: (date: Date, locale?: string, UTC?: boolean) => string;
|
|
24
|
+
WithTime: (date: Date, locale?: string, UTC?: boolean) => string;
|
|
25
25
|
private GetLocaleFromLanguage;
|
|
26
26
|
}
|
|
27
27
|
declare const _default: DATE;
|
|
@@ -30,20 +30,22 @@ class DATE {
|
|
|
30
30
|
* @param locale
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
Verbose = (date, locale = "tr") => {
|
|
33
|
+
Verbose = (date, locale = "tr", UTC = false) => {
|
|
34
34
|
return date.toLocaleDateString(this.GetLocaleFromLanguage(locale), {
|
|
35
35
|
day: "numeric",
|
|
36
36
|
month: "long",
|
|
37
37
|
year: "numeric",
|
|
38
|
+
...(UTC ? { timeZone: "UTC" } : {}),
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
|
-
WithTime = (date, locale = "tr") => {
|
|
41
|
+
WithTime = (date, locale = "tr", UTC = false) => {
|
|
41
42
|
return date.toLocaleString(this.GetLocaleFromLanguage(locale), {
|
|
42
43
|
day: "numeric",
|
|
43
44
|
month: "long",
|
|
44
45
|
year: "numeric",
|
|
45
46
|
hour: "2-digit",
|
|
46
47
|
minute: "2-digit",
|
|
48
|
+
...(UTC ? { timeZone: "UTC" } : {}),
|
|
47
49
|
});
|
|
48
50
|
};
|
|
49
51
|
GetLocaleFromLanguage = (lang) => {
|