@ssa-ui-kit/utils 2.32.0-canary-d213a33-20251219 → 2.32.0-canary-f90c17a-20251231

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/utils",
3
- "version": "2.32.0-canary-d213a33-20251219",
3
+ "version": "2.32.0-canary-f90c17a-20251231",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -21,13 +21,16 @@
21
21
  "files": [
22
22
  "dist"
23
23
  ],
24
+ "devDependencies": {
25
+ "@types/sass": "1.45.0"
26
+ },
24
27
  "browserslist": [
25
28
  ">0.1%",
26
29
  "not dead",
27
30
  "not op_mini all"
28
31
  ],
29
32
  "scripts": {
30
- "build": "webpack --mode=production --node-env=production && tsc --build --force ./tsconfig.build.json && resolve-tspaths -p ./tsconfig.build.json",
33
+ "build": "tsc --build --force ./tsconfig.build.json && resolve-tspaths -p ./tsconfig.build.json",
31
34
  "ts-show-config": "tsc --showConfig -p ./tsconfig.json",
32
35
  "ts-show-config-build": "tsc --showConfig -p ./tsconfig.build.json",
33
36
  "ts-check": "tsc -p ./tsconfig.json",
package/dist/index.js DELETED
@@ -1,357 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define([], factory);
6
- else if(typeof exports === 'object')
7
- exports["SSAUtils"] = factory();
8
- else
9
- root["SSAUtils"] = factory();
10
- })(self, () => {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ // The require scope
14
- /******/ var __webpack_require__ = {};
15
- /******/
16
- /************************************************************************/
17
- /******/ /* webpack/runtime/define property getters */
18
- /******/ (() => {
19
- /******/ // define getter functions for harmony exports
20
- /******/ __webpack_require__.d = (exports, definition) => {
21
- /******/ for(var key in definition) {
22
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
23
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
24
- /******/ }
25
- /******/ }
26
- /******/ };
27
- /******/ })();
28
- /******/
29
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
30
- /******/ (() => {
31
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
32
- /******/ })();
33
- /******/
34
- /******/ /* webpack/runtime/make namespace object */
35
- /******/ (() => {
36
- /******/ // define __esModule on exports
37
- /******/ __webpack_require__.r = (exports) => {
38
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
39
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
40
- /******/ }
41
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
42
- /******/ };
43
- /******/ })();
44
- /******/
45
- /************************************************************************/
46
- var __webpack_exports__ = {};
47
- // ESM COMPAT FLAG
48
- __webpack_require__.r(__webpack_exports__);
49
-
50
- // EXPORTS
51
- __webpack_require__.d(__webpack_exports__, {
52
- ClassnameArray: () => (/* reexport */ ClassnameArray),
53
- assocPath: () => (/* reexport */ assocPath),
54
- callAll: () => (/* reexport */ callAll),
55
- dateFormatters: () => (/* reexport */ dateFormatters_namespaceObject),
56
- debounce: () => (/* reexport */ debounce),
57
- dissocPath: () => (/* reexport */ dissocPath),
58
- generateRange: () => (/* reexport */ pagination_generateRange),
59
- mapObjIndexed: () => (/* reexport */ mapObjIndexed),
60
- path: () => (/* reexport */ path_path),
61
- pathOr: () => (/* reexport */ pathOr),
62
- prop: () => (/* reexport */ prop),
63
- propOr: () => (/* reexport */ propOr),
64
- seededRandom: () => (/* reexport */ seededRandom),
65
- throttle: () => (/* reexport */ throttle)
66
- });
67
-
68
- // NAMESPACE OBJECT: ./src/utils/dates/dateFormatters.ts
69
- var dateFormatters_namespaceObject = {};
70
- __webpack_require__.r(dateFormatters_namespaceObject);
71
- __webpack_require__.d(dateFormatters_namespaceObject, {
72
- formatDate: () => (formatDate),
73
- formatDayOfWeek: () => (formatDayOfWeek),
74
- formatTime: () => (formatTime),
75
- getTimeAgo: () => (getTimeAgo),
76
- printDayOfTheWeek: () => (printDayOfTheWeek)
77
- });
78
-
79
- ;// ./src/utils/CallAll.ts
80
- /* eslint-disable @typescript-eslint/no-explicit-any */
81
- const callAll = (...fns) => (...args) => fns.forEach(fn => fn?.(...args));
82
- /* eslint-enable @typescript-eslint/no-explicit-any */
83
- ;// ./src/utils/throttle/throttle.ts
84
- const throttle = (fn, delayMs) => {
85
- let isThrottled = false;
86
- let savedArgs = null;
87
- let timeoutId = null;
88
- function throttledFn(...args) {
89
- if (isThrottled) {
90
- savedArgs = args;
91
- return;
92
- }
93
- isThrottled = true;
94
- fn(...args);
95
- timeoutId = setTimeout(() => {
96
- isThrottled = false;
97
-
98
- // istanbul ignore else
99
- if (savedArgs) {
100
- throttledFn(...savedArgs);
101
- savedArgs = null;
102
- }
103
- }, delayMs);
104
- }
105
- return [throttledFn, function cancel() {
106
- if (timeoutId) {
107
- clearTimeout(timeoutId);
108
- }
109
- }];
110
- };
111
- ;// ./src/utils/debounce/debounce.ts
112
- const debounce = (func, wait = 200) => {
113
- let timeoutId = null;
114
- const executedFunction = (...args) => {
115
- const postponedFn = () => {
116
- if (timeoutId) {
117
- clearTimeout(timeoutId);
118
- }
119
- func(...args);
120
- };
121
- if (timeoutId) {
122
- clearTimeout(timeoutId);
123
- }
124
- timeoutId = setTimeout(postponedFn, wait);
125
- };
126
- const cancel = function () {
127
- if (timeoutId) {
128
- clearTimeout(timeoutId);
129
- }
130
- };
131
- return [executedFunction, cancel];
132
- };
133
- ;// ./src/utils/debounce/index.ts
134
-
135
- ;// ./src/utils/dates/dateFormatters.ts
136
- const dayOfWeekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
137
- const periodValues = {
138
- year: 31536000,
139
- month: 2592000,
140
- week: 604800,
141
- day: 86400,
142
- hour: 3600,
143
- min: 60
144
- };
145
- const formatTime = timestampMs => new Date(timestampMs).toLocaleTimeString('en-US', {
146
- hour: '2-digit',
147
- minute: '2-digit'
148
- });
149
- const formatDayOfWeek = timestampMs => dayOfWeekNames[new Date(timestampMs).getDay()];
150
- const formatDate = timestampMs => new Date(timestampMs).toLocaleDateString('en-US', {
151
- day: '2-digit',
152
- month: 'short'
153
- });
154
- const printDayOfTheWeek = day => {
155
- switch (day) {
156
- case 0:
157
- return 'Sun';
158
- case 1:
159
- return 'Mon';
160
- case 2:
161
- return 'Tue';
162
- case 3:
163
- return 'Wed';
164
- case 4:
165
- return 'Thu';
166
- case 5:
167
- return 'Fri';
168
- case 6:
169
- return 'Sat';
170
- }
171
- };
172
- const getTimeAgo = timeValue => {
173
- const date = new Date(timeValue).getTime();
174
- if (Number.isNaN(date)) {
175
- throw new Error('Invalid date');
176
- }
177
- const diff = Math.floor((Date.now() - date) / 1000);
178
- let interval;
179
- for (const key in periodValues) {
180
- interval = Math.floor(diff / periodValues[key]);
181
- if (interval >= 1) {
182
- const pluralValue = interval > 1 ? 's' : '';
183
- return `${interval} ${key}${pluralValue} ago`;
184
- }
185
- }
186
- return 'Just Now';
187
- };
188
- ;// ./src/utils/objects/mapObjIndexed.ts
189
- const mapObjIndexed = (fn, obj) => {
190
- return Object.keys(obj).reduce((result, key) => {
191
- result[key] = fn(obj[key], key, obj);
192
- return result;
193
- }, {});
194
- };
195
- ;// ./src/utils/pagination/generateRange.ts
196
- /**
197
- * The function that returns an array of page numbers to show in the pagination
198
- * component.
199
- *
200
- * Rules:
201
- * - To always show the 1st and the last page.
202
- * - To show one item before and one item after the selected page.
203
- * - To return "-1" for the skipped items. This is to be able to display "..." in
204
- * the pagination component.
205
- * */
206
- const SKIPPED_ITEMS_DELTA = 2;
207
- const getSelectedRange = (pagesCount, selectedPage) => {
208
- const range = [];
209
- if (selectedPage !== pagesCount) {
210
- range.push(selectedPage);
211
- }
212
- if (selectedPage > 1) {
213
- range.unshift(selectedPage - 1);
214
- }
215
- if (selectedPage + 1 < pagesCount) {
216
- range.push(selectedPage + 1);
217
- }
218
- return range;
219
- };
220
- const fill = (range, minValue, maxValue) => {
221
- for (let i = minValue; i < maxValue; ++i) {
222
- range.push(i);
223
- }
224
- };
225
- const generateRange = (pagesCount, selectedPage) => {
226
- if (pagesCount == null || !Number.isInteger(pagesCount)) {
227
- throw new Error('Pages count should be an integer');
228
- }
229
- if (pagesCount <= 0) {
230
- return [];
231
- }
232
- let range = [1];
233
- if (pagesCount === 1) {
234
- return range;
235
- }
236
- if (selectedPage != null && !Number.isInteger(selectedPage)) {
237
- throw new Error('Selected page should be an integer');
238
- }
239
- if (selectedPage != null && (selectedPage < 1 || selectedPage > pagesCount)) {
240
- throw new Error(`Selected page ${selectedPage} is out of range`);
241
- }
242
- if (selectedPage && selectedPage > 2) {
243
- const selectedRange = getSelectedRange(pagesCount, selectedPage);
244
- const [minSelectedRange,, maxSelectedRange] = selectedRange;
245
- if (minSelectedRange - SKIPPED_ITEMS_DELTA > 1) {
246
- range.push(-1);
247
- } else {
248
- fill(range, 2, minSelectedRange);
249
- }
250
- range = range.concat(selectedRange);
251
- if (pagesCount - maxSelectedRange > SKIPPED_ITEMS_DELTA) {
252
- range.push(-1);
253
- } else {
254
- fill(range, maxSelectedRange + 1, pagesCount);
255
- }
256
- } else if (pagesCount <= 5) {
257
- fill(range, 2, pagesCount);
258
- } else {
259
- range.push(2, 3, -1);
260
- }
261
- range.push(pagesCount);
262
- return range;
263
- };
264
- /* harmony default export */ const pagination_generateRange = (generateRange);
265
- ;// ./src/utils/objects/assocPath.ts
266
- const assocPath = ([first, ...rest], value) => sourceObject => JSON.parse(JSON.stringify({
267
- ...sourceObject,
268
- [first]: rest.length ? assocPath(rest, value)(sourceObject[first]) : value
269
- }));
270
- ;// ./src/utils/objects/dissocPath.ts
271
- const dissocPath = path => sourceObject => {
272
- const resultObject = JSON.parse(JSON.stringify(sourceObject));
273
- path.reduce((acc, key, index) => {
274
- if (index === path.length - 1) {
275
- delete acc[key];
276
- }
277
- return acc[key];
278
- }, resultObject);
279
- return resultObject;
280
- };
281
- ;// ./src/utils/objects/path.ts
282
- const path_path = path => obj => path.reduce((prev, curr) => prev?.[curr], obj);
283
- ;// ./src/utils/objects/pathOr.ts
284
-
285
-
286
- /* eslint-disable @typescript-eslint/no-explicit-any */
287
- const pathOr = (defaultValue, path) => obj => {
288
- const result = path_path(path)(obj);
289
- return result === null || result === undefined ? defaultValue : result;
290
- };
291
- /* eslint-enable @typescript-eslint/no-explicit-any */
292
- ;// ./src/utils/objects/prop.ts
293
- /* eslint-disable @typescript-eslint/no-explicit-any */
294
- const prop = propName => obj => obj?.[propName];
295
- ;// ./src/utils/objects/propOr.ts
296
-
297
-
298
- /* eslint-disable @typescript-eslint/no-explicit-any */
299
- const propOr = (defaultValue, propName) => obj => {
300
- const result = prop(propName)(obj);
301
- return result === null || result === undefined ? defaultValue : result;
302
- };
303
- /* eslint-enable @typescript-eslint/no-explicit-any */
304
- ;// ./src/utils/objects/index.ts
305
-
306
-
307
-
308
-
309
-
310
-
311
-
312
- ;// ./src/utils/story.ts
313
- // Useful for generating test datasets for storybook stories
314
- const seededRandom = seed => {
315
- return () => {
316
- // Linear congruential generator
317
- seed = (seed * 9301 + 49297) % 233280;
318
- return seed / 233280;
319
- };
320
- };
321
- ;// ./src/utils/ClassnameArray/ClassnameArray.ts
322
- class ClassnameArray extends Array {
323
- toggle(className, condition) {
324
- const index = this.indexOf(className);
325
- if (condition) {
326
- if (index === -1) {
327
- this.push(className);
328
- }
329
- } else {
330
- if (index > -1) {
331
- this.splice(index, 1);
332
- }
333
- }
334
- return this;
335
- }
336
- clear() {
337
- this.length = 0;
338
- return this;
339
- }
340
- }
341
- ;// ./src/index.ts
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
- /******/ return __webpack_exports__;
354
- /******/ })()
355
- ;
356
- });
357
- //# sourceMappingURL=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oC;AACX;AACnB;AACF;AACA","sources":["webpack://SSAUtils/webpack/universalModuleDefinition","webpack://SSAUtils/webpack/bootstrap","webpack://SSAUtils/webpack/runtime/define property getters","webpack://SSAUtils/webpack/runtime/hasOwnProperty shorthand","webpack://SSAUtils/webpack/runtime/make namespace object","webpack://SSAUtils/./src/utils/CallAll.ts","webpack://SSAUtils/./src/utils/throttle/throttle.ts","webpack://SSAUtils/./src/utils/debounce/debounce.ts","webpack://SSAUtils/./src/utils/debounce/index.ts","webpack://SSAUtils/./src/utils/dates/dateFormatters.ts","webpack://SSAUtils/./src/utils/objects/mapObjIndexed.ts","webpack://SSAUtils/./src/utils/pagination/generateRange.ts","webpack://SSAUtils/./src/utils/objects/assocPath.ts","webpack://SSAUtils/./src/utils/objects/dissocPath.ts","webpack://SSAUtils/./src/utils/objects/path.ts","webpack://SSAUtils/./src/utils/objects/pathOr.ts","webpack://SSAUtils/./src/utils/objects/prop.ts","webpack://SSAUtils/./src/utils/objects/propOr.ts","webpack://SSAUtils/./src/utils/objects/index.ts","webpack://SSAUtils/./src/utils/story.ts","webpack://SSAUtils/./src/utils/ClassnameArray/ClassnameArray.ts","webpack://SSAUtils/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SSAUtils\"] = factory();\n\telse\n\t\troot[\"SSAUtils\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const callAll =\n (...fns: any[]) =>\n (...args: any) =>\n fns.forEach((fn) => fn?.(...args));\n/* eslint-enable @typescript-eslint/no-explicit-any */\n","export const throttle = <T extends unknown[]>(\n fn: (...args: T) => unknown,\n delayMs: number,\n) => {\n let isThrottled = false;\n let savedArgs: T | null = null;\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n function throttledFn(...args: T) {\n if (isThrottled) {\n savedArgs = args;\n return;\n }\n\n isThrottled = true;\n\n fn(...args);\n\n timeoutId = setTimeout(() => {\n isThrottled = false;\n\n // istanbul ignore else\n if (savedArgs) {\n throttledFn(...savedArgs);\n savedArgs = null;\n }\n }, delayMs);\n }\n\n return [\n throttledFn,\n function cancel() {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n },\n ] as const;\n};\n","export const debounce = <T extends unknown[]>(\n func: (...args: T) => unknown,\n wait = 200,\n) => {\n let timeoutId: NodeJS.Timeout | null = null;\n const executedFunction = (...args: T) => {\n const postponedFn = () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n func(...args);\n };\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(postponedFn, wait);\n };\n\n const cancel = function () {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n return [executedFunction, cancel] as const;\n};\n","export { debounce } from './debounce';\n","const dayOfWeekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];\nconst periodValues: Record<string, number> = {\n year: 31536000,\n month: 2592000,\n week: 604800,\n day: 86400,\n hour: 3600,\n min: 60,\n};\n\nexport const formatTime = (timestampMs: number) =>\n new Date(timestampMs).toLocaleTimeString('en-US', {\n hour: '2-digit',\n minute: '2-digit',\n });\n\nexport const formatDayOfWeek = (timestampMs: number) =>\n dayOfWeekNames[new Date(timestampMs).getDay()];\n\nexport const formatDate = (timestampMs: number) =>\n new Date(timestampMs).toLocaleDateString('en-US', {\n day: '2-digit',\n month: 'short',\n });\n\nexport const printDayOfTheWeek = (day: number) => {\n switch (day) {\n case 0:\n return 'Sun';\n case 1:\n return 'Mon';\n case 2:\n return 'Tue';\n case 3:\n return 'Wed';\n case 4:\n return 'Thu';\n case 5:\n return 'Fri';\n case 6:\n return 'Sat';\n }\n};\n\nexport const getTimeAgo = (timeValue: string | number) => {\n const date = new Date(timeValue).getTime();\n if (Number.isNaN(date)) {\n throw new Error('Invalid date');\n }\n const diff = Math.floor((Date.now() - date) / 1000);\n let interval;\n for (const key in periodValues) {\n interval = Math.floor(diff / periodValues[key]);\n if (interval >= 1) {\n const pluralValue = interval > 1 ? 's' : '';\n return `${interval} ${key}${pluralValue} ago`;\n }\n }\n\n return 'Just Now';\n};\n","type MapObjIndexedFn<T, U> = (\n value: T,\n key: string,\n obj: Record<string, T>,\n) => U;\n\nexport const mapObjIndexed = <T, U>(\n fn: MapObjIndexedFn<T, U>,\n obj: Record<string, T>,\n): Record<string, U> => {\n return Object.keys(obj).reduce((result: Record<string, U>, key: string) => {\n result[key] = fn(obj[key], key, obj);\n return result;\n }, {});\n};\n","import { GenerateRangeFn } from './types';\n\n/**\n * The function that returns an array of page numbers to show in the pagination\n * component.\n *\n * Rules:\n * - To always show the 1st and the last page.\n * - To show one item before and one item after the selected page.\n * - To return \"-1\" for the skipped items. This is to be able to display \"...\" in\n * the pagination component.\n * */\nconst SKIPPED_ITEMS_DELTA = 2;\n\nconst getSelectedRange = (pagesCount: number, selectedPage: number) => {\n const range: number[] = [];\n\n if (selectedPage !== pagesCount) {\n range.push(selectedPage);\n }\n\n if (selectedPage > 1) {\n range.unshift(selectedPage - 1);\n }\n\n if (selectedPage + 1 < pagesCount) {\n range.push(selectedPage + 1);\n }\n\n return range;\n};\n\nconst fill = (range: number[], minValue: number, maxValue: number) => {\n for (let i = minValue; i < maxValue; ++i) {\n range.push(i);\n }\n};\n\nconst generateRange: GenerateRangeFn = (pagesCount, selectedPage) => {\n if (pagesCount == null || !Number.isInteger(pagesCount)) {\n throw new Error('Pages count should be an integer');\n }\n\n if (pagesCount <= 0) {\n return [];\n }\n\n let range = [1];\n\n if (pagesCount === 1) {\n return range;\n }\n\n if (selectedPage != null && !Number.isInteger(selectedPage)) {\n throw new Error('Selected page should be an integer');\n }\n\n if (selectedPage != null && (selectedPage < 1 || selectedPage > pagesCount)) {\n throw new Error(`Selected page ${selectedPage} is out of range`);\n }\n\n if (selectedPage && selectedPage > 2) {\n const selectedRange = getSelectedRange(pagesCount, selectedPage);\n\n const [minSelectedRange, , maxSelectedRange] = selectedRange;\n\n if (minSelectedRange - SKIPPED_ITEMS_DELTA > 1) {\n range.push(-1);\n } else {\n fill(range, 2, minSelectedRange);\n }\n\n range = range.concat(selectedRange);\n\n if (pagesCount - maxSelectedRange > SKIPPED_ITEMS_DELTA) {\n range.push(-1);\n } else {\n fill(range, maxSelectedRange + 1, pagesCount);\n }\n } else if (pagesCount <= 5) {\n fill(range, 2, pagesCount);\n } else {\n range.push(2, 3, -1);\n }\n\n range.push(pagesCount);\n\n return range;\n};\n\nexport default generateRange;\n","export const assocPath =\n <T>([first, ...rest]: string[], value: unknown) =>\n (sourceObject: T): T =>\n JSON.parse(\n JSON.stringify({\n ...sourceObject,\n [first]: rest.length\n ? assocPath(rest, value)(sourceObject[first as keyof T])\n : value,\n }),\n ) as T;\n","export const dissocPath =\n <T>(path: string[]) =>\n (sourceObject: T): T => {\n const resultObject = JSON.parse(JSON.stringify(sourceObject));\n path.reduce((acc, key, index) => {\n if (index === path.length - 1) {\n delete acc[key];\n }\n return acc[key];\n }, resultObject);\n\n return resultObject;\n };\n","export const path =\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n <T extends Record<string | number, any>, R = unknown>(\n path: Array<string | number>,\n ) =>\n (obj: T): R =>\n path.reduce(\n (prev, curr: string | number) => prev?.[curr],\n obj,\n ) as unknown as R;\n","import { path as originalPath } from './path';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const pathOr =\n <T extends Record<string | number, any>, R>(\n defaultValue: any,\n path: Array<string | number>,\n ) =>\n (obj: T): R => {\n const result = originalPath(path)(obj);\n return result === null || result === undefined\n ? defaultValue\n : (result as R);\n };\n/* eslint-enable @typescript-eslint/no-explicit-any */\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const prop =\n <T extends Record<string | number, any>, R = any>(propName: string) =>\n (obj: T): R =>\n obj?.[propName] as R;\n","import { prop } from './prop';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const propOr =\n <T extends Record<string | number, any>, R = any>(\n defaultValue: any,\n propName: string,\n ) =>\n (obj: T): R => {\n const result = prop(propName)(obj);\n return result === null || result === undefined ? defaultValue : result;\n };\n/* eslint-enable @typescript-eslint/no-explicit-any */\n","export * from './mapObjIndexed';\nexport * from './assocPath';\nexport * from './dissocPath';\nexport * from './path';\nexport * from './pathOr';\nexport * from './prop';\nexport * from './propOr';\n","// Useful for generating test datasets for storybook stories\nexport const seededRandom = (seed: number) => {\n return () => {\n // Linear congruential generator\n seed = (seed * 9301 + 49297) % 233280;\n return seed / 233280;\n };\n};\n","export class ClassnameArray extends Array<string> {\n toggle(className: string, condition: boolean) {\n const index = this.indexOf(className);\n if (condition) {\n if (index === -1) {\n this.push(className);\n }\n } else {\n if (index > -1) {\n this.splice(index, 1);\n }\n }\n return this;\n }\n\n clear() {\n this.length = 0;\n return this;\n }\n}\n","export { callAll } from './utils/CallAll';\nexport { throttle } from './utils/throttle';\nexport * from './utils/debounce';\nexport * as dateFormatters from './utils/dates/dateFormatters';\nexport { mapObjIndexed } from './utils/objects/mapObjIndexed';\nexport { generateRange } from './utils/pagination';\nexport * from './utils/objects';\nexport * from './utils/types';\nexport * from './utils/story';\nexport * from './utils/ClassnameArray/ClassnameArray';\n"],"names":["callAll","fns","args","forEach","fn","throttle","delayMs","isThrottled","savedArgs","timeoutId","throttledFn","setTimeout","cancel","clearTimeout","debounce","func","wait","executedFunction","postponedFn","dayOfWeekNames","periodValues","year","month","week","day","hour","min","formatTime","timestampMs","Date","toLocaleTimeString","minute","formatDayOfWeek","getDay","formatDate","toLocaleDateString","printDayOfTheWeek","getTimeAgo","timeValue","date","getTime","Number","isNaN","Error","diff","Math","floor","now","interval","key","pluralValue","mapObjIndexed","obj","Object","keys","reduce","result","SKIPPED_ITEMS_DELTA","getSelectedRange","pagesCount","selectedPage","range","push","unshift","fill","minValue","maxValue","i","generateRange","isInteger","selectedRange","minSelectedRange","maxSelectedRange","concat","assocPath","first","rest","value","sourceObject","JSON","parse","stringify","length","dissocPath","path","resultObject","acc","index","prev","curr","originalPath","pathOr","defaultValue","undefined","prop","propName","propOr","seededRandom","seed","ClassnameArray","Array","toggle","className","condition","indexOf","splice","clear","_dateFormatters","dateFormatters"],"ignoreList":[],"sourceRoot":""}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};