@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.
- package/dist/components/Dialog/Dialog.d.ts +4 -0
- package/dist/components/Dialog/Dialog.js +93 -71
- package/dist/components/Dialog/DialogContext.d.ts +7 -0
- package/dist/components/Dialog/DialogContext.js +5 -0
- package/dist/components/Dialog/useDialog.d.ts +4 -0
- package/dist/components/Dialog/useDialog.js +25 -24
- package/dist/components/Fields/Numeric.js +27 -27
- package/dist/components/Heading/Heading.d.ts +2 -1
- package/dist/components/Heading/Heading.js +38 -34
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/Menu/Menu.js +66 -64
- package/dist/components/Popover/Popover.d.ts +18 -0
- package/dist/components/Popover/Popover.js +62 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Popover/index.js +4 -0
- package/dist/components/Spinner/Spinner.js +7 -7
- package/dist/components/Tooltip/Tooltip.d.ts +2 -1
- package/dist/components/Tooltip/Tooltip.js +36 -36
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -24
- package/dist/styles/_utils.scss +2 -1
- package/dist/styles/style.css +1 -1
- package/package.json +2 -3
|
@@ -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
|
|
2
|
-
import
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
}
|
|
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
|
-
),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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>;
|
|
@@ -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
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
}, []),
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
e !== void 0 ? (C = (
|
|
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
|
-
}, []),
|
|
21
|
-
|
|
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
|
-
|
|
25
|
+
t.current = !1;
|
|
26
26
|
}
|
|
27
27
|
}, []);
|
|
28
28
|
return {
|
|
29
|
-
props: { ref:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|
|
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
|
|
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",
|
|
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:
|
|
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
|
|
16
|
-
var
|
|
17
|
-
(
|
|
18
|
-
}, []),
|
|
19
|
-
var
|
|
20
|
-
(
|
|
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
|
-
...
|
|
25
|
+
...n,
|
|
26
26
|
ref: e,
|
|
27
27
|
type: "number",
|
|
28
28
|
wrapperType: "numeric",
|
|
29
|
-
className: y(
|
|
29
|
+
className: y(c.numeric, u),
|
|
30
30
|
children: [
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
|
|
31
|
+
/* @__PURE__ */ a(
|
|
32
|
+
l,
|
|
33
33
|
{
|
|
34
34
|
type: "button",
|
|
35
35
|
variant: "secondary",
|
|
36
|
-
"aria-label":
|
|
37
|
-
disabled:
|
|
38
|
-
className:
|
|
39
|
-
icon: /* @__PURE__ */
|
|
40
|
-
onClick:
|
|
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__ */
|
|
44
|
-
|
|
43
|
+
/* @__PURE__ */ a(
|
|
44
|
+
l,
|
|
45
45
|
{
|
|
46
46
|
type: "button",
|
|
47
47
|
variant: "secondary",
|
|
48
|
-
"aria-label":
|
|
49
|
-
disabled:
|
|
50
|
-
className:
|
|
51
|
-
icon: /* @__PURE__ */
|
|
52
|
-
onClick:
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
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:
|
|
7
|
-
h2:
|
|
7
|
+
heading: v,
|
|
8
|
+
h2: m,
|
|
8
9
|
h3: x,
|
|
9
|
-
h4:
|
|
10
|
-
h5:
|
|
11
|
-
h6:
|
|
12
|
-
accessory:
|
|
13
|
-
|
|
10
|
+
h4: N,
|
|
11
|
+
h5: R,
|
|
12
|
+
h6: z,
|
|
13
|
+
accessory: A,
|
|
14
|
+
description: B
|
|
15
|
+
}, V = ({
|
|
14
16
|
as: s = "h2",
|
|
15
|
-
size:
|
|
16
|
-
title:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
26
|
-
return i ? /* @__PURE__ */
|
|
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
|
-
...
|
|
32
|
+
..._,
|
|
30
33
|
"data-heading": s,
|
|
31
|
-
className:
|
|
34
|
+
className: y(e.heading, o),
|
|
32
35
|
style: {
|
|
33
|
-
...
|
|
34
|
-
...
|
|
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:
|
|
38
|
-
/* @__PURE__ */ a("div", { "data-heading-accessory": !0, className:
|
|
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
|
-
...
|
|
48
|
+
..._,
|
|
45
49
|
"data-heading": s,
|
|
46
|
-
className:
|
|
50
|
+
className: y(e[s], o),
|
|
47
51
|
style: {
|
|
48
|
-
...
|
|
49
|
-
...
|
|
52
|
+
...r,
|
|
53
|
+
...f({ fontSize: g, margin: h, marginStart: c, marginEnd: d })
|
|
50
54
|
},
|
|
51
|
-
children:
|
|
55
|
+
children: n
|
|
52
56
|
}
|
|
53
57
|
);
|
|
54
58
|
};
|
|
55
59
|
export {
|
|
56
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { useFloating as
|
|
5
|
-
import
|
|
6
|
-
import { MenuContext as
|
|
7
|
-
import { cssProps as
|
|
8
|
-
import { s as
|
|
9
|
-
const
|
|
10
|
-
size:
|
|
11
|
-
placement:
|
|
12
|
-
trigger:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
...
|
|
22
|
+
...w
|
|
22
23
|
}) => {
|
|
23
|
-
const [
|
|
24
|
-
open:
|
|
25
|
-
placement:
|
|
26
|
-
onOpenChange:
|
|
27
|
-
whileElementsMounted:
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
U(R),
|
|
31
|
+
q({ padding: 10 }),
|
|
32
|
+
G({
|
|
32
33
|
padding: 10,
|
|
33
|
-
apply({ rects:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
minHeight:
|
|
37
|
-
minWidth:
|
|
38
|
-
maxWidth:
|
|
39
|
-
maxHeight: P ??
|
|
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:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
listRef:
|
|
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:
|
|
53
|
-
onNavigate:
|
|
53
|
+
activeIndex: a,
|
|
54
|
+
onNavigate: C
|
|
54
55
|
})
|
|
55
|
-
]),
|
|
56
|
-
() => ({ active:
|
|
57
|
-
[
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
...
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"data-menu":
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
87
|
+
de as Menu
|
|
86
88
|
};
|