@kolking/react-ui 1.8.6 → 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.
|
@@ -1,88 +1,85 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as O, Fragment as W, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import _, { useState as l, useRef as g, useMemo as k, useEffect as A } from "react";
|
|
3
3
|
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 {
|
|
8
|
-
import { s as
|
|
9
|
-
const
|
|
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:
|
|
12
|
-
trigger:
|
|
11
|
+
placement: c = "bottom-start",
|
|
12
|
+
trigger: s,
|
|
13
13
|
offset: R = 5,
|
|
14
14
|
unmount: v = !0,
|
|
15
15
|
minWidth: x,
|
|
16
16
|
maxWidth: F,
|
|
17
|
-
minHeight:
|
|
18
|
-
maxHeight:
|
|
19
|
-
className:
|
|
17
|
+
minHeight: y,
|
|
18
|
+
maxHeight: M,
|
|
19
|
+
className: P,
|
|
20
20
|
children: z,
|
|
21
|
-
onSelect:
|
|
21
|
+
onSelect: m,
|
|
22
22
|
...w
|
|
23
23
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
open:
|
|
26
|
-
placement:
|
|
27
|
-
onOpenChange:
|
|
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
|
+
open: r,
|
|
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:
|
|
34
|
+
apply({ rects: a, availableWidth: n, availableHeight: L }) {
|
|
35
35
|
D(() => {
|
|
36
36
|
I({
|
|
37
|
-
minHeight:
|
|
38
|
-
minWidth: x ??
|
|
39
|
-
maxWidth: F ??
|
|
40
|
-
maxHeight:
|
|
37
|
+
minHeight: y,
|
|
38
|
+
minWidth: x ?? a.reference.width,
|
|
39
|
+
maxWidth: F ?? n,
|
|
40
|
+
maxHeight: M ?? L
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
45
|
]
|
|
46
|
-
}), { getReferenceProps: S, getFloatingProps:
|
|
46
|
+
}), { getReferenceProps: S, getFloatingProps: b, getItemProps: p } = K([
|
|
47
47
|
Q(e),
|
|
48
48
|
T(e, { role: "menu" }),
|
|
49
49
|
V(e, { event: "mousedown" }),
|
|
50
50
|
X(e, {
|
|
51
|
-
listRef:
|
|
51
|
+
listRef: f,
|
|
52
52
|
loop: !0,
|
|
53
|
-
activeIndex:
|
|
53
|
+
activeIndex: i,
|
|
54
54
|
onNavigate: C
|
|
55
55
|
})
|
|
56
|
-
]),
|
|
57
|
-
() => ({ active:
|
|
58
|
-
[
|
|
59
|
-
),
|
|
60
|
-
n.setReference,
|
|
61
|
-
"ref" in o ? o.ref : null
|
|
62
|
-
]);
|
|
56
|
+
]), j = k(
|
|
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
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
}, [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
S({ ref:
|
|
61
|
+
var n;
|
|
62
|
+
const a = (n = o.domReference.current) == null ? void 0 : n.closest("[data-floating-root]");
|
|
63
|
+
d.current = a ?? document.body;
|
|
64
|
+
}, [o]), /* @__PURE__ */ O(W, { children: [
|
|
65
|
+
_.cloneElement(
|
|
66
|
+
s,
|
|
67
|
+
S({ ...s.props, ref: B, "data-menu-trigger": !0 })
|
|
71
68
|
),
|
|
72
|
-
/* @__PURE__ */ t(oe.Provider, { value:
|
|
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
|
-
...
|
|
76
|
-
ref:
|
|
77
|
-
"data-open":
|
|
78
|
-
"data-menu":
|
|
79
|
-
className: te(
|
|
80
|
-
style: { ...N, ...E, ...
|
|
81
|
-
children: /* @__PURE__ */ t(ee, { elementsRef:
|
|
72
|
+
...b(w),
|
|
73
|
+
ref: o.setFloating,
|
|
74
|
+
"data-open": r,
|
|
75
|
+
"data-menu": c,
|
|
76
|
+
className: te(re.menu, P),
|
|
77
|
+
style: { ...N, ...E, ...se({ size: h }) },
|
|
78
|
+
children: /* @__PURE__ */ t(ee, { elementsRef: f, children: z })
|
|
82
79
|
}
|
|
83
80
|
) }) }) })
|
|
84
81
|
] });
|
|
85
82
|
};
|
|
86
83
|
export {
|
|
87
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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:
|
|
10
|
+
event: s = "click",
|
|
10
11
|
placement: c = "bottom",
|
|
11
|
-
trigger:
|
|
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:
|
|
18
|
-
maxWidth:
|
|
18
|
+
minWidth: R,
|
|
19
|
+
maxWidth: v,
|
|
19
20
|
className: F,
|
|
20
21
|
children: P,
|
|
21
22
|
onToggle: h,
|
|
22
|
-
...
|
|
23
|
+
...E
|
|
23
24
|
}) => {
|
|
24
|
-
const
|
|
25
|
-
open:
|
|
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:
|
|
38
|
-
J(o, { enabled:
|
|
39
|
-
K(o, { enabled:
|
|
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 && (
|
|
45
|
+
!l && u && (p.current = u);
|
|
48
46
|
}, [e, l]), X(() => {
|
|
49
47
|
n && e.setPositionReference(n);
|
|
50
|
-
}, [e, n]), l ?
|
|
51
|
-
D.cloneElement(
|
|
52
|
-
|
|
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(
|
|
53
|
+
...M(E),
|
|
56
54
|
ref: e.setFloating,
|
|
57
55
|
"data-popover": c,
|
|
58
|
-
className: b(
|
|
59
|
-
style: { ..._, minWidth:
|
|
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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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:
|
|
20
|
+
children: n,
|
|
20
21
|
...x
|
|
21
22
|
}) => {
|
|
22
|
-
const u = g(null), p = g(null), [d,
|
|
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:
|
|
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:
|
|
32
|
-
|
|
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
|
|
47
|
-
const
|
|
48
|
-
!i &&
|
|
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 ?
|
|
52
|
-
j.cloneElement(
|
|
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:
|
|
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
|
-
|
|
78
|
+
rt as Tooltip
|
|
81
79
|
};
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -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'];
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
function
|
|
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
|
|
6
|
+
function i(r) {
|
|
7
7
|
return r.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
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 =
|
|
16
|
-
|
|
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 =
|
|
28
|
+
const x = s.forwardRef;
|
|
26
29
|
export {
|
|
27
|
-
|
|
30
|
+
a as clamp,
|
|
28
31
|
m as cssProps,
|
|
29
32
|
x as fixedForwardRef,
|
|
30
|
-
$ as
|
|
33
|
+
$ as getElementRef,
|
|
34
|
+
l as getErrorMessage,
|
|
31
35
|
g as wrapNode
|
|
32
36
|
};
|