@companix/uikit 0.0.32 → 0.0.33

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 (49) hide show
  1. package/dist/ThemeProvider/script.d.ts +1 -0
  2. package/dist/bundle.es.js +30 -27
  3. package/dist/bundle.es10.js +2 -2
  4. package/dist/bundle.es11.js +1 -1
  5. package/dist/bundle.es12.js +1 -1
  6. package/dist/bundle.es14.js +1 -1
  7. package/dist/bundle.es18.js +1 -1
  8. package/dist/bundle.es19.js +1 -1
  9. package/dist/bundle.es20.js +1 -1
  10. package/dist/bundle.es23.js +1 -1
  11. package/dist/bundle.es24.js +3 -3
  12. package/dist/bundle.es25.js +4 -4
  13. package/dist/bundle.es26.js +2 -2
  14. package/dist/bundle.es29.js +2 -2
  15. package/dist/bundle.es32.js +13 -17
  16. package/dist/bundle.es33.js +21 -10
  17. package/dist/bundle.es34.js +10 -24
  18. package/dist/bundle.es35.js +17 -31
  19. package/dist/bundle.es36.js +36 -48
  20. package/dist/bundle.es37.js +49 -41
  21. package/dist/bundle.es38.js +42 -8
  22. package/dist/bundle.es39.js +8 -23
  23. package/dist/bundle.es40.js +24 -87
  24. package/dist/bundle.es41.js +87 -18
  25. package/dist/bundle.es42.js +16 -18
  26. package/dist/bundle.es43.js +20 -24
  27. package/dist/bundle.es44.js +20 -35
  28. package/dist/bundle.es45.js +39 -3
  29. package/dist/bundle.es46.js +3 -5
  30. package/dist/bundle.es47.js +5 -14
  31. package/dist/bundle.es48.js +13 -13
  32. package/dist/bundle.es49.js +14 -3
  33. package/dist/bundle.es50.js +3 -3
  34. package/dist/bundle.es51.js +3 -70
  35. package/dist/bundle.es52.js +68 -66
  36. package/dist/bundle.es53.js +67 -69
  37. package/dist/bundle.es54.js +69 -11
  38. package/dist/bundle.es55.js +11 -42
  39. package/dist/bundle.es56.js +42 -14
  40. package/dist/bundle.es57.js +11 -20
  41. package/dist/bundle.es59.js +1 -1
  42. package/dist/bundle.es60.js +20 -14
  43. package/dist/bundle.es61.js +2 -20
  44. package/dist/bundle.es62.js +14 -2
  45. package/dist/bundle.es68.js +2 -2
  46. package/dist/bundle.es69.js +2 -2
  47. package/dist/bundle.es9.js +4 -4
  48. package/dist/index.d.ts +1 -0
  49. package/package.json +1 -1
@@ -4,4 +4,5 @@ interface ColorSchemeScriptProps {
4
4
  defaultColorScheme: ColorSchemeExtendedType;
5
5
  }
6
6
  export declare const ColorSchemeScript: import('react').MemoExoticComponent<({ storageKey, defaultColorScheme }: ColorSchemeScriptProps) => import("react/jsx-runtime").JSX.Element>;
7
+ export declare const colorSchemeScript: (storageKey: string, defaultColorScheme: "light" | "dark") => void;
7
8
  export {};
package/dist/bundle.es.js CHANGED
@@ -3,17 +3,17 @@ import { ButtonGroup as p } from "./bundle.es3.js";
3
3
  import { Spinner as x } from "./bundle.es4.js";
4
4
  import { Scrollable as a } from "./bundle.es5.js";
5
5
  import { ImitateScroll as l } from "./bundle.es6.js";
6
- import { Popover as c } from "./bundle.es7.js";
6
+ import { Popover as n } from "./bundle.es7.js";
7
7
  import { Tooltip as u } from "./bundle.es8.js";
8
- import { Select as T } from "./bundle.es9.js";
9
- import { Input as D } from "./bundle.es10.js";
10
- import { OptionItem as P } from "./bundle.es11.js";
11
- import { NumberInput as h } from "./bundle.es12.js";
8
+ import { Select as g } from "./bundle.es9.js";
9
+ import { Input as h } from "./bundle.es10.js";
10
+ import { OptionItem as I } from "./bundle.es11.js";
11
+ import { NumberInput as d } from "./bundle.es12.js";
12
12
  import { OptionsList as v } from "./bundle.es13.js";
13
13
  import { Checkbox as B } from "./bundle.es14.js";
14
14
  import { Switch as k } from "./bundle.es15.js";
15
- import { Radio as y, RadioGroup as G } from "./bundle.es16.js";
16
- import { Drawer as O } from "./bundle.es17.js";
15
+ import { Radio as y, RadioGroup as C } from "./bundle.es16.js";
16
+ import { Drawer as L } from "./bundle.es17.js";
17
17
  import { Dialog as F } from "./bundle.es18.js";
18
18
  import { AlertDialog as j } from "./bundle.es19.js";
19
19
  import { LoadingButton as z } from "./bundle.es20.js";
@@ -29,38 +29,40 @@ import { TimePicker as to } from "./bundle.es29.js";
29
29
  import { Icon as mo } from "./bundle.es30.js";
30
30
  import { ProgressBar as fo } from "./bundle.es31.js";
31
31
  import { ThemeProvider as io, useTheme as lo } from "./bundle.es32.js";
32
- import { useLocalStorage as co } from "./bundle.es33.js";
33
- import { createAlertAgent as uo } from "./bundle.es34.js";
34
- import { createToaster as To } from "./bundle.es35.js";
35
- import { Toast as Do } from "./bundle.es36.js";
36
- import { DialogShell as Po, createDialogsRegistry as ho } from "./bundle.es37.js";
37
- import { createPopoversRegistry as vo } from "./bundle.es38.js";
32
+ import { ColorSchemeScript as no, colorSchemeScript as so } from "./bundle.es33.js";
33
+ import { useLocalStorage as So } from "./bundle.es34.js";
34
+ import { createAlertAgent as To } from "./bundle.es35.js";
35
+ import { createToaster as Do } from "./bundle.es36.js";
36
+ import { Toast as Po } from "./bundle.es37.js";
37
+ import { DialogShell as vo, createDialogsRegistry as Ao } from "./bundle.es38.js";
38
+ import { createPopoversRegistry as Ro } from "./bundle.es39.js";
38
39
  export {
39
40
  j as AlertDialog,
40
41
  e as Button,
41
42
  p as ButtonGroup,
42
43
  B as Checkbox,
44
+ no as ColorSchemeScript,
43
45
  K as Countdown,
44
46
  Z as DateInput,
45
47
  X as DatePicker,
46
48
  F as Dialog,
47
- Po as DialogShell,
48
- O as Drawer,
49
+ vo as DialogShell,
50
+ L as Drawer,
49
51
  $ as FileOverlay,
50
52
  ro as FormGroup,
51
53
  mo as Icon,
52
54
  l as ImitateScroll,
53
- D as Input,
55
+ h as Input,
54
56
  z as LoadingButton,
55
- h as NumberInput,
56
- P as OptionItem,
57
+ d as NumberInput,
58
+ I as OptionItem,
57
59
  v as OptionsList,
58
- c as Popover,
60
+ n as Popover,
59
61
  fo as ProgressBar,
60
62
  y as Radio,
61
- G as RadioGroup,
63
+ C as RadioGroup,
62
64
  a as Scrollable,
63
- T as Select,
65
+ g as Select,
64
66
  V as SelectTags,
65
67
  x as Spinner,
66
68
  k as Switch,
@@ -68,12 +70,13 @@ export {
68
70
  Q as TextArea,
69
71
  io as ThemeProvider,
70
72
  to as TimePicker,
71
- Do as Toast,
73
+ Po as Toast,
72
74
  u as Tooltip,
73
- uo as createAlertAgent,
74
- ho as createDialogsRegistry,
75
- vo as createPopoversRegistry,
76
- To as createToaster,
77
- co as useLocalStorage,
75
+ so as colorSchemeScript,
76
+ To as createAlertAgent,
77
+ Ao as createDialogsRegistry,
78
+ Ro as createPopoversRegistry,
79
+ Do as createToaster,
80
+ So as useLocalStorage,
78
81
  lo as useTheme
79
82
  };
@@ -1,8 +1,8 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { forwardRef as b, useRef as R } from "react";
3
3
  import { mergeRefs as c } from "react-merge-refs";
4
- import { InputElement as x } from "./bundle.es43.js";
5
- import { InputContainer as I } from "./bundle.es44.js";
4
+ import { InputElement as x } from "./bundle.es44.js";
5
+ import { InputContainer as I } from "./bundle.es45.js";
6
6
  import g from "classnames";
7
7
  const N = b(
8
8
  ({
@@ -3,7 +3,7 @@ import N from "classnames";
3
3
  import { Icon as v } from "./bundle.es30.js";
4
4
  import { attr as t } from "@companix/utils-browser";
5
5
  import { forwardRef as k } from "react";
6
- import { f as x } from "./bundle.es45.js";
6
+ import { f as x } from "./bundle.es46.js";
7
7
  const E = k(
8
8
  ({ title: s, icon: c, active: e, label: n, disabled: a, minimal: r, onClick: d, className: l, ...m }, p) => {
9
9
  const f = (h) => {
@@ -2,7 +2,7 @@ import { jsx as t } from "react/jsx-runtime";
2
2
  import C from "classnames";
3
3
  import { forwardRef as j, useRef as w } from "react";
4
4
  import { mergeRefs as y } from "react-merge-refs";
5
- import { InputContainer as F } from "./bundle.es44.js";
5
+ import { InputContainer as F } from "./bundle.es45.js";
6
6
  import { NumericFormat as V } from "react-number-format";
7
7
  const D = j(
8
8
  ({
@@ -1,7 +1,7 @@
1
1
  import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
2
  import * as t from "@radix-ui/react-checkbox";
3
3
  import { Icon as h } from "./bundle.es30.js";
4
- import { f as l } from "./bundle.es45.js";
4
+ import { f as l } from "./bundle.es46.js";
5
5
  import { useId as n } from "react";
6
6
  import { attr as c } from "@companix/utils-browser";
7
7
  const N = ({ checked: a, required: s, disabled: r, onCheckedChange: m, size: x, label: e }) => {
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
2
  import f from "classnames";
3
3
  import * as o from "@radix-ui/react-dialog";
4
4
  import { VisuallyHidden as a } from "@radix-ui/react-visually-hidden";
5
- import { RemoveListener as v } from "./bundle.es46.js";
5
+ import { RemoveListener as v } from "./bundle.es47.js";
6
6
  const g = (l) => {
7
7
  const { size: n = "s", open: r, onOpenChange: s, children: c, onClosed: t, disableEsc: p, className: d } = l, m = (h) => {
8
8
  p && h.preventDefault();
@@ -1,7 +1,7 @@
1
1
  import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
2
  import * as r from "@radix-ui/react-alert-dialog";
3
3
  import { Button as c } from "./bundle.es2.js";
4
- import { RemoveListener as N } from "./bundle.es46.js";
4
+ import { RemoveListener as N } from "./bundle.es47.js";
5
5
  import { VisuallyHidden as u } from "@radix-ui/react-visually-hidden";
6
6
  const C = ({
7
7
  open: d,
@@ -1,6 +1,6 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { Button as m } from "./bundle.es2.js";
3
- import { useLoading as p } from "./bundle.es47.js";
3
+ import { useLoading as p } from "./bundle.es48.js";
4
4
  const g = ({ onClick: o, appearance: r = "primary", ...i }) => {
5
5
  const { isLoading: n, isError: t, handleClick: a } = p({ onClick: o });
6
6
  return /* @__PURE__ */ e(
@@ -1,5 +1,5 @@
1
1
  import { jsx as f } from "react/jsx-runtime";
2
- import { useResizeTextarea as x } from "./bundle.es48.js";
2
+ import { useResizeTextarea as x } from "./bundle.es49.js";
3
3
  import { attr as e, callMultiple as u } from "@companix/utils-browser";
4
4
  import { useEffect as z } from "react";
5
5
  import { mergeRefs as R } from "react-merge-refs";
@@ -1,12 +1,12 @@
1
1
  import { jsx as o, jsxs as l } from "react/jsx-runtime";
2
- import { useFroozeClosing as M } from "./bundle.es39.js";
2
+ import { useFroozeClosing as M } from "./bundle.es40.js";
3
3
  import { Popover as j } from "./bundle.es7.js";
4
4
  import { OptionItem as q } from "./bundle.es11.js";
5
5
  import { OptionsList as V } from "./bundle.es13.js";
6
6
  import { Icon as d } from "./bundle.es30.js";
7
7
  import { useState as B, useRef as h, useMemo as g } from "react";
8
- import { f as H } from "./bundle.es49.js";
9
- import { f as Q } from "./bundle.es50.js";
8
+ import { f as H } from "./bundle.es50.js";
9
+ import { f as Q } from "./bundle.es51.js";
10
10
  import { attr as x, getActiveElementByAnotherElement as G, contains as J } from "@companix/utils-browser";
11
11
  import { mergeRefs as K } from "react-merge-refs";
12
12
  const se = (C) => {
@@ -2,11 +2,11 @@ import { jsx as u } from "react/jsx-runtime";
2
2
  import { Popover as T } from "./bundle.es7.js";
3
3
  import { Input as w } from "./bundle.es10.js";
4
4
  import { useState as A, useRef as j } from "react";
5
- import { Calendar as E } from "./bundle.es51.js";
6
- import { useDayDisableCheker as N } from "./bundle.es52.js";
5
+ import { Calendar as E } from "./bundle.es52.js";
6
+ import { useDayDisableCheker as N } from "./bundle.es53.js";
7
7
  import { getNum as h, formatTime as v } from "@companix/utils-js";
8
- import { removeDigits as O } from "./bundle.es53.js";
9
- import { SelectRightElements as Y } from "./bundle.es54.js";
8
+ import { removeDigits as O } from "./bundle.es54.js";
9
+ import { SelectRightElements as Y } from "./bundle.es55.js";
10
10
  const i = {
11
11
  char: "-",
12
12
  toString: (e) => {
@@ -1,8 +1,8 @@
1
1
  import { jsxs as D, jsx as h } from "react/jsx-runtime";
2
2
  import { useMemo as M, useEffect as C } from "react";
3
3
  import { Select as c } from "./bundle.es9.js";
4
- import { createDateValidation as O, getMonthMaxDay as T } from "./bundle.es53.js";
5
- import { defaultMin as j, defaultMax as N, useCalendarOptions as V } from "./bundle.es55.js";
4
+ import { createDateValidation as O, getMonthMaxDay as T } from "./bundle.es54.js";
5
+ import { defaultMin as j, defaultMax as N, useCalendarOptions as V } from "./bundle.es56.js";
6
6
  const B = ({
7
7
  min: o = j,
8
8
  max: e = N,
@@ -1,8 +1,8 @@
1
1
  import { jsx as g } from "react/jsx-runtime";
2
2
  import { useRef as _, useMemo as b, useState as P, useEffect as j } from "react";
3
3
  import { getNum as v } from "@companix/utils-js";
4
- import { getTimesOptions as D, getTimeValue as A, removeDigits as W, convertTimeToOption as q } from "./bundle.es53.js";
5
- import { SelectRightElements as w } from "./bundle.es54.js";
4
+ import { getTimesOptions as D, getTimeValue as A, removeDigits as W, convertTimeToOption as q } from "./bundle.es54.js";
5
+ import { SelectRightElements as w } from "./bundle.es55.js";
6
6
  import { Select as y } from "./bundle.es9.js";
7
7
  import { Input as z } from "./bundle.es10.js";
8
8
  const r = {
@@ -1,20 +1,19 @@
1
- import { jsxs as h, jsx as u } from "react/jsx-runtime";
2
- import { useState as f, useEffect as c, createContext as S, useContext as w } from "react";
3
- import { getColorScheme as v, updateDOM as i } from "./bundle.es56.js";
4
- import { ColorSchemeScript as C } from "./bundle.es57.js";
5
- const a = S({
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { useState as h, useEffect as c, createContext as f, useContext as w } from "react";
3
+ import { getColorScheme as v, updateDOM as m } from "./bundle.es57.js";
4
+ const i = f({
6
5
  setColorScheme: () => {
7
6
  }
8
- }), E = () => w(a), L = (d) => {
9
- const { defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = d, [r, m] = f(() => v(n, o)), s = (e) => {
10
- m(e), localStorage.setItem(n, e);
7
+ }), y = () => w(i), p = (d) => {
8
+ const { defaultColorScheme: o = "system", storageKey: n = "theme", children: l } = d, [r, a] = h(() => v(n, o)), s = (e) => {
9
+ a(e), localStorage.setItem(n, e);
11
10
  };
12
11
  return c(() => {
13
12
  const e = window ? window.matchMedia("(prefers-color-scheme: dark)") : void 0;
14
13
  if (!e)
15
14
  return;
16
15
  const t = () => {
17
- r === "system" && i("system");
16
+ r === "system" && m("system");
18
17
  };
19
18
  return e.addEventListener?.("change", t), t(), () => {
20
19
  e.removeEventListener?.("change", t);
@@ -23,19 +22,16 @@ const a = S({
23
22
  if (!window)
24
23
  return;
25
24
  const e = (t) => {
26
- t.key === n && (t.newValue ? m(t.newValue) : s(o));
25
+ t.key === n && (t.newValue ? a(t.newValue) : s(o));
27
26
  };
28
27
  return window.addEventListener("storage", e), () => {
29
28
  window.removeEventListener("storage", e);
30
29
  };
31
30
  }, [s, o]), c(() => {
32
- i(r);
33
- }, [r]), /* @__PURE__ */ h(a.Provider, { value: { colorScheme: r, setColorScheme: s }, children: [
34
- /* @__PURE__ */ u(C, { storageKey: n, defaultColorScheme: o }),
35
- l
36
- ] });
31
+ m(r);
32
+ }, [r]), /* @__PURE__ */ u(i.Provider, { value: { colorScheme: r, setColorScheme: s }, children: l });
37
33
  };
38
34
  export {
39
- L as ThemeProvider,
40
- E as useTheme
35
+ p as ThemeProvider,
36
+ y as useTheme
41
37
  };
@@ -1,13 +1,24 @@
1
- import { useState as s, useEffect as c } from "react";
2
- const l = (e, a) => {
3
- const [t, o] = s(() => {
4
- const r = localStorage.getItem(e);
5
- return r ? JSON.parse(r) : a;
6
- });
7
- return c(() => {
8
- localStorage.setItem(e, JSON.stringify(t));
9
- }, [t]), [t, o];
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 {
19
+ }
10
20
  };
11
21
  export {
12
- l as useLocalStorage
22
+ i as ColorSchemeScript,
23
+ a as colorSchemeScript
13
24
  };
@@ -1,27 +1,13 @@
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 u } from "./bundle.es58.js";
5
- const h = (t = {}) => {
6
- const e = {
7
- emit: (r) => {
8
- console.error("uninitialized", r);
9
- }
10
- };
11
- return {
12
- show: (r) => {
13
- e.emit({ ...r, id: m() });
14
- },
15
- Viewport: () => {
16
- const r = n(null);
17
- return s(() => {
18
- e.emit = (o) => {
19
- r.current && r.current.showAlert(o);
20
- };
21
- }, []), /* @__PURE__ */ i(u, { ref: r, ...t });
22
- }
23
- };
1
+ import { useState as s, useEffect as c } from "react";
2
+ const l = (e, a) => {
3
+ const [t, o] = s(() => {
4
+ const r = localStorage.getItem(e);
5
+ return r ? JSON.parse(r) : a;
6
+ });
7
+ return c(() => {
8
+ localStorage.setItem(e, JSON.stringify(t));
9
+ }, [t]), [t, o];
24
10
  };
25
11
  export {
26
- h as createAlertAgent
12
+ l as useLocalStorage
27
13
  };
@@ -1,41 +1,27 @@
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.es59.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 u } from "./bundle.es58.js";
5
+ const h = (t = {}) => {
6
+ const e = {
7
+ emit: (r) => {
8
+ console.error("uninitialized", r);
9
9
  }
10
10
  };
11
11
  return {
12
- api: {
13
- show: (e) => {
14
- const n = e.id ?? r();
15
- return o.showToast({ ...e, id: n }), n;
16
- }
12
+ show: (r) => {
13
+ e.emit({ ...r, id: m() });
17
14
  },
18
- Viewport: (e = {}) => {
19
- const n = c(null);
20
- return h(() => {
21
- o.showToast = (s) => {
22
- n.current && n.current.showToast(s);
15
+ Viewport: () => {
16
+ const r = n(null);
17
+ return s(() => {
18
+ e.emit = (o) => {
19
+ r.current && r.current.showAlert(o);
23
20
  };
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
- );
21
+ }, []), /* @__PURE__ */ i(u, { ref: r, ...t });
36
22
  }
37
23
  };
38
24
  };
39
25
  export {
40
- m as createToaster
26
+ h as createAlertAgent
41
27
  };
@@ -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.es46.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.es59.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
  };
@@ -1,45 +1,53 @@
1
- import { jsx as r, Fragment as m } from "react/jsx-runtime";
2
- import { useContext as C, createContext as g, useState as h, useEffect as x, useCallback as u } from "react";
3
- import { Dialog as D } from "./bundle.es18.js";
4
- import { hash as v } from "@companix/utils-js";
5
- const $ = (t) => {
6
- const e = {}, n = {}, l = [], c = v();
7
- for (const o in t)
8
- e[o] = () => {
9
- }, n[o] = () => {
10
- }, l.push(() => /* @__PURE__ */ r(O, { Open: e, Close: n, name: o, Content: t[o] }));
11
- return {
12
- Open: e,
13
- Close: n,
14
- Overlay: () => /* @__PURE__ */ r(m, { children: l.map((o, s) => /* @__PURE__ */ r(o, {}, `popup-${c}-${s}`)) })
15
- };
16
- }, O = ({ name: t, Open: e, Close: n, Content: l }) => {
17
- const [{ data: c, open: o }, s] = h({ data: null, open: !1 });
18
- x(() => {
19
- e[t] = (a) => {
20
- s({ data: a, open: !0 });
21
- }, n[t] = () => {
22
- o && p();
23
- };
24
- }, []);
25
- const p = u(() => {
26
- s(({ data: a }) => ({ data: a, open: !1 }));
27
- }, []), f = u(() => {
28
- s({ data: null, open: !1 });
29
- }, []), d = u((a) => {
30
- a || p();
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.es47.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);
31
23
  }, []);
32
- return c ? /* @__PURE__ */ r(i.Provider, { value: { open: o, onOpenChange: d, onClosed: f }, children: /* @__PURE__ */ r(l, { data: c, close: p }) }) : null;
33
- }, i = g(null), S = () => {
34
- const t = C(i);
35
- if (!t)
36
- throw new Error("Dialog context not provided");
37
- return t;
38
- }, b = ({ children: t, ...e }) => {
39
- const n = S();
40
- return /* @__PURE__ */ r(D, { ...n, ...e, children: t });
24
+ const R = (i) => {
25
+ i || v(), u(i);
26
+ };
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
+ ]
47
+ }
48
+ );
41
49
  };
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" }) }) });
42
51
  export {
43
- b as DialogShell,
44
- $ as createDialogsRegistry
52
+ m as Toast
45
53
  };