@autoguru/overdrive 4.26.1 → 4.26.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/dist/components/DropDown/DropDown.d.ts.map +1 -1
- package/dist/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/components/EditableText/EditableText.js +14 -5
- package/dist/components/NumberInput/stories.js +1 -0
- package/dist/components/private/InputBase/NotchedBase.css.d.ts +1 -0
- package/dist/components/private/InputBase/NotchedBase.css.d.ts.map +1 -1
- package/dist/components/private/InputBase/NotchedBase.css.js +5 -1
- package/dist/components/private/InputBase/NotchedBase.d.ts.map +1 -1
- package/dist/components/private/InputBase/NotchedBase.js +10 -21
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,cAAc,
|
|
1
|
+
{"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EACN,cAAc,EACd,iBAAiB,EAEjB,SAAS,EAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOnC,KAAK,WAAW,GAAG,IAAI,CACtB,cAAc,CAAC,OAAO,MAAM,CAAC,EAC7B,IAAI,GAAG,UAAU,GAAG,SAAS,CAC7B,CAAC;AACF,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;AAEpE,MAAM,WAAW,KAAM,SAAQ,WAAW,EAAE,WAAW;IACtD,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAsC7C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEN,cAAc,EAEd,mBAAmB,EAKnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAK9C,KAAK,QAAQ,GAAG,IAAI,CACnB,cAAc,CAAC,OAAO,GAAG,CAAC,EAC1B,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAC9C,CAAC;AACF,KAAK,SAAS,GAAG,IAAI,CACpB,cAAc,CAAC,OAAO,IAAI,CAAC,EAC3B,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAChD,CAAC;AACF,KAAK,UAAU,GAAG,IAAI,CACrB,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,OAAO,GACP,IAAI,GACJ,WAAW,GACX,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,MAAM,SAAS,GACf,MAAM,QAAQ,CAChB,CAAC;AAEF,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,UAAU,EAAE,QAAQ;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACzC;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAClC,eAAO,MAAM,YAAY,iFAmGxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
const _excluded = ["is", "colour", "size", "display", "value", "onFocus", "onBlur", "onKeyDown", "onModeChange", "tabIndex"];
|
|
5
|
+
const _excluded = ["is", "colour", "size", "display", "value", "onFocus", "onBlur", "onKeyDown", "onModeChange", "tabIndex", "onChange"];
|
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
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
|
import clsx from 'clsx';
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import { forwardRef, useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
11
11
|
import { Box } from "../Box/index.js";
|
|
12
12
|
import { Text, useTextStyles } from "../Text/index.js";
|
|
13
13
|
import * as inputStyles from "../private/InputBase/withEnhancedInput.css.js";
|
|
@@ -25,17 +25,25 @@ export const EditableText = forwardRef((_ref, ref) => {
|
|
|
25
25
|
onBlur,
|
|
26
26
|
onKeyDown,
|
|
27
27
|
onModeChange,
|
|
28
|
-
tabIndex = 0
|
|
28
|
+
tabIndex = 0,
|
|
29
|
+
onChange: incomingOnChange
|
|
29
30
|
} = _ref,
|
|
30
31
|
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
31
32
|
const textRef = useRef(null);
|
|
32
33
|
const [mode, setMode] = useState('TEXT');
|
|
34
|
+
const [inputValue, setInputValue] = useState(value);
|
|
33
35
|
const onRequestModeChange = newMode => {
|
|
34
36
|
setMode(newMode);
|
|
35
37
|
if (typeof onModeChange === 'function') {
|
|
36
38
|
onModeChange(newMode);
|
|
37
39
|
}
|
|
38
40
|
};
|
|
41
|
+
const onChange = useCallback(e => {
|
|
42
|
+
if (mode === 'INPUT') {
|
|
43
|
+
setInputValue(e.currentTarget.value);
|
|
44
|
+
}
|
|
45
|
+
if (typeof incomingOnChange === 'function') incomingOnChange(e);
|
|
46
|
+
}, [incomingOnChange, mode, value]);
|
|
39
47
|
const textStyles = useTextStyles({
|
|
40
48
|
is,
|
|
41
49
|
colour,
|
|
@@ -72,8 +80,9 @@ export const EditableText = forwardRef((_ref, ref) => {
|
|
|
72
80
|
is: "input"
|
|
73
81
|
}, inputProps), {}, {
|
|
74
82
|
autoFocus: true,
|
|
75
|
-
value:
|
|
83
|
+
value: inputValue,
|
|
76
84
|
className: clsx(textStyles, inputStyles.input.itself.root),
|
|
85
|
+
onChange: onChange,
|
|
77
86
|
style: {
|
|
78
87
|
width
|
|
79
88
|
}
|
|
@@ -86,7 +95,7 @@ export const EditableText = forwardRef((_ref, ref) => {
|
|
|
86
95
|
className: clsx(textStyles, styles.text, {
|
|
87
96
|
[styles.textHidden]: mode === 'INPUT'
|
|
88
97
|
}),
|
|
89
|
-
children: value
|
|
98
|
+
children: mode === 'INPUT' ? inputValue : value
|
|
90
99
|
})]
|
|
91
100
|
});
|
|
92
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotchedBase.css.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.css.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NotchedBase.css.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,QAEf,CAAC;AAeH,eAAO,MAAM,mBAAmB,QAG9B,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;;;;CAuCnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;CAmCzB,CAAC;AACF,eAAO,MAAM,aAAa;;;CAmCzB,CAAC;AAEF,eAAO,MAAM,WAAW,gDAWtB,CAAC;AAyBH,eAAO,MAAM,oBAAoB,KAiDhC,CAAC"}
|
|
@@ -4,6 +4,7 @@ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
|
4
4
|
__vanilla_filescope__.setFileScope("lib/components/private/InputBase/NotchedBase.css.ts", "@autoguru/overdrive");
|
|
5
5
|
import { style, styleVariants } from '@vanilla-extract/css';
|
|
6
6
|
import { themeContractVars as vars } from "../../../themes/theme.css.js";
|
|
7
|
+
const active_scaling_factor = 0.7777;
|
|
7
8
|
export const root = style({
|
|
8
9
|
transition: "fill 0.2s ".concat(vars.animation.easing.decelerate, " 0s")
|
|
9
10
|
}, "root");
|
|
@@ -18,6 +19,10 @@ const borderVisualDefaults = style({
|
|
|
18
19
|
borderRadius: vars.border.radius['1'],
|
|
19
20
|
boxShadow: vars.elevation['2']
|
|
20
21
|
}, "borderVisualDefaults");
|
|
22
|
+
export const notchGapPlaceholder = style({
|
|
23
|
+
visibility: 'hidden',
|
|
24
|
+
fontSize: "calc(".concat(vars.typography.size['4'].fontSize, " * ").concat(active_scaling_factor, ")")
|
|
25
|
+
}, "notchGapPlaceholder");
|
|
21
26
|
export const borders = {
|
|
22
27
|
root: {
|
|
23
28
|
default: [borderVisualDefaults, style({
|
|
@@ -132,7 +137,6 @@ export const placeholder = styleVariants({
|
|
|
132
137
|
color: vars.typography.colour.muted
|
|
133
138
|
}
|
|
134
139
|
}, "placeholder");
|
|
135
|
-
const active_scaling_factor = 0.7777;
|
|
136
140
|
const calcPlaceholderTranslate = (notched, prefixed, size) => {
|
|
137
141
|
if (notched) {
|
|
138
142
|
return "calc(".concat(vars.space['2'], " + ").concat(vars.space['2'], "), calc(-0.5 * ").concat(active_scaling_factor, " * ").concat(vars.typography.size['4'].fontSize, ")");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotchedBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"NotchedBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AAK7D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,MAAM,WAAW,KAAK;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,0BAA0B,EAAE,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,OAAO,MAAM,CAAC,oBAAoB,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,KAAK,CA0LhD,CAAC"}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useRef } from 'react';
|
|
6
6
|
import { Box } from "../../Box/index.js";
|
|
7
7
|
import { useTextStyles } from "../../Text/index.js";
|
|
8
8
|
import * as styles from "./NotchedBase.css.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
const ACTIVE_SCALING_FACTOR = 0.7777;
|
|
12
|
-
const ACTIVE_PADDING_ADDED = 16;
|
|
13
|
-
const ROUGH_WIDTH_PER_CHARACTER = 10.2;
|
|
14
11
|
export const NotchedBase = _ref => {
|
|
15
12
|
let {
|
|
16
13
|
id,
|
|
@@ -34,14 +31,7 @@ export const NotchedBase = _ref => {
|
|
|
34
31
|
size: '4'
|
|
35
32
|
});
|
|
36
33
|
const labelRef = useRef(null);
|
|
37
|
-
const [labelWidth, setLabelWidth] = useState(getNotchedComputedWidthForWidth(placeholder.length * ROUGH_WIDTH_PER_CHARACTER));
|
|
38
34
|
const shouldMerge = !isFocused && !isHovered;
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (labelRef.current) {
|
|
41
|
-
setLabelWidth(labelRef.current.offsetWidth);
|
|
42
|
-
}
|
|
43
|
-
}, [placeholder]);
|
|
44
|
-
const notchedWidth = getNotchedComputedWidthForWidth(labelWidth);
|
|
45
35
|
return _jsxs(Box, {
|
|
46
36
|
position: "relative",
|
|
47
37
|
width: "full",
|
|
@@ -79,12 +69,14 @@ export const NotchedBase = _ref => {
|
|
|
79
69
|
[styles.bordersAttach.flatCorners.TOP_LEFT]: attach === 'LEFT' || attach === 'TOP' || attach === 'ALL',
|
|
80
70
|
[styles.bordersAttach.flatCorners.BOTTOM_LEFT]: attach === 'LEFT' || attach === 'BOTTOM' || attach === 'ALL'
|
|
81
71
|
})
|
|
82
|
-
}),
|
|
72
|
+
}), _jsxs("div", {
|
|
83
73
|
className: clsx(styles.borders.middle, borderColourClassName),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
children: [_jsx(Box, {
|
|
75
|
+
display: isEmpty || placeholder.length === 0 ? 'none' : 'block',
|
|
76
|
+
paddingX: "2",
|
|
77
|
+
className: [labelStyles, styles.notchGapPlaceholder],
|
|
78
|
+
children: placeholder
|
|
79
|
+
}), _jsx(Box, {
|
|
88
80
|
ref: labelRef,
|
|
89
81
|
is: "label",
|
|
90
82
|
pointerEvents: "none",
|
|
@@ -103,7 +95,7 @@ export const NotchedBase = _ref => {
|
|
|
103
95
|
[styles.placeholderPlacement[size].shifted]: !isEmpty
|
|
104
96
|
}),
|
|
105
97
|
children: placeholder
|
|
106
|
-
})
|
|
98
|
+
})]
|
|
107
99
|
}), _jsx("div", {
|
|
108
100
|
className: clsx(styles.borders.trailing, borderColourClassName, borderColourClassName, {
|
|
109
101
|
[styles.bordersMerged.complete.RIGHT]: shouldMerge && borderMerged === 'RIGHT',
|
|
@@ -116,7 +108,4 @@ export const NotchedBase = _ref => {
|
|
|
116
108
|
})]
|
|
117
109
|
})]
|
|
118
110
|
});
|
|
119
|
-
};
|
|
120
|
-
function getNotchedComputedWidthForWidth(width) {
|
|
121
|
-
return Math.round((width * ACTIVE_SCALING_FACTOR + ACTIVE_PADDING_ADDED) * 100) / 100;
|
|
122
|
-
}
|
|
111
|
+
};
|