@companix/uikit 0.0.32 → 0.0.34

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 (92) hide show
  1. package/dist/Avatar/Avatar.scss +64 -0
  2. package/dist/Avatar/helpers.d.ts +10 -0
  3. package/dist/Avatar/index.d.ts +8 -0
  4. package/dist/Avatar/types.d.ts +2 -0
  5. package/dist/Icon/index.d.ts +2 -3
  6. package/dist/Segments/Segments.scss +57 -0
  7. package/dist/Segments/index.d.ts +11 -0
  8. package/dist/ThemeProvider/script.d.ts +1 -0
  9. package/dist/bundle.es.js +86 -77
  10. package/dist/bundle.es10.js +78 -39
  11. package/dist/bundle.es11.js +26 -36
  12. package/dist/bundle.es12.js +75 -56
  13. package/dist/bundle.es13.js +39 -19
  14. package/dist/bundle.es14.js +36 -33
  15. package/dist/bundle.es15.js +54 -23
  16. package/dist/bundle.es16.js +21 -45
  17. package/dist/bundle.es17.js +29 -19
  18. package/dist/bundle.es18.js +21 -25
  19. package/dist/bundle.es19.js +45 -38
  20. package/dist/bundle.es2.js +42 -45
  21. package/dist/bundle.es20.js +21 -14
  22. package/dist/bundle.es21.js +28 -33
  23. package/dist/bundle.es22.js +38 -21
  24. package/dist/bundle.es23.js +12 -38
  25. package/dist/bundle.es24.js +32 -114
  26. package/dist/bundle.es25.js +20 -120
  27. package/dist/bundle.es26.js +40 -72
  28. package/dist/bundle.es27.js +115 -32
  29. package/dist/bundle.es28.js +120 -11
  30. package/dist/bundle.es29.js +71 -83
  31. package/dist/bundle.es3.js +2 -8
  32. package/dist/bundle.es30.js +31 -20
  33. package/dist/bundle.es31.js +11 -6
  34. package/dist/bundle.es32.js +83 -36
  35. package/dist/bundle.es33.js +22 -11
  36. package/dist/bundle.es34.js +6 -24
  37. package/dist/bundle.es35.js +33 -37
  38. package/dist/bundle.es36.js +20 -49
  39. package/dist/bundle.es37.js +10 -42
  40. package/dist/bundle.es38.js +24 -8
  41. package/dist/bundle.es39.js +35 -20
  42. package/dist/bundle.es4.js +44 -10
  43. package/dist/bundle.es40.js +51 -87
  44. package/dist/bundle.es41.js +42 -17
  45. package/dist/bundle.es42.js +8 -19
  46. package/dist/bundle.es43.js +25 -24
  47. package/dist/bundle.es44.js +24 -39
  48. package/dist/bundle.es45.js +87 -3
  49. package/dist/bundle.es46.js +18 -5
  50. package/dist/bundle.es47.js +19 -13
  51. package/dist/bundle.es48.js +24 -14
  52. package/dist/bundle.es49.js +39 -3
  53. package/dist/bundle.es5.js +8 -85
  54. package/dist/bundle.es50.js +3 -3
  55. package/dist/bundle.es51.js +5 -70
  56. package/dist/bundle.es52.js +13 -67
  57. package/dist/bundle.es53.js +13 -69
  58. package/dist/bundle.es54.js +3 -12
  59. package/dist/bundle.es55.js +3 -43
  60. package/dist/bundle.es56.js +69 -14
  61. package/dist/bundle.es57.js +67 -23
  62. package/dist/bundle.es58.js +69 -31
  63. package/dist/bundle.es59.js +12 -70
  64. package/dist/bundle.es6.js +11 -85
  65. package/dist/bundle.es60.js +41 -12
  66. package/dist/bundle.es61.js +15 -20
  67. package/dist/bundle.es62.js +32 -2
  68. package/dist/bundle.es63.js +69 -19
  69. package/dist/bundle.es64.js +76 -2
  70. package/dist/bundle.es65.js +49 -21
  71. package/dist/bundle.es66.js +14 -2
  72. package/dist/bundle.es67.js +9 -9
  73. package/dist/bundle.es68.js +2 -76
  74. package/dist/bundle.es69.js +20 -49
  75. package/dist/bundle.es7.js +84 -79
  76. package/dist/bundle.es70.js +2 -2
  77. package/dist/bundle.es71.js +21 -14
  78. package/dist/bundle.es72.js +2 -3
  79. package/dist/bundle.es73.js +20 -3
  80. package/dist/bundle.es74.js +3 -20
  81. package/dist/bundle.es75.js +3 -2
  82. package/dist/bundle.es76.js +14 -20
  83. package/dist/bundle.es77.js +2 -2
  84. package/dist/bundle.es78.js +22 -0
  85. package/dist/bundle.es79.js +4 -0
  86. package/dist/bundle.es8.js +83 -24
  87. package/dist/bundle.es80.js +22 -0
  88. package/dist/bundle.es81.js +4 -0
  89. package/dist/bundle.es9.js +20 -73
  90. package/dist/index.d.ts +7 -0
  91. package/dist/index.scss +2 -0
  92. package/package.json +1 -1
@@ -1,47 +1,44 @@
1
- import { jsx as e, jsxs as x, Fragment as h } from "react/jsx-runtime";
2
- import j from "classnames";
3
- import { Spinner as k } from "./bundle.es4.js";
4
- import { forwardRef as w } from "react";
5
- import { attr as r } from "@companix/utils-browser";
6
- const F = w(
7
- ({
8
- children: d,
9
- fill: l,
10
- text: i,
11
- active: c,
12
- mode: f = "default",
13
- appearance: s = "neutral",
14
- size: p = "md",
15
- align: u,
16
- icon: m,
17
- loading: t,
18
- className: b,
19
- iconRight: n,
20
- Component: o = "button",
21
- ...a
22
- }, v) => /* @__PURE__ */ e(
23
- o,
24
- {
25
- ref: v,
26
- className: j("button", b),
27
- "data-size": p,
28
- "data-loading": r(t),
29
- "data-align": t ? "center" : u ?? (m && n ? "left" : "center"),
30
- "data-appearance": s,
31
- "data-mode": f,
32
- "data-fill": r(l),
33
- "data-active": r(c),
34
- type: o === "button" ? "button" : void 0,
35
- ...a,
36
- onClick: t ?? a.disabled ? void 0 : a.onClick,
37
- children: t ? /* @__PURE__ */ e(k, { size: 14, width: 2 }) : /* @__PURE__ */ x(h, { children: [
38
- m,
39
- (d ?? i) && /* @__PURE__ */ e("span", { className: "button-text", children: i ?? d }),
40
- n
41
- ] })
42
- }
43
- )
44
- );
1
+ import { jsxs as I, jsx as a } from "react/jsx-runtime";
2
+ import { box as g } from "@companix/utils-browser";
3
+ import { getInitialsFontSize as h } from "./bundle.es43.js";
4
+ const k = 24, y = ({
5
+ alt: n,
6
+ crossOrigin: i,
7
+ decoding: m,
8
+ loading: v,
9
+ referrerPolicy: d,
10
+ sizes: f,
11
+ size: t = k,
12
+ src: o,
13
+ srcSet: s,
14
+ useMap: N,
15
+ initials: c,
16
+ noBorder: b,
17
+ fallbackIcon: p,
18
+ children: l
19
+ }) => {
20
+ const r = o || s, x = c ? /* @__PURE__ */ a("div", { className: "avatar-initials", style: { fontSize: h(t) }, children: c }) : p, e = r ? null : x;
21
+ return /* @__PURE__ */ I("div", { className: "avatar", style: g(t), children: [
22
+ r && /* @__PURE__ */ a(
23
+ "img",
24
+ {
25
+ alt: n,
26
+ className: "avatar-image",
27
+ crossOrigin: i,
28
+ decoding: m,
29
+ loading: v,
30
+ referrerPolicy: d,
31
+ sizes: f,
32
+ src: o,
33
+ srcSet: s,
34
+ useMap: N
35
+ }
36
+ ),
37
+ e && /* @__PURE__ */ a("div", { className: "avatar-icon", children: e }),
38
+ l && /* @__PURE__ */ a("div", { className: "avatar-content", children: l }),
39
+ !b && /* @__PURE__ */ a("div", { className: "avatar-border" })
40
+ ] });
41
+ };
45
42
  export {
46
- F as Button
43
+ y as Avatar
47
44
  };
@@ -1,18 +1,25 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { Button as m } from "./bundle.es2.js";
3
- import { useLoading as p } from "./bundle.es47.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,
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,
8
10
  {
9
- appearance: t ? "negative" : r,
10
- ...i,
11
- loading: n,
12
- onClick: a
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
+ ]
13
19
  }
14
- );
15
- };
20
+ )
21
+ ] }) });
22
+ p.Close = r.Close;
16
23
  export {
17
- g as LoadingButton
24
+ p as Drawer
18
25
  };
@@ -1,36 +1,31 @@
1
- import { jsx as n, jsxs as T } from "react/jsx-runtime";
2
- import * as c from "@radix-ui/react-tabs";
3
- import { useRef as g, useId as p, createContext as v, useState as I, useContext as d, useEffect as R } from "react";
4
- const l = v({ baseId: "", listRef: {} }), b = (t, e) => `radix-${t}-trigger-${e}`, y = ({ children: t, value: e, onChange: s }) => {
5
- const r = g(null), o = p();
6
- return /* @__PURE__ */ n(c.Root, { value: e, onValueChange: s, children: /* @__PURE__ */ n(l.Provider, { value: { baseId: o, listRef: r }, children: /* @__PURE__ */ T(c.List, { className: "tabs", ref: r, children: [
7
- /* @__PURE__ */ n($, { value: e }),
8
- t
9
- ] }) }) });
10
- }, $ = ({ value: t }) => {
11
- const [e, s] = I({}), { baseId: r, listRef: o } = d(l);
12
- return R(() => {
13
- const a = { observer: null };
14
- if (o.current) {
15
- const f = `.tab[id="${b(r, t)}"]`, i = o.current.querySelector(f);
16
- i != null ? (a.observer = new ResizeObserver(() => {
17
- const { clientHeight: u, clientWidth: m, offsetLeft: h, offsetTop: x } = i;
18
- s({
19
- height: u,
20
- transform: `translateX(${Math.floor(h)}px) translateY(${Math.floor(x)}px)`,
21
- width: m
22
- });
23
- }), a.observer.observe(i)) : s({ display: "none" });
24
- }
25
- return () => {
26
- a.observer && a.observer.disconnect();
27
- };
28
- }, [t]), /* @__PURE__ */ n("div", { className: "tab-indicator-container", style: e, children: /* @__PURE__ */ n("div", { className: "tab-indicator" }) });
29
- }, C = ({ children: t, value: e, ...s }) => {
30
- const { baseId: r } = d(l), o = b(r, e);
31
- return /* @__PURE__ */ n(c.Trigger, { ...s, id: o, className: "tab", value: e, children: t });
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.es51.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
+ ] }) });
32
27
  };
33
- y.Tab = C;
28
+ g.Close = o.Close;
34
29
  export {
35
- y as Tabs
30
+ g as Dialog
36
31
  };
@@ -1,23 +1,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) });
20
- };
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.es51.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
+ ] });
21
38
  export {
22
- j as Countdown
39
+ C as AlertDialog
23
40
  };
@@ -1,44 +1,18 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useResizeTextarea as x } from "./bundle.es48.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",
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.es52.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,
21
8
  {
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
- )
9
+ appearance: t ? "negative" : r,
10
+ ...i,
11
+ loading: n,
12
+ onClick: a
39
13
  }
40
14
  );
41
15
  };
42
16
  export {
43
- q as TextArea
17
+ g as LoadingButton
44
18
  };
@@ -1,118 +1,36 @@
1
- import { jsx as o, jsxs as l } from "react/jsx-runtime";
2
- import { useFroozeClosing as M } from "./bundle.es39.js";
3
- import { Popover as j } from "./bundle.es7.js";
4
- import { OptionItem as q } from "./bundle.es11.js";
5
- import { OptionsList as V } from "./bundle.es13.js";
6
- import { Icon as d } from "./bundle.es30.js";
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";
10
- import { attr as x, getActiveElementByAnotherElement as G, contains as J } from "@companix/utils-browser";
11
- import { mergeRefs as K } from "react-merge-refs";
12
- const se = (C) => {
13
- const {
14
- options: r,
15
- closeAfterSelect: v,
16
- placeholder: N,
17
- onChange: c,
18
- emptyText: R = "Ничего не найдено",
19
- readOnly: m,
20
- size: z = "md",
21
- value: n,
22
- inputRef: A,
23
- disabled: u,
24
- required: D
25
- } = C, [a, E] = B(""), i = h(null), w = h(null), { popoverRef: f, froozePopoverPosition: y, handleAnimationEnd: b } = M(), O = g(() => {
26
- const e = {};
27
- return r.forEach((t) => {
28
- e[t.value] = t;
29
- }), e;
30
- }, [r]), P = (e) => n.includes(e) ? [...n] : [...n, e], T = (e) => n.filter((t) => e !== t), k = (e, t) => {
31
- v ? (y(), c(e), t()) : c(e);
32
- }, p = g(() => a.trim() ? r.filter(({ title: e }) => {
33
- const t = e.toLowerCase(), s = a.trim().toLowerCase();
34
- return t.indexOf(s) >= 0;
35
- }) : r, [a, r]), I = (e) => {
36
- if (u) return;
37
- f.current && f.current.getAttribute("data-state") === "open" && e.preventDefault();
38
- const t = G(e.currentTarget);
39
- e.defaultPrevented || J(e.currentTarget, t) || i.current && i.current.focus();
40
- }, S = (e) => {
41
- e.target !== i.current && e.preventDefault();
42
- }, $ = (e, t) => {
43
- e.stopPropagation(), c(T(t));
44
- };
45
- return /* @__PURE__ */ o(
46
- j,
47
- {
48
- minimal: !0,
49
- ref: f,
50
- sideOffset: 0,
51
- matchTarget: "width",
52
- onAnimationEnd: b,
53
- onOpenAutoFocus: (e) => e.preventDefault(),
54
- onCloseAutoFocus: (e) => e.preventDefault(),
55
- content: ({ close: e }) => /* @__PURE__ */ l(V, { maxHeight: 300, children: [
56
- p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: R }),
57
- p.map(({ value: t, title: s, icon: F }, L) => /* @__PURE__ */ o(
58
- q,
59
- {
60
- active: n.includes(t),
61
- onClick: () => k(P(t), e),
62
- title: s,
63
- icon: F
64
- },
65
- `option-item-${t}-${L}`
66
- ))
67
- ] }),
68
- children: /* @__PURE__ */ o(
69
- "div",
70
- {
71
- className: "form",
72
- onClick: I,
73
- onMouseDown: S,
74
- "data-size": z,
75
- "data-required": x(D),
76
- children: /* @__PURE__ */ l("div", { className: "select-tags-container", children: [
77
- /* @__PURE__ */ l("div", { className: "select-tags", children: [
78
- n.length > 0 && /* @__PURE__ */ o(
79
- "div",
80
- {
81
- className: "tag-container",
82
- ref: w,
83
- role: "listbox",
84
- "data-readonly": x(m),
85
- children: n.map((e, t) => /* @__PURE__ */ l("div", { className: "tag", children: [
86
- /* @__PURE__ */ o("span", { className: "tag-name", children: O[e].title }),
87
- /* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) => $(s, e), children: /* @__PURE__ */ o(d, { className: "tag-close-icon", icon: Q.faClose, size: "xxxs" }) })
88
- ] }, `tag-option-${e}-${t}`))
89
- }
90
- ),
91
- (!m || n.length === 0) && /* @__PURE__ */ o(
92
- "input",
93
- {
94
- ref: K([A, i]),
95
- type: "text",
96
- autoCapitalize: "none",
97
- autoComplete: "off",
98
- autoCorrect: "off",
99
- className: "form-input",
100
- spellCheck: !1,
101
- value: a,
102
- disabled: u,
103
- readOnly: m,
104
- placeholder: N,
105
- onChange: ({ target: e }) => E(e.value)
106
- }
107
- )
108
- ] }),
109
- /* @__PURE__ */ o(d, { className: "expand-icon", icon: H.faChevronDown, size: "xxxs" })
110
- ] })
111
- }
112
- )
1
+ import { jsx as n, jsxs as T } from "react/jsx-runtime";
2
+ import * as c from "@radix-ui/react-tabs";
3
+ import { useRef as g, useId as p, createContext as v, useState as I, useContext as d, useEffect as R } from "react";
4
+ const l = v({ baseId: "", listRef: {} }), b = (t, e) => `radix-${t}-trigger-${e}`, y = ({ children: t, value: e, onChange: s }) => {
5
+ const r = g(null), o = p();
6
+ return /* @__PURE__ */ n(c.Root, { value: e, onValueChange: s, children: /* @__PURE__ */ n(l.Provider, { value: { baseId: o, listRef: r }, children: /* @__PURE__ */ T(c.List, { className: "tabs", ref: r, children: [
7
+ /* @__PURE__ */ n($, { value: e }),
8
+ t
9
+ ] }) }) });
10
+ }, $ = ({ value: t }) => {
11
+ const [e, s] = I({}), { baseId: r, listRef: o } = d(l);
12
+ return R(() => {
13
+ const a = { observer: null };
14
+ if (o.current) {
15
+ const f = `.tab[id="${b(r, t)}"]`, i = o.current.querySelector(f);
16
+ i != null ? (a.observer = new ResizeObserver(() => {
17
+ const { clientHeight: u, clientWidth: m, offsetLeft: h, offsetTop: x } = i;
18
+ s({
19
+ height: u,
20
+ transform: `translateX(${Math.floor(h)}px) translateY(${Math.floor(x)}px)`,
21
+ width: m
22
+ });
23
+ }), a.observer.observe(i)) : s({ display: "none" });
113
24
  }
114
- );
25
+ return () => {
26
+ a.observer && a.observer.disconnect();
27
+ };
28
+ }, [t]), /* @__PURE__ */ n("div", { className: "tab-indicator-container", style: e, children: /* @__PURE__ */ n("div", { className: "tab-indicator" }) });
29
+ }, C = ({ children: t, value: e, ...s }) => {
30
+ const { baseId: r } = d(l), o = b(r, e);
31
+ return /* @__PURE__ */ n(c.Trigger, { ...s, id: o, className: "tab", value: e, children: t });
115
32
  };
33
+ y.Tab = C;
116
34
  export {
117
- se as SelectTags
35
+ y as Tabs
118
36
  };
@@ -1,123 +1,23 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { Popover as T } from "./bundle.es7.js";
3
- import { Input as w } from "./bundle.es10.js";
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";
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";
10
- const i = {
11
- char: "-",
12
- toString: (e) => {
13
- if (e) {
14
- const n = v(e.getDate()), r = v(e.getMonth() + 1), l = e.getFullYear();
15
- return [n, r, l].join(i.char);
16
- }
17
- return "";
18
- },
19
- toValue: (e) => {
20
- const n = e.split(i.char);
21
- if (n.length === 3) {
22
- const [r, l, a] = [h(n[0]), h(n[1]), h(n[2])];
23
- if (r && l && a) {
24
- const o = new Date(a, l - 1, r);
25
- if (o.getFullYear() === a && o.getDate() === r && o.getMonth() === l - 1)
26
- return o;
27
- }
28
- }
29
- return null;
30
- }
31
- }, U = (e) => {
32
- const {
33
- clearButton: n,
34
- clearButtonIcon: r,
35
- children: l,
36
- disabled: a,
37
- // calendar props
38
- value: o,
39
- enableTime: y,
40
- disablePickers: I,
41
- showNeighboringMonth: P,
42
- onChange: c,
43
- shouldDisableDate: g,
44
- viewDate: S,
45
- disablePast: d,
46
- disableFuture: D,
47
- minDateTime: C,
48
- maxDateTime: b,
49
- // input props
50
- ...V
51
- } = e, [m, s] = A(() => i.toString(o ?? null)), p = j(null), k = N({
52
- disableFuture: D,
53
- disablePast: d,
54
- shouldDisableDate: g,
55
- minDateTime: C,
56
- maxDateTime: b
57
- }), B = (t) => {
58
- a || p.current && p.current.getAttribute("data-state") === "open" && t.preventDefault();
59
- }, F = (t) => {
60
- t.stopPropagation(), s(""), c?.(null);
61
- }, x = (t) => {
62
- s(t);
63
- const f = i.toValue(t);
64
- f && !k(f) && c?.(f);
65
- }, M = () => {
66
- const t = i.toValue(m);
67
- (!t || k(t)) && s(i.toString(o ?? null));
68
- }, R = (t) => {
69
- c?.(t), s(i.toString(t));
70
- };
71
- return /* @__PURE__ */ u(
72
- T,
73
- {
74
- minimal: !0,
75
- ref: p,
76
- sideOffset: 0,
77
- onOpenAutoFocus: (t) => t.preventDefault(),
78
- onCloseAutoFocus: (t) => t.preventDefault(),
79
- disabled: a,
80
- fitMaxHeight: !1,
81
- content: () => /* @__PURE__ */ u(
82
- E,
83
- {
84
- value: o,
85
- disablePast: d,
86
- disableFuture: D,
87
- enableTime: y,
88
- disablePickers: I,
89
- showNeighboringMonth: P,
90
- onChange: R,
91
- shouldDisableDate: g,
92
- viewDate: S,
93
- minDateTime: C,
94
- maxDateTime: b
95
- }
96
- ),
97
- children: /* @__PURE__ */ u(
98
- w,
99
- {
100
- ...V,
101
- value: m,
102
- disabled: a,
103
- onClick: B,
104
- onValueChange: x,
105
- onBlur: M,
106
- mask: "99-99-9999",
107
- rightElement: /* @__PURE__ */ u(
108
- Y,
109
- {
110
- clearButton: n,
111
- clearButtonIcon: r,
112
- value: !!O(m, ["-", "_"]),
113
- onClear: F
114
- }
115
- )
116
- }
117
- )
118
- }
119
- );
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) });
120
20
  };
121
21
  export {
122
- U as DatePicker
22
+ j as Countdown
123
23
  };