@autoguru/overdrive 4.1.12 → 4.1.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @autoguru/overdrive
2
2
 
3
+ ## 4.1.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 7dbf75b: Tooltip: Gets auto closing timeout option
8
+
3
9
  ## 4.1.12
4
10
 
5
11
  ### Patch Changes
@@ -4,6 +4,7 @@ export interface Props {
4
4
  label: string;
5
5
  alignment?: EAlignment;
6
6
  children: ReactElement;
7
+ closeAfter?: number;
7
8
  }
8
9
  export declare const Tooltip: FunctionComponent<Props>;
9
10
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../lib/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAGN,iBAAiB,EACjB,YAAY,EAIZ,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,MAAM,WAAW,KAAK;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAoD5C,CAAC"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../lib/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAGN,iBAAiB,EACjB,YAAY,EAKZ,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,MAAM,WAAW,KAAK;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,KAAK,CA6D5C,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import { Children, cloneElement, useCallback, useRef, useState, } from 'react';
2
+ import { Children, cloneElement, useCallback, useEffect, useRef, useState, } from 'react';
3
3
  import { Box } from '../Box';
4
4
  import { Positioner } from '../Positioner';
5
5
  import { EAlignment } from '../Positioner/alignment';
6
6
  import { Text } from '../Text';
7
7
  import * as styles from './Tooltip.css';
8
- export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, }) => {
8
+ export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, closeAfter = null, }) => {
9
9
  const [isOpen, setIsOpen] = useState(false);
10
10
  const childRef = useRef(null);
11
11
  const triggerRef = useRef(null);
@@ -21,6 +21,12 @@ export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, }) => {
21
21
  setIsOpen(false);
22
22
  }, 1e3 / 2);
23
23
  }, [setIsOpen]);
24
+ useEffect(() => {
25
+ let timeout;
26
+ if (isOpen && typeof closeAfter === 'number')
27
+ timeout = setTimeout(() => setIsOpen(false), closeAfter);
28
+ return () => (timeout ? clearTimeout(timeout) : void 0);
29
+ }, [closeAfter, isOpen]);
24
30
  return (React.createElement(React.Fragment, null,
25
31
  cloneElement(Children.only(children), {
26
32
  ref: triggerRef,
@@ -31,6 +31,15 @@ export default {
31
31
  control: {
32
32
  type: 'select'
33
33
  }
34
+ },
35
+ label: {
36
+ defaultValue: ''
37
+ },
38
+ closeAfter: {
39
+ defaultValue: EAlignment.RIGHT,
40
+ control: {
41
+ type: 'number'
42
+ }
34
43
  }
35
44
  }
36
45
  };
@@ -45,10 +54,17 @@ const Template = args => _jsx(Tooltip, _objectSpread(_objectSpread({}, args), {}
45
54
  }));
46
55
 
47
56
  const standardProps = {
48
- label: 'Im the tooltip body'
57
+ label: 'Im the tooltip body',
58
+ closeAfter: null
49
59
  };
50
60
  export const standard = Template.bind(standardProps);
51
61
  standard.args = standardProps;
62
+ const withAtuCloseProps = {
63
+ label: 'I will automatically close after 5 seconds',
64
+ closeAfter: 5e3
65
+ };
66
+ export const withAutoClose = Template.bind(withAtuCloseProps);
67
+ withAutoClose.args = withAtuCloseProps;
52
68
  const withLongTextProps = {
53
69
  label: 'Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.',
54
70
  alignment: EAlignment.BOTTOM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.1.12",
3
+ "version": "4.1.13",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",