@kolking/react-ui 1.8.20 → 1.9.1

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 (48) hide show
  1. package/dist/Thumbnails-BlXFynlF.js +38 -0
  2. package/dist/components/Avatar/Avatar.js +15 -15
  3. package/dist/components/Avatar/helpers.js +15 -16
  4. package/dist/components/Badge/Badge.js +28 -29
  5. package/dist/components/Button/Button.d.ts +1 -1
  6. package/dist/components/Dialog/Dialog.js +44 -44
  7. package/dist/components/Dialog/useDialog.d.ts +9 -6
  8. package/dist/components/Dialog/useDialog.js +20 -28
  9. package/dist/components/Fields/Checkbox.js +15 -15
  10. package/dist/components/Fields/Numeric.js +34 -36
  11. package/dist/components/Fields/Range.d.ts +1 -1
  12. package/dist/components/Fields/Range.js +33 -33
  13. package/dist/components/Flex/Flex.d.ts +1 -1
  14. package/dist/components/Gallery/Gallery.d.ts +11 -0
  15. package/dist/components/Gallery/Gallery.js +49 -0
  16. package/dist/components/Gallery/GalleryItem.d.ts +12 -0
  17. package/dist/components/Gallery/GalleryItem.js +41 -0
  18. package/dist/components/Gallery/index.d.ts +2 -0
  19. package/dist/components/Gallery/index.js +6 -0
  20. package/dist/components/Icon/Icon.js +125 -122
  21. package/dist/components/Icon/icons.d.ts +1 -1
  22. package/dist/components/Icon/icons.js +4 -0
  23. package/dist/components/Lightbox/Lightbox.d.ts +12 -0
  24. package/dist/components/Lightbox/Lightbox.js +166 -0
  25. package/dist/components/Lightbox/Thumbnail.d.ts +7 -0
  26. package/dist/components/Lightbox/Thumbnail.js +26 -0
  27. package/dist/components/Lightbox/Thumbnails.d.ts +11 -0
  28. package/dist/components/Lightbox/Thumbnails.js +8 -0
  29. package/dist/components/Lightbox/index.d.ts +1 -0
  30. package/dist/components/Lightbox/index.js +4 -0
  31. package/dist/components/Menu/Menu.js +44 -45
  32. package/dist/components/Menu/MenuItem.js +33 -33
  33. package/dist/components/Notice/Notice.js +58 -43
  34. package/dist/components/Popover/Popover.js +40 -41
  35. package/dist/components/Progress/ProgressBar.js +14 -14
  36. package/dist/components/Progress/ProgressCircular.js +15 -15
  37. package/dist/components/Segmented/Segmented.js +43 -47
  38. package/dist/components/Tag/Tag.d.ts +1 -1
  39. package/dist/components/ToggleButton/ToggleButton.d.ts +1 -1
  40. package/dist/components/ToggleButton/ToggleGroup.js +42 -40
  41. package/dist/components/Tooltip/Tooltip.js +30 -31
  42. package/dist/index.d.ts +3 -1
  43. package/dist/index.js +71 -63
  44. package/dist/styles/style.css +1 -1
  45. package/dist/styles.module-D0C-vMZX.js +7 -0
  46. package/dist/utils/helpers.d.ts +3 -1
  47. package/dist/utils/helpers.js +30 -19
  48. package/package.json +41 -32
@@ -0,0 +1,38 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import a from "classnames";
3
+ import { Thumbnail as g } from "./components/Lightbox/Thumbnail.js";
4
+ import { cssProps as u, htmlImage as _ } from "./utils/helpers.js";
5
+ const x = "Lightbox_lightbox_JQunO", p = "Lightbox_images_WFWsL", L = "Lightbox_thumbnails_jQSPH", f = "Lightbox_willhide_z2lO8", d = "Lightbox_content_UfCvB", v = "Lightbox_prev_qIKJt", T = "Lightbox_next_qZR61", j = "Lightbox_close_SgBu9", w = {
6
+ lightbox: x,
7
+ images: p,
8
+ thumbnails: L,
9
+ willhide: f,
10
+ content: d,
11
+ prev: v,
12
+ next: T,
13
+ close: j
14
+ }, F = ({
15
+ images: o,
16
+ selected: i,
17
+ className: n,
18
+ style: e,
19
+ imageSize: h,
20
+ objectFit: c,
21
+ renderImage: b = _,
22
+ onSelect: m,
23
+ ...r
24
+ }) => o.length <= 1 ? null : /* @__PURE__ */ s(
25
+ "ul",
26
+ {
27
+ ...r,
28
+ role: "listbox",
29
+ "data-lightbox-thumbnails": !0,
30
+ className: a(w.thumbnails, n),
31
+ style: { ...e, ...u({ thumbnailSize: h, thumbnailObjectFit: c }) },
32
+ children: o.map((l, t) => /* @__PURE__ */ s(g, { index: t, selected: t === i, onSelect: m, children: b({ ...l, alt: l.alt ?? `Thumbnail ${t + 1}` }) }, t))
33
+ }
34
+ );
35
+ export {
36
+ F as T,
37
+ w as s
38
+ };
@@ -4,47 +4,47 @@ import * as m from "react";
4
4
  import { forwardRef as S, useMemo as x, useState as A, useEffect as N, useCallback as E } from "react";
5
5
  import { cssProps as C } from "../../utils/helpers.js";
6
6
  import { getStringColor as k, getGravatarUri as M, getInitials as R } from "./helpers.js";
7
- const b = (a, t) => /* @__PURE__ */ m.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50", ref: t, ...a }, /* @__PURE__ */ m.createElement("path", { fill: "currentColor", d: "M25 31c4.97 0 9-4.253 9-9.5S29.97 12 25 12s-9 4.253-9 9.5 4.03 9.5 9 9.5Zm19 19c0-8.837-8.507-15-19-15S6 41.163 6 50h38Z" })), j = S(b), y = "Avatar_avatar_PNlL5", I = "Avatar_image_Jwmxk", P = "Avatar_initials_i0r2T", e = {
7
+ const b = (a, e) => /* @__PURE__ */ m.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50", ref: e, ...a }, /* @__PURE__ */ m.createElement("path", { fill: "currentColor", d: "M25 31c4.97 0 9-4.253 9-9.5S29.97 12 25 12s-9 4.253-9 9.5 4.03 9.5 9 9.5Zm19 19c0-8.837-8.507-15-19-15S6 41.163 6 50h38Z" })), j = S(b), y = "Avatar_avatar_PNlL5", I = "Avatar_image_Jwmxk", P = "Avatar_initials_i0r2T", r = {
8
8
  avatar: y,
9
9
  image: I,
10
10
  initials: P,
11
11
  default: "Avatar_default_v75Mg"
12
12
  }, J = ({
13
13
  size: a = 50,
14
- name: t,
14
+ name: e,
15
15
  email: o,
16
16
  src: c,
17
17
  colorize: v,
18
- className: d,
19
- style: u,
18
+ className: u,
19
+ style: d,
20
20
  children: g,
21
21
  ...f
22
22
  }) => {
23
- const r = t == null ? void 0 : t.trim(), p = v && r ? k(r) : void 0, s = x(() => c || (o ? M(a, o) : void 0), [c, a, o]), [l, n] = A(s);
23
+ const t = e?.trim(), p = v && t ? k(t) : void 0, s = x(() => c || (o ? M(a, o) : void 0), [c, a, o]), [n, l] = A(s);
24
24
  N(() => {
25
- n(s);
25
+ l(s);
26
26
  }, [s]);
27
27
  const w = E(() => {
28
- n(void 0);
28
+ l(void 0);
29
29
  }, []);
30
30
  return /* @__PURE__ */ _(
31
- "div",
31
+ "figure",
32
32
  {
33
33
  ...f,
34
34
  "data-avatar": !0,
35
- className: h(e.avatar, d),
36
- style: { ...u, ...C({ size: a, backgroundColor: p }) },
35
+ className: h(r.avatar, u),
36
+ style: { ...d, ...C({ size: a, backgroundColor: p }) },
37
37
  children: [
38
- l ? /* @__PURE__ */ i(
38
+ n ? /* @__PURE__ */ i(
39
39
  "img",
40
40
  {
41
41
  "data-avatar-image": !0,
42
- className: e.image,
43
- src: l,
44
- alt: r ?? "",
42
+ className: r.image,
43
+ src: n,
44
+ alt: t ?? "",
45
45
  onError: w
46
46
  }
47
- ) : r ? /* @__PURE__ */ i("span", { "data-avatar-initials": !0, className: e.initials, children: R(r) }) : /* @__PURE__ */ i(j, { "aria-hidden": !0, "data-avatar-default": !0, className: e.default }),
47
+ ) : t ? /* @__PURE__ */ i("figcaption", { "data-avatar-initials": !0, className: r.initials, children: R(t) }) : /* @__PURE__ */ i(j, { "aria-hidden": !0, "data-avatar-default": !0, className: r.default }),
48
48
  g
49
49
  ]
50
50
  }
@@ -1,22 +1,21 @@
1
- import { md5 as r } from "js-md5";
2
- function n(i, t) {
3
- const e = r(t.toLowerCase().trim()), o = window.devicePixelRatio * i;
4
- return `https://www.gravatar.com/avatar/${e}?s=${o}&d=404`;
1
+ import { md5 as o } from "js-md5";
2
+ function l(e, t) {
3
+ const i = o(t.toLowerCase().trim()), r = window.devicePixelRatio || 1, n = Math.round(r * e);
4
+ return `https://www.gravatar.com/avatar/${i}?s=${n}&d=404`;
5
5
  }
6
- function l(i) {
7
- const t = i.trim().split(/\s+/gu) || [];
8
- let e = [...t.shift() || ""][0];
9
- return t.length > 0 && (e += [...t.pop() || ""][0]), e.toUpperCase();
6
+ function s(e) {
7
+ const t = e.trim().split(/\s+/gu).filter(Boolean);
8
+ return t.length === 0 ? "" : ([...t[0]][0] + (t.length > 1 ? [...t[t.length - 1]][0] : "")).toUpperCase();
10
9
  }
11
- function s(i) {
10
+ function h(e) {
12
11
  let t = 0;
13
- if (i.length > 0)
14
- for (let e = 0; e < i.length; e += 1)
15
- t = i.charCodeAt(e) + ((t << 5) - t), t &= t;
16
- return `hsl(${t % 360}, 75%, 50%)`;
12
+ if (e.length > 0)
13
+ for (let r = 0; r < e.length; r += 1)
14
+ t = e.charCodeAt(r) + ((t << 5) - t), t &= t;
15
+ return `hsl(${(t % 360 + 360) % 360}, 75%, 50%)`;
17
16
  }
18
17
  export {
19
- n as getGravatarUri,
20
- l as getInitials,
21
- s as getStringColor
18
+ l as getGravatarUri,
19
+ s as getInitials,
20
+ h as getStringColor
22
21
  };
@@ -2,64 +2,63 @@ import { jsx as h } from "react/jsx-runtime";
2
2
  import { useRef as _, useLayoutEffect as w, useEffect as l } from "react";
3
3
  import E from "classnames";
4
4
  import { wrapNode as P, cssProps as H } from "../../utils/helpers.js";
5
- const M = "Badge_badge_-mEE7", k = "Badge_appear_LbxbS", x = "Badge_accent_BIYve", L = "Badge_gray_7jA-J", I = "Badge_brown_x1GS7", R = "Badge_red_zPgCR", S = "Badge_orange_EoLmF", X = "Badge_yellow_qvbb6", j = "Badge_green_XX-1c", v = "Badge_teal_VHoFK", C = "Badge_cyan_1ksBn", F = "Badge_blue_YulfT", K = "Badge_indigo_2KXUy", N = "Badge_purple_o55fQ", O = "Badge_pink_T5H--", g = {
5
+ const M = "Badge_badge_-mEE7", k = "Badge_appear_LbxbS", x = "Badge_accent_BIYve", L = "Badge_gray_7jA-J", v = "Badge_brown_x1GS7", I = "Badge_red_zPgCR", R = "Badge_orange_EoLmF", S = "Badge_yellow_qvbb6", X = "Badge_green_XX-1c", j = "Badge_teal_VHoFK", C = "Badge_cyan_1ksBn", F = "Badge_blue_YulfT", K = "Badge_indigo_2KXUy", N = "Badge_purple_o55fQ", O = "Badge_pink_T5H--", c = {
6
6
  badge: M,
7
7
  appear: k,
8
8
  accent: x,
9
9
  gray: L,
10
- brown: I,
11
- red: R,
12
- orange: S,
13
- yellow: X,
14
- green: j,
15
- teal: v,
10
+ brown: v,
11
+ red: I,
12
+ orange: R,
13
+ yellow: S,
14
+ green: X,
15
+ teal: j,
16
16
  cyan: C,
17
17
  blue: F,
18
18
  indigo: K,
19
19
  purple: N,
20
20
  pink: O
21
21
  };
22
- function T(a) {
23
- const n = _();
22
+ function T(o) {
23
+ const n = _(void 0);
24
24
  return l(() => {
25
- n.current = a;
25
+ n.current = o;
26
26
  }), n.current;
27
27
  }
28
28
  const A = ({
29
- size: a,
29
+ size: o,
30
30
  scheme: n = "red",
31
- placement: s = "top-right",
32
- value: o,
33
- maxValue: c = 99,
31
+ placement: a = "top-right",
32
+ value: r,
33
+ maxValue: s = 99,
34
34
  className: u,
35
35
  style: f,
36
36
  ...y
37
37
  }) => {
38
- const e = !o, p = T(e), t = _(null);
38
+ const e = !r, d = T(e), t = _(null);
39
39
  if (w(() => {
40
- var r;
41
- p && !e && ((r = t.current) == null || r.classList.add(g.appear));
42
- }, [p, e]), l(() => {
43
- if (!e && s && t.current) {
44
- const r = t.current.clientHeight, d = t.current.parentElement, i = d ? Math.min(
45
- parseInt(getComputedStyle(d).getPropertyValue("border-radius")),
46
- d.clientHeight / 2
47
- ) : 0, b = i * (1 - Math.sin(45 * Math.PI / 180)), m = (1 + Math.min(i / r, 1)) * (r / 4);
40
+ d && !e && t.current?.classList.add(c.appear);
41
+ }, [d, e]), l(() => {
42
+ if (!e && a && t.current?.parentElement) {
43
+ const g = t.current.clientHeight, p = t.current.parentElement, i = Math.min(
44
+ parseInt(getComputedStyle(p).getPropertyValue("border-radius")) || 0,
45
+ p.clientHeight / 2
46
+ ), b = i * (1 - Math.sin(45 * Math.PI / 180)), m = (1 + Math.min(i / g, 1)) * (g / 4);
48
47
  t.current.style.setProperty("--offset", `${b - m}px`);
49
48
  }
50
- }, [e, s]), e)
49
+ }, [e, a]), e)
51
50
  return null;
52
- const B = typeof o == "number" && c > 0 && o > c;
51
+ const B = typeof r == "number" && s > 0 && r > s;
53
52
  return /* @__PURE__ */ h(
54
53
  "div",
55
54
  {
56
55
  ...y,
57
56
  ref: t,
58
57
  "data-badge": n,
59
- "data-placement": s,
60
- className: E(g.badge, g[n], u),
61
- style: { ...f, ...H({ size: a }) },
62
- children: P(B ? `${c}+` : o, "span")
58
+ "data-placement": a,
59
+ className: E(c.badge, c[n], u),
60
+ style: { ...f, ...H({ size: o }) },
61
+ children: P(B ? `${s}+` : r, "span")
63
62
  }
64
63
  );
65
64
  };
@@ -23,4 +23,4 @@ export declare const Button: <T extends React.ElementType = "button">(props: {
23
23
  title?: React.ReactNode;
24
24
  icon?: React.ReactElement;
25
25
  iconPosition?: "start" | "end";
26
- } & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "title" | "size" | "as" | "icon" | "scheme" | "minWidth" | "maxWidth" | "variant" | "busy" | "iconPosition"> & React.RefAttributes<unknown>) => React.ReactElement | null;
26
+ } & Omit<React.PropsWithoutRef<React.ComponentProps<T>>, "title" | "as" | "size" | "icon" | "scheme" | "minWidth" | "maxWidth" | "variant" | "busy" | "iconPosition"> & React.RefAttributes<unknown>) => React.ReactElement | null;
@@ -1,16 +1,16 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import h, { useState as x, useLayoutEffect as m, useContext as y } from "react";
2
+ import h, { useState as x, useLayoutEffect as m, useContext as p } from "react";
3
3
  import s from "classnames";
4
- import { useFloating as N, useInteractions as L, useDismiss as E, useRole as S, useMergeRefs as k, FloatingPortal as M, FloatingOverlay as O, FloatingFocusManager as Q, useId as j } from "@floating-ui/react";
5
- import { cssProps as q } from "../../utils/helpers.js";
6
- import { DialogContext as d } from "./DialogContext.js";
7
- import { Button as w } from "../Button/Button.js";
8
- import { Heading as B } from "../Heading/Heading.js";
9
- import { Icon as G } from "../Icon/Icon.js";
10
- const H = "Dialog_overlay_C98Qt", J = "Dialog_dialog_G3gxL", P = "Dialog_title_2pDPQ", V = "Dialog_footer_N-aEV", z = "Dialog_close_JSEkn", r = {
11
- overlay: H,
12
- dialog: J,
13
- title: P,
4
+ import { useFloating as N, useInteractions as P, useDismiss as L, useRole as E, useMergeRefs as S, FloatingPortal as k, FloatingOverlay as M, FloatingFocusManager as O, useId as Q } from "@floating-ui/react";
5
+ import { cssProps as j } from "../../utils/helpers.js";
6
+ import { DialogContext as c } from "./DialogContext.js";
7
+ import { Button as q } from "../Button/Button.js";
8
+ import { Heading as w } from "../Heading/Heading.js";
9
+ import { Icon as B } from "../Icon/Icon.js";
10
+ const G = "Dialog_overlay_C98Qt", H = "Dialog_dialog_G3gxL", J = "Dialog_title_2pDPQ", V = "Dialog_footer_N-aEV", z = "Dialog_close_JSEkn", i = {
11
+ overlay: G,
12
+ dialog: H,
13
+ title: J,
14
14
  footer: V,
15
15
  close: z
16
16
  }, oo = h.forwardRef(
@@ -19,73 +19,73 @@ const H = "Dialog_overlay_C98Qt", J = "Dialog_dialog_G3gxL", P = "Dialog_title_2
19
19
  size: e,
20
20
  width: a,
21
21
  lockScroll: l = !0,
22
- style: i,
23
- className: v,
24
- children: D,
25
- setTriggerProps: n,
26
- requestClose: u,
27
- ..._
28
- }, p) => {
29
- const [f, b] = x(), { refs: F, context: c } = N({
22
+ style: r,
23
+ className: y,
24
+ children: v,
25
+ setTriggerProps: d,
26
+ requestClose: g,
27
+ ...D
28
+ }, _) => {
29
+ const [u, b] = x(), { refs: F, context: n } = N({
30
30
  open: o,
31
- onOpenChange: u
32
- }), { getFloatingProps: C, getReferenceProps: g } = L([
33
- E(c),
34
- S(c, { role: "dialog" })
31
+ onOpenChange: g
32
+ }), { getFloatingProps: C, getReferenceProps: f } = P([
33
+ L(n),
34
+ E(n, { role: "dialog" })
35
35
  ]);
36
36
  m(() => {
37
- n == null || n(g());
38
- }, [n, g]);
39
- const I = k([F.setFloating, p]), R = document.querySelector("[data-floating-root]") ?? document.body;
40
- return o ? /* @__PURE__ */ t(d.Provider, { value: { labelId: f, setLabelId: b, requestClose: u }, children: /* @__PURE__ */ t(M, { root: R, children: /* @__PURE__ */ t(
41
- O,
37
+ d?.(f());
38
+ }, [d, f]);
39
+ const I = S([F.setFloating, _]), R = document.querySelector("[data-floating-root]") ?? document.body;
40
+ return o ? /* @__PURE__ */ t(c.Provider, { value: { labelId: u, setLabelId: b, requestClose: g }, children: /* @__PURE__ */ t(k, { root: R, children: /* @__PURE__ */ t(
41
+ M,
42
42
  {
43
43
  "data-floating-root": !0,
44
44
  "data-dialog-overlay": !0,
45
45
  lockScroll: l,
46
- className: r.overlay,
47
- children: /* @__PURE__ */ t(Q, { context: c, children: /* @__PURE__ */ t(
46
+ className: i.overlay,
47
+ children: /* @__PURE__ */ t(O, { context: n, children: /* @__PURE__ */ t(
48
48
  "div",
49
49
  {
50
- ...C(_),
50
+ ...C(D),
51
51
  ref: I,
52
52
  "data-dialog": !0,
53
53
  "data-open": o,
54
- "aria-labelledby": f,
55
- className: s(r.dialog, v),
56
- style: { ...i, ...q({ size: e, width: a }) },
57
- children: D
54
+ "aria-labelledby": u,
55
+ className: s(i.dialog, y),
56
+ style: { ...r, ...j({ size: e, width: a }) },
57
+ children: v
58
58
  }
59
59
  ) })
60
60
  }
61
61
  ) }) }) : null;
62
62
  }
63
63
  ), to = ({ className: o, children: e, ...a }) => {
64
- const l = j(), { setLabelId: i } = y(d);
65
- return m(() => (i(l), () => i(void 0)), [l, i]), /* @__PURE__ */ t(
66
- B,
64
+ const l = Q(), { setLabelId: r } = p(c);
65
+ return m(() => (r(l), () => r(void 0)), [l, r]), /* @__PURE__ */ t(
66
+ w,
67
67
  {
68
68
  as: "h4",
69
69
  ...a,
70
70
  id: l,
71
71
  "data-dialog-title": !0,
72
72
  title: e,
73
- className: s(r.title, o)
73
+ className: s(i.title, o)
74
74
  }
75
75
  );
76
- }, eo = (o) => /* @__PURE__ */ t("div", { ...o, "data-dialog-content": !0 }), ao = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { ...e, "data-dialog-footer": !0, className: s(r.footer, o) }), lo = ({ className: o, ...e }) => {
77
- const { requestClose: a } = y(d);
76
+ }, eo = (o) => /* @__PURE__ */ t("div", { ...o, "data-dialog-content": !0 }), ao = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { ...e, "data-dialog-footer": !0, className: s(i.footer, o) }), lo = ({ className: o, ...e }) => {
77
+ const { requestClose: a } = p(c);
78
78
  return /* @__PURE__ */ t(
79
- w,
79
+ q,
80
80
  {
81
81
  type: "button",
82
82
  variant: "tertiary",
83
83
  "aria-label": "close dialog",
84
- icon: /* @__PURE__ */ t(G, { name: "close" }),
84
+ icon: /* @__PURE__ */ t(B, { name: "close" }),
85
85
  onClick: a,
86
86
  ...e,
87
87
  "data-dialog-close": !0,
88
- className: s(r.close, o)
88
+ className: s(i.close, o)
89
89
  }
90
90
  );
91
91
  };
@@ -1,23 +1,26 @@
1
- export type DialogOptions<T, R> = {
1
+ type DialogShowOptions<R> = {
2
+ onConfirm?: (values: R) => void;
3
+ onCancel?: () => void;
4
+ };
5
+ export type DialogOptions<T, R> = DialogShowOptions<R> & {
2
6
  defaultOpen?: boolean;
3
7
  onShow?: (values: T) => void;
4
- onConfirm?: (result: R) => void;
5
- onCancel?: () => void;
6
8
  };
7
9
  export type DialogType<T, R> = ReturnType<typeof useDialog<T, R>>;
8
10
  export declare function useDialog<T, R>(options?: DialogOptions<T, R>): {
9
11
  props: {
10
- ref: import('react').RefObject<HTMLDivElement>;
12
+ ref: import('react').RefObject<HTMLDivElement | null>;
11
13
  open: boolean;
12
14
  setTriggerProps: import('react').Dispatch<import('react').SetStateAction<{}>>;
13
15
  requestClose: () => void;
14
16
  };
15
17
  trigger: {
16
- onClick: (values: T) => void;
18
+ onClick: (values: T, showOptions?: DialogShowOptions<R>) => void;
17
19
  };
18
20
  data: T | undefined;
19
- show: (values: T) => void;
21
+ show: (values: T, showOptions?: DialogShowOptions<R>) => void;
20
22
  cancel: () => void;
21
23
  confirm: (values: R) => void;
22
24
  preventClose: <T_1>(promise: Promise<T_1>) => Promise<T_1>;
23
25
  };
26
+ export {};
@@ -1,40 +1,32 @@
1
- import { useRef as l, useState as f, useCallback as o } from "react";
2
- function T(r, a) {
3
- const c = r ? Math.max(
4
- ...getComputedStyle(r).transitionDuration.split(",").map((t) => parseFloat(t) * 1e3)
5
- ) : 0;
6
- setTimeout(a, c);
7
- }
8
- function v(r) {
9
- const a = l(null), c = l(r), t = l(!1), [D, b] = f({}), [h, p] = f((r == null ? void 0 : r.defaultOpen) ?? !1), [w, d] = f();
10
- c.current = r;
11
- const g = o((e) => {
12
- var n, s;
13
- t.current || (p(!0), d(e), (s = (n = c.current) == null ? void 0 : n.onShow) == null || s.call(n, e));
14
- }, []), u = o((e) => {
15
- var n;
16
- t.current || (t.current = !0, (n = a.current) == null || n.setAttribute("data-open", "false"), T(a.current, () => {
17
- var s, C, i, y;
18
- e !== void 0 ? (C = (s = c.current) == null ? void 0 : s.onConfirm) == null || C.call(s, e) : (y = (i = c.current) == null ? void 0 : i.onCancel) == null || y.call(i), p(!1), d(void 0), t.current = !1;
1
+ import { useRef as c, useState as f, useCallback as t } from "react";
2
+ import { afterTransition as v } from "../../utils/helpers.js";
3
+ function S(s) {
4
+ const u = c(null), e = c(!1), n = c(s), a = c(void 0), [d, g] = f({}), [m, i] = f(s?.defaultOpen ?? !1), [w, l] = f();
5
+ n.current = s;
6
+ const p = t((r, h = {}) => {
7
+ e.current || (a.current = h, i(!0), l(r), n.current?.onShow?.(r));
8
+ }, []), o = t((r) => {
9
+ e.current || (e.current = !0, u.current?.setAttribute("data-open", "false"), v(u.current, () => {
10
+ r !== void 0 ? (n.current?.onConfirm?.(r), a.current?.onConfirm?.(r)) : (n.current?.onCancel?.(), a.current?.onCancel?.()), i(!1), l(void 0), e.current = !1;
19
11
  }));
20
- }, []), m = o(() => u(), [u]), O = o((e) => u(e), [u]), S = o(async (e) => {
21
- t.current = !0;
12
+ }, []), C = t(() => o(), [o]), O = t((r) => o(r), [o]), b = t(async (r) => {
13
+ e.current = !0;
22
14
  try {
23
- return await e;
15
+ return await r;
24
16
  } finally {
25
- t.current = !1;
17
+ e.current = !1;
26
18
  }
27
19
  }, []);
28
20
  return {
29
- props: { ref: a, open: h, setTriggerProps: b, requestClose: m },
30
- trigger: { ...D, onClick: g },
21
+ props: { ref: u, open: m, setTriggerProps: g, requestClose: C },
22
+ trigger: { ...d, onClick: p },
31
23
  data: w,
32
- show: g,
33
- cancel: m,
24
+ show: p,
25
+ cancel: C,
34
26
  confirm: O,
35
- preventClose: S
27
+ preventClose: b
36
28
  };
37
29
  }
38
30
  export {
39
- v as useDialog
31
+ S as useDialog
40
32
  };
@@ -1,28 +1,28 @@
1
- import { jsxs as h, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as h, jsx as o } from "react/jsx-runtime";
2
2
  import i from "classnames";
3
- import p, { useRef as x, useImperativeHandle as b, useEffect as k } from "react";
3
+ import k, { useRef as x, useImperativeHandle as b, useEffect as p } from "react";
4
4
  import { cssProps as R } from "../../utils/helpers.js";
5
- import { I as y, s as l } from "../../Input-BG84zXZH.js";
6
- const q = p.forwardRef(
7
- ({ size: c, error: n, label: t, className: u, style: f, required: m, indeterminate: r, ...o }, d) => {
8
- const s = o.checked, e = x(null);
9
- return b(d, () => e.current), k(() => {
10
- r != null && e.current != null && (e.current.indeterminate = !s && r);
11
- }, [e, r, s]), /* @__PURE__ */ h(
5
+ import { I as y, s } from "../../Input-BG84zXZH.js";
6
+ const _ = k.forwardRef(
7
+ ({ size: t, error: u, label: a, className: f, style: n, required: d, indeterminate: c, ...r }, m) => {
8
+ const l = r.checked || r.defaultChecked, e = x(null);
9
+ return b(m, () => e.current), p(() => {
10
+ c != null && e.current != null && (e.current.indeterminate = !l && c);
11
+ }, [e, c, l]), /* @__PURE__ */ h(
12
12
  "label",
13
13
  {
14
14
  "data-checkbox": !0,
15
- "data-required": m,
16
- className: i(l.checkbox, u),
17
- style: { ...f, ...R({ size: c }) },
15
+ "data-required": d,
16
+ className: i(s.checkbox, f),
17
+ style: { ...n, ...R({ size: t }) },
18
18
  children: [
19
- /* @__PURE__ */ a(y, { ...o, ref: e, type: "checkbox", size: c, error: n }),
20
- t && /* @__PURE__ */ a("div", { "data-checkbox-label": !0, className: l.label, children: t })
19
+ /* @__PURE__ */ o(y, { ...r, ref: e, type: "checkbox", size: t, error: u }),
20
+ a && /* @__PURE__ */ o("div", { "data-checkbox-label": !0, className: s.label, children: a })
21
21
  ]
22
22
  }
23
23
  );
24
24
  }
25
25
  );
26
26
  export {
27
- q as Checkbox
27
+ _ as Checkbox
28
28
  };
@@ -1,56 +1,54 @@
1
- import { jsxs as f, jsx as a } from "react/jsx-runtime";
2
- import y from "classnames";
3
- import _, { useRef as h, useImperativeHandle as v, useCallback as s } from "react";
4
- import { Icon as i } from "../Icon/Icon.js";
5
- import { Button as o } from "../Button/Button.js";
1
+ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
+ import b from "classnames";
3
+ import f, { useRef as y, useImperativeHandle as _, useCallback as a } from "react";
4
+ import { Icon as c } from "../Icon/Icon.js";
5
+ import { Button as s } from "../Button/Button.js";
6
6
  import "../../utils/helpers.js";
7
- import { I as w } from "../../Input-BG84zXZH.js";
8
- const E = "styles_numeric_dzUSE", R = "styles_increase_5S-Jo", g = "styles_decrease_j8UR6", c = {
9
- numeric: E,
10
- increase: R,
11
- decrease: g
12
- }, C = _.forwardRef(
13
- ({ labelIncrease: l = "increase", labelDecrease: d = "decrease", className: u, ...n }, m) => {
14
- const e = h(null);
15
- v(m, () => e.current);
16
- const p = s(() => {
17
- var r, t;
18
- (r = e.current) == null || r.stepUp(), (t = e.current) == null || t.dispatchEvent(new Event("change", { bubbles: !0 }));
19
- }, []), b = s(() => {
20
- var r, t;
21
- (r = e.current) == null || r.stepDown(), (t = e.current) == null || t.dispatchEvent(new Event("change", { bubbles: !0 }));
7
+ import { I as h } from "../../Input-BG84zXZH.js";
8
+ const v = "styles_numeric_dzUSE", w = "styles_increase_5S-Jo", E = "styles_decrease_j8UR6", t = {
9
+ numeric: v,
10
+ increase: w,
11
+ decrease: E
12
+ }, k = f.forwardRef(
13
+ ({ labelIncrease: i = "increase", labelDecrease: o = "decrease", className: l, ...n }, d) => {
14
+ const e = y(null);
15
+ _(d, () => e.current);
16
+ const u = a(() => {
17
+ e.current?.stepUp(), e.current?.dispatchEvent(new Event("change", { bubbles: !0 }));
18
+ }, []), m = a(() => {
19
+ e.current?.stepDown(), e.current?.dispatchEvent(new Event("change", { bubbles: !0 }));
22
20
  }, []);
23
- return /* @__PURE__ */ f(
24
- w,
21
+ return /* @__PURE__ */ p(
22
+ h,
25
23
  {
26
24
  ...n,
27
25
  ref: e,
28
26
  type: "number",
29
27
  wrapperType: "numeric",
30
- className: y(c.numeric, u),
28
+ className: b(t.numeric, l),
31
29
  children: [
32
- /* @__PURE__ */ a(
33
- o,
30
+ /* @__PURE__ */ r(
31
+ s,
34
32
  {
35
33
  type: "button",
36
34
  variant: "secondary",
37
- "aria-label": l,
35
+ "aria-label": i,
38
36
  disabled: n.disabled || n.readOnly,
39
- className: c.increase,
40
- icon: /* @__PURE__ */ a(i, { name: "triangle-up" }),
41
- onClick: p
37
+ className: t.increase,
38
+ icon: /* @__PURE__ */ r(c, { name: "triangle-up" }),
39
+ onClick: u
42
40
  }
43
41
  ),
44
- /* @__PURE__ */ a(
45
- o,
42
+ /* @__PURE__ */ r(
43
+ s,
46
44
  {
47
45
  type: "button",
48
46
  variant: "secondary",
49
- "aria-label": d,
47
+ "aria-label": o,
50
48
  disabled: n.disabled || n.readOnly,
51
- className: c.decrease,
52
- icon: /* @__PURE__ */ a(i, { name: "triangle-down" }),
53
- onClick: b
49
+ className: t.decrease,
50
+ icon: /* @__PURE__ */ r(c, { name: "triangle-down" }),
51
+ onClick: m
54
52
  }
55
53
  )
56
54
  ]
@@ -59,5 +57,5 @@ const E = "styles_numeric_dzUSE", R = "styles_increase_5S-Jo", g = "styles_decre
59
57
  }
60
58
  );
61
59
  export {
62
- C as Numeric
60
+ k as Numeric
63
61
  };
@@ -10,7 +10,7 @@ export type RangeProps = Omit<BaseInputProps, 'min' | 'max' | 'value' | 'default
10
10
  defaultValue?: number;
11
11
  ticks?: TickMarksProps['ticks'];
12
12
  };
13
- export declare const Range: React.ForwardRefExoticComponent<Omit<BaseInputProps, "max" | "min" | "defaultValue" | "value"> & {
13
+ export declare const Range: React.ForwardRefExoticComponent<Omit<BaseInputProps, "defaultValue" | "value" | "max" | "min"> & {
14
14
  min?: number;
15
15
  max?: number;
16
16
  value?: number;