@autoguru/overdrive 4.9.4 → 4.9.6
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/AutoSuggest/stories.js +16 -0
- package/dist/components/ColourInput/stories.js +16 -0
- package/dist/components/DateInput/stories.js +16 -0
- package/dist/components/MinimalModal/MinimalModal.d.ts.map +1 -1
- package/dist/components/MinimalModal/MinimalModal.js +9 -7
- package/dist/components/NumberInput/stories.js +16 -0
- package/dist/components/Portal/Portal.d.ts.map +1 -1
- package/dist/components/Portal/Portal.js +14 -12
- package/dist/components/SelectInput/stories.js +16 -0
- package/dist/components/StandardModal/StandardModal.d.ts.map +1 -1
- package/dist/components/StandardModal/StandardModal.js +9 -7
- package/dist/components/TextInput/stories.js +86 -0
- package/dist/components/Toaster/Toast.d.ts.map +1 -1
- package/dist/components/Toaster/Toast.js +11 -8
- package/dist/components/private/InputBase/NotchedBase.css.d.ts +8 -0
- package/dist/components/private/InputBase/NotchedBase.css.d.ts.map +1 -1
- package/dist/components/private/InputBase/NotchedBase.css.js +75 -8
- package/dist/components/private/InputBase/NotchedBase.d.ts +4 -0
- package/dist/components/private/InputBase/NotchedBase.d.ts.map +1 -1
- package/dist/components/private/InputBase/NotchedBase.js +46 -4
- package/dist/components/private/InputBase/withEnhancedInput.d.ts +4 -7
- package/dist/components/private/InputBase/withEnhancedInput.d.ts.map +1 -1
- package/dist/components/private/InputBase/withEnhancedInput.js +2 -2
- package/dist/hooks/useMedia/useMedia.d.ts.map +1 -1
- package/dist/hooks/useMedia/useMedia.js +22 -20
- package/package.json +1 -1
|
@@ -31,6 +31,14 @@ const iconOptions = {
|
|
|
31
31
|
StarIcon,
|
|
32
32
|
CheckIcon
|
|
33
33
|
};
|
|
34
|
+
const attachOptions = {
|
|
35
|
+
NONE: 'NONE',
|
|
36
|
+
TOP: 'TOP',
|
|
37
|
+
RIGHT: 'RIGHT',
|
|
38
|
+
LEFT: 'LEFT',
|
|
39
|
+
BOTTOM: 'BOTTOM',
|
|
40
|
+
ALL: 'ALL'
|
|
41
|
+
};
|
|
34
42
|
export default {
|
|
35
43
|
title: 'Components/Inputs/AutoSuggest',
|
|
36
44
|
component: AutoSuggest,
|
|
@@ -53,6 +61,14 @@ export default {
|
|
|
53
61
|
type: 'select'
|
|
54
62
|
}
|
|
55
63
|
},
|
|
64
|
+
attach: {
|
|
65
|
+
defaultValue: 'NONE',
|
|
66
|
+
description: 'Input attach',
|
|
67
|
+
options: attachOptions,
|
|
68
|
+
control: {
|
|
69
|
+
type: 'select'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
56
72
|
fieldIcon: {
|
|
57
73
|
defaultValue: void 0,
|
|
58
74
|
description: 'Input field Icon',
|
|
@@ -30,12 +30,28 @@ const iconOptions = {
|
|
|
30
30
|
PlusIcon,
|
|
31
31
|
StarIcon
|
|
32
32
|
};
|
|
33
|
+
const attachOptions = {
|
|
34
|
+
NONE: 'NONE',
|
|
35
|
+
TOP: 'TOP',
|
|
36
|
+
RIGHT: 'RIGHT',
|
|
37
|
+
LEFT: 'LEFT',
|
|
38
|
+
BOTTOM: 'BOTTOM',
|
|
39
|
+
ALL: 'ALL'
|
|
40
|
+
};
|
|
33
41
|
const argTypes = {
|
|
34
42
|
value: {
|
|
35
43
|
control: {
|
|
36
44
|
type: 'color'
|
|
37
45
|
}
|
|
38
46
|
},
|
|
47
|
+
attach: {
|
|
48
|
+
defaultValue: 'NONE',
|
|
49
|
+
description: 'Input attach',
|
|
50
|
+
options: attachOptions,
|
|
51
|
+
control: {
|
|
52
|
+
type: 'select'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
39
55
|
suffixIcon: {
|
|
40
56
|
defaultValue: null,
|
|
41
57
|
description: 'Input suffix Icon',
|
|
@@ -40,12 +40,28 @@ const iconOptions = {
|
|
|
40
40
|
PlusIcon,
|
|
41
41
|
StarIcon
|
|
42
42
|
};
|
|
43
|
+
const attachOptions = {
|
|
44
|
+
NONE: 'NONE',
|
|
45
|
+
TOP: 'TOP',
|
|
46
|
+
RIGHT: 'RIGHT',
|
|
47
|
+
LEFT: 'LEFT',
|
|
48
|
+
BOTTOM: 'BOTTOM',
|
|
49
|
+
ALL: 'ALL'
|
|
50
|
+
};
|
|
43
51
|
const argTypes = {
|
|
44
52
|
value: {
|
|
45
53
|
control: {
|
|
46
54
|
type: 'date'
|
|
47
55
|
}
|
|
48
56
|
},
|
|
57
|
+
attach: {
|
|
58
|
+
defaultValue: 'NONE',
|
|
59
|
+
description: 'Input attach',
|
|
60
|
+
options: attachOptions,
|
|
61
|
+
control: {
|
|
62
|
+
type: 'select'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
49
65
|
prefixIcon: {
|
|
50
66
|
defaultValue: null,
|
|
51
67
|
description: 'Input prefix Icon',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinimalModal.d.ts","sourceRoot":"","sources":["../../../lib/components/MinimalModal/MinimalModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAA2B,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,KAChB,SAAQ,cAAc,CAAC,OAAO,KAAK,CAAC,EACnC,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,YAAY,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"MinimalModal.d.ts","sourceRoot":"","sources":["../../../lib/components/MinimalModal/MinimalModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAA2B,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,KAChB,SAAQ,cAAc,CAAC,OAAO,KAAK,CAAC,EACnC,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,YAAY,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,KAAK,CAqEjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useLayoutEffect, useRef } from 'react';
|
|
3
|
-
import { useEventCallback, useId } from '../../utils';
|
|
3
|
+
import { isBrowser, useEventCallback, useId } from '../../utils';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
5
|
import { Modal } from '../Modal';
|
|
6
6
|
import * as styles from './MinimalModal.css';
|
|
@@ -16,12 +16,14 @@ export const MinimalModal = ({ isOpen, alignItems = 'center', className = '', on
|
|
|
16
16
|
if (typeof onRequestClose === 'function')
|
|
17
17
|
onRequestClose('backdrop');
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (isBrowser) {
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
document.body.style.overflow = isOpen ? 'hidden' : '';
|
|
22
|
+
return () => {
|
|
23
|
+
document.body.style.overflow = '';
|
|
24
|
+
};
|
|
25
|
+
}, [isOpen]);
|
|
26
|
+
}
|
|
25
27
|
return (React.createElement(Modal, { isOpen: isOpen, onRequestClose: onRequestClose },
|
|
26
28
|
React.createElement(Box, { className: [styles.container, className], height: "full", display: "flex", alignItems: alignItems, justifyContent: "center", "aria-hidden": isOpen ? 'false' : 'true', role: "none presentation", onMouseDown: unlockModal, onClick: backdropHandler },
|
|
27
29
|
React.createElement(Box, { is: "article", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, display: "flex", flexDirection: "column" },
|
|
@@ -34,6 +34,14 @@ const iconOptions = {
|
|
|
34
34
|
StarIcon,
|
|
35
35
|
CheckIcon
|
|
36
36
|
};
|
|
37
|
+
const attachOptions = {
|
|
38
|
+
NONE: 'NONE',
|
|
39
|
+
TOP: 'TOP',
|
|
40
|
+
RIGHT: 'RIGHT',
|
|
41
|
+
LEFT: 'LEFT',
|
|
42
|
+
BOTTOM: 'BOTTOM',
|
|
43
|
+
ALL: 'ALL'
|
|
44
|
+
};
|
|
37
45
|
const argTypes = {
|
|
38
46
|
prefixIcon: {
|
|
39
47
|
defaultValue: null,
|
|
@@ -43,6 +51,14 @@ const argTypes = {
|
|
|
43
51
|
type: 'select'
|
|
44
52
|
}
|
|
45
53
|
},
|
|
54
|
+
attach: {
|
|
55
|
+
defaultValue: 'NONE',
|
|
56
|
+
description: 'Input attach',
|
|
57
|
+
options: attachOptions,
|
|
58
|
+
control: {
|
|
59
|
+
type: 'select'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
46
62
|
suffixIcon: {
|
|
47
63
|
defaultValue: null,
|
|
48
64
|
description: 'Input suffix Icon',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../../lib/components/Portal/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAa,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAID,iBAAS,MAAM,CACd,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,KAAK,EAC/C,GAAG,EAAE,GAAG,CAAC,OAAO,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../../lib/components/Portal/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAa,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAID,iBAAS,MAAM,CACd,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,KAAK,EAC/C,GAAG,EAAE,GAAG,CAAC,OAAO,SAAS,CAAC,4BA6B1B;AAED,QAAA,MAAM,OAAO,mFAAqB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,CAAC;AAE7B,eAAe,MAAM,CAAC"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { forwardRef, useLayoutEffect, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { isHtmlElement, setRef } from '../../utils';
|
|
4
|
+
import { isBrowser, isHtmlElement, setRef } from '../../utils';
|
|
5
5
|
import { useTheme } from '../ThemeProvider';
|
|
6
6
|
function Portal({ children, container, noThemedWrapper }, ref) {
|
|
7
7
|
const themeClass = useTheme()?.themeClass;
|
|
8
8
|
const [mountNode, setMountNode] = useState(null);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
if (isBrowser) {
|
|
10
|
+
useLayoutEffect(() => {
|
|
11
|
+
setMountNode(isHtmlElement(container) ? container : document.body);
|
|
12
|
+
}, [container]);
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
if (mountNode) {
|
|
15
|
+
setRef(ref, mountNode);
|
|
16
|
+
}
|
|
17
|
+
return () => {
|
|
18
|
+
void setRef(ref, null);
|
|
19
|
+
};
|
|
20
|
+
}, [ref, mountNode]);
|
|
21
|
+
}
|
|
20
22
|
if (!mountNode)
|
|
21
23
|
return null;
|
|
22
24
|
return noThemedWrapper
|
|
@@ -39,6 +39,14 @@ const iconOptions = {
|
|
|
39
39
|
StarIcon,
|
|
40
40
|
CheckIcon
|
|
41
41
|
};
|
|
42
|
+
const attachOptions = {
|
|
43
|
+
NONE: 'NONE',
|
|
44
|
+
TOP: 'TOP',
|
|
45
|
+
RIGHT: 'RIGHT',
|
|
46
|
+
LEFT: 'LEFT',
|
|
47
|
+
BOTTOM: 'BOTTOM',
|
|
48
|
+
ALL: 'ALL'
|
|
49
|
+
};
|
|
42
50
|
const argTypes = {
|
|
43
51
|
value: {
|
|
44
52
|
options: valueOptions,
|
|
@@ -47,6 +55,14 @@ const argTypes = {
|
|
|
47
55
|
type: 'select'
|
|
48
56
|
}
|
|
49
57
|
},
|
|
58
|
+
attach: {
|
|
59
|
+
defaultValue: 'NONE',
|
|
60
|
+
description: 'Input attach',
|
|
61
|
+
options: attachOptions,
|
|
62
|
+
control: {
|
|
63
|
+
type: 'select'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
50
66
|
prefixIcon: {
|
|
51
67
|
defaultValue: null,
|
|
52
68
|
description: 'Input prefix Icon',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardModal.d.ts","sourceRoot":"","sources":["../../../lib/components/StandardModal/StandardModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AASf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjC,oBAAY,KAAK;IAChB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACrB;AAED,aAAK,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE7C,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,OAAO,KAAK,CAAC;IAC1D,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"StandardModal.d.ts","sourceRoot":"","sources":["../../../lib/components/StandardModal/StandardModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AASf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjC,oBAAY,KAAK;IAChB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACrB;AAED,aAAK,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE7C,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,OAAO,KAAK,CAAC;IAC1D,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,KAAK,CAsHlD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { WindowCloseIcon } from '@autoguru/icons';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useLayoutEffect, useRef } from 'react';
|
|
5
|
-
import { useEventCallback, useId } from '../../utils';
|
|
5
|
+
import { isBrowser, useEventCallback, useId } from '../../utils';
|
|
6
6
|
import { Box } from '../Box';
|
|
7
7
|
import { Button } from '../Button';
|
|
8
8
|
import { Heading } from '../Heading';
|
|
@@ -32,12 +32,14 @@ export const StandardModal = ({ isOpen, size = 'standard', className = '', title
|
|
|
32
32
|
if (typeof onRequestClose === 'function')
|
|
33
33
|
onRequestClose('backdrop');
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (isBrowser) {
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
document.body.style.overflow = isOpen ? 'hidden' : '';
|
|
38
|
+
return () => {
|
|
39
|
+
document.body.style.overflow = '';
|
|
40
|
+
};
|
|
41
|
+
}, [isOpen]);
|
|
42
|
+
}
|
|
41
43
|
return (React.createElement(Modal, { isOpen: isOpen, onRequestClose: onRequestClose },
|
|
42
44
|
React.createElement(Box, { className: styles.container, height: "full", display: "flex", alignItems: "center", justifyContent: "center", "aria-hidden": isOpen ? 'false' : 'true', role: "none presentation", onMouseDown: unlockModal, onClick: backdropHandler },
|
|
43
45
|
React.createElement(Box, { is: "article", overflow: "hidden", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, display: "flex", flexDirection: "column", backgroundColour: "white", marginTop: "8", className: clsx([
|
|
@@ -32,7 +32,23 @@ const iconOptions = {
|
|
|
32
32
|
StarIcon,
|
|
33
33
|
CheckIcon
|
|
34
34
|
};
|
|
35
|
+
const attachOptions = {
|
|
36
|
+
NONE: 'NONE',
|
|
37
|
+
TOP: 'TOP',
|
|
38
|
+
RIGHT: 'RIGHT',
|
|
39
|
+
LEFT: 'LEFT',
|
|
40
|
+
BOTTOM: 'BOTTOM',
|
|
41
|
+
ALL: 'ALL'
|
|
42
|
+
};
|
|
35
43
|
const argTypes = {
|
|
44
|
+
attach: {
|
|
45
|
+
defaultValue: 'NONE',
|
|
46
|
+
description: 'Input attach',
|
|
47
|
+
options: attachOptions,
|
|
48
|
+
control: {
|
|
49
|
+
type: 'select'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
36
52
|
prefixIcon: {
|
|
37
53
|
defaultValue: null,
|
|
38
54
|
description: 'Input prefix Icon',
|
|
@@ -85,6 +101,46 @@ const withPrefixIconProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
|
85
101
|
prefixIcon: CalendarIcon
|
|
86
102
|
});
|
|
87
103
|
|
|
104
|
+
const attachedLeftProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
105
|
+
attach: 'LEFT'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const attachedTopProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
109
|
+
attach: 'TOP'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const attachedRightProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
113
|
+
attach: 'RIGHT'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const attachedBottomProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
117
|
+
attach: 'BOTTOM'
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const attachedAllProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
121
|
+
attach: 'ALL'
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const mergedLeftProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
125
|
+
borderMerged: 'LEFT'
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const mergedTopProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
129
|
+
borderMerged: 'TOP'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const mergedRightProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
133
|
+
borderMerged: 'RIGHT'
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const mergedBottomProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
137
|
+
borderMerged: 'BOTTOM'
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const mergedAllProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
141
|
+
borderMerged: 'ALL'
|
|
142
|
+
});
|
|
143
|
+
|
|
88
144
|
const withSuffixIconProps = _objectSpread(_objectSpread({}, sharedProps), {}, {
|
|
89
145
|
suffixIcon: AccountEditIcon
|
|
90
146
|
});
|
|
@@ -154,6 +210,36 @@ withSuffixIcon.argTypes = argTypes;
|
|
|
154
210
|
export const withBothIcons = Template.bind(withBothIconsProps);
|
|
155
211
|
withBothIcons.args = withBothIconsProps;
|
|
156
212
|
withBothIcons.argTypes = argTypes;
|
|
213
|
+
export const attachedLeft = Template.bind(attachedLeftProps);
|
|
214
|
+
attachedLeft.args = attachedLeftProps;
|
|
215
|
+
attachedLeft.argTypes = argTypes;
|
|
216
|
+
export const attachedTop = Template.bind(attachedTopProps);
|
|
217
|
+
attachedTop.args = attachedTopProps;
|
|
218
|
+
attachedTop.argTypes = argTypes;
|
|
219
|
+
export const attachedRight = Template.bind(attachedRightProps);
|
|
220
|
+
attachedRight.args = attachedRightProps;
|
|
221
|
+
attachedRight.argTypes = argTypes;
|
|
222
|
+
export const attachedBottom = Template.bind(attachedBottomProps);
|
|
223
|
+
attachedBottom.args = attachedBottomProps;
|
|
224
|
+
attachedBottom.argTypes = argTypes;
|
|
225
|
+
export const attachedAll = Template.bind(attachedAllProps);
|
|
226
|
+
attachedAll.args = attachedAllProps;
|
|
227
|
+
attachedAll.argTypes = argTypes;
|
|
228
|
+
export const mergedLeft = Template.bind(mergedLeftProps);
|
|
229
|
+
mergedLeft.args = mergedLeftProps;
|
|
230
|
+
mergedLeft.argTypes = argTypes;
|
|
231
|
+
export const mergedTop = Template.bind(mergedTopProps);
|
|
232
|
+
mergedTop.args = mergedTopProps;
|
|
233
|
+
mergedTop.argTypes = argTypes;
|
|
234
|
+
export const mergedRight = Template.bind(mergedRightProps);
|
|
235
|
+
mergedRight.args = mergedRightProps;
|
|
236
|
+
mergedRight.argTypes = argTypes;
|
|
237
|
+
export const mergedBottom = Template.bind(mergedBottomProps);
|
|
238
|
+
mergedBottom.args = mergedBottomProps;
|
|
239
|
+
mergedBottom.argTypes = argTypes;
|
|
240
|
+
export const mergedAll = Template.bind(mergedAllProps);
|
|
241
|
+
mergedAll.args = mergedAllProps;
|
|
242
|
+
mergedAll.argTypes = argTypes;
|
|
157
243
|
export const disabled = Template.bind(disabledProps);
|
|
158
244
|
disabled.args = disabledProps;
|
|
159
245
|
disabled.argTypes = argTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../lib/components/Toaster/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,cAAc,EAEd,iBAAiB,EACjB,SAAS,EAOT,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../lib/components/Toaster/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,cAAc,EAEd,iBAAiB,EACjB,SAAS,EAOT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,aAAK,WAAW,GAAG,SAAS,CAAC;AAC7B,aAAK,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEpE,UAAU,aAAa;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAID,UAAU,OACT,SAAQ,QAAQ,CACf,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,CACtE;IACD,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AA0ED,eAAO,MAAM,aAAa;;iBAQzB,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,OAwE3B,CAAC;AAEF,QAAA,MAAM,KAAK,EAAE,iBAAiB,CAC7B,aAAa,GAAG;IACf,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CA2BD,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { invariant } from '@autoguru/utilities';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useReducer, } from 'react';
|
|
4
|
+
import { isBrowser } from '../../utils';
|
|
4
5
|
import { Alert } from '../Alert';
|
|
5
6
|
import { Box } from '../Box';
|
|
6
7
|
import { Portal } from '../Portal';
|
|
@@ -108,14 +109,16 @@ const Toast = ({ remove, duration, message, id, intent }) => {
|
|
|
108
109
|
const dismiss = useCallback(() => {
|
|
109
110
|
remove(id);
|
|
110
111
|
}, [id, remove]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
if (isBrowser) {
|
|
113
|
+
useLayoutEffect(() => {
|
|
114
|
+
const timeout = setTimeout(() => {
|
|
115
|
+
dismiss();
|
|
116
|
+
}, duration);
|
|
117
|
+
return () => {
|
|
118
|
+
clearTimeout(timeout);
|
|
119
|
+
};
|
|
120
|
+
}, [dismiss]);
|
|
121
|
+
}
|
|
119
122
|
return (React.createElement(Alert, { dismissible: true, intent: intent, className: styles.alert, onRequestClose: dismiss }, message));
|
|
120
123
|
};
|
|
121
124
|
export default Toast;
|
|
@@ -9,6 +9,14 @@ export declare const borders: {
|
|
|
9
9
|
middle: string[];
|
|
10
10
|
trailing: string[];
|
|
11
11
|
};
|
|
12
|
+
export declare const bordersAttach: {
|
|
13
|
+
complete: Record<"NONE" | "LEFT" | "TOP" | "RIGHT" | "BOTTOM" | "ALL", string>;
|
|
14
|
+
flatCorners: Record<"TOP_LEFT" | "TOP_RIGHT" | "BOTTOM_RIGHT" | "BOTTOM_LEFT", string>;
|
|
15
|
+
};
|
|
16
|
+
export declare const bordersMerged: {
|
|
17
|
+
complete: Record<"NONE" | "LEFT" | "TOP" | "RIGHT" | "BOTTOM" | "ALL", string>;
|
|
18
|
+
flatCorners: Record<"TOP_LEFT" | "TOP_RIGHT" | "BOTTOM_RIGHT" | "BOTTOM_LEFT", string>;
|
|
19
|
+
};
|
|
12
20
|
export declare const placeholder: Record<"default" | "mutedLabelStyles", string>;
|
|
13
21
|
export declare const placeholderPlacement: any;
|
|
14
22
|
//# sourceMappingURL=NotchedBase.css.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotchedBase.css.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAEf,CAAC;
|
|
1
|
+
{"version":3,"file":"NotchedBase.css.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAEf,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;AA2BH,eAAO,MAAM,oBAAoB,KAiDhC,CAAC"}
|
|
@@ -3,8 +3,9 @@ import { themeContractVars as vars } from '../../../themes/theme.css';
|
|
|
3
3
|
export const root = style({
|
|
4
4
|
transition: `fill 0.2s ${vars.animation.easing.decelerate} 0s`,
|
|
5
5
|
});
|
|
6
|
+
const defaultBorderWidth = '1px';
|
|
6
7
|
const borderRegionDefaults = style({
|
|
7
|
-
borderWidth:
|
|
8
|
+
borderWidth: defaultBorderWidth,
|
|
8
9
|
borderStyle: 'solid',
|
|
9
10
|
display: 'inline-flex',
|
|
10
11
|
transition: `border-color 0.2s ${vars.animation.easing.decelerate} 0s`,
|
|
@@ -26,13 +27,7 @@ export const borders = {
|
|
|
26
27
|
],
|
|
27
28
|
disabled: style({ boxShadow: 'none' }),
|
|
28
29
|
},
|
|
29
|
-
complete: [
|
|
30
|
-
borderVisualDefaults,
|
|
31
|
-
borderRegionDefaults,
|
|
32
|
-
style({
|
|
33
|
-
borderRadius: `${vars.border.radius['1']}`,
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
30
|
+
complete: [borderVisualDefaults, borderRegionDefaults],
|
|
36
31
|
leading: [
|
|
37
32
|
borderRegionDefaults,
|
|
38
33
|
style({
|
|
@@ -59,6 +54,78 @@ export const borders = {
|
|
|
59
54
|
}),
|
|
60
55
|
],
|
|
61
56
|
};
|
|
57
|
+
export const bordersAttach = {
|
|
58
|
+
complete: styleVariants({
|
|
59
|
+
NONE: {
|
|
60
|
+
borderRadius: `${vars.border.radius['1']}`,
|
|
61
|
+
},
|
|
62
|
+
LEFT: {
|
|
63
|
+
borderRadius: `0 ${vars.border.radius['1']} ${vars.border.radius['1']} 0`,
|
|
64
|
+
},
|
|
65
|
+
TOP: {
|
|
66
|
+
borderRadius: `0 0 ${vars.border.radius['1']} ${vars.border.radius['1']}`,
|
|
67
|
+
},
|
|
68
|
+
RIGHT: {
|
|
69
|
+
borderRadius: `${vars.border.radius['1']} 0 0 ${vars.border.radius['1']}`,
|
|
70
|
+
},
|
|
71
|
+
BOTTOM: {
|
|
72
|
+
borderRadius: `${vars.border.radius['1']} ${vars.border.radius['1']} 0 0`,
|
|
73
|
+
},
|
|
74
|
+
ALL: {
|
|
75
|
+
borderRadius: 0,
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
flatCorners: styleVariants({
|
|
79
|
+
TOP_LEFT: {
|
|
80
|
+
borderTopLeftRadius: 0,
|
|
81
|
+
},
|
|
82
|
+
TOP_RIGHT: {
|
|
83
|
+
borderTopRightRadius: 0,
|
|
84
|
+
},
|
|
85
|
+
BOTTOM_RIGHT: {
|
|
86
|
+
borderBottomRightRadius: 0,
|
|
87
|
+
},
|
|
88
|
+
BOTTOM_LEFT: {
|
|
89
|
+
borderBottomLeftRadius: 0,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
export const bordersMerged = {
|
|
94
|
+
complete: styleVariants({
|
|
95
|
+
NONE: {
|
|
96
|
+
borderWidth: defaultBorderWidth,
|
|
97
|
+
},
|
|
98
|
+
LEFT: {
|
|
99
|
+
borderLeftColor: 'transparent',
|
|
100
|
+
},
|
|
101
|
+
TOP: {
|
|
102
|
+
borderTopColor: 'transparent',
|
|
103
|
+
},
|
|
104
|
+
RIGHT: {
|
|
105
|
+
borderRightColor: 'transparent',
|
|
106
|
+
},
|
|
107
|
+
BOTTOM: {
|
|
108
|
+
borderBottomColor: 'transparent',
|
|
109
|
+
},
|
|
110
|
+
ALL: {
|
|
111
|
+
borderColor: 'transparent',
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
flatCorners: styleVariants({
|
|
115
|
+
TOP_LEFT: {
|
|
116
|
+
borderTopLeftRadius: 0,
|
|
117
|
+
},
|
|
118
|
+
TOP_RIGHT: {
|
|
119
|
+
borderTopRightRadius: 0,
|
|
120
|
+
},
|
|
121
|
+
BOTTOM_RIGHT: {
|
|
122
|
+
borderBottomRightRadius: 0,
|
|
123
|
+
},
|
|
124
|
+
BOTTOM_LEFT: {
|
|
125
|
+
borderBottomLeftRadius: 0,
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
62
129
|
export const placeholder = styleVariants({
|
|
63
130
|
default: {
|
|
64
131
|
lineHeight: 1,
|
|
@@ -12,6 +12,10 @@ export interface Props {
|
|
|
12
12
|
size: keyof typeof styles.placeholderPlacement;
|
|
13
13
|
className?: string;
|
|
14
14
|
children?: ReactNode;
|
|
15
|
+
attach?: keyof typeof styles.bordersAttach['complete'];
|
|
16
|
+
borderMerged?: keyof typeof styles.bordersMerged['complete'];
|
|
17
|
+
isFocused?: boolean;
|
|
18
|
+
isHovered?: boolean;
|
|
15
19
|
}
|
|
16
20
|
export declare const NotchedBase: FunctionComponent<Props>;
|
|
17
21
|
//# sourceMappingURL=NotchedBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotchedBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,iBAAiB,EACjB,SAAS,EAIT,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAM5C,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;
|
|
1
|
+
{"version":3,"file":"NotchedBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/NotchedBase.tsx"],"names":[],"mappings":"AAEA,OAAO,EACN,iBAAiB,EACjB,SAAS,EAIT,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAM5C,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,OAAO,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACvD,YAAY,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,KAAK,CAyLhD,CAAC"}
|
|
@@ -7,34 +7,76 @@ import * as styles from './NotchedBase.css';
|
|
|
7
7
|
const ACTIVE_SCALING_FACTOR = 0.7777;
|
|
8
8
|
const ACTIVE_PADDING_ADDED = 16;
|
|
9
9
|
const ROUGH_WIDTH_PER_CHARACTER = 10.2;
|
|
10
|
-
export const NotchedBase = ({ id, placeholder, isEmpty, disabled, prefixed, size, children, notch = true, borderColourClassName, placeholderColourClassName, className = '', }) => {
|
|
10
|
+
export const NotchedBase = ({ id, placeholder, isEmpty, disabled, prefixed, size, children, notch = true, borderColourClassName, placeholderColourClassName, className = '', attach = 'NONE', borderMerged = 'NONE', isFocused = false, isHovered = false, }) => {
|
|
11
11
|
const labelStyles = useTextStyles({
|
|
12
12
|
noWrap: true,
|
|
13
13
|
size: '4',
|
|
14
14
|
});
|
|
15
15
|
const labelRef = useRef(null);
|
|
16
16
|
const [labelWidth, setLabelWidth] = useState(getNotchedComputedWidthForWidth(placeholder.length * ROUGH_WIDTH_PER_CHARACTER));
|
|
17
|
+
const shouldMerge = !isFocused && !isHovered;
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
if (labelRef.current) {
|
|
19
20
|
setLabelWidth(labelRef.current.offsetWidth);
|
|
20
21
|
}
|
|
21
22
|
}, [placeholder]);
|
|
22
23
|
const notchedWidth = getNotchedComputedWidthForWidth(labelWidth);
|
|
23
|
-
return (React.createElement(Box, { position: "relative", width: "full", padding: "none", className: clsx(styles.root, !notch && [styles.borders.complete, borderColourClassName], className
|
|
24
|
+
return (React.createElement(Box, { position: "relative", width: "full", padding: "none", className: clsx(styles.root, !notch && [styles.borders.complete, borderColourClassName], className, {
|
|
25
|
+
[styles.bordersMerged.complete.NONE]: !notch &&
|
|
26
|
+
shouldMerge &&
|
|
27
|
+
(!borderMerged || borderMerged === 'NONE'),
|
|
28
|
+
[styles.bordersMerged.complete.LEFT]: !notch && shouldMerge && borderMerged === 'LEFT',
|
|
29
|
+
[styles.bordersMerged.complete.TOP]: !notch && shouldMerge && borderMerged === 'TOP',
|
|
30
|
+
[styles.bordersMerged.complete.RIGHT]: !notch && shouldMerge && borderMerged === 'RIGHT',
|
|
31
|
+
[styles.bordersMerged.complete.BOTTOM]: !notch && shouldMerge && borderMerged === 'BOTTOM',
|
|
32
|
+
[styles.bordersMerged.complete.ALL]: !notch && shouldMerge && borderMerged === 'ALL',
|
|
33
|
+
[styles.bordersAttach.complete.NONE]: !notch && attach === 'NONE',
|
|
34
|
+
[styles.bordersAttach.complete.LEFT]: !notch && attach === 'LEFT',
|
|
35
|
+
[styles.bordersAttach.complete.RIGHT]: !notch && attach === 'RIGHT',
|
|
36
|
+
[styles.bordersAttach.complete.TOP]: !notch && attach === 'TOP',
|
|
37
|
+
[styles.bordersAttach.complete.BOTTOM]: !notch && attach === 'BOTTOM',
|
|
38
|
+
[styles.bordersAttach.complete.ALL]: !notch && attach === 'ALL',
|
|
39
|
+
}) },
|
|
24
40
|
children,
|
|
25
41
|
notch && (React.createElement(Box, { className: clsx(styles.borders.root.default, {
|
|
26
42
|
[styles.borders.root.disabled]: disabled,
|
|
27
43
|
}), pointerEvents: "none", position: "absolute", display: "flex", width: "full", height: "full", textAlign: "left" },
|
|
28
|
-
React.createElement("div", { className: clsx(styles.borders.leading, borderColourClassName
|
|
44
|
+
React.createElement("div", { className: clsx(styles.borders.leading, borderColourClassName, {
|
|
45
|
+
[styles.bordersMerged.complete.LEFT]: shouldMerge && borderMerged === 'LEFT',
|
|
46
|
+
[styles.bordersMerged.complete.TOP]: shouldMerge && borderMerged === 'TOP',
|
|
47
|
+
[styles.bordersMerged.complete.BOTTOM]: shouldMerge && borderMerged === 'BOTTOM',
|
|
48
|
+
[styles.bordersMerged.complete.ALL]: shouldMerge && borderMerged === 'ALL',
|
|
49
|
+
[styles.bordersAttach.flatCorners.TOP_LEFT]: attach === 'LEFT' ||
|
|
50
|
+
attach === 'TOP' ||
|
|
51
|
+
attach === 'ALL',
|
|
52
|
+
[styles.bordersAttach.flatCorners.BOTTOM_LEFT]: attach === 'LEFT' ||
|
|
53
|
+
attach === 'BOTTOM' ||
|
|
54
|
+
attach === 'ALL',
|
|
55
|
+
}) }),
|
|
29
56
|
React.createElement("div", { className: clsx(styles.borders.middle, borderColourClassName), style: { width: isEmpty ? 0 : notchedWidth } },
|
|
30
57
|
React.createElement(Box, { ref: labelRef, is: "label", pointerEvents: "none", htmlFor: id, position: "absolute", display: "inline", margin: "none", padding: "none", className: clsx(styles.placeholder.default, placeholderColourClassName, labelStyles, {
|
|
58
|
+
[styles.bordersMerged.complete.TOP]: shouldMerge && borderMerged === 'TOP',
|
|
59
|
+
[styles.bordersMerged.complete.BOTTOM]: shouldMerge &&
|
|
60
|
+
borderMerged === 'BOTTOM',
|
|
61
|
+
[styles.bordersMerged.complete.ALL]: shouldMerge && borderMerged === 'ALL',
|
|
31
62
|
[styles.placeholder.mutedLabelStyles]: isEmpty || disabled,
|
|
32
63
|
[styles.placeholderPlacement[size].default]: isEmpty && !prefixed,
|
|
33
64
|
[styles.placeholderPlacement[size]
|
|
34
65
|
.defaultPrefixed]: isEmpty && prefixed,
|
|
35
66
|
[styles.placeholderPlacement[size].shifted]: !isEmpty,
|
|
36
67
|
}) }, placeholder)),
|
|
37
|
-
React.createElement("div", { className: clsx(styles.borders.trailing, borderColourClassName
|
|
68
|
+
React.createElement("div", { className: clsx(styles.borders.trailing, borderColourClassName, borderColourClassName, {
|
|
69
|
+
[styles.bordersMerged.complete.RIGHT]: shouldMerge && borderMerged === 'RIGHT',
|
|
70
|
+
[styles.bordersMerged.complete.TOP]: shouldMerge && borderMerged === 'TOP',
|
|
71
|
+
[styles.bordersMerged.complete.BOTTOM]: shouldMerge && borderMerged === 'BOTTOM',
|
|
72
|
+
[styles.bordersMerged.complete.ALL]: shouldMerge && borderMerged === 'ALL',
|
|
73
|
+
[styles.bordersAttach.flatCorners.TOP_RIGHT]: attach === 'RIGHT' ||
|
|
74
|
+
attach === 'TOP' ||
|
|
75
|
+
attach === 'ALL',
|
|
76
|
+
[styles.bordersAttach.flatCorners.BOTTOM_RIGHT]: attach === 'RIGHT' ||
|
|
77
|
+
attach === 'BOTTOM' ||
|
|
78
|
+
attach === 'ALL',
|
|
79
|
+
}) })))));
|
|
38
80
|
};
|
|
39
81
|
function getNotchedComputedWidthForWidth(width) {
|
|
40
82
|
return (Math.round((width * ACTIVE_SCALING_FACTOR + ACTIVE_PADDING_ADDED) * 100) / 100);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IconType } from '@autoguru/icons';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { AriaAttributes, ChangeEventHandler, ComponentType, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, MutableRefObject, ReactNode, Ref } from 'react';
|
|
3
|
+
import { AriaAttributes, ChangeEventHandler, ComponentProps, ComponentType, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, MutableRefObject, ReactNode, Ref } from 'react';
|
|
4
|
+
import { NotchedBase } from './NotchedBase';
|
|
4
5
|
import * as styles from './withEnhancedInput.css';
|
|
5
6
|
export interface EventHandlers<PrimitiveElementType> {
|
|
6
7
|
onChange?: ChangeEventHandler<PrimitiveElementType>;
|
|
@@ -12,16 +13,14 @@ export interface EventHandlers<PrimitiveElementType> {
|
|
|
12
13
|
onMouseLeave?: MouseEventHandler<PrimitiveElementType>;
|
|
13
14
|
onReset?(): void;
|
|
14
15
|
}
|
|
15
|
-
export interface EnhanceInputPrimitiveProps extends AriaAttributes {
|
|
16
|
+
export interface EnhanceInputPrimitiveProps extends AriaAttributes, Pick<ComponentProps<typeof NotchedBase>, 'notch' | 'placeholder' | 'attach' | 'borderMerged' | 'isFocused'> {
|
|
16
17
|
name: string;
|
|
17
|
-
placeholder: string;
|
|
18
18
|
id?: string;
|
|
19
19
|
className?: string;
|
|
20
20
|
value?: string;
|
|
21
21
|
hintText?: ReactNode;
|
|
22
22
|
autoFocus?: boolean;
|
|
23
23
|
disabled?: boolean;
|
|
24
|
-
notch?: boolean;
|
|
25
24
|
reserveHintSpace?: boolean;
|
|
26
25
|
size?: keyof typeof styles.inputItselfSize;
|
|
27
26
|
fieldIcon?: IconType;
|
|
@@ -29,7 +28,6 @@ export interface EnhanceInputPrimitiveProps extends AriaAttributes {
|
|
|
29
28
|
suffixIcon?: IconType;
|
|
30
29
|
wrapperRef?: Ref<HTMLDivElement>;
|
|
31
30
|
isLoading?: boolean;
|
|
32
|
-
isFocused?: boolean;
|
|
33
31
|
}
|
|
34
32
|
export interface ValidationProps {
|
|
35
33
|
isTouched?: boolean;
|
|
@@ -44,12 +42,11 @@ export declare type WrappedComponentProps<IncomingProps, PrimitiveElementType> =
|
|
|
44
42
|
ref: MutableRefObject<PrimitiveElementType>;
|
|
45
43
|
};
|
|
46
44
|
fieldIcon?: EnhanceInputPrimitiveProps['fieldIcon'];
|
|
47
|
-
isFocused?: boolean;
|
|
48
45
|
className?: boolean;
|
|
49
46
|
prefixed: boolean;
|
|
50
47
|
suffixed: boolean;
|
|
51
48
|
isLoading: boolean;
|
|
52
|
-
} & IncomingProps
|
|
49
|
+
} & IncomingProps & Pick<ComponentProps<typeof NotchedBase>, 'attach' | 'borderMerged' | 'isFocused'>;
|
|
53
50
|
interface EnhancedInputConfigs<ValueType = string> {
|
|
54
51
|
defaultValue?: ValueType;
|
|
55
52
|
withPrefixIcon?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withEnhancedInput.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/withEnhancedInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,GAAG,EAGH,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"withEnhancedInput.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/InputBase/withEnhancedInput.tsx"],"names":[],"mappings":"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"}
|
|
@@ -10,7 +10,7 @@ import { HintText } from './HintText';
|
|
|
10
10
|
import * as inputStateStyles from './InputState.css';
|
|
11
11
|
import { NotchedBase } from './NotchedBase';
|
|
12
12
|
import * as styles from './withEnhancedInput.css';
|
|
13
|
-
export const withEnhancedInput = (WrappingComponent, { primitiveType = 'text', withPrefixIcon = true, withSuffixIcon = true, defaultValue, } = { primitiveType: 'text', defaultValue: void 0 }) => forwardRef(({ placeholder, name, id = name, hintText, disabled = false, className, isTouched, isValid, isLoading = false, notch = true, reserveHintSpace = false, size = 'medium', value: incomingValue = defaultValue || '', onChange: incomingOnChange, onReset, onMouseLeave, onMouseEnter, onBlur, onFocus, onKeyDown, prefixIcon, suffixIcon, wrapperRef, autoFocus, ...rest }, ref) => {
|
|
13
|
+
export const withEnhancedInput = (WrappingComponent, { primitiveType = 'text', withPrefixIcon = true, withSuffixIcon = true, defaultValue, } = { primitiveType: 'text', defaultValue: void 0 }) => forwardRef(({ placeholder, name, id = name, hintText, disabled = false, className, isTouched, isValid, isLoading = false, notch = true, reserveHintSpace = false, size = 'medium', value: incomingValue = defaultValue || '', onChange: incomingOnChange, onReset, onMouseLeave, onMouseEnter, onBlur, onFocus, onKeyDown, prefixIcon, suffixIcon, wrapperRef, autoFocus, attach, borderMerged, ...rest }, ref) => {
|
|
14
14
|
invariant(!(prefixIcon && !withPrefixIcon), 'prefix icon is not supported for this component');
|
|
15
15
|
invariant(!(suffixIcon && !withSuffixIcon), 'suffix icon is not supported for this component');
|
|
16
16
|
const [value, onChange] = useInputControlledState(incomingValue, incomingOnChange);
|
|
@@ -83,7 +83,7 @@ export const withEnhancedInput = (WrappingComponent, { primitiveType = 'text', w
|
|
|
83
83
|
position: 'absolute',
|
|
84
84
|
});
|
|
85
85
|
return (React.createElement(Box, { width: "full", className: className, onMouseEnter: onMouseOver, onMouseLeave: onMouseOut },
|
|
86
|
-
React.createElement(NotchedBase, { id: id, prefixed: Boolean(prefixIcon), isEmpty: isEmpty, size: size, disabled: disabled, notch: notch, placeholder: placeholder, placeholderColourClassName: clsx({
|
|
86
|
+
React.createElement(NotchedBase, { id: id, prefixed: Boolean(prefixIcon), isEmpty: isEmpty, size: size, disabled: disabled, notch: notch, placeholder: placeholder, attach: attach, borderMerged: borderMerged, isFocused: isActive, isHovered: isHovered, placeholderColourClassName: clsx({
|
|
87
87
|
[derivedColours.colour]: !isEmpty,
|
|
88
88
|
}), borderColourClassName: derivedColours.borderColour },
|
|
89
89
|
React.createElement(Box, { ref: wrapperRef, className: styles.inputWrapperSize[size].root[primitiveType], width: "full", height: "full" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useMedia/useMedia.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,eAAO,MAAM,QAAQ,YACX,cAAc,MAAM,WAAW,CAAC,6BAEvC,SAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useMedia/useMedia.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,eAAO,MAAM,QAAQ,YACX,cAAc,MAAM,WAAW,CAAC,6BAEvC,SAAS,OAAO,EA+ClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -8,27 +8,29 @@ export const useMedia = (queries, fallbackCase = false) => {
|
|
|
8
8
|
const getQueries = useCallback(() => queries.map((media) => `(min-width: ${breakpoints[media]})`), [breakpoints]);
|
|
9
9
|
const matchesInit = useMemo(() => getQueries().map((query) => window.matchMedia(query).matches), [getQueries]);
|
|
10
10
|
const [matches, setMatches] = useState(matchesInit);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
if (isBrowser) {
|
|
12
|
+
useLayoutEffect(() => {
|
|
13
|
+
let isMounted = true;
|
|
14
|
+
const matchers = getQueries().map((query) => window.matchMedia(query));
|
|
15
|
+
const removeHandlersFn = matchers.map((matcher, idx) => {
|
|
16
|
+
const handler = (e) => {
|
|
17
|
+
if (!isMounted)
|
|
18
|
+
return;
|
|
19
|
+
setMatches((prevState) => {
|
|
20
|
+
const newState = [...prevState];
|
|
21
|
+
newState[idx] = e.matches;
|
|
22
|
+
return newState;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
matcher.addEventListener('change', handler, { passive: true });
|
|
26
|
+
return () => matcher.removeEventListener('change', handler);
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
isMounted = false;
|
|
30
|
+
removeHandlersFn.forEach((item) => item());
|
|
23
31
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
return () => {
|
|
28
|
-
isMounted = false;
|
|
29
|
-
removeHandlersFn.forEach((item) => item());
|
|
30
|
-
};
|
|
31
|
-
}, [...queries, breakpoints]);
|
|
32
|
+
}, [...queries, breakpoints]);
|
|
33
|
+
}
|
|
32
34
|
return matches;
|
|
33
35
|
};
|
|
34
36
|
export default useMedia;
|