@sydsoft/base 1.47.0 → 1.48.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.
- package/README.md +8 -1
- package/dist/esm/_lib/baseFunctions.js +25 -38
- package/dist/esm/_lib/inputMask.js +66 -69
- package/dist/esm/_lib/listFunctions.js +12 -13
- package/dist/esm/_lib/storage/cookies.js +20 -21
- package/dist/esm/_lib/storage/encData.js +18 -20
- package/dist/esm/_lib/storage/localStorage.js +10 -10
- package/dist/esm/_lib/storage/sessionStorage.js +10 -10
- package/dist/esm/_lib/useInterval.js +5 -5
- package/dist/esm/alert/index.js +28 -30
- package/dist/esm/box/Box.js +6 -7
- package/dist/esm/box/BoxContent.js +2 -4
- package/dist/esm/box/BoxFooter.js +6 -4
- package/dist/esm/box/BoxHeader.js +6 -5
- package/dist/esm/countDown/index.js +28 -33
- package/dist/esm/dateTime/index.js +25 -31
- package/dist/esm/form/Button.js +28 -22
- package/dist/esm/form/Checkbox.js +7 -8
- package/dist/esm/form/Dialog.js +47 -34
- package/dist/esm/form/Form.js +3 -5
- package/dist/esm/form/FormOlustur.js +15 -17
- package/dist/esm/form/Input.js +57 -56
- package/dist/esm/form/Label.js +2 -4
- package/dist/esm/form/SearchableInput.js +77 -89
- package/dist/esm/form/UploadBase.js +30 -32
- package/dist/esm/grid/index.js +40 -41
- package/dist/esm/icon/icons.js +1 -1
- package/dist/esm/icon/index.js +16 -8
- package/dist/esm/menu/index.js +14 -16
- package/dist/esm/modal/index.js +14 -16
- package/dist/esm/popover/index.js +100 -100
- package/dist/esm/tooltip/index.js +117 -34
- package/package.json +12 -6
- package/dist/esm/alert/index.module.css +0 -119
- package/dist/esm/grid/index.module.css +0 -805
- package/dist/esm/menu/index.module.css +0 -92
- package/dist/esm/modal/index.module.css +0 -77
- /package/dist/esm/{box/Box.module.css → Box.module.css} +0 -0
- /package/dist/esm/{popover/index.module.css → index.module.css} +0 -0
- /package/dist/esm/{form/styles → styles}/Button.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/Input.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/Label.module.css +0 -0
- /package/dist/esm/{form/styles → styles}/SearchableInput.module.css +0 -0
package/README.md
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
6
|
-
};
|
|
7
|
-
export var padNumber = function (num, padLength, padString) {
|
|
8
|
-
if (padLength === void 0) { padLength = 2; }
|
|
9
|
-
if (padString === void 0) { padString = '0'; }
|
|
10
|
-
return String(num).padStart(padLength, padString);
|
|
11
|
-
};
|
|
1
|
+
export const isDev = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
|
|
2
|
+
export const isServerReq = (context) => { var _a, _b; return !((_b = (_a = context === null || context === void 0 ? void 0 : context.req) === null || _a === void 0 ? void 0 : _a.url) === null || _b === void 0 ? void 0 : _b.startsWith('/_next')); };
|
|
3
|
+
export const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
|
+
export const padNumber = (num, padLength = 2, padString = '0') => String(num).padStart(padLength, padString);
|
|
12
5
|
export function inputTumuBuyukCevir(e) {
|
|
13
6
|
var _a;
|
|
14
7
|
if ((e === null || e === void 0 ? void 0 : e.target) && ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.setSelectionRange)) {
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const start = e.target.selectionStart;
|
|
9
|
+
const end = e.target.selectionEnd;
|
|
17
10
|
e.target.value = e.target.value.toString().toLocaleUpperCase('tr-TR');
|
|
18
11
|
e.target.setSelectionRange(start, end);
|
|
19
12
|
}
|
|
@@ -21,18 +14,15 @@ export function inputTumuBuyukCevir(e) {
|
|
|
21
14
|
export function inputTumuKucukCevir(e) {
|
|
22
15
|
var _a;
|
|
23
16
|
if ((e === null || e === void 0 ? void 0 : e.target) && ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.setSelectionRange)) {
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const start = e.target.selectionStart;
|
|
18
|
+
const end = e.target.selectionEnd;
|
|
26
19
|
e.target.value = e.target.value.toString().toLocaleLowerCase('tr-TR');
|
|
27
20
|
e.target.setSelectionRange(start, end);
|
|
28
21
|
}
|
|
29
22
|
}
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
export var convertForSearch = function (value) {
|
|
35
|
-
var data = value === null || value === void 0 ? void 0 : value.toString().toLocaleLowerCase('tr-TR');
|
|
23
|
+
export const convertLowerCase = (text = '') => text.toString().toLocaleLowerCase('tr-TR');
|
|
24
|
+
export const convertForSearch = (value) => {
|
|
25
|
+
let data = value === null || value === void 0 ? void 0 : value.toString().toLocaleLowerCase('tr-TR');
|
|
36
26
|
data = data.replace(/ö/g, 'o');
|
|
37
27
|
data = data.replace(/ç/g, 'c');
|
|
38
28
|
data = data.replace(/ş/g, 's');
|
|
@@ -46,12 +36,12 @@ export var convertForSearch = function (value) {
|
|
|
46
36
|
export function convertForSEO(e) {
|
|
47
37
|
var _a;
|
|
48
38
|
if ((e === null || e === void 0 ? void 0 : e.target) && ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.setSelectionRange)) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
for (
|
|
39
|
+
const start = e.target.selectionStart;
|
|
40
|
+
const end = e.target.selectionEnd;
|
|
41
|
+
let string = e.target.value.toString().toLocaleLowerCase('tr');
|
|
42
|
+
const turkce = [' ', '-', 'ş', 'Ş', 'ı', 'ü', 'Ü', 'ö', 'Ö', 'ç', 'Ç', 'ş', 'Ş', 'ı', 'ğ', 'Ğ', 'İ', 'ö', 'Ö', 'Ç', 'ç', 'ü', 'Ü', 'â', 'ê', 'Â', '“', '”'];
|
|
43
|
+
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', '', ''];
|
|
44
|
+
for (let i = 0; i < turkce.length; i++) {
|
|
55
45
|
string = string.split(turkce[i]).join(duzgun[i]);
|
|
56
46
|
}
|
|
57
47
|
string = string.replace(/[^a-z0-9\-_şıüğçİŞĞÜÇ]+/gi, '_');
|
|
@@ -62,9 +52,8 @@ export function convertForSEO(e) {
|
|
|
62
52
|
e.target.setSelectionRange(start, end);
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
|
-
export function getDomain(context) {
|
|
66
|
-
|
|
67
|
-
var url = '';
|
|
55
|
+
export function getDomain(context = null) {
|
|
56
|
+
let url = '';
|
|
68
57
|
if (context) {
|
|
69
58
|
url = context.req.headers.host;
|
|
70
59
|
}
|
|
@@ -72,23 +61,21 @@ export function getDomain(context) {
|
|
|
72
61
|
url = window.location.hostname;
|
|
73
62
|
}
|
|
74
63
|
if (url.length) {
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
const parts = url.split('.').reverse();
|
|
65
|
+
const cnt = parts.length;
|
|
77
66
|
if (cnt >= 3) {
|
|
78
67
|
// see if the second level domain is a common SLD.
|
|
79
68
|
if (parts[1].match(/^(com|edu|gov|net|mil|org|nom|co|name|info|biz)$/i)) {
|
|
80
|
-
|
|
81
|
-
return
|
|
69
|
+
const domain = parts[2] + '.' + parts[1] + '.' + parts[0];
|
|
70
|
+
return domain.split(':')[0];
|
|
82
71
|
}
|
|
83
72
|
}
|
|
84
|
-
|
|
73
|
+
const domain = parts[1] + '.' + parts[0];
|
|
85
74
|
return domain.split(':')[0];
|
|
86
75
|
}
|
|
87
76
|
return url;
|
|
88
77
|
}
|
|
89
|
-
export
|
|
90
|
-
if (key === void 0) { key = ''; }
|
|
91
|
-
if (length === void 0) { length = 16; }
|
|
78
|
+
export const uniqueID = (key = '', length = 16) => {
|
|
92
79
|
return (key +
|
|
93
80
|
parseInt(Math.ceil(Math.random() * Date.now())
|
|
94
81
|
.toPrecision(length)
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { isDev } from "./baseFunctions";
|
|
2
2
|
// Mask işleme core fonksiyonları
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const createMaskCore = () => {
|
|
4
|
+
const defaultTranslation = {
|
|
5
5
|
"0": { pattern: /\d/ },
|
|
6
6
|
"9": { pattern: /\d/, optional: true },
|
|
7
7
|
"#": { pattern: /\d/, recursive: true },
|
|
8
8
|
A: { pattern: /[a-zA-Z0-9]/ },
|
|
9
9
|
S: { pattern: /[a-zA-Z]/ },
|
|
10
|
-
U: { pattern: /[a-zA-Z]/, transform:
|
|
11
|
-
L: { pattern: /[a-zA-Z]/, transform:
|
|
10
|
+
U: { pattern: /[a-zA-Z]/, transform: (char) => char.toUpperCase() },
|
|
11
|
+
L: { pattern: /[a-zA-Z]/, transform: (char) => char.toLowerCase() },
|
|
12
12
|
X: { pattern: /[0-9a-fA-F]/ }
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var i = 0;
|
|
14
|
+
const parseMask = (maskString, translation = defaultTranslation) => {
|
|
15
|
+
const tokens = [];
|
|
16
|
+
let i = 0;
|
|
18
17
|
while (i < maskString.length) {
|
|
19
|
-
|
|
18
|
+
const char = maskString[i];
|
|
20
19
|
if (translation[char]) {
|
|
21
20
|
tokens.push({
|
|
22
21
|
type: "input",
|
|
@@ -36,28 +35,27 @@ var createMaskCore = function () {
|
|
|
36
35
|
}
|
|
37
36
|
return tokens;
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
if (reverse === void 0) { reverse = false; }
|
|
38
|
+
const applyMask = (inputValue, maskTokens, reverse = false) => {
|
|
41
39
|
if (!maskTokens.length)
|
|
42
40
|
return inputValue;
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const normalizedValue = inputValue == null ? "" : String(inputValue);
|
|
42
|
+
const cleanValue = normalizedValue.replace(/[^\w\s]/g, "");
|
|
45
43
|
if (reverse) {
|
|
46
44
|
return applyReverseMask(cleanValue, maskTokens);
|
|
47
45
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
let result = "";
|
|
47
|
+
let valueIndex = 0;
|
|
48
|
+
let maskIndex = 0;
|
|
51
49
|
while (maskIndex < maskTokens.length && valueIndex < cleanValue.length) {
|
|
52
|
-
|
|
50
|
+
const token = maskTokens[maskIndex];
|
|
53
51
|
if (token.type === "literal") {
|
|
54
52
|
result += token.char;
|
|
55
53
|
maskIndex++;
|
|
56
54
|
}
|
|
57
55
|
else {
|
|
58
|
-
|
|
56
|
+
const char = cleanValue[valueIndex];
|
|
59
57
|
if (token.pattern.test(char)) {
|
|
60
|
-
|
|
58
|
+
const transformedChar = token.transform ? token.transform(char) : char;
|
|
61
59
|
result += transformedChar;
|
|
62
60
|
valueIndex++;
|
|
63
61
|
maskIndex++;
|
|
@@ -71,7 +69,7 @@ var createMaskCore = function () {
|
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
while (maskIndex < maskTokens.length) {
|
|
74
|
-
|
|
72
|
+
const token = maskTokens[maskIndex];
|
|
75
73
|
if (token.type === "literal") {
|
|
76
74
|
result += token.char;
|
|
77
75
|
}
|
|
@@ -82,22 +80,22 @@ var createMaskCore = function () {
|
|
|
82
80
|
}
|
|
83
81
|
return result;
|
|
84
82
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
const applyReverseMask = (inputValue, maskTokens) => {
|
|
84
|
+
const reversedMask = maskTokens.slice().reverse();
|
|
85
|
+
const reversedValue = inputValue.split("").reverse().join("");
|
|
86
|
+
let result = "";
|
|
87
|
+
let valueIndex = 0;
|
|
88
|
+
let maskIndex = 0;
|
|
91
89
|
while (maskIndex < reversedMask.length && valueIndex < reversedValue.length) {
|
|
92
|
-
|
|
90
|
+
const token = reversedMask[maskIndex];
|
|
93
91
|
if (token.type === "literal") {
|
|
94
92
|
result = token.char + result;
|
|
95
93
|
maskIndex++;
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
98
|
-
|
|
96
|
+
const char = reversedValue[valueIndex];
|
|
99
97
|
if (token.pattern.test(char)) {
|
|
100
|
-
|
|
98
|
+
const transformedChar = token.transform ? token.transform(char) : char;
|
|
101
99
|
result = transformedChar + result;
|
|
102
100
|
valueIndex++;
|
|
103
101
|
maskIndex++;
|
|
@@ -112,14 +110,14 @@ var createMaskCore = function () {
|
|
|
112
110
|
}
|
|
113
111
|
return result;
|
|
114
112
|
};
|
|
115
|
-
|
|
113
|
+
const getCleanValue = (maskedValue, maskTokens) => {
|
|
116
114
|
if (!maskTokens.length)
|
|
117
115
|
return maskedValue;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
let clean = "";
|
|
117
|
+
let valueIndex = 0;
|
|
118
|
+
let maskIndex = 0;
|
|
121
119
|
while (maskIndex < maskTokens.length && valueIndex < maskedValue.length) {
|
|
122
|
-
|
|
120
|
+
const token = maskTokens[maskIndex];
|
|
123
121
|
if (token.type === "literal") {
|
|
124
122
|
if (maskedValue[valueIndex] === token.char) {
|
|
125
123
|
valueIndex++;
|
|
@@ -135,36 +133,35 @@ var createMaskCore = function () {
|
|
|
135
133
|
return clean;
|
|
136
134
|
};
|
|
137
135
|
return {
|
|
138
|
-
parseMask
|
|
139
|
-
applyMask
|
|
140
|
-
getCleanValue
|
|
136
|
+
parseMask,
|
|
137
|
+
applyMask,
|
|
138
|
+
getCleanValue
|
|
141
139
|
};
|
|
142
140
|
};
|
|
143
141
|
// Fonksiyonel yaklaşım - herhangi bir input elementine mask uygula
|
|
144
|
-
export
|
|
145
|
-
if (options === void 0) { options = {}; }
|
|
142
|
+
export const applyInputMask = (inputElement, mask, options = {}) => {
|
|
146
143
|
if (!inputElement || !mask)
|
|
147
144
|
return null;
|
|
148
|
-
isDev && console.log("Input mask applied:", { inputElement
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
145
|
+
isDev && console.log("Input mask applied:", { inputElement, mask, options });
|
|
146
|
+
const { translation, reverse = false, clearIfNotMatch = true, selectOnFocus = false, onChange } = options;
|
|
147
|
+
const maskCore = createMaskCore();
|
|
148
|
+
const maskTokens = maskCore.parseMask(mask, translation);
|
|
149
|
+
const applyMaskToValue = (inputValue) => maskCore.applyMask(inputValue, maskTokens, reverse);
|
|
150
|
+
const getCleanValue = (maskedValue) => maskCore.getCleanValue(maskedValue, maskTokens);
|
|
151
|
+
const handleInputChange = (e) => {
|
|
152
|
+
const inputValue = e.target.value;
|
|
153
|
+
const maskedValue = applyMaskToValue(inputValue);
|
|
154
|
+
const cleanValue = getCleanValue(maskedValue);
|
|
158
155
|
e.target.value = maskedValue;
|
|
159
156
|
onChange === null || onChange === void 0 ? void 0 : onChange(maskedValue, cleanValue, e);
|
|
160
157
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
const handleKeyDown = (e) => {
|
|
159
|
+
const { key, target } = e;
|
|
160
|
+
const cursorStart = target.selectionStart;
|
|
161
|
+
const cursorEnd = target.selectionEnd;
|
|
165
162
|
if (key === "Backspace" || key === "Delete") {
|
|
166
163
|
e.preventDefault();
|
|
167
|
-
|
|
164
|
+
let newValue = target.value;
|
|
168
165
|
if (cursorStart !== cursorEnd) {
|
|
169
166
|
newValue = newValue.substring(0, cursorStart) + newValue.substring(cursorEnd);
|
|
170
167
|
}
|
|
@@ -174,27 +171,27 @@ export var applyInputMask = function (inputElement, mask, options) {
|
|
|
174
171
|
else if (key === "Delete" && cursorStart < newValue.length) {
|
|
175
172
|
newValue = newValue.substring(0, cursorStart) + newValue.substring(cursorStart + 1);
|
|
176
173
|
}
|
|
177
|
-
|
|
174
|
+
const maskedValue = applyMaskToValue(newValue);
|
|
178
175
|
target.value = maskedValue;
|
|
179
|
-
|
|
176
|
+
const cleanValue = getCleanValue(maskedValue);
|
|
180
177
|
onChange === null || onChange === void 0 ? void 0 : onChange(maskedValue, cleanValue, e);
|
|
181
|
-
setTimeout(
|
|
182
|
-
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
const newPos = key === "Backspace" ? Math.max(0, cursorStart - 1) : cursorStart;
|
|
183
180
|
target.setSelectionRange(newPos, newPos);
|
|
184
181
|
}, 0);
|
|
185
182
|
}
|
|
186
183
|
};
|
|
187
|
-
|
|
184
|
+
const handleFocus = (e) => {
|
|
188
185
|
if (selectOnFocus) {
|
|
189
|
-
setTimeout(
|
|
186
|
+
setTimeout(() => {
|
|
190
187
|
e.target.select();
|
|
191
188
|
}, 0);
|
|
192
189
|
}
|
|
193
190
|
};
|
|
194
|
-
|
|
191
|
+
const handleBlur = (e) => {
|
|
195
192
|
if (clearIfNotMatch) {
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
const cleanValue = getCleanValue(e.target.value);
|
|
194
|
+
const expectedLength = maskTokens.filter((t) => t.type === "input" && !t.optional).length;
|
|
198
195
|
if (cleanValue.length < expectedLength) {
|
|
199
196
|
e.target.value = "";
|
|
200
197
|
onChange === null || onChange === void 0 ? void 0 : onChange("", "", e);
|
|
@@ -207,7 +204,7 @@ export var applyInputMask = function (inputElement, mask, options) {
|
|
|
207
204
|
inputElement.addEventListener("focus", handleFocus);
|
|
208
205
|
inputElement.addEventListener("blur", handleBlur);
|
|
209
206
|
// Cleanup fonksiyonu
|
|
210
|
-
|
|
207
|
+
const destroy = () => {
|
|
211
208
|
inputElement.removeEventListener("input", handleInputChange);
|
|
212
209
|
inputElement.removeEventListener("keydown", handleKeyDown);
|
|
213
210
|
inputElement.removeEventListener("focus", handleFocus);
|
|
@@ -215,15 +212,15 @@ export var applyInputMask = function (inputElement, mask, options) {
|
|
|
215
212
|
};
|
|
216
213
|
// Utility fonksiyonları
|
|
217
214
|
return {
|
|
218
|
-
destroy
|
|
219
|
-
setValue:
|
|
215
|
+
destroy,
|
|
216
|
+
setValue: (value) => {
|
|
220
217
|
if (!value)
|
|
221
218
|
return;
|
|
222
|
-
|
|
219
|
+
const maskedValue = applyMaskToValue(value || "");
|
|
223
220
|
inputElement.value = maskedValue;
|
|
224
221
|
},
|
|
225
|
-
getValue:
|
|
226
|
-
getCleanValue:
|
|
222
|
+
getValue: () => inputElement.value,
|
|
223
|
+
getCleanValue: () => getCleanValue(inputElement.value),
|
|
227
224
|
applyMask: applyMaskToValue
|
|
228
225
|
};
|
|
229
226
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
var e = _a.e, targetElement = _a.targetElement, _b = _a.itemClass, itemClass = _b === void 0 ? "item" : _b, _c = _a.selectedClass, selectedClass = _c === void 0 ? "selected" : _c, checkByValue = _a.checkByValue, checkByInput = _a.checkByInput, clear = _a.clear;
|
|
1
|
+
export const onKeyboardSelection = ({ e, targetElement, itemClass = `item`, selectedClass = "selected", checkByValue, checkByInput, clear }) => {
|
|
3
2
|
if (!targetElement.current)
|
|
4
3
|
return null;
|
|
5
|
-
|
|
4
|
+
const config = {
|
|
6
5
|
e: e,
|
|
7
6
|
itemClass: itemClass,
|
|
8
7
|
selectedClass: selectedClass,
|
|
@@ -10,12 +9,12 @@ export var onKeyboardSelection = function (_a) {
|
|
|
10
9
|
function selectEnter() {
|
|
11
10
|
if (!targetElement.current)
|
|
12
11
|
return null;
|
|
13
|
-
|
|
12
|
+
const text = targetElement.current.querySelector(`${config.itemClass}.${config.selectedClass}`);
|
|
14
13
|
if (text) {
|
|
15
14
|
checkByValue(text.dataset.value);
|
|
16
15
|
}
|
|
17
|
-
else if (targetElement.current.querySelectorAll(
|
|
18
|
-
|
|
16
|
+
else if (targetElement.current.querySelectorAll(`${config.itemClass}`).length > 0) {
|
|
17
|
+
const target = targetElement.current.querySelectorAll(`${config.itemClass}.${config.selectedClass}`)[0];
|
|
19
18
|
checkByValue(target.dataset.value);
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
@@ -25,7 +24,7 @@ export var onKeyboardSelection = function (_a) {
|
|
|
25
24
|
function selectFirst() {
|
|
26
25
|
if (!targetElement.current)
|
|
27
26
|
return null;
|
|
28
|
-
|
|
27
|
+
const showList = targetElement.current.querySelectorAll(`${config.itemClass}`);
|
|
29
28
|
if (showList.length > 0) {
|
|
30
29
|
showList[0].classList.add(config.selectedClass);
|
|
31
30
|
}
|
|
@@ -33,14 +32,14 @@ export var onKeyboardSelection = function (_a) {
|
|
|
33
32
|
function selectLast() {
|
|
34
33
|
if (!targetElement.current)
|
|
35
34
|
return null;
|
|
36
|
-
|
|
35
|
+
const showList = targetElement.current.querySelectorAll(`${config.itemClass}`);
|
|
37
36
|
if (showList.length > 0) {
|
|
38
37
|
showList[showList.length - 1].classList.add(config.selectedClass);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
function selectNext(element) {
|
|
42
41
|
element.classList.remove(config.selectedClass);
|
|
43
|
-
|
|
42
|
+
const next = element.nextElementSibling;
|
|
44
43
|
if (next && next.nodeType !== -1) {
|
|
45
44
|
if (next.classList.contains("item")) {
|
|
46
45
|
next.classList.add(config.selectedClass);
|
|
@@ -55,7 +54,7 @@ export var onKeyboardSelection = function (_a) {
|
|
|
55
54
|
}
|
|
56
55
|
function selectPrev(element) {
|
|
57
56
|
element.classList.remove(config.selectedClass);
|
|
58
|
-
|
|
57
|
+
const next = element.previousElementSibling;
|
|
59
58
|
if (next && next.nodeType !== -1) {
|
|
60
59
|
if (next.classList.contains("item")) {
|
|
61
60
|
next.classList.add(config.selectedClass);
|
|
@@ -68,7 +67,7 @@ export var onKeyboardSelection = function (_a) {
|
|
|
68
67
|
selectLast();
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
|
|
70
|
+
const selected = targetElement.current.querySelector(`${config.itemClass}.${config.selectedClass}`);
|
|
72
71
|
if (e.which == 40) {
|
|
73
72
|
if (selected) {
|
|
74
73
|
selectNext(selected);
|
|
@@ -101,8 +100,8 @@ export var onKeyboardSelection = function (_a) {
|
|
|
101
100
|
};
|
|
102
101
|
export function setScrollListPosition(targetElement) {
|
|
103
102
|
if (targetElement.current) {
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
let position = 0;
|
|
104
|
+
const text = targetElement.current.querySelector(".selected");
|
|
106
105
|
if (text) {
|
|
107
106
|
position = text.offsetTop - 35;
|
|
108
107
|
}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import nookies, { destroyCookie, parseCookies, setCookie } from 'nookies';
|
|
3
2
|
import { getDomain } from '../baseFunctions';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
var cookies = context ? nookies.get(context) : parseCookies();
|
|
3
|
+
export const cerezOku = (context = null, key) => {
|
|
4
|
+
const cookies = context ? nookies.get(context) : parseCookies();
|
|
7
5
|
return cookies[key] || false;
|
|
8
6
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export const cerezKaydet = (context = null, key, value, time = 0) => {
|
|
8
|
+
const newConfig = checkDomain(context);
|
|
9
|
+
setCookie(context, key, value, {
|
|
10
|
+
maxAge: time > 0 ? time : null,
|
|
11
|
+
...newConfig
|
|
12
|
+
});
|
|
14
13
|
};
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
var newConfig = checkDomain(context);
|
|
14
|
+
export const cerezSil = (context = null, key) => {
|
|
15
|
+
const newConfig = checkDomain(context);
|
|
18
16
|
destroyCookie(context, key, newConfig);
|
|
19
17
|
};
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
var cookies = parseCookies(context);
|
|
18
|
+
export const cerezTumuSil = (context = null) => {
|
|
19
|
+
const cookies = parseCookies(context);
|
|
23
20
|
if (cookies) {
|
|
24
|
-
Object.keys(cookies).forEach(
|
|
21
|
+
Object.keys(cookies).forEach((key) => {
|
|
25
22
|
destroyCookie(context, key);
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const checkDomain = (context = null, config = {}) => {
|
|
27
|
+
let cookieDomain = getDomain(context);
|
|
28
|
+
return {
|
|
29
|
+
...config,
|
|
30
|
+
domain: '.' + cookieDomain,
|
|
31
|
+
path: '/'
|
|
32
|
+
};
|
|
34
33
|
};
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { isDev } from "../baseFunctions";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
if (keys === void 0) { keys = encDecDataKeys; }
|
|
2
|
+
const encDecDataKeys = [3, 5, 8, 11, 15, 22];
|
|
3
|
+
export const encData = (data, keys = encDecDataKeys) => {
|
|
5
4
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
keys.map(
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const newJSON = { data: data };
|
|
6
|
+
const utf8Data = unescape(encodeURIComponent(JSON.stringify(newJSON))); // Dizeyi UTF-8'e dönüştür
|
|
7
|
+
let newData = btoa(utf8Data);
|
|
8
|
+
keys.map((value) => {
|
|
9
|
+
const randomChar = String.fromCharCode(Math.floor(Math.random() * (122 - 97 + 1)) + 97);
|
|
10
|
+
newData = newData.slice(0, value) + randomChar + newData.slice(value);
|
|
12
11
|
});
|
|
13
|
-
return
|
|
12
|
+
return newData;
|
|
14
13
|
}
|
|
15
14
|
catch (e) {
|
|
16
15
|
isDev && console.log("ERROR => encData =>", e);
|
|
17
16
|
return "";
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
|
-
export
|
|
19
|
+
export const decData = (data, keys = encDecDataKeys) => {
|
|
21
20
|
var _a;
|
|
22
|
-
if (keys === void 0) { keys = encDecDataKeys; }
|
|
23
21
|
try {
|
|
24
|
-
|
|
25
|
-
keys.map(
|
|
26
|
-
|
|
22
|
+
let decode = data;
|
|
23
|
+
keys.map((value, index) => {
|
|
24
|
+
const prevValue = keys[index - 1];
|
|
27
25
|
if (!prevValue) {
|
|
28
|
-
|
|
26
|
+
decode = decode.slice(0, value) + decode.slice(value + 1);
|
|
29
27
|
}
|
|
30
28
|
else {
|
|
31
|
-
|
|
29
|
+
decode = decode.slice(0, value - index) + decode.slice(value - index + 1);
|
|
32
30
|
}
|
|
33
31
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const decodedString = atob(decode);
|
|
33
|
+
const utf8DecodedString = decodeURIComponent(escape(decodedString));
|
|
34
|
+
const parse = JSON.parse(utf8DecodedString);
|
|
37
35
|
return (_a = parse === null || parse === void 0 ? void 0 : parse.data) !== null && _a !== void 0 ? _a : "";
|
|
38
36
|
}
|
|
39
37
|
catch (e) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decData, encData } from './encData';
|
|
2
2
|
import { isDev } from '../baseFunctions';
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
const storageAvailable = typeof Storage === 'undefined' || !window.localStorage ? false : true;
|
|
4
|
+
export const setLocalStorage = (key, value) => {
|
|
5
5
|
if (!storageAvailable)
|
|
6
6
|
return false;
|
|
7
7
|
try {
|
|
@@ -13,11 +13,11 @@ export var setLocalStorage = function (key, value) {
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export const getLocalStorage = (key) => {
|
|
17
17
|
if (!storageAvailable)
|
|
18
18
|
return false;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
const saved = localStorage.getItem(key);
|
|
21
21
|
return saved ? decData(saved) : null;
|
|
22
22
|
}
|
|
23
23
|
catch (e) {
|
|
@@ -25,7 +25,7 @@ export var getLocalStorage = function (key) {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export const removeLocalStorage = (key) => {
|
|
29
29
|
if (!storageAvailable)
|
|
30
30
|
return false;
|
|
31
31
|
try {
|
|
@@ -37,7 +37,7 @@ export var removeLocalStorage = function (key) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export const clearLocalStorage = () => {
|
|
41
41
|
if (!storageAvailable)
|
|
42
42
|
return false;
|
|
43
43
|
try {
|
|
@@ -50,17 +50,17 @@ export var clearLocalStorage = function () {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
// Tüm localStorage anahtarlarını getir
|
|
53
|
-
export
|
|
53
|
+
export const getLocalStorageAllKeys = () => {
|
|
54
54
|
if (!storageAvailable)
|
|
55
55
|
return [];
|
|
56
56
|
return Object.keys(localStorage);
|
|
57
57
|
};
|
|
58
58
|
// Tüm localStorage boyutunu getir
|
|
59
|
-
export
|
|
59
|
+
export const getLocalStorageSize = () => {
|
|
60
60
|
if (!storageAvailable)
|
|
61
61
|
return 0;
|
|
62
|
-
|
|
63
|
-
for (
|
|
62
|
+
let total = 0;
|
|
63
|
+
for (const key in localStorage) {
|
|
64
64
|
if (localStorage.hasOwnProperty(key)) {
|
|
65
65
|
total += localStorage[key].length + key.length;
|
|
66
66
|
}
|