@forgedevstack/bear 1.2.5 → 1.2.6
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 +15 -0
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.const.cjs +1 -0
- package/dist/components/AppBar/AppBar.const.d.ts +36 -1
- package/dist/components/AppBar/AppBar.const.js +39 -0
- package/dist/components/AppBar/AppBar.js +65 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- package/dist/components/Backdrop/Backdrop.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.d.ts +7 -0
- package/dist/components/Backdrop/Backdrop.const.js +10 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +43 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +12 -0
- package/dist/components/Backdrop/index.d.ts +2 -0
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +39 -0
- package/dist/components/Chip/Chip.const.js +43 -0
- package/dist/components/Chip/Chip.js +44 -65
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +41 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +57 -56
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +63 -62
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +133 -123
- package/dist/components/List/List.types.d.ts +2 -0
- package/dist/components/MessageList/MessageList.cjs +1 -1
- package/dist/components/MessageList/MessageList.const.cjs +1 -1
- package/dist/components/MessageList/MessageList.const.d.ts +6 -0
- package/dist/components/MessageList/MessageList.const.js +26 -20
- package/dist/components/MessageList/MessageList.d.ts +0 -16
- package/dist/components/MessageList/MessageList.js +127 -115
- package/dist/components/MessageList/MessageList.types.d.ts +2 -0
- package/dist/components/MessageList/MessageList.utils.cjs +1 -1
- package/dist/components/MessageList/MessageList.utils.d.ts +7 -0
- package/dist/components/MessageList/MessageList.utils.js +47 -28
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.const.cjs +1 -0
- package/dist/components/Progress/Progress.const.d.ts +16 -1
- package/dist/components/Progress/Progress.const.js +19 -0
- package/dist/components/Progress/Progress.d.ts +0 -10
- package/dist/components/Progress/Progress.js +81 -71
- package/dist/components/Progress/Progress.types.d.ts +2 -11
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
- package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -0
- package/dist/components/Select/Select.const.d.ts +9 -0
- package/dist/components/Select/Select.const.js +13 -0
- package/dist/components/Select/Select.js +144 -68
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -0
- package/dist/components/Toast/Toast.const.d.ts +4 -0
- package/dist/components/Toast/Toast.const.js +17 -0
- package/dist/components/Toast/Toast.d.ts +0 -1
- package/dist/components/Toast/Toast.js +90 -84
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +277 -273
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +8 -0
- package/dist/context/BearProvider.js +149 -139
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +12 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +385 -379
- package/dist/styles.css +67 -19
- package/package.json +1 -1
|
@@ -1,127 +1,203 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as O, useRef as D, useCallback as X, useEffect as V } from "react";
|
|
3
|
+
import { SELECT_DEFAULT_PLACEHOLDER as W, SELECT_SIZE_CLASSES as M, S_E_L_E_C_T_ROOT_CLASS as l, SELECT_MENU_Z_INDEX as Z, SELECT_MENU_EDGE_PAD_PX as $, SELECT_MENU_OFFSET_PX as G } from "./Select.const.js";
|
|
4
|
+
import { ChevronDownIcon as H, CheckIcon as q } from "../Icon/index.js";
|
|
5
|
+
import { Portal as J } from "../Portal/Portal.js";
|
|
6
|
+
import { cn as b } from "../../utils/cn.js";
|
|
7
|
+
import { resolveBearId as K } from "../../utils/generateBearId.utils.js";
|
|
8
|
+
import { useBearId as Q } from "../../utils/useBearId.js";
|
|
9
|
+
import { useClickOutsideMultiple as Y } from "../../hooks/useClickOutside.js";
|
|
5
10
|
import "../../context/BearProvider.js";
|
|
6
11
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
7
12
|
import "../FormControl/FormControl.context.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const ue = (R) => {
|
|
14
|
+
const {
|
|
15
|
+
options: v,
|
|
16
|
+
value: a,
|
|
17
|
+
onChange: o,
|
|
18
|
+
placeholder: h = W,
|
|
19
|
+
label: c,
|
|
20
|
+
error: s,
|
|
21
|
+
disabled: d = !1,
|
|
22
|
+
size: y = "md",
|
|
23
|
+
fullWidth: C = !1,
|
|
24
|
+
displayEmpty: p = !1,
|
|
25
|
+
renderValue: N,
|
|
26
|
+
native: u = !1,
|
|
27
|
+
className: S,
|
|
28
|
+
id: A,
|
|
29
|
+
testId: L
|
|
30
|
+
} = R, j = Q("Select"), f = K(A, j), [t, x] = O(!1), [w, z] = O({
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
width: 0
|
|
34
|
+
}), E = D(null), k = D(null), m = !!s, g = v.find((e) => e.value === a), _ = a === void 0 || a === "", I = _ || p && _, B = X(() => x(!1), []);
|
|
35
|
+
Y([E, k], B, { enabled: t && !u });
|
|
36
|
+
const F = (e) => {
|
|
37
|
+
o == null || o(e), x(!1);
|
|
30
38
|
};
|
|
31
|
-
|
|
32
|
-
if (!
|
|
39
|
+
V(() => {
|
|
40
|
+
if (!t || u) return;
|
|
33
41
|
const e = () => {
|
|
34
|
-
var
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
top:
|
|
38
|
-
left: Math.max(
|
|
39
|
-
|
|
42
|
+
var T;
|
|
43
|
+
const i = (T = E.current) == null ? void 0 : T.getBoundingClientRect();
|
|
44
|
+
i && z({
|
|
45
|
+
top: i.bottom + G,
|
|
46
|
+
left: Math.max(
|
|
47
|
+
$,
|
|
48
|
+
Math.min(i.left, window.innerWidth - i.width - $)
|
|
49
|
+
),
|
|
50
|
+
width: i.width
|
|
40
51
|
});
|
|
41
52
|
};
|
|
42
53
|
return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
43
54
|
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
44
55
|
};
|
|
45
|
-
}, [
|
|
56
|
+
}, [t, u]);
|
|
57
|
+
const U = N && !_ ? N(a) : I || !g ? h : g.label, P = {
|
|
58
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
59
|
+
borderColor: m ? void 0 : "var(--bear-border-default)",
|
|
60
|
+
color: g && !I ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
|
|
61
|
+
};
|
|
62
|
+
return u ? /* @__PURE__ */ n(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
id: f,
|
|
66
|
+
"data-testid": L,
|
|
67
|
+
className: b(
|
|
68
|
+
l,
|
|
69
|
+
"bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
70
|
+
C && "bear-w-full"
|
|
71
|
+
),
|
|
72
|
+
children: [
|
|
73
|
+
c && /* @__PURE__ */ r(
|
|
74
|
+
"label",
|
|
75
|
+
{
|
|
76
|
+
htmlFor: `${f}-native`,
|
|
77
|
+
className: "bear-text-sm bear-font-medium",
|
|
78
|
+
style: { color: "var(--bear-text-secondary)" },
|
|
79
|
+
children: c
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ n(
|
|
83
|
+
"select",
|
|
84
|
+
{
|
|
85
|
+
id: `${f}-native`,
|
|
86
|
+
disabled: d,
|
|
87
|
+
value: a ?? "",
|
|
88
|
+
onChange: (e) => o == null ? void 0 : o(e.target.value),
|
|
89
|
+
className: b(
|
|
90
|
+
`${l}__native`,
|
|
91
|
+
"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200",
|
|
92
|
+
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
93
|
+
m ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500",
|
|
94
|
+
d && "bear-opacity-50 bear-cursor-not-allowed",
|
|
95
|
+
M[y],
|
|
96
|
+
S
|
|
97
|
+
),
|
|
98
|
+
style: P,
|
|
99
|
+
"aria-invalid": m || void 0,
|
|
100
|
+
children: [
|
|
101
|
+
(p || h) && /* @__PURE__ */ r("option", { value: "", disabled: !p, children: h }),
|
|
102
|
+
v.map((e) => /* @__PURE__ */ r("option", { value: e.value, disabled: e.disabled, children: e.label }, e.value))
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
s && /* @__PURE__ */ r("p", { className: "bear-text-sm bear-text-red-500", children: s })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
) : /* @__PURE__ */ n(
|
|
46
110
|
"div",
|
|
47
111
|
{
|
|
48
|
-
ref:
|
|
49
|
-
|
|
112
|
+
ref: E,
|
|
113
|
+
id: f,
|
|
114
|
+
"data-testid": L,
|
|
115
|
+
className: b(
|
|
116
|
+
l,
|
|
117
|
+
"bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
118
|
+
C && "bear-w-full"
|
|
119
|
+
),
|
|
50
120
|
children: [
|
|
51
|
-
|
|
52
|
-
/* @__PURE__ */
|
|
121
|
+
c && /* @__PURE__ */ r("label", { className: "bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)" }, children: c }),
|
|
122
|
+
/* @__PURE__ */ n(
|
|
53
123
|
"button",
|
|
54
124
|
{
|
|
55
125
|
type: "button",
|
|
56
126
|
disabled: d,
|
|
57
|
-
onClick: () => !d &&
|
|
58
|
-
className:
|
|
127
|
+
onClick: () => !d && x(!t),
|
|
128
|
+
className: b(
|
|
129
|
+
`${l}__trigger`,
|
|
59
130
|
"bear-flex bear-items-center bear-justify-between bear-w-full",
|
|
60
131
|
"bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200",
|
|
61
132
|
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
62
|
-
|
|
133
|
+
m ? "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",
|
|
63
134
|
d && "bear-opacity-50 bear-cursor-not-allowed",
|
|
64
|
-
|
|
65
|
-
|
|
135
|
+
M[y],
|
|
136
|
+
S
|
|
66
137
|
),
|
|
67
|
-
style:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
color: l ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
|
|
71
|
-
},
|
|
138
|
+
style: P,
|
|
139
|
+
"aria-haspopup": "listbox",
|
|
140
|
+
"aria-expanded": t,
|
|
72
141
|
children: [
|
|
73
|
-
/* @__PURE__ */ r("span", {
|
|
142
|
+
/* @__PURE__ */ r("span", { className: `${l}__value`, children: U }),
|
|
74
143
|
/* @__PURE__ */ r(
|
|
75
|
-
|
|
144
|
+
H,
|
|
76
145
|
{
|
|
77
|
-
className:
|
|
146
|
+
className: b(
|
|
147
|
+
"bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",
|
|
148
|
+
t && "bear-rotate-180"
|
|
149
|
+
),
|
|
78
150
|
style: { color: "var(--bear-text-muted)" }
|
|
79
151
|
}
|
|
80
152
|
)
|
|
81
153
|
]
|
|
82
154
|
}
|
|
83
155
|
),
|
|
84
|
-
|
|
156
|
+
t && /* @__PURE__ */ r(J, { children: /* @__PURE__ */ r(
|
|
85
157
|
"div",
|
|
86
158
|
{
|
|
87
|
-
ref:
|
|
88
|
-
className:
|
|
159
|
+
ref: k,
|
|
160
|
+
className: `${l}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,
|
|
89
161
|
style: {
|
|
90
162
|
backgroundColor: "var(--bear-bg-primary)",
|
|
91
163
|
borderColor: "var(--bear-border-default)",
|
|
92
|
-
top:
|
|
93
|
-
left:
|
|
94
|
-
width:
|
|
95
|
-
zIndex:
|
|
164
|
+
top: w.top,
|
|
165
|
+
left: w.left,
|
|
166
|
+
width: w.width,
|
|
167
|
+
zIndex: Z
|
|
96
168
|
},
|
|
97
|
-
|
|
169
|
+
role: "listbox",
|
|
170
|
+
children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: v.map((e) => /* @__PURE__ */ n(
|
|
98
171
|
"button",
|
|
99
172
|
{
|
|
100
173
|
type: "button",
|
|
101
174
|
disabled: e.disabled,
|
|
102
|
-
onClick: () => !e.disabled &&
|
|
103
|
-
|
|
175
|
+
onClick: () => !e.disabled && F(e.value),
|
|
176
|
+
role: "option",
|
|
177
|
+
"aria-selected": e.value === a,
|
|
178
|
+
className: b(
|
|
179
|
+
`${l}__option`,
|
|
104
180
|
"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2",
|
|
105
181
|
"bear-text-left bear-transition-colors",
|
|
106
182
|
e.disabled && "bear-cursor-not-allowed",
|
|
107
|
-
e.value ===
|
|
108
|
-
!e.disabled && e.value !==
|
|
183
|
+
e.value === a && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",
|
|
184
|
+
!e.disabled && e.value !== a && "hover:bear-bg-[var(--bear-bg-tertiary)]"
|
|
109
185
|
),
|
|
110
|
-
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value ===
|
|
186
|
+
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value === a ? void 0 : { color: "var(--bear-text-secondary)" },
|
|
111
187
|
children: [
|
|
112
188
|
e.label,
|
|
113
|
-
e.value ===
|
|
189
|
+
e.value === a && /* @__PURE__ */ r(q, { className: "bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400" })
|
|
114
190
|
]
|
|
115
191
|
},
|
|
116
192
|
e.value
|
|
117
193
|
)) })
|
|
118
194
|
}
|
|
119
195
|
) }),
|
|
120
|
-
|
|
196
|
+
s && /* @__PURE__ */ r("p", { className: "bear-text-sm bear-text-red-500", children: s })
|
|
121
197
|
]
|
|
122
198
|
}
|
|
123
199
|
);
|
|
124
200
|
};
|
|
125
201
|
export {
|
|
126
|
-
|
|
202
|
+
ue as Select
|
|
127
203
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),E=require("react"),H=require("../../context/BearProvider.cjs"),ee=require("../../utils/maxVisible.utils.cjs"),c=require("../../utils/cn.cjs"),U=require("../Typography/Typography.cjs"),re=require("../Dropdown/Dropdown.cjs"),ne=require("../Icon/index.cjs"),r=require("./Stepper.const.cjs"),m=require("./Stepper.utils.cjs"),te=1200,se=16,oe=640,W=3,ie=()=>n.jsx("svg",{width:r.CHECK_ICON_SIZE,height:r.CHECK_ICON_SIZE,viewBox:r.CHECK_ICON_VIEWBOX,fill:"none",stroke:"currentColor",strokeWidth:"3",children:n.jsx("polyline",{points:r.CHECK_ICON_POINTS})}),ce=()=>n.jsxs("svg",{width:r.ERROR_ICON_SIZE,height:r.ERROR_ICON_SIZE,viewBox:r.ERROR_ICON_VIEWBOX,fill:"none",stroke:"currentColor",strokeWidth:"3",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),D=E.forwardRef(({steps:o,activeStep:_,onStepClick:S,orientation:M=r.DEFAULT_ORIENTATION,size:A=r.DEFAULT_SIZE,showNumbers:V=r.DEFAULT_SHOW_NUMBERS,clickable:g=r.DEFAULT_CLICKABLE,showConnectors:q=r.DEFAULT_SHOW_CONNECTORS,connectorStyle:R=r.DEFAULT_CONNECTOR_STYLE,alternativeLabel:L=r.DEFAULT_ALTERNATIVE_LABEL,completedIcon:Z,errorIcon:z,labelTypographyProps:K,descriptionTypographyProps:k,maxVisibleSteps:C,testId:X,className:$,...G},Y)=>{const f=H.useBearThemeOptional(),{direction:p}=H.useBearDirectionOptional(),[O,J]=E.useState(()=>typeof window<"u"?window.innerWidth:te);E.useEffect(()=>{const e=()=>J(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const h=E.useMemo(()=>{if(C!=null)return ee.resolveMaxVisible(C,{width:O,theme:f});if(O<oe&&o.length>W)return W},[C,O,f,o.length]),d=M==="horizontal",v=r.STEP_INDICATOR_SIZES[A],x=r.STEP_LABEL_SIZES[A],T=d&&h!=null&&o.length>h,{visibleIndices:j,leftHidden:b,rightHidden:N}=E.useMemo(()=>{if(!T||h==null)return{visibleIndices:o.map((a,I)=>I),leftHidden:[],rightHidden:[]};const e=h,t=Math.floor(e/2),s=Math.max(0,Math.min(_-t,o.length-e)),i=Array.from({length:e},(a,I)=>s+I),l=[],F=[];for(let a=0;a<s;a++)l.push(a);for(let a=s+e;a<o.length;a++)F.push(a);return{visibleIndices:i,leftHidden:l,rightHidden:F}},[T,h,o,_]),w=(e,t,s)=>{const i=r.STEP_STATUS_CLASSES[s],l=m.resolveIndicatorContent(e,t,s,V,Z,z,n.jsx(ie,{}),n.jsx(ce,{}));return n.jsx("div",{className:c.cn(r.STEP_INDICATOR_BASE,v,i.indicator,g&&!e.disabled&&"cursor-pointer hover:scale-105"),onClick:()=>{g&&!e.disabled&&S&&S(t)},children:l})},u=(e,t)=>{if(!q||t)return null;const s=e<_;return d?n.jsx("div",{className:c.cn("Bear-Stepper__connector flex-1 self-center mx-1","h-0.5 min-w-[12px] transition-colors",s?r.CONNECTOR_STATUS.completed:r.CONNECTOR_STATUS.pending,R==="dashed"&&"border-t-2 border-dashed bg-transparent")}):n.jsx("div",{className:c.cn(r.CONNECTOR_BASE,r.CONNECTOR_VERTICAL,s?r.CONNECTOR_STATUS.completed:r.CONNECTOR_STATUS.pending,R==="dashed"&&"border-t-2 border-dashed bg-transparent")})},B=(e,t)=>{const s=r.STEP_STATUS_CLASSES[t],i={...K,...e.labelTypographyProps},l={...k,...e.descriptionTypographyProps};return n.jsxs(n.Fragment,{children:[n.jsx(U.Typography,{variant:"body2",...i,className:c.cn(r.STEP_LABEL_BASE,x.label,s.label,i==null?void 0:i.className),children:e.label}),e.description&&n.jsx(U.Typography,{variant:"caption",...l,className:c.cn(r.STEP_DESCRIPTION_CLASSES,x.description,l==null?void 0:l.className),children:e.description})]})},P=(e,t)=>{const s=m.resolveStepStatus(e,t,_);return n.jsxs("div",{className:c.cn("Bear-Stepper__content flex shrink-0",L?"flex-col items-center":"items-center gap-2"),children:[w(e,t,s),n.jsx("div",{className:c.cn(L&&"text-center mt-2","whitespace-nowrap"),children:B(e,s)})]})},Q=(e,t)=>{const s=m.resolveStepStatus(e,t,_);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-shrink-0 mr-4",children:w(e,t,s)}),n.jsxs("div",{className:"flex-1 pt-0.5",children:[B(e,s),e.content&&s==="active"&&n.jsx("div",{className:"mt-4",children:e.content})]})]})},y=(e,t)=>n.jsx("div",{className:"Bear-Stepper__overflow shrink-0",children:n.jsx(re.Dropdown,{placement:"bottom-start",closeOnSelect:!0,trigger:n.jsx("button",{type:"button",className:c.cn(r.STEP_INDICATOR_BASE,v,r.STEP_STATUS_CLASSES.pending.indicator,"bear-cursor-pointer bear-border-0"),"aria-label":t==="left"?r.OVERFLOW_LEFT_LABEL:r.OVERFLOW_RIGHT_LABEL,children:n.jsx(ne.BearIcons.MoreHorizIcon,{size:se})}),items:e.map(s=>({key:`step-${s}`,label:o[s].label,disabled:o[s].disabled,onClick:()=>{o[s].disabled||S==null||S(s)}}))})},`overflow-${t}`);return n.jsxs("div",{ref:Y,dir:p,className:c.cn(r.STEPPER_BASE_CLASSES,d?r.STEPPER_HORIZONTAL_CLASSES:r.STEPPER_VERTICAL_CLASSES,p==="rtl"&&d&&"bear-flex-row-reverse",$),"data-testid":X,...G,children:[d&&!T&&o.map((e,t)=>n.jsxs(E.Fragment,{children:[P(e,t),u(t,t===o.length-1)]},t)),d&&T&&n.jsxs(n.Fragment,{children:[b.length>0&&n.jsxs(n.Fragment,{children:[y(b,"left"),u(-1,!1)]}),j.map((e,t)=>{const s=o[e],i=t===j.length-1&&N.length===0;return n.jsxs(E.Fragment,{children:[P(s,e),u(e,i)]},e)}),N.length>0&&y(N,"right")]}),!d&&o.map((e,t)=>n.jsxs("div",{className:c.cn("Bear-Stepper__step",r.STEP_WRAPPER_VERTICAL),children:[Q(e,t),u(t,t===o.length-1)]},t))]})});D.displayName="Stepper";exports.Stepper=D;
|
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as f, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useBearThemeOptional as
|
|
4
|
-
import { resolveMaxVisible as
|
|
2
|
+
import U, { forwardRef as ie, useState as le, useEffect as se, useMemo as V } from "react";
|
|
3
|
+
import { useBearThemeOptional as ae, useBearDirectionOptional as ce } from "../../context/BearProvider.js";
|
|
4
|
+
import { resolveMaxVisible as de } from "../../utils/maxVisible.utils.js";
|
|
5
5
|
import { cn as s } from "../../utils/cn.js";
|
|
6
|
-
import { Typography as
|
|
7
|
-
import { Dropdown as
|
|
8
|
-
import { BearIcons as
|
|
9
|
-
import { STEP_WRAPPER_VERTICAL as
|
|
10
|
-
import { resolveStepStatus as
|
|
11
|
-
const
|
|
6
|
+
import { Typography as M } from "../Typography/Typography.js";
|
|
7
|
+
import { Dropdown as Ee } from "../Dropdown/Dropdown.js";
|
|
8
|
+
import { BearIcons as he } from "../Icon/index.js";
|
|
9
|
+
import { STEP_WRAPPER_VERTICAL as _e, STEPPER_HORIZONTAL_CLASSES as me, STEPPER_VERTICAL_CLASSES as Te, STEPPER_BASE_CLASSES as fe, DEFAULT_ORIENTATION as Se, DEFAULT_SIZE as Ie, DEFAULT_SHOW_NUMBERS as Oe, DEFAULT_CLICKABLE as Ce, DEFAULT_SHOW_CONNECTORS as Ne, DEFAULT_CONNECTOR_STYLE as ue, DEFAULT_ALTERNATIVE_LABEL as Ae, CONNECTOR_STATUS as S, CONNECTOR_VERTICAL as Le, CONNECTOR_BASE as ge, OVERFLOW_LEFT_LABEL as Re, OVERFLOW_RIGHT_LABEL as pe, STEP_STATUS_CLASSES as u, STEP_INDICATOR_SIZES as ve, STEP_INDICATOR_BASE as z, STEP_LABEL_SIZES as we, STEP_LABEL_BASE as be, STEP_DESCRIPTION_CLASSES as Be, ERROR_ICON_VIEWBOX as Pe, ERROR_ICON_SIZE as Z, CHECK_ICON_VIEWBOX as ye, CHECK_ICON_SIZE as K, CHECK_ICON_POINTS as He } from "./Stepper.const.js";
|
|
10
|
+
import { resolveStepStatus as k, resolveIndicatorContent as We } from "./Stepper.utils.js";
|
|
11
|
+
const Fe = 1200, De = 16, Ue = 640, x = 3, Ve = () => /* @__PURE__ */ t("svg", { width: K, height: K, viewBox: ye, fill: "none", stroke: "currentColor", strokeWidth: "3", children: /* @__PURE__ */ t("polyline", { points: He }) }), Me = () => /* @__PURE__ */ i("svg", { width: Z, height: Z, viewBox: Pe, fill: "none", stroke: "currentColor", strokeWidth: "3", children: [
|
|
12
12
|
/* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
13
13
|
/* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
14
|
-
] }),
|
|
14
|
+
] }), ze = ie(
|
|
15
15
|
({
|
|
16
16
|
steps: o,
|
|
17
17
|
activeStep: E,
|
|
18
18
|
onStepClick: h,
|
|
19
|
-
orientation: X =
|
|
20
|
-
size: A =
|
|
21
|
-
showNumbers: j =
|
|
22
|
-
clickable: L =
|
|
23
|
-
showConnectors:
|
|
24
|
-
connectorStyle: g =
|
|
25
|
-
alternativeLabel: R =
|
|
26
|
-
completedIcon:
|
|
27
|
-
errorIcon:
|
|
28
|
-
labelTypographyProps:
|
|
29
|
-
descriptionTypographyProps:
|
|
19
|
+
orientation: X = Se,
|
|
20
|
+
size: A = Ie,
|
|
21
|
+
showNumbers: j = Oe,
|
|
22
|
+
clickable: L = Ce,
|
|
23
|
+
showConnectors: $ = Ne,
|
|
24
|
+
connectorStyle: g = ue,
|
|
25
|
+
alternativeLabel: R = Ae,
|
|
26
|
+
completedIcon: G,
|
|
27
|
+
errorIcon: Y,
|
|
28
|
+
labelTypographyProps: q,
|
|
29
|
+
descriptionTypographyProps: J,
|
|
30
30
|
maxVisibleSteps: I,
|
|
31
|
-
testId:
|
|
32
|
-
className:
|
|
33
|
-
...
|
|
34
|
-
},
|
|
35
|
-
const p =
|
|
36
|
-
|
|
37
|
-
const e = () =>
|
|
31
|
+
testId: Q,
|
|
32
|
+
className: ee,
|
|
33
|
+
...re
|
|
34
|
+
}, ne) => {
|
|
35
|
+
const p = ae(), { direction: v } = ce(), [O, te] = le(() => typeof window < "u" ? window.innerWidth : Fe);
|
|
36
|
+
se(() => {
|
|
37
|
+
const e = () => te(window.innerWidth);
|
|
38
38
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
39
39
|
}, []);
|
|
40
|
-
const _ =
|
|
40
|
+
const _ = V(() => {
|
|
41
41
|
if (I != null)
|
|
42
|
-
return
|
|
43
|
-
if (O <
|
|
44
|
-
return
|
|
45
|
-
}, [I, O, p, o.length]), d = X === "horizontal",
|
|
42
|
+
return de(I, { width: O, theme: p });
|
|
43
|
+
if (O < Ue && o.length > x)
|
|
44
|
+
return x;
|
|
45
|
+
}, [I, O, p, o.length]), d = X === "horizontal", w = ve[A], b = we[A], m = d && _ != null && o.length > _, { visibleIndices: B, leftHidden: P, rightHidden: C } = V(() => {
|
|
46
46
|
if (!m || _ == null)
|
|
47
47
|
return {
|
|
48
48
|
visibleIndices: o.map((c, N) => N),
|
|
49
49
|
leftHidden: [],
|
|
50
50
|
rightHidden: []
|
|
51
51
|
};
|
|
52
|
-
const e = _, r = Math.floor(e / 2), n = Math.max(0, Math.min(E - r, o.length - e)), l = Array.from({ length: e }, (c, N) => n + N), a = [],
|
|
52
|
+
const e = _, r = Math.floor(e / 2), n = Math.max(0, Math.min(E - r, o.length - e)), l = Array.from({ length: e }, (c, N) => n + N), a = [], D = [];
|
|
53
53
|
for (let c = 0; c < n; c++) a.push(c);
|
|
54
|
-
for (let c = n + e; c < o.length; c++)
|
|
55
|
-
return { visibleIndices: l, leftHidden: a, rightHidden:
|
|
56
|
-
}, [m, _, o, E]),
|
|
57
|
-
const l = u[n], a =
|
|
54
|
+
for (let c = n + e; c < o.length; c++) D.push(c);
|
|
55
|
+
return { visibleIndices: l, leftHidden: a, rightHidden: D };
|
|
56
|
+
}, [m, _, o, E]), y = (e, r, n) => {
|
|
57
|
+
const l = u[n], a = We(
|
|
58
58
|
e,
|
|
59
59
|
r,
|
|
60
60
|
n,
|
|
61
61
|
j,
|
|
62
|
-
$,
|
|
63
62
|
G,
|
|
64
|
-
|
|
65
|
-
/* @__PURE__ */ t(
|
|
63
|
+
Y,
|
|
64
|
+
/* @__PURE__ */ t(Ve, {}),
|
|
65
|
+
/* @__PURE__ */ t(Me, {})
|
|
66
66
|
);
|
|
67
67
|
return /* @__PURE__ */ t(
|
|
68
68
|
"div",
|
|
69
69
|
{
|
|
70
70
|
className: s(
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
z,
|
|
72
|
+
w,
|
|
73
73
|
l.indicator,
|
|
74
74
|
L && !e.disabled && "cursor-pointer hover:scale-105"
|
|
75
75
|
),
|
|
@@ -80,7 +80,7 @@ const He = 1200, We = 16, Fe = 640, k = 3, De = () => /* @__PURE__ */ t("svg", {
|
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
}, T = (e, r) => {
|
|
83
|
-
if (
|
|
83
|
+
if (!$ || r) return null;
|
|
84
84
|
const n = e < E;
|
|
85
85
|
return d ? /* @__PURE__ */ t(
|
|
86
86
|
"div",
|
|
@@ -96,52 +96,52 @@ const He = 1200, We = 16, Fe = 640, k = 3, De = () => /* @__PURE__ */ t("svg", {
|
|
|
96
96
|
"div",
|
|
97
97
|
{
|
|
98
98
|
className: s(
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
ge,
|
|
100
|
+
Le,
|
|
101
101
|
n ? S.completed : S.pending,
|
|
102
102
|
g === "dashed" && "border-t-2 border-dashed bg-transparent"
|
|
103
103
|
)
|
|
104
104
|
}
|
|
105
105
|
);
|
|
106
|
-
},
|
|
107
|
-
const n = u[r], l = { ...
|
|
106
|
+
}, H = (e, r) => {
|
|
107
|
+
const n = u[r], l = { ...q, ...e.labelTypographyProps }, a = { ...J, ...e.descriptionTypographyProps };
|
|
108
108
|
return /* @__PURE__ */ i(f, { children: [
|
|
109
109
|
/* @__PURE__ */ t(
|
|
110
|
-
|
|
110
|
+
M,
|
|
111
111
|
{
|
|
112
112
|
variant: "body2",
|
|
113
113
|
...l,
|
|
114
|
-
className: s(
|
|
114
|
+
className: s(be, b.label, n.label, l == null ? void 0 : l.className),
|
|
115
115
|
children: e.label
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
118
|
e.description && /* @__PURE__ */ t(
|
|
119
|
-
|
|
119
|
+
M,
|
|
120
120
|
{
|
|
121
121
|
variant: "caption",
|
|
122
122
|
...a,
|
|
123
|
-
className: s(
|
|
123
|
+
className: s(Be, b.description, a == null ? void 0 : a.className),
|
|
124
124
|
children: e.description
|
|
125
125
|
}
|
|
126
126
|
)
|
|
127
127
|
] });
|
|
128
|
-
},
|
|
129
|
-
const n =
|
|
128
|
+
}, W = (e, r) => {
|
|
129
|
+
const n = k(e, r, E);
|
|
130
130
|
return /* @__PURE__ */ i("div", { className: s("Bear-Stepper__content flex shrink-0", R ? "flex-col items-center" : "items-center gap-2"), children: [
|
|
131
|
-
|
|
132
|
-
/* @__PURE__ */ t("div", { className: s(R && "text-center mt-2", "whitespace-nowrap"), children:
|
|
131
|
+
y(e, r, n),
|
|
132
|
+
/* @__PURE__ */ t("div", { className: s(R && "text-center mt-2", "whitespace-nowrap"), children: H(e, n) })
|
|
133
133
|
] });
|
|
134
|
-
},
|
|
135
|
-
const n =
|
|
134
|
+
}, oe = (e, r) => {
|
|
135
|
+
const n = k(e, r, E);
|
|
136
136
|
return /* @__PURE__ */ i(f, { children: [
|
|
137
|
-
/* @__PURE__ */ t("div", { className: "flex-shrink-0 mr-4", children:
|
|
137
|
+
/* @__PURE__ */ t("div", { className: "flex-shrink-0 mr-4", children: y(e, r, n) }),
|
|
138
138
|
/* @__PURE__ */ i("div", { className: "flex-1 pt-0.5", children: [
|
|
139
|
-
|
|
139
|
+
H(e, n),
|
|
140
140
|
e.content && n === "active" && /* @__PURE__ */ t("div", { className: "mt-4", children: e.content })
|
|
141
141
|
] })
|
|
142
142
|
] });
|
|
143
|
-
},
|
|
144
|
-
|
|
143
|
+
}, F = (e, r) => /* @__PURE__ */ t("div", { className: "Bear-Stepper__overflow shrink-0", children: /* @__PURE__ */ t(
|
|
144
|
+
Ee,
|
|
145
145
|
{
|
|
146
146
|
placement: "bottom-start",
|
|
147
147
|
closeOnSelect: !0,
|
|
@@ -150,13 +150,13 @@ const He = 1200, We = 16, Fe = 640, k = 3, De = () => /* @__PURE__ */ t("svg", {
|
|
|
150
150
|
{
|
|
151
151
|
type: "button",
|
|
152
152
|
className: s(
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
z,
|
|
154
|
+
w,
|
|
155
155
|
u.pending.indicator,
|
|
156
156
|
"bear-cursor-pointer bear-border-0"
|
|
157
157
|
),
|
|
158
|
-
"aria-label": r === "left" ?
|
|
159
|
-
children: /* @__PURE__ */ t(
|
|
158
|
+
"aria-label": r === "left" ? Re : pe,
|
|
159
|
+
children: /* @__PURE__ */ t(he.MoreHorizIcon, { size: De })
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
162
|
items: e.map((n) => ({
|
|
@@ -172,31 +172,37 @@ const He = 1200, We = 16, Fe = 640, k = 3, De = () => /* @__PURE__ */ t("svg", {
|
|
|
172
172
|
return /* @__PURE__ */ i(
|
|
173
173
|
"div",
|
|
174
174
|
{
|
|
175
|
-
ref:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
ref: ne,
|
|
176
|
+
dir: v,
|
|
177
|
+
className: s(
|
|
178
|
+
fe,
|
|
179
|
+
d ? me : Te,
|
|
180
|
+
v === "rtl" && d && "bear-flex-row-reverse",
|
|
181
|
+
ee
|
|
182
|
+
),
|
|
183
|
+
"data-testid": Q,
|
|
184
|
+
...re,
|
|
179
185
|
children: [
|
|
180
|
-
d && !m && o.map((e, r) => /* @__PURE__ */ i(
|
|
181
|
-
|
|
186
|
+
d && !m && o.map((e, r) => /* @__PURE__ */ i(U.Fragment, { children: [
|
|
187
|
+
W(e, r),
|
|
182
188
|
T(r, r === o.length - 1)
|
|
183
189
|
] }, r)),
|
|
184
190
|
d && m && /* @__PURE__ */ i(f, { children: [
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
P.length > 0 && /* @__PURE__ */ i(f, { children: [
|
|
192
|
+
F(P, "left"),
|
|
187
193
|
T(-1, !1)
|
|
188
194
|
] }),
|
|
189
|
-
|
|
190
|
-
const n = o[e], l = r ===
|
|
191
|
-
return /* @__PURE__ */ i(
|
|
192
|
-
|
|
195
|
+
B.map((e, r) => {
|
|
196
|
+
const n = o[e], l = r === B.length - 1 && C.length === 0;
|
|
197
|
+
return /* @__PURE__ */ i(U.Fragment, { children: [
|
|
198
|
+
W(n, e),
|
|
193
199
|
T(e, l)
|
|
194
200
|
] }, e);
|
|
195
201
|
}),
|
|
196
|
-
C.length > 0 &&
|
|
202
|
+
C.length > 0 && F(C, "right")
|
|
197
203
|
] }),
|
|
198
|
-
!d && o.map((e, r) => /* @__PURE__ */ i("div", { className: s("Bear-Stepper__step",
|
|
199
|
-
|
|
204
|
+
!d && o.map((e, r) => /* @__PURE__ */ i("div", { className: s("Bear-Stepper__step", _e), children: [
|
|
205
|
+
oe(e, r),
|
|
200
206
|
T(r, r === o.length - 1)
|
|
201
207
|
] }, r))
|
|
202
208
|
]
|
|
@@ -204,7 +210,7 @@ const He = 1200, We = 16, Fe = 640, k = 3, De = () => /* @__PURE__ */ t("svg", {
|
|
|
204
210
|
);
|
|
205
211
|
}
|
|
206
212
|
);
|
|
207
|
-
|
|
213
|
+
ze.displayName = "Stepper";
|
|
208
214
|
export {
|
|
209
|
-
|
|
215
|
+
ze as Stepper
|
|
210
216
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),k=require("../../utils/cn.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),d=require("./Toast.const.cjs"),k=require("../../utils/cn.cjs"),C=require("../../utils/generateBearId.utils.cjs"),A={success:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),info:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),warning:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),error:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})},E=()=>e.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),O={success:"bear-bg-green-500 bear-text-white",info:"bear-bg-blue-500 bear-text-white",warning:"bear-bg-amber-500 bear-text-white",error:"bear-bg-red-500 bear-text-white"},R={"top-left":"bear-top-4 bear-left-4","top-center":"bear-top-4 bear-left-1/2 bear-transform bear--translate-x-1/2","top-right":"bear-top-4 bear-right-4","bottom-left":"bear-bottom-4 bear-left-4","bottom-center":"bear-bottom-4 bear-left-1/2 bear-transform bear--translate-x-1/2","bottom-right":"bear-bottom-4 bear-right-4"},_=t.createContext(null),L=()=>{const i=t.useContext(_);if(!i)throw new Error("useToast must be used within a ToastProvider");return i},N=({message:i,title:u,severity:c="info",duration:l=5e3,closable:b=!0,icon:o,action:a,onClose:n,onRemove:h,className:j,autoScroll:f=!1,pauseOnHover:T=!1})=>{const[v,m]=t.useState(!1),[g,r]=t.useState(!1),s=t.useRef(null),x=t.useRef(l),w=t.useRef(0);t.useEffect(()=>{f&&s.current&&s.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[f]),t.useEffect(()=>{if(l<=0||g)return;w.current=Date.now();const I=setTimeout(()=>{m(!0),setTimeout(()=>{h(),n==null||n()},d.TOAST_EXIT_MS)},x.current);return()=>{clearTimeout(I),x.current=Math.max(0,x.current-(Date.now()-w.current))}},[l,g,h,n]);const S=()=>{m(!0),setTimeout(()=>{h(),n==null||n()},d.TOAST_EXIT_MS)},y=()=>o===!1?null:o||A[c];return e.jsxs("div",{ref:s,role:d.TOAST_ARIA_ROLE[c],"aria-live":d.TOAST_ARIA_LIVE[c],"aria-atomic":"true",onMouseEnter:T?()=>r(!0):void 0,onMouseLeave:T?()=>r(!1):void 0,className:k.cn(d.T_O_A_S_T_ROOT_CLASS,"bear-flex bear-items-start bear-gap-3 bear-p-4 bear-rounded-lg bear-shadow-lg bear-min-w-[300px] bear-max-w-[400px]","bear-transition-all bear-duration-200",v?"bear-opacity-0 bear-translate-x-2":"bear-opacity-100 bear-translate-x-0",O[c],j),children:[y()&&e.jsx("span",{className:"bear-flex-shrink-0 bear-mt-0.5",children:y()}),e.jsxs("div",{className:"bear-flex-1 bear-min-w-0",children:[u&&e.jsx("div",{className:"bear-font-semibold bear-mb-0.5",children:u}),e.jsx("div",{className:"bear-text-sm bear-opacity-90",children:i})]}),a&&e.jsx("div",{className:"bear-flex-shrink-0",children:a}),b&&e.jsx("button",{type:"button",onClick:S,className:"bear-flex-shrink-0 bear-p-1 bear-rounded hover:bear-bg-white/20 bear-transition-colors bear-bg-transparent bear-border-none bear-cursor-pointer","aria-label":"Close",children:e.jsx(E,{})})]})},p=({position:i="top-right",maxToasts:u=5,className:c})=>{const l=t.useContext(_);if(!l)return null;const{_toasts:b,_removeToast:o}=l,a=b.slice(0,u);return e.jsx("div",{className:k.cn(`${d.T_O_A_S_T_ROOT_CLASS}__container`,"bear-fixed bear-z-[11000] bear-flex bear-flex-col bear-gap-2",R[i],c),"aria-relevant":"additions",children:a.map(n=>e.jsx(N,{...n,onRemove:()=>o(n.id)},n.id))})},M=({children:i,position:u="top-right",maxToasts:c})=>{const[l,b]=t.useState([]),o=t.useCallback(r=>{b(s=>s.filter(x=>x.id!==r))},[]),a=t.useCallback(r=>{const s=r.id||C.generateBearId("Toast");return b(x=>[...x,{...r,id:s}]),s},[]),n=t.useCallback(r=>a(r),[a]),h=t.useCallback((r,s)=>a({message:r,severity:"success",...s}),[a]),j=t.useCallback((r,s)=>a({message:r,severity:"info",...s}),[a]),f=t.useCallback((r,s)=>a({message:r,severity:"warning",...s}),[a]),T=t.useCallback((r,s)=>a({message:r,severity:"error",...s}),[a]),v=t.useCallback(r=>o(r),[o]),m=t.useCallback(()=>b([]),[]),g={toast:n,success:h,info:j,warning:f,error:T,dismiss:v,dismissAll:m,_toasts:l,_removeToast:o};return e.jsxs(_.Provider,{value:g,children:[i,e.jsx(p,{position:u,maxToasts:c})]})};exports.ToastContainer=p;exports.ToastProvider=M;exports.useToast=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="Bear-Toast",t={success:"polite",info:"polite",warning:"polite",error:"assertive"},T={success:"status",info:"status",warning:"status",error:"alert"},s=200;exports.TOAST_ARIA_LIVE=t;exports.TOAST_ARIA_ROLE=T;exports.TOAST_EXIT_MS=s;exports.T_O_A_S_T_ROOT_CLASS=_;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
import { ToastSeverity } from './Toast.types';
|
|
1
2
|
export declare const T_O_A_S_T_ROOT_CLASS = "Bear-Toast";
|
|
3
|
+
export declare const TOAST_ARIA_LIVE: Record<ToastSeverity, 'polite' | 'assertive'>;
|
|
4
|
+
export declare const TOAST_ARIA_ROLE: Record<ToastSeverity, 'status' | 'alert'>;
|
|
5
|
+
export declare const TOAST_EXIT_MS = 200;
|