@thecb/components 10.5.0-beta.0 → 10.5.0-beta.1

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
@@ -46428,6 +46428,112 @@ var Modal$1 = function Modal(_ref) {
46428
46428
  }))))))))), children);
46429
46429
  };
46430
46430
 
46431
+ var ButtonLayoutWrapper = function ButtonLayoutWrapper(_ref) {
46432
+ var _ref$children = _ref.children,
46433
+ children = _ref$children === void 0 ? [] : _ref$children,
46434
+ _ref$isMobile = _ref.isMobile,
46435
+ isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46436
+ var safeChildren = Array.isArray(children) ? children : [children];
46437
+ var flexGrow = isMobile ? "flex-grow: 1;" : "";
46438
+ return /*#__PURE__*/React.createElement(Box, {
46439
+ padding: SPACING_NORMAL
46440
+ }, /*#__PURE__*/React.createElement(Stack, {
46441
+ childGap: "1rem",
46442
+ direction: "row",
46443
+ justify: "flex-end"
46444
+ }, safeChildren.map(function (child, index) {
46445
+ return /*#__PURE__*/React.createElement(Box, {
46446
+ padding: "0",
46447
+ extraStyles: flexGrow,
46448
+ key: index
46449
+ }, child);
46450
+ })));
46451
+ };
46452
+
46453
+ var CancelButton = function CancelButton(_ref) {
46454
+ var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46455
+ buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46456
+ _ref$cancelAction = _ref.cancelAction,
46457
+ cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46458
+ _ref$cancelButtonText = _ref.cancelButtonText,
46459
+ cancelButtonText = _ref$cancelButtonText === void 0 ? "" : _ref$cancelButtonText,
46460
+ _ref$hideModal = _ref.hideModal,
46461
+ hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46462
+ _ref$isMobile = _ref.isMobile,
46463
+ isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46464
+ var fullWidth = isMobile ? "width: 100%;" : "";
46465
+ return /*#__PURE__*/React.createElement(ButtonWithAction, {
46466
+ action: cancelAction ? cancelAction : hideModal,
46467
+ borderRadius: CORNER_STANDARD,
46468
+ className: "modal-cancel-button",
46469
+ dataQa: cancelButtonText,
46470
+ extraStyles: "".concat(buttonExtraStyles, "; margin: 0; ").concat(fullWidth),
46471
+ name: cancelButtonText,
46472
+ role: "button",
46473
+ text: cancelButtonText,
46474
+ variant: "secondary"
46475
+ });
46476
+ };
46477
+
46478
+ var CloseButton = function CloseButton(_ref) {
46479
+ var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46480
+ buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46481
+ _ref$closeButtonText = _ref.closeButtonText,
46482
+ closeButtonText = _ref$closeButtonText === void 0 ? "" : _ref$closeButtonText,
46483
+ _ref$hideModal = _ref.hideModal,
46484
+ hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46485
+ _ref$isMobile = _ref.isMobile,
46486
+ isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46487
+ var fullWidth = isMobile ? "width: 100%;" : "";
46488
+ return /*#__PURE__*/React.createElement(ButtonWithAction, {
46489
+ action: hideModal,
46490
+ borderRadius: CORNER_STANDARD,
46491
+ className: "modal-close-button",
46492
+ dataQa: closeButtonText,
46493
+ extraStyles: "".concat(buttonExtraStyles, "; margin: 0; ").concat(fullWidth),
46494
+ name: closeButtonText,
46495
+ role: "button",
46496
+ text: closeButtonText,
46497
+ variant: "primary"
46498
+ });
46499
+ };
46500
+
46501
+ var ContinueButton = function ContinueButton(_ref) {
46502
+ var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46503
+ buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46504
+ _ref$continueAction = _ref.continueAction,
46505
+ continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46506
+ _ref$continueButtonTe = _ref.continueButtonText,
46507
+ continueButtonText = _ref$continueButtonTe === void 0 ? "" : _ref$continueButtonTe,
46508
+ _ref$continueURL = _ref.continueURL,
46509
+ continueURL = _ref$continueURL === void 0 ? "" : _ref$continueURL,
46510
+ _ref$isContinueAction = _ref.isContinueActionDisabled,
46511
+ isContinueActionDisabled = _ref$isContinueAction === void 0 ? false : _ref$isContinueAction,
46512
+ _ref$isLoading = _ref.isLoading,
46513
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
46514
+ _ref$isMobile = _ref.isMobile,
46515
+ isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile,
46516
+ _ref$useDangerButton = _ref.useDangerButton,
46517
+ useDangerButton = _ref$useDangerButton === void 0 ? false : _ref$useDangerButton;
46518
+ var ContinueButtonAtom = continueURL ? ButtonWithLink : ButtonWithAction;
46519
+ var fullWidth = isMobile ? "width: 100%;" : "";
46520
+ return /*#__PURE__*/React.createElement(ContinueButtonAtom, {
46521
+ action: continueAction,
46522
+ borderRadius: CORNER_STANDARD,
46523
+ className: "modal-continue-button",
46524
+ dataQa: continueButtonText,
46525
+ disabled: isContinueActionDisabled,
46526
+ extraStyles: "".concat(buttonExtraStyles, "; margin: 0; ").concat(fullWidth),
46527
+ isLoading: isLoading,
46528
+ linkExtraStyles: "display: inline-block; ".concat(fullWidth),
46529
+ name: continueButtonText,
46530
+ role: "button",
46531
+ text: continueButtonText,
46532
+ url: continueURL,
46533
+ variant: useDangerButton ? "danger" : "primary"
46534
+ });
46535
+ };
46536
+
46431
46537
  /*
46432
46538
  Default Modal molecule
46433
46539
  Uses react-aria-modal behind the scenes for a11y purposes
@@ -46444,35 +46550,48 @@ var getApplicationNode$1 = function getApplicationNode() {
46444
46550
  var Modal$2 = function Modal(_ref) {
46445
46551
  var _ref$blurUnderlay = _ref.blurUnderlay,
46446
46552
  blurUnderlay = _ref$blurUnderlay === void 0 ? true : _ref$blurUnderlay,
46447
- buttonExtraStyles = _ref.buttonExtraStyles,
46448
- cancelAction = _ref.cancelAction,
46553
+ _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46554
+ buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46555
+ _ref$cancelAction = _ref.cancelAction,
46556
+ cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46449
46557
  _ref$cancelButtonText = _ref.cancelButtonText,
46450
46558
  cancelButtonText = _ref$cancelButtonText === void 0 ? "Cancel" : _ref$cancelButtonText,
46451
- children = _ref.children,
46559
+ _ref$children = _ref.children,
46560
+ children = _ref$children === void 0 ? [] : _ref$children,
46452
46561
  _ref$closeButtonText = _ref.closeButtonText,
46453
46562
  closeButtonText = _ref$closeButtonText === void 0 ? "Close" : _ref$closeButtonText,
46454
- continueAction = _ref.continueAction,
46563
+ _ref$continueAction = _ref.continueAction,
46564
+ continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46455
46565
  _ref$continueButtonTe = _ref.continueButtonText,
46456
46566
  continueButtonText = _ref$continueButtonTe === void 0 ? "Continue" : _ref$continueButtonTe,
46457
- customWidth = _ref.customWidth,
46567
+ _ref$continueURL = _ref.continueURL,
46568
+ continueURL = _ref$continueURL === void 0 ? "" : _ref$continueURL,
46569
+ _ref$customWidth = _ref.customWidth,
46570
+ customWidth = _ref$customWidth === void 0 ? "" : _ref$customWidth,
46458
46571
  _ref$dataQa = _ref.dataQa,
46459
46572
  dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
46460
46573
  _ref$defaultWrapper = _ref.defaultWrapper,
46461
46574
  defaultWrapper = _ref$defaultWrapper === void 0 ? true : _ref$defaultWrapper,
46462
- hideModal = _ref.hideModal,
46575
+ _ref$hideModal = _ref.hideModal,
46576
+ hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46463
46577
  _ref$initialFocusSele = _ref.initialFocusSelector,
46464
46578
  initialFocusSelector = _ref$initialFocusSele === void 0 ? "" : _ref$initialFocusSele,
46465
46579
  _ref$isContinueAction = _ref.isContinueActionDisabled,
46466
46580
  isContinueActionDisabled = _ref$isContinueAction === void 0 ? false : _ref$isContinueAction,
46467
- isLoading = _ref.isLoading,
46468
- maxHeight = _ref.maxHeight,
46581
+ _ref$isLoading = _ref.isLoading,
46582
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
46583
+ _ref$maxHeight = _ref.maxHeight,
46584
+ maxHeight = _ref$maxHeight === void 0 ? "" : _ref$maxHeight,
46469
46585
  _ref$modalBodyBg = _ref.modalBodyBg,
46470
46586
  modalBodyBg = _ref$modalBodyBg === void 0 ? ATHENS_GREY : _ref$modalBodyBg,
46471
- modalBodyText = _ref.modalBodyText,
46587
+ _ref$modalBodyText = _ref.modalBodyText,
46588
+ modalBodyText = _ref$modalBodyText === void 0 ? "" : _ref$modalBodyText,
46472
46589
  _ref$modalHeaderBg = _ref.modalHeaderBg,
46473
46590
  modalHeaderBg = _ref$modalHeaderBg === void 0 ? WHITE : _ref$modalHeaderBg,
46474
- modalHeaderText = _ref.modalHeaderText,
46475
- modalOpen = _ref.modalOpen,
46591
+ _ref$modalHeaderText = _ref.modalHeaderText,
46592
+ modalHeaderText = _ref$modalHeaderText === void 0 ? "" : _ref$modalHeaderText,
46593
+ _ref$modalOpen = _ref.modalOpen,
46594
+ modalOpen = _ref$modalOpen === void 0 ? false : _ref$modalOpen,
46476
46595
  _ref$noButtons = _ref.noButtons,
46477
46596
  noButtons = _ref$noButtons === void 0 ? false : _ref$noButtons,
46478
46597
  _ref$onExit = _ref.onExit,
@@ -46488,106 +46607,9 @@ var Modal$2 = function Modal(_ref) {
46488
46607
  var _useContext = useContext(ThemeContext),
46489
46608
  isMobile = _useContext.isMobile;
46490
46609
  var modalContainerRef = useRef(null);
46491
- var AllButtons = function AllButtons() {
46492
- return isMobile ? /*#__PURE__*/React.createElement(Stack, {
46493
- childGap: "1rem",
46494
- direction: "row"
46495
- }, /*#__PURE__*/React.createElement(Box, {
46496
- width: "100%",
46497
- padding: "0"
46498
- }, /*#__PURE__*/React.createElement(ButtonWithAction, {
46499
- variant: "secondary",
46500
- action: cancelAction ? cancelAction : hideModal,
46501
- text: cancelButtonText,
46502
- dataQa: cancelButtonText,
46503
- extraStyles: buttonExtraStyles,
46504
- borderRadius: CORNER_STANDARD,
46505
- className: "modal-cancel-button",
46506
- role: "button",
46507
- name: cancelButtonText
46508
- })), /*#__PURE__*/React.createElement(Box, {
46509
- width: "100%",
46510
- padding: "0"
46511
- }, /*#__PURE__*/React.createElement(ButtonWithAction, {
46512
- variant: useDangerButton ? "danger" : "primary",
46513
- action: continueAction,
46514
- text: continueButtonText,
46515
- dataQa: continueButtonText,
46516
- isLoading: isLoading,
46517
- disabled: isContinueActionDisabled,
46518
- extraStyles: buttonExtraStyles,
46519
- borderRadius: CORNER_STANDARD,
46520
- className: "modal-continue-button",
46521
- role: "button",
46522
- name: continueButtonText
46523
- }))) : /*#__PURE__*/React.createElement(Stack, {
46524
- childGap: "1rem",
46525
- direction: "row",
46526
- justify: "flex-end"
46527
- }, /*#__PURE__*/React.createElement(ButtonWithAction, {
46528
- variant: "secondary",
46529
- action: cancelAction ? cancelAction : hideModal,
46530
- text: cancelButtonText,
46531
- dataQa: cancelButtonText,
46532
- extraStyles: buttonExtraStyles,
46533
- borderRadius: CORNER_STANDARD,
46534
- className: "modal-cancel-button",
46535
- role: "button",
46536
- name: cancelButtonText
46537
- }), /*#__PURE__*/React.createElement(ButtonWithAction, {
46538
- variant: useDangerButton ? "danger" : "primary",
46539
- action: continueAction,
46540
- text: continueButtonText,
46541
- dataQa: continueButtonText,
46542
- isLoading: isLoading,
46543
- disabled: isContinueActionDisabled,
46544
- extraStyles: buttonExtraStyles,
46545
- borderRadius: CORNER_STANDARD,
46546
- className: "modal-continue-button",
46547
- role: "button",
46548
- name: continueButtonText
46549
- }));
46550
- };
46551
- var CloseButton = function CloseButton() {
46552
- return /*#__PURE__*/React.createElement(ButtonWithAction, {
46553
- action: hideModal,
46554
- variant: "primary",
46555
- text: closeButtonText,
46556
- dataQa: closeButtonText,
46557
- extraStyles: buttonExtraStyles,
46558
- borderRadius: CORNER_STANDARD,
46559
- className: "modal-close-button",
46560
- role: "button",
46561
- name: closeButtonText
46562
- });
46563
- };
46564
- var ContinueButton = function ContinueButton() {
46565
- return /*#__PURE__*/React.createElement(ButtonWithAction, {
46566
- variant: useDangerButton ? "danger" : "primary",
46567
- action: continueAction,
46568
- text: continueButtonText,
46569
- dataQa: continueButtonText,
46570
- isLoading: isLoading,
46571
- disabled: isContinueActionDisabled,
46572
- extraStyles: buttonExtraStyles,
46573
- borderRadius: CORNER_STANDARD,
46574
- className: "modal-continue-button",
46575
- role: "button",
46576
- name: continueButtonText
46577
- });
46578
- };
46579
- var MaybeButtons = /*#__PURE__*/forwardRef(function () {
46580
- return /*#__PURE__*/React.createElement(Fragment$1, null);
46581
- });
46582
- if (!noButtons) {
46583
- if (onlyContinueButton) {
46584
- MaybeButtons = ContinueButton;
46585
- } else if (onlyCloseButton) {
46586
- MaybeButtons = CloseButton;
46587
- } else {
46588
- MaybeButtons = AllButtons;
46589
- }
46590
- }
46610
+ var hasCloseButton = onlyCloseButton && !noButtons;
46611
+ var hasCancelButton = !onlyContinueButton && !onlyCloseButton && !noButtons;
46612
+ var hasContinueButton = onlyContinueButton && !noButtons || !onlyCloseButton && !noButtons;
46591
46613
  return /*#__PURE__*/React.createElement("div", {
46592
46614
  ref: modalContainerRef,
46593
46615
  "data-qa": dataQa
@@ -46611,7 +46633,7 @@ var Modal$2 = function Modal(_ref) {
46611
46633
  },
46612
46634
  dialogStyle: {
46613
46635
  borderRadius: CORNER_STANDARD,
46614
- width: customWidth || "615px",
46636
+ width: isMobile ? "" : customWidth || "615px",
46615
46637
  overflow: "auto"
46616
46638
  },
46617
46639
  underlayClickExits: underlayClickExits,
@@ -46636,8 +46658,6 @@ var Modal$2 = function Modal(_ref) {
46636
46658
  }, modalHeaderText))), /*#__PURE__*/React.createElement(Box, {
46637
46659
  background: modalBodyBg,
46638
46660
  padding: "0"
46639
- }, /*#__PURE__*/React.createElement(Stack, {
46640
- childGap: SPACING_NORMAL
46641
46661
  }, /*#__PURE__*/React.createElement(Box, {
46642
46662
  padding: SPACING_NORMAL,
46643
46663
  borderWidthOverride: !noButtons && "0 0 ".concat(BORDER_THIN, " 0"),
@@ -46647,22 +46667,40 @@ var Modal$2 = function Modal(_ref) {
46647
46667
  variant: "p"
46648
46668
  }, modalBodyText) : /*#__PURE__*/React.createElement(Box, {
46649
46669
  padding: maxHeight ? "0 0 ".concat(SPACING_XS, " 0") : "0"
46650
- }, modalBodyText)), noButtons ? /*#__PURE__*/React.createElement(MaybeButtons, null) : /*#__PURE__*/React.createElement(Box, {
46651
- padding: "0 ".concat(SPACING_NORMAL, " ").concat(SPACING_NORMAL)
46652
- }, /*#__PURE__*/React.createElement(Stack, {
46653
- direction: "row",
46654
- justify: "flex-end",
46655
- align: "center",
46656
- childGap: "0rem"
46657
- }, /*#__PURE__*/React.createElement(MaybeButtons, null))))))), children);
46670
+ }, modalBodyText)), noButtons ? /*#__PURE__*/React.createElement(React.Fragment, null) : /*#__PURE__*/React.createElement(ButtonLayoutWrapper, {
46671
+ isMobile: isMobile
46672
+ }, [hasCancelButton && /*#__PURE__*/React.createElement(CancelButton, {
46673
+ buttonExtraStyles: buttonExtraStyles,
46674
+ cancelAction: cancelAction,
46675
+ cancelButtonText: cancelButtonText,
46676
+ hideModal: hideModal,
46677
+ isMobile: isMobile
46678
+ }), hasContinueButton && /*#__PURE__*/React.createElement(ContinueButton, {
46679
+ buttonExtraStyles: buttonExtraStyles,
46680
+ continueAction: continueAction,
46681
+ continueButtonText: continueButtonText,
46682
+ continueURL: continueURL,
46683
+ isContinueActionDisabled: isContinueActionDisabled,
46684
+ isLoading: isLoading,
46685
+ isMobile: isMobile,
46686
+ useDangerButton: useDangerButton
46687
+ }), hasCloseButton && /*#__PURE__*/React.createElement(CloseButton, {
46688
+ buttonExtraStyles: buttonExtraStyles,
46689
+ closeButtonText: closeButtonText,
46690
+ hideModal: hideModal,
46691
+ isMobile: isMobile
46692
+ })].filter(function (button) {
46693
+ return button;
46694
+ }))))), children);
46658
46695
  };
46696
+ var ModalControlV2 = withWindowSize(Modal$2);
46659
46697
 
46660
46698
  var _excluded$A = ["version"];
46661
46699
  var Modal$3 = function Modal(_ref) {
46662
46700
  var _ref$version = _ref.version,
46663
46701
  version = _ref$version === void 0 ? "v1" : _ref$version,
46664
46702
  rest = _objectWithoutProperties(_ref, _excluded$A);
46665
- var ModalControl = version === "v1" ? Modal$1 : Modal$2;
46703
+ var ModalControl = version === "v1" ? Modal$1 : ModalControlV2;
46666
46704
  return /*#__PURE__*/React.createElement(ModalControl, rest);
46667
46705
  };
46668
46706