@forgedevstack/bear 1.3.3 → 1.3.4
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/README.md +145 -292
- package/dist/components/AlertDialog/AlertDialog.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +67 -84
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +72 -64
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +2 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +6 -4
- package/dist/components/ChipGroup/ChipGroup.js +52 -48
- package/dist/components/CommandPalette/CommandItem.cjs +1 -0
- package/dist/components/CommandPalette/CommandItem.d.ts +6 -0
- package/dist/components/CommandPalette/CommandItem.js +39 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +129 -144
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +72 -66
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.d.ts +5 -0
- package/dist/components/EmptyState/EmptyState.const.js +30 -15
- package/dist/components/EmptyState/EmptyState.js +35 -35
- package/dist/components/EmptyState/EmptyState.types.d.ts +2 -2
- package/dist/components/HoverCard/HoverCard.cjs +4 -3
- package/dist/components/HoverCard/HoverCard.const.cjs +1 -0
- package/dist/components/HoverCard/HoverCard.const.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.const.js +10 -0
- package/dist/components/HoverCard/HoverCard.js +62 -56
- package/dist/components/HoverCard/HoverCard.types.d.ts +7 -0
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.const.cjs +1 -0
- package/dist/components/Menu/Menu.const.d.ts +2 -0
- package/dist/components/Menu/Menu.const.js +12 -0
- package/dist/components/Menu/Menu.d.ts +3 -9
- package/dist/components/Menu/Menu.js +57 -89
- package/dist/components/Menu/Menu.types.d.ts +8 -1
- package/dist/components/Menu/MenuDivider.cjs +1 -0
- package/dist/components/Menu/MenuDivider.d.ts +6 -0
- package/dist/components/Menu/MenuDivider.js +7 -0
- package/dist/components/Menu/MenuItem.cjs +1 -0
- package/dist/components/Menu/MenuItem.d.ts +6 -0
- package/dist/components/Menu/MenuItem.js +46 -0
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -0
- package/dist/components/Modal/Modal.const.js +20 -12
- package/dist/components/Modal/Modal.js +62 -59
- package/dist/components/Modal/Modal.types.d.ts +7 -0
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.const.cjs +1 -0
- package/dist/components/Popover/Popover.const.d.ts +15 -1
- package/dist/components/Popover/Popover.const.js +29 -0
- package/dist/components/Popover/Popover.js +77 -73
- package/dist/components/Popover/Popover.types.d.ts +7 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -1
- package/dist/components/Select/Select.const.d.ts +1 -0
- package/dist/components/Select/Select.const.js +7 -6
- package/dist/components/Select/Select.js +101 -96
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -1
- package/dist/components/Toast/Toast.const.d.ts +2 -0
- package/dist/components/Toast/Toast.const.js +11 -8
- package/dist/components/Toast/Toast.context.cjs +1 -0
- package/dist/components/Toast/Toast.context.d.ts +3 -0
- package/dist/components/Toast/Toast.context.js +11 -0
- package/dist/components/Toast/Toast.d.ts +4 -3
- package/dist/components/Toast/Toast.icons.cjs +1 -0
- package/dist/components/Toast/Toast.icons.d.ts +4 -0
- package/dist/components/Toast/Toast.icons.js +29 -0
- package/dist/components/Toast/Toast.js +32 -160
- package/dist/components/Toast/ToastContainer.cjs +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +3 -0
- package/dist/components/Toast/ToastContainer.js +39 -0
- package/dist/components/Toast/ToastItem.cjs +1 -0
- package/dist/components/Toast/ToastItem.d.ts +5 -0
- package/dist/components/Toast/ToastItem.js +86 -0
- package/dist/components/ToggleGroup/ToggleGroup.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.d.ts +15 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.js +33 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.js +5 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +86 -0
- package/dist/components/ToggleGroup/ToggleGroup.types.d.ts +48 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.js +50 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.cjs +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.d.ts +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.js +6 -0
- package/dist/components/ToggleGroup/index.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.const.cjs +1 -0
- package/dist/components/Tooltip/Tooltip.const.d.ts +8 -0
- package/dist/components/Tooltip/Tooltip.const.js +18 -0
- package/dist/components/Tooltip/Tooltip.js +59 -61
- package/dist/components/Tooltip/Tooltip.types.d.ts +7 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +428 -418
- package/dist/constants/numbers.const.cjs +1 -1
- package/dist/constants/numbers.const.d.ts +3 -0
- package/dist/constants/numbers.const.js +37 -34
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +6 -4
- package/dist/hooks/useFocusTrap/index.d.ts +2 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.js +41 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.types.d.ts +8 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.d.ts +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.js +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +575 -563
- package/dist/styles.css +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EIGHT as r, ELEVEN_THOUSAND as t } from "../../constants/numbers.const.js";
|
|
2
|
+
const e = t, n = r, o = {
|
|
3
|
+
scale: "animate-scale-in",
|
|
4
|
+
fade: "animate-fade-in",
|
|
5
|
+
"slide-down": "animate-grow-up",
|
|
6
|
+
fold: "animate-alert-dialog-in",
|
|
7
|
+
none: ""
|
|
8
|
+
}, b = "bottom", s = "top", E = "left", T = "right", l = "start", _ = "end", A = "translateX(-50%)", N = "translateX(-100%)", R = "translateY(-50%)", c = "translateY(-100%)", d = {
|
|
9
|
+
top: "bear-top-full bear-left-1/2 -bear-translate-x-1/2 bear-border-t-zinc-700 bear-border-x-transparent bear-border-b-transparent",
|
|
10
|
+
bottom: "bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-border-b-zinc-700 bear-border-x-transparent bear-border-t-transparent",
|
|
11
|
+
left: "bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-border-l-zinc-700 bear-border-y-transparent bear-border-r-transparent",
|
|
12
|
+
right: "bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-border-r-zinc-700 bear-border-y-transparent bear-border-l-transparent"
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
_ as ALIGN_END,
|
|
16
|
+
l as ALIGN_START,
|
|
17
|
+
b as PLACEMENT_BOTTOM,
|
|
18
|
+
E as PLACEMENT_LEFT,
|
|
19
|
+
T as PLACEMENT_RIGHT,
|
|
20
|
+
s as PLACEMENT_TOP,
|
|
21
|
+
d as POPOVER_ARROW_STYLES,
|
|
22
|
+
n as POPOVER_DEFAULT_OFFSET,
|
|
23
|
+
o as POPOVER_EFFECT_CLASS_MAP,
|
|
24
|
+
e as POPOVER_Z_INDEX,
|
|
25
|
+
A as TRANSFORM_TRANSLATE_X_CENTER,
|
|
26
|
+
N as TRANSFORM_TRANSLATE_X_END,
|
|
27
|
+
R as TRANSFORM_TRANSLATE_Y_CENTER,
|
|
28
|
+
c as TRANSFORM_TRANSLATE_Y_END
|
|
29
|
+
};
|
|
@@ -1,98 +1,102 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { cn as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs as p, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useRef as h, useCallback as P, useEffect as m } from "react";
|
|
3
|
+
import { createPortal as j } from "react-dom";
|
|
4
|
+
import { cn as v } from "../../utils/cn.js";
|
|
5
|
+
import { TWO as S } from "../../constants/numbers.const.js";
|
|
6
|
+
import { resolveOverlayEffects as B } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.js";
|
|
7
|
+
import { PLACEMENT_BOTTOM as T, POPOVER_DEFAULT_OFFSET as K, POPOVER_ARROW_STYLES as U, POPOVER_EFFECT_CLASS_MAP as O, ALIGN_START as Z, ALIGN_END as q, PLACEMENT_TOP as M, TRANSFORM_TRANSLATE_X_CENTER as J, TRANSFORM_TRANSLATE_X_END as Q, PLACEMENT_RIGHT as $, PLACEMENT_LEFT as ee, TRANSFORM_TRANSLATE_Y_CENTER as te, TRANSFORM_TRANSLATE_Y_END as oe, POPOVER_Z_INDEX as ne } from "./Popover.const.js";
|
|
8
|
+
function re(l, e, s) {
|
|
9
|
+
const t = { position: "fixed", zIndex: ne }, [n] = l.split("-"), r = l.includes(Z), i = l.includes(q);
|
|
10
|
+
return n === T || n === M ? (t.top = n === T ? e.bottom + s : void 0, t.bottom = n === M ? window.innerHeight - e.top + s : void 0, t.left = r ? e.left : i ? e.right : e.left + e.width / S, t.transform = !r && !i ? J : i ? Q : void 0) : (t.left = n === $ ? e.right + s : void 0, t.right = n === ee ? window.innerWidth - e.left + s : void 0, t.bottom = i ? window.innerHeight - e.bottom : void 0, t.top = i ? void 0 : r ? e.top : e.top + e.height / S, t.transform = !r && !i ? te : i ? oe : void 0), t;
|
|
9
11
|
}
|
|
10
|
-
const
|
|
11
|
-
children:
|
|
12
|
-
content:
|
|
13
|
-
placement:
|
|
14
|
-
trigger:
|
|
15
|
-
open:
|
|
16
|
-
onOpenChange:
|
|
17
|
-
className:
|
|
18
|
-
contentClassName:
|
|
19
|
-
arrow:
|
|
20
|
-
closeOnClickOutside:
|
|
21
|
-
closeOnEscape:
|
|
22
|
-
offset:
|
|
12
|
+
const fe = ({
|
|
13
|
+
children: l,
|
|
14
|
+
content: e,
|
|
15
|
+
placement: s = T,
|
|
16
|
+
trigger: t = "click",
|
|
17
|
+
open: n,
|
|
18
|
+
onOpenChange: r,
|
|
19
|
+
className: i,
|
|
20
|
+
contentClassName: R,
|
|
21
|
+
arrow: g = !0,
|
|
22
|
+
closeOnClickOutside: b = !0,
|
|
23
|
+
closeOnEscape: _ = !0,
|
|
24
|
+
offset: L = K,
|
|
25
|
+
openEffect: C,
|
|
26
|
+
closeEffect: F,
|
|
27
|
+
effect: k
|
|
23
28
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const [y, D] = A(!1), [I, x] = A({}), E = h(null), f = h(null), d = n !== void 0 ? n : y, a = P((o) => {
|
|
30
|
+
D(o), r == null || r(o);
|
|
31
|
+
}, [r]), u = P(() => {
|
|
32
|
+
if (!E.current || !f.current) return;
|
|
33
|
+
const o = E.current.firstElementChild;
|
|
34
|
+
if (!o) return;
|
|
35
|
+
const c = o.getBoundingClientRect();
|
|
36
|
+
x(re(s, c, L));
|
|
37
|
+
}, [s, L]);
|
|
38
|
+
m(() => {
|
|
39
|
+
if (d) {
|
|
40
|
+
u();
|
|
41
|
+
const o = () => u(), c = () => u();
|
|
42
|
+
return window.addEventListener("resize", o), window.addEventListener("scroll", c, !0), () => {
|
|
43
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", c, !0);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}, [d, u]), m(() => {
|
|
47
|
+
if (!d || !b) return;
|
|
48
|
+
const o = (c) => {
|
|
49
|
+
const N = c.target;
|
|
50
|
+
E.current && !E.current.contains(N) && f.current && !f.current.contains(N) && a(!1);
|
|
43
51
|
};
|
|
44
|
-
return
|
|
45
|
-
}, [
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
|
|
52
|
+
return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
|
|
53
|
+
}, [d, b, a]), m(() => {
|
|
54
|
+
if (!d || !_) return;
|
|
55
|
+
const o = (c) => {
|
|
56
|
+
c.key === "Escape" && a(!1);
|
|
49
57
|
};
|
|
50
|
-
return
|
|
51
|
-
}, [
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
bottom: "bear-bottom-full bear-left-1/2 -bear-translate-x-1/2 bear-border-b-zinc-700 bear-border-x-transparent bear-border-t-transparent",
|
|
61
|
-
left: "bear-left-full bear-top-1/2 -bear-translate-y-1/2 bear-border-l-zinc-700 bear-border-y-transparent bear-border-r-transparent",
|
|
62
|
-
right: "bear-right-full bear-top-1/2 -bear-translate-y-1/2 bear-border-r-zinc-700 bear-border-y-transparent bear-border-l-transparent"
|
|
63
|
-
}, D = a.split("-")[0], Y = i && typeof document < "u" && T(
|
|
64
|
-
/* @__PURE__ */ g(
|
|
58
|
+
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
59
|
+
}, [d, _, a]);
|
|
60
|
+
const z = () => {
|
|
61
|
+
t === "click" && a(!d);
|
|
62
|
+
}, V = () => {
|
|
63
|
+
t === "hover" && a(!0);
|
|
64
|
+
}, G = () => {
|
|
65
|
+
t === "hover" && a(!1);
|
|
66
|
+
}, H = s.split("-")[0], { openEffect: W } = B({ openEffect: C, closeEffect: F, effect: k }, "fade"), X = O[W] ?? O.fade, Y = d && typeof document < "u" && j(
|
|
67
|
+
/* @__PURE__ */ p(
|
|
65
68
|
"div",
|
|
66
69
|
{
|
|
67
|
-
ref:
|
|
70
|
+
ref: f,
|
|
68
71
|
"data-bear-popover": !0,
|
|
69
|
-
className:
|
|
72
|
+
className: v(
|
|
70
73
|
"bear-bg-zinc-800 bear-border bear-border-zinc-700 bear-rounded-lg bear-shadow-xl bear-p-3",
|
|
71
|
-
|
|
74
|
+
X,
|
|
75
|
+
R
|
|
72
76
|
),
|
|
73
|
-
style:
|
|
77
|
+
style: I,
|
|
74
78
|
children: [
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
e,
|
|
80
|
+
g && /* @__PURE__ */ w("div", { className: v("bear-absolute bear-w-0 bear-h-0 bear-border-8", U[H]) })
|
|
77
81
|
]
|
|
78
82
|
}
|
|
79
83
|
),
|
|
80
84
|
document.body
|
|
81
85
|
);
|
|
82
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ p(
|
|
83
87
|
"div",
|
|
84
88
|
{
|
|
85
|
-
ref:
|
|
86
|
-
className:
|
|
87
|
-
onMouseEnter:
|
|
88
|
-
onMouseLeave:
|
|
89
|
+
ref: E,
|
|
90
|
+
className: v("bear-relative bear-inline-block", i),
|
|
91
|
+
onMouseEnter: V,
|
|
92
|
+
onMouseLeave: G,
|
|
89
93
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ w("div", { onClick: z, className: "bear-cursor-pointer", children: l }),
|
|
91
95
|
Y
|
|
92
96
|
]
|
|
93
97
|
}
|
|
94
98
|
);
|
|
95
99
|
};
|
|
96
100
|
export {
|
|
97
|
-
|
|
101
|
+
fe as Popover
|
|
98
102
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { OverlayMotionEffect, OverlayEffectConfig } from '../../hooks/useFixedAnchorPosition';
|
|
2
3
|
export type PopoverPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
3
4
|
export interface PopoverProps {
|
|
4
5
|
testId?: string;
|
|
@@ -15,4 +16,10 @@ export interface PopoverProps {
|
|
|
15
16
|
closeOnClickOutside?: boolean;
|
|
16
17
|
closeOnEscape?: boolean;
|
|
17
18
|
offset?: number;
|
|
19
|
+
/** Transition effect when opening */
|
|
20
|
+
openEffect?: OverlayMotionEffect;
|
|
21
|
+
/** Transition effect when closing */
|
|
22
|
+
closeEffect?: OverlayMotionEffect;
|
|
23
|
+
/** Config for open and close transition effects */
|
|
24
|
+
effect?: OverlayEffectConfig;
|
|
18
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),v=require("react"),s=require("./Select.const.cjs"),W=require("./helpers/SelectCheckSvg.cjs"),X=require("./helpers/SelectChevronDownSvg.cjs"),H=require("../OverlayPortal/OverlayPortal.cjs"),l=require("../../utils/cn.cjs"),Y=require("../../utils/generateBearId.utils.cjs"),G=require("../../utils/useBearId.cjs"),J=require("../../context/BearProvider.cjs");require("../../context/defaultTheme.cjs");const K=require("../../constants/generals.const.cjs"),Q=require("../../hooks/useClickOutside.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const ee=require("../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.cjs"),re=require("../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.cjs"),ae=require("../../hooks/useFormControl/useFormControl.cjs"),se=O=>{const{options:x,value:t,onChange:b,placeholder:S=s.SELECT_DEFAULT_PLACEHOLDER,label:c,error:E,disabled:A=!1,required:I=!1,size:T="md",fullWidth:L=!1,displayEmpty:y=!1,renderValue:q,native:n=!1,className:N,id:P,testId:j}=O,{openEffect:B,closeEffect:D}=re.resolveOverlayEffects(O),{density:F}=J.useBearDensityOptional(),u=F===K.DENSITY_COMPACT,M=G.useBearId(s.COMPONENT_NAME_SELECT),_=Y.resolveBearId(P,M),a=ae.useFormControl(),[i,m]=v.useState(!1),h=v.useRef(null),w=v.useRef(null),{style:$,ready:U}=ee.useFixedAnchorPosition({anchorRef:h,open:i&&!n,offsetPx:s.SELECT_MENU_OFFSET_PX,matchWidth:!0}),o=A||!!(a!=null&&a.disabled),g=I||!!(a!=null&&a.required),d=!!E||!!(a!=null&&a.error),f=typeof E=="string"?E:void 0,p=x.find(e=>e.value===t),C=t===void 0||t==="",R=C||y&&C,Z=v.useCallback(()=>m(!1),[]);Q.useClickOutsideMultiple([h,w],Z,{enabled:i&&!n&&!o});const z=e=>{b==null||b(e),m(!1)},V=q&&!C?q(t):R||!p?S:p.label,k={backgroundColor:"var(--bear-bg-primary)",borderColor:d?void 0:"var(--bear-border-default)",color:p&&!R?"var(--bear-text-primary)":"var(--bear-text-muted)"};return n?r.jsxs("div",{id:_,"data-testid":j,className:l.cn(s.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",L&&"bear-w-full"),children:[c&&r.jsx("label",{htmlFor:`${_}-native`,className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("select",{id:`${_}-native`,disabled:o,required:g,value:t??"",onChange:e=>b==null?void 0:b(e.target.value),className:l.cn(`${s.S_E_L_E_C_T_ROOT_CLASS}__native`,"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",d?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500",o&&"bear-opacity-50 bear-cursor-not-allowed",s.SELECT_SIZE_CLASSES[T],u&&"Bear-Select--compact bear-py-1 bear-text-xs",N),style:k,"aria-invalid":d||void 0,"aria-required":g||void 0,"aria-describedby":a==null?void 0:a.helperId,children:[(y||S)&&r.jsx("option",{value:"",disabled:!y,children:S}),x.map(e=>r.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value))]}),f&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:f})]}):r.jsxs("div",{ref:h,id:_,"data-testid":j,className:l.cn(s.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",u&&"Bear-Select--compact",L&&"bear-w-full"),children:[c&&r.jsx("label",{className:l.cn("bear-font-medium",u?"bear-text-xs":"bear-text-sm"),style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("button",{type:"button",disabled:o,onClick:()=>!o&&m(!i),className:l.cn(`${s.S_E_L_E_C_T_ROOT_CLASS}__trigger`,"bear-flex bear-items-center bear-justify-between bear-w-full","bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",d?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",o&&"bear-opacity-50 bear-cursor-not-allowed",s.SELECT_SIZE_CLASSES[T],u&&"bear-py-1 bear-text-xs bear-h-8",N),style:k,"aria-haspopup":"listbox","aria-expanded":i,"aria-invalid":d||void 0,"aria-required":g||void 0,"aria-describedby":a==null?void 0:a.helperId,children:[r.jsx("span",{className:`${s.S_E_L_E_C_T_ROOT_CLASS}__value`,children:V}),r.jsx(X.SelectChevronDownSvg,{className:l.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",i&&"bear-rotate-180")})]}),r.jsx(H.OverlayPortal,{open:i&&!n,ready:U,style:{...$,backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)"},zIndex:s.SELECT_MENU_Z_INDEX,openEffect:B,closeEffect:D,panelRef:w,className:`${s.S_E_L_E_C_T_ROOT_CLASS}__menu bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,attributes:{role:"listbox"},children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:x.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&z(e.value),role:"option","aria-selected":e.value===t,className:l.cn(`${s.S_E_L_E_C_T_ROOT_CLASS}__option`,"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2","bear-text-left bear-transition-colors",e.disabled&&"bear-cursor-not-allowed",e.value===t&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==t&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===t?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===t&&r.jsx(W.SelectCheckSvg,{className:"bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})}),f&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:f})]})};exports.Select=se;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E="Bear-Select",_="Select an option",
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E="Bear-Select",_="Select",S="Select an option",e=4,t=1e4,L={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"};exports.COMPONENT_NAME_SELECT=_;exports.SELECT_DEFAULT_PLACEHOLDER=S;exports.SELECT_MENU_OFFSET_PX=e;exports.SELECT_MENU_Z_INDEX=t;exports.SELECT_SIZE_CLASSES=L;exports.S_E_L_E_C_T_ROOT_CLASS=E;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const S_E_L_E_C_T_ROOT_CLASS = "Bear-Select";
|
|
2
|
+
export declare const COMPONENT_NAME_SELECT = "Select";
|
|
2
3
|
export declare const SELECT_DEFAULT_PLACEHOLDER = "Select an option";
|
|
3
4
|
export declare const SELECT_MENU_OFFSET_PX = 4;
|
|
4
5
|
export declare const SELECT_MENU_EDGE_PAD_PX = 8;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = "Bear-Select", e = "Select", _ = "Select an option", t = 4, S = 1e4, a = {
|
|
2
2
|
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
3
3
|
md: "bear-h-10 bear-text-base bear-px-4",
|
|
4
4
|
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
_ as
|
|
9
|
-
t as
|
|
10
|
-
S as
|
|
11
|
-
|
|
7
|
+
e as COMPONENT_NAME_SELECT,
|
|
8
|
+
_ as SELECT_DEFAULT_PLACEHOLDER,
|
|
9
|
+
t as SELECT_MENU_OFFSET_PX,
|
|
10
|
+
S as SELECT_MENU_Z_INDEX,
|
|
11
|
+
a as SELECT_SIZE_CLASSES,
|
|
12
|
+
E as S_E_L_E_C_T_ROOT_CLASS
|
|
12
13
|
};
|
|
@@ -1,67 +1,69 @@
|
|
|
1
1
|
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { SELECT_DEFAULT_PLACEHOLDER as
|
|
4
|
-
import { SelectCheckSvg as
|
|
5
|
-
import { SelectChevronDownSvg as
|
|
6
|
-
import { OverlayPortal as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { resolveBearId as
|
|
9
|
-
import { useBearId as
|
|
10
|
-
import {
|
|
11
|
-
import "../../context/
|
|
2
|
+
import { useState as H, useRef as P, useCallback as Y } from "react";
|
|
3
|
+
import { SELECT_DEFAULT_PLACEHOLDER as G, COMPONENT_NAME_SELECT as J, SELECT_MENU_OFFSET_PX as K, SELECT_SIZE_CLASSES as R, S_E_L_E_C_T_ROOT_CLASS as l, SELECT_MENU_Z_INDEX as Q } from "./Select.const.js";
|
|
4
|
+
import { SelectCheckSvg as ee } from "./helpers/SelectCheckSvg.js";
|
|
5
|
+
import { SelectChevronDownSvg as re } from "./helpers/SelectChevronDownSvg.js";
|
|
6
|
+
import { OverlayPortal as ae } from "../OverlayPortal/OverlayPortal.js";
|
|
7
|
+
import { cn as s } from "../../utils/cn.js";
|
|
8
|
+
import { resolveBearId as te } from "../../utils/generateBearId.utils.js";
|
|
9
|
+
import { useBearId as le } from "../../utils/useBearId.js";
|
|
10
|
+
import { useBearDensityOptional as se } from "../../context/BearProvider.js";
|
|
11
|
+
import "../../context/defaultTheme.js";
|
|
12
|
+
import { DENSITY_COMPACT as be } from "../../constants/generals.const.js";
|
|
13
|
+
import { useClickOutsideMultiple as oe } from "../../hooks/useClickOutside.js";
|
|
12
14
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
13
|
-
import { useFixedAnchorPosition as
|
|
14
|
-
import { resolveOverlayEffects as
|
|
15
|
-
import { useFormControl as
|
|
16
|
-
const
|
|
15
|
+
import { useFixedAnchorPosition as de } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.js";
|
|
16
|
+
import { resolveOverlayEffects as ie } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.js";
|
|
17
|
+
import { useFormControl as ce } from "../../hooks/useFormControl/useFormControl.js";
|
|
18
|
+
const Oe = (w) => {
|
|
17
19
|
const {
|
|
18
|
-
options:
|
|
19
|
-
value:
|
|
20
|
-
onChange:
|
|
21
|
-
placeholder:
|
|
20
|
+
options: p,
|
|
21
|
+
value: t,
|
|
22
|
+
onChange: b,
|
|
23
|
+
placeholder: x = G,
|
|
22
24
|
label: n,
|
|
23
25
|
error: y,
|
|
24
|
-
disabled:
|
|
25
|
-
required:
|
|
26
|
-
size:
|
|
27
|
-
fullWidth:
|
|
26
|
+
disabled: A = !1,
|
|
27
|
+
required: M = !1,
|
|
28
|
+
size: k = "md",
|
|
29
|
+
fullWidth: C = !1,
|
|
28
30
|
displayEmpty: h = !1,
|
|
29
|
-
renderValue:
|
|
31
|
+
renderValue: O,
|
|
30
32
|
native: u = !1,
|
|
31
|
-
className:
|
|
32
|
-
id:
|
|
33
|
-
testId:
|
|
34
|
-
} = w, { openEffect:
|
|
35
|
-
anchorRef:
|
|
36
|
-
open:
|
|
37
|
-
offsetPx:
|
|
33
|
+
className: I,
|
|
34
|
+
id: $,
|
|
35
|
+
testId: T
|
|
36
|
+
} = w, { openEffect: q, closeEffect: F } = ie(w), { density: j } = se(), f = j === be, U = le(J), m = te($, U), r = ce(), [o, g] = H(!1), E = P(null), L = P(null), { style: z, ready: V } = de({
|
|
37
|
+
anchorRef: E,
|
|
38
|
+
open: o && !u,
|
|
39
|
+
offsetPx: K,
|
|
38
40
|
matchWidth: !0
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
enabled:
|
|
41
|
+
}), d = A || !!(r != null && r.disabled), _ = M || !!(r != null && r.required), i = !!y || !!(r != null && r.error), v = typeof y == "string" ? y : void 0, S = p.find((e) => e.value === t), N = t === void 0 || t === "", B = N || h && N, W = Y(() => g(!1), []);
|
|
42
|
+
oe([E, L], W, {
|
|
43
|
+
enabled: o && !u && !d
|
|
42
44
|
});
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
},
|
|
45
|
+
const X = (e) => {
|
|
46
|
+
b == null || b(e), g(!1);
|
|
47
|
+
}, Z = O && !N ? O(t) : B || !S ? x : S.label, D = {
|
|
46
48
|
backgroundColor: "var(--bear-bg-primary)",
|
|
47
49
|
borderColor: i ? void 0 : "var(--bear-border-default)",
|
|
48
|
-
color:
|
|
50
|
+
color: S && !B ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
|
|
49
51
|
};
|
|
50
52
|
return u ? /* @__PURE__ */ c(
|
|
51
53
|
"div",
|
|
52
54
|
{
|
|
53
|
-
id:
|
|
54
|
-
"data-testid":
|
|
55
|
-
className:
|
|
56
|
-
|
|
55
|
+
id: m,
|
|
56
|
+
"data-testid": T,
|
|
57
|
+
className: s(
|
|
58
|
+
l,
|
|
57
59
|
"bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
58
|
-
|
|
60
|
+
C && "bear-w-full"
|
|
59
61
|
),
|
|
60
62
|
children: [
|
|
61
63
|
n && /* @__PURE__ */ a(
|
|
62
64
|
"label",
|
|
63
65
|
{
|
|
64
|
-
htmlFor: `${
|
|
66
|
+
htmlFor: `${m}-native`,
|
|
65
67
|
className: "bear-text-sm bear-font-medium",
|
|
66
68
|
style: { color: "var(--bear-text-secondary)" },
|
|
67
69
|
children: n
|
|
@@ -70,76 +72,79 @@ const _e = (w) => {
|
|
|
70
72
|
/* @__PURE__ */ c(
|
|
71
73
|
"select",
|
|
72
74
|
{
|
|
73
|
-
id: `${
|
|
74
|
-
disabled:
|
|
75
|
+
id: `${m}-native`,
|
|
76
|
+
disabled: d,
|
|
75
77
|
required: _,
|
|
76
|
-
value:
|
|
77
|
-
onChange: (e) =>
|
|
78
|
-
className:
|
|
79
|
-
`${
|
|
78
|
+
value: t ?? "",
|
|
79
|
+
onChange: (e) => b == null ? void 0 : b(e.target.value),
|
|
80
|
+
className: s(
|
|
81
|
+
`${l}__native`,
|
|
80
82
|
"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200",
|
|
81
83
|
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
82
84
|
i ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500",
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
d && "bear-opacity-50 bear-cursor-not-allowed",
|
|
86
|
+
R[k],
|
|
87
|
+
f && "Bear-Select--compact bear-py-1 bear-text-xs",
|
|
88
|
+
I
|
|
86
89
|
),
|
|
87
|
-
style:
|
|
90
|
+
style: D,
|
|
88
91
|
"aria-invalid": i || void 0,
|
|
89
92
|
"aria-required": _ || void 0,
|
|
90
93
|
"aria-describedby": r == null ? void 0 : r.helperId,
|
|
91
94
|
children: [
|
|
92
|
-
(h ||
|
|
93
|
-
|
|
95
|
+
(h || x) && /* @__PURE__ */ a("option", { value: "", disabled: !h, children: x }),
|
|
96
|
+
p.map((e) => /* @__PURE__ */ a("option", { value: e.value, disabled: e.disabled, children: e.label }, e.value))
|
|
94
97
|
]
|
|
95
98
|
}
|
|
96
99
|
),
|
|
97
|
-
|
|
100
|
+
v && /* @__PURE__ */ a("p", { className: "bear-text-sm bear-text-red-500", children: v })
|
|
98
101
|
]
|
|
99
102
|
}
|
|
100
103
|
) : /* @__PURE__ */ c(
|
|
101
104
|
"div",
|
|
102
105
|
{
|
|
103
|
-
ref:
|
|
104
|
-
id:
|
|
105
|
-
"data-testid":
|
|
106
|
-
className:
|
|
107
|
-
|
|
106
|
+
ref: E,
|
|
107
|
+
id: m,
|
|
108
|
+
"data-testid": T,
|
|
109
|
+
className: s(
|
|
110
|
+
l,
|
|
108
111
|
"bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
109
|
-
|
|
112
|
+
f && "Bear-Select--compact",
|
|
113
|
+
C && "bear-w-full"
|
|
110
114
|
),
|
|
111
115
|
children: [
|
|
112
|
-
n && /* @__PURE__ */ a("label", { className: "bear-text-
|
|
116
|
+
n && /* @__PURE__ */ a("label", { className: s("bear-font-medium", f ? "bear-text-xs" : "bear-text-sm"), style: { color: "var(--bear-text-secondary)" }, children: n }),
|
|
113
117
|
/* @__PURE__ */ c(
|
|
114
118
|
"button",
|
|
115
119
|
{
|
|
116
120
|
type: "button",
|
|
117
|
-
disabled:
|
|
118
|
-
onClick: () => !
|
|
119
|
-
className:
|
|
120
|
-
`${
|
|
121
|
+
disabled: d,
|
|
122
|
+
onClick: () => !d && g(!o),
|
|
123
|
+
className: s(
|
|
124
|
+
`${l}__trigger`,
|
|
121
125
|
"bear-flex bear-items-center bear-justify-between bear-w-full",
|
|
122
126
|
"bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200",
|
|
123
127
|
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
124
128
|
i ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
d && "bear-opacity-50 bear-cursor-not-allowed",
|
|
130
|
+
R[k],
|
|
131
|
+
f && "bear-py-1 bear-text-xs bear-h-8",
|
|
132
|
+
I
|
|
128
133
|
),
|
|
129
|
-
style:
|
|
134
|
+
style: D,
|
|
130
135
|
"aria-haspopup": "listbox",
|
|
131
|
-
"aria-expanded":
|
|
136
|
+
"aria-expanded": o,
|
|
132
137
|
"aria-invalid": i || void 0,
|
|
133
138
|
"aria-required": _ || void 0,
|
|
134
139
|
"aria-describedby": r == null ? void 0 : r.helperId,
|
|
135
140
|
children: [
|
|
136
|
-
/* @__PURE__ */ a("span", { className: `${
|
|
141
|
+
/* @__PURE__ */ a("span", { className: `${l}__value`, children: Z }),
|
|
137
142
|
/* @__PURE__ */ a(
|
|
138
|
-
|
|
143
|
+
re,
|
|
139
144
|
{
|
|
140
|
-
className:
|
|
145
|
+
className: s(
|
|
141
146
|
"bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",
|
|
142
|
-
|
|
147
|
+
o && "bear-rotate-180"
|
|
143
148
|
)
|
|
144
149
|
}
|
|
145
150
|
)
|
|
@@ -147,52 +152,52 @@ const _e = (w) => {
|
|
|
147
152
|
}
|
|
148
153
|
),
|
|
149
154
|
/* @__PURE__ */ a(
|
|
150
|
-
|
|
155
|
+
ae,
|
|
151
156
|
{
|
|
152
|
-
open:
|
|
153
|
-
ready:
|
|
157
|
+
open: o && !u,
|
|
158
|
+
ready: V,
|
|
154
159
|
style: {
|
|
155
|
-
...
|
|
160
|
+
...z,
|
|
156
161
|
backgroundColor: "var(--bear-bg-primary)",
|
|
157
162
|
borderColor: "var(--bear-border-default)"
|
|
158
163
|
},
|
|
159
|
-
zIndex:
|
|
160
|
-
openEffect:
|
|
161
|
-
closeEffect:
|
|
162
|
-
panelRef:
|
|
163
|
-
className: `${
|
|
164
|
+
zIndex: Q,
|
|
165
|
+
openEffect: q,
|
|
166
|
+
closeEffect: F,
|
|
167
|
+
panelRef: L,
|
|
168
|
+
className: `${l}__menu bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,
|
|
164
169
|
attributes: { role: "listbox" },
|
|
165
|
-
children: /* @__PURE__ */ a("div", { className: "bear-max-h-60 bear-overflow-y-auto", children:
|
|
170
|
+
children: /* @__PURE__ */ a("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: p.map((e) => /* @__PURE__ */ c(
|
|
166
171
|
"button",
|
|
167
172
|
{
|
|
168
173
|
type: "button",
|
|
169
174
|
disabled: e.disabled,
|
|
170
|
-
onClick: () => !e.disabled &&
|
|
175
|
+
onClick: () => !e.disabled && X(e.value),
|
|
171
176
|
role: "option",
|
|
172
|
-
"aria-selected": e.value ===
|
|
173
|
-
className:
|
|
174
|
-
`${
|
|
177
|
+
"aria-selected": e.value === t,
|
|
178
|
+
className: s(
|
|
179
|
+
`${l}__option`,
|
|
175
180
|
"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2",
|
|
176
181
|
"bear-text-left bear-transition-colors",
|
|
177
182
|
e.disabled && "bear-cursor-not-allowed",
|
|
178
|
-
e.value ===
|
|
179
|
-
!e.disabled && e.value !==
|
|
183
|
+
e.value === t && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",
|
|
184
|
+
!e.disabled && e.value !== t && "hover:bear-bg-[var(--bear-bg-tertiary)]"
|
|
180
185
|
),
|
|
181
|
-
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value ===
|
|
186
|
+
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value === t ? void 0 : { color: "var(--bear-text-secondary)" },
|
|
182
187
|
children: [
|
|
183
188
|
e.label,
|
|
184
|
-
e.value ===
|
|
189
|
+
e.value === t && /* @__PURE__ */ a(ee, { className: "bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400" })
|
|
185
190
|
]
|
|
186
191
|
},
|
|
187
192
|
e.value
|
|
188
193
|
)) })
|
|
189
194
|
}
|
|
190
195
|
),
|
|
191
|
-
|
|
196
|
+
v && /* @__PURE__ */ a("p", { className: "bear-text-sm bear-text-red-500", children: v })
|
|
192
197
|
]
|
|
193
198
|
}
|
|
194
199
|
);
|
|
195
200
|
};
|
|
196
201
|
export {
|
|
197
|
-
|
|
202
|
+
Oe as Select
|
|
198
203
|
};
|