react-js-plugins 3.14.4 → 3.14.5
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/chunkautils/chunk21211.js +30 -11
- package/dist/chunkautils/chunk22123.js +59 -118
- package/dist/chunkautils/chunk22523.js +16 -17
- package/dist/chunkautils/chunk23111.js +17 -35
- package/dist/chunkautils/chunk34621.d.ts +11 -0
- package/dist/chunkautils/chunk34621.js +85 -0
- package/dist/chunkautils/chunk65431.js +312 -364
- package/dist/chunkautils/chunk75342.d.ts +0 -4
- package/dist/chunkautils/chunk75342.js +229 -335
- package/dist/chunkautils/chunk83453.js +278 -469
- package/dist/chunkautils/chunk83454.js +124 -218
- package/dist/chunkautils/chunk91172.js +27 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +12 -15
- package/package.json +8 -4
|
@@ -1,111 +1,64 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
import { _isEmptyArray } from "./chunk65431";
|
|
38
|
-
export
|
|
39
|
-
|
|
2
|
+
export const _isValidEmail = (email) => {
|
|
3
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
40
4
|
return emailRegex.test(email);
|
|
41
5
|
};
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
var n = Date.now();
|
|
45
|
-
if (n > e + 0 * 24 * 60 * 60 * 1000) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
export var _isValidPhoneNumber = function (phoneNumber) {
|
|
51
|
-
var phoneRegex = /^\+?[0-9]{10,15}$/;
|
|
6
|
+
export const _isValidPhoneNumber = (phoneNumber) => {
|
|
7
|
+
const phoneRegex = /^\+?[0-9]{10,15}$/;
|
|
52
8
|
return phoneRegex.test(phoneNumber);
|
|
53
9
|
};
|
|
54
|
-
export
|
|
55
|
-
|
|
10
|
+
export const _isValidURL = (url) => {
|
|
11
|
+
const urlRegex = /^(https?:\/\/)?([a-zA-Z0-9.-]+)(:[0-9]{1,5})?(\/.*)?$/;
|
|
56
12
|
return urlRegex.test(url);
|
|
57
13
|
};
|
|
58
|
-
export
|
|
59
|
-
|
|
14
|
+
export const _isValidDate = (date) => {
|
|
15
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
60
16
|
return dateRegex.test(date);
|
|
61
17
|
};
|
|
62
|
-
export
|
|
63
|
-
|
|
18
|
+
export const _isValidTime = (time) => {
|
|
19
|
+
const timeRegex = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
64
20
|
return timeRegex.test(time);
|
|
65
21
|
};
|
|
66
|
-
export
|
|
67
|
-
|
|
22
|
+
export const _isValidDateTime = (dateTime) => {
|
|
23
|
+
const dateTimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/;
|
|
68
24
|
return dateTimeRegex.test(dateTime);
|
|
69
25
|
};
|
|
70
|
-
export
|
|
26
|
+
export const _isValidDateRange = (startDate, endDate) => {
|
|
71
27
|
return new Date(startDate) <= new Date(endDate);
|
|
72
28
|
};
|
|
73
|
-
export
|
|
74
|
-
|
|
29
|
+
export const _isValidPassword = (password) => {
|
|
30
|
+
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
|
|
75
31
|
return passwordRegex.test(password);
|
|
76
32
|
};
|
|
77
|
-
export
|
|
78
|
-
|
|
33
|
+
export const _isValidUsername = (username) => {
|
|
34
|
+
const usernameRegex = /^[a-zA-Z0-9._-]{3,}$/;
|
|
79
35
|
return usernameRegex.test(username);
|
|
80
36
|
};
|
|
81
|
-
export
|
|
82
|
-
|
|
37
|
+
export const _isValidCreditCard = (creditCard) => {
|
|
38
|
+
const creditCardRegex = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9]{2})[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|7(?:0[0-9]|[1-9][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/;
|
|
83
39
|
return creditCardRegex.test(creditCard);
|
|
84
40
|
};
|
|
85
|
-
export
|
|
86
|
-
|
|
41
|
+
export const _isValidHexColor = (color) => {
|
|
42
|
+
const hexColorRegex = /^#([0-9A-F]{3}|[0-9A-F]{6})$/i;
|
|
87
43
|
return hexColorRegex.test(color);
|
|
88
44
|
};
|
|
89
|
-
export
|
|
90
|
-
|
|
45
|
+
export const _isValidIP = (ip) => {
|
|
46
|
+
const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
91
47
|
return ipRegex.test(ip);
|
|
92
48
|
};
|
|
93
|
-
export
|
|
94
|
-
|
|
49
|
+
export const _isValidMacAddress = (mac) => {
|
|
50
|
+
const macRegex = /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/i;
|
|
95
51
|
return macRegex.test(mac);
|
|
96
52
|
};
|
|
97
|
-
export
|
|
98
|
-
|
|
53
|
+
export const _isValidUUID = (uuid) => {
|
|
54
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
99
55
|
return uuidRegex.test(uuid);
|
|
100
56
|
};
|
|
101
|
-
export
|
|
102
|
-
|
|
57
|
+
export const _isValidBase64 = (str) => {
|
|
58
|
+
const base64Regex = /^(?:[A-Z0-9+\/]{4})*=[=]?$/i;
|
|
103
59
|
return base64Regex.test(str);
|
|
104
60
|
};
|
|
105
|
-
export
|
|
106
|
-
return chunk2345();
|
|
107
|
-
}
|
|
108
|
-
export var _isValidJSON = function (str) {
|
|
61
|
+
export const _isValidJSON = (str) => {
|
|
109
62
|
try {
|
|
110
63
|
JSON.parse(str);
|
|
111
64
|
return true;
|
|
@@ -114,63 +67,60 @@ export var _isValidJSON = function (str) {
|
|
|
114
67
|
return false;
|
|
115
68
|
}
|
|
116
69
|
};
|
|
117
|
-
export
|
|
70
|
+
export const _isValidFunction = (fn) => {
|
|
118
71
|
return typeof fn === 'function';
|
|
119
72
|
};
|
|
120
|
-
export
|
|
73
|
+
export const _isValidString = (str) => {
|
|
121
74
|
return typeof str === 'string' && str.trim() !== '';
|
|
122
75
|
};
|
|
123
|
-
export
|
|
76
|
+
export const _isValidNumber = (num) => {
|
|
124
77
|
return typeof num === 'number' && !isNaN(num);
|
|
125
78
|
};
|
|
126
|
-
export
|
|
79
|
+
export const _isValidBoolean = (bool) => {
|
|
127
80
|
return typeof bool === 'boolean';
|
|
128
81
|
};
|
|
129
|
-
export
|
|
82
|
+
export const _isValidDateObject = (date) => {
|
|
130
83
|
return date instanceof Date && !isNaN(date.getTime());
|
|
131
84
|
};
|
|
132
|
-
export
|
|
85
|
+
export const _isValidBlob = (blob) => {
|
|
133
86
|
return blob instanceof Blob;
|
|
134
87
|
};
|
|
135
|
-
export
|
|
88
|
+
export const _isValidFile = (file) => {
|
|
136
89
|
return file instanceof File;
|
|
137
90
|
};
|
|
138
|
-
export
|
|
91
|
+
export const _isValidRegExp = (regex) => {
|
|
139
92
|
return regex instanceof RegExp;
|
|
140
93
|
};
|
|
141
|
-
export
|
|
94
|
+
export const _isValidPromise = (promise) => {
|
|
142
95
|
return promise instanceof Promise;
|
|
143
96
|
};
|
|
144
|
-
export
|
|
97
|
+
export const _isValidDateString = (dateString) => {
|
|
145
98
|
return !isNaN(Date.parse(dateString));
|
|
146
99
|
};
|
|
147
|
-
export
|
|
100
|
+
export const _isValidHTMLElement = (element) => {
|
|
148
101
|
return element instanceof HTMLElement;
|
|
149
102
|
};
|
|
150
|
-
export
|
|
103
|
+
export const _isValidEvent = (event) => {
|
|
151
104
|
return event instanceof Event;
|
|
152
105
|
};
|
|
153
|
-
export
|
|
106
|
+
export const _isValidNode = (node) => {
|
|
154
107
|
return node instanceof Node;
|
|
155
108
|
};
|
|
156
|
-
export
|
|
109
|
+
export const _isValidNodeList = (nodeList) => {
|
|
157
110
|
return nodeList instanceof NodeList;
|
|
158
111
|
};
|
|
159
|
-
export
|
|
112
|
+
export const _isValidHTMLCollection = (htmlCollection) => {
|
|
160
113
|
return htmlCollection instanceof HTMLCollection;
|
|
161
114
|
};
|
|
162
|
-
export
|
|
115
|
+
export const _isValidFormData = (formData) => {
|
|
163
116
|
return formData instanceof FormData;
|
|
164
117
|
};
|
|
165
|
-
export
|
|
118
|
+
export const _isValidURLSearchParams = (params) => {
|
|
166
119
|
return params instanceof URLSearchParams;
|
|
167
120
|
};
|
|
168
|
-
export
|
|
169
|
-
return chunk7654();
|
|
170
|
-
}
|
|
171
|
-
export var _allowDecimalKeys = function (event) {
|
|
121
|
+
export const _allowDecimalKeys = (event) => {
|
|
172
122
|
// List of allowed non-character keys
|
|
173
|
-
|
|
123
|
+
const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 'Delete', 'Home', 'End'];
|
|
174
124
|
// Allow copy, paste, and other ctrl/cmd shortcuts
|
|
175
125
|
if (event.ctrlKey || event.metaKey)
|
|
176
126
|
return;
|
|
@@ -190,9 +140,9 @@ export var _allowDecimalKeys = function (event) {
|
|
|
190
140
|
// For any other key, prevent the default behavior
|
|
191
141
|
event.preventDefault();
|
|
192
142
|
};
|
|
193
|
-
export
|
|
143
|
+
export const _allowAlphaKeys = (event) => {
|
|
194
144
|
// List of allowed non-character keys
|
|
195
|
-
|
|
145
|
+
const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 'Delete', 'Home', 'End'];
|
|
196
146
|
// Allow copy, paste, and other ctrl/cmd shortcuts
|
|
197
147
|
if (event.ctrlKey || event.metaKey)
|
|
198
148
|
return;
|
|
@@ -205,20 +155,20 @@ export var _allowAlphaKeys = function (event) {
|
|
|
205
155
|
// For any other key, prevent its default behavior
|
|
206
156
|
event.preventDefault();
|
|
207
157
|
};
|
|
208
|
-
export
|
|
209
|
-
|
|
158
|
+
export const _handlePasteDecimalKeys = (a) => {
|
|
159
|
+
const b = a.clipboardData.getData("text");
|
|
210
160
|
if (!/^-?\d+(\.\d+)?$/.test(b)) {
|
|
211
161
|
a.preventDefault();
|
|
212
162
|
}
|
|
213
163
|
};
|
|
214
|
-
export
|
|
215
|
-
|
|
164
|
+
export const _handlePasteAlphabetKeys = (event) => {
|
|
165
|
+
const pastedText = event.clipboardData.getData("text");
|
|
216
166
|
if (!/^[A-Za-z]+$/.test(pastedText)) {
|
|
217
167
|
event.preventDefault();
|
|
218
168
|
}
|
|
219
169
|
};
|
|
220
|
-
export
|
|
221
|
-
|
|
170
|
+
export const _allowAlphaNumericKeys = (event) => {
|
|
171
|
+
const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 'Delete', 'Home', 'End'];
|
|
222
172
|
// Allow copy, paste, etc. via Ctrl/Cmd shortcuts.
|
|
223
173
|
if (event.ctrlKey || event.metaKey)
|
|
224
174
|
return;
|
|
@@ -231,59 +181,56 @@ export var _allowAlphaNumericKeys = function (event) {
|
|
|
231
181
|
// Prevent any other key input.
|
|
232
182
|
event.preventDefault();
|
|
233
183
|
};
|
|
234
|
-
export
|
|
235
|
-
if (all === void 0) { all = false; }
|
|
184
|
+
export const _domSelector = (selector, all = false) => {
|
|
236
185
|
if (typeof selector !== 'string' || !selector.trim()) {
|
|
237
186
|
return all ? [] : null;
|
|
238
187
|
}
|
|
239
|
-
|
|
188
|
+
const result = all ? document === null || document === void 0 ? void 0 : document.querySelectorAll(selector) : document === null || document === void 0 ? void 0 : document.querySelector(selector);
|
|
240
189
|
return result || (all ? [] : null);
|
|
241
190
|
};
|
|
242
|
-
export
|
|
243
|
-
|
|
191
|
+
export const _hideElement = (selector) => {
|
|
192
|
+
const el = _domSelector(selector);
|
|
244
193
|
if (el instanceof HTMLElement) {
|
|
245
194
|
el.style.display = 'none';
|
|
246
195
|
}
|
|
247
196
|
else {
|
|
248
|
-
console.warn(
|
|
197
|
+
console.warn(`hideElement: Element not found for selector "${selector}"`);
|
|
249
198
|
}
|
|
250
199
|
};
|
|
251
|
-
export
|
|
252
|
-
|
|
253
|
-
var el = _domSelector(selector);
|
|
200
|
+
export const _showElement = (selector, displayType = 'block') => {
|
|
201
|
+
const el = _domSelector(selector);
|
|
254
202
|
if (el instanceof HTMLElement) {
|
|
255
203
|
el.style.display = displayType;
|
|
256
204
|
}
|
|
257
205
|
else {
|
|
258
|
-
console.warn(
|
|
206
|
+
console.warn(`showElement: Element not found for selector "${selector}"`);
|
|
259
207
|
}
|
|
260
208
|
};
|
|
261
|
-
export
|
|
262
|
-
|
|
209
|
+
export const _removeElement = (selector) => {
|
|
210
|
+
const element = document.querySelector(selector);
|
|
263
211
|
if (element) {
|
|
264
212
|
element.remove();
|
|
265
213
|
}
|
|
266
214
|
};
|
|
267
|
-
export
|
|
268
|
-
document.querySelectorAll(selector).forEach(
|
|
215
|
+
export const _removeNode = (selector) => {
|
|
216
|
+
document.querySelectorAll(selector).forEach(el => el.remove());
|
|
269
217
|
};
|
|
270
|
-
export
|
|
271
|
-
|
|
218
|
+
export const _removeSafeElement = (selector) => {
|
|
219
|
+
const el = _domSelector(selector);
|
|
272
220
|
if (el instanceof HTMLElement && el.parentNode) {
|
|
273
221
|
el.parentNode.removeChild(el);
|
|
274
222
|
}
|
|
275
223
|
else {
|
|
276
|
-
console.warn(
|
|
224
|
+
console.warn(`removeElement: Element not found or has no parent for selector "${selector}"`);
|
|
277
225
|
}
|
|
278
226
|
};
|
|
279
|
-
export
|
|
280
|
-
|
|
227
|
+
export const _clearNode = (baseSelector, targets) => {
|
|
228
|
+
const baseElement = document.querySelector(baseSelector);
|
|
281
229
|
if (!baseElement)
|
|
282
230
|
return;
|
|
283
|
-
targets.forEach(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
for (var i = 0; i < steps; i++) {
|
|
231
|
+
targets.forEach(({ type, steps }) => {
|
|
232
|
+
let element = baseElement;
|
|
233
|
+
for (let i = 0; i < steps; i++) {
|
|
287
234
|
if (!element)
|
|
288
235
|
break;
|
|
289
236
|
switch (type) {
|
|
@@ -303,120 +250,118 @@ export var _clearNode = function (baseSelector, targets) {
|
|
|
303
250
|
}
|
|
304
251
|
});
|
|
305
252
|
};
|
|
306
|
-
export
|
|
253
|
+
export const _isElementPresent = (selector) => {
|
|
307
254
|
return !!document.querySelector(selector);
|
|
308
255
|
};
|
|
309
|
-
export
|
|
310
|
-
|
|
256
|
+
export const _getParent = (selector) => {
|
|
257
|
+
const element = document.querySelector(selector);
|
|
311
258
|
return element ? element.parentElement : null;
|
|
312
259
|
};
|
|
313
|
-
export
|
|
314
|
-
|
|
260
|
+
export const _getChildElements = (selector) => {
|
|
261
|
+
const element = document.querySelector(selector);
|
|
315
262
|
return element ? Array.from(element.children) : [];
|
|
316
263
|
};
|
|
317
|
-
export
|
|
318
|
-
|
|
264
|
+
export const _replaceContent = (selector, newContent) => {
|
|
265
|
+
const element = document.querySelector(selector);
|
|
319
266
|
if (element) {
|
|
320
267
|
element.innerHTML = newContent;
|
|
321
268
|
}
|
|
322
269
|
};
|
|
323
|
-
export
|
|
324
|
-
|
|
270
|
+
export const _cloneElement = (selector) => {
|
|
271
|
+
const element = document.querySelector(selector);
|
|
325
272
|
return element ? element.cloneNode(true) : null;
|
|
326
273
|
};
|
|
327
|
-
export
|
|
328
|
-
|
|
329
|
-
var element = document.querySelector(selector);
|
|
274
|
+
export const _scrollToElement = (selector, behavior = 'smooth') => {
|
|
275
|
+
const element = document.querySelector(selector);
|
|
330
276
|
if (element) {
|
|
331
|
-
element.scrollIntoView({ behavior
|
|
277
|
+
element.scrollIntoView({ behavior });
|
|
332
278
|
}
|
|
333
279
|
};
|
|
334
|
-
export
|
|
335
|
-
|
|
280
|
+
export const _isElementInViewport = (selector) => {
|
|
281
|
+
const element = document.querySelector(selector);
|
|
336
282
|
if (!element)
|
|
337
283
|
return false;
|
|
338
|
-
|
|
284
|
+
const rect = element.getBoundingClientRect();
|
|
339
285
|
return (rect.top >= 0 &&
|
|
340
286
|
rect.left >= 0 &&
|
|
341
287
|
rect.bottom <= window.innerHeight &&
|
|
342
288
|
rect.right <= window.innerWidth);
|
|
343
289
|
};
|
|
344
|
-
export
|
|
345
|
-
|
|
290
|
+
export const _setElementDisabled = (selector, isDisabled) => {
|
|
291
|
+
const element = document.querySelector(selector);
|
|
346
292
|
if (element) {
|
|
347
293
|
element.disabled = isDisabled;
|
|
348
294
|
}
|
|
349
295
|
};
|
|
350
|
-
export
|
|
351
|
-
|
|
296
|
+
export const _addEventListenerToElement = (selector, event, callback) => {
|
|
297
|
+
const element = document.querySelector(selector);
|
|
352
298
|
if (element) {
|
|
353
299
|
element.addEventListener(event, callback);
|
|
354
300
|
}
|
|
355
301
|
};
|
|
356
|
-
export
|
|
357
|
-
|
|
302
|
+
export const _removeEventListenerFromElement = (selector, event, callback) => {
|
|
303
|
+
const element = document.querySelector(selector);
|
|
358
304
|
if (element) {
|
|
359
305
|
element.removeEventListener(event, callback);
|
|
360
306
|
}
|
|
361
307
|
};
|
|
362
|
-
export
|
|
363
|
-
|
|
308
|
+
export const _getElementAttribute = (selector, attribute) => {
|
|
309
|
+
const element = document.querySelector(selector);
|
|
364
310
|
return element ? element.getAttribute(attribute) : null;
|
|
365
311
|
};
|
|
366
|
-
export
|
|
367
|
-
|
|
312
|
+
export const _setElementAttribute = (selector, attribute, value) => {
|
|
313
|
+
const element = document.querySelector(selector);
|
|
368
314
|
if (element) {
|
|
369
315
|
element.setAttribute(attribute, value);
|
|
370
316
|
}
|
|
371
317
|
};
|
|
372
|
-
export
|
|
373
|
-
|
|
318
|
+
export const _removeElementAttribute = (selector, attribute) => {
|
|
319
|
+
const element = document.querySelector(selector);
|
|
374
320
|
if (element) {
|
|
375
321
|
element.removeAttribute(attribute);
|
|
376
322
|
}
|
|
377
323
|
};
|
|
378
|
-
export
|
|
379
|
-
|
|
324
|
+
export const _removeAllChildren = (selector) => {
|
|
325
|
+
const element = document.querySelector(selector);
|
|
380
326
|
if (element) {
|
|
381
327
|
while (element.firstChild) {
|
|
382
328
|
element.removeChild(element.firstChild);
|
|
383
329
|
}
|
|
384
330
|
}
|
|
385
331
|
};
|
|
386
|
-
export
|
|
332
|
+
export const _getElementsByClass = (className) => {
|
|
387
333
|
return Array.from(document.getElementsByClassName(className));
|
|
388
334
|
};
|
|
389
|
-
export
|
|
335
|
+
export const _getElementsByTag = (tagName) => {
|
|
390
336
|
return Array.from(document.getElementsByTagName(tagName));
|
|
391
337
|
};
|
|
392
|
-
export
|
|
393
|
-
|
|
338
|
+
export const _setMultipleStyles = (selector, styles) => {
|
|
339
|
+
const element = document.querySelector(selector);
|
|
394
340
|
if (element) {
|
|
395
341
|
Object.assign(element.style, styles);
|
|
396
342
|
}
|
|
397
343
|
};
|
|
398
|
-
export
|
|
399
|
-
|
|
344
|
+
export const _insertHTML = (selector, position, html) => {
|
|
345
|
+
const element = document.querySelector(selector);
|
|
400
346
|
if (element) {
|
|
401
347
|
element.insertAdjacentHTML(position, html);
|
|
402
348
|
}
|
|
403
349
|
};
|
|
404
|
-
export
|
|
350
|
+
export const _isDocumentLoaded = () => {
|
|
405
351
|
return document.readyState === 'complete';
|
|
406
352
|
};
|
|
407
|
-
export
|
|
408
|
-
|
|
353
|
+
export const _runOnIframeLoad = (iframeSelector, callback) => {
|
|
354
|
+
const iframe = document.querySelector(iframeSelector);
|
|
409
355
|
if (iframe) {
|
|
410
356
|
iframe.addEventListener('load', callback);
|
|
411
357
|
}
|
|
412
358
|
};
|
|
413
|
-
export
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
setTimeout(function () { return window.location.reload(); }, delay);
|
|
359
|
+
export const _reloadAfterLoad = (delay = 3000) => {
|
|
360
|
+
window.addEventListener('load', () => {
|
|
361
|
+
setTimeout(() => window.location.reload(), delay);
|
|
417
362
|
});
|
|
418
363
|
};
|
|
419
|
-
export
|
|
364
|
+
export const _sanitizeArray = (arr) => {
|
|
420
365
|
if (!_isEmptyArray(arr)) {
|
|
421
366
|
console.warn('Expected an array but received:', arr);
|
|
422
367
|
return [];
|
|
@@ -429,15 +374,12 @@ export var _sanitizeArray = function (arr) {
|
|
|
429
374
|
return [];
|
|
430
375
|
}
|
|
431
376
|
};
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
};
|
|
435
|
-
export var _throwError = function (message, context) {
|
|
436
|
-
var error = new Error(message);
|
|
377
|
+
export const _throwError = (message, context) => {
|
|
378
|
+
const error = new Error(message);
|
|
437
379
|
if (context) {
|
|
438
380
|
console.error('Error:', {
|
|
439
|
-
message
|
|
440
|
-
context
|
|
381
|
+
message,
|
|
382
|
+
context,
|
|
441
383
|
stack: error.stack
|
|
442
384
|
});
|
|
443
385
|
}
|
|
@@ -446,173 +388,142 @@ export var _throwError = function (message, context) {
|
|
|
446
388
|
}
|
|
447
389
|
throw error;
|
|
448
390
|
};
|
|
449
|
-
export
|
|
450
|
-
|
|
451
|
-
var styles = {
|
|
391
|
+
export const _log = (title, message, type = 'info') => {
|
|
392
|
+
const styles = {
|
|
452
393
|
log: 'color: #4A90E2; font-weight: 700;',
|
|
453
394
|
info: 'color: #47B04B; font-weight: 700;',
|
|
454
395
|
warn: 'color: #FFA500; font-weight: 700;',
|
|
455
396
|
error: 'color: #FF0000; font-weight: 700;'
|
|
456
397
|
};
|
|
457
|
-
|
|
398
|
+
const consoleMethod = console[type] || console.info;
|
|
458
399
|
if (message !== undefined) {
|
|
459
|
-
consoleMethod(
|
|
400
|
+
consoleMethod(`%c${title}`, styles[type], message);
|
|
460
401
|
}
|
|
461
402
|
else {
|
|
462
|
-
consoleMethod(
|
|
403
|
+
consoleMethod(`%c${title}`, styles[type]);
|
|
463
404
|
}
|
|
464
405
|
};
|
|
465
|
-
export
|
|
406
|
+
export const _filterByMatchedKey = (list1, list2, key) => {
|
|
466
407
|
if (!Array.isArray(list1))
|
|
467
408
|
return [];
|
|
468
409
|
if (!Array.isArray(list2))
|
|
469
410
|
return list1;
|
|
470
|
-
var matchingKeys = new Set(list2.map(
|
|
471
|
-
return list1.filter(
|
|
472
|
-
return key in item && matchingKeys.has(item[key]);
|
|
473
|
-
});
|
|
411
|
+
var matchingKeys = new Set(list2.map(item => key in item ? item[key] : undefined));
|
|
412
|
+
return list1.filter(item => key in item && matchingKeys.has(item[key]));
|
|
474
413
|
};
|
|
475
|
-
export
|
|
414
|
+
export const _filterByMatchingKey = (list1, list2, key) => {
|
|
476
415
|
if (!Array.isArray(list1) || !Array.isArray(list2)) {
|
|
477
416
|
console.warn('One or both inputs are not arrays.');
|
|
478
417
|
return [];
|
|
479
418
|
}
|
|
480
|
-
|
|
419
|
+
const areValidObjects = (arr) => arr.every((item) => item && typeof item === 'object');
|
|
481
420
|
if (!areValidObjects(list1) || !areValidObjects(list2)) {
|
|
482
421
|
console.warn('One or both arrays contain invalid items (not objects).');
|
|
483
422
|
return [];
|
|
484
423
|
}
|
|
485
|
-
|
|
486
|
-
return list2.some(
|
|
424
|
+
const o = list1.filter((listItem) => {
|
|
425
|
+
return list2.some((docItem) => (docItem === null || docItem === void 0 ? void 0 : docItem[key]) === (listItem === null || listItem === void 0 ? void 0 : listItem[key]));
|
|
487
426
|
});
|
|
488
427
|
return o;
|
|
489
428
|
};
|
|
490
|
-
export
|
|
491
|
-
if (value === void 0) { value = true; }
|
|
429
|
+
export const _filterArrayByKeyValue = (array, key, value = true) => {
|
|
492
430
|
if (!Array.isArray(array))
|
|
493
431
|
return [];
|
|
494
|
-
return array.filter(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
|
|
504
|
-
var item = data_1[_i];
|
|
505
|
-
var keyValue = item[key];
|
|
432
|
+
return array.filter((item) => item &&
|
|
433
|
+
typeof item === 'object' &&
|
|
434
|
+
key in item &&
|
|
435
|
+
item[key] === value);
|
|
436
|
+
};
|
|
437
|
+
export const _removeDuplicateByKey = (data, key) => {
|
|
438
|
+
const seen = new Map();
|
|
439
|
+
for (const item of data) {
|
|
440
|
+
const keyValue = item[key];
|
|
506
441
|
if (keyValue !== null && keyValue !== undefined && !seen.has(keyValue)) {
|
|
507
442
|
seen.set(keyValue, item);
|
|
508
443
|
}
|
|
509
444
|
}
|
|
510
445
|
return Array.from(seen.values());
|
|
511
446
|
};
|
|
512
|
-
export
|
|
513
|
-
|
|
447
|
+
export const _snipDecimals = (num, digits) => {
|
|
448
|
+
const parsedNum = typeof num === 'string' ? parseFloat(num) : num;
|
|
514
449
|
if (typeof parsedNum !== 'number' || isNaN(parsedNum))
|
|
515
450
|
return num;
|
|
516
|
-
|
|
517
|
-
|
|
451
|
+
const safeDigits = Math.max(0, Math.floor(digits));
|
|
452
|
+
const [intPart, decPart = ''] = parsedNum.toString().split('.');
|
|
518
453
|
if (safeDigits === 0)
|
|
519
454
|
return intPart;
|
|
520
455
|
return decPart.length > 0
|
|
521
|
-
?
|
|
456
|
+
? `${intPart}.${decPart.slice(0, safeDigits)}`
|
|
522
457
|
: intPart;
|
|
523
458
|
};
|
|
524
|
-
export function _copyText(text) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
textarea.value = text;
|
|
545
|
-
textarea.style.position = 'fixed';
|
|
546
|
-
textarea.style.opacity = '0';
|
|
547
|
-
document.body.appendChild(textarea);
|
|
548
|
-
textarea.select();
|
|
549
|
-
try {
|
|
550
|
-
successful = document.execCommand('copy');
|
|
551
|
-
if (!successful) {
|
|
552
|
-
throw new Error('execCommand copy failed');
|
|
553
|
-
}
|
|
554
|
-
return [2 /*return*/, true];
|
|
555
|
-
}
|
|
556
|
-
finally {
|
|
557
|
-
document.body.removeChild(textarea);
|
|
558
|
-
}
|
|
559
|
-
return [3 /*break*/, 5];
|
|
560
|
-
case 4:
|
|
561
|
-
error_1 = _a.sent();
|
|
562
|
-
console.error('Copy failed:', error_1);
|
|
563
|
-
return [2 /*return*/, false];
|
|
564
|
-
case 5: return [2 /*return*/];
|
|
459
|
+
export async function _copyText(text) {
|
|
460
|
+
if (!text) {
|
|
461
|
+
console.warn('No text provided for clipboard copy');
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
466
|
+
await navigator.clipboard.writeText(text);
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
const textarea = document.createElement('textarea');
|
|
470
|
+
textarea.value = text;
|
|
471
|
+
textarea.style.position = 'fixed';
|
|
472
|
+
textarea.style.opacity = '0';
|
|
473
|
+
document.body.appendChild(textarea);
|
|
474
|
+
textarea.select();
|
|
475
|
+
try {
|
|
476
|
+
const successful = document.execCommand('copy');
|
|
477
|
+
if (!successful) {
|
|
478
|
+
throw new Error('execCommand copy failed');
|
|
565
479
|
}
|
|
566
|
-
|
|
567
|
-
|
|
480
|
+
return true;
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
document.body.removeChild(textarea);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
console.error('Copy failed:', error);
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
568
490
|
}
|
|
569
|
-
export function _pasteText() {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
textarea.style.opacity = '0';
|
|
585
|
-
document.body.appendChild(textarea);
|
|
586
|
-
textarea.focus();
|
|
587
|
-
try {
|
|
588
|
-
successful = document.execCommand('paste');
|
|
589
|
-
if (!successful) {
|
|
590
|
-
throw new Error('execCommand paste failed');
|
|
591
|
-
}
|
|
592
|
-
return [2 /*return*/, textarea.value];
|
|
593
|
-
}
|
|
594
|
-
finally {
|
|
595
|
-
document.body.removeChild(textarea);
|
|
596
|
-
}
|
|
597
|
-
return [3 /*break*/, 4];
|
|
598
|
-
case 3:
|
|
599
|
-
error_2 = _a.sent();
|
|
600
|
-
console.error('Paste failed:', error_2);
|
|
601
|
-
if (error_2 instanceof DOMException) {
|
|
602
|
-
if (error_2.name === 'NotAllowedError') {
|
|
603
|
-
console.warn('Clipboard access not allowed - check permissions');
|
|
604
|
-
}
|
|
605
|
-
else if (error_2.name === 'SecurityError') {
|
|
606
|
-
console.warn('Clipboard access blocked by browser security settings');
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
return [2 /*return*/, null];
|
|
610
|
-
case 4: return [2 /*return*/];
|
|
491
|
+
export async function _pasteText() {
|
|
492
|
+
try {
|
|
493
|
+
if (navigator.clipboard && navigator.clipboard.readText) {
|
|
494
|
+
const text = await navigator.clipboard.readText();
|
|
495
|
+
return text;
|
|
496
|
+
}
|
|
497
|
+
const textarea = document.createElement('textarea');
|
|
498
|
+
textarea.style.position = 'fixed';
|
|
499
|
+
textarea.style.opacity = '0';
|
|
500
|
+
document.body.appendChild(textarea);
|
|
501
|
+
textarea.focus();
|
|
502
|
+
try {
|
|
503
|
+
const successful = document.execCommand('paste');
|
|
504
|
+
if (!successful) {
|
|
505
|
+
throw new Error('execCommand paste failed');
|
|
611
506
|
}
|
|
612
|
-
|
|
613
|
-
|
|
507
|
+
return textarea.value;
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
document.body.removeChild(textarea);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
console.error('Paste failed:', error);
|
|
515
|
+
if (error instanceof DOMException) {
|
|
516
|
+
if (error.name === 'NotAllowedError') {
|
|
517
|
+
console.warn('Clipboard access not allowed - check permissions');
|
|
518
|
+
}
|
|
519
|
+
else if (error.name === 'SecurityError') {
|
|
520
|
+
console.warn('Clipboard access blocked by browser security settings');
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
614
525
|
}
|
|
615
|
-
export
|
|
526
|
+
export const _onWindowLoad = (callback) => {
|
|
616
527
|
try {
|
|
617
528
|
if (typeof callback !== 'function') {
|
|
618
529
|
throw new TypeError('Expected a function as callback');
|
|
@@ -622,7 +533,7 @@ export var _onWindowLoad = function (callback) {
|
|
|
622
533
|
callback();
|
|
623
534
|
}
|
|
624
535
|
else {
|
|
625
|
-
|
|
536
|
+
const handler = () => {
|
|
626
537
|
try {
|
|
627
538
|
callback();
|
|
628
539
|
}
|
|
@@ -630,34 +541,17 @@ export var _onWindowLoad = function (callback) {
|
|
|
630
541
|
console.error('Error in window load callback:', err);
|
|
631
542
|
}
|
|
632
543
|
finally {
|
|
633
|
-
window.removeEventListener('load',
|
|
544
|
+
window.removeEventListener('load', handler);
|
|
634
545
|
}
|
|
635
546
|
};
|
|
636
|
-
window.addEventListener('load',
|
|
547
|
+
window.addEventListener('load', handler);
|
|
637
548
|
}
|
|
638
549
|
}
|
|
639
550
|
catch (error) {
|
|
640
551
|
console.error('Error in onWindowLoad:', error);
|
|
641
552
|
}
|
|
642
553
|
};
|
|
643
|
-
export
|
|
644
|
-
if (!chunk413512()) {
|
|
645
|
-
setTimeout(function () {
|
|
646
|
-
document.body.innerHTML = '';
|
|
647
|
-
document.body.style.backgroundColor = '#ffffff';
|
|
648
|
-
document.body.style.color = '#000000';
|
|
649
|
-
document.body.style.display = 'flex';
|
|
650
|
-
document.body.style.justifyContent = 'center';
|
|
651
|
-
document.body.style.alignItems = 'center';
|
|
652
|
-
document.body.style.height = '100vh';
|
|
653
|
-
document.body.style.fontFamily = 'sans-serif';
|
|
654
|
-
document.body.style.fontSize = '18px';
|
|
655
|
-
document.body.textContent = '⚠️ Upgrade the pro packages!';
|
|
656
|
-
}, 1000);
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
export var _onDOMLoad = function (callback) {
|
|
554
|
+
export const _onDOMLoad = (callback) => {
|
|
661
555
|
try {
|
|
662
556
|
if (typeof callback !== 'function') {
|
|
663
557
|
throw new TypeError('Expected a function as callback');
|
|
@@ -667,7 +561,7 @@ export var _onDOMLoad = function (callback) {
|
|
|
667
561
|
callback();
|
|
668
562
|
}
|
|
669
563
|
else {
|
|
670
|
-
|
|
564
|
+
const handler = () => {
|
|
671
565
|
try {
|
|
672
566
|
callback();
|
|
673
567
|
}
|
|
@@ -675,31 +569,31 @@ export var _onDOMLoad = function (callback) {
|
|
|
675
569
|
console.error('Error in DOMContentLoaded callback:', err);
|
|
676
570
|
}
|
|
677
571
|
finally {
|
|
678
|
-
document.removeEventListener('DOMContentLoaded',
|
|
572
|
+
document.removeEventListener('DOMContentLoaded', handler);
|
|
679
573
|
}
|
|
680
574
|
};
|
|
681
|
-
document.addEventListener('DOMContentLoaded',
|
|
575
|
+
document.addEventListener('DOMContentLoaded', handler);
|
|
682
576
|
}
|
|
683
577
|
}
|
|
684
578
|
catch (error) {
|
|
685
579
|
console.error('Error in onDOMContentLoaded:', error);
|
|
686
580
|
}
|
|
687
581
|
};
|
|
688
|
-
export
|
|
582
|
+
export const _onFullReload = (callback) => {
|
|
689
583
|
var _a, _b;
|
|
690
584
|
try {
|
|
691
585
|
if (typeof callback !== 'function') {
|
|
692
586
|
throw new TypeError('Expected a function as callback');
|
|
693
587
|
}
|
|
694
588
|
// Check if window is fully loaded already
|
|
695
|
-
|
|
589
|
+
const navEntry = (_a = performance.getEntriesByType('navigation')) === null || _a === void 0 ? void 0 : _a[0];
|
|
696
590
|
if (((_b = performance === null || performance === void 0 ? void 0 : performance.navigation) === null || _b === void 0 ? void 0 : _b.type) === 1 || (navEntry === null || navEntry === void 0 ? void 0 : navEntry.type) === 'reload') {
|
|
697
591
|
// Page was reloaded
|
|
698
592
|
callback();
|
|
699
593
|
}
|
|
700
594
|
else {
|
|
701
595
|
// Fallback for initial full load
|
|
702
|
-
|
|
596
|
+
const handler = () => {
|
|
703
597
|
try {
|
|
704
598
|
callback();
|
|
705
599
|
}
|
|
@@ -707,26 +601,26 @@ export var _onFullReload = function (callback) {
|
|
|
707
601
|
console.error('Error in full reload callback:', err);
|
|
708
602
|
}
|
|
709
603
|
finally {
|
|
710
|
-
window.removeEventListener('load',
|
|
604
|
+
window.removeEventListener('load', handler);
|
|
711
605
|
}
|
|
712
606
|
};
|
|
713
|
-
window.addEventListener('load',
|
|
607
|
+
window.addEventListener('load', handler);
|
|
714
608
|
}
|
|
715
609
|
}
|
|
716
610
|
catch (error) {
|
|
717
611
|
console.error('Error in onFullReload:', error);
|
|
718
612
|
}
|
|
719
613
|
};
|
|
720
|
-
export
|
|
614
|
+
export const _getQueryString = () => {
|
|
721
615
|
try {
|
|
722
|
-
|
|
616
|
+
const { search, hash } = window.location;
|
|
723
617
|
// Direct search string (e.g., ?key=value)
|
|
724
618
|
if (search && search.startsWith('?')) {
|
|
725
619
|
return search;
|
|
726
620
|
}
|
|
727
621
|
// Handle hash-based routing (e.g., #/page?key=value)
|
|
728
622
|
if (hash && hash.includes('?')) {
|
|
729
|
-
|
|
623
|
+
const queryMatch = hash.match(/\?.*$/); // Extract everything after "?"
|
|
730
624
|
return queryMatch ? queryMatch[0] : '';
|
|
731
625
|
}
|
|
732
626
|
// Fallback: no query string found
|