@autoguru/overdrive 4.3.0 → 4.3.3
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 +19 -0
- package/dist/components/NumberBubble/NumberBubble.d.ts +1 -0
- package/dist/components/NumberBubble/NumberBubble.d.ts.map +1 -1
- package/dist/components/NumberBubble/NumberBubble.js +20 -4
- package/dist/components/NumberBubble/stories.js +7 -6
- package/dist/components/NumberInput/NumberInput.js +3 -3
- package/dist/components/NumberInput/stories.js +0 -5
- package/dist/components/TextAreaInput/stories.js +1 -7
- package/dist/components/TextInput/stories.js +0 -5
- package/dist/components/private/InputBase/withEnhancedInput.css.js +1 -1
- package/dist/themes/base/tokens.js +2 -2
- package/dist/themes/flat_red/tokens.js +3 -3
- package/dist/utils/number.d.ts +6 -0
- package/dist/utils/number.d.ts.map +1 -0
- package/dist/utils/number.js +25 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @autoguru/overdrive
|
|
2
2
|
|
|
3
|
+
## 4.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 33c6c71: Inputs: Get theme standard line height
|
|
8
|
+
- 28252fb: NumberInput: Fixes paasive events being prevented
|
|
9
|
+
|
|
10
|
+
## 4.3.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 5930dd5: NumberBubble: Suppoertsa larger numbers
|
|
15
|
+
|
|
16
|
+
## 4.3.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 3b81bdc: Button: Fixes warning and information text colours
|
|
21
|
+
|
|
3
22
|
## 4.3.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -3,6 +3,7 @@ import { Box } from '../Box';
|
|
|
3
3
|
import { Text } from '../Text';
|
|
4
4
|
export interface Props extends Omit<ComponentProps<typeof Box>, 'borderRadius' | 'position' | 'padding'> {
|
|
5
5
|
value: number;
|
|
6
|
+
rawNumbers?: boolean;
|
|
6
7
|
textColour?: ComponentProps<typeof Text>['colour'];
|
|
7
8
|
}
|
|
8
9
|
export declare const NumberBubble: FunctionComponent<Props>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberBubble.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberBubble/NumberBubble.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"NumberBubble.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberBubble/NumberBubble.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAGnE,OAAO,EAAE,GAAG,EAAgB,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI/B,MAAM,WAAW,KAChB,SAAQ,IAAI,CACX,cAAc,CAAC,OAAO,GAAG,CAAC,EAC1B,cAAc,GAAG,UAAU,GAAG,SAAS,CACvC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;CACnD;AAaD,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,KAAK,CAkCjD,CAAC"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { toPrettyBigNumber } from '../../utils/number';
|
|
3
5
|
import { Box, useBoxStyles } from '../Box';
|
|
4
6
|
import { Text } from '../Text';
|
|
5
7
|
import * as styles from './NumberBubble.css';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const valuePaddingMap = {
|
|
9
|
+
SMALL: '2',
|
|
10
|
+
MEDIUM: '3',
|
|
11
|
+
LARGE: '4',
|
|
12
|
+
X_LARGE: '5',
|
|
13
|
+
};
|
|
14
|
+
export const NumberBubble = ({ value, textColour = 'white', rawNumbers = false, ...boxProps }) => {
|
|
15
|
+
const size = useMemo(() => {
|
|
16
|
+
if (value > 9 && value < 100)
|
|
17
|
+
return 'MEDIUM';
|
|
18
|
+
if (value > 99 && value < 9999)
|
|
19
|
+
return 'LARGE';
|
|
20
|
+
if (value >= 9999)
|
|
21
|
+
return 'LARGE';
|
|
22
|
+
return 'SMALL';
|
|
23
|
+
}, [value]);
|
|
24
|
+
return (React.createElement(Box, { borderRadius: "full", backgroundColour: "gray900", display: "inlineBlock", position: "relative", padding: valuePaddingMap[size], ...boxProps },
|
|
9
25
|
React.createElement(Text, { size: "2", strong: true, className: clsx(styles.bubbleText, useBoxStyles({
|
|
10
26
|
position: 'absolute',
|
|
11
|
-
})), colour: textColour }, value)));
|
|
27
|
+
})), colour: textColour }, rawNumbers ? value : toPrettyBigNumber(value))));
|
|
12
28
|
};
|
|
@@ -7,15 +7,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import { boxArgTypes } from "../Box/argTypes.js";
|
|
11
10
|
import { NumberBubble } from "./index.js";
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
export default {
|
|
14
13
|
title: 'Foundation/Typography/NumberBubble',
|
|
15
|
-
component: NumberBubble
|
|
16
|
-
argTypes: {
|
|
17
|
-
paddingX: boxArgTypes.paddingX
|
|
18
|
-
}
|
|
14
|
+
component: NumberBubble
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
const template = args => _jsx(NumberBubble, _objectSpread({}, args));
|
|
@@ -24,4 +20,9 @@ const standardProps = {
|
|
|
24
20
|
value: 0
|
|
25
21
|
};
|
|
26
22
|
export const standard = template.bind(standardProps);
|
|
27
|
-
standard.args = standardProps;
|
|
23
|
+
standard.args = standardProps;
|
|
24
|
+
const bigNumberProps = {
|
|
25
|
+
value: 2345
|
|
26
|
+
};
|
|
27
|
+
export const bigNumber = template.bind(bigNumberProps);
|
|
28
|
+
bigNumber.args = bigNumberProps;
|
|
@@ -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, { passive:
|
|
19
|
-
onWheelListener = inputRef.current.addEventListener('onwheel', preventWheel, { passive:
|
|
20
|
-
wheelListener = inputRef.current.addEventListener('wheel', preventWheel, { passive:
|
|
18
|
+
mouseWheelListener = inputRef.current.addEventListener('mousewheel', preventWheel, { passive: false });
|
|
19
|
+
onWheelListener = inputRef.current.addEventListener('onwheel', preventWheel, { passive: false });
|
|
20
|
+
wheelListener = inputRef.current.addEventListener('wheel', preventWheel, { passive: false });
|
|
21
21
|
}
|
|
22
22
|
return () => {
|
|
23
23
|
if (mouseWheelListener)
|
|
@@ -21,13 +21,7 @@ export default {
|
|
|
21
21
|
};
|
|
22
22
|
const defaultValue = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vitae pulvinar odio. Duis laoreet lacus vel consequat congue. Ut euismod enim non eros lacinia mollis. Vestibulum libero quam, aliquet non justo laoreet, egestas molestie ante. Quisque urna leo, consectetur id dui aliquet, placerat iaculis augue. Pellentesque sed vestibulum augue, quis porta lectus.';
|
|
23
23
|
const defaultPlaceholder = 'Tell us about your car.';
|
|
24
|
-
const argTypes = {
|
|
25
|
-
value: {
|
|
26
|
-
control: {
|
|
27
|
-
type: 'string'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
24
|
+
const argTypes = {};
|
|
31
25
|
|
|
32
26
|
const Template = args => _jsx(TextAreaInput, _objectSpread({}, args));
|
|
33
27
|
|
|
@@ -18,7 +18,7 @@ export const input = {
|
|
|
18
18
|
background: 'transparent',
|
|
19
19
|
outline: 'none',
|
|
20
20
|
fontSize: vars.typography.size['4'].fontSize,
|
|
21
|
-
lineHeight:
|
|
21
|
+
lineHeight: vars.typography.size['4'].lineHeight,
|
|
22
22
|
height: vars.space['8'],
|
|
23
23
|
padding: `calc(((${vars.space['8']} - ${vars.typography.size['4'].fontSize}) / 2) - 3px) calc(${vars.space['4']} - 1px)`,
|
|
24
24
|
selectors: {
|
|
@@ -139,7 +139,7 @@ export const tokens = {
|
|
|
139
139
|
mild: colours.yellow['100'],
|
|
140
140
|
strong: colours.yellow['900'],
|
|
141
141
|
},
|
|
142
|
-
foreground:
|
|
142
|
+
foreground: white,
|
|
143
143
|
border: colours.yellow['900'],
|
|
144
144
|
},
|
|
145
145
|
neutral: {
|
|
@@ -166,7 +166,7 @@ export const tokens = {
|
|
|
166
166
|
mild: colours.blue['200'],
|
|
167
167
|
strong: colours.blue['900'],
|
|
168
168
|
},
|
|
169
|
-
foreground:
|
|
169
|
+
foreground: white,
|
|
170
170
|
border: colours.blue['900'],
|
|
171
171
|
},
|
|
172
172
|
},
|
|
@@ -119,7 +119,7 @@ export const tokens = {
|
|
|
119
119
|
mild: colours.yellow['100'],
|
|
120
120
|
strong: colours.yellow['900'],
|
|
121
121
|
},
|
|
122
|
-
foreground:
|
|
122
|
+
foreground: white,
|
|
123
123
|
border: colours.yellow['900'],
|
|
124
124
|
},
|
|
125
125
|
neutral: {
|
|
@@ -137,7 +137,7 @@ export const tokens = {
|
|
|
137
137
|
mild: colours.green['100'],
|
|
138
138
|
strong: colours.green['900'],
|
|
139
139
|
},
|
|
140
|
-
foreground:
|
|
140
|
+
foreground: white,
|
|
141
141
|
border: colours.green['900'],
|
|
142
142
|
},
|
|
143
143
|
information: {
|
|
@@ -146,7 +146,7 @@ export const tokens = {
|
|
|
146
146
|
mild: colours.blue['100'],
|
|
147
147
|
strong: colours.blue['900'],
|
|
148
148
|
},
|
|
149
|
-
foreground:
|
|
149
|
+
foreground: white,
|
|
150
150
|
border: colours.blue['900'],
|
|
151
151
|
},
|
|
152
152
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../lib/utils/number.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QACtB,MAAM,KACT;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAoBrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WACrB,MAAM,8BAEZ,MAMF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const bigNumFormatter = (num) => {
|
|
2
|
+
if (num < 1e3)
|
|
3
|
+
return {
|
|
4
|
+
value: num,
|
|
5
|
+
descriptor: '',
|
|
6
|
+
};
|
|
7
|
+
else if (num < 1e6)
|
|
8
|
+
return {
|
|
9
|
+
value: num / 1e3,
|
|
10
|
+
descriptor: 'K',
|
|
11
|
+
};
|
|
12
|
+
else {
|
|
13
|
+
return {
|
|
14
|
+
value: num / 1e6,
|
|
15
|
+
descriptor: 'M',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const toPrettyBigNumber = (number, fractionDigits = 1) => {
|
|
20
|
+
const formatChunks = bigNumFormatter(number);
|
|
21
|
+
const value = Number.isInteger(formatChunks.value)
|
|
22
|
+
? formatChunks.value
|
|
23
|
+
: formatChunks.value.toFixed(fractionDigits);
|
|
24
|
+
return `${value}${formatChunks.descriptor}`;
|
|
25
|
+
};
|