@unicef/material-ui 0.11.2 → 0.11.3
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/dev.js +65 -31
- package/lib/dev.js.map +1 -1
- package/lib/prod.js +65 -31
- package/lib/prod.js.map +1 -1
- package/package.json +1 -1
package/lib/prod.js
CHANGED
|
@@ -42684,12 +42684,17 @@ var useStyles$n = makeStyles$1(function (theme) {
|
|
|
42684
42684
|
};
|
|
42685
42685
|
});
|
|
42686
42686
|
|
|
42687
|
-
|
|
42688
|
-
|
|
42689
|
-
|
|
42690
|
-
|
|
42691
|
-
|
|
42692
|
-
|
|
42687
|
+
var CONTROL_VARIANTS = {
|
|
42688
|
+
popup: 'popup',
|
|
42689
|
+
menuItem: 'menuItem',
|
|
42690
|
+
icon: 'icon'
|
|
42691
|
+
|
|
42692
|
+
/**
|
|
42693
|
+
* UConfirmationButton is a component to get confirmation from the user before processing it.
|
|
42694
|
+
* This button displays the confirmation where user has clicked the button
|
|
42695
|
+
* It has two varint icon/menu item
|
|
42696
|
+
*/
|
|
42697
|
+
};function UConfirmationButton(props) {
|
|
42693
42698
|
var classes = useStyles$n();
|
|
42694
42699
|
var onConfirm = props.onConfirm,
|
|
42695
42700
|
id = props.id,
|
|
@@ -42699,32 +42704,41 @@ function UConfirmationButton(props) {
|
|
|
42699
42704
|
icon = props.icon,
|
|
42700
42705
|
confirmText = props.confirmText,
|
|
42701
42706
|
confirmActionText = props.confirmActionText,
|
|
42702
|
-
|
|
42707
|
+
cancelText = props.cancelText;
|
|
42703
42708
|
|
|
42704
42709
|
var _useState = React.useState(null),
|
|
42705
42710
|
_useState2 = slicedToArray(_useState, 2),
|
|
42706
42711
|
deleteAnchorEl = _useState2[0],
|
|
42707
42712
|
setDeleteAnchorEl = _useState2[1];
|
|
42708
42713
|
|
|
42714
|
+
var _useState3 = React.useState(false),
|
|
42715
|
+
_useState4 = slicedToArray(_useState3, 2),
|
|
42716
|
+
openDialog = _useState4[0],
|
|
42717
|
+
setOpenDialog = _useState4[1];
|
|
42718
|
+
|
|
42709
42719
|
var handleConfirm = function handleConfirm(e) {
|
|
42710
|
-
onConfirm(e, id);
|
|
42711
|
-
handleDeleteOptionClicked();
|
|
42720
|
+
onConfirm && onConfirm(e, id);
|
|
42721
|
+
if (variant !== CONTROL_VARIANTS.popup) handleDeleteOptionClicked();
|
|
42712
42722
|
};
|
|
42713
42723
|
|
|
42714
42724
|
var handleDeleteOptionClicked = function handleDeleteOptionClicked(e) {
|
|
42715
42725
|
setDeleteAnchorEl(null);
|
|
42716
42726
|
};
|
|
42727
|
+
|
|
42728
|
+
var handleClick = function handleClick(e) {
|
|
42729
|
+
if (variant !== CONTROL_VARIANTS.popup) setDeleteAnchorEl(e.currentTarget);else setOpenDialog(true);
|
|
42730
|
+
};
|
|
42731
|
+
|
|
42732
|
+
var handleCancelPopup = function handleCancelPopup(e) {
|
|
42733
|
+
setOpenDialog(false);
|
|
42734
|
+
};
|
|
42735
|
+
|
|
42717
42736
|
return React__default.createElement(
|
|
42718
42737
|
React__default.Fragment,
|
|
42719
42738
|
null,
|
|
42720
|
-
variant ===
|
|
42739
|
+
variant === CONTROL_VARIANTS.menuItem ? React__default.createElement(
|
|
42721
42740
|
MenuItem$1,
|
|
42722
|
-
{
|
|
42723
|
-
onClick: function onClick(e) {
|
|
42724
|
-
return setDeleteAnchorEl(e.currentTarget);
|
|
42725
|
-
},
|
|
42726
|
-
className: classes.menuLabel
|
|
42727
|
-
},
|
|
42741
|
+
{ onClick: handleClick, className: classes.menuLabel },
|
|
42728
42742
|
icon,
|
|
42729
42743
|
React__default.createElement(
|
|
42730
42744
|
'span',
|
|
@@ -42739,16 +42753,40 @@ function UConfirmationButton(props) {
|
|
|
42739
42753
|
{
|
|
42740
42754
|
'aria-controls': 'delete-confirmation-menu-' + id,
|
|
42741
42755
|
'aria-haspopup': 'true',
|
|
42742
|
-
onClick:
|
|
42743
|
-
return setDeleteAnchorEl(e.currentTarget);
|
|
42744
|
-
},
|
|
42756
|
+
onClick: handleClick,
|
|
42745
42757
|
disabled: !enabled,
|
|
42746
42758
|
className: classes.menuLabel
|
|
42747
42759
|
},
|
|
42748
42760
|
icon
|
|
42749
42761
|
)
|
|
42750
42762
|
),
|
|
42751
|
-
React__default.createElement(
|
|
42763
|
+
variant === CONTROL_VARIANTS.popup ? React__default.createElement(
|
|
42764
|
+
Dialog$1,
|
|
42765
|
+
{ id: 'delete-confirmation-menu-' + id, open: openDialog },
|
|
42766
|
+
React__default.createElement(
|
|
42767
|
+
DialogContent$1,
|
|
42768
|
+
null,
|
|
42769
|
+
React__default.createElement(
|
|
42770
|
+
Typography$1,
|
|
42771
|
+
{ variant: 'body1' },
|
|
42772
|
+
confirmText || ''
|
|
42773
|
+
)
|
|
42774
|
+
),
|
|
42775
|
+
React__default.createElement(
|
|
42776
|
+
DialogActions$1,
|
|
42777
|
+
null,
|
|
42778
|
+
React__default.createElement(
|
|
42779
|
+
UButton,
|
|
42780
|
+
{ onClick: handleCancelPopup, variant: 'uDefault' },
|
|
42781
|
+
cancelText || ''
|
|
42782
|
+
),
|
|
42783
|
+
React__default.createElement(
|
|
42784
|
+
UButton,
|
|
42785
|
+
{ onClick: handleConfirm, variant: 'uPrimary', color: 'primary' },
|
|
42786
|
+
confirmActionText || ''
|
|
42787
|
+
)
|
|
42788
|
+
)
|
|
42789
|
+
) : React__default.createElement(
|
|
42752
42790
|
Menu$1,
|
|
42753
42791
|
{
|
|
42754
42792
|
id: 'delete-confirmation-menu-' + id,
|
|
@@ -42782,9 +42820,11 @@ UConfirmationButton.propTypes = {
|
|
|
42782
42820
|
/** trigger confirmation function */
|
|
42783
42821
|
onConfirm: PropTypes__default.func.isRequired,
|
|
42784
42822
|
/** variant: menu or icon */
|
|
42785
|
-
variant: PropTypes__default.oneOf([
|
|
42823
|
+
variant: PropTypes__default.oneOf([CONTROL_VARIANTS.popup, CONTROL_VARIANTS.menuItem, CONTROL_VARIANTS.icon]),
|
|
42786
42824
|
/** if the variant is menuitem, this prop make sure the item enable or not */
|
|
42787
42825
|
enabled: PropTypes__default.bool,
|
|
42826
|
+
/** button cancel text for popup variant */
|
|
42827
|
+
cancelText: PropTypes__default.string,
|
|
42788
42828
|
/** button confirm text */
|
|
42789
42829
|
confirmText: PropTypes__default.string,
|
|
42790
42830
|
/** confirm action text */
|
|
@@ -42799,6 +42839,7 @@ UConfirmationButton.defaultProps = {
|
|
|
42799
42839
|
enabled: true,
|
|
42800
42840
|
confirmText: 'Confirm deletion?',
|
|
42801
42841
|
confirmActionText: 'Yes, delete',
|
|
42842
|
+
cancelText: 'No',
|
|
42802
42843
|
icon: React__default.createElement(DeleteOutlinedIcon, null)
|
|
42803
42844
|
};
|
|
42804
42845
|
|
|
@@ -42978,21 +43019,14 @@ function UAsyncBadge(_ref) {
|
|
|
42978
43019
|
}
|
|
42979
43020
|
}, [variant]);
|
|
42980
43021
|
|
|
42981
|
-
React.useEffect(function () {
|
|
42982
|
-
// When the badge becomes visible, set focus to it.
|
|
42983
|
-
if (visible && variant) {
|
|
42984
|
-
chipRef.current.focus();
|
|
42985
|
-
}
|
|
42986
|
-
}, [visible, variant]);
|
|
42987
|
-
|
|
42988
43022
|
return React__default.createElement(
|
|
42989
43023
|
'span',
|
|
42990
43024
|
{ className: classes.root },
|
|
42991
43025
|
visible && React__default.createElement(Chip$1, {
|
|
42992
43026
|
ref: chipRef,
|
|
42993
|
-
|
|
42994
|
-
'aria-live': '
|
|
42995
|
-
|
|
43027
|
+
role: 'status',
|
|
43028
|
+
'aria-live': 'polite',
|
|
43029
|
+
className: classes.chip + ' ' + classes[variant],
|
|
42996
43030
|
avatar: variant === 'loading' ? React__default.createElement(CircularProgress$1, { size: 16 }) : variant === 'error' ? React__default.createElement(HighlightOffIcon, { size: 16 }) : variant === 'success' && React__default.createElement(DoneIcon, { size: 16 }),
|
|
42997
43031
|
classes: { avatar: classes[variant] },
|
|
42998
43032
|
size: 'medium',
|