intelicoreact 2.0.16 → 2.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/css/accordion.css +1 -1
  2. package/dist/css/advanced-status.css +1 -1
  3. package/dist/css/datepicker.css +1 -1
  4. package/dist/css/dropdown-live-search.css +1 -1
  5. package/dist/css/dropdown.css +1 -1
  6. package/dist/css/input-date-range.css +1 -1
  7. package/dist/css/main-menu.css +1 -1
  8. package/dist/css/switcher-radio.css +1 -1
  9. package/dist/css/switcher-range-list.css +1 -1
  10. package/dist/css/switcher-tags-dropdown.css +1 -1
  11. package/dist/css/switcher-textarea.css +1 -1
  12. package/dist/css/table.css +1 -1
  13. package/dist/css/tags-dropdown.css +1 -1
  14. package/dist/css/wizard-stepper.css +1 -1
  15. package/dist/es/_virtual/_rolldown/runtime.js +27 -0
  16. package/dist/es/charts.js +4 -0
  17. package/dist/es/classes.js +4 -0
  18. package/dist/es/form.js +99 -0
  19. package/dist/es/hooks.js +32 -0
  20. package/dist/es/icons.js +10 -0
  21. package/dist/es/icons.js.map +1 -0
  22. package/dist/es/index.js +71 -0
  23. package/dist/es/layout.js +3 -0
  24. package/dist/es/presets.js +6 -0
  25. package/dist/es/router-ui.js +8 -0
  26. package/dist/es/sdk.js +1 -0
  27. package/dist/es/styles/base.css +1 -0
  28. package/dist/es/types/index.js +2 -0
  29. package/dist/es/ui.js +42 -0
  30. package/dist/es/utils.js +6 -0
  31. package/dist/intelicoreact.css +1 -1
  32. package/dist/scss/_mixins.scss +2 -2
  33. package/dist/scss/_vars.scss +1 -1
  34. package/dist/scss/main.scss +4 -1
  35. package/package.json +47 -64
  36. package/charts/package.json +0 -5
  37. package/classes/package.json +0 -5
  38. package/dist/charts.cjs +0 -927
  39. package/dist/charts.cjs.map +0 -7
  40. package/dist/charts.js +0 -911
  41. package/dist/charts.js.map +0 -7
  42. package/dist/classes.cjs +0 -1858
  43. package/dist/classes.cjs.map +0 -7
  44. package/dist/classes.js +0 -1836
  45. package/dist/classes.js.map +0 -7
  46. package/dist/form.cjs +0 -15167
  47. package/dist/form.cjs.map +0 -7
  48. package/dist/form.js +0 -15182
  49. package/dist/form.js.map +0 -7
  50. package/dist/hooks.cjs +0 -2330
  51. package/dist/hooks.cjs.map +0 -7
  52. package/dist/hooks.js +0 -2298
  53. package/dist/hooks.js.map +0 -7
  54. package/dist/icons.cjs +0 -1807
  55. package/dist/icons.cjs.map +0 -7
  56. package/dist/icons.js +0 -1785
  57. package/dist/icons.js.map +0 -7
  58. package/dist/index.cjs +0 -22917
  59. package/dist/index.cjs.map +0 -7
  60. package/dist/index.js +0 -22938
  61. package/dist/index.js.map +0 -7
  62. package/dist/layout.cjs +0 -458
  63. package/dist/layout.cjs.map +0 -7
  64. package/dist/layout.js +0 -426
  65. package/dist/layout.js.map +0 -7
  66. package/dist/presets.cjs +0 -262
  67. package/dist/presets.cjs.map +0 -7
  68. package/dist/presets.js +0 -240
  69. package/dist/presets.js.map +0 -7
  70. package/dist/router-ui.cjs +0 -989
  71. package/dist/router-ui.cjs.map +0 -7
  72. package/dist/router-ui.js +0 -957
  73. package/dist/router-ui.js.map +0 -7
  74. package/dist/sdk.cjs +0 -451
  75. package/dist/sdk.cjs.map +0 -7
  76. package/dist/sdk.js +0 -429
  77. package/dist/sdk.js.map +0 -7
  78. package/dist/types/index.cjs +0 -18
  79. package/dist/types/index.cjs.map +0 -7
  80. package/dist/types/index.js +0 -1
  81. package/dist/types/index.js.map +0 -7
  82. package/dist/ui.cjs +0 -4090
  83. package/dist/ui.cjs.map +0 -7
  84. package/dist/ui.js +0 -4064
  85. package/dist/ui.js.map +0 -7
  86. package/dist/utils.cjs +0 -653
  87. package/dist/utils.cjs.map +0 -7
  88. package/dist/utils.js +0 -621
  89. package/dist/utils.js.map +0 -7
  90. package/form/package.json +0 -5
  91. package/hooks/package.json +0 -5
  92. package/icons/package.json +0 -5
  93. package/layout/package.json +0 -5
  94. package/presets/package.json +0 -5
  95. package/router-ui/package.json +0 -5
  96. package/sdk/package.json +0 -5
  97. package/types/package.json +0 -5
  98. package/ui/package.json +0 -5
  99. package/utils/package.json +0 -5
package/dist/utils.cjs DELETED
@@ -1,653 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/utils.ts
30
- var utils_exports = {};
31
- __export(utils_exports, {
32
- addBitDepthPoints: () => addBitDepthPoints,
33
- assertions: () => assertions_default,
34
- capitalized: () => capitalized,
35
- changeMeta: () => changeMeta,
36
- checkedRef: () => checkedRef,
37
- clone: () => clone,
38
- compare: () => compare,
39
- compareAlphabetical: () => compareAlphabetical,
40
- debounce: () => debounce,
41
- downloadEmulation: () => downloadEmulation,
42
- downloadFile: () => downloadFile,
43
- firstLetterCapital: () => firstLetterCapital,
44
- getBase64: () => getBase64,
45
- getColorById: () => getColorById,
46
- getCorrectTestId: () => getCorrectTestId,
47
- getIsOnlyAnObject: () => getIsOnlyAnObject,
48
- getOS: () => getOS,
49
- getResponseClone: () => getResponseClone,
50
- getStyles: () => getStyles,
51
- getUniqueFileExtensions: () => getUniqueFileExtensions,
52
- handleObjectChange: () => handleObjectChange,
53
- logout: () => logout,
54
- omitKeys: () => omitKeys,
55
- renderFileSize: () => renderFileSize,
56
- safeValue: () => safeValue_default,
57
- setCarretToEnd: () => setCarretToEnd,
58
- throttle: () => throttle,
59
- transformDateOrTimeOrTogetherToFormat: () => transformDateOrTimeOrTogetherToFormat,
60
- transformDateOrTimeOrTogetherToFormattedLocal: () => transformDateOrTimeOrTogetherToFormattedLocal,
61
- transformLocalTimeToUTC: () => transformLocalTimeToUTC,
62
- transformUTCHoursToLocal: () => transformUTCHoursToLocal,
63
- transformUTCTimeToLocal: () => transformUTCTimeToLocal,
64
- typesGuards: () => typeGuards_default,
65
- useOutsideToggle: () => useOutsideToggle,
66
- uuid: () => uuid
67
- });
68
- module.exports = __toCommonJS(utils_exports);
69
-
70
- // src/Functions/guards/typeGuards.ts
71
- var isArray = (value) => Array.isArray(value);
72
- function isObject(value) {
73
- return typeof value === "object" && value !== null && !isArray(value);
74
- }
75
- var isNumber = (value) => typeof value === "number";
76
- var isString = (value) => typeof value === "string";
77
- var isBoolean = (value) => typeof value === "boolean";
78
- var isFunction = (value) => typeof value === "function";
79
- var isInstanceOf = (value, classType) => value instanceof classType;
80
- function isEnumValue(enumObject, value) {
81
- return Object.values(enumObject).includes(value);
82
- }
83
- function isNullOrUndefined(value) {
84
- return value === null || value === void 0;
85
- }
86
- var isTruthy = (value) => !!value;
87
- var isEmptyObject = (value) => isObject(value) && Object.keys(value).length === 0;
88
- function isTypedArray(value, type) {
89
- return isArray(value) && value.every((item) => item instanceof type);
90
- }
91
- function isArrayWithLength(value, length) {
92
- return isArray(value) && value.length === length;
93
- }
94
- var isEmptyArray = (value) => Array.isArray(value) && value.length === 0;
95
- function isTypeOrNull(value, type) {
96
- return value === null || value instanceof type;
97
- }
98
- var nonNullable = (value) => value !== null && value !== void 0;
99
- var isDate = (value) => value instanceof Date;
100
- var isPromise = (value) => value instanceof Promise;
101
- var isRegExp = (value) => value instanceof RegExp;
102
- function isPrimitive(value) {
103
- return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
104
- }
105
- var isError = (value) => value instanceof Error;
106
- var isSymbol = (value) => typeof value === "symbol";
107
- var isMap = (value) => value instanceof Map;
108
- var isSet = (value) => value instanceof Set;
109
- function isReactElement(value) {
110
- return isObject(value) && "type" in value && "props" in value && "$$typeof" in value;
111
- }
112
- function isReactComponent(value) {
113
- return isFunction(value) || isObject(value) && "render" in value;
114
- }
115
- function isComponentType(value, componentType) {
116
- return isReactElement(value) && value.type === componentType;
117
- }
118
- function isReactEvent(value) {
119
- return isObject(value) && "nativeEvent" in value && "currentTarget" in value && "target" in value;
120
- }
121
- function isRef(value) {
122
- return isObject(value) && "current" in value;
123
- }
124
- function isContext(value) {
125
- return isObject(value) && "Provider" in value && "Consumer" in value;
126
- }
127
- function isType(value) {
128
- const type = typeof value;
129
- return type === "string" || type === "number" || type === "boolean" || type === "object" || type === "function" || type === "undefined" || type === "symbol" || type === "bigint";
130
- }
131
- var typesGuards = {
132
- isArray,
133
- isObject,
134
- isNumber,
135
- isString,
136
- isBoolean,
137
- isFunction,
138
- isInstanceOf,
139
- isEnumValue,
140
- isNullOrUndefined,
141
- isTruthy,
142
- isEmptyObject,
143
- isEmptyArray,
144
- isTypedArray,
145
- isArrayWithLength,
146
- isTypeOrNull,
147
- nonNullable,
148
- isDate,
149
- isPromise,
150
- isRegExp,
151
- isPrimitive,
152
- isError,
153
- isSymbol,
154
- isMap,
155
- isSet,
156
- isReactElement,
157
- isReactComponent,
158
- isComponentType,
159
- isReactEvent,
160
- isRef,
161
- isContext,
162
- isType
163
- };
164
- var typeGuards_default = typesGuards;
165
-
166
- // src/Functions/guards/assertions.ts
167
- function assertArray(value, message) {
168
- if (!Array.isArray(value)) {
169
- throw new TypeError(message || "Expected value to be an array");
170
- }
171
- }
172
- function assertObject(value, message) {
173
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
174
- throw new TypeError(message || "Expected value to be an object");
175
- }
176
- }
177
- function assertNumber(value, message) {
178
- if (typeof value !== "number") {
179
- throw new TypeError(message || "Expected value to be a number");
180
- }
181
- }
182
- function assertString(value, message) {
183
- if (typeof value !== "string") {
184
- throw new TypeError(message || "Expected value to be a string");
185
- }
186
- }
187
- function assertBoolean(value, message) {
188
- if (typeof value !== "boolean") {
189
- throw new TypeError(message || "Expected value to be a boolean");
190
- }
191
- }
192
- function assertFunction(value, message) {
193
- if (typeof value !== "function") {
194
- throw new TypeError(message || "Expected value to be a function");
195
- }
196
- }
197
- function assertInstanceOf(value, classType, message) {
198
- if (!(value instanceof classType)) {
199
- throw new TypeError(message || `Expected value to be an instance of ${classType.name}`);
200
- }
201
- }
202
- function assertEnumValue(enumObject, value, message) {
203
- if (!Object.values(enumObject).includes(value)) {
204
- throw new TypeError(
205
- message || `Expected value to be one of: ${Object.values(enumObject).join(", ")}`
206
- );
207
- }
208
- }
209
- function assertReactElement(value, message) {
210
- if (!(typeGuards_default.isObject(value) && "type" in value && "props" in value && "$$typeof" in value)) {
211
- throw new TypeError(message || "Expected value to be a React element");
212
- }
213
- }
214
- function assertReactComponent(value, message) {
215
- if (!(typeof value === "function" || typeGuards_default.isObject(value) && "render" in value)) {
216
- throw new TypeError(message || "Expected value to be a React component");
217
- }
218
- }
219
- function assertNonNullable(value, message) {
220
- if (value === null || value === void 0) {
221
- throw new TypeError(message || "Expected value to be non-nullable");
222
- }
223
- }
224
- function assertTruthy(value, message) {
225
- if (!value) {
226
- throw new TypeError(message || "Expected value to be truthy");
227
- }
228
- }
229
- function assertFalsy(value, message) {
230
- if (value) {
231
- throw new TypeError(message || "Expected value to be falsy");
232
- }
233
- }
234
- function assertDefined(value, message) {
235
- if (value === void 0) {
236
- throw new TypeError(message || "Expected value to be defined");
237
- }
238
- }
239
- function assertNotEmptyString(value, message) {
240
- if (value === "") {
241
- throw new TypeError(message || "Expected string to be not empty");
242
- }
243
- }
244
- function assertPositiveNumber(value, message) {
245
- if (value <= 0) {
246
- throw new TypeError(message || "Expected number to be positive");
247
- }
248
- }
249
- function assertNegativeNumber(value, message) {
250
- if (value >= 0) {
251
- throw new TypeError(message || "Expected number to be negative");
252
- }
253
- }
254
- function assertArrayNotEmpty(value, message) {
255
- if (value.length === 0) {
256
- throw new TypeError(message || "Expected array to be not empty");
257
- }
258
- }
259
- var assertions = {
260
- assertArray,
261
- assertObject,
262
- assertNumber,
263
- assertString,
264
- assertBoolean,
265
- assertFunction,
266
- assertInstanceOf,
267
- assertEnumValue,
268
- assertReactElement,
269
- assertReactComponent,
270
- assertNonNullable,
271
- assertTruthy,
272
- assertFalsy,
273
- assertDefined,
274
- assertNotEmptyString,
275
- assertPositiveNumber,
276
- assertNegativeNumber,
277
- assertArrayNotEmpty
278
- };
279
- var assertions_default = assertions;
280
-
281
- // src/Functions/utils.js
282
- var import_react = require("react");
283
- var import_moment_timezone = __toESM(require("moment-timezone"), 1);
284
-
285
- // src/Constants/index.constants.js
286
- var DEFAULT_COLORS = [
287
- "#D9C1FF",
288
- "#FFBAF0",
289
- "#FFB8CE",
290
- "#FFC3A2",
291
- "#FFDB7C",
292
- "#F9F871",
293
- "#C3FCF1",
294
- "#F6F2CB",
295
- "#E0F8D1",
296
- "#B1DFFB",
297
- "#8DECFE",
298
- "#76F7ED",
299
- "#8AFEC8"
300
- ];
301
- var OS = {
302
- iOS: "iOS",
303
- Android: "Android",
304
- WP: "Windows Phone",
305
- Linux: "Linux",
306
- Windows: "Windows",
307
- MacOS: "MacOS",
308
- Unknown: "unknown"
309
- };
310
-
311
- // src/Functions/utils.js
312
- var uuid = () => Date.now().toString(36) + Math.random().toString(36).substring(2);
313
- var getIsOnlyAnObject = (input) => {
314
- return typeof input === "object" && // "отбивает" примитивы и функции
315
- input instanceof Object && // "отбивает" null
316
- !Array.isArray(input) && // "отбивает" массивы
317
- !(input instanceof Set) && // "отбивает" сеты
318
- !(input instanceof Map);
319
- };
320
- var handleObjectChange = (updateObject, updateFunction) => (data, prop = "", isNumber2) => {
321
- let value;
322
- if (data?.target) {
323
- value = data.target.type === "checkbox" ? data.target.checked : data.target.value;
324
- } else value = data;
325
- value = isNumber2 ? Number(value) : value;
326
- const props = prop.split(".");
327
- const currentObject = props.reduce((res, chapter, index) => {
328
- if (props.length !== index + 1) res = res[chapter];
329
- return res;
330
- }, updateObject);
331
- currentObject[props.pop()] = value;
332
- updateFunction();
333
- };
334
- var useOutsideToggle = (ref, setOut, open) => {
335
- function handleClickOutside(event) {
336
- if (ref.current && !ref.current.contains(event.target)) {
337
- setOut(open);
338
- }
339
- }
340
- (0, import_react.useEffect)(() => {
341
- document.addEventListener("mouseup", handleClickOutside);
342
- return () => {
343
- document.removeEventListener("mouseup", handleClickOutside);
344
- };
345
- }, [ref]);
346
- };
347
- var clone = (input) => {
348
- if (input === null || typeof input !== "object") return input;
349
- const data = input instanceof Array ? [] : {};
350
- for (const i in input) data[i] = clone(input[i]);
351
- return data;
352
- };
353
- var getResponseClone = async (res) => await (typeof res?.clone === "function" ? res.clone() : clone(res));
354
- function transformUTCTimeToLocal(date, format = "YYYY-MM-DD HH:mm:ss") {
355
- if (!date) return;
356
- const utcDate = import_moment_timezone.default.utc(date).toDate();
357
- return (0, import_moment_timezone.default)(utcDate, format).local().format(format);
358
- }
359
- function transformLocalTimeToUTC(date, format = "YYYY-MM-DD HH:mm:ss") {
360
- if (!date) return;
361
- return (0, import_moment_timezone.default)(date, format).utc().format(format);
362
- }
363
- function transformUTCHoursToLocal(time, format = "HH:mm:ss") {
364
- if (!time) return;
365
- const splitedTime = time.split(":");
366
- const offset = (0, import_moment_timezone.default)().utcOffset();
367
- let HH = Number(splitedTime[0]);
368
- let mm = Number(splitedTime[1]);
369
- const ss = splitedTime[2];
370
- mm = mm + offset;
371
- while (mm > 59) {
372
- mm -= 60;
373
- HH += 1;
374
- }
375
- if (HH > 23) HH -= 24;
376
- while (mm < 0) {
377
- mm += 60;
378
- HH -= 1;
379
- }
380
- if (HH < 0) HH += 24;
381
- return `${HH}:${mm}:${ss}`;
382
- }
383
- function transformDateOrTimeOrTogetherToFormat(data, outputFormat = "HH:mm", additional) {
384
- const ERROR_VALUE = "Invalid date";
385
- const ERROR_MESSGE = `Invalid input data for ${outputFormat} format`;
386
- const { parseFormat, isReturnAsMomentInstance } = getIsOnlyAnObject(
387
- additional
388
- ) ? additional : {};
389
- if (typeof data !== "string" && typeof data !== "number") {
390
- return isReturnAsMomentInstance ? (0, import_moment_timezone.default)("error") : ERROR_MESSGE;
391
- }
392
- const momentArgs = [
393
- data,
394
- ...!Number.isNaN(Number(data)) || typeof parseFormat === "string" ? [] : [parseFormat]
395
- ];
396
- const momentInstance = (() => {
397
- let instance = (0, import_moment_timezone.default)(...momentArgs);
398
- if (instance.format(outputFormat) !== ERROR_VALUE) return instance;
399
- else if (/^\d\d.\d\d/.test(data)) {
400
- instance = (0, import_moment_timezone.default)();
401
- const symbols = data.split("");
402
- const timeArr = symbols.reduce(
403
- (acc, symbol, idx) => {
404
- if (Number.isNaN(Number(symbol))) {
405
- if (acc.group) acc.result.push(acc.group);
406
- acc.group = "";
407
- } else acc.group = `${acc.group}${symbol}`;
408
- if (idx === symbols.length - 1 && acc.group)
409
- acc.result.push(acc.group);
410
- return acc;
411
- },
412
- { result: [], group: "" }
413
- ).result.reverse();
414
- instance.hours(Number(timeArr.pop()));
415
- instance.minutes(Number(timeArr.pop()));
416
- instance.seconds(timeArr.length ? Number(timeArr.pop()) : 0);
417
- instance.milliseconds(timeArr.length ? Number(timeArr.pop()) : 0);
418
- } else instance = (0, import_moment_timezone.default)("error");
419
- return instance;
420
- })();
421
- if (isReturnAsMomentInstance) return momentInstance;
422
- const output = momentInstance.format(outputFormat);
423
- return output === ERROR_VALUE ? ERROR_MESSGE : output;
424
- }
425
- function transformDateOrTimeOrTogetherToFormattedLocal(data, outputFormat = "HH:mm", additional) {
426
- const ERROR_VALUE = "Invalid date";
427
- const ERROR_MESSGE = `Invalid input data for ${outputFormat} format`;
428
- if (additional && !getIsOnlyAnObject(additional)) {
429
- throw new Error(
430
- "Bad additional [transformDateOrTimeOrTogetherToFormattedLocal]"
431
- );
432
- }
433
- const compositeAdditional = {
434
- ...additional || {},
435
- isReturnAsMomentInstance: true
436
- };
437
- const date = transformDateOrTimeOrTogetherToFormat(
438
- data,
439
- outputFormat,
440
- compositeAdditional
441
- );
442
- const dateWithLocale = date.add((0, import_moment_timezone.default)().utcOffset(), "minutes");
443
- const output = dateWithLocale.format(outputFormat);
444
- return output === ERROR_VALUE ? ERROR_MESSGE : output;
445
- }
446
- var omitKeys = (obj = {}, keys = []) => keys.reduce((acc, key) => {
447
- const { [key]: omit, ...rest } = acc;
448
- return rest;
449
- }, obj);
450
- var logout = () => {
451
- window.localStorage.removeItem("accessToken");
452
- window.localStorage.removeItem("tokenExpires");
453
- window.location.reload();
454
- };
455
- var getStyles = (el, prop) => {
456
- if (!el) return null;
457
- if (!prop) return window.getComputedStyle(el);
458
- return window.getComputedStyle(el).getPropertyValue(prop);
459
- };
460
- var getColorById = (id, colors) => {
461
- if (!id) return "#FF7D00";
462
- const idToArr = Array.from(id);
463
- const colorsArr = colors && colors.length > 0 ? colors : DEFAULT_COLORS;
464
- let number = idToArr.reduce((acc, item) => {
465
- if (Number(item)) {
466
- return acc + Number(item);
467
- }
468
- return acc;
469
- }, 0);
470
- while (number >= colorsArr.length) {
471
- number -= colorsArr.length;
472
- }
473
- return colorsArr[number];
474
- };
475
- var debounce = (fn, ms) => {
476
- let id = null;
477
- return (...args) => {
478
- clearTimeout(id);
479
- id = setTimeout(() => {
480
- clearTimeout(id);
481
- fn(...args);
482
- }, ms);
483
- };
484
- };
485
- var throttle = (fn, ms) => {
486
- let id = null;
487
- return (...args) => {
488
- if (id) return;
489
- fn(...args);
490
- id = setTimeout(() => {
491
- clearTimeout(id);
492
- id = null;
493
- }, ms);
494
- };
495
- };
496
- var addBitDepthPoints = (value, step = 3) => {
497
- const isFraction = value?.includes(".");
498
- const valueBeforeDot = isFraction ? value?.slice(0, value?.indexOf(".")) : value;
499
- const intPart = valueBeforeDot.split("").reverse().reduce(
500
- (acc, item, idx) => idx % step === 0 && idx !== 0 ? [...acc, ",", item] : [...acc, item],
501
- []
502
- ).reverse().join("");
503
- return isFraction ? intPart + value?.slice(value?.indexOf(".")) : intPart;
504
- };
505
- var changeMeta = (key, items = []) => {
506
- const defaultMeta = items.find((i) => i.key === "default");
507
- if (key) {
508
- const item = items.find((i) => i.key === key);
509
- document.title = item?.title ?? defaultMeta?.title;
510
- document.querySelector('meta[name="description"]').setAttribute("content", item?.description ?? defaultMeta?.description);
511
- }
512
- };
513
- var firstLetterCapital = (str) => typeof str === "string" ? `${str.charAt(0).toUpperCase()}${str.slice(1)}` : str;
514
- var capitalized = firstLetterCapital;
515
- var checkedRef = (ref) => ref ? typeof ref === "function" ? (node) => ref(node) : ref : null;
516
- function downloadEmulation(data, filename, type = "image/*") {
517
- const file = new Blob([data], { type });
518
- if (window.navigator.msSaveOrOpenBlob)
519
- window.navigator.msSaveOrOpenBlob(file, filename);
520
- else {
521
- const a = document.createElement("a"), url = URL.createObjectURL(file);
522
- a.href = url;
523
- a.download = filename;
524
- document.body.appendChild(a);
525
- a.click();
526
- setTimeout(() => {
527
- document.body.removeChild(a);
528
- window.URL.revokeObjectURL(url);
529
- }, 0);
530
- }
531
- }
532
- var downloadFile = async ({ url, name, type = null }) => {
533
- const response = await fetch(url).then(async (res) => ({
534
- data: await res.blob(),
535
- type: type ?? res.headers.get("content-type")
536
- }));
537
- downloadEmulation(response.data, name, response.type);
538
- };
539
- var compare = (first, second, keys = []) => {
540
- if (typeof first !== typeof second) return false;
541
- if (Array.isArray(first) !== Array.isArray(second)) return false;
542
- if (!(first instanceof Object)) return first === second;
543
- const getComparationStructure = (data) => {
544
- if (typeof data === "function") return data.toString();
545
- if (!(data instanceof Object)) return data;
546
- return Object.entries(data).sort((a, b) => a[0].localeCompare(b[0])).map(([key, value]) => [key, getComparationStructure(data[key])]);
547
- };
548
- const structureForComparingOfFirst = getComparationStructure(first);
549
- const structureForComparingOfSecond = getComparationStructure(second);
550
- return JSON.stringify(structureForComparingOfFirst) === JSON.stringify(structureForComparingOfSecond);
551
- };
552
- var setCarretToEnd = (input) => {
553
- setTimeout(() => {
554
- const tmp = input.value;
555
- input.value = "";
556
- input.value = tmp;
557
- }, 10);
558
- };
559
- var compareAlphabetical = (a, b, key = "label") => {
560
- let item1 = a?.[key];
561
- let item2 = b?.[key];
562
- if (typeof item1 !== "string" || typeof item2 !== "string") return 0;
563
- item1 = item1?.toLowerCase();
564
- item2 = item2?.toLowerCase();
565
- if (item1 < item2) {
566
- return -1;
567
- }
568
- if (item1 > item2) {
569
- return 1;
570
- }
571
- return 0;
572
- };
573
- var getBase64 = (file) => {
574
- if (file) {
575
- return new Promise(function(resolve, reject) {
576
- const reader = new FileReader();
577
- reader.readAsDataURL(file);
578
- reader.onload = () => resolve(reader.result);
579
- reader.onerror = (error) => reject("Error: ", error);
580
- });
581
- }
582
- };
583
- var renderFileSize = (bytes, decimals = 2) => {
584
- if (!Number(bytes)) return "0 Bytes";
585
- const k = 1024;
586
- const dm = decimals < 0 ? 0 : decimals;
587
- const sizes = ["Bytes", "KB", "MB", "GB"];
588
- const i = Math.floor(Math.log(bytes) / Math.log(k));
589
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
590
- };
591
- var getUniqueFileExtensions = (extListString) => {
592
- const extArray = extListString?.split(",").map((ext) => ext.trim().toUpperCase());
593
- const uniqueExts = [...new Set(extArray)];
594
- return uniqueExts.join(", ");
595
- };
596
- var getOS = () => {
597
- let userAgent = window.navigator.userAgent, platform = window.navigator?.userAgentData?.platform || window.navigator.platform, macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"], windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"], iosPlatforms = ["iPhone", "iPad", "iPod"], os = OS.Unknown;
598
- if (macosPlatforms.indexOf(platform) !== -1) {
599
- os = OS.MacOS;
600
- } else if (iosPlatforms.indexOf(platform) !== -1) {
601
- os = OS.iOS;
602
- } else if (windowsPlatforms.indexOf(platform) !== -1) {
603
- os = OS.Windows;
604
- } else if (/Android/.test(userAgent)) {
605
- os = OS.Android;
606
- } else if (/Linux/.test(platform)) {
607
- os = OS.Linux;
608
- }
609
- return os;
610
- };
611
- String.prototype.longerThan = function(compareWith) {
612
- return this?.length > compareWith?.length;
613
- };
614
- String.prototype.lastIndexEqualsTo = function(index) {
615
- return this?.length - 1 === index;
616
- };
617
- var getCorrectTestId = ({ testId = "", withTier = true }) => testId && testId !== void 0 ? `${withTier ? "-" : ""}${testId}` : "";
618
-
619
- // src/Functions/guards/safeValue.ts
620
- function stringValue(value) {
621
- if (typeof value === "string" && value !== "") return value;
622
- return "";
623
- }
624
- function objectValue(value) {
625
- if (typeof value === "object" && value !== null && Object.keys(value).length > 0) {
626
- return clone(value);
627
- }
628
- return {};
629
- }
630
- function numberValue(value) {
631
- if (!Number.isNaN(value) && typeof value === "number") return value;
632
- return 0;
633
- }
634
- var arrayValue = (value) => Array.isArray(value) ? clone(value) : [];
635
- function booleanValue(value) {
636
- if (typeGuards_default.isBoolean(value)) {
637
- return value;
638
- }
639
- return false;
640
- }
641
- function notNullValue(value, defaultValue) {
642
- return value !== null && value !== void 0 ? value : defaultValue;
643
- }
644
- var safeValue = {
645
- booleanValue,
646
- stringValue,
647
- objectValue,
648
- numberValue,
649
- arrayValue,
650
- notNullValue
651
- };
652
- var safeValue_default = safeValue;
653
- //# sourceMappingURL=utils.cjs.map