@loomhq/lens 10.57.0 → 10.57.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.
@@ -1,14 +1,16 @@
1
1
  import React from 'react';
2
2
  declare const ToastWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ToastWrapperProps, object>;
3
- declare const Toast: ({ children, isOpen, onCloseClick, zIndex, ...props }: ToastProps & React.ComponentProps<typeof ToastWrapper>) => JSX.Element;
3
+ declare const Toast: ({ children, isOpen, onCloseClick, zIndex, duration, ...props }: ToastProps & React.ComponentProps<typeof ToastWrapper>) => JSX.Element;
4
4
  declare type ToastProps = {
5
5
  children?: React.ReactNode;
6
6
  isOpen?: boolean;
7
7
  onCloseClick?: () => void;
8
8
  zIndex?: number;
9
+ duration?: 'short' | 'long';
9
10
  };
10
11
  declare type ToastWrapperProps = {
11
12
  zIndex?: number;
12
13
  isOpen?: boolean;
14
+ toastDuration?: number;
13
15
  };
14
16
  export default Toast;
@@ -15,7 +15,7 @@ import IconButton from '../icon-button/icon-button';
15
15
  import { SvgClose } from '../icon/available-icons';
16
16
  import { keyframes } from '@emotion/core';
17
17
  import styled from '@emotion/styled';
18
- const toastDuration = 3000;
18
+ const toastDurations = { short: 3000, long: 8000 };
19
19
  const enter = keyframes `
20
20
  from {
21
21
  opacity: 0;
@@ -49,8 +49,7 @@ const ToastWrapper = styled.div `
49
49
  right: var(--lns-space-small);
50
50
  padding: ${u(1.5)} var(--lns-space-medium) ${u(1.5)} var(--lns-space-large);
51
51
  z-index: ${props => props.zIndex};
52
- animation: ${enter} ${toastDuration}ms forwards;
53
-
52
+ animation: ${enter} ${props => props.toastDuration}ms forwards;
54
53
  @media (min-width: 800px) {
55
54
  right: var(--lns-space-medium);
56
55
  }
@@ -59,14 +58,15 @@ const ChildrenSection = styled.div `
59
58
  align-self: center;
60
59
  `;
61
60
  const Toast = (_a) => {
62
- var { children, isOpen, onCloseClick, zIndex = 1100 } = _a, props = __rest(_a, ["children", "isOpen", "onCloseClick", "zIndex"]);
61
+ var { children, isOpen, onCloseClick, zIndex = 1100, duration = 'short' } = _a, props = __rest(_a, ["children", "isOpen", "onCloseClick", "zIndex", "duration"]);
62
+ const toastDuration = toastDurations[duration];
63
63
  useEffect(() => {
64
64
  const timer = setTimeout(() => {
65
65
  onCloseClick();
66
66
  }, toastDuration);
67
67
  return () => clearTimeout(timer);
68
68
  }, [isOpen, onCloseClick]);
69
- return (React.createElement(React.Fragment, null, isOpen && (React.createElement(ToastWrapper, Object.assign({ "data-lens-theme": "dark", onClick: e => e.stopPropagation(), zIndex: zIndex, isOpen: isOpen }, props),
69
+ return (React.createElement(React.Fragment, null, isOpen && (React.createElement(ToastWrapper, Object.assign({ "data-lens-theme": "dark", onClick: e => e.stopPropagation(), zIndex: zIndex, isOpen: isOpen, toastDuration: toastDuration }, props),
70
70
  React.createElement(ChildrenSection, { "aria-live": "polite" }, children),
71
71
  onCloseClick && (React.createElement(IconButton, { altText: "Close", icon: React.createElement(SvgClose, null), onClick: onCloseClick }))))));
72
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.57.0",
3
+ "version": "10.57.1",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",