@companix/uikit 0.1.42 → 0.1.44

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 (84) hide show
  1. package/dist/CounterInput/CounterInput.scss +29 -0
  2. package/dist/CounterInput/index.d.ts +14 -0
  3. package/dist/Select/index.d.ts +9 -1
  4. package/dist/bundle.es.js +122 -120
  5. package/dist/bundle.es10.js +1 -1
  6. package/dist/bundle.es13.js +82 -76
  7. package/dist/bundle.es14.js +4 -4
  8. package/dist/bundle.es15.js +2 -2
  9. package/dist/bundle.es16.js +1 -1
  10. package/dist/bundle.es17.js +1 -1
  11. package/dist/bundle.es18.js +105 -19
  12. package/dist/bundle.es19.js +21 -34
  13. package/dist/bundle.es20.js +33 -24
  14. package/dist/bundle.es21.js +24 -45
  15. package/dist/bundle.es22.js +46 -26
  16. package/dist/bundle.es23.js +24 -259
  17. package/dist/bundle.es24.js +260 -13
  18. package/dist/bundle.es25.js +14 -21
  19. package/dist/bundle.es26.js +20 -37
  20. package/dist/bundle.es27.js +38 -21
  21. package/dist/bundle.es28.js +20 -18
  22. package/dist/bundle.es29.js +18 -21
  23. package/dist/bundle.es30.js +21 -43
  24. package/dist/bundle.es31.js +37 -114
  25. package/dist/bundle.es32.js +119 -72
  26. package/dist/bundle.es33.js +68 -38
  27. package/dist/bundle.es34.js +42 -10
  28. package/dist/bundle.es35.js +11 -85
  29. package/dist/bundle.es36.js +85 -19
  30. package/dist/bundle.es37.js +20 -7
  31. package/dist/bundle.es38.js +7 -3
  32. package/dist/bundle.es39.js +3 -23
  33. package/dist/bundle.es40.js +16 -45
  34. package/dist/bundle.es41.js +51 -56
  35. package/dist/bundle.es42.js +57 -162
  36. package/dist/bundle.es43.js +160 -79
  37. package/dist/bundle.es44.js +81 -7
  38. package/dist/bundle.es45.js +7 -59
  39. package/dist/bundle.es46.js +58 -33
  40. package/dist/bundle.es47.js +33 -20
  41. package/dist/bundle.es48.js +19 -47
  42. package/dist/bundle.es49.js +49 -11
  43. package/dist/bundle.es50.js +11 -13
  44. package/dist/bundle.es51.js +13 -13
  45. package/dist/bundle.es52.js +13 -30
  46. package/dist/bundle.es53.js +30 -11
  47. package/dist/bundle.es54.js +10 -25
  48. package/dist/bundle.es55.js +17 -29
  49. package/dist/bundle.es56.js +36 -48
  50. package/dist/bundle.es57.js +49 -55
  51. package/dist/bundle.es58.js +56 -8
  52. package/dist/bundle.es59.js +8 -26
  53. package/dist/bundle.es60.js +27 -5
  54. package/dist/bundle.es61.js +5 -66
  55. package/dist/bundle.es62.js +66 -23
  56. package/dist/bundle.es63.js +22 -23
  57. package/dist/bundle.es64.js +24 -90
  58. package/dist/bundle.es65.js +90 -18
  59. package/dist/bundle.es66.js +17 -93
  60. package/dist/bundle.es67.js +93 -73
  61. package/dist/bundle.es68.js +73 -23
  62. package/dist/bundle.es69.js +20 -35
  63. package/dist/bundle.es70.js +39 -24
  64. package/dist/bundle.es71.js +24 -79
  65. package/dist/bundle.es72.js +71 -85
  66. package/dist/bundle.es73.js +93 -10
  67. package/dist/bundle.es74.js +10 -6
  68. package/dist/bundle.es75.js +5 -69
  69. package/dist/bundle.es76.js +68 -10
  70. package/dist/bundle.es77.js +11 -42
  71. package/dist/bundle.es78.js +42 -32
  72. package/dist/bundle.es79.js +31 -64
  73. package/dist/bundle.es80.js +65 -40
  74. package/dist/bundle.es81.js +40 -14
  75. package/dist/bundle.es82.js +15 -32
  76. package/dist/bundle.es83.js +23 -61
  77. package/dist/bundle.es84.js +69 -13
  78. package/dist/bundle.es85.js +13 -74
  79. package/dist/bundle.es86.js +71 -45
  80. package/dist/bundle.es87.js +48 -13
  81. package/dist/bundle.es88.js +16 -0
  82. package/dist/index.d.ts +3 -1
  83. package/dist/index.scss +1 -0
  84. package/package.json +1 -1
@@ -1,37 +1,62 @@
1
- import { jsx as h } from "react/jsx-runtime";
2
- import { useState as f, useEffect as i, createContext as w, useContext as v } from "react";
3
- import { getColorScheme as S, updateDOM as m } from "./bundle.es81.js";
4
- const d = w({
5
- setColorScheme: () => {
6
- }
7
- }), p = () => v(d), x = (u) => {
8
- const { fixed: c, defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = u, [r, a] = f(() => c ? o : S(n, o)), s = (e) => {
9
- c || (a(e), localStorage.setItem(n, e));
1
+ import { jsxs as b, jsx as i } from "react/jsx-runtime";
2
+ import y from "classnames";
3
+ import { useRef as F, useMemo as I, useState as o } from "react";
4
+ const C = (a) => {
5
+ const {
6
+ previewSrc: e,
7
+ maskHeight: s,
8
+ maskWidth: t,
9
+ className: m,
10
+ src: l,
11
+ children: d,
12
+ enableAspectRatio: g,
13
+ imgAttrs: p,
14
+ ...f
15
+ } = a, h = F(null), u = I(() => N(t, s), [t, s]), [r, v] = o(!1), [x, n] = o(!1), [w, c] = o(!1), $ = () => {
16
+ x && (n(!1), c(!1));
10
17
  };
11
- return i(() => {
12
- const e = window ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
13
- if (!e)
14
- return;
15
- const t = () => {
16
- r === "system" && m("system");
17
- };
18
- return e.addEventListener?.("change", t), t(), () => {
19
- e.removeEventListener?.("change", t);
20
- };
21
- }, [r]), i(() => {
22
- if (!window)
23
- return;
24
- const e = (t) => {
25
- t.key === n && (t.newValue ? a(t.newValue) : s(o));
26
- };
27
- return window.addEventListener("storage", e), () => {
28
- window.removeEventListener("storage", e);
29
- };
30
- }, [s, o]), i(() => {
31
- m(r);
32
- }, [r]), /* @__PURE__ */ h(d.Provider, { value: { colorScheme: r, setColorScheme: s }, children: l });
18
+ return /* @__PURE__ */ b(
19
+ "div",
20
+ {
21
+ className: y("image-base", { "image-base-loading": !r }, m),
22
+ style: g ? { aspectRatio: t / s } : {},
23
+ onClickCapture: $,
24
+ ...f,
25
+ children: [
26
+ !r && /* @__PURE__ */ i("img", { className: "image-base-placeholder", src: u, alt: "" }),
27
+ e && e !== l && !r && !w && /* @__PURE__ */ i(
28
+ "img",
29
+ {
30
+ className: "image-base-preview",
31
+ src: e,
32
+ style: { maxWidth: `${t}px`, maxHeight: `${s}px` },
33
+ loading: "lazy",
34
+ decoding: "async",
35
+ onError: () => c(!0),
36
+ alt: ""
37
+ }
38
+ ),
39
+ /* @__PURE__ */ i(
40
+ "img",
41
+ {
42
+ ref: h,
43
+ className: "image-base-img",
44
+ src: l,
45
+ decoding: "async",
46
+ onLoad: () => v(!0),
47
+ onError: () => n(!0),
48
+ ...p,
49
+ alt: ""
50
+ }
51
+ ),
52
+ d
53
+ ]
54
+ }
55
+ );
56
+ }, N = (a, e) => {
57
+ const s = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} ${e}" width="${a}" height="${e}" />`;
58
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`;
33
59
  };
34
60
  export {
35
- x as ThemeProvider,
36
- p as useTheme
61
+ C as ImageBase
37
62
  };
@@ -1,24 +1,37 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { memo as n } from "react";
3
- const i = n(({ storageKey: t, defaultColorScheme: o }) => /* @__PURE__ */ l(
4
- "script",
5
- {
6
- suppressHydrationWarning: !0,
7
- dangerouslySetInnerHTML: {
8
- __html: `(${a.toString()})("${t}", "${o}")`
9
- }
10
- }
11
- )), a = (t, o) => {
12
- const [r, c] = ["theme-light", "theme-dark"];
13
- try {
14
- let e = localStorage.getItem(t) || o;
15
- e === "system" && (e = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
16
- const s = e === "dark" ? c : r;
17
- document.documentElement.classList.remove(r, c), document.documentElement.classList.add(s), document.documentElement.style.colorScheme = e;
18
- } catch {
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import { useState as f, useEffect as i, createContext as w, useContext as v } from "react";
3
+ import { getColorScheme as S, updateDOM as m } from "./bundle.es82.js";
4
+ const d = w({
5
+ setColorScheme: () => {
19
6
  }
7
+ }), p = () => v(d), x = (u) => {
8
+ const { fixed: c, defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = u, [r, a] = f(() => c ? o : S(n, o)), s = (e) => {
9
+ c || (a(e), localStorage.setItem(n, e));
10
+ };
11
+ return i(() => {
12
+ const e = window ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
13
+ if (!e)
14
+ return;
15
+ const t = () => {
16
+ r === "system" && m("system");
17
+ };
18
+ return e.addEventListener?.("change", t), t(), () => {
19
+ e.removeEventListener?.("change", t);
20
+ };
21
+ }, [r]), i(() => {
22
+ if (!window)
23
+ return;
24
+ const e = (t) => {
25
+ t.key === n && (t.newValue ? a(t.newValue) : s(o));
26
+ };
27
+ return window.addEventListener("storage", e), () => {
28
+ window.removeEventListener("storage", e);
29
+ };
30
+ }, [s, o]), i(() => {
31
+ m(r);
32
+ }, [r]), /* @__PURE__ */ h(d.Provider, { value: { colorScheme: r, setColorScheme: s }, children: l });
20
33
  };
21
34
  export {
22
- i as ColorSchemeScript,
23
- a as colorSchemeScript
35
+ x as ThemeProvider,
36
+ p as useTheme
24
37
  };
@@ -1,52 +1,24 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { EventEmmiter as g } from "@companix/utils-js";
3
- import { useContext as S, createContext as l, useState as f, useEffect as n, useRef as w } from "react";
4
- const a = l({});
5
- class d {
6
- constructor(e) {
7
- this.emmiter = e;
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { memo as n } from "react";
3
+ const i = n(({ storageKey: t, defaultColorScheme: o }) => /* @__PURE__ */ l(
4
+ "script",
5
+ {
6
+ suppressHydrationWarning: !0,
7
+ dangerouslySetInnerHTML: {
8
+ __html: `(${a.toString()})("${t}", "${o}")`
9
+ }
8
10
  }
9
- getStorageValue(e, t) {
10
- if (typeof window > "u")
11
- return t;
12
- const r = localStorage.getItem(e);
13
- return r ? JSON.parse(r) : t;
11
+ )), a = (t, o) => {
12
+ const [r, c] = ["theme-light", "theme-dark"];
13
+ try {
14
+ let e = localStorage.getItem(t) || o;
15
+ e === "system" && (e = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
16
+ const s = e === "dark" ? c : r;
17
+ document.documentElement.classList.remove(r, c), document.documentElement.classList.add(s), document.documentElement.style.colorScheme = e;
18
+ } catch {
14
19
  }
15
- setValue(e, t) {
16
- localStorage.setItem(e, JSON.stringify(t)), this.emmiter.emit(e, t);
17
- }
18
- }
19
- const x = (o, e) => {
20
- const t = S(a), [r, i] = f(() => t.getStorageValue(o, e));
21
- n(() => {
22
- i(t.getStorageValue(o, e));
23
- }, [o]);
24
- const c = (s) => {
25
- t.setValue(o, s);
26
- };
27
- return n(() => {
28
- const s = t.emmiter.subscribe(o, (u) => {
29
- i(u);
30
- });
31
- return () => {
32
- s();
33
- };
34
- }, [o]), [r, c];
35
- }, y = ({ children: o }) => {
36
- const e = w(new d(new g()));
37
- return n(() => {
38
- if (!window || !e.current)
39
- return;
40
- const t = (r) => {
41
- r.key && e.current.emmiter.store[r.key] && r.newValue && e.current.emmiter.emit(r.key, JSON.parse(r.newValue));
42
- };
43
- return window.addEventListener("storage", t), () => {
44
- window.removeEventListener("storage", t);
45
- };
46
- }, []), /* @__PURE__ */ m(a.Provider, { value: e.current, children: o });
47
20
  };
48
21
  export {
49
- y as LocalStorageProvider,
50
- d as LocalStorageService,
51
- x as useLocalStorage
22
+ i as ColorSchemeScript,
23
+ a as colorSchemeScript
52
24
  };
@@ -1,14 +1,52 @@
1
- import { useState as r, useCallback as t } from "react";
2
- const f = (s = !1) => {
3
- const [o, e] = r(s), a = t(() => {
4
- e(!0);
5
- }, []), l = t(() => {
6
- e(!1);
7
- }, []), u = t(() => {
8
- e((n) => !n);
9
- }, []);
10
- return [o, a, l, u];
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { EventEmmiter as g } from "@companix/utils-js";
3
+ import { useContext as S, createContext as l, useState as f, useEffect as n, useRef as w } from "react";
4
+ const a = l({});
5
+ class d {
6
+ constructor(e) {
7
+ this.emmiter = e;
8
+ }
9
+ getStorageValue(e, t) {
10
+ if (typeof window > "u")
11
+ return t;
12
+ const r = localStorage.getItem(e);
13
+ return r ? JSON.parse(r) : t;
14
+ }
15
+ setValue(e, t) {
16
+ localStorage.setItem(e, JSON.stringify(t)), this.emmiter.emit(e, t);
17
+ }
18
+ }
19
+ const x = (o, e) => {
20
+ const t = S(a), [r, i] = f(() => t.getStorageValue(o, e));
21
+ n(() => {
22
+ i(t.getStorageValue(o, e));
23
+ }, [o]);
24
+ const c = (s) => {
25
+ t.setValue(o, s);
26
+ };
27
+ return n(() => {
28
+ const s = t.emmiter.subscribe(o, (u) => {
29
+ i(u);
30
+ });
31
+ return () => {
32
+ s();
33
+ };
34
+ }, [o]), [r, c];
35
+ }, y = ({ children: o }) => {
36
+ const e = w(new d(new g()));
37
+ return n(() => {
38
+ if (!window || !e.current)
39
+ return;
40
+ const t = (r) => {
41
+ r.key && e.current.emmiter.store[r.key] && r.newValue && e.current.emmiter.emit(r.key, JSON.parse(r.newValue));
42
+ };
43
+ return window.addEventListener("storage", t), () => {
44
+ window.removeEventListener("storage", t);
45
+ };
46
+ }, []), /* @__PURE__ */ m(a.Provider, { value: e.current, children: o });
11
47
  };
12
48
  export {
13
- f as useBooleanState
49
+ y as LocalStorageProvider,
50
+ d as LocalStorageService,
51
+ x as useLocalStorage
14
52
  };
@@ -1,16 +1,14 @@
1
- import { useRef as i, useCallback as o } from "react";
2
- const f = (e, s) => {
3
- const r = i(null), c = i(void 0), n = o(
4
- (t) => {
5
- s && t.offsetParent && (t.style.height = "", t.style.height = `${t.scrollHeight}px`, t.scrollHeight !== c.current && e && (e(t), c.current = t.scrollHeight));
6
- },
7
- [s, e]
8
- ), l = o(() => {
9
- const t = r.current;
10
- t && n(t);
11
- }, [r, n]);
12
- return [r, l];
1
+ import { useState as r, useCallback as t } from "react";
2
+ const f = (s = !1) => {
3
+ const [o, e] = r(s), a = t(() => {
4
+ e(!0);
5
+ }, []), l = t(() => {
6
+ e(!1);
7
+ }, []), u = t(() => {
8
+ e((n) => !n);
9
+ }, []);
10
+ return [o, a, l, u];
13
11
  };
14
12
  export {
15
- f as useResizeTextarea
13
+ f as useBooleanState
16
14
  };
@@ -1,16 +1,16 @@
1
- import { useState as e } from "react";
2
- const d = ({ onClick: t }) => {
3
- const [a, s] = e({ isLoading: !1, isError: !1 });
4
- return { ...a, handleClick: (r) => {
5
- a.isLoading || t(() => {
6
- s({ isLoading: !0, isError: !1 });
7
- }, r).then(() => {
8
- s({ isLoading: !1, isError: !1 });
9
- }).catch(() => {
10
- s({ isLoading: !1, isError: !0 });
11
- });
12
- } };
1
+ import { useRef as i, useCallback as o } from "react";
2
+ const f = (e, s) => {
3
+ const r = i(null), c = i(void 0), n = o(
4
+ (t) => {
5
+ s && t.offsetParent && (t.style.height = "", t.style.height = `${t.scrollHeight}px`, t.scrollHeight !== c.current && e && (e(t), c.current = t.scrollHeight));
6
+ },
7
+ [s, e]
8
+ ), l = o(() => {
9
+ const t = r.current;
10
+ t && n(t);
11
+ }, [r, n]);
12
+ return [r, l];
13
13
  };
14
14
  export {
15
- d as useLoading
15
+ f as useResizeTextarea
16
16
  };
@@ -1,33 +1,16 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { useState as w, useEffect as i, useRef as d, useCallback as f, createContext as C, useContext as b } from "react";
3
- const k = 6e4, a = C(null), g = ({ children: t }) => {
4
- const r = d(/* @__PURE__ */ new Map()), s = f(
5
- (e, c) => {
6
- let n = r.current.get(e);
7
- return n || (n = {
8
- intervalId: window.setInterval(() => {
9
- const o = Date.now();
10
- n?.callbacks.forEach((l) => l(o));
11
- }, e),
12
- callbacks: /* @__PURE__ */ new Set()
13
- }, r.current.set(e, n)), n.callbacks.add(c), () => {
14
- const o = r.current.get(e);
15
- o && (o.callbacks.delete(c), o.callbacks.size === 0 && (window.clearInterval(o.intervalId), r.current.delete(e)));
16
- };
17
- },
18
- []
19
- );
20
- return /* @__PURE__ */ u(a.Provider, { value: s, children: t });
21
- }, x = () => {
22
- const t = b(a);
23
- if (t === null)
24
- throw new Error("NowContextProvider is not provided");
25
- return t;
26
- }, p = (t = k) => {
27
- const [r, s] = w(() => Date.now()), e = x();
28
- return i(() => e(t, s), [t, e]), r;
1
+ import { useState as e } from "react";
2
+ const d = ({ onClick: t }) => {
3
+ const [a, s] = e({ isLoading: !1, isError: !1 });
4
+ return { ...a, handleClick: (r) => {
5
+ a.isLoading || t(() => {
6
+ s({ isLoading: !0, isError: !1 });
7
+ }, r).then(() => {
8
+ s({ isLoading: !1, isError: !1 });
9
+ }).catch(() => {
10
+ s({ isLoading: !1, isError: !0 });
11
+ });
12
+ } };
29
13
  };
30
14
  export {
31
- g as NowContextProvider,
32
- p as useNow
15
+ d as useLoading
33
16
  };
@@ -1,14 +1,33 @@
1
- import { useRef as o } from "react";
2
- import { useRerender as u } from "./bundle.es74.js";
3
- const m = (e) => {
4
- const t = u(), r = o(e);
5
- return [
6
- r.current,
7
- (n) => {
8
- r.current = n, t();
9
- }
10
- ];
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { useState as w, useEffect as i, useRef as d, useCallback as f, createContext as C, useContext as b } from "react";
3
+ const k = 6e4, a = C(null), g = ({ children: t }) => {
4
+ const r = d(/* @__PURE__ */ new Map()), s = f(
5
+ (e, c) => {
6
+ let n = r.current.get(e);
7
+ return n || (n = {
8
+ intervalId: window.setInterval(() => {
9
+ const o = Date.now();
10
+ n?.callbacks.forEach((l) => l(o));
11
+ }, e),
12
+ callbacks: /* @__PURE__ */ new Set()
13
+ }, r.current.set(e, n)), n.callbacks.add(c), () => {
14
+ const o = r.current.get(e);
15
+ o && (o.callbacks.delete(c), o.callbacks.size === 0 && (window.clearInterval(o.intervalId), r.current.delete(e)));
16
+ };
17
+ },
18
+ []
19
+ );
20
+ return /* @__PURE__ */ u(a.Provider, { value: s, children: t });
21
+ }, x = () => {
22
+ const t = b(a);
23
+ if (t === null)
24
+ throw new Error("NowContextProvider is not provided");
25
+ return t;
26
+ }, p = (t = k) => {
27
+ const [r, s] = w(() => Date.now()), e = x();
28
+ return i(() => e(t, s), [t, e]), r;
11
29
  };
12
30
  export {
13
- m as useSyncSubmit
31
+ g as NowContextProvider,
32
+ p as useNow
14
33
  };
@@ -1,29 +1,14 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { hash as m } from "@companix/utils-js";
3
- import { useRef as n, useMemo as s } from "react";
4
- import { Viewport as p } from "./bundle.es82.js";
5
- const a = (t = {}) => {
6
- const e = {
7
- emit: (r) => {
8
- console.error("uninitialized", r);
1
+ import { useRef as o } from "react";
2
+ import { useRerender as u } from "./bundle.es75.js";
3
+ const m = (e) => {
4
+ const t = u(), r = o(e);
5
+ return [
6
+ r.current,
7
+ (n) => {
8
+ r.current = n, t();
9
9
  }
10
- };
11
- return {
12
- api: {
13
- show: (r) => {
14
- e.emit({ ...r, id: m() });
15
- }
16
- },
17
- Viewport: () => {
18
- const r = n(null);
19
- return s(() => {
20
- e.emit = (o) => {
21
- r.current && r.current.showAlert(o);
22
- };
23
- }, []), /* @__PURE__ */ i(p, { ref: r, ...t });
24
- }
25
- };
10
+ ];
26
11
  };
27
12
  export {
28
- a as createAlertAgent
13
+ m as useSyncSubmit
29
14
  };
@@ -1,41 +1,29 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { hash as r } from "@companix/utils-js";
3
- import { Viewport as a } from "./bundle.es83.js";
4
- import { useRef as c, useMemo as h } from "react";
5
- const m = (i = {}) => {
6
- const o = {
7
- showToast: (e) => {
8
- console.error("uninitialized", e);
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { hash as m } from "@companix/utils-js";
3
+ import { useRef as n, useMemo as s } from "react";
4
+ import { Viewport as p } from "./bundle.es83.js";
5
+ const a = (t = {}) => {
6
+ const e = {
7
+ emit: (r) => {
8
+ console.error("uninitialized", r);
9
9
  }
10
10
  };
11
11
  return {
12
12
  api: {
13
- show: (e) => {
14
- const n = e.id ?? r();
15
- return o.showToast({ ...e, id: n }), n;
13
+ show: (r) => {
14
+ e.emit({ ...r, id: m() });
16
15
  }
17
16
  },
18
- Viewport: (e = {}) => {
19
- const n = c(null);
20
- return h(() => {
21
- o.showToast = (s) => {
22
- n.current && n.current.showToast(s);
17
+ Viewport: () => {
18
+ const r = n(null);
19
+ return s(() => {
20
+ e.emit = (o) => {
21
+ r.current && r.current.showAlert(o);
23
22
  };
24
- }, []), /* @__PURE__ */ t(
25
- a,
26
- {
27
- ref: n,
28
- align: e.align ?? i.align,
29
- closeIcon: e.closeIcon ?? i.closeIcon,
30
- duration: e.duration ?? i.duration,
31
- gap: e.gap ?? i.gap,
32
- side: e.side ?? i.side,
33
- swipeThreshold: e.swipeThreshold ?? i.swipeThreshold
34
- }
35
- );
23
+ }, []), /* @__PURE__ */ i(p, { ref: r, ...t });
36
24
  }
37
25
  };
38
26
  };
39
27
  export {
40
- m as createToaster
28
+ a as createAlertAgent
41
29
  };
@@ -1,53 +1,41 @@
1
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
- import * as t from "@radix-ui/react-toast";
3
- import { attr as T } from "@companix/utils-browser";
4
- import { useState as d, useRef as b, useEffect as j, useLayoutEffect as E } from "react";
5
- import { RemoveListener as I } from "./bundle.es60.js";
6
- const m = (o) => {
7
- const [r, u] = d(!0), [p, f] = d(!1), s = b(null), {
8
- appearance: C = "neutral",
9
- icon: a,
10
- title: n,
11
- description: c,
12
- duration: L,
13
- closeIcon: h,
14
- onClosing: v,
15
- onClosed: N,
16
- closable: x = !0,
17
- onInitialized: g
18
- } = o;
19
- j(() => {
20
- f(!0);
21
- }, []), E(() => {
22
- s.current && g(s.current);
23
- }, []);
24
- const R = (i) => {
25
- i || v(), u(i);
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { hash as r } from "@companix/utils-js";
3
+ import { Viewport as a } from "./bundle.es84.js";
4
+ import { useRef as c, useMemo as h } from "react";
5
+ const m = (i = {}) => {
6
+ const o = {
7
+ showToast: (e) => {
8
+ console.error("uninitialized", e);
9
+ }
26
10
  };
27
- return /* @__PURE__ */ l(
28
- t.Root,
29
- {
30
- ref: s,
31
- "data-expanded": !0,
32
- "data-appearance": C,
33
- "data-mounted": T(p),
34
- className: "toaster",
35
- open: r,
36
- onOpenChange: R,
37
- duration: L,
38
- children: [
39
- /* @__PURE__ */ e(I, { callback: N }),
40
- a && /* @__PURE__ */ e("div", { className: "toaster-icon", children: a }),
41
- /* @__PURE__ */ l("div", { className: "toaster-content", children: [
42
- n && /* @__PURE__ */ e(t.Title, { className: "toaster-title", children: n }),
43
- c && /* @__PURE__ */ e(t.Description, { className: "toaster-description", children: c })
44
- ] }),
45
- x && /* @__PURE__ */ e(m.Close, { className: "toaster-close toaster-close-placement", closeIcon: h })
46
- ]
11
+ return {
12
+ api: {
13
+ show: (e) => {
14
+ const n = e.id ?? r();
15
+ return o.showToast({ ...e, id: n }), n;
16
+ }
17
+ },
18
+ Viewport: (e = {}) => {
19
+ const n = c(null);
20
+ return h(() => {
21
+ o.showToast = (s) => {
22
+ n.current && n.current.showToast(s);
23
+ };
24
+ }, []), /* @__PURE__ */ t(
25
+ a,
26
+ {
27
+ ref: n,
28
+ align: e.align ?? i.align,
29
+ closeIcon: e.closeIcon ?? i.closeIcon,
30
+ duration: e.duration ?? i.duration,
31
+ gap: e.gap ?? i.gap,
32
+ side: e.side ?? i.side,
33
+ swipeThreshold: e.swipeThreshold ?? i.swipeThreshold
34
+ }
35
+ );
47
36
  }
48
- );
37
+ };
49
38
  };
50
- m.Close = ({ closeIcon: o, className: r } = {}) => /* @__PURE__ */ e(t.Close, { className: r, children: o ?? /* @__PURE__ */ e("svg", { viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M2.96967 2.96967C3.26256 2.67678 3.73744 2.67678 4.03033 2.96967L8 6.939L11.9697 2.96967C12.2626 2.67678 12.7374 2.67678 13.0303 2.96967C13.3232 3.26256 13.3232 3.73744 13.0303 4.03033L9.061 8L13.0303 11.9697C13.2966 12.2359 13.3208 12.6526 13.1029 12.9462L13.0303 13.0303C12.7374 13.3232 12.2626 13.3232 11.9697 13.0303L8 9.061L4.03033 13.0303C3.73744 13.3232 3.26256 13.3232 2.96967 13.0303C2.67678 12.7374 2.67678 12.2626 2.96967 11.9697L6.939 8L2.96967 4.03033C2.7034 3.76406 2.6792 3.3474 2.89705 3.05379L2.96967 2.96967Z" }) }) });
51
39
  export {
52
- m as Toast
40
+ m as createToaster
53
41
  };