@motech-development/breeze-ui 2.0.34 → 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 +54 -60
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.esm.js +54 -60
- package/lib/index.esm.js.map +1 -1
- package/package.json +16 -16
package/lib/index.cjs.js
CHANGED
|
@@ -1961,56 +1961,31 @@ const ModalContent = styled__default.default.div`
|
|
|
1961
1961
|
pointer-events: auto;
|
|
1962
1962
|
`;
|
|
1963
1963
|
const ModalDialog = styled__default.default.div`
|
|
1964
|
-
box-shadow:
|
|
1964
|
+
box-shadow:
|
|
1965
|
+
0 3px 5px -1px rgba(0, 0, 0, 0.2),
|
|
1966
|
+
0 5px 8px 0 rgba(0, 0, 0, 0.14),
|
|
1965
1967
|
0 1px 14px 0 rgba(0, 0, 0, 0.12);
|
|
1966
1968
|
margin: 5rem auto;
|
|
1967
|
-
max-width: 500px;
|
|
1969
|
+
max-width: ${({ size })=>size === 'sm' ? '500px' : '90vw'};
|
|
1968
1970
|
pointer-events: none;
|
|
1969
1971
|
position: relative;
|
|
1970
1972
|
`;
|
|
1971
|
-
const Modal = ({ children, isOpen, onDismiss, title })=>{
|
|
1972
|
-
const output = document.createElement('div');
|
|
1973
|
+
const Modal = ({ children, isOpen, onDismiss, size = 'sm', title })=>{
|
|
1973
1974
|
const doNotDismiss = (e)=>{
|
|
1974
1975
|
e.stopPropagation();
|
|
1975
1976
|
};
|
|
1976
|
-
const modal = /*#__PURE__*/ jsxRuntime.jsxs(react.Suspense, {
|
|
1977
|
-
fallback: /*#__PURE__*/ jsxRuntime.jsx(Loader, {}),
|
|
1978
|
-
children: [
|
|
1979
|
-
/*#__PURE__*/ jsxRuntime.jsx(ModalOuter, {
|
|
1980
|
-
"aria-modal": true,
|
|
1981
|
-
"aria-label": title,
|
|
1982
|
-
role: "dialog",
|
|
1983
|
-
tabIndex: -1,
|
|
1984
|
-
onClick: onDismiss,
|
|
1985
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(ModalDialog, {
|
|
1986
|
-
role: "document",
|
|
1987
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(ModalContent, {
|
|
1988
|
-
onClick: doNotDismiss,
|
|
1989
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(Card, {
|
|
1990
|
-
padding: "lg",
|
|
1991
|
-
children: children
|
|
1992
|
-
})
|
|
1993
|
-
})
|
|
1994
|
-
})
|
|
1995
|
-
}),
|
|
1996
|
-
/*#__PURE__*/ jsxRuntime.jsx(Overlay, {})
|
|
1997
|
-
]
|
|
1998
|
-
});
|
|
1999
1977
|
react.useEffect(()=>{
|
|
2000
1978
|
const keyboardEvent = (e)=>{
|
|
2001
1979
|
if (e.key === 'Escape') {
|
|
2002
1980
|
onDismiss();
|
|
2003
1981
|
}
|
|
2004
1982
|
};
|
|
2005
|
-
document.body.appendChild(output);
|
|
2006
1983
|
document.addEventListener('keydown', keyboardEvent, false);
|
|
2007
1984
|
return ()=>{
|
|
2008
|
-
document.body.removeChild(output);
|
|
2009
1985
|
document.body.style.removeProperty('overflow');
|
|
2010
1986
|
document.removeEventListener('keydown', keyboardEvent, false);
|
|
2011
1987
|
};
|
|
2012
1988
|
}, [
|
|
2013
|
-
output,
|
|
2014
1989
|
onDismiss
|
|
2015
1990
|
]);
|
|
2016
1991
|
react.useEffect(()=>{
|
|
@@ -2021,7 +1996,30 @@ const Modal = ({ children, isOpen, onDismiss, title })=>{
|
|
|
2021
1996
|
isOpen
|
|
2022
1997
|
]);
|
|
2023
1998
|
if (isOpen) {
|
|
2024
|
-
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);
|
|
2025
2023
|
}
|
|
2026
2024
|
return null;
|
|
2027
2025
|
};
|
|
@@ -2708,7 +2706,6 @@ const selectIcon = (alertType)=>{
|
|
|
2708
2706
|
}
|
|
2709
2707
|
};
|
|
2710
2708
|
const ToastProvider = ({ children })=>{
|
|
2711
|
-
const output = document.createElement('div');
|
|
2712
2709
|
const [toasts, setToasts] = react.useState([]);
|
|
2713
2710
|
const add = react.useCallback(({ colour, message, onDismiss })=>{
|
|
2714
2711
|
const id = generateId();
|
|
@@ -2724,34 +2721,18 @@ const ToastProvider = ({ children })=>{
|
|
|
2724
2721
|
}, [
|
|
2725
2722
|
toasts
|
|
2726
2723
|
]);
|
|
2727
|
-
const remove = react.useCallback((id)=>
|
|
2728
|
-
|
|
2729
|
-
|
|
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();
|
|
2730
2729
|
}
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
spacing: "lg",
|
|
2738
|
-
dismissable: 5000,
|
|
2739
|
-
icon: /*#__PURE__*/ jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, {
|
|
2740
|
-
icon: selectIcon(colour)
|
|
2741
|
-
}),
|
|
2742
|
-
colour: colour,
|
|
2743
|
-
message: message,
|
|
2744
|
-
onDismiss: ()=>remove(id)
|
|
2745
|
-
}, id))
|
|
2746
|
-
});
|
|
2747
|
-
react.useEffect(()=>{
|
|
2748
|
-
document.body.appendChild(output);
|
|
2749
|
-
return ()=>{
|
|
2750
|
-
document.body.removeChild(output);
|
|
2751
|
-
};
|
|
2752
|
-
}, [
|
|
2753
|
-
output
|
|
2754
|
-
]);
|
|
2730
|
+
if (item !== -1) {
|
|
2731
|
+
value.splice(item, 1);
|
|
2732
|
+
}
|
|
2733
|
+
return value;
|
|
2734
|
+
});
|
|
2735
|
+
}, []);
|
|
2755
2736
|
const value = react.useMemo(()=>({
|
|
2756
2737
|
add,
|
|
2757
2738
|
remove
|
|
@@ -2763,7 +2744,20 @@ const ToastProvider = ({ children })=>{
|
|
|
2763
2744
|
value: value,
|
|
2764
2745
|
children: [
|
|
2765
2746
|
children,
|
|
2766
|
-
/*#__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)
|
|
2767
2761
|
]
|
|
2768
2762
|
});
|
|
2769
2763
|
};
|