react-js-plugins 3.14.3 → 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.
@@ -1,97 +1,24 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- 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);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- 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;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
1
  import moment from "moment";
58
2
  import { _deepClone, isWindowReady } from "./chunk65431";
59
- import { chunk } from "./chunk75342";
60
- export var _scrollToTop = function () {
3
+ export const _scrollToTop = () => {
61
4
  if (!isWindowReady()) {
62
5
  return;
63
6
  }
64
7
  window.scrollTo({ top: 0, behavior: "smooth" });
65
8
  };
66
- export var _batchProcess = function (data, batchSize, processFn) { return __awaiter(void 0, void 0, void 0, function () {
67
- var i, batch;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0:
71
- i = 0;
72
- _a.label = 1;
73
- case 1:
74
- if (!(i < data.length)) return [3 /*break*/, 4];
75
- batch = data.slice(i, i + batchSize);
76
- return [4 /*yield*/, Promise.all(batch.map(processFn))];
77
- case 2:
78
- _a.sent();
79
- _a.label = 3;
80
- case 3:
81
- i += batchSize;
82
- return [3 /*break*/, 1];
83
- case 4: return [2 /*return*/];
84
- }
85
- });
86
- }); };
87
- export var _flattenObject = function (obj, prefix) {
88
- if (prefix === void 0) { prefix = ''; }
89
- var result = {};
90
- for (var key in obj) {
9
+ export const _batchProcess = async (data, batchSize, processFn) => {
10
+ for (let i = 0; i < data.length; i += batchSize) {
11
+ const batch = data.slice(i, i + batchSize);
12
+ await Promise.all(batch.map(processFn));
13
+ }
14
+ };
15
+ export const _flattenObject = (obj, prefix = '') => {
16
+ let result = {};
17
+ for (let key in obj) {
91
18
  if (obj.hasOwnProperty(key)) {
92
- var newKey = prefix ? "".concat(prefix, ".").concat(key) : key;
19
+ const newKey = prefix ? `${prefix}.${key}` : key;
93
20
  if (typeof obj[key] === 'object' && obj[key] !== null) {
94
- result = __assign(__assign({}, result), _flattenObject(obj[key], newKey));
21
+ result = Object.assign(Object.assign({}, result), _flattenObject(obj[key], newKey));
95
22
  }
96
23
  else {
97
24
  result[newKey] = obj[key];
@@ -100,8 +27,8 @@ export var _flattenObject = function (obj, prefix) {
100
27
  }
101
28
  return result;
102
29
  };
103
- export var _deepMerge = function (target, source) {
104
- for (var key in source) {
30
+ export const _deepMerge = (target, source) => {
31
+ for (let key in source) {
105
32
  if (source.hasOwnProperty(key)) {
106
33
  if (typeof source[key] === 'object' && source[key] !== null && target[key]) {
107
34
  target[key] = _deepMerge(target[key], source[key]);
@@ -113,14 +40,14 @@ export var _deepMerge = function (target, source) {
113
40
  }
114
41
  return target;
115
42
  };
116
- export var _chunk = function (arr, size) {
117
- var result = [];
118
- for (var i = 0; i < arr.length; i += size) {
43
+ export const _chunk = (arr, size) => {
44
+ const result = [];
45
+ for (let i = 0; i < arr.length; i += size) {
119
46
  result.push(arr.slice(i, i + size));
120
47
  }
121
48
  return result;
122
49
  };
123
- var toVal = function (mix) {
50
+ const toVal = (mix) => {
124
51
  if (typeof mix === "string" || typeof mix === "number") {
125
52
  return String(mix);
126
53
  }
@@ -132,66 +59,40 @@ var toVal = function (mix) {
132
59
  }
133
60
  if (mix && typeof mix === "object") {
134
61
  return Object.entries(mix)
135
- .filter(function (_a) {
136
- var _ = _a[0], value = _a[1];
137
- return Boolean(value);
138
- })
139
- .map(function (_a) {
140
- var key = _a[0];
141
- return key;
142
- })
62
+ .filter(([_, value]) => Boolean(value))
63
+ .map(([key]) => key)
143
64
  .join(" ");
144
65
  }
145
66
  return "";
146
67
  };
147
- export var _combineClasses = function () {
148
- var args = [];
149
- for (var _i = 0; _i < arguments.length; _i++) {
150
- args[_i] = arguments[_i];
151
- }
152
- if (!chunk()) {
153
- throw new Error("Postcss: <css input>:X:X: Unknown word");
154
- }
68
+ export const _combineClasses = (...args) => {
155
69
  return args
156
70
  .map(toVal)
157
71
  .filter(Boolean)
158
72
  .join(" ");
159
73
  };
160
- export var _asyncDebounce = function (fn, delay) {
161
- var timeout;
162
- return function () {
163
- var args = [];
164
- for (var _i = 0; _i < arguments.length; _i++) {
165
- args[_i] = arguments[_i];
166
- }
167
- return __awaiter(void 0, void 0, void 0, function () {
168
- return __generator(this, function (_a) {
169
- clearTimeout(timeout);
170
- timeout = setTimeout(function () { return fn.apply(void 0, args); }, delay);
171
- return [2 /*return*/];
172
- });
173
- });
74
+ export const _asyncDebounce = (fn, delay) => {
75
+ let timeout;
76
+ return async (...args) => {
77
+ clearTimeout(timeout);
78
+ timeout = setTimeout(() => fn(...args), delay);
174
79
  };
175
80
  };
176
81
  export function _throttle(func, limit) {
177
- var inThrottle;
178
- return function () {
179
- var args = [];
180
- for (var _i = 0; _i < arguments.length; _i++) {
181
- args[_i] = arguments[_i];
182
- }
82
+ let inThrottle;
83
+ return (...args) => {
183
84
  if (!inThrottle) {
184
- func.apply(void 0, args);
85
+ func(...args);
185
86
  inThrottle = true;
186
- setTimeout(function () { return (inThrottle = false); }, limit);
87
+ setTimeout(() => (inThrottle = false), limit);
187
88
  }
188
89
  };
189
90
  }
190
- export var _deepCloneArray = function (arr) {
191
- return arr.map(function (item) { return (typeof item === 'object' ? _deepClone(item) : item); });
91
+ export const _deepCloneArray = (arr) => {
92
+ return arr.map(item => (typeof item === 'object' ? _deepClone(item) : item));
192
93
  };
193
- export var _getMaxMinValue = function (arr) {
194
- return arr.reduce(function (acc, curr) {
94
+ export const _getMaxMinValue = (arr) => {
95
+ return arr.reduce((acc, curr) => {
195
96
  if (curr > acc.max)
196
97
  acc.max = curr;
197
98
  if (curr < acc.min)
@@ -199,64 +100,34 @@ export var _getMaxMinValue = function (arr) {
199
100
  return acc;
200
101
  }, { max: -Infinity, min: Infinity });
201
102
  };
202
- export var _asyncMap = function (arr, asyncFn) { return __awaiter(void 0, void 0, void 0, function () {
203
- var results, i, _a, _b;
204
- return __generator(this, function (_c) {
205
- switch (_c.label) {
206
- case 0:
207
- results = [];
208
- i = 0;
209
- _c.label = 1;
210
- case 1:
211
- if (!(i < arr.length)) return [3 /*break*/, 4];
212
- _b = (_a = results).push;
213
- return [4 /*yield*/, asyncFn(arr[i])];
214
- case 2:
215
- _b.apply(_a, [_c.sent()]);
216
- _c.label = 3;
217
- case 3:
218
- i++;
219
- return [3 /*break*/, 1];
220
- case 4: return [2 /*return*/, results];
221
- }
222
- });
223
- }); };
224
- export var _transformAsyncData = function (arr, transformer) { return __awaiter(void 0, void 0, void 0, function () {
225
- var result, i, transformedItem;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0:
229
- result = [];
230
- i = 0;
231
- _a.label = 1;
232
- case 1:
233
- if (!(i < arr.length)) return [3 /*break*/, 4];
234
- return [4 /*yield*/, transformer(arr[i])];
235
- case 2:
236
- transformedItem = _a.sent();
237
- result.push(transformedItem);
238
- _a.label = 3;
239
- case 3:
240
- i++;
241
- return [3 /*break*/, 1];
242
- case 4: return [2 /*return*/, result];
243
- }
244
- });
245
- }); };
246
- export var _getNestedProperty = function (obj, path) {
247
- return path.split('.').reduce(function (acc, key) { return acc && acc[key]; }, obj);
103
+ export const _asyncMap = async (arr, asyncFn) => {
104
+ const results = [];
105
+ for (let i = 0; i < arr.length; i++) {
106
+ results.push(await asyncFn(arr[i]));
107
+ }
108
+ return results;
109
+ };
110
+ export const _transformAsyncData = async (arr, transformer) => {
111
+ const result = [];
112
+ for (let i = 0; i < arr.length; i++) {
113
+ const transformedItem = await transformer(arr[i]);
114
+ result.push(transformedItem);
115
+ }
116
+ return result;
117
+ };
118
+ export const _getNestedProperty = (obj, path) => {
119
+ return path.split('.').reduce((acc, key) => acc && acc[key], obj);
248
120
  };
249
- export var _deepEqual = function (obj1, obj2) {
121
+ export const _deepEqual = (obj1, obj2) => {
250
122
  if (obj1 === obj2)
251
123
  return true;
252
124
  if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null)
253
125
  return false;
254
- var keys1 = Object.keys(obj1);
255
- var keys2 = Object.keys(obj2);
126
+ const keys1 = Object.keys(obj1);
127
+ const keys2 = Object.keys(obj2);
256
128
  if (keys1.length !== keys2.length)
257
129
  return false;
258
- for (var _i = 0, keys1_1 = keys1; _i < keys1_1.length; _i++) {
259
- var key = keys1_1[_i];
130
+ for (let key of keys1) {
260
131
  if (!keys2.includes(key))
261
132
  return false;
262
133
  if (!_deepEqual(obj1[key], obj2[key]))
@@ -264,63 +135,50 @@ export var _deepEqual = function (obj1, obj2) {
264
135
  }
265
136
  return true;
266
137
  };
267
- export var _mergeArrays = function (arr1, arr2) {
268
- return Array.from(new Set(__spreadArray(__spreadArray([], arr1, true), arr2, true)));
138
+ export const _mergeArrays = (arr1, arr2) => {
139
+ return Array.from(new Set([...arr1, ...arr2]));
269
140
  };
270
- export var _filterDuplicates = function (arr, uniqueKey) {
271
- var seen = new Set();
272
- return arr.filter(function (item) {
273
- var key = item[uniqueKey];
141
+ export const _filterDuplicates = (arr, uniqueKey) => {
142
+ const seen = new Set();
143
+ return arr.filter((item) => {
144
+ const key = item[uniqueKey];
274
145
  if (seen.has(key))
275
146
  return false;
276
147
  seen.add(key);
277
148
  return true;
278
149
  });
279
150
  };
280
- export var _sortByKey = function (arr, key, order) {
281
- if (order === void 0) { order = "asc"; }
282
- return __spreadArray([], arr, true).sort(function (a, b) {
283
- return order === "asc" ? a[key] - b[key] : b[key] - a[key];
284
- });
285
- };
286
- export var _extractUniqueValues = function (array, key) {
151
+ export const _sortByKey = (arr, key, order = "asc") => [...arr].sort((a, b) => order === "asc" ? a[key] - b[key] : b[key] - a[key]);
152
+ export const _extractUniqueValues = (array, key) => {
287
153
  if (!Array.isArray(array))
288
154
  return [];
289
- return Array.from(new Set(array.map(function (item) { return item[key]; }).filter(function (val) { return val !== undefined; })));
155
+ return Array.from(new Set(array.map(item => item[key]).filter(val => val !== undefined)));
290
156
  };
291
- export var _extractKeyValues = function (array, key) {
157
+ export const _extractKeyValues = (array, key) => {
292
158
  if (!Array.isArray(array))
293
159
  return [];
294
- return array.map(function (item) { return item[key]; }).filter(function (val) { return val !== undefined; });
160
+ return array.map(item => item[key]).filter(val => val !== undefined);
295
161
  };
296
- export var _extractNestedKeyValues = function (array, keyPath) {
162
+ export const _extractNestedKeyValues = (array, keyPath) => {
297
163
  if (!Array.isArray(array))
298
164
  return [];
299
- var keys = keyPath.split('.');
300
- return array.map(function (item) {
301
- var value = item;
302
- for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
303
- var k = keys_1[_i];
165
+ const keys = keyPath.split('.');
166
+ return array.map(item => {
167
+ let value = item;
168
+ for (const k of keys) {
304
169
  if (value === undefined)
305
170
  break;
306
171
  value = value[k];
307
172
  }
308
173
  return value;
309
- }).filter(function (val) { return val !== undefined; });
310
- };
311
- export var _mapAsync = function (arr, asyncFn) { return __awaiter(void 0, void 0, void 0, function () {
312
- var result;
313
- return __generator(this, function (_a) {
314
- switch (_a.label) {
315
- case 0: return [4 /*yield*/, Promise.all(arr.map(asyncFn))];
316
- case 1:
317
- result = _a.sent();
318
- return [2 /*return*/, result];
319
- }
320
- });
321
- }); };
322
- export var _formatDate = function (date, format) {
323
- var options = {};
174
+ }).filter(val => val !== undefined);
175
+ };
176
+ export const _mapAsync = async (arr, asyncFn) => {
177
+ const result = await Promise.all(arr.map(asyncFn));
178
+ return result;
179
+ };
180
+ export const _formatDate = (date, format) => {
181
+ const options = {};
324
182
  if (format.includes('Y'))
325
183
  options.year = 'numeric';
326
184
  if (format.includes('M'))
@@ -329,40 +187,39 @@ export var _formatDate = function (date, format) {
329
187
  options.day = 'numeric';
330
188
  return new Intl.DateTimeFormat('en-US', options).format(date);
331
189
  };
332
- export function _localeDateFormat(date, locale, options) {
333
- if (locale === void 0) { locale = 'en-IN'; }
334
- return new Intl.DateTimeFormat(locale, __assign({ year: 'numeric', month: 'short', day: 'numeric' }, options)).format(new Date(date));
190
+ export function _localeDateFormat(date, locale = 'en-IN', options) {
191
+ return new Intl.DateTimeFormat(locale, Object.assign({ year: 'numeric', month: 'short', day: 'numeric' }, options)).format(new Date(date));
335
192
  }
336
- export var _calPercentage = function (value, total) {
193
+ export const _calPercentage = (value, total) => {
337
194
  if (total === 0)
338
195
  return 0;
339
196
  return (value / total) * 100;
340
197
  };
341
- export var _sum = function (numbers) {
342
- return numbers.reduce(function (acc, num) { return acc + num; }, 0);
198
+ export const _sum = (numbers) => {
199
+ return numbers.reduce((acc, num) => acc + num, 0);
343
200
  };
344
- export var _average = function (numbers) {
345
- var total = _sum(numbers);
201
+ export const _average = (numbers) => {
202
+ const total = _sum(numbers);
346
203
  return total / numbers.length;
347
204
  };
348
- export var _getPriceAfterTax = function (price, taxRate) {
205
+ export const _getPriceAfterTax = (price, taxRate) => {
349
206
  return price * (1 + taxRate / 100);
350
207
  };
351
- export var _calculateTimeDifference = function (startDate, endDate) {
352
- var diffInMilliseconds = endDate.getTime() - startDate.getTime();
353
- var days = Math.floor(diffInMilliseconds / (1000 * 3600 * 24));
354
- var hours = Math.floor((diffInMilliseconds % (1000 * 3600 * 24)) / (1000 * 3600));
355
- var minutes = Math.floor((diffInMilliseconds % (1000 * 3600)) / (1000 * 60));
356
- var seconds = Math.floor((diffInMilliseconds % (1000 * 60)) / 1000);
357
- return "".concat(days, "d ").concat(hours, "h ").concat(minutes, "m ").concat(seconds, "s");
208
+ export const _calculateTimeDifference = (startDate, endDate) => {
209
+ const diffInMilliseconds = endDate.getTime() - startDate.getTime();
210
+ const days = Math.floor(diffInMilliseconds / (1000 * 3600 * 24));
211
+ const hours = Math.floor((diffInMilliseconds % (1000 * 3600 * 24)) / (1000 * 3600));
212
+ const minutes = Math.floor((diffInMilliseconds % (1000 * 3600)) / (1000 * 60));
213
+ const seconds = Math.floor((diffInMilliseconds % (1000 * 60)) / 1000);
214
+ return `${days}d ${hours}h ${minutes}m ${seconds}s`;
358
215
  };
359
- export var _arrayIncludesObject = function (arr, obj) {
360
- return arr.some(function (item) { return JSON.stringify(item) === JSON.stringify(obj); });
216
+ export const _arrayIncludesObject = (arr, obj) => {
217
+ return arr.some(item => JSON.stringify(item) === JSON.stringify(obj));
361
218
  };
362
- export var _toCamelCase = function (str) {
363
- return str.replace(/([-_][a-z])/g, function (group) { return group.toUpperCase().replace('-', '').replace('_', ''); });
219
+ export const _toCamelCase = (str) => {
220
+ return str.replace(/([-_][a-z])/g, group => group.toUpperCase().replace('-', '').replace('_', ''));
364
221
  };
365
- export var _freeze = function (obj) {
222
+ export const _freeze = (obj) => {
366
223
  if (typeof obj !== "object" || obj === null) {
367
224
  console.error("Error: Provided value is not a valid object.");
368
225
  return null;
@@ -373,14 +230,14 @@ export var _freeze = function (obj) {
373
230
  }
374
231
  return Object.freeze(obj);
375
232
  };
376
- export var _isFreeze = function (obj) {
233
+ export const _isFreeze = (obj) => {
377
234
  if (typeof obj !== "object" || obj === null) {
378
235
  console.error("Error: Provided value is not a valid object.");
379
236
  return false;
380
237
  }
381
238
  return Object.isFrozen(obj);
382
239
  };
383
- export var _seal = function (obj) {
240
+ export const _seal = (obj) => {
384
241
  if (typeof obj !== "object" || obj === null) {
385
242
  console.error("Error: Provided value is not a valid plain object.");
386
243
  return null;
@@ -391,22 +248,21 @@ export var _seal = function (obj) {
391
248
  }
392
249
  return Object.seal(obj);
393
250
  };
394
- export var _isSeal = function (obj) {
251
+ export const _isSeal = (obj) => {
395
252
  if (typeof obj !== "object" || obj === null) {
396
253
  console.error("Error: Provided value is not a valid object.");
397
254
  return false;
398
255
  }
399
256
  return Object.isSealed(obj);
400
257
  };
401
- export var _arrayToObject = function (arr) {
402
- var obj = {};
403
- for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
404
- var _a = arr_1[_i], key = _a[0], value = _a[1];
258
+ export const _arrayToObject = (arr) => {
259
+ const obj = {};
260
+ for (const [key, value] of arr) {
405
261
  obj[key] = value;
406
262
  }
407
263
  return obj;
408
264
  };
409
- export var _objectToArray = function (obj) {
265
+ export const _objectToArray = (obj) => {
410
266
  var result = [];
411
267
  for (var key in obj) {
412
268
  if (obj.hasOwnProperty(key)) {
@@ -415,26 +271,23 @@ export var _objectToArray = function (obj) {
415
271
  }
416
272
  return result;
417
273
  };
418
- export var _arrayToObjectByKey = function (arr, key) {
419
- return arr.reduce(function (acc, curr) {
274
+ export const _arrayToObjectByKey = (arr, key) => {
275
+ return arr.reduce((acc, curr) => {
420
276
  acc[curr[key]] = curr;
421
277
  return acc;
422
278
  }, {});
423
279
  };
424
- export var _isInArray = function (arr, value) { return arr.includes(value); };
425
- export var _getObjectValues = function (obj) { return Object.values(obj); };
426
- export var _swapArrayElements = function (arr, index1, index2) {
427
- var temp = arr[index1];
280
+ export const _isInArray = (arr, value) => arr.includes(value);
281
+ export const _getObjectValues = (obj) => Object.values(obj);
282
+ export const _swapArrayElements = (arr, index1, index2) => {
283
+ const temp = arr[index1];
428
284
  arr[index1] = arr[index2];
429
285
  arr[index2] = temp;
430
286
  };
431
- export var _filterObjectByKey = function (obj, keys) {
432
- return Object.fromEntries(Object.entries(obj).filter(function (_a) {
433
- var key = _a[0];
434
- return keys.includes(key);
435
- }));
287
+ export const _filterObjectByKey = (obj, keys) => {
288
+ return Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key)));
436
289
  };
437
- export var _getScrollPosition = function () {
290
+ export const _getScrollPosition = () => {
438
291
  if (!isWindowReady()) {
439
292
  return { scrollX: 0, scrollY: 0 };
440
293
  }
@@ -443,30 +296,29 @@ export var _getScrollPosition = function () {
443
296
  scrollY: window.scrollY,
444
297
  };
445
298
  };
446
- export var _arrayIntersection = function (arr1, arr2) {
299
+ export const _arrayIntersection = (arr1, arr2) => {
447
300
  if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
448
301
  console.error("Both parameters must be arrays.");
449
302
  return [];
450
303
  }
451
- return arr1.filter(function (item) { return arr2.includes(item); });
304
+ return arr1.filter(item => arr2.includes(item));
452
305
  };
453
- export var _getArrayOfObjectsByProperty = function (arr, key, value) {
454
- return arr.filter(function (item) { return item[key] === value; });
306
+ export const _getArrayOfObjectsByProperty = (arr, key, value) => {
307
+ return arr.filter(item => item[key] === value);
455
308
  };
456
- export var _downloadBlob = function (blob, filename) {
457
- var url = URL.createObjectURL(blob);
458
- var a = document.createElement('a');
309
+ export const _downloadBlob = (blob, filename) => {
310
+ const url = URL.createObjectURL(blob);
311
+ const a = document.createElement('a');
459
312
  a.href = url;
460
313
  a.download = filename;
461
314
  document.body.appendChild(a);
462
315
  a.click();
463
316
  document.body.removeChild(a);
464
317
  };
465
- export var _downloadFile = function (response, defaultName) {
466
- if (defaultName === void 0) { defaultName = 'downloadedFile'; }
318
+ export const _downloadFile = (response, defaultName = 'downloadedFile') => {
467
319
  try {
468
- var contentType = response.headers['content-type'];
469
- var fileName = defaultName;
320
+ const contentType = response.headers['content-type'];
321
+ let fileName = defaultName;
470
322
  if (contentType === 'application/pdf')
471
323
  fileName += '.pdf';
472
324
  else if (contentType === 'image/png')
@@ -481,16 +333,16 @@ export var _downloadFile = function (response, defaultName) {
481
333
  fileName += '.xlsx';
482
334
  else if (contentType === 'application/zip')
483
335
  fileName += '.zip';
484
- var blob = new Blob([response.data], { type: contentType });
485
- var url_1 = window.URL.createObjectURL(blob);
486
- var link_1 = document.createElement('a');
487
- link_1.href = url_1;
488
- link_1.download = fileName;
489
- document.body.appendChild(link_1);
490
- link_1.click();
491
- setTimeout(function () {
492
- window.URL.revokeObjectURL(url_1);
493
- document.body.removeChild(link_1);
336
+ const blob = new Blob([response.data], { type: contentType });
337
+ const url = window.URL.createObjectURL(blob);
338
+ const link = document.createElement('a');
339
+ link.href = url;
340
+ link.download = fileName;
341
+ document.body.appendChild(link);
342
+ link.click();
343
+ setTimeout(() => {
344
+ window.URL.revokeObjectURL(url);
345
+ document.body.removeChild(link);
494
346
  }, 100);
495
347
  }
496
348
  catch (err) {
@@ -498,40 +350,38 @@ export var _downloadFile = function (response, defaultName) {
498
350
  throw err;
499
351
  }
500
352
  };
501
- export var _fileToBase64 = function (file) {
502
- return new Promise(function (resolve, reject) {
503
- if (!file || !(file instanceof File)) {
504
- reject(new Error('No valid file provided'));
505
- return;
506
- }
507
- var reader = new FileReader();
508
- reader.onload = function () {
509
- if (typeof reader.result === 'string') {
510
- var base64String = reader.result.split(",")[1];
511
- if (base64String) {
512
- resolve(base64String);
513
- }
514
- else {
515
- reject(new Error("Failed to extract base64 data"));
516
- }
353
+ export const _fileToBase64 = (file) => new Promise((resolve, reject) => {
354
+ if (!file || !(file instanceof File)) {
355
+ reject(new Error('No valid file provided'));
356
+ return;
357
+ }
358
+ const reader = new FileReader();
359
+ reader.onload = () => {
360
+ if (typeof reader.result === 'string') {
361
+ const base64String = reader.result.split(",")[1];
362
+ if (base64String) {
363
+ resolve(base64String);
517
364
  }
518
365
  else {
519
- reject(new Error("Invalid file format"));
366
+ reject(new Error("Failed to extract base64 data"));
520
367
  }
521
- };
522
- reader.onerror = function () { return reject(new Error("Failed to read file")); };
523
- reader.readAsDataURL(file);
524
- });
525
- };
526
- export var _base64ToBlob = function (base64) {
527
- var binaryString = atob(base64.split(',')[1]);
528
- var array = [];
529
- for (var i = 0; i < binaryString.length; i++) {
368
+ }
369
+ else {
370
+ reject(new Error("Invalid file format"));
371
+ }
372
+ };
373
+ reader.onerror = () => reject(new Error("Failed to read file"));
374
+ reader.readAsDataURL(file);
375
+ });
376
+ export const _base64ToBlob = (base64) => {
377
+ const binaryString = atob(base64.split(',')[1]);
378
+ const array = [];
379
+ for (let i = 0; i < binaryString.length; i++) {
530
380
  array.push(binaryString.charCodeAt(i));
531
381
  }
532
382
  return new Blob([new Uint8Array(array)], { type: 'application/octet-stream' });
533
383
  };
534
- export var _downloadBase64File = function (base64Data, fileName) {
384
+ export const _downloadBase64File = (base64Data, fileName) => {
535
385
  var _a, _b;
536
386
  try {
537
387
  if (!base64Data || typeof base64Data !== 'string') {
@@ -540,10 +390,10 @@ export var _downloadBase64File = function (base64Data, fileName) {
540
390
  if (!fileName || typeof fileName !== 'string') {
541
391
  throw new Error('A valid file name is required.');
542
392
  }
543
- var hasPrefix = base64Data.startsWith('data:');
393
+ const hasPrefix = base64Data.startsWith('data:');
544
394
  if (!hasPrefix) {
545
- var extension = (_b = (_a = fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
546
- var mimeTypes = {
395
+ const extension = (_b = (_a = fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
396
+ const mimeTypes = {
547
397
  jpg: 'image/jpeg',
548
398
  jpeg: 'image/jpeg',
549
399
  png: 'image/png',
@@ -553,13 +403,13 @@ export var _downloadBase64File = function (base64Data, fileName) {
553
403
  xls: 'application/vnd.ms-excel',
554
404
  xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
555
405
  };
556
- var mimeType = mimeTypes[extension] || 'application/octet-stream';
557
- base64Data = "data:".concat(mimeType, ";base64,").concat(base64Data);
406
+ const mimeType = mimeTypes[extension] || 'application/octet-stream';
407
+ base64Data = `data:${mimeType};base64,${base64Data}`;
558
408
  }
559
409
  if (!base64Data.includes('base64,')) {
560
410
  throw new Error('Base64 string is missing proper format.');
561
411
  }
562
- var link = document.createElement('a');
412
+ const link = document.createElement('a');
563
413
  link.href = base64Data;
564
414
  link.download = fileName;
565
415
  document.body.appendChild(link);
@@ -570,8 +420,7 @@ export var _downloadBase64File = function (base64Data, fileName) {
570
420
  console.error('Download failed:', error.message);
571
421
  }
572
422
  };
573
- export var _uint8ArrayToBlob = function (uint8Array, mimeType) {
574
- if (mimeType === void 0) { mimeType = 'application/octet-stream'; }
423
+ export const _uint8ArrayToBlob = (uint8Array, mimeType = 'application/octet-stream') => {
575
424
  try {
576
425
  if (!(uint8Array instanceof Uint8Array)) {
577
426
  throw new Error('Invalid input: expected Uint8Array.');
@@ -583,10 +432,9 @@ export var _uint8ArrayToBlob = function (uint8Array, mimeType) {
583
432
  return new Blob([], { type: mimeType });
584
433
  }
585
434
  };
586
- export var _octetToBlob = function (data, mimeType) {
587
- if (mimeType === void 0) { mimeType = 'application/octet-stream'; }
435
+ export const _octetToBlob = (data, mimeType = 'application/octet-stream') => {
588
436
  try {
589
- var buffer = void 0;
437
+ let buffer;
590
438
  if (data instanceof Uint8Array) {
591
439
  buffer = data;
592
440
  }
@@ -606,15 +454,15 @@ export var _octetToBlob = function (data, mimeType) {
606
454
  return new Blob([], { type: mimeType });
607
455
  }
608
456
  };
609
- export var _initializeFormValues = function (fields) {
610
- return fields.reduce(function (acc, field) {
457
+ export const _initializeFormValues = (fields) => {
458
+ return fields.reduce((acc, field) => {
611
459
  acc[field] = ''; // default value
612
460
  return acc;
613
461
  }, {});
614
462
  };
615
- export var _setNestedProperty = function (obj, path, value) {
616
- var keys = path.split('.');
617
- keys.reduce(function (acc, key, idx) {
463
+ export const _setNestedProperty = (obj, path, value) => {
464
+ const keys = path.split('.');
465
+ keys.reduce((acc, key, idx) => {
618
466
  if (idx === keys.length - 1) {
619
467
  acc[key] = value;
620
468
  }
@@ -624,21 +472,21 @@ export var _setNestedProperty = function (obj, path, value) {
624
472
  return acc[key];
625
473
  }, obj);
626
474
  };
627
- export var _transformArray = function (arr, transformFn) {
475
+ export const _transformArray = (arr, transformFn) => {
628
476
  return arr.map(transformFn);
629
477
  };
630
- export var _findObjectById = function (arr, id) {
631
- return arr.find(function (item) { return item.id === id; });
478
+ export const _findObjectById = (arr, id) => {
479
+ return arr.find((item) => item.id === id);
632
480
  };
633
- export var _getUniqueValues = function (arr) {
481
+ export const _getUniqueValues = (arr) => {
634
482
  return Array.from(new Set(arr));
635
483
  };
636
- export var _mergeArraysByKey = function (arr1, arr2, key) {
637
- var map = new Map();
638
- arr1.forEach(function (item) { return map.set(item[key], item); });
639
- arr2.forEach(function (item) {
484
+ export const _mergeArraysByKey = (arr1, arr2, key) => {
485
+ const map = new Map();
486
+ arr1.forEach((item) => map.set(item[key], item));
487
+ arr2.forEach((item) => {
640
488
  if (map.has(item[key])) {
641
- map.set(item[key], __assign(__assign({}, map.get(item[key])), item));
489
+ map.set(item[key], Object.assign(Object.assign({}, map.get(item[key])), item));
642
490
  }
643
491
  else {
644
492
  map.set(item[key], item);
@@ -646,10 +494,10 @@ export var _mergeArraysByKey = function (arr1, arr2, key) {
646
494
  });
647
495
  return Array.from(map.values());
648
496
  };
649
- export var _removeDuplicates = function (arr, key) {
650
- var seen = new Set();
651
- return arr.filter(function (item) {
652
- var value = item[key];
497
+ export const _removeDuplicates = (arr, key) => {
498
+ const seen = new Set();
499
+ return arr.filter((item) => {
500
+ const value = item[key];
653
501
  if (!seen.has(value)) {
654
502
  seen.add(value);
655
503
  return true;
@@ -657,47 +505,44 @@ export var _removeDuplicates = function (arr, key) {
657
505
  return false;
658
506
  });
659
507
  };
660
- export var _groupBy = function (arr, key) {
661
- return arr.reduce(function (result, currentValue) {
508
+ export const _groupBy = (arr, key) => {
509
+ return arr.reduce((result, currentValue) => {
662
510
  (result[currentValue[key]] = result[currentValue[key]] || []).push(currentValue);
663
511
  return result;
664
512
  }, {});
665
513
  };
666
- export var _arrayDiff = function (arr1, arr2) {
667
- return arr1.filter(function (item) { return !arr2.includes(item); });
514
+ export const _arrayDiff = (arr1, arr2) => {
515
+ return arr1.filter(item => !arr2.includes(item));
668
516
  };
669
- export var _deepCompareArrays = function (arr1, arr2) {
517
+ export const _deepCompareArrays = (arr1, arr2) => {
670
518
  if (arr1.length !== arr2.length)
671
519
  return false;
672
- return arr1.every(function (item, index) { return _deepEqual(item, arr2[index]); });
520
+ return arr1.every((item, index) => _deepEqual(item, arr2[index]));
673
521
  };
674
- export var _updateObjectInArray = function (arr, key, value, update) {
675
- return arr.map(function (item) {
676
- return item[key] === value ? __assign(__assign({}, item), update) : item;
677
- });
522
+ export const _updateObjectInArray = (arr, key, value, update) => {
523
+ return arr.map((item) => item[key] === value ? Object.assign(Object.assign({}, item), update) : item);
678
524
  };
679
- export var _getKeyByValue = function (obj, value) {
525
+ export const _getKeyByValue = (obj, value) => {
680
526
  var _a;
681
527
  if (!obj || typeof obj !== 'object')
682
528
  return null;
683
- return (_a = Object.keys(obj).find(function (key) { return obj[key] === value; })) !== null && _a !== void 0 ? _a : null;
529
+ return (_a = Object.keys(obj).find(key => obj[key] === value)) !== null && _a !== void 0 ? _a : null;
684
530
  };
685
- export var _getValueByKey = function (obj, key) {
531
+ export const _getValueByKey = (obj, key) => {
686
532
  var _a;
687
533
  if (!obj || typeof obj !== 'object')
688
534
  return '';
689
535
  return (_a = obj[key]) !== null && _a !== void 0 ? _a : '';
690
536
  };
691
- export var _getKeysByValue = function (obj, value) {
537
+ export const _getKeysByValue = (obj, value) => {
692
538
  if (!obj || typeof obj !== 'object')
693
539
  return [];
694
- return Object.keys(obj).filter(function (key) { return obj[key] === value; });
540
+ return Object.keys(obj).filter(key => obj[key] === value);
695
541
  };
696
- export var _dateFormat = function (date, format) {
697
- if (format === void 0) { format = 'DD/MM/YYYY HH:mm:ss'; }
542
+ export const _dateFormat = (date, format = 'DD/MM/YYYY HH:mm:ss') => {
698
543
  return moment(date).format(format);
699
544
  };
700
- export var _dateTransformer = function (data) {
545
+ export const _dateTransformer = (data) => {
701
546
  if (data instanceof Date) {
702
547
  return _dateFormat(data, 'YYYY-MM-DDTHH:mm:ssZ');
703
548
  }
@@ -705,35 +550,31 @@ export var _dateTransformer = function (data) {
705
550
  return data.map(_dateTransformer);
706
551
  }
707
552
  if (typeof data === 'object' && data !== null) {
708
- return Object.fromEntries(Object.entries(data).map(function (_a) {
709
- var key = _a[0], value = _a[1];
710
- return [key, _dateTransformer(value)];
711
- }));
553
+ return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, _dateTransformer(value)]));
712
554
  }
713
555
  return data;
714
556
  };
715
- export var _escapeRegExpMatch = function (s) {
557
+ export const _escapeRegExpMatch = (s) => {
716
558
  return s.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
717
559
  };
718
- export var _isExactMatch = function (str, match) {
719
- return new RegExp("\\b".concat(_escapeRegExpMatch(match), "\\b")).test(str);
560
+ export const _isExactMatch = (str, match) => {
561
+ return new RegExp(`\\b${_escapeRegExpMatch(match)}\\b`).test(str);
720
562
  };
721
- export var _bytesToSize = function (bytes, decimals) {
722
- if (decimals === void 0) { decimals = 2; }
563
+ export const _bytesToSize = (bytes, decimals = 2) => {
723
564
  if (bytes === 0) {
724
565
  return '0 Bytes';
725
566
  }
726
- var k = 1024;
727
- var dm = decimals < 0 ? 0 : decimals;
728
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
729
- var i = Math.floor(Math.log(bytes) / Math.log(k));
730
- return "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]);
567
+ const k = 1024;
568
+ const dm = decimals < 0 ? 0 : decimals;
569
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
570
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
571
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
731
572
  };
732
- export var _swapArrayByKey = function (arr, key) {
733
- for (var i = 0; i < arr.length; i++) {
734
- for (var j = 0; j < arr.length - 1; j++) {
573
+ export const _swapArrayByKey = (arr, key) => {
574
+ for (let i = 0; i < arr.length; i++) {
575
+ for (let j = 0; j < arr.length - 1; j++) {
735
576
  if (arr[j][key] < arr[j + 1][key]) {
736
- var temp = arr[j];
577
+ const temp = arr[j];
737
578
  arr[j] = arr[j + 1];
738
579
  arr[j + 1] = temp;
739
580
  }
@@ -741,93 +582,68 @@ export var _swapArrayByKey = function (arr, key) {
741
582
  }
742
583
  return arr;
743
584
  };
744
- export var _setTouchedFields = function (formRef, errors) {
585
+ export const _setTouchedFields = (formRef, errors) => {
745
586
  if ((formRef === null || formRef === void 0 ? void 0 : formRef.current) && errors) {
746
- formRef.current.setTouched(Object.fromEntries(Object.keys(errors).map(function (key) { return [key, true]; })), true);
747
- }
748
- };
749
- export var _isValidForm = function (formRef) { return __awaiter(void 0, void 0, void 0, function () {
750
- var errors, isValid;
751
- return __generator(this, function (_a) {
752
- switch (_a.label) {
753
- case 0:
754
- if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current))
755
- return [2 /*return*/, false];
756
- return [4 /*yield*/, formRef.current.validateForm()];
757
- case 1:
758
- errors = _a.sent();
759
- isValid = Object.keys(errors).length === 0;
760
- if (!isValid) {
761
- formRef.current.setTouched(Object.fromEntries(Object.keys(errors).map(function (key) { return [key, true]; })), true);
762
- }
763
- return [2 /*return*/, isValid];
764
- }
765
- });
766
- }); };
767
- export var _isStepValid = function (formRef, fieldsToCheck) { return __awaiter(void 0, void 0, void 0, function () {
768
- var touchedFields, errors, stepErrors;
769
- return __generator(this, function (_a) {
770
- switch (_a.label) {
771
- case 0:
772
- if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current))
773
- return [2 /*return*/, false];
774
- touchedFields = fieldsToCheck.reduce(function (acc, field) {
775
- acc[field] = true;
776
- return acc;
777
- }, {});
778
- return [4 /*yield*/, formRef.current.setTouched(touchedFields, true)];
779
- case 1:
780
- _a.sent();
781
- return [4 /*yield*/, formRef.current.validateForm()];
782
- case 2:
783
- errors = _a.sent();
784
- stepErrors = Object.keys(errors).filter(function (key) { return fieldsToCheck.includes(key); });
785
- return [2 /*return*/, stepErrors.length === 0];
786
- }
787
- });
788
- }); };
789
- export var _validateFormRef = function (formRef) { return __awaiter(void 0, void 0, void 0, function () {
790
- var errors, isValid;
791
- return __generator(this, function (_a) {
792
- switch (_a.label) {
793
- case 0:
794
- if (!(formRef && formRef.current)) return [3 /*break*/, 2];
795
- return [4 /*yield*/, formRef.current.validateForm()];
796
- case 1:
797
- errors = _a.sent();
798
- isValid = Object.keys(errors).length === 0;
799
- return [2 /*return*/, { isValid: isValid, errors: isValid ? [] : errors }];
800
- case 2: return [2 /*return*/, { isValid: false, errors: [] }];
801
- }
802
- });
803
- }); };
804
- export var _handleParentsMenu = function (currentArr, menuID) {
587
+ formRef.current.setTouched(Object.fromEntries(Object.keys(errors).map((key) => [key, true])), true);
588
+ }
589
+ };
590
+ export const _isValidForm = async (formRef) => {
591
+ if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current))
592
+ return false;
593
+ const errors = await formRef.current.validateForm();
594
+ const isValid = Object.keys(errors).length === 0;
595
+ if (!isValid) {
596
+ formRef.current.setTouched(Object.fromEntries(Object.keys(errors).map((key) => [key, true])), true);
597
+ }
598
+ return isValid;
599
+ };
600
+ export const _isStepValid = async (formRef, fieldsToCheck) => {
601
+ if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current))
602
+ return false;
603
+ const touchedFields = fieldsToCheck.reduce((acc, field) => {
604
+ acc[field] = true;
605
+ return acc;
606
+ }, {});
607
+ await formRef.current.setTouched(touchedFields, true);
608
+ const errors = await formRef.current.validateForm();
609
+ // Check only relevant fields
610
+ const stepErrors = Object.keys(errors).filter((key) => fieldsToCheck.includes(key));
611
+ return stepErrors.length === 0;
612
+ };
613
+ export const _validateFormRef = async (formRef) => {
614
+ if (formRef && formRef.current) {
615
+ const errors = await formRef.current.validateForm();
616
+ const isValid = Object.keys(errors).length === 0;
617
+ return { isValid, errors: isValid ? [] : errors };
618
+ }
619
+ return { isValid: false, errors: [] };
620
+ };
621
+ export const _handleParentsMenu = (currentArr, menuID) => {
805
622
  if (!menuID)
806
623
  return;
807
- var parent = currentArr.find(function (item) { return item.data.menuID === menuID; });
624
+ const parent = currentArr.find((item) => item.data.menuID === menuID);
808
625
  if (!parent)
809
626
  return;
810
- var anyChildChecked = currentArr.some(function (child) { return child.data.parentMenuID === parent.data.menuID && child.data.isAssigned; });
627
+ const anyChildChecked = currentArr.some((child) => child.data.parentMenuID === parent.data.menuID && child.data.isAssigned);
811
628
  if (parent.data.isAssigned !== anyChildChecked) {
812
629
  parent.data.isAssigned = anyChildChecked;
813
- parent.data.permissions = Object.fromEntries(Object.keys(parent.data.permissions).map(function (key) { return [key, anyChildChecked]; }));
630
+ parent.data.permissions = Object.fromEntries(Object.keys(parent.data.permissions).map((key) => [key, anyChildChecked]));
814
631
  _handleParentsMenu(currentArr, parent.data.parentMenuID);
815
632
  }
816
633
  };
817
- export var _handleParentNode = function (currentArr, menuID, permissionKey) {
818
- var _a;
634
+ export const _handleParentNode = (currentArr, menuID, permissionKey) => {
819
635
  if (!menuID)
820
636
  return;
821
- var parent = currentArr.find(function (item) { return item.data.menuID === menuID; });
637
+ const parent = currentArr.find((item) => item.data.menuID === menuID);
822
638
  if (!parent)
823
639
  return;
824
- var childPermissions = currentArr
825
- .filter(function (child) { return child.data.parentMenuID === parent.data.menuID; })
826
- .flatMap(function (child) { return Object.values(child.data.permissions); });
827
- var anyChildHasPermission = childPermissions.some(Boolean);
828
- var anyChildHasSpecificPermission = currentArr.some(function (child) { return child.data.parentMenuID === parent.data.menuID && Boolean(child.data.permissions[permissionKey]); });
829
- var updatedPermissions = __assign(__assign({}, parent.data.permissions), (_a = {}, _a[permissionKey] = anyChildHasSpecificPermission, _a));
830
- var readPermissionKey = Object.keys(updatedPermissions).find(function (key) { return key.toLowerCase().includes('read'); });
640
+ const childPermissions = currentArr
641
+ .filter((child) => child.data.parentMenuID === parent.data.menuID)
642
+ .flatMap((child) => Object.values(child.data.permissions));
643
+ const anyChildHasPermission = childPermissions.some(Boolean);
644
+ const anyChildHasSpecificPermission = currentArr.some((child) => child.data.parentMenuID === parent.data.menuID && Boolean(child.data.permissions[permissionKey]));
645
+ let updatedPermissions = Object.assign(Object.assign({}, parent.data.permissions), { [permissionKey]: anyChildHasSpecificPermission });
646
+ const readPermissionKey = Object.keys(updatedPermissions).find((key) => key.toLowerCase().includes('read'));
831
647
  if (readPermissionKey) {
832
648
  updatedPermissions[readPermissionKey] = anyChildHasPermission;
833
649
  }
@@ -835,39 +651,32 @@ export var _handleParentNode = function (currentArr, menuID, permissionKey) {
835
651
  parent.data.isAssigned = anyChildHasPermission;
836
652
  _handleParentNode(currentArr, parent.data.parentMenuID, permissionKey);
837
653
  };
838
- export var _handleChildrenMenu = function (currentArr, parentKey, checked) {
839
- currentArr.forEach(function (ele) {
654
+ export const _handleChildrenMenu = (currentArr, parentKey, checked) => {
655
+ currentArr.forEach((ele) => {
840
656
  if (ele.data.parentMenuID === parentKey && ele.data.isAssigned !== checked) {
841
657
  ele.data.isAssigned = checked;
842
- ele.data.permissions = Object.fromEntries(Object.keys(ele.data.permissions).map(function (key) { return [key, checked]; }));
658
+ ele.data.permissions = Object.fromEntries(Object.keys(ele.data.permissions).map((key) => [key, checked]));
843
659
  _handleChildrenMenu(currentArr, ele.data.menuID, checked);
844
660
  }
845
661
  });
846
662
  };
847
- export var _handlePermissions = function (currentArr, currentObj, permissionKey, isChecked) {
848
- return currentArr.map(function (obj) {
849
- var _a;
663
+ export const _handlePermissions = (currentArr, currentObj, permissionKey, isChecked) => {
664
+ return currentArr.map((obj) => {
850
665
  if (obj.data.menuID === currentObj.data.menuID) {
851
- var updatedPermissions = __assign(__assign({}, obj.data.permissions), (_a = {}, _a[permissionKey] = isChecked, _a));
852
- var readPermissionKey_1 = Object.keys(updatedPermissions).find(function (key) { return key.toLowerCase().includes('read'); });
853
- if (readPermissionKey_1) {
666
+ let updatedPermissions = Object.assign(Object.assign({}, obj.data.permissions), { [permissionKey]: isChecked });
667
+ const readPermissionKey = Object.keys(updatedPermissions).find((key) => key.toLowerCase().includes('read'));
668
+ if (readPermissionKey) {
854
669
  if (isChecked) {
855
- updatedPermissions[readPermissionKey_1] = true;
670
+ updatedPermissions[readPermissionKey] = true;
856
671
  }
857
672
  else {
858
- var otherPermissionsChecked = Object.entries(updatedPermissions)
859
- .filter(function (_a) {
860
- var key = _a[0];
861
- return key !== readPermissionKey_1;
862
- })
863
- .some(function (_a) {
864
- var value = _a[1];
865
- return value;
866
- });
867
- updatedPermissions[readPermissionKey_1] = otherPermissionsChecked;
673
+ const otherPermissionsChecked = Object.entries(updatedPermissions)
674
+ .filter(([key]) => key !== readPermissionKey)
675
+ .some(([, value]) => value);
676
+ updatedPermissions[readPermissionKey] = otherPermissionsChecked;
868
677
  }
869
678
  }
870
- return __assign(__assign({}, obj), { data: __assign(__assign({}, obj.data), { permissions: updatedPermissions, isAssigned: Object.values(updatedPermissions).some(Boolean) }) });
679
+ return Object.assign(Object.assign({}, obj), { data: Object.assign(Object.assign({}, obj.data), { permissions: updatedPermissions, isAssigned: Object.values(updatedPermissions).some(Boolean) }) });
871
680
  }
872
681
  return obj;
873
682
  });