@divayth/brick-ui 0.0.15 → 0.1.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.
- package/dist/index.js +48 -40
- package/dist/lib/dates.d.ts +5 -0
- package/dist/lib/dates.d.ts.map +1 -0
- package/dist/lib/dates.js +12 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/ui/Date/DateInput.d.ts +2 -3
- package/dist/ui/Date/DateInput.d.ts.map +1 -1
- package/dist/ui/Date/DateInput.js +70 -89
- package/dist/ui/Date/DateInput.module.css.js +5 -5
- package/dist/ui/DateText/DateText.d.ts +0 -1
- package/dist/ui/DateText/DateText.d.ts.map +1 -1
- package/dist/ui/DateText/DateText.js +9 -10
- package/dist/ui/Drawer/Drawer.d.ts +1 -1
- package/dist/ui/Drawer/Drawer.d.ts.map +1 -1
- package/dist/ui/Drawer/Drawer.js +50 -53
- package/dist/ui/FeedScroll/FeedScroll.d.ts.map +1 -1
- package/dist/ui/FeedScroll/FeedScroll.js +30 -33
- package/dist/ui/Popover/Popover.d.ts +14 -0
- package/dist/ui/Popover/Popover.d.ts.map +1 -0
- package/dist/ui/Popover/Popover.js +26 -0
- package/dist/ui/Portal/Portal.d.ts +6 -0
- package/dist/ui/Portal/Portal.d.ts.map +1 -0
- package/dist/ui/Portal/Portal.js +12 -0
- package/dist/ui/Select/Select.d.ts.map +1 -1
- package/dist/ui/Select/Select.js +105 -173
- package/dist/ui/Select/Select.module.css.js +18 -20
- package/dist/ui/Tooltip/Tooltip.d.ts +18 -0
- package/dist/ui/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/ui/Tooltip/Tooltip.js +56 -0
- package/dist/ui/Tooltip/Tooltip.module.css.js +7 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/package.json +3 -1
package/dist/ui/Drawer/Drawer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
3
3
|
import { useState as d, useEffect as k } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { Portal as C } from "../Portal/Portal.js";
|
|
5
5
|
import { Flex as u } from "../Flex/Flex.js";
|
|
6
6
|
import { IconButton as E } from "../IconButton/IconButton.js";
|
|
7
7
|
import p from "clsx";
|
|
@@ -11,12 +11,12 @@ import e from "./Drawer.module.css.js";
|
|
|
11
11
|
const X = ({
|
|
12
12
|
isOpen: o,
|
|
13
13
|
onClose: h,
|
|
14
|
-
position:
|
|
15
|
-
size:
|
|
14
|
+
position: x = "right",
|
|
15
|
+
size: b = "md",
|
|
16
16
|
title: a,
|
|
17
|
-
children:
|
|
17
|
+
children: v,
|
|
18
18
|
withCloseButton: s = !0,
|
|
19
|
-
closeOnOverlay:
|
|
19
|
+
closeOnOverlay: y = !0,
|
|
20
20
|
closeLabel: i,
|
|
21
21
|
className: N
|
|
22
22
|
}) => {
|
|
@@ -29,56 +29,53 @@ const X = ({
|
|
|
29
29
|
});
|
|
30
30
|
}, [o]);
|
|
31
31
|
const g = () => {
|
|
32
|
-
|
|
32
|
+
y && t(!1);
|
|
33
33
|
}, j = () => {
|
|
34
34
|
!f && m && (c(!1), o && h());
|
|
35
35
|
};
|
|
36
|
-
return m ? C(
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
] }),
|
|
80
|
-
document.body
|
|
81
|
-
) : null;
|
|
36
|
+
return m ? /* @__PURE__ */ r(C, { children: /* @__PURE__ */ n("div", { className: p(e.root, { [e.open]: f }), children: [
|
|
37
|
+
/* @__PURE__ */ r(
|
|
38
|
+
"button",
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
"aria-label": i ?? l.close,
|
|
42
|
+
tabIndex: -1,
|
|
43
|
+
className: e.overlay,
|
|
44
|
+
onClick: g,
|
|
45
|
+
onTransitionEnd: j
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ n(
|
|
49
|
+
u,
|
|
50
|
+
{
|
|
51
|
+
direction: "col",
|
|
52
|
+
className: p(e.panel, e[x], e[b], N),
|
|
53
|
+
children: [
|
|
54
|
+
(a || s) && /* @__PURE__ */ n(
|
|
55
|
+
u,
|
|
56
|
+
{
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "between",
|
|
59
|
+
className: e.header,
|
|
60
|
+
children: [
|
|
61
|
+
a,
|
|
62
|
+
s && /* @__PURE__ */ r(
|
|
63
|
+
E,
|
|
64
|
+
{
|
|
65
|
+
"aria-label": i ?? l.close,
|
|
66
|
+
color: "secondary",
|
|
67
|
+
onClick: () => t(!1),
|
|
68
|
+
children: /* @__PURE__ */ r(F, { size: 20 })
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ r("div", { className: e.content, children: v })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] }) }) : null;
|
|
82
79
|
};
|
|
83
80
|
export {
|
|
84
81
|
X as Drawer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedScroll.d.ts","sourceRoot":"","sources":["../../../src/ui/FeedScroll/FeedScroll.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,OAAO,CAAC;AAYtE,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,GAAI,kDAIxB,eAAe,
|
|
1
|
+
{"version":3,"file":"FeedScroll.d.ts","sourceRoot":"","sources":["../../../src/ui/FeedScroll/FeedScroll.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,OAAO,CAAC;AAYtE,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,GAAI,kDAIxB,eAAe,gCAuFjB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as R, jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { ArrowBigUp as
|
|
7
|
-
import { useProvider as
|
|
8
|
-
import { Flex as
|
|
2
|
+
import { jsxs as R, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { useState as h, useCallback as S } from "react";
|
|
4
|
+
import { Portal as z } from "../Portal/Portal.js";
|
|
5
|
+
import H from "clsx";
|
|
6
|
+
import { ArrowBigUp as L } from "lucide-react";
|
|
7
|
+
import { useProvider as T } from "../../app/Provider.js";
|
|
8
|
+
import { Flex as y } from "../Flex/Flex.js";
|
|
9
9
|
import { IconButton as P } from "../IconButton/IconButton.js";
|
|
10
10
|
import p from "./FeedScroll.module.css.js";
|
|
11
11
|
const Y = ({
|
|
@@ -13,24 +13,24 @@ const Y = ({
|
|
|
13
13
|
scrollToTopLabel: b,
|
|
14
14
|
withScrollToTop: f = !0
|
|
15
15
|
}) => {
|
|
16
|
-
const { messages: v } =
|
|
16
|
+
const { messages: v } = T(), [n, w] = h(!1), [d, x] = h(
|
|
17
17
|
null
|
|
18
|
-
), [C, E] =
|
|
18
|
+
), [C, E] = h({ right: 8, bottom: 24 }), B = S((r) => {
|
|
19
19
|
if (!r) return;
|
|
20
20
|
let o = r.parentElement;
|
|
21
21
|
for (; o && !/(auto|scroll|overlay)/.test(getComputedStyle(o).overflowY); )
|
|
22
22
|
o = o.parentElement;
|
|
23
23
|
const t = o ?? document.scrollingElement, e = () => {
|
|
24
|
-
const s = t.getBoundingClientRect(), l = r.getBoundingClientRect(), M = Math.max(0, s.top),
|
|
24
|
+
const s = t.getBoundingClientRect(), l = r.getBoundingClientRect(), M = Math.max(0, s.top), u = Math.min(innerHeight, s.bottom);
|
|
25
25
|
w(
|
|
26
|
-
t.scrollHeight > t.clientHeight && t.scrollTop > 0 && l.bottom > M && l.top <
|
|
26
|
+
t.scrollHeight > t.clientHeight && t.scrollTop > 0 && l.bottom > M && l.top < u
|
|
27
27
|
);
|
|
28
28
|
const c = {
|
|
29
29
|
right: Math.max(
|
|
30
30
|
8,
|
|
31
31
|
innerWidth - Math.min(s.right, l.right, innerWidth) + 8
|
|
32
32
|
),
|
|
33
|
-
bottom: Math.max(24, innerHeight -
|
|
33
|
+
bottom: Math.max(24, innerHeight - u + 24)
|
|
34
34
|
};
|
|
35
35
|
E(
|
|
36
36
|
(a) => a.right === c.right && a.bottom === c.bottom ? a : c
|
|
@@ -42,28 +42,25 @@ const Y = ({
|
|
|
42
42
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), i.disconnect();
|
|
43
43
|
};
|
|
44
44
|
}, []);
|
|
45
|
-
return /* @__PURE__ */ R(
|
|
45
|
+
return /* @__PURE__ */ R(y, { ref: B, direction: "col", className: "w-full", children: [
|
|
46
46
|
g,
|
|
47
|
-
f && d &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
),
|
|
65
|
-
document.body
|
|
66
|
-
)
|
|
47
|
+
f && d && /* @__PURE__ */ m(z, { children: /* @__PURE__ */ m(
|
|
48
|
+
P,
|
|
49
|
+
{
|
|
50
|
+
size: "lg",
|
|
51
|
+
"aria-label": b ?? v.scrollToTop,
|
|
52
|
+
variant: "filled",
|
|
53
|
+
"aria-hidden": !n,
|
|
54
|
+
tabIndex: n ? 0 : -1,
|
|
55
|
+
className: H(p.button, { [p.visible]: n }),
|
|
56
|
+
style: C,
|
|
57
|
+
onClick: () => d.scrollTo({
|
|
58
|
+
top: 0,
|
|
59
|
+
behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth"
|
|
60
|
+
}),
|
|
61
|
+
children: /* @__PURE__ */ m(L, {})
|
|
62
|
+
}
|
|
63
|
+
) })
|
|
67
64
|
] });
|
|
68
65
|
};
|
|
69
66
|
export {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { Popover as Primitive } from "radix-ui";
|
|
3
|
+
import { type PortalProps } from "../Portal/Portal.js";
|
|
4
|
+
export type PopoverRootProps = ComponentProps<typeof Primitive.Root>;
|
|
5
|
+
export type PopoverTriggerProps = ComponentProps<typeof Primitive.Trigger>;
|
|
6
|
+
export type PopoverContentProps = ComponentProps<typeof Primitive.Content> & Pick<PortalProps, "container">;
|
|
7
|
+
export declare const Popover: {
|
|
8
|
+
Root: import("react").FC<Primitive.PopoverProps>;
|
|
9
|
+
Anchor: (props: ComponentProps<typeof Primitive.Anchor>) => import("react").JSX.Element;
|
|
10
|
+
Trigger: (props: PopoverTriggerProps) => import("react").JSX.Element;
|
|
11
|
+
Content: ({ container, sideOffset, collisionPadding, ...props }: PopoverContentProps) => import("react").JSX.Element;
|
|
12
|
+
Close: import("react").ForwardRefExoticComponent<Primitive.PopoverCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/ui/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACrE,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC3E,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,GACxE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAwBjC,eAAO,MAAM,OAAO;;oBAnBG,cAAc,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC;qBAHtC,mBAAmB;qEAYxC,mBAAmB;;CAgBrB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Popover as r } from "radix-ui";
|
|
4
|
+
import { Portal as i } from "../Portal/Portal.js";
|
|
5
|
+
const c = (o) => /* @__PURE__ */ t(r.Trigger, { asChild: !0, ...o }), p = (o) => /* @__PURE__ */ t(r.Anchor, { asChild: !0, ...o }), l = ({
|
|
6
|
+
container: o,
|
|
7
|
+
sideOffset: e = 8,
|
|
8
|
+
collisionPadding: n = 8,
|
|
9
|
+
...s
|
|
10
|
+
}) => /* @__PURE__ */ t(i, { container: o, children: /* @__PURE__ */ t(
|
|
11
|
+
r.Content,
|
|
12
|
+
{
|
|
13
|
+
sideOffset: e,
|
|
14
|
+
collisionPadding: n,
|
|
15
|
+
...s
|
|
16
|
+
}
|
|
17
|
+
) }), a = {
|
|
18
|
+
Root: r.Root,
|
|
19
|
+
Anchor: p,
|
|
20
|
+
Trigger: c,
|
|
21
|
+
Content: l,
|
|
22
|
+
Close: r.Close
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
a as Popover
|
|
26
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
export interface PortalProps extends PropsWithChildren {
|
|
3
|
+
container?: Element | DocumentFragment | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const Portal: ({ container, children }: PortalProps) => import("react").ReactPortal | null;
|
|
6
|
+
//# sourceMappingURL=Portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../../src/ui/Portal/Portal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAGpE,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAC/C;AAED,eAAO,MAAM,MAAM,GAAI,yBAAyB,WAAW,uCAU1D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState as u, useEffect as n } from "react";
|
|
3
|
+
import { createPortal as f } from "react-dom";
|
|
4
|
+
const a = ({ container: t, children: e }) => {
|
|
5
|
+
const [o, r] = u(!1);
|
|
6
|
+
return n(() => {
|
|
7
|
+
r(!0);
|
|
8
|
+
}, []), o ? f(e, t ?? document.body) : null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
a as Portal
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/ui/Select/Select.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/ui/Select/Select.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAU5D,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC9D,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CACjC;AA4BD,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,WAAW,EAAE,oHAa3C,WAAW,CAAC,CAAC,CAAC,gCA6GhB,CAAC"}
|
package/dist/ui/Select/Select.js
CHANGED
|
@@ -1,190 +1,122 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useRef as
|
|
4
|
-
import {
|
|
5
|
-
import { Field as
|
|
6
|
-
import { Flex as
|
|
7
|
-
import { IconButton as
|
|
8
|
-
import { Text as
|
|
9
|
-
import { useProvider as
|
|
10
|
-
import { clsx as
|
|
11
|
-
import { ChevronDown as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
2
|
+
import { jsx as r, jsxs as s, Fragment as O } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as P, useState as w, useId as R } from "react";
|
|
4
|
+
import { Popover as m } from "../Popover/Popover.js";
|
|
5
|
+
import { Field as d } from "../Field/Field.js";
|
|
6
|
+
import { Flex as j } from "../Flex/Flex.js";
|
|
7
|
+
import { IconButton as k } from "../IconButton/IconButton.js";
|
|
8
|
+
import { Text as q } from "../Text/Text.js";
|
|
9
|
+
import { useProvider as A } from "../../app/Provider.js";
|
|
10
|
+
import { clsx as x } from "clsx";
|
|
11
|
+
import { ChevronDown as D, X as E } from "lucide-react";
|
|
12
|
+
import t from "./Select.module.css.js";
|
|
13
|
+
const T = {
|
|
14
14
|
sm: 16,
|
|
15
15
|
md: 20,
|
|
16
16
|
lg: 24
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
/* @__PURE__ */
|
|
20
|
-
] }) :
|
|
21
|
-
value:
|
|
22
|
-
onChange:
|
|
23
|
-
label:
|
|
24
|
-
disabled:
|
|
25
|
-
options:
|
|
26
|
-
placeholder:
|
|
27
|
-
error:
|
|
28
|
-
withArrow:
|
|
29
|
-
clearable:
|
|
30
|
-
className:
|
|
31
|
-
size:
|
|
32
|
-
variant:
|
|
17
|
+
}, _ = (n, l) => n ? /* @__PURE__ */ s(O, { children: [
|
|
18
|
+
n.icon,
|
|
19
|
+
/* @__PURE__ */ r(q, { className: t.value, children: n.label ?? String(n.value ?? "") })
|
|
20
|
+
] }) : l ? /* @__PURE__ */ r("span", { className: x(t.value, t.placeholder), children: l }) : /* @__PURE__ */ r("span", { className: t.value }), U = ({
|
|
21
|
+
value: n,
|
|
22
|
+
onChange: l,
|
|
23
|
+
label: f,
|
|
24
|
+
disabled: o,
|
|
25
|
+
options: g = [],
|
|
26
|
+
placeholder: N,
|
|
27
|
+
error: c,
|
|
28
|
+
withArrow: b = !0,
|
|
29
|
+
clearable: S = !0,
|
|
30
|
+
className: y,
|
|
31
|
+
size: p = "md",
|
|
32
|
+
variant: C = "filled"
|
|
33
33
|
}) => {
|
|
34
|
-
const { messages: $ } =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
left: 0,
|
|
39
|
-
width: 0,
|
|
40
|
-
maxHeight: 320,
|
|
41
|
-
direction: "down"
|
|
42
|
-
});
|
|
43
|
-
q(() => {
|
|
44
|
-
if (!t.isOpen) return;
|
|
45
|
-
if (a) {
|
|
46
|
-
l((r) => ({ ...r, isOpen: !1 }));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const e = (r) => {
|
|
50
|
-
r.key === "Escape" && (r.preventDefault(), r.stopPropagation(), l((s) => ({ ...s, isOpen: !1 })), c.current?.querySelector("button")?.focus());
|
|
51
|
-
};
|
|
52
|
-
document.addEventListener("keydown", e, !0);
|
|
53
|
-
const n = (r) => {
|
|
54
|
-
const s = r.target;
|
|
55
|
-
s instanceof Node && (c.current?.contains(s) || N.current?.contains(s) || l((g) => ({ ...g, isOpen: !1 })));
|
|
56
|
-
};
|
|
57
|
-
document.addEventListener("mousedown", n), document.addEventListener("touchstart", n);
|
|
58
|
-
const m = (r) => {
|
|
59
|
-
r.target instanceof Node && N.current?.contains(r.target) || l((s) => ({ ...s, isOpen: !1 }));
|
|
60
|
-
};
|
|
61
|
-
return document.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
|
|
62
|
-
document.removeEventListener("keydown", e, !0), document.removeEventListener("mousedown", n), document.removeEventListener("touchstart", n), document.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
|
|
63
|
-
};
|
|
64
|
-
}, [t.isOpen, a]);
|
|
65
|
-
const u = B(), D = (e) => {
|
|
66
|
-
a || (f?.(e.value), l((n) => ({ ...n, isOpen: !1 })), c.current?.querySelector("button")?.focus());
|
|
67
|
-
}, I = (e) => {
|
|
68
|
-
e.preventDefault(), e.stopPropagation(), f?.(void 0), l((n) => ({ ...n, isOpen: !1 })), c.current?.querySelector("button")?.focus();
|
|
69
|
-
}, P = () => {
|
|
70
|
-
if (!a) {
|
|
71
|
-
if (!t.isOpen && c.current) {
|
|
72
|
-
const e = c.current.getBoundingClientRect(), n = 4, m = Math.min(320, y.length * 40 + 8), r = window.innerHeight - e.bottom - n, s = e.top - n, g = r < m && s > r, S = Math.min(e.width, window.innerWidth - n * 2);
|
|
73
|
-
l({
|
|
74
|
-
isOpen: !0,
|
|
75
|
-
portalTarget: c.current.closest("dialog") ?? document.body,
|
|
76
|
-
direction: g ? "up" : "down",
|
|
77
|
-
left: Math.max(
|
|
78
|
-
n,
|
|
79
|
-
Math.min(e.left, window.innerWidth - S - n)
|
|
80
|
-
),
|
|
81
|
-
width: S,
|
|
82
|
-
maxHeight: Math.max(0, Math.min(320, g ? s : r)),
|
|
83
|
-
top: g ? e.top : e.bottom
|
|
84
|
-
});
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
l((e) => ({
|
|
88
|
-
...e,
|
|
89
|
-
isOpen: !e.isOpen
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
34
|
+
const { messages: $ } = A(), i = g.find((e) => e.value === n), u = P(null), [v, h] = w(!1), a = R(), I = (e) => {
|
|
35
|
+
o || (l?.(e.value), h(!1), u.current?.querySelector("button")?.focus());
|
|
36
|
+
}, F = (e) => {
|
|
37
|
+
e.preventDefault(), e.stopPropagation(), l?.(void 0), h(!1), u.current?.querySelector("button")?.focus();
|
|
92
38
|
};
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
95
|
-
/* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ r(m.Root, { open: v && !o, onOpenChange: h, children: /* @__PURE__ */ s(d.Root, { className: y, children: [
|
|
40
|
+
f && /* @__PURE__ */ r(d.Label, { htmlFor: a, label: f }),
|
|
41
|
+
/* @__PURE__ */ r(d.Control, { size: p, children: /* @__PURE__ */ r(m.Anchor, { children: /* @__PURE__ */ s(
|
|
96
42
|
"div",
|
|
97
43
|
{
|
|
98
|
-
ref:
|
|
99
|
-
className:
|
|
100
|
-
[
|
|
101
|
-
[
|
|
44
|
+
ref: u,
|
|
45
|
+
className: x(t.select, t[C], {
|
|
46
|
+
[t.error]: c,
|
|
47
|
+
[t.disabled]: o
|
|
102
48
|
}),
|
|
103
49
|
children: [
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
k && !(h && L) && /* @__PURE__ */ i(
|
|
121
|
-
A,
|
|
122
|
-
{
|
|
123
|
-
size: U[E],
|
|
124
|
-
className: o.arrow,
|
|
125
|
-
"aria-hidden": "true"
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
),
|
|
131
|
-
h && L && /* @__PURE__ */ i(
|
|
132
|
-
W,
|
|
133
|
-
{
|
|
134
|
-
size: E,
|
|
135
|
-
color: "secondary",
|
|
136
|
-
onClick: I,
|
|
137
|
-
className: o.clear,
|
|
138
|
-
disabled: a,
|
|
139
|
-
"aria-label": $.clear,
|
|
140
|
-
children: /* @__PURE__ */ i(K, {})
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
] }),
|
|
144
|
-
t.isOpen && !a && j(
|
|
145
|
-
/* @__PURE__ */ i(
|
|
146
|
-
M,
|
|
147
|
-
{
|
|
148
|
-
ref: N,
|
|
149
|
-
id: `${u}-options`,
|
|
150
|
-
role: "listbox",
|
|
151
|
-
"aria-label": x ?? b,
|
|
152
|
-
direction: "col",
|
|
153
|
-
gap: "xs",
|
|
154
|
-
className: O(o.dropdown),
|
|
155
|
-
style: {
|
|
156
|
-
position: "fixed",
|
|
157
|
-
left: t.left,
|
|
158
|
-
top: t.direction === "down" ? t.top + 4 : t.top - 4,
|
|
159
|
-
width: t.width,
|
|
160
|
-
maxHeight: t.maxHeight,
|
|
161
|
-
transform: t.direction === "up" ? "translateY(-100%)" : void 0
|
|
162
|
-
},
|
|
163
|
-
children: y.map((e) => /* @__PURE__ */ i(
|
|
164
|
-
"button",
|
|
50
|
+
/* @__PURE__ */ r(m.Trigger, { children: /* @__PURE__ */ s(
|
|
51
|
+
"button",
|
|
52
|
+
{
|
|
53
|
+
id: a,
|
|
54
|
+
type: "button",
|
|
55
|
+
className: t.trigger,
|
|
56
|
+
disabled: o,
|
|
57
|
+
"aria-expanded": v && !o,
|
|
58
|
+
"aria-haspopup": "listbox",
|
|
59
|
+
"aria-controls": v && !o ? `${a}-options` : void 0,
|
|
60
|
+
"aria-invalid": c ? !0 : void 0,
|
|
61
|
+
"aria-describedby": c ? `${a}-error` : void 0,
|
|
62
|
+
children: [
|
|
63
|
+
_(i, N),
|
|
64
|
+
b && !(i && S) && /* @__PURE__ */ r(
|
|
65
|
+
D,
|
|
165
66
|
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
67
|
+
size: T[p],
|
|
68
|
+
className: t.arrow,
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
) }),
|
|
75
|
+
i && S && /* @__PURE__ */ r(
|
|
76
|
+
k,
|
|
77
|
+
{
|
|
78
|
+
size: p,
|
|
79
|
+
color: "secondary",
|
|
80
|
+
onClick: F,
|
|
81
|
+
className: t.clear,
|
|
82
|
+
disabled: o,
|
|
83
|
+
"aria-label": $.clear,
|
|
84
|
+
children: /* @__PURE__ */ r(E, {})
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ r(
|
|
88
|
+
m.Content,
|
|
89
|
+
{
|
|
90
|
+
container: u.current?.closest("dialog"),
|
|
91
|
+
role: "listbox",
|
|
92
|
+
align: "start",
|
|
93
|
+
sideOffset: 4,
|
|
94
|
+
id: `${a}-options`,
|
|
95
|
+
"aria-label": f ?? N,
|
|
96
|
+
className: t.dropdown,
|
|
97
|
+
children: g.map((e) => /* @__PURE__ */ r(
|
|
98
|
+
"button",
|
|
99
|
+
{
|
|
100
|
+
role: "option",
|
|
101
|
+
"aria-selected": i?.value === e.value,
|
|
102
|
+
onClick: () => I(e),
|
|
103
|
+
type: "button",
|
|
104
|
+
className: i?.value === e.value ? t.active : void 0,
|
|
105
|
+
children: /* @__PURE__ */ s(j, { alignItems: "center", children: [
|
|
106
|
+
e.icon,
|
|
107
|
+
e.label ?? String(e.value ?? "")
|
|
108
|
+
] })
|
|
109
|
+
},
|
|
110
|
+
`${typeof e.value}:${String(e.value)}`
|
|
111
|
+
))
|
|
112
|
+
}
|
|
181
113
|
)
|
|
182
114
|
]
|
|
183
115
|
}
|
|
184
|
-
) }),
|
|
185
|
-
|
|
186
|
-
] });
|
|
116
|
+
) }) }),
|
|
117
|
+
c && /* @__PURE__ */ r(d.Error, { id: `${a}-error`, error: c })
|
|
118
|
+
] }) });
|
|
187
119
|
};
|
|
188
120
|
export {
|
|
189
|
-
|
|
121
|
+
U as Select
|
|
190
122
|
};
|