@companix/uikit 0.0.63 → 0.0.64

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,27 +1,35 @@
1
- import { jsxs as d, jsx as c } from "react/jsx-runtime";
2
- import * as r from "@radix-ui/react-switch";
3
- import { attr as a } from "@companix/utils-browser";
1
+ import { jsxs as x, jsx as o } from "react/jsx-runtime";
2
+ import * as t from "@radix-ui/react-checkbox";
3
+ import { Icon as h } from "./bundle.es33.js";
4
+ import { faCheck as l } from "@companix/icons-solid";
4
5
  import { useId as n } from "react";
5
- const u = (m) => {
6
- const { checked: e, disabled: s, onCheckedChange: o, uncheckedIcon: i, checkedIcon: t, label: h } = m, l = n();
7
- return /* @__PURE__ */ d("div", { className: "switch", "data-disabled": a(s), children: [
8
- /* @__PURE__ */ c(
9
- r.Root,
10
- {
11
- className: "switch-track",
12
- checked: e,
13
- onCheckedChange: o,
14
- disabled: s,
15
- id: l,
16
- children: /* @__PURE__ */ d(r.Thumb, { className: "switch-thumb", children: [
17
- i && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(!e), children: i }),
18
- t && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(e), children: t })
19
- ] })
20
- }
21
- ),
22
- h && /* @__PURE__ */ c("label", { className: "switch-label", htmlFor: l, "data-disabled": s, children: h })
23
- ] });
6
+ import { attr as c } from "@companix/utils-browser";
7
+ const u = ({ checked: e, required: m, disabled: r, onCheckedChange: s, size: d, label: a }) => {
8
+ const i = n();
9
+ return /* @__PURE__ */ x(
10
+ "div",
11
+ {
12
+ className: "checkbox",
13
+ "data-size": d ?? "md",
14
+ "data-required": c(m && !e),
15
+ "data-disabled": c(r),
16
+ children: [
17
+ /* @__PURE__ */ o(
18
+ t.Root,
19
+ {
20
+ className: "checkbox-box",
21
+ checked: e,
22
+ onCheckedChange: s,
23
+ disabled: r,
24
+ id: i,
25
+ children: /* @__PURE__ */ o(t.Indicator, { className: "checkbox-icon", children: /* @__PURE__ */ o(h, { icon: l, size: "xxxs" }) })
26
+ }
27
+ ),
28
+ a && /* @__PURE__ */ o("label", { className: "checkbox-label", htmlFor: i, "data-disabled": c(r), children: a })
29
+ ]
30
+ }
31
+ );
24
32
  };
25
33
  export {
26
- u as Switch
34
+ u as Checkbox
27
35
  };
@@ -1,47 +1,27 @@
1
- import { jsxs as u, jsx as o } from "react/jsx-runtime";
2
- import { useId as p } from "react";
3
- import * as l from "@radix-ui/react-radio-group";
4
- import { attr as s } from "@companix/utils-browser";
5
- const q = (t) => {
6
- const { options: m, value: a, onChange: r, disabled: d, required: e, size: n } = t;
7
- return /* @__PURE__ */ o(
8
- l.Root,
9
- {
10
- className: "radio-group",
11
- disabled: d,
12
- "data-required": s(e && !a),
13
- "data-v": a,
14
- value: a,
15
- onValueChange: (i) => r(i),
16
- children: m.map((i, c) => /* @__PURE__ */ o(
17
- h,
18
- {
19
- ...i,
20
- size: n,
21
- disabled: d,
22
- required: e && !a
23
- },
24
- `radio-${i.value}-${c}`
25
- ))
26
- }
27
- );
28
- }, h = ({ value: t, label: m, size: a = "md", disabled: r, required: d }) => {
29
- const e = p();
30
- return /* @__PURE__ */ u(
31
- "span",
32
- {
33
- className: "radio",
34
- "data-disabled": s(r),
35
- "data-size": a,
36
- "data-required": s(d),
37
- children: [
38
- /* @__PURE__ */ o(l.Item, { className: "radio-box", value: t, disabled: r, id: e, children: /* @__PURE__ */ o(l.Indicator, { className: "radio-mark" }) }),
39
- /* @__PURE__ */ o("label", { className: "radio-label", htmlFor: e, "data-disabled": s(r), children: m })
40
- ]
41
- }
42
- );
1
+ import { jsxs as d, jsx as c } from "react/jsx-runtime";
2
+ import * as r from "@radix-ui/react-switch";
3
+ import { attr as a } from "@companix/utils-browser";
4
+ import { useId as n } from "react";
5
+ const u = (m) => {
6
+ const { checked: e, disabled: s, onCheckedChange: o, uncheckedIcon: i, checkedIcon: t, label: h } = m, l = n();
7
+ return /* @__PURE__ */ d("div", { className: "switch", "data-disabled": a(s), children: [
8
+ /* @__PURE__ */ c(
9
+ r.Root,
10
+ {
11
+ className: "switch-track",
12
+ checked: e,
13
+ onCheckedChange: o,
14
+ disabled: s,
15
+ id: l,
16
+ children: /* @__PURE__ */ d(r.Thumb, { className: "switch-thumb", children: [
17
+ i && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(!e), children: i }),
18
+ t && /* @__PURE__ */ c("span", { className: "switch-thumb-icon", "data-visible": a(e), children: t })
19
+ ] })
20
+ }
21
+ ),
22
+ h && /* @__PURE__ */ c("label", { className: "switch-label", htmlFor: l, "data-disabled": s, children: h })
23
+ ] });
43
24
  };
44
25
  export {
45
- h as Radio,
46
- q as RadioGroup
26
+ u as Switch
47
27
  };
@@ -1,25 +1,47 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import c from "classnames";
3
- import * as r from "@radix-ui/react-dialog";
4
- import { VisuallyHidden as i } from "@radix-ui/react-visually-hidden";
5
- import { customCSS as d } from "@companix/utils-browser";
6
- const p = ({ open: t, onOpenChange: l, children: a, size: s, direction: m, className: n }) => /* @__PURE__ */ e(r.Root, { open: t, onOpenChange: l, children: /* @__PURE__ */ o(r.Portal, { children: [
7
- /* @__PURE__ */ e(r.Overlay, { className: "drawer-overlay" }),
8
- /* @__PURE__ */ o(
9
- r.Content,
1
+ import { jsxs as u, jsx as o } from "react/jsx-runtime";
2
+ import { useId as p } from "react";
3
+ import * as l from "@radix-ui/react-radio-group";
4
+ import { attr as s } from "@companix/utils-browser";
5
+ const q = (t) => {
6
+ const { options: m, value: a, onChange: r, disabled: d, required: e, size: n } = t;
7
+ return /* @__PURE__ */ o(
8
+ l.Root,
10
9
  {
11
- style: d({ "--drawer-size": s ?? "50%" }),
12
- className: c("drawer", n),
13
- "data-direction": m,
10
+ className: "radio-group",
11
+ disabled: d,
12
+ "data-required": s(e && !a),
13
+ "data-v": a,
14
+ value: a,
15
+ onValueChange: (i) => r(i),
16
+ children: m.map((i, c) => /* @__PURE__ */ o(
17
+ h,
18
+ {
19
+ ...i,
20
+ size: n,
21
+ disabled: d,
22
+ required: e && !a
23
+ },
24
+ `radio-${i.value}-${c}`
25
+ ))
26
+ }
27
+ );
28
+ }, h = ({ value: t, label: m, size: a = "md", disabled: r, required: d }) => {
29
+ const e = p();
30
+ return /* @__PURE__ */ u(
31
+ "span",
32
+ {
33
+ className: "radio",
34
+ "data-disabled": s(r),
35
+ "data-size": a,
36
+ "data-required": s(d),
14
37
  children: [
15
- /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Title, {}) }),
16
- /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Description, {}) }),
17
- a
38
+ /* @__PURE__ */ o(l.Item, { className: "radio-box", value: t, disabled: r, id: e, children: /* @__PURE__ */ o(l.Indicator, { className: "radio-mark" }) }),
39
+ /* @__PURE__ */ o("label", { className: "radio-label", htmlFor: e, "data-disabled": s(r), children: m })
18
40
  ]
19
41
  }
20
- )
21
- ] }) });
22
- p.Close = r.Close;
42
+ );
43
+ };
23
44
  export {
24
- p as Drawer
45
+ h as Radio,
46
+ q as RadioGroup
25
47
  };
@@ -1,31 +1,25 @@
1
- import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
- import f from "classnames";
3
- import * as o from "@radix-ui/react-dialog";
4
- import { VisuallyHidden as a } from "@radix-ui/react-visually-hidden";
5
- import { RemoveListener as v } from "./bundle.es53.js";
6
- const g = (l) => {
7
- const { size: n = "s", open: r, onOpenChange: s, children: c, onClosed: t, disableEsc: p, className: d } = l, m = (h) => {
8
- p && h.preventDefault();
9
- };
10
- return /* @__PURE__ */ e(o.Root, { open: r, onOpenChange: s, children: /* @__PURE__ */ i(o.Portal, { children: [
11
- /* @__PURE__ */ e(o.Overlay, { className: "popup-overlay dialog-overlay" }),
12
- /* @__PURE__ */ e(
13
- o.Content,
14
- {
15
- className: "popup-container dialog-container",
16
- "data-size": n,
17
- onEscapeKeyDown: m,
18
- children: /* @__PURE__ */ i("div", { className: f("popup dialog", d), children: [
19
- /* @__PURE__ */ e(v, { callback: t }),
20
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(o.Title, {}) }),
21
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(o.Description, {}) }),
22
- c
23
- ] })
24
- }
25
- )
26
- ] }) });
27
- };
28
- g.Close = o.Close;
1
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
+ import c from "classnames";
3
+ import * as r from "@radix-ui/react-dialog";
4
+ import { VisuallyHidden as i } from "@radix-ui/react-visually-hidden";
5
+ import { customCSS as d } from "@companix/utils-browser";
6
+ const p = ({ open: t, onOpenChange: l, children: a, size: s, direction: m, className: n }) => /* @__PURE__ */ e(r.Root, { open: t, onOpenChange: l, children: /* @__PURE__ */ o(r.Portal, { children: [
7
+ /* @__PURE__ */ e(r.Overlay, { className: "drawer-overlay" }),
8
+ /* @__PURE__ */ o(
9
+ r.Content,
10
+ {
11
+ style: d({ "--drawer-size": s ?? "50%" }),
12
+ className: c("drawer", n),
13
+ "data-direction": m,
14
+ children: [
15
+ /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Title, {}) }),
16
+ /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(r.Description, {}) }),
17
+ a
18
+ ]
19
+ }
20
+ )
21
+ ] }) });
22
+ p.Close = r.Close;
29
23
  export {
30
- g as Dialog
24
+ p as Drawer
31
25
  };
@@ -1,40 +1,31 @@
1
- import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
- import * as r from "@radix-ui/react-alert-dialog";
3
- import { Button as c } from "./bundle.es4.js";
4
- import { RemoveListener as N } from "./bundle.es53.js";
5
- import { VisuallyHidden as u } from "@radix-ui/react-visually-hidden";
6
- const C = ({
7
- open: d,
8
- defaultOpen: p,
9
- onOpenChange: m,
10
- onUnMounted: h,
11
- icon: i,
12
- title: l,
13
- description: o,
14
- cancelDefaultText: n,
15
- cancel: t,
16
- disableCancel: v,
17
- confirm: s
18
- }) => /* @__PURE__ */ a(r.Root, { open: d, defaultOpen: p, onOpenChange: m, children: [
19
- /* @__PURE__ */ e(N, { callback: h }),
20
- /* @__PURE__ */ a(r.Portal, { children: [
21
- /* @__PURE__ */ e(r.Overlay, { className: "popup-overlay dialog-overlay" }),
22
- /* @__PURE__ */ e(r.Content, { className: "popup-container dialog-container", children: /* @__PURE__ */ a("div", { className: "popup alert", children: [
23
- /* @__PURE__ */ a("div", { className: "alert-body", children: [
24
- i && /* @__PURE__ */ e("span", { className: "alert-icon", children: i }),
25
- /* @__PURE__ */ a("div", { className: "alert-content", children: [
26
- l && /* @__PURE__ */ e(r.Title, { className: "alert-title", children: l }),
27
- !l && /* @__PURE__ */ e(u, { children: /* @__PURE__ */ e(r.Title, {}) }),
28
- o && /* @__PURE__ */ e(r.Description, { className: "alert-description", children: o })
1
+ import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
+ import f from "classnames";
3
+ import * as o from "@radix-ui/react-dialog";
4
+ import { VisuallyHidden as a } from "@radix-ui/react-visually-hidden";
5
+ import { RemoveListener as v } from "./bundle.es53.js";
6
+ const g = (l) => {
7
+ const { size: n = "s", open: r, onOpenChange: s, children: c, onClosed: t, disableEsc: p, className: d } = l, m = (h) => {
8
+ p && h.preventDefault();
9
+ };
10
+ return /* @__PURE__ */ e(o.Root, { open: r, onOpenChange: s, children: /* @__PURE__ */ i(o.Portal, { children: [
11
+ /* @__PURE__ */ e(o.Overlay, { className: "popup-overlay dialog-overlay" }),
12
+ /* @__PURE__ */ e(
13
+ o.Content,
14
+ {
15
+ className: "popup-container dialog-container",
16
+ "data-size": n,
17
+ onEscapeKeyDown: m,
18
+ children: /* @__PURE__ */ i("div", { className: f("popup dialog", d), children: [
19
+ /* @__PURE__ */ e(v, { callback: t }),
20
+ /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(o.Title, {}) }),
21
+ /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(o.Description, {}) }),
22
+ c
29
23
  ] })
30
- ] }),
31
- /* @__PURE__ */ a("div", { className: "alert-footer", children: [
32
- !v && (t?.text || n) && /* @__PURE__ */ e(r.Cancel, { asChild: !0, children: /* @__PURE__ */ e(c, { appearance: "neutral", ...t, text: t?.text ?? n }) }),
33
- s?.text && /* @__PURE__ */ e(r.Action, { asChild: !0, children: /* @__PURE__ */ e(c, { appearance: "negative", ...s }) })
34
- ] })
35
- ] }) })
36
- ] })
37
- ] });
24
+ }
25
+ )
26
+ ] }) });
27
+ };
28
+ g.Close = o.Close;
38
29
  export {
39
- C as AlertDialog
30
+ g as Dialog
40
31
  };
@@ -1,18 +1,40 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { Button as m } from "./bundle.es4.js";
3
- import { useLoading as p } from "./bundle.es54.js";
4
- const g = ({ onClick: o, appearance: r = "primary", ...i }) => {
5
- const { isLoading: n, isError: t, handleClick: a } = p({ onClick: o });
6
- return /* @__PURE__ */ e(
7
- m,
8
- {
9
- appearance: t ? "negative" : r,
10
- ...i,
11
- loading: n,
12
- onClick: a
13
- }
14
- );
15
- };
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import * as r from "@radix-ui/react-alert-dialog";
3
+ import { Button as c } from "./bundle.es4.js";
4
+ import { RemoveListener as N } from "./bundle.es53.js";
5
+ import { VisuallyHidden as u } from "@radix-ui/react-visually-hidden";
6
+ const C = ({
7
+ open: d,
8
+ defaultOpen: p,
9
+ onOpenChange: m,
10
+ onUnMounted: h,
11
+ icon: i,
12
+ title: l,
13
+ description: o,
14
+ cancelDefaultText: n,
15
+ cancel: t,
16
+ disableCancel: v,
17
+ confirm: s
18
+ }) => /* @__PURE__ */ a(r.Root, { open: d, defaultOpen: p, onOpenChange: m, children: [
19
+ /* @__PURE__ */ e(N, { callback: h }),
20
+ /* @__PURE__ */ a(r.Portal, { children: [
21
+ /* @__PURE__ */ e(r.Overlay, { className: "popup-overlay dialog-overlay" }),
22
+ /* @__PURE__ */ e(r.Content, { className: "popup-container dialog-container", children: /* @__PURE__ */ a("div", { className: "popup alert", children: [
23
+ /* @__PURE__ */ a("div", { className: "alert-body", children: [
24
+ i && /* @__PURE__ */ e("span", { className: "alert-icon", children: i }),
25
+ /* @__PURE__ */ a("div", { className: "alert-content", children: [
26
+ l && /* @__PURE__ */ e(r.Title, { className: "alert-title", children: l }),
27
+ !l && /* @__PURE__ */ e(u, { children: /* @__PURE__ */ e(r.Title, {}) }),
28
+ o && /* @__PURE__ */ e(r.Description, { className: "alert-description", children: o })
29
+ ] })
30
+ ] }),
31
+ /* @__PURE__ */ a("div", { className: "alert-footer", children: [
32
+ !v && (t?.text || n) && /* @__PURE__ */ e(r.Cancel, { asChild: !0, children: /* @__PURE__ */ e(c, { appearance: "neutral", ...t, text: t?.text ?? n }) }),
33
+ s?.text && /* @__PURE__ */ e(r.Action, { asChild: !0, children: /* @__PURE__ */ e(c, { appearance: "negative", ...s }) })
34
+ ] })
35
+ ] }) })
36
+ ] })
37
+ ] });
16
38
  export {
17
- g as LoadingButton
39
+ C as AlertDialog
18
40
  };
@@ -1,21 +1,18 @@
1
- import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
- import { useTabSlider as b, makeTabId as l } from "./bundle.es46.js";
3
- import * as n from "@radix-ui/react-tabs";
4
- import { useRef as m, useId as f, createContext as T, useContext as c } from "react";
5
- const o = T({ baseId: "", containerRef: {} }), u = ({ children: s, value: e, onChange: r }) => {
6
- const t = m(null), i = f().replaceAll(":", "");
7
- return /* @__PURE__ */ a(n.Root, { value: e, onValueChange: r, children: /* @__PURE__ */ a(o.Provider, { value: { baseId: i, containerRef: t }, children: /* @__PURE__ */ d(n.List, { className: "tabs", ref: t, children: [
8
- /* @__PURE__ */ a(x, { value: e }),
9
- s
10
- ] }) }) });
11
- }, x = ({ value: s }) => {
12
- const { baseId: e, containerRef: r } = c(o), t = b({ baseId: e, value: s, containerRef: r });
13
- return /* @__PURE__ */ a("div", { className: "tab-indicator-container", style: t, children: /* @__PURE__ */ a("div", { className: "tab-indicator" }) });
14
- }, I = ({ children: s, value: e, ...r }) => {
15
- const { baseId: t } = c(o);
16
- return /* @__PURE__ */ a(n.Trigger, { ...r, id: l(t, e), className: "tab", value: e, children: s });
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { Button as m } from "./bundle.es4.js";
3
+ import { useLoading as p } from "./bundle.es54.js";
4
+ const g = ({ onClick: o, appearance: r = "primary", ...i }) => {
5
+ const { isLoading: n, isError: t, handleClick: a } = p({ onClick: o });
6
+ return /* @__PURE__ */ e(
7
+ m,
8
+ {
9
+ appearance: t ? "negative" : r,
10
+ ...i,
11
+ loading: n,
12
+ onClick: a
13
+ }
14
+ );
17
15
  };
18
- u.Tab = I;
19
16
  export {
20
- u as Tabs
17
+ g as LoadingButton
21
18
  };
@@ -1,23 +1,21 @@
1
- import { jsx as d, Fragment as p } from "react/jsx-runtime";
2
- import { getNextCandleTime as T, sleep as S, getTimes as x } from "@companix/utils-js";
3
- import { useRef as g, useState as v, useEffect as s } from "react";
4
- const n = (t) => String(t).padStart(2, "0"), j = ({ expiration: t, separator: m = ":", onExpired: a }) => {
5
- const e = g(null), [, o] = v([]);
6
- s(() => {
7
- const c = Date.now(), f = T(c, "1s") - c;
8
- return e.current && clearInterval(e.current), S(f).then(() => {
9
- o([]), e.current = setInterval(() => {
10
- o([]);
11
- }, 1e3);
12
- }), () => {
13
- e.current && clearInterval(e.current);
14
- };
15
- }, [t]);
16
- const r = t - Date.now(), { hours: i, minutes: u, seconds: l } = x(r);
17
- return s(() => {
18
- r <= 0 && (a?.(), e.current && clearInterval(e.current));
19
- }, [r <= 0]), /* @__PURE__ */ d(p, { children: [n(i), n(u), n(l)].join(m) });
1
+ import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
+ import { useTabSlider as b, makeTabId as l } from "./bundle.es46.js";
3
+ import * as n from "@radix-ui/react-tabs";
4
+ import { useRef as m, useId as f, createContext as T, useContext as c } from "react";
5
+ const o = T({ baseId: "", containerRef: {} }), u = ({ children: s, value: e, onChange: r }) => {
6
+ const t = m(null), i = f().replaceAll(":", "");
7
+ return /* @__PURE__ */ a(n.Root, { value: e, onValueChange: r, children: /* @__PURE__ */ a(o.Provider, { value: { baseId: i, containerRef: t }, children: /* @__PURE__ */ d(n.List, { className: "tabs", ref: t, children: [
8
+ /* @__PURE__ */ a(x, { value: e }),
9
+ s
10
+ ] }) }) });
11
+ }, x = ({ value: s }) => {
12
+ const { baseId: e, containerRef: r } = c(o), t = b({ baseId: e, value: s, containerRef: r });
13
+ return /* @__PURE__ */ a("div", { className: "tab-indicator-container", style: t, children: /* @__PURE__ */ a("div", { className: "tab-indicator" }) });
14
+ }, I = ({ children: s, value: e, ...r }) => {
15
+ const { baseId: t } = c(o);
16
+ return /* @__PURE__ */ a(n.Trigger, { ...r, id: l(t, e), className: "tab", value: e, children: s });
20
17
  };
18
+ u.Tab = I;
21
19
  export {
22
- j as Countdown
20
+ u as Tabs
23
21
  };
@@ -1,44 +1,23 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useResizeTextarea as x } from "./bundle.es55.js";
3
- import { attr as e, callMultiple as u } from "@companix/utils-browser";
4
- import { useEffect as z } from "react";
5
- import { mergeRefs as R } from "react-merge-refs";
6
- const q = ({
7
- onResize: m,
8
- grow: a = !1,
9
- value: t,
10
- onChange: s,
11
- disabled: o,
12
- required: i,
13
- rows: l = 2,
14
- fill: p = !1,
15
- textAreaRef: c,
16
- ...d
17
- }) => {
18
- const [n, r] = x(m, a);
19
- return z(r, [r, t]), /* @__PURE__ */ f(
20
- "div",
21
- {
22
- className: "form form-textarea",
23
- "data-required": e(i),
24
- "data-disabled": e(o),
25
- "data-fill": e(p),
26
- children: /* @__PURE__ */ f(
27
- "textarea",
28
- {
29
- className: "form-input",
30
- "data-grow": e(a),
31
- value: t,
32
- ref: R([c, n]),
33
- rows: l,
34
- disabled: o,
35
- onChange: u(s, r),
36
- ...d
37
- }
38
- )
39
- }
40
- );
1
+ import { jsx as d, Fragment as p } from "react/jsx-runtime";
2
+ import { getNextCandleTime as T, sleep as S, getTimes as x } from "@companix/utils-js";
3
+ import { useRef as g, useState as v, useEffect as s } from "react";
4
+ const n = (t) => String(t).padStart(2, "0"), j = ({ expiration: t, separator: m = ":", onExpired: a }) => {
5
+ const e = g(null), [, o] = v([]);
6
+ s(() => {
7
+ const c = Date.now(), f = T(c, "1s") - c;
8
+ return e.current && clearInterval(e.current), S(f).then(() => {
9
+ o([]), e.current = setInterval(() => {
10
+ o([]);
11
+ }, 1e3);
12
+ }), () => {
13
+ e.current && clearInterval(e.current);
14
+ };
15
+ }, [t]);
16
+ const r = t - Date.now(), { hours: i, minutes: u, seconds: l } = x(r);
17
+ return s(() => {
18
+ r <= 0 && (a?.(), e.current && clearInterval(e.current));
19
+ }, [r <= 0]), /* @__PURE__ */ d(p, { children: [n(i), n(u), n(l)].join(m) });
41
20
  };
42
21
  export {
43
- q as TextArea
22
+ j as Countdown
44
23
  };