@autoguru/overdrive 4.1.12 → 4.1.15

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,24 @@
1
1
  # @autoguru/overdrive
2
2
 
3
+ ## 4.1.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 5293616: NumberInput: Changed event lister to passive TabList: Changed event
8
+ lister to passive useMedia: Changed event lister to passive
9
+
10
+ ## 4.1.14
11
+
12
+ ### Patch Changes
13
+
14
+ - 14ee239: Tooltip: Gets test size option
15
+
16
+ ## 4.1.13
17
+
18
+ ### Patch Changes
19
+
20
+ - 7dbf75b: Tooltip: Gets auto closing timeout option
21
+
3
22
  ## 4.1.12
4
23
 
5
24
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,UAAU,KACT,SAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;IAC/D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW,oTA0EvB,CAAC"}
1
+ {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,UAAU,KACT,SAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;IAC/D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW,oTA6EvB,CAAC"}
@@ -15,9 +15,9 @@ export const NumberInput = withEnhancedInput(({ field: { ref, ...incomingFieldPr
15
15
  let onWheelListener;
16
16
  let wheelListener;
17
17
  if (preventMouseWheel && inputRef?.current) {
18
- mouseWheelListener = inputRef.current.addEventListener('mousewheel', preventWheel);
19
- onWheelListener = inputRef.current.addEventListener('onwheel', preventWheel);
20
- wheelListener = inputRef.current.addEventListener('wheel', preventWheel);
18
+ mouseWheelListener = inputRef.current.addEventListener('mousewheel', preventWheel, { passive: true });
19
+ onWheelListener = inputRef.current.addEventListener('onwheel', preventWheel, { passive: true });
20
+ wheelListener = inputRef.current.addEventListener('wheel', preventWheel, { passive: true });
21
21
  }
22
22
  return () => {
23
23
  if (mouseWheelListener)
@@ -53,7 +53,7 @@ export const TabList = ({ children, stretch = false, scrollable = false, }) => {
53
53
  const handleResize = () => {
54
54
  updateScrollButtonState();
55
55
  };
56
- win.addEventListener('resize', handleResize);
56
+ win.addEventListener('resize', handleResize, { passive: true });
57
57
  return () => {
58
58
  win.removeEventListener('resize', handleResize);
59
59
  };
@@ -1,9 +1,13 @@
1
1
  import { FunctionComponent, ReactElement } from 'react';
2
2
  import { EAlignment } from '../Positioner/alignment';
3
+ declare type ToolTipSize = 'medium' | 'large';
3
4
  export interface Props {
5
+ size?: ToolTipSize;
4
6
  label: string;
5
7
  alignment?: EAlignment;
6
8
  children: ReactElement;
9
+ closeAfter?: number;
7
10
  }
8
11
  export declare const Tooltip: FunctionComponent<Props>;
12
+ export {};
9
13
  //# 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,EAIN,iBAAiB,EACjB,YAAY,EAKZ,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,aAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AACtC,MAAM,WAAW,KAAK;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAiE5C,CAAC"}
@@ -1,11 +1,15 @@
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
+ const sizeMap = {
9
+ medium: '2',
10
+ large: '3',
11
+ };
12
+ export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, size = 'medium', closeAfter = null, }) => {
9
13
  const [isOpen, setIsOpen] = useState(false);
10
14
  const childRef = useRef(null);
11
15
  const triggerRef = useRef(null);
@@ -21,6 +25,12 @@ export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, }) => {
21
25
  setIsOpen(false);
22
26
  }, 1e3 / 2);
23
27
  }, [setIsOpen]);
28
+ useEffect(() => {
29
+ let timeout;
30
+ if (isOpen && typeof closeAfter === 'number')
31
+ timeout = setTimeout(() => setIsOpen(false), closeAfter);
32
+ return () => (timeout ? clearTimeout(timeout) : void 0);
33
+ }, [closeAfter, isOpen]);
24
34
  return (React.createElement(React.Fragment, null,
25
35
  cloneElement(Children.only(children), {
26
36
  ref: triggerRef,
@@ -28,6 +38,6 @@ export const Tooltip = ({ alignment = EAlignment.RIGHT, label, children, }) => {
28
38
  onMouseLeave: leaveHandler,
29
39
  }),
30
40
  React.createElement(Positioner, { triggerRef: triggerRef, alignment: alignment, isOpen: isOpen },
31
- React.createElement(Box, { ref: childRef, className: styles.root, width: "full", pointerEvents: "none", userSelect: "none", overflow: "hidden", borderRadius: "1", boxShadow: "4", backgroundColour: "gray900", padding: "4" },
32
- React.createElement(Text, { colour: "white" }, label)))));
41
+ React.createElement(Box, { ref: childRef, className: styles.root, width: "full", pointerEvents: "none", userSelect: "none", overflow: "hidden", borderRadius: "1", boxShadow: "4", backgroundColour: "gray900", paddingY: "2", paddingX: "3" },
42
+ React.createElement(Text, { size: sizeMap[size], colour: "white" }, label)))));
33
43
  };
@@ -10,6 +10,7 @@ import * as React from 'react';
10
10
  import { EAlignment } from "../Positioner/alignment.js";
11
11
  import { Tooltip } from "./index.js";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ const sizeScale = ['medium', 'large'];
13
14
  export default {
14
15
  title: 'Components/Tooltip',
15
16
  decorators: [Story => _jsx("div", {
@@ -31,6 +32,22 @@ export default {
31
32
  control: {
32
33
  type: 'select'
33
34
  }
35
+ },
36
+ size: {
37
+ options: sizeScale,
38
+ defaultValue: void 0,
39
+ control: {
40
+ type: 'select'
41
+ }
42
+ },
43
+ label: {
44
+ defaultValue: ''
45
+ },
46
+ closeAfter: {
47
+ defaultValue: EAlignment.RIGHT,
48
+ control: {
49
+ type: 'number'
50
+ }
34
51
  }
35
52
  }
36
53
  };
@@ -45,13 +62,27 @@ const Template = args => _jsx(Tooltip, _objectSpread(_objectSpread({}, args), {}
45
62
  }));
46
63
 
47
64
  const standardProps = {
48
- label: 'Im the tooltip body'
65
+ label: 'Im the tooltip body',
66
+ closeAfter: null
49
67
  };
50
68
  export const standard = Template.bind(standardProps);
51
69
  standard.args = standardProps;
70
+ const withAtuCloseProps = {
71
+ label: 'I will automatically close after 5 seconds',
72
+ closeAfter: 5e3
73
+ };
74
+ export const withAutoClose = Template.bind(withAtuCloseProps);
75
+ withAutoClose.args = withAtuCloseProps;
52
76
  const withLongTextProps = {
53
77
  label: 'Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.',
54
78
  alignment: EAlignment.BOTTOM
55
79
  };
56
80
  export const withLongText = Template.bind(withLongTextProps);
57
- withLongText.args = withLongTextProps;
81
+ withLongText.args = withLongTextProps;
82
+ const withSmallTextSizePropsProps = {
83
+ label: 'Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.',
84
+ alignment: EAlignment.BOTTOM,
85
+ size: 'large'
86
+ };
87
+ export const withLargeTextSize = Template.bind(withSmallTextSizePropsProps);
88
+ withLargeTextSize.args = withSmallTextSizePropsProps;
@@ -21,7 +21,7 @@ export const useMedia = (queries, fallbackCase = false) => {
21
21
  return newState;
22
22
  });
23
23
  };
24
- matcher.addEventListener('change', handler);
24
+ matcher.addEventListener('change', handler, { passive: true });
25
25
  return () => matcher.removeEventListener('change', handler);
26
26
  });
27
27
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.1.12",
3
+ "version": "4.1.15",
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",