@motech-development/breeze-ui 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs.js +49 -58
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +49 -58
- package/lib/index.esm.js.map +1 -1
- package/package.json +5 -5
package/lib/index.cjs.js
CHANGED
|
@@ -1971,49 +1971,21 @@ const ModalDialog = styled__default.default.div`
|
|
|
1971
1971
|
position: relative;
|
|
1972
1972
|
`;
|
|
1973
1973
|
const Modal = ({ children, isOpen, onDismiss, size = 'sm', title })=>{
|
|
1974
|
-
const output = document.createElement('div');
|
|
1975
1974
|
const doNotDismiss = (e)=>{
|
|
1976
1975
|
e.stopPropagation();
|
|
1977
1976
|
};
|
|
1978
|
-
const modal = /*#__PURE__*/ jsxRuntime.jsxs(react.Suspense, {
|
|
1979
|
-
fallback: /*#__PURE__*/ jsxRuntime.jsx(Loader, {}),
|
|
1980
|
-
children: [
|
|
1981
|
-
/*#__PURE__*/ jsxRuntime.jsx(ModalOuter, {
|
|
1982
|
-
"aria-modal": true,
|
|
1983
|
-
"aria-label": title,
|
|
1984
|
-
role: "dialog",
|
|
1985
|
-
tabIndex: -1,
|
|
1986
|
-
onClick: onDismiss,
|
|
1987
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(ModalDialog, {
|
|
1988
|
-
size: size,
|
|
1989
|
-
role: "document",
|
|
1990
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(ModalContent, {
|
|
1991
|
-
onClick: doNotDismiss,
|
|
1992
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Card, {
|
|
1993
|
-
padding: "lg",
|
|
1994
|
-
children: children
|
|
1995
|
-
})
|
|
1996
|
-
})
|
|
1997
|
-
})
|
|
1998
|
-
}),
|
|
1999
|
-
/*#__PURE__*/ jsxRuntime.jsx(Overlay, {})
|
|
2000
|
-
]
|
|
2001
|
-
});
|
|
2002
1977
|
react.useEffect(()=>{
|
|
2003
1978
|
const keyboardEvent = (e)=>{
|
|
2004
1979
|
if (e.key === 'Escape') {
|
|
2005
1980
|
onDismiss();
|
|
2006
1981
|
}
|
|
2007
1982
|
};
|
|
2008
|
-
document.body.appendChild(output);
|
|
2009
1983
|
document.addEventListener('keydown', keyboardEvent, false);
|
|
2010
1984
|
return ()=>{
|
|
2011
|
-
document.body.removeChild(output);
|
|
2012
1985
|
document.body.style.removeProperty('overflow');
|
|
2013
1986
|
document.removeEventListener('keydown', keyboardEvent, false);
|
|
2014
1987
|
};
|
|
2015
1988
|
}, [
|
|
2016
|
-
output,
|
|
2017
1989
|
onDismiss
|
|
2018
1990
|
]);
|
|
2019
1991
|
react.useEffect(()=>{
|
|
@@ -2024,7 +1996,30 @@ const Modal = ({ children, isOpen, onDismiss, size = 'sm', title })=>{
|
|
|
2024
1996
|
isOpen
|
|
2025
1997
|
]);
|
|
2026
1998
|
if (isOpen) {
|
|
2027
|
-
return /*#__PURE__*/ reactDom.createPortal(
|
|
1999
|
+
return /*#__PURE__*/ reactDom.createPortal(/*#__PURE__*/ jsxRuntime.jsxs(react.Suspense, {
|
|
2000
|
+
fallback: /*#__PURE__*/ jsxRuntime.jsx(Loader, {}),
|
|
2001
|
+
children: [
|
|
2002
|
+
/*#__PURE__*/ jsxRuntime.jsx(ModalOuter, {
|
|
2003
|
+
"aria-modal": true,
|
|
2004
|
+
"aria-label": title,
|
|
2005
|
+
role: "dialog",
|
|
2006
|
+
tabIndex: -1,
|
|
2007
|
+
onClick: onDismiss,
|
|
2008
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ModalDialog, {
|
|
2009
|
+
size: size,
|
|
2010
|
+
role: "document",
|
|
2011
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ModalContent, {
|
|
2012
|
+
onClick: doNotDismiss,
|
|
2013
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Card, {
|
|
2014
|
+
padding: "lg",
|
|
2015
|
+
children: children
|
|
2016
|
+
})
|
|
2017
|
+
})
|
|
2018
|
+
})
|
|
2019
|
+
}),
|
|
2020
|
+
/*#__PURE__*/ jsxRuntime.jsx(Overlay, {})
|
|
2021
|
+
]
|
|
2022
|
+
}), document.body);
|
|
2028
2023
|
}
|
|
2029
2024
|
return null;
|
|
2030
2025
|
};
|
|
@@ -2711,7 +2706,6 @@ const selectIcon = (alertType)=>{
|
|
|
2711
2706
|
}
|
|
2712
2707
|
};
|
|
2713
2708
|
const ToastProvider = ({ children })=>{
|
|
2714
|
-
const output = document.createElement('div');
|
|
2715
2709
|
const [toasts, setToasts] = react.useState([]);
|
|
2716
2710
|
const add = react.useCallback(({ colour, message, onDismiss })=>{
|
|
2717
2711
|
const id = generateId();
|
|
@@ -2727,34 +2721,18 @@ const ToastProvider = ({ children })=>{
|
|
|
2727
2721
|
}, [
|
|
2728
2722
|
toasts
|
|
2729
2723
|
]);
|
|
2730
|
-
const remove = react.useCallback((id)=>
|
|
2731
|
-
|
|
2732
|
-
|
|
2724
|
+
const remove = react.useCallback((id)=>{
|
|
2725
|
+
setToasts((value)=>{
|
|
2726
|
+
const item = value.findIndex((t)=>t.id === id);
|
|
2727
|
+
if (value[item]?.onDismiss) {
|
|
2728
|
+
value[item].onDismiss();
|
|
2733
2729
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
spacing: "lg",
|
|
2741
|
-
dismissable: 5000,
|
|
2742
|
-
icon: /*#__PURE__*/ jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, {
|
|
2743
|
-
icon: selectIcon(colour)
|
|
2744
|
-
}),
|
|
2745
|
-
colour: colour,
|
|
2746
|
-
message: message,
|
|
2747
|
-
onDismiss: ()=>remove(id)
|
|
2748
|
-
}, id))
|
|
2749
|
-
});
|
|
2750
|
-
react.useEffect(()=>{
|
|
2751
|
-
document.body.appendChild(output);
|
|
2752
|
-
return ()=>{
|
|
2753
|
-
document.body.removeChild(output);
|
|
2754
|
-
};
|
|
2755
|
-
}, [
|
|
2756
|
-
output
|
|
2757
|
-
]);
|
|
2730
|
+
if (item !== -1) {
|
|
2731
|
+
value.splice(item, 1);
|
|
2732
|
+
}
|
|
2733
|
+
return value;
|
|
2734
|
+
});
|
|
2735
|
+
}, []);
|
|
2758
2736
|
const value = react.useMemo(()=>({
|
|
2759
2737
|
add,
|
|
2760
2738
|
remove
|
|
@@ -2766,7 +2744,20 @@ const ToastProvider = ({ children })=>{
|
|
|
2766
2744
|
value: value,
|
|
2767
2745
|
children: [
|
|
2768
2746
|
children,
|
|
2769
|
-
/*#__PURE__*/ reactDom.createPortal(
|
|
2747
|
+
/*#__PURE__*/ reactDom.createPortal(/*#__PURE__*/ jsxRuntime.jsx(ToastContainer, {
|
|
2748
|
+
children: toasts.map(({ colour, id, message })=>/*#__PURE__*/ jsxRuntime.jsx(Alert, {
|
|
2749
|
+
spacing: "lg",
|
|
2750
|
+
dismissable: 5000,
|
|
2751
|
+
icon: /*#__PURE__*/ jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, {
|
|
2752
|
+
icon: selectIcon(colour)
|
|
2753
|
+
}),
|
|
2754
|
+
colour: colour,
|
|
2755
|
+
message: message,
|
|
2756
|
+
onDismiss: ()=>{
|
|
2757
|
+
remove(id);
|
|
2758
|
+
}
|
|
2759
|
+
}, id))
|
|
2760
|
+
}), document.body)
|
|
2770
2761
|
]
|
|
2771
2762
|
});
|
|
2772
2763
|
};
|