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