@thecb/components 9.2.0-beta.6 → 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.cjs.js CHANGED
@@ -25586,6 +25586,53 @@ var useOutsideClickHook = function useOutsideClickHook(handler) {
25586
25586
  return ref;
25587
25587
  };
25588
25588
 
25589
+ var initialToastState = {
25590
+ isOpen: false,
25591
+ variant: "",
25592
+ message: ""
25593
+ };
25594
+
25595
+ var useToastNotification = function useToastNotification() {
25596
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
25597
+ _ref$timeout = _ref.timeout,
25598
+ timeout = _ref$timeout === void 0 ? 5000 : _ref$timeout;
25599
+
25600
+ var _useState = React.useState(initialToastState),
25601
+ _useState2 = _slicedToArray(_useState, 2),
25602
+ toastState = _useState2[0],
25603
+ setToastState = _useState2[1];
25604
+
25605
+ React.useEffect(function () {
25606
+ if (toastState.isOpen) {
25607
+ setTimeout(function () {
25608
+ setToastState(initialToastState);
25609
+ }, timeout);
25610
+ }
25611
+ }, [timeout, toastState.isOpen]);
25612
+
25613
+ var showToast = function showToast(_ref2) {
25614
+ var message = _ref2.message,
25615
+ variant = _ref2.variant;
25616
+ return setToastState({
25617
+ isOpen: true,
25618
+ variant: variant,
25619
+ message: message
25620
+ });
25621
+ };
25622
+
25623
+ var hideToast = function hideToast() {
25624
+ return setToastState(initialToastState);
25625
+ };
25626
+
25627
+ return {
25628
+ isToastOpen: toastState.isOpen,
25629
+ toastVariant: toastState.variant,
25630
+ toastMessage: toastState.message,
25631
+ showToast: showToast,
25632
+ hideToast: hideToast
25633
+ };
25634
+ };
25635
+
25589
25636
 
25590
25637
 
25591
25638
  var index$4 = /*#__PURE__*/Object.freeze({
@@ -25594,7 +25641,8 @@ var index$4 = /*#__PURE__*/Object.freeze({
25594
25641
  general: general,
25595
25642
  theme: themeUtils,
25596
25643
  useFocusInvalidInput: useFocusInvalidInput,
25597
- useOutsideClick: useOutsideClickHook
25644
+ useOutsideClick: useOutsideClickHook,
25645
+ useToastNotification: useToastNotification
25598
25646
  });
25599
25647
 
25600
25648
  var hoverColor$4 = "#116285";