@kolking/react-ui 1.8.7 → 1.8.8

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.
@@ -4,12 +4,12 @@ import { flushSync as D } from "react-dom";
4
4
  import { useFloating as H, offset as U, flip as q, size as G, autoUpdate as J, useInteractions as K, useDismiss as Q, useRole as T, useClick as V, useListNavigation as X, useMergeRefs as Y, FloatingPortal as Z, FloatingFocusManager as $, FloatingList as ee } from "@floating-ui/react";
5
5
  import te from "classnames";
6
6
  import { MenuContext as oe } from "./MenuContext.js";
7
- import { cssProps as ne } from "../../utils/helpers.js";
8
- import { s as se } from "../../styles.module-DHm-YTnz.js";
9
- const de = ({
7
+ import { getElementRef as ne, cssProps as se } from "../../utils/helpers.js";
8
+ import { s as re } from "../../styles.module-DHm-YTnz.js";
9
+ const pe = ({
10
10
  size: h,
11
- placement: u = "bottom-start",
12
- trigger: o,
11
+ placement: c = "bottom-start",
12
+ trigger: s,
13
13
  offset: R = 5,
14
14
  unmount: v = !0,
15
15
  minWidth: x,
@@ -18,25 +18,25 @@ const de = ({
18
18
  maxHeight: M,
19
19
  className: P,
20
20
  children: z,
21
- onSelect: c,
21
+ onSelect: m,
22
22
  ...w
23
23
  }) => {
24
- const [r, m] = l(!1), [i, C] = l(null), [E, I] = l({}), f = g([]), d = g(null), { refs: n, context: e, floatingStyles: N } = H({
24
+ const [r, u] = l(!1), [i, C] = l(null), [E, I] = l({}), f = g([]), d = g(null), { refs: o, context: e, floatingStyles: N } = H({
25
25
  open: r,
26
- placement: u,
27
- onOpenChange: m,
26
+ placement: c,
27
+ onOpenChange: u,
28
28
  whileElementsMounted: J,
29
29
  middleware: [
30
30
  U(R),
31
31
  q({ padding: 10 }),
32
32
  G({
33
33
  padding: 10,
34
- apply({ rects: a, availableWidth: s, availableHeight: L }) {
34
+ apply({ rects: a, availableWidth: n, availableHeight: L }) {
35
35
  D(() => {
36
36
  I({
37
37
  minHeight: y,
38
38
  minWidth: x ?? a.reference.width,
39
- maxWidth: F ?? s,
39
+ maxWidth: F ?? n,
40
40
  maxHeight: M ?? L
41
41
  });
42
42
  });
@@ -54,35 +54,32 @@ const de = ({
54
54
  onNavigate: C
55
55
  })
56
56
  ]), j = k(
57
- () => ({ active: i, setOpen: m, getItemProps: p, onSelect: c }),
58
- [i, p, c]
59
- ), B = Y([
60
- n.setReference,
61
- "ref" in o ? o.ref : null
62
- ]);
57
+ () => ({ active: i, setOpen: u, getItemProps: p, onSelect: m }),
58
+ [i, p, m]
59
+ ), B = Y([o.setReference, ne(s)]);
63
60
  return A(() => {
64
- var s;
65
- const a = (s = n.domReference.current) == null ? void 0 : s.closest("[data-floating-root]");
61
+ var n;
62
+ const a = (n = o.domReference.current) == null ? void 0 : n.closest("[data-floating-root]");
66
63
  d.current = a ?? document.body;
67
- }, [n]), /* @__PURE__ */ O(W, { children: [
64
+ }, [o]), /* @__PURE__ */ O(W, { children: [
68
65
  _.cloneElement(
69
- o,
70
- S({ ref: B, "data-menu-trigger": !0, ...o.props })
66
+ s,
67
+ S({ ...s.props, ref: B, "data-menu-trigger": !0 })
71
68
  ),
72
69
  /* @__PURE__ */ t(oe.Provider, { value: j, children: (r || !v) && /* @__PURE__ */ t(Z, { root: d.current, children: /* @__PURE__ */ t($, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
73
70
  "div",
74
71
  {
75
72
  ...b(w),
76
- ref: n.setFloating,
73
+ ref: o.setFloating,
77
74
  "data-open": r,
78
- "data-menu": u,
79
- className: te(se.menu, P),
80
- style: { ...N, ...E, ...ne({ size: h }) },
75
+ "data-menu": c,
76
+ className: te(re.menu, P),
77
+ style: { ...N, ...E, ...se({ size: h }) },
81
78
  children: /* @__PURE__ */ t(ee, { elementsRef: f, children: z })
82
79
  }
83
80
  ) }) }) })
84
81
  ] });
85
82
  };
86
83
  export {
87
- de as Menu
84
+ pe as Menu
88
85
  };
@@ -2,27 +2,28 @@ import { jsxs as w, Fragment as C, jsx as r } from "react/jsx-runtime";
2
2
  import D, { useRef as H, useState as S, useEffect as U, useLayoutEffect as X } from "react";
3
3
  import b from "classnames";
4
4
  import { useFloating as B, offset as I, flip as L, shift as N, autoUpdate as T, useInteractions as q, useDismiss as z, useRole as A, useHover as G, useFocus as J, useClick as K, useMergeRefs as Q, FloatingPortal as V, FloatingFocusManager as W } from "@floating-ui/react";
5
- const Y = "Popover_popover_sXXB0", Z = {
6
- popover: Y
7
- }, te = ({
5
+ import { getElementRef as Y } from "../../utils/helpers.js";
6
+ const Z = "Popover_popover_sXXB0", $ = {
7
+ popover: Z
8
+ }, le = ({
8
9
  open: m,
9
- event: t = "click",
10
+ event: s = "click",
10
11
  placement: c = "bottom",
11
- trigger: s,
12
+ trigger: t,
12
13
  offset: g = 5,
13
14
  modal: f = !1,
14
15
  anchor: n,
15
16
  boundary: i,
16
17
  disabled: l,
17
- minWidth: v,
18
- maxWidth: R,
18
+ minWidth: R,
19
+ maxWidth: v,
19
20
  className: F,
20
21
  children: P,
21
22
  onToggle: h,
22
- ...x
23
+ ...E
23
24
  }) => {
24
- const a = H(null), [y, E] = S(!1), p = m ?? y, O = h ?? E, { refs: e, context: o, floatingStyles: _ } = B({
25
- open: p,
25
+ const p = H(null), [x, y] = S(!1), a = m ?? x, O = h ?? y, { refs: e, context: o, floatingStyles: _ } = B({
26
+ open: a,
26
27
  placement: c,
27
28
  onOpenChange: O,
28
29
  whileElementsMounted: T,
@@ -34,34 +35,31 @@ const Y = "Popover_popover_sXXB0", Z = {
34
35
  }), { getReferenceProps: k, getFloatingProps: M } = q([
35
36
  z(o),
36
37
  A(o, { role: "dialog" }),
37
- G(o, { move: !1, enabled: t.includes("hover") }),
38
- J(o, { enabled: t.includes("focus") }),
39
- K(o, { enabled: t.includes("click") })
40
- ]), j = Q([
41
- e.setReference,
42
- "ref" in s ? s.ref : null
43
- ]);
38
+ G(o, { move: !1, enabled: s.includes("hover") }),
39
+ J(o, { enabled: s.includes("focus") }),
40
+ K(o, { enabled: s.includes("click") })
41
+ ]), j = Q([e.setReference, Y(t)]);
44
42
  return U(() => {
45
43
  var d;
46
44
  const u = (d = e.domReference.current) == null ? void 0 : d.closest("[data-floating-root]");
47
- !l && u && (a.current = u);
45
+ !l && u && (p.current = u);
48
46
  }, [e, l]), X(() => {
49
47
  n && e.setPositionReference(n);
50
- }, [e, n]), l ? s : /* @__PURE__ */ w(C, { children: [
51
- D.cloneElement(s, k({ ref: j, ...s.props })),
52
- p && /* @__PURE__ */ r(V, { root: a, children: /* @__PURE__ */ r(W, { context: o, modal: f, visuallyHiddenDismiss: f, children: /* @__PURE__ */ r(
48
+ }, [e, n]), l ? t : /* @__PURE__ */ w(C, { children: [
49
+ D.cloneElement(t, k({ ...t.props, ref: j })),
50
+ a && /* @__PURE__ */ r(V, { root: p, children: /* @__PURE__ */ r(W, { context: o, modal: f, visuallyHiddenDismiss: f, children: /* @__PURE__ */ r(
53
51
  "div",
54
52
  {
55
- ...M(x),
53
+ ...M(E),
56
54
  ref: e.setFloating,
57
55
  "data-popover": c,
58
- className: b(Z.popover, F),
59
- style: { ..._, minWidth: v, maxWidth: R },
56
+ className: b($.popover, F),
57
+ style: { ..._, minWidth: R, maxWidth: v },
60
58
  children: P
61
59
  }
62
60
  ) }) })
63
61
  ] });
64
62
  };
65
63
  export {
66
- te as Popover
64
+ le as Popover
67
65
  };
@@ -2,11 +2,12 @@ import { jsxs as m, Fragment as S, jsx as f } from "react/jsx-runtime";
2
2
  import j, { useRef as g, useState as w, useEffect as k, useLayoutEffect as C } from "react";
3
3
  import U from "classnames";
4
4
  import { useFloating as W, offset as b, flip as A, shift as B, arrow as D, autoUpdate as H, useInteractions as I, useDismiss as L, useRole as V, useHover as $, useFocus as q, useClick as z, useMergeRefs as G, FloatingPortal as J, FloatingArrow as K } from "@floating-ui/react";
5
- const Q = "Tooltip_tooltip_u1Uix", X = "Tooltip_arrow_NBFiV", Y = "Tooltip_content_lfpfM", a = {
6
- tooltip: Q,
7
- arrow: X,
8
- content: Y
9
- }, st = ({
5
+ import { getElementRef as Q } from "../../utils/helpers.js";
6
+ const X = "Tooltip_tooltip_u1Uix", Y = "Tooltip_arrow_NBFiV", Z = "Tooltip_content_lfpfM", a = {
7
+ tooltip: X,
8
+ arrow: Y,
9
+ content: Z
10
+ }, rt = ({
10
11
  trigger: r = "hover focus",
11
12
  placement: c = "top",
12
13
  offset: R = 8,
@@ -16,20 +17,20 @@ const Q = "Tooltip_tooltip_u1Uix", X = "Tooltip_arrow_NBFiV", Y = "Tooltip_conte
16
17
  minWidth: F,
17
18
  maxWidth: _,
18
19
  className: v,
19
- children: o,
20
+ children: n,
20
21
  ...x
21
22
  }) => {
22
- const u = g(null), p = g(null), [d, O] = w(!1), [y, E] = w(!1), { refs: t, context: e, floatingStyles: N } = W({
23
+ const u = g(null), p = g(null), [d, E] = w(!1), [O, y] = w(!1), { refs: t, context: e, floatingStyles: N } = W({
23
24
  open: d,
24
25
  placement: c,
25
- onOpenChange: O,
26
+ onOpenChange: E,
26
27
  whileElementsMounted: H,
27
28
  middleware: [
28
29
  b(R),
29
30
  A({ padding: 10 }),
30
31
  B({ padding: 5 }),
31
- D(({ placement: s, rects: n }) => (E(
32
- n.floating.width < n.reference.width && (s.endsWith("-start") || s.endsWith("-end"))
32
+ D(({ placement: o, rects: s }) => (y(
33
+ s.floating.width < s.reference.width && (o.endsWith("-start") || o.endsWith("-end"))
33
34
  ), { element: u, padding: 8 }))
34
35
  ]
35
36
  }), { getReferenceProps: P, getFloatingProps: T } = I([
@@ -38,18 +39,15 @@ const Q = "Tooltip_tooltip_u1Uix", X = "Tooltip_arrow_NBFiV", Y = "Tooltip_conte
38
39
  $(e, { move: !1, enabled: r.includes("hover") }),
39
40
  q(e, { enabled: r.includes("focus") }),
40
41
  z(e, { enabled: r.includes("click") })
41
- ]), M = G([
42
- t.setReference,
43
- "ref" in o ? o.ref : null
44
- ]);
42
+ ]), M = G([t.setReference, Q(n)]);
45
43
  return k(() => {
46
- var n;
47
- const s = (n = t.domReference.current) == null ? void 0 : n.closest("[data-floating-root]");
48
- !i && s && (p.current = s);
44
+ var s;
45
+ const o = (s = t.domReference.current) == null ? void 0 : s.closest("[data-floating-root]");
46
+ !i && o && (p.current = o);
49
47
  }, [t, i]), C(() => {
50
48
  l && t.setPositionReference(l);
51
- }, [t, l]), i ? o : /* @__PURE__ */ m(S, { children: [
52
- j.cloneElement(o, P({ ref: M, ...o.props })),
49
+ }, [t, l]), i ? n : /* @__PURE__ */ m(S, { children: [
50
+ j.cloneElement(n, P({ ...n.props, ref: M })),
53
51
  d && /* @__PURE__ */ f(J, { root: p, children: /* @__PURE__ */ m(
54
52
  "div",
55
53
  {
@@ -67,7 +65,7 @@ const Q = "Tooltip_tooltip_u1Uix", X = "Tooltip_arrow_NBFiV", Y = "Tooltip_conte
67
65
  ref: u,
68
66
  context: e,
69
67
  className: a.arrow,
70
- staticOffset: y ? 8 : null
68
+ staticOffset: O ? 8 : null
71
69
  }
72
70
  ),
73
71
  /* @__PURE__ */ f("div", { "data-tooltip-content": !0, className: a.content, children: h })
@@ -77,5 +75,5 @@ const Q = "Tooltip_tooltip_u1Uix", X = "Tooltip_arrow_NBFiV", Y = "Tooltip_conte
77
75
  ] });
78
76
  };
79
77
  export {
80
- st as Tooltip
78
+ rt as Tooltip
81
79
  };
@@ -4,6 +4,7 @@ export declare function cssProps(values: {
4
4
  [key: string]: number | string | undefined;
5
5
  }): React.CSSProperties;
6
6
  export declare function wrapNode(node: React.ReactNode, Wrapper: React.ElementType): boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
7
+ export declare function getElementRef(element: React.JSX.Element): React.Ref<Element>;
7
8
  export declare function getErrorMessage(error: unknown): string;
8
9
  export type PolymorphicProps<T extends React.ElementType, P = Record<string, never>> = P & Omit<React.ComponentPropsWithoutRef<T>, keyof P>;
9
10
  export type PolymorphicRef<T extends React.ElementType> = React.ComponentPropsWithRef<T>['ref'];
@@ -1,32 +1,36 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import f from "react";
3
- function p(r, t, e) {
2
+ import s from "react";
3
+ function a(r, t, e) {
4
4
  return Math.max(t, Math.min(r, e));
5
5
  }
6
- function c(r) {
6
+ function i(r) {
7
7
  return r.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
8
8
  }
9
- function i(r, t) {
9
+ function u(r, t) {
10
10
  return typeof t == "number" ? `${t}px` : typeof t == "string" ? t.replace(/(^|\s)([1-4]?xs|sm|md|lg|[1-4]?xl)(?=$|\s)/g, `$1var(--${r}-$2)`) : t;
11
11
  }
12
12
  function m(r) {
13
13
  const t = {};
14
14
  return Object.keys(r).map((e) => {
15
- const n = c(e), s = i(n, r[e]);
16
- s && (t[`--${n}`] = s);
15
+ const n = i(e), f = u(n, r[e]);
16
+ f && (t[`--${n}`] = f);
17
17
  }), t;
18
18
  }
19
19
  function g(r, t) {
20
20
  return typeof r == "string" || typeof r == "number" ? /* @__PURE__ */ o(t, { children: r }) : r;
21
21
  }
22
22
  function $(r) {
23
+ return parseInt(s.version, 10) >= 19 && r.props.ref ? r.props.ref : "ref" in r ? r.ref : null;
24
+ }
25
+ function l(r) {
23
26
  return r instanceof Error && r.message ? r.message : typeof r == "string" ? r : "An error occurred";
24
27
  }
25
- const x = f.forwardRef;
28
+ const x = s.forwardRef;
26
29
  export {
27
- p as clamp,
30
+ a as clamp,
28
31
  m as cssProps,
29
32
  x as fixedForwardRef,
30
- $ as getErrorMessage,
33
+ $ as getElementRef,
34
+ l as getErrorMessage,
31
35
  g as wrapNode
32
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolking/react-ui",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "description": "React component library for building user interfaces",
5
5
  "author": "Nick Seryakov (https://github.com/kolking)",
6
6
  "license": "MIT",