@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.esm.js CHANGED
@@ -46296,14 +46296,27 @@ var Modal$1 = function Modal(_ref) {
46296
46296
  blurUnderlay = _ref$blurUnderlay === void 0 ? true : _ref$blurUnderlay;
46297
46297
  var _useContext = useContext(ThemeContext),
46298
46298
  isMobile = _useContext.isMobile;
46299
- var modalContainerRef = useRef(null);
46299
+
46300
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46301
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46302
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46303
+ // this option will be populated on initial render when `focus-trap` is checking
46304
+ // these option. When there are no buttons in the modal, this causes an error.
46305
+ // Because `focus-trap` cannot be disabled, the ref itself requires a default value
46306
+ // to satisfy `focus-trap` until React populates it with the real ref value.
46307
+ //
46308
+ // See:
46309
+ // - https://react.dev/reference/react/useRef#caveats
46310
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46311
+ // - https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions
46312
+ var modalContainerRef = useRef("[id='react-aria-modal-dialog']");
46300
46313
  return /*#__PURE__*/React.createElement("div", {
46301
46314
  ref: modalContainerRef,
46315
+ tabIndex: "-1",
46302
46316
  "data-qa": dataQa
46303
- }, modalOpen && /*#__PURE__*/React.createElement(reactAriaModal
46304
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46305
- , {
46317
+ }, modalOpen && /*#__PURE__*/React.createElement(reactAriaModal, {
46306
46318
  focusTrapOptions: {
46319
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46307
46320
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46308
46321
  },
46309
46322
  onExit: onExit,
@@ -46606,17 +46619,30 @@ var Modal$2 = function Modal(_ref) {
46606
46619
  useDangerButton = _ref$useDangerButton === void 0 ? false : _ref$useDangerButton;
46607
46620
  var _useContext = useContext(ThemeContext),
46608
46621
  isMobile = _useContext.isMobile;
46609
- var modalContainerRef = useRef(null);
46622
+
46623
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46624
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46625
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46626
+ // this option will be populated on initial render when `focus-trap` is checking
46627
+ // these option. When there are no buttons in the modal, this causes an error.
46628
+ // Because `focus-trap` cannot be disabled, the ref itself requires a default value
46629
+ // to satisfy `focus-trap` until React populates it with the real ref value.
46630
+ //
46631
+ // See:
46632
+ // - https://react.dev/reference/react/useRef#caveats
46633
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46634
+ // - https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions
46635
+ var modalContainerRef = useRef("[id='react-aria-modal-dialog']");
46610
46636
  var hasCloseButton = onlyCloseButton && !noButtons;
46611
46637
  var hasCancelButton = !onlyContinueButton && !onlyCloseButton && !noButtons;
46612
46638
  var hasContinueButton = onlyContinueButton && !noButtons || !onlyCloseButton && !noButtons;
46613
46639
  return /*#__PURE__*/React.createElement("div", {
46614
46640
  ref: modalContainerRef,
46641
+ tabIndex: "-1",
46615
46642
  "data-qa": dataQa
46616
- }, modalOpen && /*#__PURE__*/React.createElement(reactAriaModal
46617
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46618
- , {
46643
+ }, modalOpen && /*#__PURE__*/React.createElement(reactAriaModal, {
46619
46644
  focusTrapOptions: {
46645
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46620
46646
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46621
46647
  },
46622
46648
  onExit: onExit,
@@ -46674,7 +46700,8 @@ var Modal$2 = function Modal(_ref) {
46674
46700
  cancelAction: cancelAction,
46675
46701
  cancelButtonText: cancelButtonText,
46676
46702
  hideModal: hideModal,
46677
- isMobile: isMobile
46703
+ isMobile: isMobile,
46704
+ key: "cancel"
46678
46705
  }), hasContinueButton && /*#__PURE__*/React.createElement(ContinueButton, {
46679
46706
  buttonExtraStyles: buttonExtraStyles,
46680
46707
  continueAction: continueAction,
@@ -46683,12 +46710,14 @@ var Modal$2 = function Modal(_ref) {
46683
46710
  isContinueActionDisabled: isContinueActionDisabled,
46684
46711
  isLoading: isLoading,
46685
46712
  isMobile: isMobile,
46713
+ key: "continue",
46686
46714
  useDangerButton: useDangerButton
46687
46715
  }), hasCloseButton && /*#__PURE__*/React.createElement(CloseButton, {
46688
46716
  buttonExtraStyles: buttonExtraStyles,
46689
46717
  closeButtonText: closeButtonText,
46690
46718
  hideModal: hideModal,
46691
- isMobile: isMobile
46719
+ isMobile: isMobile,
46720
+ key: "close"
46692
46721
  })].filter(function (button) {
46693
46722
  return button;
46694
46723
  }))))), children);