highsoft-ui 1.0.81 → 1.0.83

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.
@@ -1,11 +1,11 @@
1
1
  import * as r from "react";
2
- import { useState as C, useEffect as A } from "react";
3
- var N = (e, t, n, s, a, o, d, h) => {
2
+ import { useState as C, useEffect as A, useLayoutEffect as N } from "react";
3
+ var R = (e, t, n, s, o, a, d, h) => {
4
4
  let u = document.documentElement, v = ["light", "dark"];
5
5
  function f(c) {
6
6
  (Array.isArray(e) ? e : [e]).forEach((y) => {
7
- let E = y === "class", L = E && o ? a.map((b) => o[b] || b) : a;
8
- E ? (u.classList.remove(...L), u.classList.add(o && o[c] ? o[c] : c)) : u.setAttribute(y, c);
7
+ let E = y === "class", L = E && a ? o.map((b) => a[b] || b) : o;
8
+ E ? (u.classList.remove(...L), u.classList.add(a && a[c] ? a[c] : c)) : u.setAttribute(y, c);
9
9
  }), k(c);
10
10
  }
11
11
  function k(c) {
@@ -20,16 +20,16 @@ var N = (e, t, n, s, a, o, d, h) => {
20
20
  f(y);
21
21
  } catch {
22
22
  }
23
- }, P = ["light", "dark"], z = "(prefers-color-scheme: dark)", R = typeof window > "u", x = r.createContext(void 0), V = { setTheme: (e) => {
24
- }, themes: [] }, W = () => {
23
+ }, P = ["light", "dark"], z = "(prefers-color-scheme: dark)", V = typeof window > "u", x = r.createContext(void 0), W = { setTheme: (e) => {
24
+ }, themes: [] }, _ = () => {
25
25
  var e;
26
- return (e = r.useContext(x)) != null ? e : V;
27
- }, U = (e) => r.useContext(x) ? r.createElement(r.Fragment, null, e.children) : r.createElement($, { ...e }), _ = ["light", "dark"], $ = ({ forcedTheme: e, disableTransitionOnChange: t = !1, enableSystem: n = !0, enableColorScheme: s = !0, storageKey: a = "theme", themes: o = _, defaultTheme: d = n ? "system" : "light", attribute: h = "data-theme", value: u, children: v, nonce: f, scriptProps: k }) => {
28
- let [m, c] = r.useState(() => J(a, d)), [y, E] = r.useState(() => m === "system" ? M() : m), L = u ? Object.values(u) : o, b = r.useCallback((i) => {
26
+ return (e = r.useContext(x)) != null ? e : W;
27
+ }, G = (e) => r.useContext(x) ? r.createElement(r.Fragment, null, e.children) : r.createElement(F, { ...e }), $ = ["light", "dark"], F = ({ forcedTheme: e, disableTransitionOnChange: t = !1, enableSystem: n = !0, enableColorScheme: s = !0, storageKey: o = "theme", themes: a = $, defaultTheme: d = n ? "system" : "light", attribute: h = "data-theme", value: u, children: v, nonce: f, scriptProps: k }) => {
28
+ let [m, c] = r.useState(() => Q(o, d)), [y, E] = r.useState(() => m === "system" ? M() : m), L = u ? Object.values(u) : a, b = r.useCallback((i) => {
29
29
  let l = i;
30
30
  if (!l) return;
31
31
  i === "system" && n && (l = M());
32
- let g = u ? u[l] : l, I = t ? Q(f) : null, w = document.documentElement, O = (p) => {
32
+ let g = u ? u[l] : l, I = t ? Z(f) : null, w = document.documentElement, O = (p) => {
33
33
  p === "class" ? (w.classList.remove(...L), g && w.classList.add(g)) : p.startsWith("data-") && (g ? w.setAttribute(p, g) : w.removeAttribute(p));
34
34
  };
35
35
  if (Array.isArray(h) ? h.forEach(O) : O(h), s) {
@@ -41,7 +41,7 @@ var N = (e, t, n, s, a, o, d, h) => {
41
41
  let l = typeof i == "function" ? i(m) : i;
42
42
  c(l);
43
43
  try {
44
- localStorage.setItem(a, l);
44
+ localStorage.setItem(o, l);
45
45
  } catch {
46
46
  }
47
47
  }, [m]), S = r.useCallback((i) => {
@@ -53,26 +53,26 @@ var N = (e, t, n, s, a, o, d, h) => {
53
53
  return i.addListener(S), S(i), () => i.removeListener(S);
54
54
  }, [S]), r.useEffect(() => {
55
55
  let i = (l) => {
56
- l.key === a && (l.newValue ? c(l.newValue) : T(d));
56
+ l.key === o && (l.newValue ? c(l.newValue) : T(d));
57
57
  };
58
58
  return window.addEventListener("storage", i), () => window.removeEventListener("storage", i);
59
59
  }, [T]), r.useEffect(() => {
60
60
  b(e ?? m);
61
61
  }, [e, m]);
62
- let H = r.useMemo(() => ({ theme: m, setTheme: T, forcedTheme: e, resolvedTheme: m === "system" ? y : m, themes: n ? [...o, "system"] : o, systemTheme: n ? y : void 0 }), [m, T, e, y, n, o]);
63
- return r.createElement(x.Provider, { value: H }, r.createElement(F, { forcedTheme: e, storageKey: a, attribute: h, enableSystem: n, enableColorScheme: s, defaultTheme: d, value: u, themes: o, nonce: f, scriptProps: k }), v);
64
- }, F = r.memo(({ forcedTheme: e, storageKey: t, attribute: n, enableSystem: s, enableColorScheme: a, defaultTheme: o, value: d, themes: h, nonce: u, scriptProps: v }) => {
65
- let f = JSON.stringify([n, t, o, e, h, d, s, a]).slice(1, -1);
66
- return r.createElement("script", { ...v, suppressHydrationWarning: !0, nonce: typeof window > "u" ? u : "", dangerouslySetInnerHTML: { __html: `(${N.toString()})(${f})` } });
67
- }), J = (e, t) => {
68
- if (R) return;
62
+ let H = r.useMemo(() => ({ theme: m, setTheme: T, forcedTheme: e, resolvedTheme: m === "system" ? y : m, themes: n ? [...a, "system"] : a, systemTheme: n ? y : void 0 }), [m, T, e, y, n, a]);
63
+ return r.createElement(x.Provider, { value: H }, r.createElement(J, { forcedTheme: e, storageKey: o, attribute: h, enableSystem: n, enableColorScheme: s, defaultTheme: d, value: u, themes: a, nonce: f, scriptProps: k }), v);
64
+ }, J = r.memo(({ forcedTheme: e, storageKey: t, attribute: n, enableSystem: s, enableColorScheme: o, defaultTheme: a, value: d, themes: h, nonce: u, scriptProps: v }) => {
65
+ let f = JSON.stringify([n, t, a, e, h, d, s, o]).slice(1, -1);
66
+ return r.createElement("script", { ...v, suppressHydrationWarning: !0, nonce: typeof window > "u" ? u : "", dangerouslySetInnerHTML: { __html: `(${R.toString()})(${f})` } });
67
+ }), Q = (e, t) => {
68
+ if (V) return;
69
69
  let n;
70
70
  try {
71
71
  n = localStorage.getItem(e) || void 0;
72
72
  } catch {
73
73
  }
74
74
  return n || t;
75
- }, Q = (e) => {
75
+ }, Z = (e) => {
76
76
  let t = document.createElement("style");
77
77
  return e && t.setAttribute("nonce", e), t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")), document.head.appendChild(t), () => {
78
78
  window.getComputedStyle(document.body), setTimeout(() => {
@@ -80,28 +80,29 @@ var N = (e, t, n, s, a, o, d, h) => {
80
80
  }, 1);
81
81
  };
82
82
  }, M = (e) => (e || (e = window.matchMedia(z)), e.matches ? "dark" : "light");
83
- const Z = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
84
- function B(e) {
85
- return !!e.match(Z);
83
+ const j = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
84
+ function X(e) {
85
+ return !!e.match(j);
86
86
  }
87
- function G(e) {
87
+ function Y(e) {
88
88
  const [t, n] = C(!1);
89
89
  return A(() => {
90
90
  const s = window.matchMedia(e);
91
91
  n(s.matches);
92
- const a = (o) => {
93
- n(o.matches);
92
+ const o = (a) => {
93
+ n(a.matches);
94
94
  };
95
- return s.addEventListener("change", a), () => s.removeEventListener("change", a);
95
+ return s.addEventListener("change", o), () => s.removeEventListener("change", o);
96
96
  }, [e]), t;
97
97
  }
98
- function j() {
98
+ const D = typeof window < "u" ? N : A;
99
+ function U() {
99
100
  const [e, t] = C(!1);
100
- return A(() => {
101
+ return D(() => {
101
102
  t(!0);
102
103
  }, []), e;
103
104
  }
104
- function X() {
105
+ function q() {
105
106
  const [e, t] = C(!1);
106
107
  return [async (s) => {
107
108
  if (s)
@@ -112,27 +113,27 @@ function X() {
112
113
  }
113
114
  }, e];
114
115
  }
115
- function Y() {
116
- const e = j(), { resolvedTheme: t } = W(), [n, s] = C("light");
116
+ function ee() {
117
+ const e = U(), { resolvedTheme: t } = _(), [n, s] = C("light");
117
118
  return A(() => {
118
119
  if (!t) {
119
120
  s(document.documentElement.dataset.theme || "light");
120
- const a = new MutationObserver(() => {
121
+ const o = new MutationObserver(() => {
121
122
  s(document.documentElement.dataset.theme || "light");
122
123
  });
123
- return a.observe(document.documentElement, {
124
+ return o.observe(document.documentElement, {
124
125
  attributeFilter: ["data-theme"]
125
- }), () => a.disconnect();
126
+ }), () => o.disconnect();
126
127
  }
127
128
  }, [t]), e && t || n;
128
129
  }
129
130
  export {
130
- U as J,
131
- G as a,
132
- j as b,
133
- X as c,
134
- Z as e,
135
- Y as u,
136
- B as v,
137
- W as z
131
+ G as J,
132
+ Y as a,
133
+ U as b,
134
+ q as c,
135
+ j as e,
136
+ ee as u,
137
+ X as v,
138
+ _ as z
138
139
  };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { e as u, c as i, a as m, b as o, u as r, v as d } from "./utils-C7rfowvr.js";
1
+ import { e as u, c as i, a as m, b as o, u as r, v as d } from "./utils-CT0G9Gzw.js";
2
2
  import "react";
3
3
  export {
4
4
  u as emailRegex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "highsoft-ui",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "Highsoft UI",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",