@thecb/components 10.5.0-beta.1 → 10.5.0-beta.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/dist/index.cjs.js CHANGED
@@ -46304,14 +46304,27 @@ var Modal$1 = function Modal(_ref) {
46304
46304
  blurUnderlay = _ref$blurUnderlay === void 0 ? true : _ref$blurUnderlay;
46305
46305
  var _useContext = React.useContext(styled.ThemeContext),
46306
46306
  isMobile = _useContext.isMobile;
46307
- var modalContainerRef = React.useRef(null);
46307
+
46308
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46309
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46310
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46311
+ // this option will be populated on initial render when `focus-trap` is checking
46312
+ // these option. When there are no buttons in the modal, this causes an error.
46313
+ // Because `focus-trap` cannot be disabled, the ref itself requires a default value
46314
+ // to satisfy `focus-trap` until React populates it with the real ref value.
46315
+ //
46316
+ // See:
46317
+ // - https://react.dev/reference/react/useRef#caveats
46318
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46319
+ // - https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions
46320
+ var modalContainerRef = React.useRef("[id='react-aria-modal-dialog']");
46308
46321
  return /*#__PURE__*/React__default.createElement("div", {
46309
46322
  ref: modalContainerRef,
46323
+ tabIndex: "-1",
46310
46324
  "data-qa": dataQa
46311
- }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal
46312
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46313
- , {
46325
+ }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal, {
46314
46326
  focusTrapOptions: {
46327
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46315
46328
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46316
46329
  },
46317
46330
  onExit: onExit,
@@ -46614,17 +46627,30 @@ var Modal$2 = function Modal(_ref) {
46614
46627
  useDangerButton = _ref$useDangerButton === void 0 ? false : _ref$useDangerButton;
46615
46628
  var _useContext = React.useContext(styled.ThemeContext),
46616
46629
  isMobile = _useContext.isMobile;
46617
- var modalContainerRef = React.useRef(null);
46630
+
46631
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46632
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46633
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46634
+ // this option will be populated on initial render when `focus-trap` is checking
46635
+ // these option. When there are no buttons in the modal, this causes an error.
46636
+ // Because `focus-trap` cannot be disabled, the ref itself requires a default value
46637
+ // to satisfy `focus-trap` until React populates it with the real ref value.
46638
+ //
46639
+ // See:
46640
+ // - https://react.dev/reference/react/useRef#caveats
46641
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46642
+ // - https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions
46643
+ var modalContainerRef = React.useRef("[id='react-aria-modal-dialog']");
46618
46644
  var hasCloseButton = onlyCloseButton && !noButtons;
46619
46645
  var hasCancelButton = !onlyContinueButton && !onlyCloseButton && !noButtons;
46620
46646
  var hasContinueButton = onlyContinueButton && !noButtons || !onlyCloseButton && !noButtons;
46621
46647
  return /*#__PURE__*/React__default.createElement("div", {
46622
46648
  ref: modalContainerRef,
46649
+ tabIndex: "-1",
46623
46650
  "data-qa": dataQa
46624
- }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal
46625
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46626
- , {
46651
+ }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal, {
46627
46652
  focusTrapOptions: {
46653
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46628
46654
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46629
46655
  },
46630
46656
  onExit: onExit,
@@ -46682,7 +46708,8 @@ var Modal$2 = function Modal(_ref) {
46682
46708
  cancelAction: cancelAction,
46683
46709
  cancelButtonText: cancelButtonText,
46684
46710
  hideModal: hideModal,
46685
- isMobile: isMobile
46711
+ isMobile: isMobile,
46712
+ key: "cancel"
46686
46713
  }), hasContinueButton && /*#__PURE__*/React__default.createElement(ContinueButton, {
46687
46714
  buttonExtraStyles: buttonExtraStyles,
46688
46715
  continueAction: continueAction,
@@ -46691,12 +46718,14 @@ var Modal$2 = function Modal(_ref) {
46691
46718
  isContinueActionDisabled: isContinueActionDisabled,
46692
46719
  isLoading: isLoading,
46693
46720
  isMobile: isMobile,
46721
+ key: "continue",
46694
46722
  useDangerButton: useDangerButton
46695
46723
  }), hasCloseButton && /*#__PURE__*/React__default.createElement(CloseButton, {
46696
46724
  buttonExtraStyles: buttonExtraStyles,
46697
46725
  closeButtonText: closeButtonText,
46698
46726
  hideModal: hideModal,
46699
- isMobile: isMobile
46727
+ isMobile: isMobile,
46728
+ key: "close"
46700
46729
  })].filter(function (button) {
46701
46730
  return button;
46702
46731
  }))))), children);