@sydsoft/base 1.48.0 → 1.49.0

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.
Files changed (130) hide show
  1. package/{dist/esm → _dist}/_lib/baseFunctions.d.ts +0 -1
  2. package/_dist/_lib/storage/cookies.d.ts +4 -0
  3. package/_dist/alert/index.module.css +119 -0
  4. package/{dist/esm → _dist}/form/SearchableInput.d.ts +0 -1
  5. package/_dist/grid/index.module.css +805 -0
  6. package/{dist/esm → _dist}/icon/index.d.ts +1 -1
  7. package/_dist/menu/index.module.css +92 -0
  8. package/_dist/modal/index.module.css +77 -0
  9. package/_lib/baseFunctions.ts +94 -0
  10. package/_lib/inputMask.ts +257 -0
  11. package/_lib/listFunctions.ts +106 -0
  12. package/_lib/storage/cookies.ts +39 -0
  13. package/_lib/storage/encData.ts +41 -0
  14. package/_lib/storage/localStorage.ts +67 -0
  15. package/_lib/storage/sessionStorage.ts +67 -0
  16. package/_lib/useInterval.ts +30 -0
  17. package/alert/index.module.css +119 -0
  18. package/alert/index.tsx +131 -0
  19. package/box/Box.module.css +153 -0
  20. package/box/Box.tsx +33 -0
  21. package/box/BoxContent.tsx +18 -0
  22. package/box/BoxFooter.tsx +25 -0
  23. package/box/BoxHeader.tsx +46 -0
  24. package/box/index.ts +10 -0
  25. package/countDown/index.tsx +116 -0
  26. package/dateTime/index.ts +79 -0
  27. package/form/Button.tsx +143 -0
  28. package/form/Checkbox.tsx +48 -0
  29. package/form/Dialog.tsx +109 -0
  30. package/form/Form.tsx +19 -0
  31. package/form/FormOlustur.tsx +105 -0
  32. package/form/Input.tsx +364 -0
  33. package/form/Label.tsx +20 -0
  34. package/form/SearchableInput.tsx +406 -0
  35. package/form/UploadBase.tsx +133 -0
  36. package/form/index.ts +10 -0
  37. package/form/styles/Button.module.css +145 -0
  38. package/form/styles/Input.module.css +221 -0
  39. package/form/styles/Label.module.css +31 -0
  40. package/form/styles/SearchableInput.module.css +80 -0
  41. package/global.d.ts +9 -0
  42. package/grid/index.module.css +805 -0
  43. package/grid/index.tsx +171 -0
  44. package/icon/icons.tsx +33 -0
  45. package/icon/index.tsx +95 -0
  46. package/icon/mui.tsx +5932 -0
  47. package/index.ts +21 -0
  48. package/menu/index.module.css +92 -0
  49. package/menu/index.tsx +143 -0
  50. package/modal/index.module.css +77 -0
  51. package/modal/index.tsx +106 -0
  52. package/npm_recovery_codes.txt +5 -0
  53. package/package.json +13 -12
  54. package/popover/index.module.css +89 -0
  55. package/popover/index.tsx +392 -0
  56. package/tooltip/index.tsx +216 -0
  57. package/tsconfig.json +24 -0
  58. package/dist/esm/_lib/storage/cookies.d.ts +0 -4
  59. /package/{dist/esm → _dist}/_lib/baseFunctions.js +0 -0
  60. /package/{dist/esm → _dist}/_lib/inputMask.d.ts +0 -0
  61. /package/{dist/esm → _dist}/_lib/inputMask.js +0 -0
  62. /package/{dist/esm → _dist}/_lib/listFunctions.d.ts +0 -0
  63. /package/{dist/esm → _dist}/_lib/listFunctions.js +0 -0
  64. /package/{dist/esm → _dist}/_lib/storage/cookies.js +0 -0
  65. /package/{dist/esm → _dist}/_lib/storage/encData.d.ts +0 -0
  66. /package/{dist/esm → _dist}/_lib/storage/encData.js +0 -0
  67. /package/{dist/esm → _dist}/_lib/storage/localStorage.d.ts +0 -0
  68. /package/{dist/esm → _dist}/_lib/storage/localStorage.js +0 -0
  69. /package/{dist/esm → _dist}/_lib/storage/sessionStorage.d.ts +0 -0
  70. /package/{dist/esm → _dist}/_lib/storage/sessionStorage.js +0 -0
  71. /package/{dist/esm → _dist}/_lib/useInterval.d.ts +0 -0
  72. /package/{dist/esm → _dist}/_lib/useInterval.js +0 -0
  73. /package/{dist/esm → _dist}/alert/index.d.ts +0 -0
  74. /package/{dist/esm → _dist}/alert/index.js +0 -0
  75. /package/{dist/esm → _dist}/box/Box.d.ts +0 -0
  76. /package/{dist/esm → _dist}/box/Box.js +0 -0
  77. /package/{dist/esm → _dist/box}/Box.module.css +0 -0
  78. /package/{dist/esm → _dist}/box/BoxContent.d.ts +0 -0
  79. /package/{dist/esm → _dist}/box/BoxContent.js +0 -0
  80. /package/{dist/esm → _dist}/box/BoxFooter.d.ts +0 -0
  81. /package/{dist/esm → _dist}/box/BoxFooter.js +0 -0
  82. /package/{dist/esm → _dist}/box/BoxHeader.d.ts +0 -0
  83. /package/{dist/esm → _dist}/box/BoxHeader.js +0 -0
  84. /package/{dist/esm → _dist}/box/index.d.ts +0 -0
  85. /package/{dist/esm → _dist}/box/index.js +0 -0
  86. /package/{dist/esm → _dist}/countDown/index.d.ts +0 -0
  87. /package/{dist/esm → _dist}/countDown/index.js +0 -0
  88. /package/{dist/esm → _dist}/dateTime/index.d.ts +0 -0
  89. /package/{dist/esm → _dist}/dateTime/index.js +0 -0
  90. /package/{dist/esm → _dist}/form/Button.d.ts +0 -0
  91. /package/{dist/esm → _dist}/form/Button.js +0 -0
  92. /package/{dist/esm → _dist}/form/Checkbox.d.ts +0 -0
  93. /package/{dist/esm → _dist}/form/Checkbox.js +0 -0
  94. /package/{dist/esm → _dist}/form/Dialog.d.ts +0 -0
  95. /package/{dist/esm → _dist}/form/Dialog.js +0 -0
  96. /package/{dist/esm → _dist}/form/Form.d.ts +0 -0
  97. /package/{dist/esm → _dist}/form/Form.js +0 -0
  98. /package/{dist/esm → _dist}/form/FormOlustur.d.ts +0 -0
  99. /package/{dist/esm → _dist}/form/FormOlustur.js +0 -0
  100. /package/{dist/esm → _dist}/form/Input.d.ts +0 -0
  101. /package/{dist/esm → _dist}/form/Input.js +0 -0
  102. /package/{dist/esm → _dist}/form/Label.d.ts +0 -0
  103. /package/{dist/esm → _dist}/form/Label.js +0 -0
  104. /package/{dist/esm → _dist}/form/SearchableInput.js +0 -0
  105. /package/{dist/esm → _dist}/form/UploadBase.d.ts +0 -0
  106. /package/{dist/esm → _dist}/form/UploadBase.js +0 -0
  107. /package/{dist/esm → _dist}/form/index.d.ts +0 -0
  108. /package/{dist/esm → _dist}/form/index.js +0 -0
  109. /package/{dist/esm → _dist/form}/styles/Button.module.css +0 -0
  110. /package/{dist/esm → _dist/form}/styles/Input.module.css +0 -0
  111. /package/{dist/esm → _dist/form}/styles/Label.module.css +0 -0
  112. /package/{dist/esm → _dist/form}/styles/SearchableInput.module.css +0 -0
  113. /package/{dist/esm → _dist}/grid/index.d.ts +0 -0
  114. /package/{dist/esm → _dist}/grid/index.js +0 -0
  115. /package/{dist/esm → _dist}/icon/icons.d.ts +0 -0
  116. /package/{dist/esm → _dist}/icon/icons.js +0 -0
  117. /package/{dist/esm → _dist}/icon/index.js +0 -0
  118. /package/{dist/esm → _dist}/icon/mui.d.ts +0 -0
  119. /package/{dist/esm → _dist}/icon/mui.js +0 -0
  120. /package/{dist/esm → _dist}/index.d.ts +0 -0
  121. /package/{dist/esm → _dist}/index.js +0 -0
  122. /package/{dist/esm → _dist}/menu/index.d.ts +0 -0
  123. /package/{dist/esm → _dist}/menu/index.js +0 -0
  124. /package/{dist/esm → _dist}/modal/index.d.ts +0 -0
  125. /package/{dist/esm → _dist}/modal/index.js +0 -0
  126. /package/{dist/esm → _dist}/popover/index.d.ts +0 -0
  127. /package/{dist/esm → _dist}/popover/index.js +0 -0
  128. /package/{dist/esm → _dist/popover}/index.module.css +0 -0
  129. /package/{dist/esm → _dist}/tooltip/index.d.ts +0 -0
  130. /package/{dist/esm → _dist}/tooltip/index.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { iconMap } from './icons';
3
3
  import { MaterialIconName } from './mui';
4
- export declare const iconList: ("search" | "close" | "edit" | "keyboard_arrow_down" | "keyboard_arrow_up")[];
4
+ export declare const iconList: IconName[];
5
5
  export type IconName = keyof typeof iconMap;
6
6
  interface BaseProps {
7
7
  color?: string;
@@ -0,0 +1,92 @@
1
+ .ul {
2
+ position: relative;
3
+ width: 100%;
4
+ max-height: calc(100vh - 94px);
5
+ list-style: none;
6
+ padding: 0;
7
+ margin: 0;
8
+ background: #fff;
9
+ letter-spacing: 0.2px;
10
+ outline: none;
11
+ border: 1px solid transparent;
12
+ border-radius: 4px;
13
+ box-shadow: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
14
+ overflow-y: auto;
15
+ user-select: none;
16
+ }
17
+
18
+ .ul > li {
19
+ cursor: pointer;
20
+ padding: 2px 6px;
21
+ min-height: 25px;
22
+ }
23
+ .ul > li,
24
+ .ul > li a {
25
+ display: flex;
26
+ flex-direction: row;
27
+ flex-wrap: nowrap;
28
+ width: 100%;
29
+ }
30
+ .ul > li a,
31
+ .ul > li a:visited {
32
+ color: inherit;
33
+ text-decoration: none;
34
+ }
35
+
36
+ .ul > li:first-child {
37
+ margin-top: 5px;
38
+ }
39
+
40
+ .ul > li:last-child {
41
+ margin-bottom: 5px;
42
+ }
43
+
44
+ .ul > li:hover {
45
+ background: #f0f2f5;
46
+ }
47
+
48
+ .ul > li:global(.spopover_active) {
49
+ background: #e8f0fe;
50
+ }
51
+
52
+ .menuicon {
53
+ display: inline-flex;
54
+ overflow: hidden;
55
+ width: 30px;
56
+ flex: 0 0 auto;
57
+ align-items: center;
58
+ justify-content: center;
59
+ color: #606060;
60
+ }
61
+
62
+ .menutitle {
63
+ display: inline-flex;
64
+ flex: 1;
65
+ align-items: center;
66
+ justify-content: flex-start;
67
+ margin: 0 10px;
68
+ }
69
+
70
+ .rightmenu {
71
+ display: inline-flex;
72
+ flex: 0 0 auto;
73
+ align-items: center;
74
+ justify-content: center;
75
+ color: #909090;
76
+ font-size: 12px;
77
+ width: 50px;
78
+ }
79
+ .rightmenu span {
80
+ user-select: none;
81
+ }
82
+
83
+ .seperator {
84
+ cursor: default !important;
85
+ background: #00000014 !important;
86
+ border: 0;
87
+ height: 1px;
88
+ min-height: 1px !important;
89
+ margin: 4px 0;
90
+ padding: 0 !important;
91
+ display: block !important;
92
+ }
@@ -0,0 +1,77 @@
1
+ .backdrop {
2
+ position: fixed;
3
+ z-index: 1300;
4
+ inset: 0;
5
+ display: none;
6
+ align-items: center;
7
+ justify-content: center;
8
+ background: rgba(0, 0, 0, 0.23);
9
+ width: 100%;
10
+ height: 100%;
11
+ outline: none;
12
+ }
13
+ .backdrop_open {
14
+ display: flex !important;
15
+ }
16
+
17
+ .modal {
18
+ position: relative;
19
+ min-width: 200px;
20
+ max-width: 90%;
21
+ max-height: calc(100% - 64px);
22
+ overflow-x: hidden;
23
+ border-radius: 8px;
24
+ background: transparent;
25
+ box-shadow:
26
+ rgb(0 0 0 / 32%) 0 4px 8px,
27
+ rgb(0 0 0 / 40%) 0 8px 40px;
28
+ margin: 15px;
29
+ padding: 0;
30
+ z-index: 1;
31
+ outline: none;
32
+ }
33
+ .fullscreen {
34
+ width: 100vw;
35
+ max-width: 100vw;
36
+ height: 100vh;
37
+ max-height: 100vh;
38
+ border-radius: 0;
39
+ margin: 0;
40
+ }
41
+ .close_fixed {
42
+ position: absolute;
43
+ top: 2px;
44
+ right: 2px;
45
+ z-index: 1000;
46
+ text-align: right;
47
+ border-radius: inherit;
48
+ }
49
+
50
+ .close {
51
+ position: fixed;
52
+ background: linear-gradient(0deg, transparent, #00000026, transparent);
53
+ padding: 8px 10px;
54
+ font-size: 11px;
55
+ transform: scale(1) translateX(-100%);
56
+ border-radius: none;
57
+ cursor: pointer;
58
+ font-weight: bold;
59
+ text-shadow: 1px 0px 0px #000000;
60
+ transition: all 0.3s ease-in-out;
61
+ }
62
+ .close:hover {
63
+ transform: scale(1.3) translateX(-85%);
64
+ background: linear-gradient(180deg, transparent, #0000003a, transparent);
65
+ }
66
+
67
+ .sbox_header {
68
+ position: sticky;
69
+ top: 0;
70
+ z-index: 10;
71
+ }
72
+
73
+ .sbox_footer {
74
+ position: sticky;
75
+ bottom: 0;
76
+ z-index: 10;
77
+ }
@@ -0,0 +1,94 @@
1
+ export const isDev = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
2
+ export const isServerReq = (context: any) => !context?.req?.url?.startsWith('/_next');
3
+ export const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
4
+
5
+ export const padNumber = (num: number, padLength = 2, padString = '0') => String(num).padStart(padLength, padString);
6
+
7
+ export function inputTumuBuyukCevir(e: React.ChangeEvent<HTMLInputElement>) {
8
+ if (e?.target && e?.target?.setSelectionRange) {
9
+ const start = e.target.selectionStart;
10
+ const end = e.target.selectionEnd;
11
+ e.target.value = e.target.value.toString().toLocaleUpperCase('tr-TR');
12
+ e.target.setSelectionRange(start, end);
13
+ }
14
+ }
15
+
16
+ export function inputTumuKucukCevir(e: React.ChangeEvent<HTMLInputElement>) {
17
+ if (e?.target && e?.target?.setSelectionRange) {
18
+ const start = e.target.selectionStart;
19
+ const end = e.target.selectionEnd;
20
+ e.target.value = e.target.value.toString().toLocaleLowerCase('tr-TR');
21
+ e.target.setSelectionRange(start, end);
22
+ }
23
+ }
24
+
25
+ export const convertLowerCase = (text: any = '') => text.toString().toLocaleLowerCase('tr-TR');
26
+
27
+ export const convertForSearch = (value: string) => {
28
+ let data = value?.toString().toLocaleLowerCase('tr-TR');
29
+ data = data.replace(/ö/g, 'o');
30
+ data = data.replace(/ç/g, 'c');
31
+ data = data.replace(/ş/g, 's');
32
+ data = data.replace(/ı/g, 'i');
33
+ data = data.replace(/ğ/g, 'g');
34
+ data = data.replace(/ü/g, 'u');
35
+ data = data.replace(/[^a-z\d]/g, ''); // %_- are allowed
36
+ data = data.replace(/^\s+|\s+$/g, '');
37
+ return data;
38
+ };
39
+
40
+ export function convertForSEO(e: React.ChangeEvent<HTMLInputElement>) {
41
+ if (e?.target && e?.target?.setSelectionRange) {
42
+ const start = e.target.selectionStart;
43
+ const end = e.target.selectionEnd;
44
+ let string = e.target.value.toString().toLocaleLowerCase('tr');
45
+ const turkce = [' ', '-', 'ş', 'Ş', 'ı', 'ü', 'Ü', 'ö', 'Ö', 'ç', 'Ç', 'ş', 'Ş', 'ı', 'ğ', 'Ğ', 'İ', 'ö', 'Ö', 'Ç', 'ç', 'ü', 'Ü', 'â', 'ê', 'Â', '“', '”'];
46
+ const duzgun = ['-', '-', 's', 'S', 'i', 'u', 'U', 'o', 'O', 'c', 'C', 's', 'S', 'i', 'g', 'G', 'I', 'o', 'O', 'C', 'c', 'u', 'U', 'a', 'ê', 'a', '', ''];
47
+ for (let i = 0; i < turkce.length; i++) {
48
+ string = string.split(turkce[i]).join(duzgun[i]);
49
+ }
50
+ string = string.replace(/[^a-z0-9\-_şıüğçİŞĞÜÇ]+/gi, '_');
51
+ string = string.replace(/_+/g, '_');
52
+ string = string.replace(/^-/, '_');
53
+ string = string.replace(/-$/, '_');
54
+
55
+ e.target.value = string;
56
+ e.target.setSelectionRange(start, end);
57
+ }
58
+ }
59
+
60
+ export function getDomain(context: any = null) {
61
+ let url = '';
62
+ if (context) {
63
+ url = context.req.headers.host;
64
+ } else if (typeof window !== 'undefined') {
65
+ url = window.location.hostname;
66
+ }
67
+
68
+ if (url.length) {
69
+ const parts = url.split('.').reverse();
70
+ const cnt = parts.length;
71
+ if (cnt >= 3) {
72
+ // see if the second level domain is a common SLD.
73
+ if (parts[1].match(/^(com|edu|gov|net|mil|org|nom|co|name|info|biz)$/i)) {
74
+ const domain = parts[2] + '.' + parts[1] + '.' + parts[0];
75
+ return domain.split(':')[0];
76
+ }
77
+ }
78
+ const domain = parts[1] + '.' + parts[0];
79
+ return domain.split(':')[0];
80
+ }
81
+ return url;
82
+ }
83
+
84
+ export const uniqueID = (key = '', length = 16) => {
85
+ return (
86
+ key +
87
+ parseInt(
88
+ Math.ceil(Math.random() * Date.now())
89
+ .toPrecision(length)
90
+ .toString()
91
+ .replace('.', '')
92
+ )
93
+ );
94
+ };
@@ -0,0 +1,257 @@
1
+ import { isDev } from "./baseFunctions";
2
+
3
+ // Mask işleme core fonksiyonları
4
+ const createMaskCore = () => {
5
+ const defaultTranslation: any = {
6
+ "0": { pattern: /\d/ },
7
+ "9": { pattern: /\d/, optional: true },
8
+ "#": { pattern: /\d/, recursive: true },
9
+ A: { pattern: /[a-zA-Z0-9]/ },
10
+ S: { pattern: /[a-zA-Z]/ },
11
+ U: { pattern: /[a-zA-Z]/, transform: (char: any) => char.toUpperCase() },
12
+ L: { pattern: /[a-zA-Z]/, transform: (char: any) => char.toLowerCase() },
13
+ X: { pattern: /[0-9a-fA-F]/ }
14
+ };
15
+
16
+ const parseMask = (maskString: string, translation = defaultTranslation) => {
17
+ const tokens = [];
18
+ let i = 0;
19
+
20
+ while (i < maskString.length) {
21
+ const char = maskString[i];
22
+
23
+ if (translation[char]) {
24
+ tokens.push({
25
+ type: "input",
26
+ pattern: translation[char].pattern,
27
+ optional: translation[char].optional,
28
+ recursive: translation[char].recursive,
29
+ transform: translation[char].transform
30
+ });
31
+ } else {
32
+ tokens.push({
33
+ type: "literal",
34
+ char: char
35
+ });
36
+ }
37
+ i++;
38
+ }
39
+
40
+ return tokens;
41
+ };
42
+
43
+ const applyMask = (inputValue: string, maskTokens: any, reverse = false) => {
44
+ if (!maskTokens.length) return inputValue;
45
+
46
+ const normalizedValue = inputValue == null ? "" : String(inputValue);
47
+ const cleanValue = normalizedValue.replace(/[^\w\s]/g, "");
48
+
49
+ if (reverse) {
50
+ return applyReverseMask(cleanValue, maskTokens);
51
+ }
52
+
53
+ let result = "";
54
+ let valueIndex = 0;
55
+ let maskIndex = 0;
56
+
57
+ while (maskIndex < maskTokens.length && valueIndex < cleanValue.length) {
58
+ const token = maskTokens[maskIndex];
59
+
60
+ if (token.type === "literal") {
61
+ result += token.char;
62
+ maskIndex++;
63
+ } else {
64
+ const char = cleanValue[valueIndex];
65
+
66
+ if (token.pattern.test(char)) {
67
+ const transformedChar = token.transform ? token.transform(char) : char;
68
+ result += transformedChar;
69
+ valueIndex++;
70
+ maskIndex++;
71
+ } else if (token.optional) {
72
+ maskIndex++;
73
+ } else {
74
+ valueIndex++;
75
+ }
76
+ }
77
+ }
78
+
79
+ while (maskIndex < maskTokens.length) {
80
+ const token = maskTokens[maskIndex];
81
+ if (token.type === "literal") {
82
+ result += token.char;
83
+ } else if (!token.optional) {
84
+ break;
85
+ }
86
+ maskIndex++;
87
+ }
88
+
89
+ return result;
90
+ };
91
+
92
+ const applyReverseMask = (inputValue: string, maskTokens: any) => {
93
+ const reversedMask = maskTokens.slice().reverse();
94
+ const reversedValue = inputValue.split("").reverse().join("");
95
+ let result = "";
96
+ let valueIndex = 0;
97
+ let maskIndex = 0;
98
+
99
+ while (maskIndex < reversedMask.length && valueIndex < reversedValue.length) {
100
+ const token = reversedMask[maskIndex];
101
+
102
+ if (token.type === "literal") {
103
+ result = token.char + result;
104
+ maskIndex++;
105
+ } else {
106
+ const char = reversedValue[valueIndex];
107
+
108
+ if (token.pattern.test(char)) {
109
+ const transformedChar = token.transform ? token.transform(char) : char;
110
+ result = transformedChar + result;
111
+ valueIndex++;
112
+ maskIndex++;
113
+ } else if (token.optional) {
114
+ maskIndex++;
115
+ } else {
116
+ valueIndex++;
117
+ }
118
+ }
119
+ }
120
+
121
+ return result;
122
+ };
123
+
124
+ const getCleanValue = (maskedValue: string, maskTokens: any) => {
125
+ if (!maskTokens.length) return maskedValue;
126
+
127
+ let clean = "";
128
+ let valueIndex = 0;
129
+ let maskIndex = 0;
130
+
131
+ while (maskIndex < maskTokens.length && valueIndex < maskedValue.length) {
132
+ const token = maskTokens[maskIndex];
133
+
134
+ if (token.type === "literal") {
135
+ if (maskedValue[valueIndex] === token.char) {
136
+ valueIndex++;
137
+ }
138
+ maskIndex++;
139
+ } else {
140
+ clean += maskedValue[valueIndex];
141
+ valueIndex++;
142
+ maskIndex++;
143
+ }
144
+ }
145
+
146
+ return clean;
147
+ };
148
+
149
+ return {
150
+ parseMask,
151
+ applyMask,
152
+ getCleanValue
153
+ };
154
+ };
155
+
156
+ // Fonksiyonel yaklaşım - herhangi bir input elementine mask uygula
157
+ export const applyInputMask = (inputElement: any, mask: string, options: any = {}) => {
158
+ if (!inputElement || !mask) return null;
159
+
160
+ isDev && console.log("Input mask applied:", { inputElement, mask, options });
161
+
162
+ const { translation, reverse = false, clearIfNotMatch = true, selectOnFocus = false, onChange } = options;
163
+
164
+ const maskCore = createMaskCore();
165
+ const maskTokens = maskCore.parseMask(mask, translation);
166
+
167
+ const applyMaskToValue = (inputValue: any) => maskCore.applyMask(inputValue, maskTokens, reverse);
168
+
169
+ const getCleanValue = (maskedValue: any) => maskCore.getCleanValue(maskedValue, maskTokens);
170
+
171
+ const handleInputChange = (e: any) => {
172
+ const inputValue = e.target.value;
173
+ const maskedValue = applyMaskToValue(inputValue);
174
+ const cleanValue = getCleanValue(maskedValue);
175
+
176
+ e.target.value = maskedValue;
177
+ onChange?.(maskedValue, cleanValue, e);
178
+ };
179
+
180
+ const handleKeyDown = (e: any) => {
181
+ const { key, target } = e;
182
+ const cursorStart = target.selectionStart;
183
+ const cursorEnd = target.selectionEnd;
184
+
185
+ if (key === "Backspace" || key === "Delete") {
186
+ e.preventDefault();
187
+
188
+ let newValue = target.value;
189
+
190
+ if (cursorStart !== cursorEnd) {
191
+ newValue = newValue.substring(0, cursorStart) + newValue.substring(cursorEnd);
192
+ } else if (key === "Backspace" && cursorStart > 0) {
193
+ newValue = newValue.substring(0, cursorStart - 1) + newValue.substring(cursorStart);
194
+ } else if (key === "Delete" && cursorStart < newValue.length) {
195
+ newValue = newValue.substring(0, cursorStart) + newValue.substring(cursorStart + 1);
196
+ }
197
+
198
+ const maskedValue = applyMaskToValue(newValue);
199
+ target.value = maskedValue;
200
+
201
+ const cleanValue = getCleanValue(maskedValue);
202
+ onChange?.(maskedValue, cleanValue, e);
203
+
204
+ setTimeout(() => {
205
+ const newPos = key === "Backspace" ? Math.max(0, cursorStart - 1) : cursorStart;
206
+ target.setSelectionRange(newPos, newPos);
207
+ }, 0);
208
+ }
209
+ };
210
+
211
+ const handleFocus = (e: any) => {
212
+ if (selectOnFocus) {
213
+ setTimeout(() => {
214
+ e.target.select();
215
+ }, 0);
216
+ }
217
+ };
218
+
219
+ const handleBlur = (e: any) => {
220
+ if (clearIfNotMatch) {
221
+ const cleanValue = getCleanValue(e.target.value);
222
+ const expectedLength = maskTokens.filter((t) => t.type === "input" && !t.optional).length;
223
+
224
+ if (cleanValue.length < expectedLength) {
225
+ e.target.value = "";
226
+ onChange?.("", "", e);
227
+ }
228
+ }
229
+ };
230
+
231
+ // Event listener'ları ekle
232
+ inputElement.addEventListener("input", handleInputChange);
233
+ inputElement.addEventListener("keydown", handleKeyDown);
234
+ inputElement.addEventListener("focus", handleFocus);
235
+ inputElement.addEventListener("blur", handleBlur);
236
+
237
+ // Cleanup fonksiyonu
238
+ const destroy = () => {
239
+ inputElement.removeEventListener("input", handleInputChange);
240
+ inputElement.removeEventListener("keydown", handleKeyDown);
241
+ inputElement.removeEventListener("focus", handleFocus);
242
+ inputElement.removeEventListener("blur", handleBlur);
243
+ };
244
+
245
+ // Utility fonksiyonları
246
+ return {
247
+ destroy,
248
+ setValue: (value: any) => {
249
+ if (!value) return;
250
+ const maskedValue = applyMaskToValue(value || "");
251
+ inputElement.value = maskedValue;
252
+ },
253
+ getValue: () => inputElement.value,
254
+ getCleanValue: () => getCleanValue(inputElement.value),
255
+ applyMask: applyMaskToValue
256
+ };
257
+ };
@@ -0,0 +1,106 @@
1
+ export const onKeyboardSelection = ({ e, targetElement, itemClass = `item`, selectedClass = "selected", checkByValue, checkByInput, clear }: any) => {
2
+ if (!targetElement.current) return null;
3
+
4
+ const config = {
5
+ e: e,
6
+ itemClass: itemClass,
7
+ selectedClass: selectedClass,
8
+ };
9
+
10
+ function selectEnter() {
11
+ if (!targetElement.current) return null;
12
+ const text: any = targetElement.current.querySelector(`${config.itemClass}.${config.selectedClass}`);
13
+ if (text) {
14
+ checkByValue(text.dataset.value);
15
+ } else if (targetElement.current.querySelectorAll(`${config.itemClass}`).length > 0) {
16
+ const target: any = targetElement.current.querySelectorAll(`${config.itemClass}.${config.selectedClass}`)[0];
17
+ checkByValue(target.dataset.value);
18
+ } else {
19
+ clear(true, true);
20
+ }
21
+ }
22
+
23
+ function selectFirst() {
24
+ if (!targetElement.current) return null;
25
+ const showList = targetElement.current.querySelectorAll(`${config.itemClass}`);
26
+ if (showList.length > 0) {
27
+ showList[0].classList.add(config.selectedClass);
28
+ }
29
+ }
30
+
31
+ function selectLast() {
32
+ if (!targetElement.current) return null;
33
+ const showList = targetElement.current.querySelectorAll(`${config.itemClass}`);
34
+ if (showList.length > 0) {
35
+ showList[showList.length - 1].classList.add(config.selectedClass);
36
+ }
37
+ }
38
+
39
+ function selectNext(element: any) {
40
+ element.classList.remove(config.selectedClass);
41
+ const next = element.nextElementSibling;
42
+ if (next && next.nodeType !== -1) {
43
+ if (next.classList.contains("item")) {
44
+ next.classList.add(config.selectedClass);
45
+ } else {
46
+ selectNext(next);
47
+ }
48
+ } else {
49
+ selectFirst();
50
+ }
51
+ }
52
+
53
+ function selectPrev(element: any) {
54
+ element.classList.remove(config.selectedClass);
55
+ const next = element.previousElementSibling;
56
+ if (next && next.nodeType !== -1) {
57
+ if (next.classList.contains("item")) {
58
+ next.classList.add(config.selectedClass);
59
+ } else {
60
+ selectPrev(next);
61
+ }
62
+ } else {
63
+ selectLast();
64
+ }
65
+ }
66
+
67
+ const selected = targetElement.current.querySelector(`${config.itemClass}.${config.selectedClass}`);
68
+ if (e.which == 40) {
69
+ if (selected) {
70
+ selectNext(selected);
71
+ } else {
72
+ selectFirst();
73
+ }
74
+ } else if (e.which == 38) {
75
+ if (selected) {
76
+ selectPrev(selected);
77
+ } else {
78
+ selectLast();
79
+ }
80
+ } else if (e.which == 35) {
81
+ selectLast();
82
+ } else if (e.which == 36) {
83
+ selectFirst();
84
+ } else if (e.which == 13) {
85
+ selectEnter();
86
+ } else if (e.which == 9) {
87
+ checkByInput();
88
+ }
89
+
90
+ setScrollListPosition(targetElement);
91
+ };
92
+
93
+ export function setScrollListPosition(targetElement: any) {
94
+ if (targetElement.current) {
95
+ let position = 0;
96
+ const text = targetElement.current.querySelector(".selected");
97
+ if (text) {
98
+ position = text.offsetTop - 35;
99
+ } else if (targetElement.current.querySelector(".active")) {
100
+ position = targetElement.current.querySelector(".active").offsetTop - 35;
101
+ }
102
+ targetElement.current.scrollTop = position;
103
+ }
104
+ }
105
+
106
+
@@ -0,0 +1,39 @@
1
+ import nookies, { destroyCookie, parseCookies, setCookie } from 'nookies';
2
+
3
+ import { getDomain } from '../baseFunctions';
4
+
5
+ export const cerezOku = (context: any | null = null, key: string) => {
6
+ const cookies = context ? nookies.get(context) : parseCookies();
7
+ return cookies[key] || false;
8
+ };
9
+
10
+ export const cerezKaydet = (context: any | null = null, key: string, value: string, time: number = 0) => {
11
+ const newConfig = checkDomain(context);
12
+ setCookie(context, key, value, {
13
+ maxAge: time > 0 ? time : null,
14
+ ...newConfig
15
+ });
16
+ };
17
+
18
+ export const cerezSil = (context: any | null = null, key: string) => {
19
+ const newConfig = checkDomain(context);
20
+ destroyCookie(context, key, newConfig);
21
+ };
22
+
23
+ export const cerezTumuSil = (context: any | null = null) => {
24
+ const cookies = parseCookies(context);
25
+ if (cookies) {
26
+ Object.keys(cookies).forEach((key) => {
27
+ destroyCookie(context, key);
28
+ });
29
+ }
30
+ };
31
+
32
+ const checkDomain = (context: any | null = null, config: any = {}) => {
33
+ let cookieDomain = getDomain(context);
34
+ return {
35
+ ...config,
36
+ domain: '.' + cookieDomain,
37
+ path: '/'
38
+ };
39
+ };