@paciu/ui 0.0.59 → 0.0.60

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 (2) hide show
  1. package/dist/provider.es.js +40 -40
  2. package/package.json +1 -1
@@ -1,54 +1,54 @@
1
1
  "use client";
2
2
  import { jsxs as S, jsx as x } from "react/jsx-runtime";
3
- import { createContext as M, useState as m, useRef as j, useCallback as p, useMemo as v, useEffect as l, useContext as Q } from "react";
3
+ import { createContext as M, useState as m, useRef as j, useCallback as p, useMemo as O, useEffect as u, useContext as Q } from "react";
4
4
  import { createPortal as $ } from "react-dom";
5
- import { a as s, T as u, D as z, c as B, s as a } from "./chunks/index.es.js";
6
- const w = M(void 0), H = () => Q(w), Y = ({ children: c, initialTheme: f, defaultDialogPosition: O }) => {
7
- const [T, D] = m(!1), [r, L] = m(f || null), [d, k] = m(f || null), [o, g] = m([]), E = j(0), C = p((e) => {
5
+ import { a as o, T as a, D as z, c as B, s as l } from "./chunks/index.es.js";
6
+ const v = M(void 0), H = () => Q(v), Y = ({ children: c, initialTheme: f, defaultDialogPosition: w }) => {
7
+ const [T, D] = m(!1), [r, L] = m(f || null), [d, k] = m(f || null), [s, g] = m([]), E = j(0), C = p((e) => {
8
8
  document.documentElement.dataset.theme = e || void 0, L(e);
9
9
  }, []), y = p((e, n) => {
10
10
  g((t) => {
11
11
  if (t.length > 0) {
12
12
  const i = [...t], I = i.length - 1;
13
- if (i[I].status === s.Opening)
13
+ if (i[I].status === o.Opening)
14
14
  return t;
15
15
  }
16
- return [...t, { id: ++E.current, status: s.Opening, node: e, options: n }];
16
+ return [...t, { id: ++E.current, status: o.Opening, node: e, options: n }];
17
17
  });
18
18
  }, []), h = p((e) => {
19
19
  g((n) => {
20
20
  if (n.length === 0)
21
21
  return n;
22
22
  const t = [...n], i = t.length - 1;
23
- return t[i].status === s.Closing || (e?.esc || e?.outside) && t[i]?.options?.unClosable ? n : (t[i] = { ...t[i], status: s.Closing }, t);
23
+ return [o.Closing, o.Opening].includes(t[i].status) || (e?.esc || e?.outside) && t[i]?.options?.unClosable ? n : (t[i] = { ...t[i], status: o.Closing }, t);
24
24
  });
25
- }, []), P = v(() => {
25
+ }, []), P = O(() => {
26
26
  const e = r || d;
27
- return e ? e === u.Light ? u.Dark : u.Light : null;
28
- }, [r, d]), b = v(
29
- () => ({ theme: r, nextTheme: P, systemTheme: d, toggleTheme: C, openDialog: y, closeDialog: h, dialogsQueue: o }),
30
- [r, P, d, C, y, h, o]
27
+ return e ? e === a.Light ? a.Dark : a.Light : null;
28
+ }, [r, d]), b = O(
29
+ () => ({ theme: r, nextTheme: P, systemTheme: d, toggleTheme: C, openDialog: y, closeDialog: h, dialogsQueue: s }),
30
+ [r, P, d, C, y, h, s]
31
31
  );
32
- return l(() => {
33
- if (o.length) {
34
- const e = o[o.length - 1];
35
- e.status === s.Opening && (e?.options?.onOpen && e.options.onOpen(), setTimeout(() => {
32
+ return u(() => {
33
+ if (s.length) {
34
+ const e = s[s.length - 1];
35
+ e.status === o.Opening && (e?.options?.onOpen && e.options.onOpen(), setTimeout(() => {
36
36
  g((n) => {
37
37
  const t = [...n];
38
- return t[t.length - 1].status = s.Opened, t;
38
+ return t[t.length - 1].status = o.Opened, t;
39
39
  }), e?.options?.onOpened && e.options.onOpened();
40
- }, 240)), e.status === s.Closing && (e?.options?.onClose && e.options.onClose(), setTimeout(() => {
40
+ }, 240)), e.status === o.Closing && (e?.options?.onClose && e.options.onClose(), setTimeout(() => {
41
41
  g((n) => n.slice(0, -1)), e?.options?.onClosed && e.options.onClosed();
42
42
  }, 240));
43
43
  }
44
- }, [o]), l(() => {
44
+ }, [s]), u(() => {
45
45
  const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (t) => {
46
- k(t.matches ? u.Dark : u.Light);
46
+ k(t.matches ? a.Dark : a.Light);
47
47
  };
48
48
  return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
49
- }, []), l(() => {
50
- document.body.style.overflowY = o.length ? "hidden" : "";
51
- }, [o]), l(() => {
49
+ }, []), u(() => {
50
+ document.body.style.overflowY = s.length ? "hidden" : "";
51
+ }, [s]), u(() => {
52
52
  const e = (i) => {
53
53
  i.key === "Escape" && (i.stopPropagation(), h({ esc: !0 }));
54
54
  }, n = () => {
@@ -59,35 +59,35 @@ const w = M(void 0), H = () => Q(w), Y = ({ children: c, initialTheme: f, defaul
59
59
  return n(), () => {
60
60
  t();
61
61
  };
62
- }, []), l(() => {
62
+ }, []), u(() => {
63
63
  D(!0);
64
- }), /* @__PURE__ */ S(w.Provider, { value: b, children: [
64
+ }), /* @__PURE__ */ S(v.Provider, { value: b, children: [
65
65
  c,
66
66
  T && $(
67
- /* @__PURE__ */ x("div", { id: "paciu-ui-dialogs", children: o.map((e, n) => {
68
- const t = e?.options?.position || O || z.Center;
67
+ /* @__PURE__ */ x("div", { id: "paciu-ui-dialogs", children: s.map((e, n) => {
68
+ const t = e?.options?.position || w || z.Center;
69
69
  return /* @__PURE__ */ x(
70
70
  "div",
71
71
  {
72
- className: B(a["dialog-overlay"], {
73
- [a["animated-opening"]]: [
74
- s.Opening,
75
- s.Opened
72
+ className: B(l["dialog-overlay"], {
73
+ [l["animated-opening"]]: [
74
+ o.Opening,
75
+ o.Opened
76
76
  ].includes(e.status),
77
- [a["animated-closing"]]: [
78
- s.Closing,
79
- s.Closed
77
+ [l["animated-closing"]]: [
78
+ o.Closing,
79
+ o.Closed
80
80
  ].includes(e.status),
81
- [a.active]: n === o.length - 1,
82
- [a["full-height"]]: e?.options?.fullHeight,
83
- [a["full-width"]]: e?.options?.fullWidth,
84
- [a["un-closable"]]: e?.options?.unClosable,
85
- [a[`position-${t}`]]: !!t
81
+ [l.active]: n === s.length - 1,
82
+ [l["full-height"]]: e?.options?.fullHeight,
83
+ [l["full-width"]]: e?.options?.fullWidth,
84
+ [l["un-closable"]]: e?.options?.unClosable,
85
+ [l[`position-${t}`]]: !!t
86
86
  }),
87
87
  onClick: () => h({ outside: !0 }),
88
88
  style: {
89
89
  zIndex: n + 1e3,
90
- transform: `scale(calc(1 - ${(o.length - n - 1) * 0.02}))`
90
+ transform: `scale(calc(1 - ${(s.length - n - 1) * 0.02}))`
91
91
  },
92
92
  children: e.node()
93
93
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paciu/ui",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",