@forgedevstack/bear 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Backdrop/Backdrop.cjs +1 -1
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -1
- package/dist/components/Backdrop/Backdrop.const.d.ts +4 -1
- package/dist/components/Backdrop/Backdrop.const.js +11 -8
- package/dist/components/Backdrop/Backdrop.js +39 -36
- package/dist/components/Backdrop/Backdrop.types.d.ts +1 -0
- package/dist/components/Backdrop/index.d.ts +1 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.const.cjs +1 -1
- package/dist/components/Drawer/Drawer.const.d.ts +3 -0
- package/dist/components/Drawer/Drawer.const.js +14 -11
- package/dist/components/Drawer/Drawer.js +95 -82
- 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 +3 -1
- package/dist/components/Modal/Modal.const.js +12 -9
- package/dist/components/Modal/Modal.js +45 -41
- package/dist/components/Modal/Modal.types.d.ts +1 -0
- package/dist/components/ModalsProvider/ModalsContext.cjs +1 -0
- package/dist/components/ModalsProvider/ModalsContext.d.ts +2 -0
- package/dist/components/ModalsProvider/ModalsContext.js +5 -0
- package/dist/components/ModalsProvider/ModalsProvider.cjs +1 -0
- package/dist/components/ModalsProvider/ModalsProvider.const.cjs +1 -0
- package/dist/components/ModalsProvider/ModalsProvider.const.d.ts +39 -0
- package/dist/components/ModalsProvider/ModalsProvider.const.js +40 -0
- package/dist/components/ModalsProvider/ModalsProvider.d.ts +3 -0
- package/dist/components/ModalsProvider/ModalsProvider.js +97 -0
- package/dist/components/ModalsProvider/ModalsProvider.types.d.ts +75 -0
- package/dist/components/ModalsProvider/ModalsProvider.utils.cjs +1 -0
- package/dist/components/ModalsProvider/ModalsProvider.utils.d.ts +8 -0
- package/dist/components/ModalsProvider/ModalsProvider.utils.js +24 -0
- package/dist/components/ModalsProvider/components/ModalsHost/ModalsHost.cjs +1 -0
- package/dist/components/ModalsProvider/components/ModalsHost/ModalsHost.d.ts +2 -0
- package/dist/components/ModalsProvider/components/ModalsHost/ModalsHost.js +24 -0
- package/dist/components/ModalsProvider/components/ModalsHost/index.d.ts +1 -0
- package/dist/components/ModalsProvider/components/StackedModal/StackedModal.cjs +1 -0
- package/dist/components/ModalsProvider/components/StackedModal/StackedModal.d.ts +2 -0
- package/dist/components/ModalsProvider/components/StackedModal/StackedModal.js +66 -0
- package/dist/components/ModalsProvider/components/StackedModal/index.d.ts +1 -0
- package/dist/components/ModalsProvider/components/index.d.ts +2 -0
- package/dist/components/ModalsProvider/hooks/index.d.ts +1 -0
- package/dist/components/ModalsProvider/hooks/useModals.cjs +1 -0
- package/dist/components/ModalsProvider/hooks/useModals.d.ts +2 -0
- package/dist/components/ModalsProvider/hooks/useModals.js +12 -0
- package/dist/components/ModalsProvider/index.d.ts +3 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.const.cjs +1 -1
- package/dist/components/SignPad/SignPad.const.d.ts +13 -2
- package/dist/components/SignPad/SignPad.const.js +22 -13
- package/dist/components/SignPad/SignPad.js +127 -121
- package/dist/components/SignPad/SignPad.types.d.ts +2 -1
- package/dist/components/SignPad/SignPad.utils.cjs +1 -0
- package/dist/components/SignPad/SignPad.utils.d.ts +34 -0
- package/dist/components/SignPad/SignPad.utils.js +42 -0
- package/dist/components/Snackbar/Snackbar.cjs +1 -1
- package/dist/components/Snackbar/Snackbar.const.cjs +1 -1
- package/dist/components/Snackbar/Snackbar.const.d.ts +7 -1
- package/dist/components/Snackbar/Snackbar.const.js +21 -11
- package/dist/components/Snackbar/Snackbar.js +60 -59
- 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 +4 -1
- package/dist/components/Toast/Toast.const.js +20 -5
- package/dist/components/Toast/Toast.js +97 -110
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +389 -385
- package/dist/index.cjs +1 -1
- package/dist/index.js +504 -500
- package/dist/styles/_feedback.css +130 -0
- package/dist/styles/_overlays.css +24 -0
- package/dist/styles/main.css +2 -0
- package/dist/styles.css +165 -5
- package/package.json +1 -1
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { jsxs as n, Fragment as
|
|
2
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as n, Fragment as w, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { createPortal as z } from "react-dom";
|
|
3
3
|
import { cn as U } from "../../utils/cn.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import { resolveBearId as X } from "../../utils/generateBearId.utils.js";
|
|
6
6
|
import { useBearId as Z } from "../../utils/useBearId.js";
|
|
7
7
|
import { getBearLiveRegionProps as j } from "../../utils/liveRegion.utils.js";
|
|
8
|
-
import { Paper as
|
|
9
|
-
import { Flex as
|
|
10
|
-
import { Typography as
|
|
11
|
-
import { Progress as
|
|
8
|
+
import { Paper as G } from "../Paper/Paper.js";
|
|
9
|
+
import { Flex as m } from "../Flex/Flex.js";
|
|
10
|
+
import { Typography as g } from "../Typography/Typography.js";
|
|
11
|
+
import { Progress as H } from "../Progress/Progress.js";
|
|
12
12
|
import { CloseButton as M } from "../CloseButton/CloseButton.js";
|
|
13
|
-
import { SNACKBAR_DEFAULT_AUTO_HIDE_MS as V, SNACKBAR_DEFAULT_OFFSET_X as Y, SNACKBAR_DEFAULT_OFFSET_Y as q, SNACKBAR_BACKDROP_Z_INDEX as J,
|
|
14
|
-
import { useSnackbar as
|
|
15
|
-
const
|
|
16
|
-
const e = { zIndex:
|
|
13
|
+
import { SNACKBAR_DEFAULT_AUTO_HIDE_MS as V, SNACKBAR_DEFAULT_OFFSET_X as Y, SNACKBAR_DEFAULT_OFFSET_Y as q, SNACKBAR_BACKDROP_Z_INDEX as J, SNACKBAR_PAPER_BACKGROUND as Q, SNACKBAR_DESCRIPTION_COLOR as W, SNACKBAR_SIZE_PADDING as $, SNACKBAR_BORDER_CLASSES as ee, SNACKBAR_SURFACE_CLASSES as re, SNACKBAR_SEVERITY_MODIFIER as oe, SNACKBAR_ROOT_CLASS as ae, SNACKBAR_Z_INDEX as te } from "./Snackbar.const.js";
|
|
14
|
+
import { useSnackbar as se } from "./hooks/useSnackbar.js";
|
|
15
|
+
const ne = (i, o, a, t) => {
|
|
16
|
+
const e = { zIndex: te };
|
|
17
17
|
return i === "top" ? e.top = t : e.bottom = t, o === "left" ? (e.left = a, e.right = "auto") : o === "right" ? (e.right = a, e.left = "auto") : (e.left = "50%", e.right = "auto", e.transform = "translateX(-50%)"), e;
|
|
18
|
-
},
|
|
18
|
+
}, Ce = (i) => {
|
|
19
19
|
const {
|
|
20
20
|
open: o,
|
|
21
21
|
message: a,
|
|
22
22
|
description: t,
|
|
23
23
|
severity: e = "default",
|
|
24
|
-
action:
|
|
25
|
-
autoHideDuration:
|
|
24
|
+
action: d,
|
|
25
|
+
autoHideDuration: B = V,
|
|
26
26
|
onClose: l,
|
|
27
|
-
anchorOrigin:
|
|
28
|
-
offsetX:
|
|
27
|
+
anchorOrigin: _ = { vertical: "bottom", horizontal: "center" },
|
|
28
|
+
offsetX: C = Y,
|
|
29
29
|
offsetY: N = q,
|
|
30
|
-
size:
|
|
31
|
-
progress:
|
|
32
|
-
progressPosition:
|
|
33
|
-
progressColor:
|
|
34
|
-
countdownProgress:
|
|
35
|
-
showCloseButton:
|
|
36
|
-
closeOnClickOutside:
|
|
30
|
+
size: R = "md",
|
|
31
|
+
progress: h = null,
|
|
32
|
+
progressPosition: S = "bottom",
|
|
33
|
+
progressColor: O = "default",
|
|
34
|
+
countdownProgress: k = !1,
|
|
35
|
+
showCloseButton: E,
|
|
36
|
+
closeOnClickOutside: I,
|
|
37
37
|
container: D,
|
|
38
|
-
id:
|
|
39
|
-
testId:
|
|
40
|
-
className:
|
|
41
|
-
} = i,
|
|
38
|
+
id: v,
|
|
39
|
+
testId: K,
|
|
40
|
+
className: P
|
|
41
|
+
} = i, x = Z("Snackbar"), y = X(v, x), f = D ?? (typeof document < "u" ? document.body : null), s = !!l, F = E ?? s, p = I ?? s, { surfaceRef: T, progressValue: u } = se({
|
|
42
42
|
open: o,
|
|
43
|
-
autoHideDuration:
|
|
43
|
+
autoHideDuration: B,
|
|
44
44
|
onClose: l,
|
|
45
|
-
countdownProgress:
|
|
46
|
-
staticProgress:
|
|
47
|
-
closeOnClickOutside:
|
|
45
|
+
countdownProgress: k,
|
|
46
|
+
staticProgress: h,
|
|
47
|
+
closeOnClickOutside: p
|
|
48
48
|
});
|
|
49
|
-
if (!o || !
|
|
49
|
+
if (!o || !f)
|
|
50
50
|
return null;
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const A = j(e), c = typeof u == "number", b = c ? /* @__PURE__ */ r(
|
|
52
|
+
H,
|
|
53
53
|
{
|
|
54
|
-
value:
|
|
54
|
+
value: u,
|
|
55
55
|
size: "sm",
|
|
56
|
-
color:
|
|
56
|
+
color: O,
|
|
57
57
|
className: "Bear-Snackbar__progress"
|
|
58
58
|
}
|
|
59
|
-
) : null,
|
|
60
|
-
|
|
59
|
+
) : null, L = /* @__PURE__ */ n(w, { children: [
|
|
60
|
+
p && s && /* @__PURE__ */ r(
|
|
61
61
|
"div",
|
|
62
62
|
{
|
|
63
63
|
className: "Bear-Snackbar__backdrop bear-fixed bear-inset-0",
|
|
@@ -66,35 +66,36 @@ const oe = (i, o, a, t) => {
|
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
68
|
/* @__PURE__ */ n(
|
|
69
|
-
|
|
69
|
+
G,
|
|
70
70
|
{
|
|
71
71
|
ref: T,
|
|
72
|
-
id:
|
|
73
|
-
"data-testid":
|
|
74
|
-
role:
|
|
75
|
-
"aria-live":
|
|
72
|
+
id: y,
|
|
73
|
+
"data-testid": K,
|
|
74
|
+
role: A.role,
|
|
75
|
+
"aria-live": A["aria-live"],
|
|
76
76
|
elevation: 4,
|
|
77
77
|
rounded: "lg",
|
|
78
78
|
padding: "none",
|
|
79
|
-
background:
|
|
79
|
+
background: Q,
|
|
80
80
|
className: U(
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
ae,
|
|
82
|
+
oe[e],
|
|
83
|
+
re,
|
|
84
|
+
ee,
|
|
83
85
|
"bear-fixed bear-flex bear-flex-col bear-overflow-hidden",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
E
|
|
86
|
+
$[R],
|
|
87
|
+
P
|
|
87
88
|
),
|
|
88
|
-
style:
|
|
89
|
+
style: ne(_.vertical, _.horizontal, C, N),
|
|
89
90
|
children: [
|
|
90
|
-
c &&
|
|
91
|
-
/* @__PURE__ */ n(
|
|
92
|
-
/* @__PURE__ */ n(
|
|
93
|
-
a && /* @__PURE__ */ r(
|
|
94
|
-
t && /* @__PURE__ */ r(
|
|
91
|
+
c && S === "top" && b,
|
|
92
|
+
/* @__PURE__ */ n(m, { className: "Bear-Snackbar__content bear-w-full", align: "center", gap: 3, children: [
|
|
93
|
+
/* @__PURE__ */ n(m, { direction: "column", className: "Bear-Snackbar__text bear-flex-1 bear-min-w-0", gap: 1, children: [
|
|
94
|
+
a && /* @__PURE__ */ r(g, { variant: "body2", className: "Bear-Snackbar__message", children: a }),
|
|
95
|
+
t && /* @__PURE__ */ r(g, { variant: "caption", color: W, className: "Bear-Snackbar__description", children: t })
|
|
95
96
|
] }),
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
d && /* @__PURE__ */ r(m, { className: "Bear-Snackbar__action bear-shrink-0", align: "center", children: d }),
|
|
98
|
+
F && s && /* @__PURE__ */ r(
|
|
98
99
|
M,
|
|
99
100
|
{
|
|
100
101
|
size: "sm",
|
|
@@ -104,13 +105,13 @@ const oe = (i, o, a, t) => {
|
|
|
104
105
|
}
|
|
105
106
|
)
|
|
106
107
|
] }),
|
|
107
|
-
c &&
|
|
108
|
+
c && S === "bottom" && b
|
|
108
109
|
]
|
|
109
110
|
}
|
|
110
111
|
)
|
|
111
112
|
] });
|
|
112
|
-
return L
|
|
113
|
+
return z(L, f);
|
|
113
114
|
};
|
|
114
115
|
export {
|
|
115
|
-
|
|
116
|
+
Ce as Snackbar
|
|
116
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),x=require("./Toast.const.cjs"),I=require("../../utils/cn.cjs"),R=require("../../utils/generateBearId.utils.cjs"),A=require("../../utils/liveRegion.utils.cjs"),P={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"})]})},L=()=>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"})]}),M=x.TOAST_SEVERITY_MODIFIER,N=x.TOAST_POSITION_CLASSES,y=s.createContext(null),B=()=>{const l=s.useContext(y);if(!l)throw new Error("useToast must be used within a ToastProvider");return l},q=({id:l,testId:b,message:h,title:u,severity:a="info",duration:i=5e3,closable:n=!0,icon:o,action:f,onClose:c,onRemove:T,className:j,autoScroll:v=!1,pauseOnHover:_=!1})=>{const[m,t]=s.useState(!1),[r,d]=s.useState(!1),S=s.useRef(null),g=s.useRef(i),k=s.useRef(0);s.useEffect(()=>{v&&S.current&&S.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[v]),s.useEffect(()=>{if(i<=0||r)return;k.current=Date.now();const O=setTimeout(()=>{t(!0),setTimeout(()=>{T(),c==null||c()},x.TOAST_EXIT_MS)},g.current);return()=>{clearTimeout(O),g.current=Math.max(0,g.current-(Date.now()-k.current))}},[i,r,T,c]);const E=()=>{t(!0),setTimeout(()=>{T(),c==null||c()},x.TOAST_EXIT_MS)},w=()=>o===!1?null:o||P[a],p=A.getBearLiveRegionProps(a);return e.jsxs("div",{ref:S,id:l,"data-testid":b,...p,"aria-atomic":"true",onMouseEnter:_?()=>d(!0):void 0,onMouseLeave:_?()=>d(!1):void 0,className:I.cn(x.T_O_A_S_T_ROOT_CLASS,x.TOAST_ITEM_CLASSES,m?"bear-opacity-0 bear-translate-x-2":"bear-opacity-100 bear-translate-x-0",M[a],j),children:[w()&&e.jsx("span",{className:"bear-flex-shrink-0 bear-mt-0.5",children:w()}),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:h})]}),f&&e.jsx("div",{className:"bear-flex-shrink-0",children:f}),n&&e.jsx("button",{type:"button",onClick:E,className:"bear-flex-shrink-0 bear-p-1 bear-rounded hover:bear-bg-black/10 dark:hover:bear-bg-white/20 bear-transition-colors bear-bg-transparent bear-border-none bear-cursor-pointer","aria-label":"Close",children:e.jsx(L,{})})]})},C=({position:l="top-right",maxToasts:b=5,className:h})=>{const u=s.useContext(y);if(!u)return null;const{_toasts:a,_removeToast:i}=u,n=a.slice(0,b);return e.jsx("div",{className:I.cn(`${x.T_O_A_S_T_ROOT_CLASS}__container`,"bear-fixed bear-z-[11000] bear-flex bear-flex-col bear-gap-2",N[l],h),"aria-relevant":"additions",children:n.map(o=>e.jsx(q,{...o,onRemove:()=>i(o.id)},o.id))})},V=({children:l,position:b="top-right",maxToasts:h})=>{const[u,a]=s.useState([]),i=s.useCallback(t=>{a(r=>r.filter(d=>d.id!==t))},[]),n=s.useCallback(t=>{const r=t.id||R.generateBearId("Toast");return a(d=>[...d,{...t,id:r}]),r},[]),o=s.useCallback(t=>n(t),[n]),f=s.useCallback((t,r)=>n({message:t,severity:"success",...r}),[n]),c=s.useCallback((t,r)=>n({message:t,severity:"info",...r}),[n]),T=s.useCallback((t,r)=>n({message:t,severity:"warning",...r}),[n]),j=s.useCallback((t,r)=>n({message:t,severity:"error",...r}),[n]),v=s.useCallback(t=>i(t),[i]),_=s.useCallback(()=>a([]),[]),m={toast:o,success:f,info:c,warning:T,error:j,dismiss:v,dismissAll:_,_toasts:u,_removeToast:i};return e.jsxs(y.Provider,{value:m,children:[l,e.jsx(C,{position:b,maxToasts:h})]})};exports.ToastContainer=C;exports.ToastProvider=V;exports.useToast=B;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../utils/liveRegion.const.cjs"),e="Bear-Toast";r.BEAR_ARIA_LIVE_BY_SEVERITY.success,r.BEAR_ARIA_LIVE_BY_SEVERITY.info,r.BEAR_ARIA_LIVE_BY_SEVERITY.warning,r.BEAR_ARIA_LIVE_BY_SEVERITY.error;r.BEAR_ARIA_ROLE_BY_SEVERITY.success,r.BEAR_ARIA_ROLE_BY_SEVERITY.info,r.BEAR_ARIA_ROLE_BY_SEVERITY.warning,r.BEAR_ARIA_ROLE_BY_SEVERITY.error;const _=200,t={success:`${e}--success`,info:`${e}--info`,warning:`${e}--warning`,error:`${e}--error`},a={"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"},o="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";exports.TOAST_EXIT_MS=_;exports.TOAST_ITEM_CLASSES=o;exports.TOAST_POSITION_CLASSES=a;exports.TOAST_SEVERITY_MODIFIER=t;exports.T_O_A_S_T_ROOT_CLASS=e;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { ToastSeverity } from './Toast.types';
|
|
1
|
+
import { ToastSeverity, ToastPosition } from './Toast.types';
|
|
2
2
|
export declare const T_O_A_S_T_ROOT_CLASS = "Bear-Toast";
|
|
3
3
|
export declare const TOAST_ARIA_LIVE: Record<ToastSeverity, 'polite' | 'assertive'>;
|
|
4
4
|
export declare const TOAST_ARIA_ROLE: Record<ToastSeverity, 'status' | 'alert'>;
|
|
5
5
|
export declare const TOAST_EXIT_MS = 200;
|
|
6
|
+
export declare const TOAST_SEVERITY_MODIFIER: Record<ToastSeverity, string>;
|
|
7
|
+
export declare const TOAST_POSITION_CLASSES: Record<ToastPosition, string>;
|
|
8
|
+
export declare const TOAST_ITEM_CLASSES = "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";
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import { BEAR_ARIA_LIVE_BY_SEVERITY as r, BEAR_ARIA_ROLE_BY_SEVERITY as
|
|
2
|
-
const
|
|
1
|
+
import { BEAR_ARIA_LIVE_BY_SEVERITY as r, BEAR_ARIA_ROLE_BY_SEVERITY as e } from "../../utils/liveRegion.const.js";
|
|
2
|
+
const t = "Bear-Toast";
|
|
3
3
|
r.success, r.info, r.warning, r.error;
|
|
4
|
-
|
|
5
|
-
const o = 200
|
|
4
|
+
e.success, e.info, e.warning, e.error;
|
|
5
|
+
const o = 200, n = {
|
|
6
|
+
success: `${t}--success`,
|
|
7
|
+
info: `${t}--info`,
|
|
8
|
+
warning: `${t}--warning`,
|
|
9
|
+
error: `${t}--error`
|
|
10
|
+
}, b = {
|
|
11
|
+
"top-left": "bear-top-4 bear-left-4",
|
|
12
|
+
"top-center": "bear-top-4 bear-left-1/2 bear-transform bear--translate-x-1/2",
|
|
13
|
+
"top-right": "bear-top-4 bear-right-4",
|
|
14
|
+
"bottom-left": "bear-bottom-4 bear-left-4",
|
|
15
|
+
"bottom-center": "bear-bottom-4 bear-left-1/2 bear-transform bear--translate-x-1/2",
|
|
16
|
+
"bottom-right": "bear-bottom-4 bear-right-4"
|
|
17
|
+
}, s = "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";
|
|
6
18
|
export {
|
|
7
19
|
o as TOAST_EXIT_MS,
|
|
8
|
-
|
|
20
|
+
s as TOAST_ITEM_CLASSES,
|
|
21
|
+
b as TOAST_POSITION_CLASSES,
|
|
22
|
+
n as TOAST_SEVERITY_MODIFIER,
|
|
23
|
+
t as T_O_A_S_T_ROOT_CLASS
|
|
9
24
|
};
|
|
@@ -1,179 +1,166 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { T_O_A_S_T_ROOT_CLASS as L, TOAST_EXIT_MS as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { generateBearId as
|
|
6
|
-
import { getBearLiveRegionProps as
|
|
7
|
-
const
|
|
8
|
-
success: /* @__PURE__ */
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as C, useContext as N, useState as w, useCallback as c, useRef as _, useEffect as O } from "react";
|
|
3
|
+
import { TOAST_POSITION_CLASSES as V, T_O_A_S_T_ROOT_CLASS as L, TOAST_EXIT_MS as A, TOAST_SEVERITY_MODIFIER as W, TOAST_ITEM_CLASSES as Y } from "./Toast.const.js";
|
|
4
|
+
import { cn as P } from "../../utils/cn.js";
|
|
5
|
+
import { generateBearId as D } from "../../utils/generateBearId.utils.js";
|
|
6
|
+
import { getBearLiveRegionProps as j } from "../../utils/liveRegion.utils.js";
|
|
7
|
+
const z = {
|
|
8
|
+
success: /* @__PURE__ */ d("svg", { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
|
|
9
9
|
/* @__PURE__ */ e("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
10
10
|
/* @__PURE__ */ e("polyline", { points: "22 4 12 14.01 9 11.01" })
|
|
11
11
|
] }),
|
|
12
|
-
info: /* @__PURE__ */
|
|
12
|
+
info: /* @__PURE__ */ d("svg", { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
|
|
13
13
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
14
14
|
/* @__PURE__ */ e("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
|
|
15
15
|
/* @__PURE__ */ e("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
16
16
|
] }),
|
|
17
|
-
warning: /* @__PURE__ */
|
|
17
|
+
warning: /* @__PURE__ */ d("svg", { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
|
|
18
18
|
/* @__PURE__ */ e("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" }),
|
|
19
19
|
/* @__PURE__ */ e("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
|
|
20
20
|
/* @__PURE__ */ e("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
21
21
|
] }),
|
|
22
|
-
error: /* @__PURE__ */
|
|
22
|
+
error: /* @__PURE__ */ d("svg", { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
|
|
23
23
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
24
24
|
/* @__PURE__ */ e("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
25
25
|
/* @__PURE__ */ e("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
26
26
|
] })
|
|
27
|
-
},
|
|
27
|
+
}, F = () => /* @__PURE__ */ d("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
|
|
28
28
|
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
29
29
|
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
30
|
-
] }),
|
|
31
|
-
|
|
32
|
-
info: "bear-bg-blue-500 bear-text-white",
|
|
33
|
-
warning: "bear-bg-amber-500 bear-text-white",
|
|
34
|
-
error: "bear-bg-red-500 bear-text-white"
|
|
35
|
-
}, D = {
|
|
36
|
-
"top-left": "bear-top-4 bear-left-4",
|
|
37
|
-
"top-center": "bear-top-4 bear-left-1/2 bear-transform bear--translate-x-1/2",
|
|
38
|
-
"top-right": "bear-top-4 bear-right-4",
|
|
39
|
-
"bottom-left": "bear-bottom-4 bear-left-4",
|
|
40
|
-
"bottom-center": "bear-bottom-4 bear-left-1/2 bear-transform bear--translate-x-1/2",
|
|
41
|
-
"bottom-right": "bear-bottom-4 bear-right-4"
|
|
42
|
-
}, I = O(null), U = () => {
|
|
43
|
-
const l = B(I);
|
|
30
|
+
] }), X = W, $ = V, k = C(null), ee = () => {
|
|
31
|
+
const l = N(k);
|
|
44
32
|
if (!l)
|
|
45
33
|
throw new Error("useToast must be used within a ToastProvider");
|
|
46
34
|
return l;
|
|
47
|
-
},
|
|
35
|
+
}, q = ({
|
|
48
36
|
id: l,
|
|
49
|
-
testId:
|
|
50
|
-
message:
|
|
51
|
-
title:
|
|
52
|
-
severity:
|
|
53
|
-
duration:
|
|
54
|
-
closable:
|
|
55
|
-
icon:
|
|
37
|
+
testId: x,
|
|
38
|
+
message: f,
|
|
39
|
+
title: u,
|
|
40
|
+
severity: n = "info",
|
|
41
|
+
duration: o = 5e3,
|
|
42
|
+
closable: s = !0,
|
|
43
|
+
icon: i,
|
|
56
44
|
action: m,
|
|
57
|
-
onClose:
|
|
58
|
-
onRemove:
|
|
59
|
-
className:
|
|
60
|
-
autoScroll:
|
|
61
|
-
pauseOnHover:
|
|
45
|
+
onClose: a,
|
|
46
|
+
onRemove: b,
|
|
47
|
+
className: g,
|
|
48
|
+
autoScroll: T = !1,
|
|
49
|
+
pauseOnHover: v = !1
|
|
62
50
|
}) => {
|
|
63
|
-
const [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const
|
|
51
|
+
const [y, t] = w(!1), [r, h] = w(!1), p = _(null), S = _(o), I = _(0);
|
|
52
|
+
O(() => {
|
|
53
|
+
T && p.current && p.current.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
54
|
+
}, [T]), O(() => {
|
|
55
|
+
if (o <= 0 || r) return;
|
|
56
|
+
I.current = Date.now();
|
|
57
|
+
const B = setTimeout(() => {
|
|
70
58
|
t(!0), setTimeout(() => {
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
},
|
|
59
|
+
b(), a == null || a();
|
|
60
|
+
}, A);
|
|
61
|
+
}, S.current);
|
|
74
62
|
return () => {
|
|
75
|
-
clearTimeout(
|
|
63
|
+
clearTimeout(B), S.current = Math.max(0, S.current - (Date.now() - I.current));
|
|
76
64
|
};
|
|
77
|
-
}, [
|
|
78
|
-
const
|
|
65
|
+
}, [o, r, b, a]);
|
|
66
|
+
const R = () => {
|
|
79
67
|
t(!0), setTimeout(() => {
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
}, E = () =>
|
|
83
|
-
return /* @__PURE__ */
|
|
68
|
+
b(), a == null || a();
|
|
69
|
+
}, A);
|
|
70
|
+
}, E = () => i === !1 ? null : i || z[n], M = j(n);
|
|
71
|
+
return /* @__PURE__ */ d(
|
|
84
72
|
"div",
|
|
85
73
|
{
|
|
86
|
-
ref:
|
|
74
|
+
ref: p,
|
|
87
75
|
id: l,
|
|
88
|
-
"data-testid":
|
|
89
|
-
...
|
|
76
|
+
"data-testid": x,
|
|
77
|
+
...M,
|
|
90
78
|
"aria-atomic": "true",
|
|
91
|
-
onMouseEnter:
|
|
92
|
-
onMouseLeave:
|
|
93
|
-
className:
|
|
79
|
+
onMouseEnter: v ? () => h(!0) : void 0,
|
|
80
|
+
onMouseLeave: v ? () => h(!1) : void 0,
|
|
81
|
+
className: P(
|
|
94
82
|
L,
|
|
95
|
-
|
|
96
|
-
"bear-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
v
|
|
83
|
+
Y,
|
|
84
|
+
y ? "bear-opacity-0 bear-translate-x-2" : "bear-opacity-100 bear-translate-x-0",
|
|
85
|
+
X[n],
|
|
86
|
+
g
|
|
100
87
|
),
|
|
101
88
|
children: [
|
|
102
89
|
E() && /* @__PURE__ */ e("span", { className: "bear-flex-shrink-0 bear-mt-0.5", children: E() }),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
|
|
105
|
-
/* @__PURE__ */ e("div", { className: "bear-text-sm bear-opacity-90", children:
|
|
90
|
+
/* @__PURE__ */ d("div", { className: "bear-flex-1 bear-min-w-0", children: [
|
|
91
|
+
u && /* @__PURE__ */ e("div", { className: "bear-font-semibold bear-mb-0.5", children: u }),
|
|
92
|
+
/* @__PURE__ */ e("div", { className: "bear-text-sm bear-opacity-90", children: f })
|
|
106
93
|
] }),
|
|
107
94
|
m && /* @__PURE__ */ e("div", { className: "bear-flex-shrink-0", children: m }),
|
|
108
|
-
|
|
95
|
+
s && /* @__PURE__ */ e(
|
|
109
96
|
"button",
|
|
110
97
|
{
|
|
111
98
|
type: "button",
|
|
112
|
-
onClick:
|
|
113
|
-
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",
|
|
99
|
+
onClick: R,
|
|
100
|
+
className: "bear-flex-shrink-0 bear-p-1 bear-rounded hover:bear-bg-black/10 dark:hover:bear-bg-white/20 bear-transition-colors bear-bg-transparent bear-border-none bear-cursor-pointer",
|
|
114
101
|
"aria-label": "Close",
|
|
115
|
-
children: /* @__PURE__ */ e(
|
|
102
|
+
children: /* @__PURE__ */ e(F, {})
|
|
116
103
|
}
|
|
117
104
|
)
|
|
118
105
|
]
|
|
119
106
|
}
|
|
120
107
|
);
|
|
121
|
-
},
|
|
108
|
+
}, G = ({
|
|
122
109
|
position: l = "top-right",
|
|
123
|
-
maxToasts:
|
|
124
|
-
className:
|
|
110
|
+
maxToasts: x = 5,
|
|
111
|
+
className: f
|
|
125
112
|
}) => {
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
const { _toasts:
|
|
113
|
+
const u = N(k);
|
|
114
|
+
if (!u) return null;
|
|
115
|
+
const { _toasts: n, _removeToast: o } = u, s = n.slice(0, x);
|
|
129
116
|
return /* @__PURE__ */ e(
|
|
130
117
|
"div",
|
|
131
118
|
{
|
|
132
|
-
className:
|
|
119
|
+
className: P(
|
|
133
120
|
`${L}__container`,
|
|
134
121
|
"bear-fixed bear-z-[11000] bear-flex bear-flex-col bear-gap-2",
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
$[l],
|
|
123
|
+
f
|
|
137
124
|
),
|
|
138
125
|
"aria-relevant": "additions",
|
|
139
|
-
children:
|
|
140
|
-
|
|
126
|
+
children: s.map((i) => /* @__PURE__ */ e(
|
|
127
|
+
q,
|
|
141
128
|
{
|
|
142
|
-
...
|
|
143
|
-
onRemove: () =>
|
|
129
|
+
...i,
|
|
130
|
+
onRemove: () => o(i.id)
|
|
144
131
|
},
|
|
145
|
-
|
|
132
|
+
i.id
|
|
146
133
|
))
|
|
147
134
|
}
|
|
148
135
|
);
|
|
149
|
-
},
|
|
136
|
+
}, te = ({
|
|
150
137
|
children: l,
|
|
151
|
-
position:
|
|
152
|
-
maxToasts:
|
|
138
|
+
position: x = "top-right",
|
|
139
|
+
maxToasts: f
|
|
153
140
|
}) => {
|
|
154
|
-
const [
|
|
155
|
-
|
|
156
|
-
}, []),
|
|
157
|
-
const r = t.id ||
|
|
158
|
-
return
|
|
159
|
-
}, []),
|
|
160
|
-
toast:
|
|
141
|
+
const [u, n] = w([]), o = c((t) => {
|
|
142
|
+
n((r) => r.filter((h) => h.id !== t));
|
|
143
|
+
}, []), s = c((t) => {
|
|
144
|
+
const r = t.id || D("Toast");
|
|
145
|
+
return n((h) => [...h, { ...t, id: r }]), r;
|
|
146
|
+
}, []), i = c((t) => s(t), [s]), m = c((t, r) => s({ message: t, severity: "success", ...r }), [s]), a = c((t, r) => s({ message: t, severity: "info", ...r }), [s]), b = c((t, r) => s({ message: t, severity: "warning", ...r }), [s]), g = c((t, r) => s({ message: t, severity: "error", ...r }), [s]), T = c((t) => o(t), [o]), v = c(() => n([]), []), y = {
|
|
147
|
+
toast: i,
|
|
161
148
|
success: m,
|
|
162
|
-
info:
|
|
163
|
-
warning:
|
|
164
|
-
error:
|
|
165
|
-
dismiss:
|
|
166
|
-
dismissAll:
|
|
167
|
-
_toasts:
|
|
168
|
-
_removeToast:
|
|
149
|
+
info: a,
|
|
150
|
+
warning: b,
|
|
151
|
+
error: g,
|
|
152
|
+
dismiss: T,
|
|
153
|
+
dismissAll: v,
|
|
154
|
+
_toasts: u,
|
|
155
|
+
_removeToast: o
|
|
169
156
|
};
|
|
170
|
-
return /* @__PURE__ */
|
|
157
|
+
return /* @__PURE__ */ d(k.Provider, { value: y, children: [
|
|
171
158
|
l,
|
|
172
|
-
/* @__PURE__ */ e(
|
|
159
|
+
/* @__PURE__ */ e(G, { position: x, maxToasts: f })
|
|
173
160
|
] });
|
|
174
161
|
};
|
|
175
162
|
export {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
163
|
+
G as ToastContainer,
|
|
164
|
+
te as ToastProvider,
|
|
165
|
+
ee as useToast
|
|
179
166
|
};
|