@autoguru/overdrive 4.1.11 → 4.1.14
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 +18 -0
- package/dist/components/Button/Button.css.d.ts +1 -0
- package/dist/components/Button/Button.css.d.ts.map +1 -1
- package/dist/components/Button/Button.css.js +3 -0
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +6 -2
- package/dist/components/Button/stories.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +14 -4
- package/dist/components/Tooltip/stories.js +33 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @autoguru/overdrive
|
|
2
2
|
|
|
3
|
+
## 4.1.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 14ee239: Tooltip: Gets test size option
|
|
8
|
+
|
|
9
|
+
## 4.1.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7dbf75b: Tooltip: Gets auto closing timeout option
|
|
14
|
+
|
|
15
|
+
## 4.1.12
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 834f5bd: Button: Keep its layout unchanged in loading mode
|
|
20
|
+
|
|
3
21
|
## 4.1.11
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.css.d.ts","sourceRoot":"","sources":["../../../lib/components/Button/Button.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAQf,CAAC;AAEH,eAAO,MAAM,IAAI,QAIf,CAAC;AAEH,eAAO,MAAM,OAAO,QAElB,CAAC;AAEH,eAAO,MAAM,OAAO,QAElB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAGnB,CAAC;AAEH,eAAO,MAAM,OAAO,QAElB,CAAC;AAIH,eAAO,MAAM,IAAI;;;CA2BhB,CAAC;AACF,eAAO,MAAM,OAAO;;;;CAgBnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAwCzB,CAAC;AAEF,eAAO,MAAM,OAAO;;;CAOnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAqCzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Button.css.d.ts","sourceRoot":"","sources":["../../../lib/components/Button/Button.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAQf,CAAC;AAEH,eAAO,MAAM,IAAI,QAIf,CAAC;AAEH,eAAO,MAAM,aAAa,QAExB,CAAC;AACH,eAAO,MAAM,OAAO,QAElB,CAAC;AAEH,eAAO,MAAM,OAAO,QAElB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAGnB,CAAC;AAEH,eAAO,MAAM,OAAO,QAElB,CAAC;AAIH,eAAO,MAAM,IAAI;;;CA2BhB,CAAC;AACF,eAAO,MAAM,OAAO;;;;CAgBnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAwCzB,CAAC;AAEF,eAAO,MAAM,OAAO;;;CAOnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAqCzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../lib/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,cAAc,EACd,oBAAoB,EAIpB,WAAW,EAGX,YAAY,EAEZ,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAEvC,aAAK,eAAe,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAE/D,aAAK,eAAe,G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C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,OAAO,CAAC;CACtC;AAqBD,eAAO,MAAM,MAAM,iFAkJlB,CAAC"}
|
|
@@ -51,9 +51,13 @@ export const Button = forwardRef(({ children, className = '', disabled = false,
|
|
|
51
51
|
}, className),
|
|
52
52
|
ref,
|
|
53
53
|
};
|
|
54
|
-
const
|
|
54
|
+
const buttonContents = useMemo(() => (React.createElement(React.Fragment, null, isSingleIconChild && maybeIconProps ? (React.createElement(Icon, { size: maybeIconProps.size ?? size === 'small'
|
|
55
55
|
? 'small'
|
|
56
|
-
: 'medium', ...maybeIconProps })) : (children)));
|
|
56
|
+
: 'medium', ...maybeIconProps })) : (children))), [maybeIconProps, isSingleIconChild, children, size]);
|
|
57
|
+
const child = isLoading ? (React.createElement(Box, { display: "flex", justifyContent: "center", position: "relative", alignItems: "center", width: "full", height: "full" },
|
|
58
|
+
React.createElement(Box, { position: "absolute", alignItems: "center", justifyContent: "center", display: "flex", width: "full", height: "full" },
|
|
59
|
+
React.createElement(ProgressSpinner, { className: styles.spinner, colour: getSpinnerColour(variant, minimal) })),
|
|
60
|
+
React.createElement(Box, { width: "full", height: "full", className: [styles.body, styles.hiddenContent] }, buttonContents))) : (React.createElement(Box, { height: "full", alignItems: "center", justifyContent: "center", className: styles.body }, buttonContents));
|
|
57
61
|
return isValidElement(Component)
|
|
58
62
|
?
|
|
59
63
|
cloneElement(Component, { ref, ...props }, child)
|
|
@@ -62,7 +62,7 @@ const TemplateMulti = args => _jsxs(_Fragment, {
|
|
|
62
62
|
children: _jsx(Button, _objectSpread(_objectSpread({
|
|
63
63
|
isLoading: true
|
|
64
64
|
}, args), {}, {
|
|
65
|
-
children: "
|
|
65
|
+
children: "A very very very long button Label"
|
|
66
66
|
}))
|
|
67
67
|
}), _jsx(Column, {
|
|
68
68
|
children: _jsx(Button, _objectSpread(_objectSpread({
|
|
@@ -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,
|
|
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
|
-
|
|
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",
|
|
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;
|