meticulous-ui 3.2.6 → 3.2.8
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/README.md +43 -13
- package/index.js +26 -22
- package/package.json +1 -1
- package/utils/announceToScreenReader.js +9 -0
- package/utils/auditLog.js +12 -0
- package/utils/captureException.js +12 -0
- package/utils/createPubSub.js +11 -0
- package/utils/decodeJWT.js +11 -0
- package/utils/deepFreeze.js +7 -0
- package/utils/fadeIn.js +10 -0
- package/utils/fadeOut.js +8 -0
- package/utils/fallback.js +4 -0
- package/utils/featureGate.js +4 -0
- package/utils/filterByKey.js +4 -0
- package/utils/fuzzySearch.js +16 -0
- package/utils/generateAriaId.js +5 -0
- package/utils/getToken.js +4 -0
- package/utils/getVariant.js +10 -0
- package/utils/handleKeyboardNavigation.js +17 -0
- package/utils/hasPermission.js +13 -0
- package/utils/identity.js +4 -0
- package/utils/index.js +200 -112
- package/utils/isAuthenticated.js +14 -0
- package/utils/isFeatureEnabled.js +10 -0
- package/utils/logError.js +7 -0
- package/utils/logInfo.js +8 -0
- package/utils/logWarn.js +8 -0
- package/utils/measurePerformance.js +12 -0
- package/utils/multiSort.js +11 -0
- package/utils/noop.js +5 -0
- package/utils/once.js +7 -0
- package/utils/paginate.js +13 -0
- package/utils/permissionGuard.js +4 -0
- package/utils/pipe.js +4 -0
- package/utils/removeToken.js +4 -0
- package/utils/safeJSONParse.js +10 -0
- package/utils/safeJSONStringify.js +10 -0
- package/utils/setToken.js +4 -0
- package/utils/singleton.js +7 -0
- package/utils/smoothScroll.js +14 -0
- package/utils/trackEvent.js +8 -0
- package/utils/trackPageView.js +12 -0
- package/utils/trapFocus.js +16 -0
- package/utils/waitForTransitionEnd.js +9 -0
package/README.md
CHANGED
|
@@ -142,19 +142,49 @@ import blue from 'meticulous-ui/colors/blue';
|
|
|
142
142
|
|
|
143
143
|
## 📦 Utils
|
|
144
144
|
|
|
145
|
-
| Category
|
|
146
|
-
|
|
|
147
|
-
| **String**
|
|
148
|
-
| **Number**
|
|
149
|
-
| **Date-Time**
|
|
150
|
-
| **Data**
|
|
151
|
-
| **Validation**
|
|
152
|
-
| **Device**
|
|
153
|
-
| **Storage**
|
|
154
|
-
| **Routing**
|
|
155
|
-
| **UI**
|
|
156
|
-
| **Performance**
|
|
157
|
-
| **Async**
|
|
145
|
+
| Category | Functions |
|
|
146
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| **String** | `capFirstLetter`, `capitalize`, `titleCase`, `camelCase`, `snakeCase`, `kebabCase`, `slugify`, `truncate`, `removeExtraSpaces`, `maskEmail`, `maskPhone`, `generateInitials`, |
|
|
148
|
+
| **Number** | `clamp`, `formatCurrency`, `formatNumber`, `formatCompactNumber`, `percentage`, `randomInt`, `randomBetween`, `randomValue`, `roundTo`, |
|
|
149
|
+
| **Date-Time** | `formatDate`, `formatTime`, `addDays`, `differenceInDays`, `isToday`, `isPast`, `timeAgo`, `getGreetingByTime`, `countdown`, |
|
|
150
|
+
| **Data** | `deepClone`, `mergeDeep`, `pick`, `omit`, `isEmpty`, `isEqual`, `hasEqualProps`, `isNonEmptyArray`, `flattenObject`, `groupBy`, `keyBy`, `uniqueBy`, `sortBy`, `chunk`, `compose`, |
|
|
151
|
+
| **Validation** | `isEmail`, `isPhone`, `isURL`, `isPasswordStrong`, `isPAN`, `isAadhaar`, `isGST`, `isRequired`, `minLength`, `maxLength`, |
|
|
152
|
+
| **Device** | `isMobile`, `isIOS`, `isAndroid`, `isSafari`, `isDarkMode`, `isOnline`, `copyToClipboard`, `downloadFile`, `openInNewTab`, `getScreenSize`, |
|
|
153
|
+
| **Storage** | `setLocalStorage`, `getLocalStorage`, `removeLocalStorage`, `setSessionStorage`, `getSessionStorage`, `clearStorage`, |
|
|
154
|
+
| **Routing** | `getQueryParams`, `setQueryParam`, `removeQueryParam`, `buildURL`, `redirectTo`, `getCurrentPath`, `isActiveRoute`, |
|
|
155
|
+
| **UI** | `scrollToTop`, `scrollToElement`, `lockBodyScroll`, `unlockBodyScroll`, `toggleFullscreen`, `focusElement`, `detectOutsideClick`, `measureElement`, |
|
|
156
|
+
| **Performance** | `debounce`, `throttle`, `memoize`, `lazyLoadComponent`, `requestIdleTask`, `rafThrottle`, |
|
|
157
|
+
| **Async** | `retry`, `sleep`, `withTimeout`, `parallel`, `sequential`, `safeAsync`, `cancelablePromise` |
|
|
158
|
+
| **Accessibility** | `announceToScreenReader`, `trapFocus`, `generateAriaId`, `handleKeyboardNavigation` |
|
|
159
|
+
| **Error Handling** | `logError`, `captureException`, `safeJSONParse`, `safeJSONStringify`, `fallback` |
|
|
160
|
+
| **Auth** | `isAuthenticated`, `getToken`, `setToken`, `removeToken`, `decodeJWT`, `hasPermission` |
|
|
161
|
+
| **Feature Flags** | `isFeatureEnabled`, `getVariant` |
|
|
162
|
+
| **Enterprise** | `trackEvent`, `trackPageView`, `measurePerformance`, `featureGate`, `permissionGuard`, `auditLog`, `logInfo`, `logWarn`, `captureException` |
|
|
163
|
+
| **Filter** | `fuzzySearch`, `filterByKey`, `multiSort`, `paginate` |
|
|
164
|
+
| **Animation** | `fadeIn`, `fadeOut`, `smoothScroll`, `waitForTransitionEnd` |
|
|
165
|
+
| **Function** | `once`, `noop`, `identity`, `pipe`, `singleton`, `createPubSub`, `deepFreeze` |
|
|
166
|
+
|
|
167
|
+
## 📦 React Helper Functions
|
|
168
|
+
|
|
169
|
+
| Function | Description |
|
|
170
|
+
| ------------------- | ---------------------------------------------------------------------------------- |
|
|
171
|
+
| `createContextHook` | Creates a React context + typed hook pair; throws if consumed outside its Provider |
|
|
172
|
+
| `composeProviders` | Merges N provider components into one wrapper, eliminating the provider pyramid |
|
|
173
|
+
| `lazyImport` | Extends `React.lazy` to work with named exports, not just default exports |
|
|
174
|
+
| `withErrorBoundary` | HOC wrapping a component in an error boundary with a configurable fallback |
|
|
175
|
+
| `withSuspense` | HOC wrapping a component in `<Suspense>` with a co-located fallback UI |
|
|
176
|
+
| `memoCompare` | Typed wrapper around `React.memo` with a custom equality comparator |
|
|
177
|
+
| `createPortalNode` | Creates and appends a DOM node to `document.body` for use as a portal container |
|
|
178
|
+
|
|
179
|
+
## 📦 Hooks
|
|
180
|
+
|
|
181
|
+
| Category | Hooks |
|
|
182
|
+
| --------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
+
| **State** | `usePrevious`, `useDebounce`, `useThrottle`, `useToggle` |
|
|
184
|
+
| **Lifecycle** | `useIsMounted`, `useUnmount`, `useFirstRender`, `useTimeout`, `useInterval` |
|
|
185
|
+
| **DOM/Browser** | `useEventListener`, `useIntersectionObserver`, `useMediaQuery`, `useOutsideClick`, `useWindowSize`, `useOnlineStatus` |
|
|
186
|
+
| **Storage** | `useLocalStorage`, `useSessionStorage` |
|
|
187
|
+
| **Utility** | `useCopyToClipboard` |
|
|
158
188
|
|
|
159
189
|
## 🌱 Features
|
|
160
190
|
|
package/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { default as a } from "./components/Pagination/Pagination.js";
|
|
2
2
|
import { default as r, ToastContainer as f } from "./components/Toast/Toast.js";
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
3
|
+
import { default as l } from "./components/Spinner/Spinner.js";
|
|
4
|
+
import { default as d } from "./components/Loader/Loader.js";
|
|
5
5
|
import { default as m } from "./components/PageLoader/PageLoader.js";
|
|
6
6
|
import { default as n } from "./components/OtpInput/OtpInput.js";
|
|
7
7
|
import { default as c } from "./components/Dropdown/Dropdown.js";
|
|
8
8
|
import { default as C } from "./components/RootComponent/RootComponent.js";
|
|
9
9
|
import { default as T } from "./components/Selectbox/Selectbox.js";
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
10
|
+
import { default as I } from "./components/Button/Button.js";
|
|
11
|
+
import { default as b } from "./components/Timer/Timer.js";
|
|
12
|
+
import { default as L } from "./components/Shimmer/Shimmer.js";
|
|
13
|
+
import { default as U } from "./components/VideoPlayer/VideoPlayer.js";
|
|
14
|
+
import { default as y } from "./components/Image/Image.js";
|
|
15
|
+
import { default as D } from "./components/Carousel/Carousel.js";
|
|
16
|
+
import { default as G } from "./components/Typography/Headings/index.js";
|
|
17
|
+
import { default as O } from "./components/Typography/P/P.js";
|
|
18
18
|
import { default as j } from "./components/Input/Input/Input.js";
|
|
19
19
|
import { default as v } from "./components/Input/Textarea/Textarea.js";
|
|
20
20
|
import { default as A } from "./components/Input/Checkbox/Checkbox.js";
|
|
@@ -22,32 +22,36 @@ import { default as J } from "./components/Input/RadioGroup/RadioGroup.js";
|
|
|
22
22
|
import { default as M } from "./components/Input/FileUploader/FileUploader.js";
|
|
23
23
|
import { default as Q } from "./colors/index.js";
|
|
24
24
|
import { default as X } from "./utils/index.js";
|
|
25
|
-
import { default as Z } from "./
|
|
25
|
+
import { default as Z } from "./hooks/index.js";
|
|
26
|
+
import { default as $ } from "./react-utils/index.js";
|
|
27
|
+
import { default as eo } from "./components/Icons/index.js";
|
|
26
28
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
I as Button,
|
|
30
|
+
D as Carousel,
|
|
29
31
|
A as Checkbox,
|
|
30
32
|
c as Dropdown,
|
|
31
33
|
M as FileUploader,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
G as Headings,
|
|
35
|
+
y as Image,
|
|
34
36
|
j as Input,
|
|
35
|
-
|
|
37
|
+
d as Loader,
|
|
36
38
|
n as OtpInput,
|
|
37
|
-
|
|
39
|
+
O as P,
|
|
38
40
|
m as PageLoader,
|
|
39
41
|
a as Pagination,
|
|
40
42
|
J as RadioGroup,
|
|
41
43
|
C as RootComponent,
|
|
42
44
|
T as Selectbox,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
L as Shimmer,
|
|
46
|
+
l as Spinner,
|
|
45
47
|
v as Textarea,
|
|
46
|
-
|
|
48
|
+
b as Timer,
|
|
47
49
|
r as Toast,
|
|
48
50
|
f as ToastContainer,
|
|
49
|
-
|
|
51
|
+
U as VideoPlayer,
|
|
50
52
|
Q as colors,
|
|
51
|
-
Z as
|
|
53
|
+
Z as hooks,
|
|
54
|
+
eo as icons,
|
|
55
|
+
$ as reactUtils,
|
|
52
56
|
X as utils
|
|
53
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meticulous-ui",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "A comprehensive React UI component library with a wide range of customizable components, icons, colors, and utilities for building modern web applications.",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const i = (t, o = "polite") => {
|
|
2
|
+
const e = document.createElement("div");
|
|
3
|
+
e.setAttribute("aria-live", o), e.setAttribute("aria-atomic", "true"), e.style.cssText = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", document.body.appendChild(e), requestAnimationFrame(() => {
|
|
4
|
+
e.textContent = t, setTimeout(() => document.body.removeChild(e), 1e3);
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
i as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const t = (n, o = {}) => {
|
|
2
|
+
const e = {
|
|
3
|
+
action: n,
|
|
4
|
+
metadata: o,
|
|
5
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6
|
+
user: typeof window < "u" ? window.__currentUser ?? null : null
|
|
7
|
+
};
|
|
8
|
+
return typeof window < "u" && typeof window.__auditLogger == "function" ? window.__auditLogger(e) : console.log("[auditLog]", e), e;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
t as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const o = (e, n = {}) => {
|
|
2
|
+
const t = {
|
|
3
|
+
message: e instanceof Error ? e.message : String(e),
|
|
4
|
+
stack: e instanceof Error ? e.stack : void 0,
|
|
5
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6
|
+
...n
|
|
7
|
+
};
|
|
8
|
+
return typeof window < "u" && typeof window.__captureException == "function" ? window.__captureException(t) : console.error("[captureException]", t), t;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
o as default
|
|
12
|
+
};
|
package/utils/fadeIn.js
ADDED
package/utils/fadeOut.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const u = (r, o) => {
|
|
2
|
+
if (!o) return r;
|
|
3
|
+
const n = o.toLowerCase(), s = (t) => {
|
|
4
|
+
let e = 0;
|
|
5
|
+
const f = t.toLowerCase();
|
|
6
|
+
for (const c of n) {
|
|
7
|
+
if (e = f.indexOf(c, e), e === -1) return !1;
|
|
8
|
+
e++;
|
|
9
|
+
}
|
|
10
|
+
return !0;
|
|
11
|
+
};
|
|
12
|
+
return r.filter((t) => typeof t == "string" ? s(t) : Object.values(t).some((e) => typeof e == "string" && s(e)));
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
u as default
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const y = (a, t, h = {}) => {
|
|
2
|
+
const { onSelect: o, loop: l = !0, orientation: p = "vertical" } = h, n = p === "horizontal" ? "ArrowLeft" : "ArrowUp", v = p === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
3
|
+
return (r) => {
|
|
4
|
+
if (r.key === v) {
|
|
5
|
+
r.preventDefault();
|
|
6
|
+
const f = t + 1 >= a.length ? l ? 0 : t : t + 1;
|
|
7
|
+
o == null || o(f, a[f]);
|
|
8
|
+
} else if (r.key === n) {
|
|
9
|
+
r.preventDefault();
|
|
10
|
+
const f = t - 1 < 0 ? l ? a.length - 1 : t : t - 1;
|
|
11
|
+
o == null || o(f, a[f]);
|
|
12
|
+
} else r.key === "Home" ? (r.preventDefault(), o == null || o(0, a[0])) : r.key === "End" && (r.preventDefault(), o == null || o(a.length - 1, a[a.length - 1]));
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
y as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import n from "./decodeJWT.js";
|
|
2
|
+
import a from "./getToken.js";
|
|
3
|
+
const l = (o, s = "auth_token") => {
|
|
4
|
+
const t = a(s);
|
|
5
|
+
if (!t) return !1;
|
|
6
|
+
const r = n(t);
|
|
7
|
+
if (!r) return !1;
|
|
8
|
+
const e = r.roles ?? r.role ?? [];
|
|
9
|
+
return Array.isArray(e) ? e.includes(o) : e === o;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
l as default
|
|
13
|
+
};
|
package/utils/index.js
CHANGED
|
@@ -7,12 +7,12 @@ import e from "./compose.js";
|
|
|
7
7
|
import p from "./deepClone.js";
|
|
8
8
|
import f from "./flattenObject.js";
|
|
9
9
|
import a from "./formatCompactNumber.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import n from "./formatCurrency.js";
|
|
11
|
+
import s from "./formatDate.js";
|
|
12
|
+
import l from "./formatNumber.js";
|
|
13
13
|
import c from "./formatTime.js";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
14
|
+
import d from "./generateInitials.js";
|
|
15
|
+
import u from "./getGreetingByTime.js";
|
|
16
16
|
import g from "./groupBy.js";
|
|
17
17
|
import y from "./hasEqualProps.js";
|
|
18
18
|
import S from "./addDays.js";
|
|
@@ -20,33 +20,33 @@ import T from "./countdown.js";
|
|
|
20
20
|
import k from "./differenceInDays.js";
|
|
21
21
|
import b from "./isEmpty.js";
|
|
22
22
|
import h from "./isEqual.js";
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
23
|
+
import P from "./isNonEmptyArray.js";
|
|
24
|
+
import E from "./isPast.js";
|
|
25
|
+
import C from "./isToday.js";
|
|
26
26
|
import L from "./kebabCase.js";
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
27
|
+
import A from "./keyBy.js";
|
|
28
|
+
import B from "./maskEmail.js";
|
|
29
|
+
import I from "./maskPhone.js";
|
|
30
30
|
import w from "./mergeDeep.js";
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
31
|
+
import N from "./omit.js";
|
|
32
|
+
import v from "./percentage.js";
|
|
33
|
+
import z from "./pick.js";
|
|
34
|
+
import F from "./randomBetween.js";
|
|
35
|
+
import O from "./randomInt.js";
|
|
36
|
+
import q from "./randomValue.js";
|
|
37
|
+
import x from "./removeExtraSpaces.js";
|
|
38
|
+
import D from "./roundTo.js";
|
|
39
|
+
import R from "./slugify.js";
|
|
40
|
+
import G from "./snakeCase.js";
|
|
41
|
+
import J from "./sortBy.js";
|
|
42
|
+
import Q from "./timeAgo.js";
|
|
43
|
+
import V from "./titleCase.js";
|
|
44
|
+
import K from "./truncate.js";
|
|
45
|
+
import M from "./uniqueBy.js";
|
|
46
|
+
import U from "./isEmail.js";
|
|
47
|
+
import W from "./isPhone.js";
|
|
48
|
+
import j from "./isURL.js";
|
|
49
|
+
import H from "./isPasswordStrong.js";
|
|
50
50
|
import X from "./isPAN.js";
|
|
51
51
|
import Y from "./isAadhaar.js";
|
|
52
52
|
import Z from "./isGST.js";
|
|
@@ -61,9 +61,9 @@ import eo from "./isDarkMode.js";
|
|
|
61
61
|
import po from "./isOnline.js";
|
|
62
62
|
import fo from "./copyToClipboard.js";
|
|
63
63
|
import ao from "./downloadFile.js";
|
|
64
|
-
import
|
|
65
|
-
import
|
|
66
|
-
import
|
|
64
|
+
import no from "./openInNewTab.js";
|
|
65
|
+
import so from "./getScreenSize.js";
|
|
66
|
+
import lo from "./getQueryParams.js";
|
|
67
67
|
import co from "./setQueryParam.js";
|
|
68
68
|
import uo from "./removeQueryParam.js";
|
|
69
69
|
import go from "./buildURL.js";
|
|
@@ -73,64 +73,104 @@ import To from "./isActiveRoute.js";
|
|
|
73
73
|
import ko from "./setLocalStorage.js";
|
|
74
74
|
import bo from "./getLocalStorage.js";
|
|
75
75
|
import ho from "./removeLocalStorage.js";
|
|
76
|
-
import
|
|
77
|
-
import
|
|
78
|
-
import
|
|
76
|
+
import Po from "./setSessionStorage.js";
|
|
77
|
+
import Eo from "./getSessionStorage.js";
|
|
78
|
+
import Co from "./clearStorage.js";
|
|
79
79
|
import Lo from "./debounce.js";
|
|
80
|
-
import
|
|
81
|
-
import
|
|
82
|
-
import
|
|
80
|
+
import Ao from "./throttle.js";
|
|
81
|
+
import Bo from "./memoize.js";
|
|
82
|
+
import Io from "./lazyLoadComponent.js";
|
|
83
83
|
import wo from "./requestIdleTask.js";
|
|
84
|
-
import
|
|
85
|
-
import
|
|
86
|
-
import
|
|
87
|
-
import
|
|
88
|
-
import
|
|
89
|
-
import
|
|
90
|
-
import
|
|
91
|
-
import
|
|
92
|
-
import
|
|
93
|
-
import
|
|
94
|
-
import
|
|
95
|
-
import
|
|
96
|
-
import
|
|
97
|
-
import
|
|
98
|
-
import
|
|
99
|
-
import
|
|
100
|
-
|
|
84
|
+
import No from "./rafThrottle.js";
|
|
85
|
+
import vo from "./scrollToTop.js";
|
|
86
|
+
import zo from "./scrollToElement.js";
|
|
87
|
+
import Fo from "./lockBodyScroll.js";
|
|
88
|
+
import Oo from "./unlockBodyScroll.js";
|
|
89
|
+
import qo from "./toggleFullscreen.js";
|
|
90
|
+
import xo from "./focusElement.js";
|
|
91
|
+
import Do from "./detectOutsideClick.js";
|
|
92
|
+
import Ro from "./measureElement.js";
|
|
93
|
+
import Go from "./announceToScreenReader.js";
|
|
94
|
+
import Jo from "./trapFocus.js";
|
|
95
|
+
import Qo from "./generateAriaId.js";
|
|
96
|
+
import Vo from "./handleKeyboardNavigation.js";
|
|
97
|
+
import Ko from "./logError.js";
|
|
98
|
+
import Mo from "./captureException.js";
|
|
99
|
+
import Uo from "./safeJSONParse.js";
|
|
100
|
+
import Wo from "./safeJSONStringify.js";
|
|
101
|
+
import jo from "./fallback.js";
|
|
102
|
+
import Ho from "./isAuthenticated.js";
|
|
103
|
+
import Xo from "./getToken.js";
|
|
104
|
+
import Yo from "./setToken.js";
|
|
105
|
+
import Zo from "./removeToken.js";
|
|
106
|
+
import _o from "./decodeJWT.js";
|
|
107
|
+
import $o from "./hasPermission.js";
|
|
108
|
+
import or from "./isFeatureEnabled.js";
|
|
109
|
+
import rr from "./getVariant.js";
|
|
110
|
+
import mr from "./retry.js";
|
|
111
|
+
import tr from "./sleep.js";
|
|
112
|
+
import ir from "./withTimeout.js";
|
|
113
|
+
import er from "./parallel.js";
|
|
114
|
+
import pr from "./sequential.js";
|
|
115
|
+
import fr from "./safeAsync.js";
|
|
116
|
+
import ar from "./cancelablePromise.js";
|
|
117
|
+
import nr from "./fuzzySearch.js";
|
|
118
|
+
import sr from "./filterByKey.js";
|
|
119
|
+
import lr from "./multiSort.js";
|
|
120
|
+
import cr from "./paginate.js";
|
|
121
|
+
import dr from "./fadeIn.js";
|
|
122
|
+
import ur from "./fadeOut.js";
|
|
123
|
+
import gr from "./smoothScroll.js";
|
|
124
|
+
import yr from "./waitForTransitionEnd.js";
|
|
125
|
+
import Sr from "./trackEvent.js";
|
|
126
|
+
import Tr from "./trackPageView.js";
|
|
127
|
+
import kr from "./measurePerformance.js";
|
|
128
|
+
import br from "./featureGate.js";
|
|
129
|
+
import hr from "./permissionGuard.js";
|
|
130
|
+
import Pr from "./auditLog.js";
|
|
131
|
+
import Er from "./logInfo.js";
|
|
132
|
+
import Cr from "./logWarn.js";
|
|
133
|
+
import Lr from "./once.js";
|
|
134
|
+
import Ar from "./noop.js";
|
|
135
|
+
import Br from "./identity.js";
|
|
136
|
+
import Ir from "./pipe.js";
|
|
137
|
+
import wr from "./singleton.js";
|
|
138
|
+
import Nr from "./createPubSub.js";
|
|
139
|
+
import vr from "./deepFreeze.js";
|
|
140
|
+
const ni = {
|
|
101
141
|
// string
|
|
102
142
|
capFirstLetter: o,
|
|
103
143
|
capitalize: r,
|
|
104
144
|
camelCase: m,
|
|
105
|
-
generateInitials:
|
|
145
|
+
generateInitials: d,
|
|
106
146
|
kebabCase: L,
|
|
107
|
-
maskEmail:
|
|
108
|
-
maskPhone:
|
|
109
|
-
removeExtraSpaces:
|
|
110
|
-
slugify:
|
|
111
|
-
snakeCase:
|
|
112
|
-
titleCase:
|
|
113
|
-
truncate:
|
|
147
|
+
maskEmail: B,
|
|
148
|
+
maskPhone: I,
|
|
149
|
+
removeExtraSpaces: x,
|
|
150
|
+
slugify: R,
|
|
151
|
+
snakeCase: G,
|
|
152
|
+
titleCase: V,
|
|
153
|
+
truncate: K,
|
|
114
154
|
// number
|
|
115
155
|
clamp: i,
|
|
116
156
|
formatCompactNumber: a,
|
|
117
|
-
formatCurrency:
|
|
118
|
-
formatNumber:
|
|
119
|
-
percentage:
|
|
120
|
-
randomBetween:
|
|
121
|
-
randomInt:
|
|
122
|
-
randomValue:
|
|
123
|
-
roundTo:
|
|
157
|
+
formatCurrency: n,
|
|
158
|
+
formatNumber: l,
|
|
159
|
+
percentage: v,
|
|
160
|
+
randomBetween: F,
|
|
161
|
+
randomInt: O,
|
|
162
|
+
randomValue: q,
|
|
163
|
+
roundTo: D,
|
|
124
164
|
// date-time
|
|
125
165
|
addDays: S,
|
|
126
166
|
countdown: T,
|
|
127
167
|
differenceInDays: k,
|
|
128
|
-
formatDate:
|
|
168
|
+
formatDate: s,
|
|
129
169
|
formatTime: c,
|
|
130
|
-
getGreetingByTime:
|
|
131
|
-
isPast:
|
|
132
|
-
isToday:
|
|
133
|
-
timeAgo:
|
|
170
|
+
getGreetingByTime: u,
|
|
171
|
+
isPast: E,
|
|
172
|
+
isToday: C,
|
|
173
|
+
timeAgo: Q,
|
|
134
174
|
// object / array
|
|
135
175
|
chunk: t,
|
|
136
176
|
compose: e,
|
|
@@ -140,18 +180,18 @@ const Rm = {
|
|
|
140
180
|
hasEqualProps: y,
|
|
141
181
|
isEmpty: b,
|
|
142
182
|
isEqual: h,
|
|
143
|
-
isNonEmptyArray:
|
|
144
|
-
keyBy:
|
|
183
|
+
isNonEmptyArray: P,
|
|
184
|
+
keyBy: A,
|
|
145
185
|
mergeDeep: w,
|
|
146
|
-
omit:
|
|
147
|
-
pick:
|
|
148
|
-
sortBy:
|
|
149
|
-
uniqueBy:
|
|
186
|
+
omit: N,
|
|
187
|
+
pick: z,
|
|
188
|
+
sortBy: J,
|
|
189
|
+
uniqueBy: M,
|
|
150
190
|
// validation
|
|
151
|
-
isEmail:
|
|
152
|
-
isPhone:
|
|
153
|
-
isURL:
|
|
154
|
-
isPasswordStrong:
|
|
191
|
+
isEmail: U,
|
|
192
|
+
isPhone: W,
|
|
193
|
+
isURL: j,
|
|
194
|
+
isPasswordStrong: H,
|
|
155
195
|
isPAN: X,
|
|
156
196
|
isAadhaar: Y,
|
|
157
197
|
isGST: Z,
|
|
@@ -167,10 +207,10 @@ const Rm = {
|
|
|
167
207
|
isOnline: po,
|
|
168
208
|
copyToClipboard: fo,
|
|
169
209
|
downloadFile: ao,
|
|
170
|
-
openInNewTab:
|
|
171
|
-
getScreenSize:
|
|
210
|
+
openInNewTab: no,
|
|
211
|
+
getScreenSize: so,
|
|
172
212
|
// routing
|
|
173
|
-
getQueryParams:
|
|
213
|
+
getQueryParams: lo,
|
|
174
214
|
setQueryParam: co,
|
|
175
215
|
removeQueryParam: uo,
|
|
176
216
|
buildURL: go,
|
|
@@ -181,34 +221,82 @@ const Rm = {
|
|
|
181
221
|
setLocalStorage: ko,
|
|
182
222
|
getLocalStorage: bo,
|
|
183
223
|
removeLocalStorage: ho,
|
|
184
|
-
setSessionStorage:
|
|
185
|
-
getSessionStorage:
|
|
186
|
-
clearStorage:
|
|
224
|
+
setSessionStorage: Po,
|
|
225
|
+
getSessionStorage: Eo,
|
|
226
|
+
clearStorage: Co,
|
|
187
227
|
// performance
|
|
188
228
|
debounce: Lo,
|
|
189
|
-
throttle:
|
|
190
|
-
memoize:
|
|
191
|
-
lazyLoadComponent:
|
|
229
|
+
throttle: Ao,
|
|
230
|
+
memoize: Bo,
|
|
231
|
+
lazyLoadComponent: Io,
|
|
192
232
|
requestIdleTask: wo,
|
|
193
|
-
rafThrottle:
|
|
233
|
+
rafThrottle: No,
|
|
194
234
|
// ui / dom
|
|
195
|
-
scrollToTop:
|
|
196
|
-
scrollToElement:
|
|
197
|
-
lockBodyScroll:
|
|
198
|
-
unlockBodyScroll:
|
|
199
|
-
toggleFullscreen:
|
|
200
|
-
focusElement:
|
|
201
|
-
detectOutsideClick:
|
|
202
|
-
measureElement:
|
|
235
|
+
scrollToTop: vo,
|
|
236
|
+
scrollToElement: zo,
|
|
237
|
+
lockBodyScroll: Fo,
|
|
238
|
+
unlockBodyScroll: Oo,
|
|
239
|
+
toggleFullscreen: qo,
|
|
240
|
+
focusElement: xo,
|
|
241
|
+
detectOutsideClick: Do,
|
|
242
|
+
measureElement: Ro,
|
|
243
|
+
// accessibility
|
|
244
|
+
announceToScreenReader: Go,
|
|
245
|
+
trapFocus: Jo,
|
|
246
|
+
generateAriaId: Qo,
|
|
247
|
+
handleKeyboardNavigation: Vo,
|
|
248
|
+
// error handling
|
|
249
|
+
logError: Ko,
|
|
250
|
+
captureException: Mo,
|
|
251
|
+
safeJSONParse: Uo,
|
|
252
|
+
safeJSONStringify: Wo,
|
|
253
|
+
fallback: jo,
|
|
254
|
+
// auth
|
|
255
|
+
isAuthenticated: Ho,
|
|
256
|
+
getToken: Xo,
|
|
257
|
+
setToken: Yo,
|
|
258
|
+
removeToken: Zo,
|
|
259
|
+
decodeJWT: _o,
|
|
260
|
+
hasPermission: $o,
|
|
261
|
+
// feature flags
|
|
262
|
+
isFeatureEnabled: or,
|
|
263
|
+
getVariant: rr,
|
|
203
264
|
// async / api
|
|
204
|
-
retry:
|
|
205
|
-
sleep:
|
|
206
|
-
withTimeout:
|
|
207
|
-
parallel:
|
|
208
|
-
sequential:
|
|
209
|
-
safeAsync:
|
|
210
|
-
cancelablePromise:
|
|
265
|
+
retry: mr,
|
|
266
|
+
sleep: tr,
|
|
267
|
+
withTimeout: ir,
|
|
268
|
+
parallel: er,
|
|
269
|
+
sequential: pr,
|
|
270
|
+
safeAsync: fr,
|
|
271
|
+
cancelablePromise: ar,
|
|
272
|
+
// filter
|
|
273
|
+
fuzzySearch: nr,
|
|
274
|
+
filterByKey: sr,
|
|
275
|
+
multiSort: lr,
|
|
276
|
+
paginate: cr,
|
|
277
|
+
// animation
|
|
278
|
+
fadeIn: dr,
|
|
279
|
+
fadeOut: ur,
|
|
280
|
+
smoothScroll: gr,
|
|
281
|
+
waitForTransitionEnd: yr,
|
|
282
|
+
// enterprise
|
|
283
|
+
trackEvent: Sr,
|
|
284
|
+
trackPageView: Tr,
|
|
285
|
+
measurePerformance: kr,
|
|
286
|
+
featureGate: br,
|
|
287
|
+
permissionGuard: hr,
|
|
288
|
+
auditLog: Pr,
|
|
289
|
+
logInfo: Er,
|
|
290
|
+
logWarn: Cr,
|
|
291
|
+
// function
|
|
292
|
+
once: Lr,
|
|
293
|
+
noop: Ar,
|
|
294
|
+
identity: Br,
|
|
295
|
+
pipe: Ir,
|
|
296
|
+
singleton: wr,
|
|
297
|
+
createPubSub: Nr,
|
|
298
|
+
deepFreeze: vr
|
|
211
299
|
};
|
|
212
300
|
export {
|
|
213
|
-
|
|
301
|
+
ni as default
|
|
214
302
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import o from "./getToken.js";
|
|
2
|
+
const s = (r = "auth_token") => {
|
|
3
|
+
const t = o(r);
|
|
4
|
+
if (!t) return !1;
|
|
5
|
+
try {
|
|
6
|
+
const [, n] = t.split("."), { exp: e } = JSON.parse(atob(n));
|
|
7
|
+
return !(e && Date.now() / 1e3 > e);
|
|
8
|
+
} catch {
|
|
9
|
+
return !!t;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
s as default
|
|
14
|
+
};
|
package/utils/logInfo.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const f = (e, t = {}) => {
|
|
2
|
+
var n;
|
|
3
|
+
const o = { level: "info", message: e, ...t, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4
|
+
return typeof window < "u" && typeof ((n = window.__logger) == null ? void 0 : n.info) == "function" ? window.__logger.info(o) : console.info("[logInfo]", o), o;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
f as default
|
|
8
|
+
};
|
package/utils/logWarn.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const r = (o, t = {}) => {
|
|
2
|
+
var e;
|
|
3
|
+
const n = { level: "warn", message: o, ...t, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4
|
+
return typeof window < "u" && typeof ((e = window.__logger) == null ? void 0 : e.warn) == "function" ? window.__logger.warn(n) : console.warn("[logWarn]", n), n;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
r as default
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const r = (o) => {
|
|
2
|
+
const e = typeof performance < "u" ? performance.getEntriesByName(o)[0] ?? null : null, n = {
|
|
3
|
+
metric: o,
|
|
4
|
+
duration: (e == null ? void 0 : e.duration) ?? null,
|
|
5
|
+
startTime: (e == null ? void 0 : e.startTime) ?? null,
|
|
6
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7
|
+
};
|
|
8
|
+
return typeof window < "u" && typeof window.__performanceReporter == "function" ? window.__performanceReporter(n) : console.log("[measurePerformance]", n), n;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
r as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const u = (f, s) => [...f].sort((o, r) => {
|
|
2
|
+
for (const { key: t, order: n = "asc" } of s) {
|
|
3
|
+
const c = typeof t == "function" ? t(o) : o[t], e = typeof t == "function" ? t(r) : r[t];
|
|
4
|
+
if (c < e) return n === "asc" ? -1 : 1;
|
|
5
|
+
if (c > e) return n === "asc" ? 1 : -1;
|
|
6
|
+
}
|
|
7
|
+
return 0;
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
u as default
|
|
11
|
+
};
|
package/utils/noop.js
ADDED
package/utils/once.js
ADDED
package/utils/pipe.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const u = (o, i = 500) => {
|
|
2
|
+
var t;
|
|
3
|
+
const e = window.scrollY, r = (typeof o == "number" ? o : ((t = o instanceof Element ? o : document.querySelector(o)) == null ? void 0 : t.getBoundingClientRect().top) + window.scrollY) - e;
|
|
4
|
+
let n = null;
|
|
5
|
+
const s = (c) => {
|
|
6
|
+
n || (n = c);
|
|
7
|
+
const d = c - n, l = Math.min(d / i, 1), a = 1 - Math.pow(1 - l, 3);
|
|
8
|
+
window.scrollTo(0, e + r * a), l < 1 && requestAnimationFrame(s);
|
|
9
|
+
};
|
|
10
|
+
requestAnimationFrame(s);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
u as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const a = (e, o = {}) => {
|
|
2
|
+
var n;
|
|
3
|
+
const t = { name: e, payload: o, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4
|
+
return typeof window < "u" && typeof ((n = window.__analytics) == null ? void 0 : n.track) == "function" ? window.__analytics.track(t) : console.log("[trackEvent]", t), t;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
a as default
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const o = (t) => {
|
|
2
|
+
var n;
|
|
3
|
+
const e = {
|
|
4
|
+
path: t,
|
|
5
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6
|
+
referrer: typeof document < "u" && document.referrer || null
|
|
7
|
+
};
|
|
8
|
+
return typeof window < "u" && typeof ((n = window.__analytics) == null ? void 0 : n.page) == "function" ? window.__analytics.page(e) : console.log("[trackPageView]", e), e;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
o as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const c = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])', d = (t) => {
|
|
2
|
+
const e = (t == null ? void 0 : t.current) ?? t;
|
|
3
|
+
if (!e) return () => {
|
|
4
|
+
};
|
|
5
|
+
const i = () => [...e.querySelectorAll(c)], s = (n) => {
|
|
6
|
+
if (n.key !== "Tab") return;
|
|
7
|
+
const o = i();
|
|
8
|
+
if (!o.length) return;
|
|
9
|
+
const r = o[0], a = o[o.length - 1];
|
|
10
|
+
n.shiftKey ? document.activeElement === r && (n.preventDefault(), a.focus()) : document.activeElement === a && (n.preventDefault(), r.focus());
|
|
11
|
+
};
|
|
12
|
+
return e.addEventListener("keydown", s), () => e.removeEventListener("keydown", s);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
d as default
|
|
16
|
+
};
|