@bigbinary/neetoui 5.1.3 → 5.1.5

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/index.cjs.js CHANGED
@@ -10237,7 +10237,7 @@ var UniqueArray = /*#__PURE__*/function () {
10237
10237
  var renderFocusOnFocusableElements = function renderFocusOnFocusableElements(ref) {
10238
10238
  var _ref$current, _ref$current2;
10239
10239
  var shouldFocusFirstFocusableElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
10240
- var focusableElements = '[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
10240
+ var focusableElements = 'button,[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
10241
10241
  var firstFocusableElement = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelectorAll(focusableElements)[0];
10242
10242
  var focusableContent = ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelectorAll(focusableElements);
10243
10243
  var lastFocusableElement = focusableContent[(focusableContent === null || focusableContent === void 0 ? void 0 : focusableContent.length) - 1];
@@ -17355,6 +17355,10 @@ var SIZES$6 = {
17355
17355
  medium: "medium",
17356
17356
  large: "large"
17357
17357
  };
17358
+ var FOCUSABLE_ELEMENTS = {
17359
+ submit: "submit",
17360
+ cancel: "cancel"
17361
+ };
17358
17362
  var Alert = function Alert(_ref) {
17359
17363
  var _ref$size = _ref.size,
17360
17364
  size = _ref$size === void 0 ? SIZES$6.medium : _ref$size,
@@ -17383,8 +17387,14 @@ var Alert = function Alert(_ref) {
17383
17387
  _ref$submitButtonLabe = _ref.submitButtonLabel,
17384
17388
  submitButtonLabel = _ref$submitButtonLabe === void 0 ? "Continue" : _ref$submitButtonLabe,
17385
17389
  _ref$cancelButtonLabe = _ref.cancelButtonLabel,
17386
- cancelButtonLabel = _ref$cancelButtonLabe === void 0 ? "Cancel" : _ref$cancelButtonLabe;
17387
- return /*#__PURE__*/React__default["default"].createElement(Modal, {
17390
+ cancelButtonLabel = _ref$cancelButtonLabe === void 0 ? "Cancel" : _ref$cancelButtonLabe,
17391
+ initialFocusRef = _ref.initialFocusRef,
17392
+ initialFocusElement = _ref.initialFocusElement;
17393
+ var submitButtonRef = React$5.useRef(null);
17394
+ var cancelButtonRef = React$5.useRef(null);
17395
+ var hasCustomFocusableElement = !!initialFocusRef || initialFocusElement;
17396
+ var initialFocusElementRef = initialFocusElement === FOCUSABLE_ELEMENTS.submit ? submitButtonRef : cancelButtonRef;
17397
+ return /*#__PURE__*/React__default["default"].createElement(Modal, _extends$4({
17388
17398
  backdropClassName: backdropClassName,
17389
17399
  className: className,
17390
17400
  closeButton: closeButton,
@@ -17393,7 +17403,9 @@ var Alert = function Alert(_ref) {
17393
17403
  isOpen: isOpen,
17394
17404
  size: size,
17395
17405
  onClose: onClose
17396
- }, /*#__PURE__*/React__default["default"].createElement(Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(Typography, {
17406
+ }, hasCustomFocusableElement && {
17407
+ initialFocusRef: initialFocusRef || initialFocusElementRef
17408
+ }), /*#__PURE__*/React__default["default"].createElement(Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(Typography, {
17397
17409
  "data-cy": "alert-title",
17398
17410
  style: "h2"
17399
17411
  }, title)), /*#__PURE__*/React__default["default"].createElement(Modal.Body, null, /*#__PURE__*/React__default["default"].createElement(Typography, {
@@ -17407,11 +17419,13 @@ var Alert = function Alert(_ref) {
17407
17419
  disabled: !isOpen,
17408
17420
  label: submitButtonLabel,
17409
17421
  loading: isSubmitting,
17422
+ ref: submitButtonRef,
17410
17423
  style: "danger",
17411
17424
  onClick: onSubmit
17412
17425
  }), /*#__PURE__*/React__default["default"].createElement(Button, {
17413
17426
  "data-cy": "alert-cancel-button",
17414
17427
  label: cancelButtonLabel,
17428
+ ref: cancelButtonRef,
17415
17429
  style: "text",
17416
17430
  onClick: onClose
17417
17431
  })));