meticulous-ui 3.2.8 → 3.2.9

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/hooks/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import o from "./usePrevious.js";
2
+ import r from "./useDebounce.js";
3
+ import e from "./useThrottle.js";
4
+ import m from "./useIsMounted.js";
5
+ import t from "./useEventListener.js";
6
+ import i from "./useIntersectionObserver.js";
7
+ import s from "./useMediaQuery.js";
8
+ import u from "./useLocalStorage.js";
9
+ import p from "./useSessionStorage.js";
10
+ import f from "./useOutsideClick.js";
11
+ import n from "./useWindowSize.js";
12
+ import a from "./useOnlineStatus.js";
13
+ import d from "./useCopyToClipboard.js";
14
+ import l from "./useToggle.js";
15
+ import c from "./useTimeout.js";
16
+ import S from "./useInterval.js";
17
+ import g from "./useUnmount.js";
18
+ import v from "./useFirstRender.js";
19
+ const R = {
20
+ // state
21
+ usePrevious: o,
22
+ useDebounce: r,
23
+ useThrottle: e,
24
+ useToggle: l,
25
+ // lifecycle
26
+ useIsMounted: m,
27
+ useUnmount: g,
28
+ useFirstRender: v,
29
+ useTimeout: c,
30
+ useInterval: S,
31
+ // dom / browser
32
+ useEventListener: t,
33
+ useIntersectionObserver: i,
34
+ useMediaQuery: s,
35
+ useOutsideClick: f,
36
+ useWindowSize: n,
37
+ useOnlineStatus: a,
38
+ // storage
39
+ useLocalStorage: u,
40
+ useSessionStorage: p,
41
+ // utility
42
+ useCopyToClipboard: d
43
+ };
44
+ export {
45
+ R as default
46
+ };
@@ -0,0 +1,14 @@
1
+ import { useState as a } from "react";
2
+ const c = () => {
3
+ const [e, t] = a(!1);
4
+ return [e, async (o) => {
5
+ try {
6
+ await navigator.clipboard.writeText(o), t(!0), setTimeout(() => t(!1), 2e3);
7
+ } catch {
8
+ t(!1);
9
+ }
10
+ }];
11
+ };
12
+ export {
13
+ c as default
14
+ };
@@ -0,0 +1,11 @@
1
+ import { useState as c, useEffect as n } from "react";
2
+ const d = (e, t) => {
3
+ const [o, s] = c(e);
4
+ return n(() => {
5
+ const u = setTimeout(() => s(e), t);
6
+ return () => clearTimeout(u);
7
+ }, [e, t]), o;
8
+ };
9
+ export {
10
+ d as default
11
+ };
@@ -0,0 +1,15 @@
1
+ import { useRef as o, useEffect as c } from "react";
2
+ const f = (r, s, e = window) => {
3
+ const t = o(s);
4
+ c(() => {
5
+ t.current = s;
6
+ }, [s]), c(() => {
7
+ const n = e && "current" in e ? e.current : e;
8
+ if (!(n != null && n.addEventListener)) return;
9
+ const u = (i) => t.current(i);
10
+ return n.addEventListener(r, u), () => n.removeEventListener(r, u);
11
+ }, [r, e]);
12
+ };
13
+ export {
14
+ f as default
15
+ };
@@ -0,0 +1,10 @@
1
+ import { useRef as r, useEffect as t } from "react";
2
+ const u = () => {
3
+ const e = r(!0);
4
+ return t(() => {
5
+ e.current = !1;
6
+ }, []), e.current;
7
+ };
8
+ export {
9
+ u as default
10
+ };
@@ -0,0 +1,13 @@
1
+ import { useState as u, useEffect as l } from "react";
2
+ const b = (r, e = {}) => {
3
+ const [s, o] = u(null);
4
+ return l(() => {
5
+ const t = r.current;
6
+ if (!t) return;
7
+ const n = new IntersectionObserver(([c]) => o(c), e);
8
+ return n.observe(t), () => n.disconnect();
9
+ }, [r, e.threshold, e.root, e.rootMargin]), s;
10
+ };
11
+ export {
12
+ b as default
13
+ };
@@ -0,0 +1,14 @@
1
+ import { useRef as u, useEffect as n } from "react";
2
+ const o = (e, r) => {
3
+ const t = u(e);
4
+ n(() => {
5
+ t.current = e;
6
+ }, [e]), n(() => {
7
+ if (r === null) return;
8
+ const s = setInterval(() => t.current(), r);
9
+ return () => clearInterval(s);
10
+ }, [r]);
11
+ };
12
+ export {
13
+ o as default
14
+ };
@@ -0,0 +1,10 @@
1
+ import { useRef as t, useEffect as r } from "react";
2
+ const s = () => {
3
+ const e = t(!1);
4
+ return r(() => (e.current = !0, () => {
5
+ e.current = !1;
6
+ }), []), e;
7
+ };
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,28 @@
1
+ import { useState as n } from "react";
2
+ const g = (e, o) => {
3
+ const [r, c] = n(() => {
4
+ try {
5
+ const t = localStorage.getItem(e);
6
+ return t !== null ? JSON.parse(t) : o;
7
+ } catch {
8
+ return o;
9
+ }
10
+ });
11
+ return [r, (t) => {
12
+ const s = typeof t == "function" ? t(r) : t;
13
+ c(s);
14
+ try {
15
+ localStorage.setItem(e, JSON.stringify(s));
16
+ } catch {
17
+ }
18
+ }, () => {
19
+ c(o);
20
+ try {
21
+ localStorage.removeItem(e);
22
+ } catch {
23
+ }
24
+ }];
25
+ };
26
+ export {
27
+ g as default
28
+ };
@@ -0,0 +1,11 @@
1
+ import { useState as o, useEffect as r } from "react";
2
+ const h = (e) => {
3
+ const [n, s] = o(() => window.matchMedia(e).matches);
4
+ return r(() => {
5
+ const t = window.matchMedia(e), a = (c) => s(c.matches);
6
+ return t.addEventListener("change", a), () => t.removeEventListener("change", a);
7
+ }, [e]), n;
8
+ };
9
+ export {
10
+ h as default
11
+ };
@@ -0,0 +1,13 @@
1
+ import { useState as o, useEffect as s } from "react";
2
+ const f = () => {
3
+ const [i, e] = o(navigator.onLine);
4
+ return s(() => {
5
+ const n = () => e(!0), t = () => e(!1);
6
+ return window.addEventListener("online", n), window.addEventListener("offline", t), () => {
7
+ window.removeEventListener("online", n), window.removeEventListener("offline", t);
8
+ };
9
+ }, []), i;
10
+ };
11
+ export {
12
+ f as default
13
+ };
@@ -0,0 +1,14 @@
1
+ import { useEffect as r } from "react";
2
+ const u = (e, n) => {
3
+ r(() => {
4
+ const t = (o) => {
5
+ e.current && !e.current.contains(o.target) && n(o);
6
+ };
7
+ return document.addEventListener("mousedown", t), document.addEventListener("touchstart", t), () => {
8
+ document.removeEventListener("mousedown", t), document.removeEventListener("touchstart", t);
9
+ };
10
+ }, [e, n]);
11
+ };
12
+ export {
13
+ u as default
14
+ };
@@ -0,0 +1,10 @@
1
+ import { useRef as t, useEffect as u } from "react";
2
+ const n = (r) => {
3
+ const e = t(void 0);
4
+ return u(() => {
5
+ e.current = r;
6
+ }), e.current;
7
+ };
8
+ export {
9
+ n as default
10
+ };
@@ -0,0 +1,28 @@
1
+ import { useState as c } from "react";
2
+ const g = (e, s) => {
3
+ const [o, r] = c(() => {
4
+ try {
5
+ const t = sessionStorage.getItem(e);
6
+ return t !== null ? JSON.parse(t) : s;
7
+ } catch {
8
+ return s;
9
+ }
10
+ });
11
+ return [o, (t) => {
12
+ const n = typeof t == "function" ? t(o) : t;
13
+ r(n);
14
+ try {
15
+ sessionStorage.setItem(e, JSON.stringify(n));
16
+ } catch {
17
+ }
18
+ }, () => {
19
+ r(s);
20
+ try {
21
+ sessionStorage.removeItem(e);
22
+ } catch {
23
+ }
24
+ }];
25
+ };
26
+ export {
27
+ g as default
28
+ };
@@ -0,0 +1,16 @@
1
+ import { useState as c, useRef as u, useEffect as i } from "react";
2
+ const f = (t, e) => {
3
+ const [r, n] = c(t), o = u(Date.now());
4
+ return i(() => {
5
+ const s = e - (Date.now() - o.current), a = setTimeout(
6
+ () => {
7
+ n(t), o.current = Date.now();
8
+ },
9
+ Math.max(0, s)
10
+ );
11
+ return () => clearTimeout(a);
12
+ }, [t, e]), r;
13
+ };
14
+ export {
15
+ f as default
16
+ };
@@ -0,0 +1,14 @@
1
+ import { useRef as s, useEffect as u } from "react";
2
+ const f = (e, t) => {
3
+ const r = s(e);
4
+ u(() => {
5
+ r.current = e;
6
+ }, [e]), u(() => {
7
+ if (t === null) return;
8
+ const o = setTimeout(() => r.current(), t);
9
+ return () => clearTimeout(o);
10
+ }, [t]);
11
+ };
12
+ export {
13
+ f as default
14
+ };
@@ -0,0 +1,10 @@
1
+ import { useState as u, useCallback as r } from "react";
2
+ const f = (o = !1) => {
3
+ const [t, a] = u(o), l = r((e) => {
4
+ a((s) => typeof e == "boolean" ? e : !s);
5
+ }, []);
6
+ return [t, l];
7
+ };
8
+ export {
9
+ f as default
10
+ };
@@ -0,0 +1,10 @@
1
+ import { useRef as u, useEffect as r } from "react";
2
+ const s = (e) => {
3
+ const t = u(e);
4
+ r(() => {
5
+ t.current = e;
6
+ }, [e]), r(() => () => t.current(), []);
7
+ };
8
+ export {
9
+ s as default
10
+ };
@@ -0,0 +1,14 @@
1
+ import { useState as t, useEffect as r } from "react";
2
+ const w = () => {
3
+ const [i, n] = t({
4
+ width: window.innerWidth,
5
+ height: window.innerHeight
6
+ });
7
+ return r(() => {
8
+ const e = () => n({ width: window.innerWidth, height: window.innerHeight });
9
+ return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
10
+ }, []), i;
11
+ };
12
+ export {
13
+ w as default
14
+ };
package/index.js CHANGED
@@ -23,7 +23,7 @@ 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
25
  import { default as Z } from "./hooks/index.js";
26
- import { default as $ } from "./react-utils/index.js";
26
+ import { default as $ } from "./reactUtils/index.js";
27
27
  import { default as eo } from "./components/Icons/index.js";
28
28
  export {
29
29
  I as Button,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meticulous-ui",
3
- "version": "3.2.8",
3
+ "version": "3.2.9",
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",
@@ -18,6 +18,8 @@
18
18
  "colors",
19
19
  "components",
20
20
  "utils",
21
+ "hooks",
22
+ "reactUtils",
21
23
  "package.json",
22
24
  "README.md"
23
25
  ],
@@ -0,0 +1,5 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ const d = (...e) => ({ children: o }) => e.reduceRight((r, s) => /* @__PURE__ */ t(s, { children: r }), o);
3
+ export {
4
+ d as default
5
+ };
@@ -0,0 +1,12 @@
1
+ import { createContext as n, useContext as s } from "react";
2
+ const i = (o) => {
3
+ const e = n(o), r = () => {
4
+ const t = s(e);
5
+ if (t === void 0) throw new Error("useContext must be used inside its Provider");
6
+ return t;
7
+ };
8
+ return [e.Provider, r];
9
+ };
10
+ export {
11
+ i as default
12
+ };
@@ -0,0 +1,7 @@
1
+ const d = (t = "div") => {
2
+ const e = document.createElement(t);
3
+ return document.body.appendChild(e), e;
4
+ };
5
+ export {
6
+ d as default
7
+ };
@@ -0,0 +1,19 @@
1
+ import o from "./createContextHook.js";
2
+ import r from "./composeProviders.js";
3
+ import m from "./lazyImport.js";
4
+ import t from "./withErrorBoundary.js";
5
+ import e from "./withSuspense.js";
6
+ import p from "./memoCompare.js";
7
+ import i from "./createPortalNode.js";
8
+ const u = {
9
+ createContextHook: o,
10
+ composeProviders: r,
11
+ lazyImport: m,
12
+ withErrorBoundary: t,
13
+ withSuspense: e,
14
+ memoCompare: p,
15
+ createPortalNode: i
16
+ };
17
+ export {
18
+ u as default
19
+ };
@@ -0,0 +1,7 @@
1
+ import { lazy as l } from "react";
2
+ const e = (o, t) => ({
3
+ [t]: l(() => o().then((a) => ({ default: a[t] })))
4
+ });
5
+ export {
6
+ e as default
7
+ };
@@ -0,0 +1,5 @@
1
+ import { memo as e } from "react";
2
+ const t = (m, o) => e(m, o);
3
+ export {
4
+ t as default
5
+ };
@@ -0,0 +1,24 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { Component as a } from "react";
3
+ class n extends a {
4
+ constructor(r) {
5
+ super(r), this.state = { hasError: !1, error: null };
6
+ }
7
+ static getDerivedStateFromError(r) {
8
+ return { hasError: !0, error: r };
9
+ }
10
+ render() {
11
+ if (this.state.hasError) {
12
+ const r = this.props.fallback;
13
+ return /* @__PURE__ */ o(r, { error: this.state.error });
14
+ }
15
+ return this.props.children;
16
+ }
17
+ }
18
+ const h = (t, r) => {
19
+ const s = (e) => /* @__PURE__ */ o(n, { fallback: r, children: /* @__PURE__ */ o(t, { ...e }) });
20
+ return s.displayName = `withErrorBoundary(${t.displayName ?? t.name ?? "Component"})`, s;
21
+ };
22
+ export {
23
+ h as default
24
+ };
@@ -0,0 +1,9 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { Suspense as u } from "react";
3
+ const r = (s, i = null) => {
4
+ const e = (n) => /* @__PURE__ */ t(u, { fallback: i, children: /* @__PURE__ */ t(s, { ...n }) });
5
+ return e.displayName = `withSuspense(${s.displayName ?? s.name ?? "Component"})`, e;
6
+ };
7
+ export {
8
+ r as default
9
+ };