ar-design 0.4.16 → 0.4.19

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.
@@ -676,28 +676,28 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
676
676
  open: { get: openProperties, set: setOpenProperties },
677
677
  sort: { get: sortConfig, set: setSortConfig, currentColumn: sortCurrentColumn },
678
678
  }, coordinate: propertiesButtonCoordinate })),
679
- pagination && (React.createElement("div", { className: "footer" },
679
+ React.createElement("div", { className: "footer" },
680
680
  React.createElement("span", null, isMobile ? (React.createElement(React.Fragment, null,
681
681
  React.createElement("strong", null,
682
682
  (currentPage - 1) * selectedPerPage + 1,
683
683
  " -",
684
684
  " ",
685
- Math.min(currentPage * selectedPerPage, pagination.totalRecords || getData.length),
685
+ Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length),
686
686
  " of",
687
687
  " ",
688
- pagination.totalRecords || getData.length))) : (React.createElement(React.Fragment, null,
688
+ pagination?.totalRecords || getData.length))) : (React.createElement(React.Fragment, null,
689
689
  React.createElement("strong", null,
690
690
  "Showing ",
691
691
  (currentPage - 1) * selectedPerPage + 1,
692
692
  " to",
693
693
  " ",
694
- Math.min(currentPage * selectedPerPage, pagination.totalRecords || getData.length)),
694
+ Math.min(currentPage * selectedPerPage, pagination?.totalRecords || getData.length)),
695
695
  " ",
696
696
  React.createElement("span", null,
697
697
  "of ",
698
- pagination.totalRecords || getData.length,
698
+ pagination?.totalRecords || getData.length,
699
699
  " agreements")))),
700
- React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : (totalRecords ?? 0), currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
700
+ pagination && (React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : (totalRecords ?? 0), currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
701
701
  setCurrentPage(currentPage);
702
702
  setSelectedPerPage(perPage);
703
703
  pagination.onChange?.(currentPage, perPage);
@@ -1,11 +1,11 @@
1
1
  import { IBorder, IColors, IValidation, IVariant } from "../../../../libs/types/IGlobalProps";
2
2
  import { Option } from "../../../../libs/types";
3
3
  interface IProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "color">, IVariant, IColors, IBorder, IValidation {
4
- options: Option[];
4
+ options?: Option[];
5
5
  values: {
6
- option: string;
6
+ option?: string;
7
7
  value: string | number | readonly string[] | undefined;
8
8
  };
9
- onSelected: (option: Option | undefined) => void;
9
+ onSelected?: (option: Option | undefined) => void;
10
10
  }
11
11
  export default IProps;
@@ -20,14 +20,14 @@ const Phone = ({ variant, color, options, values, onSelected, validation, ...att
20
20
  // useEffects
21
21
  useEffect(() => {
22
22
  setValue(values.value);
23
- setSelected(options.find((option) => option.value === values.option));
23
+ setSelected(options?.find((option) => option.value === values.option));
24
24
  }, [values]);
25
25
  return (React.createElement("div", { className: "ar-input-phone-wrapper" },
26
- React.createElement(Select, { style: { width: 130 }, variant: "outlined", color: "light", options: options, value: selected, onChange: (option) => {
27
- onSelected(option);
26
+ options && (React.createElement(Select, { style: { width: 130 }, variant: "outlined", color: "light", options: options, value: selected, onChange: (option) => {
27
+ onSelected?.(option);
28
28
  setSelected(option);
29
- } }),
30
- React.createElement(Input, { ref: _input, ...attributes, variant: variant, color: color, value: PHONE.FormatByMask(selected?.value, _value), type: "tel", inputMode: "decimal", onChange: (event) => {
29
+ } })),
30
+ React.createElement(Input, { ref: _input, ...attributes, ...(!options ? { style: { borderRadius: "var(--border-radius-sm)" } } : {}), variant: variant, color: color, value: PHONE.FormatByMask(selected?.value, _value), type: "tel", inputMode: "decimal", onChange: (event) => {
31
31
  if (attributes.disabled)
32
32
  return;
33
33
  (() => {
@@ -12,7 +12,7 @@ const NotificationEN = {
12
12
  "Notification.202.Message": "The request has been accepted and is being processed.",
13
13
  // 204 No Content -> PUT Processes
14
14
  "Notification.204.Title": "Operation Successful",
15
- "Notification.204.Message": "The content has been updated, but no data was returned.",
15
+ "Notification.204.Message": "The content has been updated.",
16
16
  "Notification.204.Delete.Title": "Removal Successful",
17
17
  "Notification.204.Delete.Message": "The removal process was successful.",
18
18
  // 301 Moved Permanently
@@ -12,7 +12,7 @@ const NotificationTR = {
12
12
  "Notification.202.Message": "İstek kabul edildi, işleniyor.",
13
13
  // 204 No Content -> PUT Processes
14
14
  "Notification.204.Title": "İşlem Başarılı",
15
- "Notification.204.Message": "Kayıtlı içerik güncellendi ancak herhangi bir veri döndürülmedi.",
15
+ "Notification.204.Message": "Kayıtlı içerik güncellendi.",
16
16
  "Notification.204.Delete.Title": "Kaldırma Başarılı",
17
17
  "Notification.204.Delete.Message": "Kaldırma işlemi başarılı.",
18
18
  // 301 Moved Permanently
@@ -1,8 +1,8 @@
1
1
  declare class PHONE {
2
- FormatByMask: (code: string, value: string) => string;
2
+ FormatByMask: (countryCode: string, value: string) => string;
3
3
  private GetMaskByCountry;
4
- private countryMasks;
5
4
  private GenerateMask;
5
+ private countryMasks;
6
6
  }
7
7
  declare const _default: PHONE;
8
8
  export default _default;
@@ -1,7 +1,7 @@
1
1
  class PHONE {
2
- FormatByMask = (code, value) => {
3
- const mask = this.GetMaskByCountry(code ?? "+90");
2
+ FormatByMask = (countryCode, value) => {
4
3
  const digits = value.replace(/\D/g, "");
4
+ const mask = this.GetMaskByCountry(countryCode ?? "+90", digits.length);
5
5
  let result = "";
6
6
  let i = 0;
7
7
  for (const char of mask) {
@@ -17,35 +17,26 @@ class PHONE {
17
17
  return result;
18
18
  };
19
19
  GetMaskByCountry(countryCode, length) {
20
- if (countryCode && this.countryMasks[countryCode]) {
21
- return this.countryMasks[countryCode];
20
+ const masks = countryCode ? this.countryMasks[countryCode] : undefined;
21
+ if (masks && masks.length > 0) {
22
+ if (length) {
23
+ const exact = masks.find((m) => typeof m !== "string" && !!m.lengths?.includes(length));
24
+ if (exact)
25
+ return exact.mask;
26
+ const generic = masks.find((m) => typeof m !== "string" && !m.lengths);
27
+ if (generic)
28
+ return generic.mask;
29
+ const closest = masks
30
+ .filter((m) => typeof m !== "string" && !!m.lengths)
31
+ .sort((a, b) => Math.abs((a.lengths[0] ?? 0) - length) - Math.abs((b.lengths[0] ?? 0) - length))[0];
32
+ if (closest)
33
+ return closest.mask;
34
+ }
35
+ const first = masks[0];
36
+ return typeof first === "string" ? first : first.mask;
22
37
  }
23
- // fallback: length varsa ona göre üret, yoksa 10 ile varsayılan
24
38
  return this.GenerateMask(length ?? 10);
25
39
  }
26
- countryMasks = {
27
- "+90": "999 999 99 99", // Türkiye
28
- "+1": "999 999 9999", // ABD / Kanada
29
- "+44": "9999 999999", // İngiltere
30
- "+49": "9999 9999999", // Almanya
31
- "+33": "9 99 99 99 99", // Fransa
32
- "+39": "999 999 9999", // İtalya
33
- "+34": "999 999 999", // İspanya
34
- "+351": "999 999 999", // Portekiz
35
- "+31": "9 99999999", // Hollanda
36
- "+32": "999 99 99 99", // Belçika
37
- "+41": "99 999 99 99", // İsviçre
38
- "+7": "999 999 99 99", // Rusya / Kazakistan
39
- "+91": "99999 99999", // Hindistan
40
- "+86": "999 9999 9999", // Çin
41
- "+81": "99 9999 9999", // Japonya
42
- "+82": "99 9999 9999", // Güney Kore
43
- "+61": "9 9999 9999", // Avustralya
44
- "+55": "99 99999 9999", // Brezilya
45
- "+52": "999 999 9999", // Meksika
46
- "+54": "99 9999 9999", // Arjantin
47
- };
48
- // length parametresi ile otomatik maske üret
49
40
  GenerateMask(length) {
50
41
  if (length <= 0)
51
42
  return "";
@@ -56,5 +47,80 @@ class PHONE {
56
47
  .map((g) => "9".repeat(g))
57
48
  .join(" ");
58
49
  }
50
+ countryMasks = {
51
+ // 🇹🇷 Türkiye
52
+ "+90": [{ mask: "999 999 99 99", lengths: [10] }],
53
+ // 🇩🇪 Almanya
54
+ "+49": [
55
+ { mask: "999 9999999", lengths: [10] },
56
+ { mask: "9999 999999", lengths: [10, 11] },
57
+ { mask: "99999 99999", lengths: [10] },
58
+ ],
59
+ // 🇧🇷 Brezilya
60
+ "+55": [
61
+ { mask: "99 9999 9999", lengths: [10] }, // sabit
62
+ { mask: "99 99999 9999", lengths: [11] }, // mobil
63
+ ],
64
+ // 🇺🇸 ABD / 🇨🇦 Kanada
65
+ "+1": [{ mask: "999 999 9999", lengths: [10] }],
66
+ // 🇬🇧 İngiltere
67
+ "+44": [
68
+ { mask: "9999 999999", lengths: [10] }, // London / area
69
+ { mask: "99 9999 9999", lengths: [10] }, // mobile
70
+ ],
71
+ // 🇫🇷 Fransa
72
+ "+33": [{ mask: "9 99 99 99 99", lengths: [9] }],
73
+ // 🇮🇹 İtalya
74
+ "+39": [{ mask: "999 999 9999", lengths: [9, 10] }],
75
+ // 🇪🇸 İspanya
76
+ "+34": [{ mask: "999 999 999", lengths: [9] }],
77
+ // 🇳🇱 Hollanda
78
+ "+31": [{ mask: "9 99999999", lengths: [9] }],
79
+ // 🇧🇪 Belçika
80
+ "+32": [{ mask: "999 99 99 99", lengths: [9] }],
81
+ // 🇨🇭 İsviçre
82
+ "+41": [{ mask: "99 999 99 99", lengths: [9] }],
83
+ // 🇵🇹 Portekiz
84
+ "+351": [{ mask: "999 999 999", lengths: [9] }],
85
+ // 🇷🇺 Rusya / 🇰🇿 Kazakistan
86
+ "+7": [{ mask: "999 999 99 99", lengths: [10] }],
87
+ // 🇮🇳 Hindistan
88
+ "+91": [{ mask: "99999 99999", lengths: [10] }],
89
+ // 🇨🇳 Çin
90
+ "+86": [{ mask: "999 9999 9999", lengths: [11] }],
91
+ // 🇯🇵 Japonya
92
+ "+81": [{ mask: "99 9999 9999", lengths: [10] }],
93
+ // 🇰🇷 Güney Kore
94
+ "+82": [
95
+ { mask: "99 9999 9999", lengths: [10] },
96
+ { mask: "999 9999 9999", lengths: [11] },
97
+ ],
98
+ // 🇦🇺 Avustralya
99
+ "+61": [{ mask: "9 9999 9999", lengths: [9] }],
100
+ // 🇲🇽 Meksika
101
+ "+52": [{ mask: "999 999 9999", lengths: [10] }],
102
+ // 🇦🇷 Arjantin
103
+ "+54": [{ mask: "99 9999 9999", lengths: [10] }],
104
+ // 🇿🇦 Güney Afrika
105
+ "+27": [{ mask: "99 999 9999", lengths: [9] }],
106
+ // 🇦🇪 BAE
107
+ "+971": [{ mask: "99 999 9999", lengths: [9] }],
108
+ // 🇸🇦 Suudi Arabistan
109
+ "+966": [{ mask: "99 999 9999", lengths: [9] }],
110
+ // 🇮🇱 İsrail
111
+ "+972": [{ mask: "99 999 9999", lengths: [9] }],
112
+ // 🇪🇬 Mısır
113
+ "+20": [{ mask: "9999 999999", lengths: [10] }],
114
+ // 🇳🇬 Nijerya
115
+ "+234": [{ mask: "999 999 9999", lengths: [10] }],
116
+ // 🇸🇪 İsveç
117
+ "+46": [{ mask: "99 999 9999", lengths: [9, 10] }],
118
+ // 🇳🇴 Norveç
119
+ "+47": [{ mask: "999 99 999", lengths: [8] }],
120
+ // 🇩🇰 Danimarka
121
+ "+45": [{ mask: "99 99 99 99", lengths: [8] }],
122
+ // 🇵🇱 Polonya
123
+ "+48": [{ mask: "999 999 999", lengths: [9] }],
124
+ };
59
125
  }
60
126
  export default new PHONE();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.4.16",
3
+ "version": "0.4.19",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",