@thecb/components 9.2.0-beta.5 → 9.2.0-beta.7

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.d.ts CHANGED
@@ -441,6 +441,11 @@ interface ErrorMessageDictionary {
441
441
  [fieldName: string]: string;
442
442
  }
443
443
 
444
+ enum ToastVariants {
445
+ ERROR = "error",
446
+ SUCCESS = "success",
447
+ }
448
+
444
449
  interface FormInputProps {
445
450
  extraStyles?: string;
446
451
  field?: Field;
@@ -1066,6 +1071,16 @@ declare const RadioGroup: React.FC<Expand<RadioGroupProps> &
1066
1071
  React.HTMLAttributes<HTMLElement>>;
1067
1072
 
1068
1073
  interface ToastNotificationProps {
1074
+ variant?: string;
1075
+ message: string;
1076
+ toastOpen: boolean;
1077
+ closeToastNotification: (event?: React.MouseEvent<HTMLElement>) => void;
1078
+ extraStyles?: string;
1079
+ minWidth?: string;
1080
+ maxWidth?: string;
1081
+ height?: string;
1082
+ childGap?: string;
1083
+ backgroundColor?: string;
1069
1084
  }
1070
1085
 
1071
1086
  declare const ToastNotification: React.FC<Expand<ToastNotificationProps> &
@@ -1085,5 +1100,5 @@ interface DefaultPageTemplateProps {
1085
1100
  declare const DefaultPageTemplate: React.FC<Expand<DefaultPageTemplateProps> &
1086
1101
  React.HTMLAttributes<HTMLElement>>;
1087
1102
 
1088
- export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ToastNotification, ToastNotificationProps, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants };
1103
+ export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ToastNotification, ToastNotificationProps, ToastVariants, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants };
1089
1104
  //# sourceMappingURL=index.d.ts.map
package/dist/index.esm.js CHANGED
@@ -25578,6 +25578,53 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
25578
25578
  return ref;
25579
25579
  };
25580
25580
 
25581
+ var initialToastState = {
25582
+ isOpen: false,
25583
+ variant: "",
25584
+ message: ""
25585
+ };
25586
+
25587
+ var useToastNotification = function useToastNotification() {
25588
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25589
+ _ref$timeout = _ref.timeout,
25590
+ timeout = _ref$timeout === void 0 ? 5000 : _ref$timeout;
25591
+
25592
+ var _useState = useState(initialToastState),
25593
+ _useState2 = _slicedToArray(_useState, 2),
25594
+ toastState = _useState2[0],
25595
+ setToastState = _useState2[1];
25596
+
25597
+ useEffect$1(function () {
25598
+ if (toastState.isOpen) {
25599
+ setTimeout(function () {
25600
+ setToastState(initialToastState);
25601
+ }, timeout);
25602
+ }
25603
+ }, [timeout, toastState.isOpen]);
25604
+
25605
+ var showToast = function showToast(_ref2) {
25606
+ var message = _ref2.message,
25607
+ variant = _ref2.variant;
25608
+ return setToastState({
25609
+ isOpen: true,
25610
+ variant: variant,
25611
+ message: message
25612
+ });
25613
+ };
25614
+
25615
+ var hideToast = function hideToast() {
25616
+ return setToastState(initialToastState);
25617
+ };
25618
+
25619
+ return {
25620
+ isToastOpen: toastState.isOpen,
25621
+ toastVariant: toastState.variant,
25622
+ toastMessage: toastState.message,
25623
+ showToast: showToast,
25624
+ hideToast: hideToast
25625
+ };
25626
+ };
25627
+
25581
25628
 
25582
25629
 
25583
25630
  var index$4 = /*#__PURE__*/Object.freeze({
@@ -25586,7 +25633,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
25586
25633
  general: general,
25587
25634
  theme: themeUtils,
25588
25635
  useFocusInvalidInput: useFocusInvalidInput,
25589
- useOutsideClick: useOutsideClickHook
25636
+ useOutsideClick: useOutsideClickHook,
25637
+ useToastNotification: useToastNotification
25590
25638
  });
25591
25639
 
25592
25640
  var hoverColor$4 = "#116285";
@@ -50290,8 +50338,12 @@ var VARIANTS = {
50290
50338
  };
50291
50339
 
50292
50340
  var ToastNotification = function ToastNotification(_ref) {
50293
- var _ref$message = _ref.message,
50341
+ var _ref$variant = _ref.variant,
50342
+ variant = _ref$variant === void 0 ? VARIANTS.SUCCESS : _ref$variant,
50343
+ _ref$message = _ref.message,
50294
50344
  message = _ref$message === void 0 ? "" : _ref$message,
50345
+ toastOpen = _ref.toastOpen,
50346
+ closeToastNotification = _ref.closeToastNotification,
50295
50347
  extraStyles = _ref.extraStyles,
50296
50348
  _ref$minWidth = _ref.minWidth,
50297
50349
  minWidth = _ref$minWidth === void 0 ? "112px" : _ref$minWidth,
@@ -50301,10 +50353,6 @@ var ToastNotification = function ToastNotification(_ref) {
50301
50353
  height = _ref$height === void 0 ? "56px" : _ref$height,
50302
50354
  _ref$childGap = _ref.childGap,
50303
50355
  childGap = _ref$childGap === void 0 ? "1rem" : _ref$childGap,
50304
- closeToastNotification = _ref.closeToastNotification,
50305
- toastOpen = _ref.toastOpen,
50306
- _ref$variant = _ref.variant,
50307
- variant = _ref$variant === void 0 ? VARIANTS.SUCCESS : _ref$variant,
50308
50356
  backgroundColor = _ref.backgroundColor;
50309
50357
  return /*#__PURE__*/React.createElement(Box, {
50310
50358
  onClick: closeToastNotification,