@unicef/material-ui 0.11.2 → 0.11.4

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 CHANGED
@@ -48532,6 +48532,18 @@ var UTextField = function (_ValidatorComponent) {
48532
48532
  }
48533
48533
  };
48534
48534
 
48535
+ _this.handleSelectOpen = function () {
48536
+ _this.setState({
48537
+ isSelectOpen: true
48538
+ });
48539
+ };
48540
+
48541
+ _this.handleSelectClose = function () {
48542
+ _this.setState({
48543
+ isSelectOpen: false
48544
+ });
48545
+ };
48546
+
48535
48547
  return _this;
48536
48548
  }
48537
48549
 
@@ -48560,8 +48572,13 @@ var UTextField = function (_ValidatorComponent) {
48560
48572
  InputLabelProps = _props.InputLabelProps,
48561
48573
  showLabelHelp = _props.showLabelHelp,
48562
48574
  InputLabelHelpProps = _props.InputLabelHelpProps,
48563
- rest = objectWithoutProperties(_props, ['variant', 'error', 'customErrorMessages', 'validators', 'requiredError', 'helperText', 'validatorListener', 'withRequiredValidator', 'onBlur', 'maxLength', 'counter', 'counterClassName', 'readOnly', 'label', 'InputProps', 'InputLabelProps', 'showLabelHelp', 'InputLabelHelpProps']);
48564
- var isValid = this.state.isValid;
48575
+ select = _props.select,
48576
+ id = _props.id,
48577
+ SelectProps = _props.SelectProps,
48578
+ rest = objectWithoutProperties(_props, ['variant', 'error', 'customErrorMessages', 'validators', 'requiredError', 'helperText', 'validatorListener', 'withRequiredValidator', 'onBlur', 'maxLength', 'counter', 'counterClassName', 'readOnly', 'label', 'InputProps', 'InputLabelProps', 'showLabelHelp', 'InputLabelHelpProps', 'select', 'id', 'SelectProps']);
48579
+ var _state = this.state,
48580
+ isValid = _state.isValid,
48581
+ isSelectOpen = _state.isSelectOpen;
48565
48582
 
48566
48583
  var length = this.props.value ? this.props.value.length : 0;
48567
48584
  var counterError = maxLength && maxLength < length;
@@ -48583,8 +48600,32 @@ var UTextField = function (_ValidatorComponent) {
48583
48600
  InputLabelProps: _extends$1({}, InputLabelProps, {
48584
48601
  style: _extends$1({}, styles$13.labelRoot)
48585
48602
  }),
48586
- label: showLabelHelp ? React__default.createElement(InputLabelHelp, _extends$1({ inputLabel: label }, InputLabelHelpProps)) : label
48587
- })),
48603
+ label: showLabelHelp ? React__default.createElement(InputLabelHelp, _extends$1({ inputLabel: label }, InputLabelHelpProps)) : label,
48604
+ select: select,
48605
+ id: id
48606
+ /** Accessibility fixes for select field */
48607
+ }, select ? {
48608
+ inputProps: _extends$1({}, this.props.inputProps ? this.props.inputProps : {}, {
48609
+ 'aria-describedby': null
48610
+ }),
48611
+ SelectProps: _extends$1({}, SelectProps ? SelectProps : {}, {
48612
+ open: isSelectOpen ? true : false,
48613
+ onClose: this.handleSelectClose,
48614
+ onOpen: this.handleSelectOpen,
48615
+ MenuProps: {
48616
+ MenuListProps: {
48617
+ id: id + '-select-menu',
48618
+ 'aria-labelledby': null
48619
+ }
48620
+ },
48621
+ SelectDisplayProps: {
48622
+ role: 'combobox',
48623
+ 'aria-controls': id + '-select-menu',
48624
+ 'aria-expanded': isSelectOpen ? true : false,
48625
+ 'aria-describedby': id + '-helper-text'
48626
+ }
48627
+ })
48628
+ } : {})),
48588
48629
  counter && React__default.createElement(
48589
48630
  Box,
48590
48631
  { display: 'block' },
@@ -48637,7 +48678,11 @@ UTextField.propTypes = {
48637
48678
  /** Show label help */
48638
48679
  showLabelHelp: PropTypes__default.bool,
48639
48680
  /** Props applied to the input label help element. E.g InputLabelHelpProps={{type:'link', label:'Help', link:'unicef.github.io', icon, tooltipTitle: 'Tooltip title', tooltipPlacement: 'bottom}} */
48640
- InputLabelHelpProps: PropTypes__default.object
48681
+ InputLabelHelpProps: PropTypes__default.object,
48682
+ /** Id of the field */
48683
+ id: PropTypes__default.string,
48684
+ /** Props applied to the Select element. */
48685
+ SelectProps: PropTypes__default.object
48641
48686
  };
48642
48687
 
48643
48688
  UTextField.defaultProps = {
@@ -48645,7 +48690,9 @@ UTextField.defaultProps = {
48645
48690
  readOnly: false,
48646
48691
  validatorListener: function validatorListener() {},
48647
48692
  showLabelHelp: false,
48648
- InputLabelHelpProps: {}
48693
+ InputLabelHelpProps: {},
48694
+ select: false,
48695
+ SelectProps: {}
48649
48696
  };
48650
48697
 
48651
48698
  //Extending the ValidatorComponent using class component, so taking an exclusion from our rule: functional components only.
@@ -49315,12 +49362,17 @@ var useStyles$n = makeStyles$1(function (theme) {
49315
49362
  };
49316
49363
  });
49317
49364
 
49318
- /**
49319
- * UConfirmationButton is a component to get confirmation from the user before processing it.
49320
- * This button displays the confirmation where user has clicked the button
49321
- * It has two varint icon/menu item
49322
- */
49323
- function UConfirmationButton(props) {
49365
+ var CONTROL_VARIANTS = {
49366
+ popup: 'popup',
49367
+ menuItem: 'menuItem',
49368
+ icon: 'icon'
49369
+
49370
+ /**
49371
+ * UConfirmationButton is a component to get confirmation from the user before processing it.
49372
+ * This button displays the confirmation where user has clicked the button
49373
+ * It has two varint icon/menu item
49374
+ */
49375
+ };function UConfirmationButton(props) {
49324
49376
  var classes = useStyles$n();
49325
49377
  var onConfirm = props.onConfirm,
49326
49378
  id = props.id,
@@ -49330,32 +49382,41 @@ function UConfirmationButton(props) {
49330
49382
  icon = props.icon,
49331
49383
  confirmText = props.confirmText,
49332
49384
  confirmActionText = props.confirmActionText,
49333
- others = objectWithoutProperties(props, ['onConfirm', 'id', 'buttonText', 'enabled', 'variant', 'icon', 'confirmText', 'confirmActionText']);
49385
+ cancelText = props.cancelText;
49334
49386
 
49335
49387
  var _useState = React.useState(null),
49336
49388
  _useState2 = slicedToArray(_useState, 2),
49337
49389
  deleteAnchorEl = _useState2[0],
49338
49390
  setDeleteAnchorEl = _useState2[1];
49339
49391
 
49392
+ var _useState3 = React.useState(false),
49393
+ _useState4 = slicedToArray(_useState3, 2),
49394
+ openDialog = _useState4[0],
49395
+ setOpenDialog = _useState4[1];
49396
+
49340
49397
  var handleConfirm = function handleConfirm(e) {
49341
- onConfirm(e, id);
49342
- handleDeleteOptionClicked();
49398
+ onConfirm && onConfirm(e, id);
49399
+ if (variant !== CONTROL_VARIANTS.popup) handleDeleteOptionClicked();
49343
49400
  };
49344
49401
 
49345
49402
  var handleDeleteOptionClicked = function handleDeleteOptionClicked(e) {
49346
49403
  setDeleteAnchorEl(null);
49347
49404
  };
49405
+
49406
+ var handleClick = function handleClick(e) {
49407
+ if (variant !== CONTROL_VARIANTS.popup) setDeleteAnchorEl(e.currentTarget);else setOpenDialog(true);
49408
+ };
49409
+
49410
+ var handleCancelPopup = function handleCancelPopup(e) {
49411
+ setOpenDialog(false);
49412
+ };
49413
+
49348
49414
  return React__default.createElement(
49349
49415
  React__default.Fragment,
49350
49416
  null,
49351
- variant === 'menuItem' ? React__default.createElement(
49417
+ variant === CONTROL_VARIANTS.menuItem ? React__default.createElement(
49352
49418
  MenuItem$1,
49353
- {
49354
- onClick: function onClick(e) {
49355
- return setDeleteAnchorEl(e.currentTarget);
49356
- },
49357
- className: classes.menuLabel
49358
- },
49419
+ { onClick: handleClick, className: classes.menuLabel },
49359
49420
  icon,
49360
49421
  React__default.createElement(
49361
49422
  'span',
@@ -49370,16 +49431,40 @@ function UConfirmationButton(props) {
49370
49431
  {
49371
49432
  'aria-controls': 'delete-confirmation-menu-' + id,
49372
49433
  'aria-haspopup': 'true',
49373
- onClick: function onClick(e) {
49374
- return setDeleteAnchorEl(e.currentTarget);
49375
- },
49434
+ onClick: handleClick,
49376
49435
  disabled: !enabled,
49377
49436
  className: classes.menuLabel
49378
49437
  },
49379
49438
  icon
49380
49439
  )
49381
49440
  ),
49382
- React__default.createElement(
49441
+ variant === CONTROL_VARIANTS.popup ? React__default.createElement(
49442
+ Dialog$1,
49443
+ { id: 'delete-confirmation-menu-' + id, open: openDialog },
49444
+ React__default.createElement(
49445
+ DialogContent$1,
49446
+ null,
49447
+ React__default.createElement(
49448
+ Typography$1,
49449
+ { variant: 'body1' },
49450
+ confirmText || ''
49451
+ )
49452
+ ),
49453
+ React__default.createElement(
49454
+ DialogActions$1,
49455
+ null,
49456
+ React__default.createElement(
49457
+ UButton,
49458
+ { onClick: handleCancelPopup, variant: 'uDefault' },
49459
+ cancelText || ''
49460
+ ),
49461
+ React__default.createElement(
49462
+ UButton,
49463
+ { onClick: handleConfirm, variant: 'uPrimary', color: 'primary' },
49464
+ confirmActionText || ''
49465
+ )
49466
+ )
49467
+ ) : React__default.createElement(
49383
49468
  Menu$1,
49384
49469
  {
49385
49470
  id: 'delete-confirmation-menu-' + id,
@@ -49413,9 +49498,11 @@ UConfirmationButton.propTypes = {
49413
49498
  /** trigger confirmation function */
49414
49499
  onConfirm: PropTypes__default.func.isRequired,
49415
49500
  /** variant: menu or icon */
49416
- variant: PropTypes__default.oneOf(['menuItem', 'icon']),
49501
+ variant: PropTypes__default.oneOf([CONTROL_VARIANTS.popup, CONTROL_VARIANTS.menuItem, CONTROL_VARIANTS.icon]),
49417
49502
  /** if the variant is menuitem, this prop make sure the item enable or not */
49418
49503
  enabled: PropTypes__default.bool,
49504
+ /** button cancel text for popup variant */
49505
+ cancelText: PropTypes__default.string,
49419
49506
  /** button confirm text */
49420
49507
  confirmText: PropTypes__default.string,
49421
49508
  /** confirm action text */
@@ -49430,6 +49517,7 @@ UConfirmationButton.defaultProps = {
49430
49517
  enabled: true,
49431
49518
  confirmText: 'Confirm deletion?',
49432
49519
  confirmActionText: 'Yes, delete',
49520
+ cancelText: 'No',
49433
49521
  icon: React__default.createElement(DeleteOutlinedIcon, null)
49434
49522
  };
49435
49523
 
@@ -49566,7 +49654,8 @@ var useStyles$p = makeStyles$1(function (theme) {
49566
49654
  root: {
49567
49655
  position: 'fixed',
49568
49656
  top: 16,
49569
- left: '40%',
49657
+ left: '50%',
49658
+ transform: 'translate(-50%, 0)',
49570
49659
  zIndex: 5000
49571
49660
  },
49572
49661
  chip: {
@@ -49609,21 +49698,14 @@ function UAsyncBadge(_ref) {
49609
49698
  }
49610
49699
  }, [variant]);
49611
49700
 
49612
- React.useEffect(function () {
49613
- // When the badge becomes visible, set focus to it.
49614
- if (visible && variant) {
49615
- chipRef.current.focus();
49616
- }
49617
- }, [visible, variant]);
49618
-
49619
49701
  return React__default.createElement(
49620
49702
  'span',
49621
49703
  { className: classes.root },
49622
49704
  visible && React__default.createElement(Chip$1, {
49623
49705
  ref: chipRef,
49624
- tabIndex: 0,
49625
- 'aria-live': 'assertive' // Announce changes to screen readers
49626
- , className: classes.chip + ' ' + classes[variant],
49706
+ role: 'status',
49707
+ 'aria-live': 'polite',
49708
+ className: classes.chip + ' ' + classes[variant],
49627
49709
  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 }),
49628
49710
  classes: { avatar: classes[variant] },
49629
49711
  size: 'medium',
@@ -52867,6 +52949,10 @@ function USearchBox(_ref) {
52867
52949
 
52868
52950
  var classes = useStyles$u();
52869
52951
 
52952
+ useEffect(function () {
52953
+ setSearch(value);
52954
+ }, [value]);
52955
+
52870
52956
  var handleChange = function handleChange(event) {
52871
52957
  setSearch(event.target.value);
52872
52958
  };