@kolking/react-ui 1.7.3 → 1.8.0

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.
@@ -5,13 +5,17 @@ export type DialogProps = React.HTMLAttributes<HTMLDivElement> & {
5
5
  open?: boolean;
6
6
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
7
7
  width?: React.CSSProperties['width'];
8
+ lockScroll?: boolean;
8
9
  requestClose: () => void;
10
+ setTriggerProps?: React.Dispatch<React.SetStateAction<object>>;
9
11
  };
10
12
  export declare const Dialog: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
11
13
  open?: boolean;
12
14
  size?: "xs" | "sm" | "md" | "lg" | "xl";
13
15
  width?: React.CSSProperties["width"];
16
+ lockScroll?: boolean;
14
17
  requestClose: () => void;
18
+ setTriggerProps?: React.Dispatch<React.SetStateAction<object>>;
15
19
  } & React.RefAttributes<HTMLDivElement>>;
16
20
  export declare const DialogTitle: ({ className, children, ...props }: Omit<HeadingProps, "title">) => import("react/jsx-runtime").JSX.Element;
17
21
  export declare const DialogContent: (props: React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
@@ -1,76 +1,98 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import y, { useRef as D, useImperativeHandle as _, useEffect as E } from "react";
3
- import { createPortal as k } from "react-dom";
4
- import { FocusTrap as h } from "focus-trap-react";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import h, { useState as x, useLayoutEffect as m, useContext as y } from "react";
5
3
  import s from "classnames";
6
- import { cssProps as L } from "../../utils/helpers.js";
7
- import { Button as N } from "../Button/Button.js";
8
- import { Heading as b } from "../Heading/Heading.js";
9
- import { Icon as w } from "../Icon/Icon.js";
10
- const x = "Dialog_overlay_C98Qt", R = "Dialog_dialog_G3gxL", T = "Dialog_footer_N-aEV", I = "Dialog_close_JSEkn", i = {
11
- overlay: x,
12
- dialog: R,
13
- footer: T,
14
- close: I
15
- }, P = { escapeDeactivates: !1 }, Q = y.forwardRef(
16
- ({ open: t = !1, size: e, width: l, style: g, className: m, children: u, requestClose: n, ...p }, v) => {
17
- const c = D(null);
18
- return _(v, () => c.current), E(() => {
19
- const r = c.current;
20
- if (r && t) {
21
- let d = function(a) {
22
- a.target === a.currentTarget && n();
23
- }, f = function(a) {
24
- a.key === "Escape" && (a.stopPropagation(), a.preventDefault(), n());
25
- };
26
- return r.addEventListener("click", d), r.addEventListener("keydown", f), () => {
27
- r.removeEventListener("click", d), r.removeEventListener("keydown", f);
28
- };
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,
14
+ footer: V,
15
+ close: z
16
+ }, oo = h.forwardRef(
17
+ ({
18
+ open: o = !1,
19
+ size: e,
20
+ width: a,
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({
30
+ open: o,
31
+ onOpenChange: u
32
+ }), { getFloatingProps: C, getReferenceProps: g } = L([
33
+ E(c),
34
+ S(c, { role: "dialog" })
35
+ ]);
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,
42
+ {
43
+ "data-floating-root": !0,
44
+ "data-dialog-overlay": !0,
45
+ lockScroll: l,
46
+ className: r.overlay,
47
+ children: /* @__PURE__ */ t(Q, { context: c, children: /* @__PURE__ */ t(
48
+ "div",
49
+ {
50
+ ...C(_),
51
+ ref: I,
52
+ "data-dialog": !0,
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
58
+ }
59
+ ) })
29
60
  }
30
- }, [t, n]), t ? k(
31
- /* @__PURE__ */ o(h, { active: t, focusTrapOptions: P, children: /* @__PURE__ */ o(
32
- "div",
33
- {
34
- ...p,
35
- ref: c,
36
- tabIndex: 0,
37
- "data-dialog": !0,
38
- "data-open": t,
39
- "data-floating-root": !0,
40
- className: i.overlay,
41
- children: /* @__PURE__ */ o(
42
- "div",
43
- {
44
- role: "alertdialog",
45
- "aria-modal": "true",
46
- "data-dialog-wrapper": !0,
47
- className: s(i.dialog, m),
48
- style: { ...g, ...L({ size: e, width: l }) },
49
- children: u
50
- }
51
- )
52
- }
53
- ) }),
54
- // Append to an element with data-floating-root attribute
55
- document.querySelector("[data-floating-root]") ?? document.body
56
- ) : null;
61
+ ) }) }) : null;
57
62
  }
58
- ), V = ({ className: t, children: e, ...l }) => /* @__PURE__ */ o(b, { as: "h4", ...l, "data-dialog-title": !0, title: e, className: t }), z = (t) => /* @__PURE__ */ o("div", { ...t, "data-dialog-content": !0 }), A = ({ className: t, ...e }) => /* @__PURE__ */ o("div", { ...e, "data-dialog-footer": !0, className: s(i.footer, t) }), K = ({ className: t, ...e }) => /* @__PURE__ */ o(
59
- N,
60
- {
61
- type: "button",
62
- variant: "tertiary",
63
- "aria-label": "close dialog",
64
- icon: /* @__PURE__ */ o(w, { name: "close" }),
65
- ...e,
66
- "data-dialog-close": !0,
67
- className: s(i.close, t)
68
- }
69
- );
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,
67
+ {
68
+ as: "h4",
69
+ ...a,
70
+ id: l,
71
+ "data-dialog-title": !0,
72
+ title: e,
73
+ className: s(r.title, o)
74
+ }
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);
78
+ return /* @__PURE__ */ t(
79
+ w,
80
+ {
81
+ type: "button",
82
+ variant: "tertiary",
83
+ "aria-label": "close dialog",
84
+ icon: /* @__PURE__ */ t(G, { name: "close" }),
85
+ onClick: a,
86
+ ...e,
87
+ "data-dialog-close": !0,
88
+ className: s(r.close, o)
89
+ }
90
+ );
91
+ };
70
92
  export {
71
- Q as Dialog,
72
- K as DialogClose,
73
- z as DialogContent,
74
- A as DialogFooter,
75
- V as DialogTitle
93
+ oo as Dialog,
94
+ lo as DialogClose,
95
+ eo as DialogContent,
96
+ ao as DialogFooter,
97
+ to as DialogTitle
76
98
  };
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export type DialogContextProps = {
3
+ labelId?: string;
4
+ setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
5
+ requestClose: () => void;
6
+ };
7
+ export declare const DialogContext: React.Context<DialogContextProps>;
@@ -0,0 +1,5 @@
1
+ import t from "react";
2
+ const o = t.createContext({});
3
+ export {
4
+ o as DialogContext
5
+ };
@@ -9,8 +9,12 @@ export declare function useDialog<T, R>(options?: DialogOptions<T, R>): {
9
9
  props: {
10
10
  ref: import('react').RefObject<HTMLDivElement>;
11
11
  open: boolean;
12
+ setTriggerProps: import('react').Dispatch<import('react').SetStateAction<{}>>;
12
13
  requestClose: () => void;
13
14
  };
15
+ trigger: {
16
+ onClick: (values: T) => void;
17
+ };
14
18
  data: T | undefined;
15
19
  show: (values: T) => void;
16
20
  cancel: () => void;
@@ -1,35 +1,36 @@
1
- import { useRef as l, useState as y, useCallback as a } from "react";
2
- function g(t, u) {
3
- setTimeout(
4
- u,
5
- t ? parseFloat(getComputedStyle(t).transitionDuration) * 1e3 : 0
6
- );
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
7
  }
8
- function v(t) {
9
- const u = l(null), s = l(t), c = l(!1), [D, i] = y((t == null ? void 0 : t.defaultOpen) ?? !1), [b, d] = y();
10
- s.current = t;
11
- const w = a((e) => {
12
- var r, n;
13
- c.current || (i(!0), d(e), (n = (r = s.current) == null ? void 0 : r.onShow) == null || n.call(r, e));
14
- }, []), o = a((e) => {
15
- var r;
16
- c.current || (c.current = !0, (r = u.current) == null || r.setAttribute("data-open", "false"), g(u.current, () => {
17
- var n, C, f, m;
18
- e !== void 0 ? (C = (n = s.current) == null ? void 0 : n.onConfirm) == null || C.call(n, e) : (m = (f = s.current) == null ? void 0 : f.onCancel) == null || m.call(f), i(!1), d(void 0), c.current = !1;
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;
19
19
  }));
20
- }, []), p = a(() => o(), [o]), O = a((e) => o(e), [o]), S = a(async (e) => {
21
- c.current = !0;
20
+ }, []), m = o(() => u(), [u]), O = o((e) => u(e), [u]), S = o(async (e) => {
21
+ t.current = !0;
22
22
  try {
23
23
  return await e;
24
24
  } finally {
25
- c.current = !1;
25
+ t.current = !1;
26
26
  }
27
27
  }, []);
28
28
  return {
29
- props: { ref: u, open: D, requestClose: p },
30
- data: b,
31
- show: w,
32
- cancel: p,
29
+ props: { ref: a, open: h, setTriggerProps: b, requestClose: m },
30
+ trigger: { ...D, onClick: g },
31
+ data: w,
32
+ show: g,
33
+ cancel: m,
33
34
  confirm: O,
34
35
  preventClose: S
35
36
  };
@@ -1,55 +1,55 @@
1
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as a } from "react/jsx-runtime";
2
2
  import y from "classnames";
3
- import _, { useRef as h, useImperativeHandle as v, useCallback as c } from "react";
3
+ import _, { useRef as h, useImperativeHandle as v, useCallback as s } from "react";
4
4
  import { Icon as i } from "../Icon/Icon.js";
5
- import { Button as o } from "../Button/Button.js";
5
+ import { Button as l } from "../Button/Button.js";
6
6
  import { I as w } from "../../Input-D46mAsdt.js";
7
- const E = "styles_numeric_dzUSE", R = "styles_increase_5S-Jo", g = "styles_decrease_j8UR6", s = {
7
+ const E = "styles_numeric_dzUSE", R = "styles_increase_5S-Jo", g = "styles_decrease_j8UR6", c = {
8
8
  numeric: E,
9
9
  increase: R,
10
10
  decrease: g
11
11
  }, x = _.forwardRef(
12
- ({ labelIncrease: l = "increase", labelDecrease: u = "decrease", className: d, ...a }, m) => {
12
+ ({ labelIncrease: o = "increase", labelDecrease: d = "decrease", className: u, ...n }, m) => {
13
13
  const e = h(null);
14
14
  v(m, () => e.current);
15
- const p = c(() => {
16
- var n, r;
17
- (n = e.current) == null || n.stepUp(), (r = e.current) == null || r.dispatchEvent(new Event("change", { bubbles: !0 }));
18
- }, []), b = c(() => {
19
- var n, r;
20
- (n = e.current) == null || n.stepDown(), (r = e.current) == null || r.dispatchEvent(new Event("change", { bubbles: !0 }));
15
+ const b = s(() => {
16
+ var r, t;
17
+ (r = e.current) == null || r.stepUp(), (t = e.current) == null || t.dispatchEvent(new Event("change", { bubbles: !0 }));
18
+ }, []), p = s(() => {
19
+ var r, t;
20
+ (r = e.current) == null || r.stepDown(), (t = e.current) == null || t.dispatchEvent(new Event("change", { bubbles: !0 }));
21
21
  }, []);
22
22
  return /* @__PURE__ */ f(
23
23
  w,
24
24
  {
25
- ...a,
25
+ ...n,
26
26
  ref: e,
27
27
  type: "number",
28
28
  wrapperType: "numeric",
29
- className: y(s.numeric, d),
29
+ className: y(c.numeric, u),
30
30
  children: [
31
- /* @__PURE__ */ t(
32
- o,
31
+ /* @__PURE__ */ a(
32
+ l,
33
33
  {
34
34
  type: "button",
35
35
  variant: "secondary",
36
- "aria-label": l,
37
- disabled: a.disabled,
38
- className: s.increase,
39
- icon: /* @__PURE__ */ t(i, { name: "triangle-up" }),
40
- onClick: p
36
+ "aria-label": o,
37
+ disabled: n.disabled || n.readOnly,
38
+ className: c.increase,
39
+ icon: /* @__PURE__ */ a(i, { name: "triangle-up" }),
40
+ onClick: b
41
41
  }
42
42
  ),
43
- /* @__PURE__ */ t(
44
- o,
43
+ /* @__PURE__ */ a(
44
+ l,
45
45
  {
46
46
  type: "button",
47
47
  variant: "secondary",
48
- "aria-label": u,
49
- disabled: a.disabled,
50
- className: s.decrease,
51
- icon: /* @__PURE__ */ t(i, { name: "triangle-down" }),
52
- onClick: b
48
+ "aria-label": d,
49
+ disabled: n.disabled || n.readOnly,
50
+ className: c.decrease,
51
+ icon: /* @__PURE__ */ a(i, { name: "triangle-down" }),
52
+ onClick: p
53
53
  }
54
54
  )
55
55
  ]
@@ -4,9 +4,10 @@ export type HeadingProps = Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title
4
4
  as?: HeadingElement;
5
5
  size?: HeadingElement;
6
6
  title: React.ReactNode;
7
+ description?: React.ReactNode;
7
8
  margin?: React.CSSProperties['margin'];
8
9
  marginStart?: React.CSSProperties['marginBlockStart'];
9
10
  marginEnd?: React.CSSProperties['marginBlockEnd'];
10
11
  };
11
- export declare const Heading: ({ as: Element, size, title, margin, marginStart, marginEnd, className, children, style, ...props }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const Heading: ({ as: Element, size, title, description, margin, marginStart, marginEnd, className, children, style, ...props }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,57 +1,61 @@
1
- import { jsx as a, jsxs as f } from "react/jsx-runtime";
2
- import g from "classnames";
3
- import { cssProps as H } from "../../utils/helpers.js";
4
- const j = "Heading_h1_jZARG", u = "Heading_heading_OG4PS", p = "Heading_h2_juB1Q", x = "Heading_h3_tZEj0", v = "Heading_h4_X927D", z = "Heading_h5_047wq", B = "Heading_h6_52sKy", G = "Heading_accessory_VOBHY", h = {
1
+ import { jsxs as p, jsx as a } from "react/jsx-runtime";
2
+ import y from "classnames";
3
+ import u from "react";
4
+ import { cssProps as f } from "../../utils/helpers.js";
5
+ const j = "Heading_h1_jZARG", v = "Heading_heading_OG4PS", m = "Heading_h2_juB1Q", x = "Heading_h3_tZEj0", N = "Heading_h4_X927D", R = "Heading_h5_047wq", z = "Heading_h6_52sKy", A = "Heading_accessory_VOBHY", B = "Heading_description_iRVjv", e = {
5
6
  h1: j,
6
- heading: u,
7
- h2: p,
7
+ heading: v,
8
+ h2: m,
8
9
  h3: x,
9
- h4: v,
10
- h5: z,
11
- h6: B,
12
- accessory: G
13
- }, Z = ({
10
+ h4: N,
11
+ h5: R,
12
+ h6: z,
13
+ accessory: A,
14
+ description: B
15
+ }, V = ({
14
16
  as: s = "h2",
15
- size: y = s,
16
- title: c,
17
- margin: e,
18
- marginStart: n,
19
- marginEnd: o,
20
- className: d,
21
- children: i,
22
- style: t,
23
- ...r
17
+ size: l = s,
18
+ title: n,
19
+ description: i,
20
+ margin: h,
21
+ marginStart: c,
22
+ marginEnd: d,
23
+ className: o,
24
+ children: t,
25
+ style: r,
26
+ ..._
24
27
  }) => {
25
- const _ = `var(--font-size-${y})`;
26
- return i ? /* @__PURE__ */ f(
28
+ const g = `var(--font-size-${l})`, H = u.Children.toArray(t).length > 0;
29
+ return H || i ? /* @__PURE__ */ p(
27
30
  "header",
28
31
  {
29
- ...r,
32
+ ..._,
30
33
  "data-heading": s,
31
- className: g(h.heading, d),
34
+ className: y(e.heading, o),
32
35
  style: {
33
- ...t,
34
- ...H({ fontSize: _, margin: e, marginStart: n, marginEnd: o })
36
+ ...r,
37
+ ...f({ fontSize: g, margin: h, marginStart: c, marginEnd: d })
35
38
  },
36
39
  children: [
37
- /* @__PURE__ */ a(s, { "data-heading-title": !0, children: c }),
38
- /* @__PURE__ */ a("div", { "data-heading-accessory": !0, className: h.accessory, children: i })
40
+ /* @__PURE__ */ a(s, { "data-heading-title": !0, children: n }),
41
+ H && /* @__PURE__ */ a("div", { "data-heading-accessory": !0, className: e.accessory, children: t }),
42
+ i && /* @__PURE__ */ a("div", { "data-heading-description": !0, className: e.description, children: i })
39
43
  ]
40
44
  }
41
45
  ) : /* @__PURE__ */ a(
42
46
  s,
43
47
  {
44
- ...r,
48
+ ..._,
45
49
  "data-heading": s,
46
- className: g(h[s], d),
50
+ className: y(e[s], o),
47
51
  style: {
48
- ...t,
49
- ...H({ fontSize: _, margin: e, marginStart: n, marginEnd: o })
52
+ ...r,
53
+ ...f({ fontSize: g, margin: h, marginStart: c, marginEnd: d })
50
54
  },
51
- children: c
55
+ children: n
52
56
  }
53
57
  );
54
58
  };
55
59
  export {
56
- Z as Heading
60
+ V as Heading
57
61
  };
@@ -4,6 +4,7 @@ export type MenuProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> &
4
4
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
5
5
  placement?: Placement;
6
6
  trigger: React.JSX.Element;
7
+ offset?: number;
7
8
  unmount?: boolean;
8
9
  minWidth?: React.CSSProperties['minWidth'];
9
10
  maxWidth?: React.CSSProperties['maxWidth'];
@@ -11,4 +12,4 @@ export type MenuProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> &
11
12
  maxHeight?: React.CSSProperties['maxHeight'];
12
13
  onSelect?: (index: number) => void;
13
14
  };
14
- export declare const Menu: ({ size, placement, trigger, unmount, minWidth, maxWidth, minHeight, maxHeight, className, children, onSelect, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const Menu: ({ size, placement, trigger, offset: customOffset, unmount, minWidth, maxWidth, minHeight, maxHeight, className, children, onSelect, ...props }: MenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,86 +1,88 @@
1
- import { jsxs as L, Fragment as O, jsx as t } from "react/jsx-runtime";
2
- import W, { useState as a, useRef as p, useMemo as _, useEffect as b } from "react";
3
- import { flushSync as k } from "react-dom";
4
- import { useFloating as A, offset as D, flip as H, size as U, autoUpdate as q, useInteractions as G, useDismiss as J, useRole as K, useClick as Q, useListNavigation as T, FloatingPortal as V, FloatingFocusManager as X, FloatingList as Y } from "@floating-ui/react";
5
- import Z from "classnames";
6
- import { MenuContext as $ } from "./MenuContext.js";
7
- import { cssProps as ee } from "../../utils/helpers.js";
8
- import { s as te } from "../../styles.module-DHm-YTnz.js";
9
- const me = ({
10
- size: g,
11
- placement: h = "bottom-start",
12
- trigger: l,
13
- unmount: R = !0,
14
- minWidth: v,
15
- maxWidth: x,
16
- minHeight: F,
1
+ import { jsxs as W, Fragment as _, jsx as t } from "react/jsx-runtime";
2
+ import b, { useState as l, useRef as g, useMemo as k, useEffect as A } from "react";
3
+ import { flushSync as D } from "react-dom";
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
+ import te from "classnames";
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 = ({
10
+ size: h,
11
+ placement: u = "bottom-start",
12
+ trigger: o,
13
+ offset: R = 5,
14
+ unmount: v = !0,
15
+ minWidth: x,
16
+ maxWidth: F,
17
+ minHeight: M,
17
18
  maxHeight: P,
18
19
  className: y,
19
20
  children: z,
20
21
  onSelect: c,
21
- ...M
22
+ ...w
22
23
  }) => {
23
- const [r, m] = a(!1), [i, w] = a(null), [C, E] = a({}), u = p([]), f = p(null), { refs: o, context: e, floatingStyles: I } = A({
24
- open: r,
25
- placement: h,
26
- onOpenChange: m,
27
- whileElementsMounted: q,
24
+ const [i, f] = l(!1), [a, C] = l(null), [E, I] = l({}), m = g([]), d = g(null), { refs: n, context: e, floatingStyles: N } = H({
25
+ open: i,
26
+ placement: u,
27
+ onOpenChange: f,
28
+ whileElementsMounted: J,
28
29
  middleware: [
29
- D(5),
30
- H({ padding: 10 }),
31
- U({
30
+ U(R),
31
+ q({ padding: 10 }),
32
+ G({
32
33
  padding: 10,
33
- apply({ rects: n, availableWidth: s, availableHeight: B }) {
34
- k(() => {
35
- E({
36
- minHeight: F,
37
- minWidth: v ?? n.reference.width,
38
- maxWidth: x ?? s,
39
- maxHeight: P ?? B
34
+ apply({ rects: s, availableWidth: r, availableHeight: O }) {
35
+ D(() => {
36
+ I({
37
+ minHeight: M,
38
+ minWidth: x ?? s.reference.width,
39
+ maxWidth: F ?? r,
40
+ maxHeight: P ?? O
40
41
  });
41
42
  });
42
43
  }
43
44
  })
44
45
  ]
45
- }), { getReferenceProps: N, getFloatingProps: S, getItemProps: d } = G([
46
- J(e),
47
- K(e, { role: "menu" }),
48
- Q(e, { event: "mousedown" }),
49
- T(e, {
50
- listRef: u,
46
+ }), { getReferenceProps: S, getFloatingProps: j, getItemProps: p } = K([
47
+ Q(e),
48
+ T(e, { role: "menu" }),
49
+ V(e, { event: "mousedown" }),
50
+ X(e, {
51
+ listRef: m,
51
52
  loop: !0,
52
- activeIndex: i,
53
- onNavigate: w
53
+ activeIndex: a,
54
+ onNavigate: C
54
55
  })
55
- ]), j = _(
56
- () => ({ active: i, setOpen: m, getItemProps: d, onSelect: c }),
57
- [i, d, c]
58
- );
59
- return b(() => {
60
- var s;
61
- const n = (s = o.domReference.current) == null ? void 0 : s.closest("[data-floating-root]");
62
- n && (f.current = n);
63
- }, [o]), /* @__PURE__ */ L(O, { children: [
64
- W.cloneElement(l, {
65
- ref: o.setReference,
66
- ...N(l.props),
67
- "data-menu-trigger": !0
68
- }),
69
- /* @__PURE__ */ t($.Provider, { value: j, children: (r || !R) && /* @__PURE__ */ t(V, { root: f.current, children: /* @__PURE__ */ t(X, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
56
+ ]), B = k(
57
+ () => ({ active: a, setOpen: f, getItemProps: p, onSelect: c }),
58
+ [a, p, c]
59
+ ), L = Y([
60
+ n.setReference,
61
+ "ref" in o ? o.ref : null
62
+ ]);
63
+ return A(() => {
64
+ var r;
65
+ const s = (r = n.domReference.current) == null ? void 0 : r.closest("[data-floating-root]");
66
+ s && (d.current = s);
67
+ }, [n]), /* @__PURE__ */ W(_, { children: [
68
+ b.cloneElement(
69
+ o,
70
+ S({ ref: L, "data-menu-trigger": !0, ...o.props })
71
+ ),
72
+ /* @__PURE__ */ t(oe.Provider, { value: B, children: (i || !v) && /* @__PURE__ */ t(Z, { root: d.current, children: /* @__PURE__ */ t($, { context: e, modal: !1, initialFocus: -1, children: /* @__PURE__ */ t(
70
73
  "div",
71
74
  {
72
- ...M,
73
- ...S(),
74
- ref: o.setFloating,
75
- "data-menu": !0,
76
- "data-open": r,
77
- className: Z(te.menu, y),
78
- style: { ...I, ...C, ...ee({ size: g }) },
79
- children: /* @__PURE__ */ t(Y, { elementsRef: u, children: z })
75
+ ...j(w),
76
+ ref: n.setFloating,
77
+ "data-open": i,
78
+ "data-menu": u,
79
+ className: te(se.menu, y),
80
+ style: { ...N, ...E, ...ne({ size: h }) },
81
+ children: /* @__PURE__ */ t(ee, { elementsRef: m, children: z })
80
82
  }
81
83
  ) }) }) })
82
84
  ] });
83
85
  };
84
86
  export {
85
- me as Menu
87
+ de as Menu
86
88
  };