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.
Files changed (44) hide show
  1. package/README.md +43 -13
  2. package/index.js +26 -22
  3. package/package.json +1 -1
  4. package/utils/announceToScreenReader.js +9 -0
  5. package/utils/auditLog.js +12 -0
  6. package/utils/captureException.js +12 -0
  7. package/utils/createPubSub.js +11 -0
  8. package/utils/decodeJWT.js +11 -0
  9. package/utils/deepFreeze.js +7 -0
  10. package/utils/fadeIn.js +10 -0
  11. package/utils/fadeOut.js +8 -0
  12. package/utils/fallback.js +4 -0
  13. package/utils/featureGate.js +4 -0
  14. package/utils/filterByKey.js +4 -0
  15. package/utils/fuzzySearch.js +16 -0
  16. package/utils/generateAriaId.js +5 -0
  17. package/utils/getToken.js +4 -0
  18. package/utils/getVariant.js +10 -0
  19. package/utils/handleKeyboardNavigation.js +17 -0
  20. package/utils/hasPermission.js +13 -0
  21. package/utils/identity.js +4 -0
  22. package/utils/index.js +200 -112
  23. package/utils/isAuthenticated.js +14 -0
  24. package/utils/isFeatureEnabled.js +10 -0
  25. package/utils/logError.js +7 -0
  26. package/utils/logInfo.js +8 -0
  27. package/utils/logWarn.js +8 -0
  28. package/utils/measurePerformance.js +12 -0
  29. package/utils/multiSort.js +11 -0
  30. package/utils/noop.js +5 -0
  31. package/utils/once.js +7 -0
  32. package/utils/paginate.js +13 -0
  33. package/utils/permissionGuard.js +4 -0
  34. package/utils/pipe.js +4 -0
  35. package/utils/removeToken.js +4 -0
  36. package/utils/safeJSONParse.js +10 -0
  37. package/utils/safeJSONStringify.js +10 -0
  38. package/utils/setToken.js +4 -0
  39. package/utils/singleton.js +7 -0
  40. package/utils/smoothScroll.js +14 -0
  41. package/utils/trackEvent.js +8 -0
  42. package/utils/trackPageView.js +12 -0
  43. package/utils/trapFocus.js +16 -0
  44. 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 | 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` |
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 d } from "./components/Spinner/Spinner.js";
4
- import { default as s } from "./components/Loader/Loader.js";
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 S } from "./components/Button/Button.js";
11
- import { default as h } from "./components/Timer/Timer.js";
12
- import { default as R } from "./components/Shimmer/Shimmer.js";
13
- import { default as w } from "./components/VideoPlayer/VideoPlayer.js";
14
- import { default as B } from "./components/Image/Image.js";
15
- import { default as F } from "./components/Carousel/Carousel.js";
16
- import { default as H } from "./components/Typography/Headings/index.js";
17
- import { default as U } from "./components/Typography/P/P.js";
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 "./components/Icons/index.js";
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
- S as Button,
28
- F as Carousel,
29
+ I as Button,
30
+ D as Carousel,
29
31
  A as Checkbox,
30
32
  c as Dropdown,
31
33
  M as FileUploader,
32
- H as Headings,
33
- B as Image,
34
+ G as Headings,
35
+ y as Image,
34
36
  j as Input,
35
- s as Loader,
37
+ d as Loader,
36
38
  n as OtpInput,
37
- U as P,
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
- R as Shimmer,
44
- d as Spinner,
45
+ L as Shimmer,
46
+ l as Spinner,
45
47
  v as Textarea,
46
- h as Timer,
48
+ b as Timer,
47
49
  r as Toast,
48
50
  f as ToastContainer,
49
- w as VideoPlayer,
51
+ U as VideoPlayer,
50
52
  Q as colors,
51
- Z as icons,
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.6",
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
+ };
@@ -0,0 +1,11 @@
1
+ const i = () => {
2
+ const u = {};
3
+ return { subscribe: (s, b) => ((u[s] ?? (u[s] = [])).push(b), () => {
4
+ u[s] = u[s].filter((c) => c !== b);
5
+ }), publish: (s, ...b) => {
6
+ (u[s] ?? []).forEach((c) => c(...b));
7
+ } };
8
+ };
9
+ export {
10
+ i as default
11
+ };
@@ -0,0 +1,11 @@
1
+ const e = (t) => {
2
+ try {
3
+ const [, a] = t.split(".");
4
+ return JSON.parse(atob(a));
5
+ } catch {
6
+ return null;
7
+ }
8
+ };
9
+ export {
10
+ e as default
11
+ };
@@ -0,0 +1,7 @@
1
+ const c = (e) => (Object.getOwnPropertyNames(e).forEach((r) => {
2
+ const t = e[r];
3
+ t && typeof t == "object" && c(t);
4
+ }), Object.freeze(e));
5
+ export {
6
+ c as default
7
+ };
@@ -0,0 +1,10 @@
1
+ const s = (a, t = 300) => {
2
+ a.style.opacity = "0", a.style.display = "", a.style.transition = `opacity ${t}ms ease`, requestAnimationFrame(() => {
3
+ requestAnimationFrame(() => {
4
+ a.style.opacity = "1";
5
+ });
6
+ });
7
+ };
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,8 @@
1
+ const a = (s, t = 300) => {
2
+ s.style.transition = `opacity ${t}ms ease`, s.style.opacity = "0", setTimeout(() => {
3
+ s.style.display = "none";
4
+ }, t);
5
+ };
6
+ export {
7
+ a as default
8
+ };
@@ -0,0 +1,4 @@
1
+ const f = (n, d) => n != null && n !== "" ? n : d;
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,4 @@
1
+ const a = (e) => typeof window < "u" && window.__featureFlags ? !!window.__featureFlags[e] : !1;
2
+ export {
3
+ a as default
4
+ };
@@ -0,0 +1,4 @@
1
+ const r = (e, t, f) => e.filter((l) => l[t] === f);
2
+ export {
3
+ r as default
4
+ };
@@ -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,5 @@
1
+ let a = 0;
2
+ const t = (e = "aria") => `${e}-${++a}`;
3
+ export {
4
+ t as default
5
+ };
@@ -0,0 +1,4 @@
1
+ const e = (t = "auth_token") => localStorage.getItem(t);
2
+ export {
3
+ e as default
4
+ };
@@ -0,0 +1,10 @@
1
+ const n = (t, a = "ab_variants") => {
2
+ try {
3
+ return JSON.parse(localStorage.getItem(a) ?? "{}")[t] ?? null;
4
+ } catch {
5
+ return null;
6
+ }
7
+ };
8
+ export {
9
+ n as default
10
+ };
@@ -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
+ };
@@ -0,0 +1,4 @@
1
+ const e = (t) => t;
2
+ export {
3
+ e as default
4
+ };
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 s from "./formatCurrency.js";
11
- import l from "./formatDate.js";
12
- import n from "./formatNumber.js";
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 u from "./generateInitials.js";
15
- import d from "./getGreetingByTime.js";
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 C from "./isNonEmptyArray.js";
24
- import P from "./isPast.js";
25
- import E from "./isToday.js";
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 B from "./keyBy.js";
28
- import A from "./maskEmail.js";
29
- import q from "./maskPhone.js";
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 I from "./omit.js";
32
- import D from "./percentage.js";
33
- import N from "./pick.js";
34
- import v from "./randomBetween.js";
35
- import x from "./randomInt.js";
36
- import z from "./randomValue.js";
37
- import O from "./removeExtraSpaces.js";
38
- import R from "./roundTo.js";
39
- import F from "./slugify.js";
40
- import Q from "./snakeCase.js";
41
- import G from "./sortBy.js";
42
- import M from "./timeAgo.js";
43
- import U from "./titleCase.js";
44
- import j from "./truncate.js";
45
- import V from "./uniqueBy.js";
46
- import H from "./isEmail.js";
47
- import J from "./isPhone.js";
48
- import K from "./isURL.js";
49
- import W from "./isPasswordStrong.js";
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 so from "./openInNewTab.js";
65
- import lo from "./getScreenSize.js";
66
- import no from "./getQueryParams.js";
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 Co from "./setSessionStorage.js";
77
- import Po from "./getSessionStorage.js";
78
- import Eo from "./clearStorage.js";
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 Bo from "./throttle.js";
81
- import Ao from "./memoize.js";
82
- import qo from "./lazyLoadComponent.js";
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 Io from "./rafThrottle.js";
85
- import Do from "./scrollToTop.js";
86
- import No from "./scrollToElement.js";
87
- import vo from "./lockBodyScroll.js";
88
- import xo from "./unlockBodyScroll.js";
89
- import zo from "./toggleFullscreen.js";
90
- import Oo from "./focusElement.js";
91
- import Ro from "./detectOutsideClick.js";
92
- import Fo from "./measureElement.js";
93
- import Qo from "./retry.js";
94
- import Go from "./sleep.js";
95
- import Mo from "./withTimeout.js";
96
- import Uo from "./parallel.js";
97
- import jo from "./sequential.js";
98
- import Vo from "./safeAsync.js";
99
- import Ho from "./cancelablePromise.js";
100
- const Rm = {
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: u,
145
+ generateInitials: d,
106
146
  kebabCase: L,
107
- maskEmail: A,
108
- maskPhone: q,
109
- removeExtraSpaces: O,
110
- slugify: F,
111
- snakeCase: Q,
112
- titleCase: U,
113
- truncate: j,
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: s,
118
- formatNumber: n,
119
- percentage: D,
120
- randomBetween: v,
121
- randomInt: x,
122
- randomValue: z,
123
- roundTo: R,
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: l,
168
+ formatDate: s,
129
169
  formatTime: c,
130
- getGreetingByTime: d,
131
- isPast: P,
132
- isToday: E,
133
- timeAgo: M,
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: C,
144
- keyBy: B,
183
+ isNonEmptyArray: P,
184
+ keyBy: A,
145
185
  mergeDeep: w,
146
- omit: I,
147
- pick: N,
148
- sortBy: G,
149
- uniqueBy: V,
186
+ omit: N,
187
+ pick: z,
188
+ sortBy: J,
189
+ uniqueBy: M,
150
190
  // validation
151
- isEmail: H,
152
- isPhone: J,
153
- isURL: K,
154
- isPasswordStrong: W,
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: so,
171
- getScreenSize: lo,
210
+ openInNewTab: no,
211
+ getScreenSize: so,
172
212
  // routing
173
- getQueryParams: no,
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: Co,
185
- getSessionStorage: Po,
186
- clearStorage: Eo,
224
+ setSessionStorage: Po,
225
+ getSessionStorage: Eo,
226
+ clearStorage: Co,
187
227
  // performance
188
228
  debounce: Lo,
189
- throttle: Bo,
190
- memoize: Ao,
191
- lazyLoadComponent: qo,
229
+ throttle: Ao,
230
+ memoize: Bo,
231
+ lazyLoadComponent: Io,
192
232
  requestIdleTask: wo,
193
- rafThrottle: Io,
233
+ rafThrottle: No,
194
234
  // ui / dom
195
- scrollToTop: Do,
196
- scrollToElement: No,
197
- lockBodyScroll: vo,
198
- unlockBodyScroll: xo,
199
- toggleFullscreen: zo,
200
- focusElement: Oo,
201
- detectOutsideClick: Ro,
202
- measureElement: Fo,
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: Qo,
205
- sleep: Go,
206
- withTimeout: Mo,
207
- parallel: Uo,
208
- sequential: jo,
209
- safeAsync: Vo,
210
- cancelablePromise: Ho
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
- Rm as default
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
+ };
@@ -0,0 +1,10 @@
1
+ const r = (e, t = "feature_flags") => {
2
+ try {
3
+ return JSON.parse(localStorage.getItem(t) ?? "{}")[e] === !0;
4
+ } catch {
5
+ return !1;
6
+ }
7
+ };
8
+ export {
9
+ r as default
10
+ };
@@ -0,0 +1,7 @@
1
+ const c = (s, n = {}) => {
2
+ const o = s instanceof Error ? s.message : String(s), t = s instanceof Error ? s.stack : void 0;
3
+ console.error("[logError]", o, { ...n, stack: t });
4
+ };
5
+ export {
6
+ c as default
7
+ };
@@ -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
+ };
@@ -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
@@ -0,0 +1,5 @@
1
+ const o = () => {
2
+ };
3
+ export {
4
+ o as default
5
+ };
package/utils/once.js ADDED
@@ -0,0 +1,7 @@
1
+ const u = (l) => {
2
+ let e = !1, t;
3
+ return (...r) => (e || (e = !0, t = l(...r)), t);
4
+ };
5
+ export {
6
+ u as default
7
+ };
@@ -0,0 +1,13 @@
1
+ const c = (a, s, t) => {
2
+ const e = a.length, o = Math.ceil(e / t), n = (s - 1) * t;
3
+ return {
4
+ data: a.slice(n, n + t),
5
+ total: e,
6
+ page: s,
7
+ limit: t,
8
+ totalPages: o
9
+ };
10
+ };
11
+ export {
12
+ c as default
13
+ };
@@ -0,0 +1,4 @@
1
+ const i = (r, e = []) => typeof window < "u" && Array.isArray(window.__userRoles) ? window.__userRoles.includes(r) : Array.isArray(e) && e.includes(r);
2
+ export {
3
+ i as default
4
+ };
package/utils/pipe.js ADDED
@@ -0,0 +1,4 @@
1
+ const c = (...e) => (p) => e.reduce((t, a) => a(t), p);
2
+ export {
3
+ c as default
4
+ };
@@ -0,0 +1,4 @@
1
+ const o = (e = "auth_token") => localStorage.removeItem(e);
2
+ export {
3
+ o as default
4
+ };
@@ -0,0 +1,10 @@
1
+ const t = (r, e = null) => {
2
+ try {
3
+ return JSON.parse(r);
4
+ } catch {
5
+ return e;
6
+ }
7
+ };
8
+ export {
9
+ t as default
10
+ };
@@ -0,0 +1,10 @@
1
+ const e = (t, r = "", n) => {
2
+ try {
3
+ return JSON.stringify(t, null, n);
4
+ } catch {
5
+ return r;
6
+ }
7
+ };
8
+ export {
9
+ e as default
10
+ };
@@ -0,0 +1,4 @@
1
+ const o = (t, e = "auth_token") => localStorage.setItem(e, t);
2
+ export {
3
+ o as default
4
+ };
@@ -0,0 +1,7 @@
1
+ const t = (n) => {
2
+ let e;
3
+ return () => (e === void 0 && (e = n()), e);
4
+ };
5
+ export {
6
+ t as default
7
+ };
@@ -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
+ };
@@ -0,0 +1,9 @@
1
+ const a = (n, t) => new Promise((i) => {
2
+ const e = (r) => {
3
+ t && r.propertyName !== t || (n.removeEventListener("transitionend", e), i(r));
4
+ };
5
+ n.addEventListener("transitionend", e);
6
+ });
7
+ export {
8
+ a as default
9
+ };