@autoguru/overdrive 4.10.2 → 4.11.0

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.
Files changed (257) hide show
  1. package/dist/components/Actions/Actions.js +21 -4
  2. package/dist/components/Actions/index.js +3 -1
  3. package/dist/components/Alert/Alert.css.js +28 -20
  4. package/dist/components/Alert/Alert.js +84 -26
  5. package/dist/components/Alert/index.js +3 -1
  6. package/dist/components/Anchor/Anchor.css.js +11 -3
  7. package/dist/components/Anchor/Anchor.js +53 -28
  8. package/dist/components/Anchor/index.js +3 -1
  9. package/dist/components/AutoSuggest/AutoSuggest.css.js +84 -76
  10. package/dist/components/AutoSuggest/AutoSuggest.js +621 -302
  11. package/dist/components/AutoSuggest/index.js +3 -1
  12. package/dist/components/AutoSuggest/useLayoutSuggestionVisible.js +29 -31
  13. package/dist/components/Badge/Badge.css.js +79 -71
  14. package/dist/components/Badge/Badge.js +44 -27
  15. package/dist/components/Badge/index.js +3 -1
  16. package/dist/components/Box/Box.js +122 -53
  17. package/dist/components/Box/argTypes.js +72 -105
  18. package/dist/components/Box/index.js +4 -2
  19. package/dist/components/Box/useBoxStyles.css.d.ts.map +1 -1
  20. package/dist/components/Box/useBoxStyles.css.js +114 -96
  21. package/dist/components/Box/useBoxStyles.js +75 -47
  22. package/dist/components/BulletList/Bullet.css.js +49 -41
  23. package/dist/components/BulletList/Bullet.js +38 -24
  24. package/dist/components/BulletList/BulletList.css.js +13 -5
  25. package/dist/components/BulletList/BulletList.js +23 -10
  26. package/dist/components/BulletList/context.js +3 -1
  27. package/dist/components/BulletList/index.js +4 -2
  28. package/dist/components/BulletText/BulletText.css.js +21 -13
  29. package/dist/components/BulletText/BulletText.js +57 -16
  30. package/dist/components/BulletText/index.js +3 -1
  31. package/dist/components/Button/Button.css.js +243 -235
  32. package/dist/components/Button/Button.js +154 -91
  33. package/dist/components/Button/index.js +3 -1
  34. package/dist/components/CheckBox/CheckBox.css.js +28 -20
  35. package/dist/components/CheckBox/CheckBox.js +54 -16
  36. package/dist/components/CheckBox/index.js +3 -1
  37. package/dist/components/ColourInput/ColourInput.css.js +31 -23
  38. package/dist/components/ColourInput/ColourInput.js +70 -20
  39. package/dist/components/ColourInput/index.js +3 -1
  40. package/dist/components/Columns/Column.css.js +36 -26
  41. package/dist/components/Columns/Column.js +51 -16
  42. package/dist/components/Columns/Columns.css.js +39 -31
  43. package/dist/components/Columns/Columns.js +55 -22
  44. package/dist/components/Columns/index.js +4 -2
  45. package/dist/components/DateInput/DateInput.js +34 -7
  46. package/dist/components/DateInput/index.js +3 -1
  47. package/dist/components/DatePicker/DatePicker.css.js +40 -32
  48. package/dist/components/DatePicker/DatePicker.js +64 -23
  49. package/dist/components/DatePicker/index.js +3 -1
  50. package/dist/components/DividerLine/DividerLine.css.js +45 -37
  51. package/dist/components/DividerLine/DividerLine.js +22 -6
  52. package/dist/components/DividerLine/index.js +3 -1
  53. package/dist/components/Flyout/Flyout.js +41 -5
  54. package/dist/components/Flyout/index.js +3 -1
  55. package/dist/components/Heading/Heading.js +41 -21
  56. package/dist/components/Heading/index.js +3 -1
  57. package/dist/components/Icon/Icon.css.js +13 -5
  58. package/dist/components/Icon/Icon.js +26 -9
  59. package/dist/components/Icon/index.js +3 -1
  60. package/dist/components/Image/Image.js +23 -5
  61. package/dist/components/Image/ImageServerProvider.d.ts +1 -1
  62. package/dist/components/Image/ImageServerProvider.d.ts.map +1 -1
  63. package/dist/components/Image/ImageServerProvider.js +55 -35
  64. package/dist/components/Image/ResponsiveImage.js +46 -21
  65. package/dist/components/Image/SimpleImage.js +30 -2
  66. package/dist/components/Image/index.js +4 -2
  67. package/dist/components/Image/types.js +3 -1
  68. package/dist/components/Inline/Inline.js +74 -30
  69. package/dist/components/Inline/index.js +3 -1
  70. package/dist/components/LinearProgressIndicator/LinearProgressIndicator.css.js +56 -48
  71. package/dist/components/LinearProgressIndicator/LinearProgressIndicator.js +31 -7
  72. package/dist/components/LinearProgressIndicator/index.js +3 -1
  73. package/dist/components/LoadingBox/LoadingBox.css.js +26 -18
  74. package/dist/components/LoadingBox/LoadingBox.js +40 -7
  75. package/dist/components/LoadingBox/index.js +3 -1
  76. package/dist/components/Meta/Meta.css.js +16 -8
  77. package/dist/components/Meta/Meta.js +30 -8
  78. package/dist/components/Meta/index.js +3 -1
  79. package/dist/components/MinimalModal/MinimalModal.css.js +15 -7
  80. package/dist/components/MinimalModal/MinimalModal.js +67 -29
  81. package/dist/components/MinimalModal/index.js +3 -1
  82. package/dist/components/Modal/Modal.css.js +38 -30
  83. package/dist/components/Modal/Modal.js +129 -73
  84. package/dist/components/Modal/index.js +3 -1
  85. package/dist/components/NumberBubble/NumberBubble.css.js +12 -4
  86. package/dist/components/NumberBubble/NumberBubble.js +51 -23
  87. package/dist/components/NumberBubble/index.js +3 -1
  88. package/dist/components/NumberInput/NumberInput.js +67 -29
  89. package/dist/components/NumberInput/index.js +3 -1
  90. package/dist/components/OrderedList/OrderedList.css.js +16 -8
  91. package/dist/components/OrderedList/OrderedList.js +60 -26
  92. package/dist/components/OrderedList/index.js +3 -1
  93. package/dist/components/OutsideClick/OutsideClick.js +40 -35
  94. package/dist/components/OutsideClick/index.js +3 -1
  95. package/dist/components/OverdriveProvider/OverdriveProvider.js +33 -19
  96. package/dist/components/OverdriveProvider/index.js +3 -1
  97. package/dist/components/Pagination/Bubble.js +41 -19
  98. package/dist/components/Pagination/Pagination.css.js +28 -20
  99. package/dist/components/Pagination/Pagination.js +166 -67
  100. package/dist/components/Pagination/index.js +3 -1
  101. package/dist/components/Portal/Portal.js +40 -24
  102. package/dist/components/Portal/index.js +3 -1
  103. package/dist/components/Positioner/Positioner.css.js +14 -6
  104. package/dist/components/Positioner/Positioner.js +109 -85
  105. package/dist/components/Positioner/alignment.js +13 -10
  106. package/dist/components/Positioner/index.js +4 -2
  107. package/dist/components/ProgressBar/ProgressBar.css.js +14 -6
  108. package/dist/components/ProgressBar/ProgressBar.js +30 -12
  109. package/dist/components/ProgressBar/index.js +3 -1
  110. package/dist/components/ProgressBarGroup/ProgressBarGroup.css.js +12 -4
  111. package/dist/components/ProgressBarGroup/ProgressBarGroup.js +42 -14
  112. package/dist/components/ProgressBarGroup/index.js +3 -1
  113. package/dist/components/ProgressSpinner/ProgressSpinner.css.js +81 -73
  114. package/dist/components/ProgressSpinner/ProgressSpinner.js +32 -14
  115. package/dist/components/ProgressSpinner/index.js +3 -1
  116. package/dist/components/Radio/Radio.css.js +31 -23
  117. package/dist/components/Radio/Radio.js +58 -19
  118. package/dist/components/Radio/RadioGroup.js +32 -7
  119. package/dist/components/Radio/index.js +4 -2
  120. package/dist/components/Section/Section.css.js +13 -5
  121. package/dist/components/Section/Section.js +19 -4
  122. package/dist/components/Section/index.js +3 -1
  123. package/dist/components/SelectInput/SelectInput.css.js +19 -11
  124. package/dist/components/SelectInput/SelectInput.js +60 -11
  125. package/dist/components/SelectInput/index.js +3 -1
  126. package/dist/components/SimplePagination/SimplePagination.js +57 -17
  127. package/dist/components/SimplePagination/index.js +3 -1
  128. package/dist/components/Stack/Divider.css.js +12 -4
  129. package/dist/components/Stack/Divider.js +13 -4
  130. package/dist/components/Stack/Stack.css.js +18 -10
  131. package/dist/components/Stack/Stack.js +47 -23
  132. package/dist/components/Stack/index.js +3 -1
  133. package/dist/components/StandardModal/StandardModal.css.js +69 -57
  134. package/dist/components/StandardModal/StandardModal.js +127 -52
  135. package/dist/components/StandardModal/index.js +3 -1
  136. package/dist/components/StarRating/StarRating.css.js +16 -8
  137. package/dist/components/StarRating/StarRating.js +90 -46
  138. package/dist/components/StarRating/index.js +3 -1
  139. package/dist/components/Stepper/Stepper.css.js +46 -36
  140. package/dist/components/Stepper/Stepper.js +159 -66
  141. package/dist/components/Stepper/index.js +3 -1
  142. package/dist/components/Switch/Switch.css.js +54 -46
  143. package/dist/components/Switch/Switch.js +54 -21
  144. package/dist/components/Switch/index.js +3 -1
  145. package/dist/components/Table/Table.css.js +14 -6
  146. package/dist/components/Table/Table.js +29 -6
  147. package/dist/components/Table/TableCell.css.js +28 -20
  148. package/dist/components/Table/TableCell.js +41 -11
  149. package/dist/components/Table/TableHeadCell.css.js +61 -50
  150. package/dist/components/Table/TableHeadCell.js +86 -40
  151. package/dist/components/Table/TableRow.js +18 -3
  152. package/dist/components/Table/TableRowGroup.js +16 -3
  153. package/dist/components/Table/context.js +21 -10
  154. package/dist/components/Table/index.js +7 -5
  155. package/dist/components/Tabs/Tab.css.js +43 -35
  156. package/dist/components/Tabs/Tab.js +79 -49
  157. package/dist/components/Tabs/TabList.css.js +30 -22
  158. package/dist/components/Tabs/TabList.js +122 -67
  159. package/dist/components/Tabs/TabPane.css.js +11 -3
  160. package/dist/components/Tabs/TabPane.js +32 -15
  161. package/dist/components/Tabs/TabPanes.css.js +16 -8
  162. package/dist/components/Tabs/TabPanes.js +23 -6
  163. package/dist/components/Tabs/Tabs.js +22 -10
  164. package/dist/components/Tabs/index.js +7 -5
  165. package/dist/components/Text/Text.js +37 -15
  166. package/dist/components/Text/index.js +4 -2
  167. package/dist/components/Text/useTextStyles.css.js +42 -20
  168. package/dist/components/Text/useTextStyles.js +20 -5
  169. package/dist/components/TextAreaInput/TextAreaInput.js +35 -7
  170. package/dist/components/TextAreaInput/index.js +3 -1
  171. package/dist/components/TextBubble/TextBubble.css.js +13 -5
  172. package/dist/components/TextBubble/TextBubble.js +66 -29
  173. package/dist/components/TextBubble/index.js +3 -1
  174. package/dist/components/TextContainer/TextContainer.js +44 -9
  175. package/dist/components/TextContainer/index.js +3 -1
  176. package/dist/components/TextInput/TextInput.js +36 -5
  177. package/dist/components/TextInput/index.js +3 -1
  178. package/dist/components/TextLink/TextLink.css.js +23 -15
  179. package/dist/components/TextLink/TextLink.js +63 -24
  180. package/dist/components/TextLink/index.js +3 -1
  181. package/dist/components/ThemeOverrideProvider/ThemeOverrideDebugger.d.ts +3 -0
  182. package/dist/components/ThemeOverrideProvider/ThemeOverrideDebugger.d.ts.map +1 -0
  183. package/dist/components/ThemeOverrideProvider/ThemeOverrideDebugger.js +80 -0
  184. package/dist/components/ThemeOverrideProvider/ThemeOverrideProvider.d.ts +22 -0
  185. package/dist/components/ThemeOverrideProvider/ThemeOverrideProvider.d.ts.map +1 -0
  186. package/dist/components/ThemeOverrideProvider/ThemeOverrideProvider.js +39 -0
  187. package/dist/components/ThemeOverrideProvider/index.d.ts +3 -0
  188. package/dist/components/ThemeOverrideProvider/index.d.ts.map +1 -0
  189. package/dist/components/ThemeOverrideProvider/index.js +4 -0
  190. package/dist/components/ThemeOverrideProvider/useBuildThemeOverrides.d.ts +17 -0
  191. package/dist/components/ThemeOverrideProvider/useBuildThemeOverrides.d.ts.map +1 -0
  192. package/dist/components/ThemeOverrideProvider/useBuildThemeOverrides.js +97 -0
  193. package/dist/components/ThemeProvider/ThemeProvider.js +30 -11
  194. package/dist/components/ThemeProvider/index.js +3 -1
  195. package/dist/components/Toaster/Toast.css.js +18 -10
  196. package/dist/components/Toaster/Toast.js +222 -108
  197. package/dist/components/Toaster/index.js +3 -1
  198. package/dist/components/Tooltip/Tooltip.css.js +21 -9
  199. package/dist/components/Tooltip/Tooltip.js +72 -40
  200. package/dist/components/Tooltip/index.js +3 -1
  201. package/dist/components/VisuallyHidden/VisuallyHidden.css.js +13 -5
  202. package/dist/components/VisuallyHidden/VisuallyHidden.js +20 -4
  203. package/dist/components/VisuallyHidden/index.js +3 -1
  204. package/dist/components/index.d.ts +1 -0
  205. package/dist/components/index.d.ts.map +1 -1
  206. package/dist/components/index.js +59 -56
  207. package/dist/components/private/CheckableBase/CheckableBase.css.js +46 -38
  208. package/dist/components/private/CheckableBase/CheckableBase.js +91 -27
  209. package/dist/components/private/CheckableBase/index.js +3 -1
  210. package/dist/components/private/CheckableBase/useCheckableStyles.js +5 -3
  211. package/dist/components/private/InputBase/HintText.css.js +11 -3
  212. package/dist/components/private/InputBase/HintText.js +28 -14
  213. package/dist/components/private/InputBase/InputState.css.js +96 -80
  214. package/dist/components/private/InputBase/NotchedBase.css.js +157 -162
  215. package/dist/components/private/InputBase/NotchedBase.js +116 -76
  216. package/dist/components/private/InputBase/index.js +3 -1
  217. package/dist/components/private/InputBase/withEnhancedInput.css.js +117 -109
  218. package/dist/components/private/InputBase/withEnhancedInput.js +190 -92
  219. package/dist/hooks/useAttachedBoxes/index.js +3 -1
  220. package/dist/hooks/useAttachedBoxes/useAttachedBoxes.css.js +26 -18
  221. package/dist/hooks/useAttachedBoxes/useAttachedBoxes.js +71 -46
  222. package/dist/hooks/useMedia/index.js +3 -1
  223. package/dist/hooks/useMedia/useMedia.js +44 -34
  224. package/dist/hooks/useNegativeMargin/useNegativeMargin.js +4 -2
  225. package/dist/hooks/useNegativeMargin/useNegativeMarginLeft.css.js +13 -5
  226. package/dist/hooks/useNegativeMargin/useNegativeMarginLeft.js +6 -4
  227. package/dist/hooks/useNegativeMargin/useNegativeMarginTop.css.js +12 -4
  228. package/dist/hooks/useNegativeMargin/useNegativeMarginTop.js +6 -4
  229. package/dist/hooks/useResponsiveValue/index.js +3 -1
  230. package/dist/hooks/useResponsiveValue/useResponsiveValue.js +14 -14
  231. package/dist/hooks/useWindowScrollLock/index.js +15 -13
  232. package/dist/index.js +7 -5
  233. package/dist/reset/globalFonts.css.js +20 -12
  234. package/dist/reset/globalReset.css.js +21 -13
  235. package/dist/reset/reset.css.js +105 -109
  236. package/dist/themes/base/index.d.ts +1 -0
  237. package/dist/themes/base/index.d.ts.map +1 -1
  238. package/dist/themes/base/index.js +10 -6
  239. package/dist/themes/base/tokens.js +264 -257
  240. package/dist/themes/base/vars.css.js +10 -2
  241. package/dist/themes/flat_red/index.d.ts +1 -0
  242. package/dist/themes/flat_red/index.d.ts.map +1 -1
  243. package/dist/themes/flat_red/index.js +10 -6
  244. package/dist/themes/flat_red/tokens.js +104 -98
  245. package/dist/themes/flat_red/vars.css.js +10 -2
  246. package/dist/themes/helpers.js +60 -51
  247. package/dist/themes/index.js +4 -2
  248. package/dist/themes/makeTheme.js +27 -16
  249. package/dist/themes/theme.css.js +271 -259
  250. package/dist/themes/tokens.js +3 -1
  251. package/dist/utils/index.js +93 -77
  252. package/dist/utils/mapTokenToProperty.js +22 -10
  253. package/dist/utils/number.js +21 -24
  254. package/dist/utils/resolveResponsiveProps.js +29 -31
  255. package/dist/utils/responsiveProps.css.js +29 -17
  256. package/dist/utils/responsiveStyle.js +26 -16
  257. package/package.json +4 -2
@@ -1,112 +1,210 @@
1
+ "use strict";
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["placeholder", "name", "id", "hintText", "disabled", "className", "isTouched", "isValid", "isLoading", "notch", "reserveHintSpace", "size", "value", "onChange", "onReset", "onMouseLeave", "onMouseEnter", "onBlur", "onFocus", "onKeyDown", "prefixIcon", "suffixIcon", "wrapperRef", "autoFocus", "attach", "borderMerged"];
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
1
11
  import { invariant, wrapEvent } from '@autoguru/utilities';
2
12
  import clsx from 'clsx';
3
13
  import * as React from 'react';
4
- import { forwardRef, useCallback, useState, } from 'react';
5
- import { useInputControlledState } from '../../../utils';
6
- import { Box, useBoxStyles } from '../../Box';
7
- import { Icon } from '../../Icon';
8
- import { ProgressSpinner } from '../../ProgressSpinner';
9
- import { HintText } from './HintText';
10
- import * as inputStateStyles from './InputState.css';
11
- import { NotchedBase } from './NotchedBase';
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, attach, borderMerged, ...rest }, ref) => {
14
- invariant(!(prefixIcon && !withPrefixIcon), 'prefix icon is not supported for this component');
15
- invariant(!(suffixIcon && !withSuffixIcon), 'suffix icon is not supported for this component');
14
+ import { forwardRef, useCallback, useState } from 'react';
15
+ import { useInputControlledState } from "../../../utils/index.js";
16
+ import { Box, useBoxStyles } from "../../Box/index.js";
17
+ import { Icon } from "../../Icon/index.js";
18
+ import { ProgressSpinner } from "../../ProgressSpinner/index.js";
19
+ import { HintText } from "./HintText.js";
20
+ import * as inputStateStyles from "./InputState.css.js";
21
+ import { NotchedBase } from "./NotchedBase.js";
22
+ import * as styles from "./withEnhancedInput.css.js";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import { jsxs as _jsxs } from "react/jsx-runtime";
25
+ export const withEnhancedInput = function (WrappingComponent) {
26
+ let {
27
+ primitiveType = 'text',
28
+ withPrefixIcon = true,
29
+ withSuffixIcon = true,
30
+ defaultValue
31
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
32
+ primitiveType: 'text',
33
+ defaultValue: void 0
34
+ };
35
+ return forwardRef((_ref, ref) => {
36
+ let {
37
+ placeholder,
38
+ name,
39
+ id = name,
40
+ hintText,
41
+ disabled = false,
42
+ className,
43
+ isTouched,
44
+ isValid,
45
+ isLoading = false,
46
+ notch = true,
47
+ reserveHintSpace = false,
48
+ size = 'medium',
49
+ value: incomingValue = defaultValue || '',
50
+ onChange: incomingOnChange,
51
+ onReset,
52
+ onMouseLeave,
53
+ onMouseEnter,
54
+ onBlur,
55
+ onFocus,
56
+ onKeyDown,
57
+ prefixIcon,
58
+ suffixIcon,
59
+ wrapperRef,
60
+ autoFocus,
61
+ attach,
62
+ borderMerged
63
+ } = _ref,
64
+ rest = _objectWithoutProperties(_ref, _excluded);
65
+
66
+ !!(prefixIcon && !withPrefixIcon) ? process.env.NODE_ENV !== "production" ? invariant(false, 'prefix icon is not supported for this component') : invariant(false) : void 0;
67
+ !!(suffixIcon && !withSuffixIcon) ? process.env.NODE_ENV !== "production" ? invariant(false, 'suffix icon is not supported for this component') : invariant(false) : void 0;
16
68
  const [value, onChange] = useInputControlledState(incomingValue, incomingOnChange);
17
69
  const [isActive, setActive] = useState(false);
18
70
  const [isHovered, setIsHovered] = useState(false);
19
71
  const isEmpty = primitiveType === 'date' && value === '' ? false : value === '';
20
72
  const derivedColours = derivedColourIntent({
21
- isValid,
22
- isHovered,
23
- isActive,
24
- isTouched,
25
- disabled,
73
+ isValid,
74
+ isHovered,
75
+ isActive,
76
+ isTouched,
77
+ disabled
26
78
  }, inputStateStyles);
27
79
  const inputItselfClassName = clsx(useBoxStyles({
28
- is: primitiveType === 'textarea' ? 'textarea' : 'input',
29
- width: 'full',
30
- position: 'relative',
31
- display: 'flex',
80
+ is: primitiveType === 'textarea' ? 'textarea' : 'input',
81
+ width: 'full',
82
+ position: 'relative',
83
+ display: 'flex'
32
84
  }), styles.input.itself.root, styles.types[primitiveType], styles.inputItselfSize[size].root.any, styles.inputItselfSize[size].root[primitiveType], {
33
- [styles.inputItselfSize[size].prefixed.any]: Boolean(prefixIcon),
34
- [styles.inputItselfSize[size].prefixed[primitiveType]]: Boolean(prefixIcon),
35
- [styles.inputItselfSize[size].suffixed.any]: Boolean(suffixIcon || isLoading),
36
- [styles.inputItselfSize[size].suffixed[primitiveType]]: Boolean(suffixIcon || isLoading),
85
+ [styles.inputItselfSize[size].prefixed.any]: Boolean(prefixIcon),
86
+ [styles.inputItselfSize[size].prefixed[primitiveType]]: Boolean(prefixIcon),
87
+ [styles.inputItselfSize[size].suffixed.any]: Boolean(suffixIcon || isLoading),
88
+ [styles.inputItselfSize[size].suffixed[primitiveType]]: Boolean(suffixIcon || isLoading)
37
89
  });
38
- const wrappingComponent = {
39
- validation: {
40
- isTouched,
41
- isValid,
42
- },
43
- size,
44
- eventHandlers: {
45
- onChange: wrapEvent((event) => {
46
- if (disabled) {
47
- event.preventDefault();
48
- return false;
49
- }
50
- return true;
51
- }, onChange),
52
- onFocus: wrapEvent(() => setActive(true), onFocus),
53
- onBlur: wrapEvent(() => setActive(false), onBlur),
54
- onMouseEnter,
55
- onMouseLeave,
56
- onKeyDown,
57
- onReset,
58
- },
59
- field: {
60
- name,
61
- id,
62
- disabled,
63
- value,
64
- autoFocus,
65
- className: inputItselfClassName,
66
- placeholder: notch ? undefined : placeholder,
67
- ref,
68
- },
69
- prefixed: Boolean(prefixIcon),
70
- suffixed: Boolean(suffixIcon),
71
- isLoading,
72
- 'aria-busy': isLoading || void 0,
73
- ...rest,
74
- };
90
+
91
+ const wrappingComponent = _objectSpread({
92
+ validation: {
93
+ isTouched,
94
+ isValid
95
+ },
96
+ size,
97
+ eventHandlers: {
98
+ onChange: wrapEvent(event => {
99
+ if (disabled) {
100
+ event.preventDefault();
101
+ return false;
102
+ }
103
+
104
+ return true;
105
+ }, onChange),
106
+ onFocus: wrapEvent(() => setActive(true), onFocus),
107
+ onBlur: wrapEvent(() => setActive(false), onBlur),
108
+ onMouseEnter,
109
+ onMouseLeave,
110
+ onKeyDown,
111
+ onReset
112
+ },
113
+ field: {
114
+ name,
115
+ id,
116
+ disabled,
117
+ value,
118
+ autoFocus,
119
+ className: inputItselfClassName,
120
+ placeholder: notch ? undefined : placeholder,
121
+ ref
122
+ },
123
+ prefixed: Boolean(prefixIcon),
124
+ suffixed: Boolean(suffixIcon),
125
+ isLoading,
126
+ 'aria-busy': isLoading || void 0
127
+ }, rest);
128
+
75
129
  const onMouseOver = useCallback(() => {
76
- setIsHovered(true);
130
+ setIsHovered(true);
77
131
  }, []);
78
132
  const onMouseOut = useCallback(() => {
79
- setIsHovered(false);
133
+ setIsHovered(false);
80
134
  }, []);
81
135
  const iconStyles = useBoxStyles({
82
- pointerEvents: 'none',
83
- position: 'absolute',
136
+ pointerEvents: 'none',
137
+ position: 'absolute'
84
138
  });
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, attach: attach, borderMerged: borderMerged, isFocused: isActive, isHovered: isHovered, placeholderColourClassName: clsx({
87
- [derivedColours.colour]: !isEmpty,
88
- }), borderColourClassName: derivedColours.borderColour },
89
- React.createElement(Box, { ref: wrapperRef, className: styles.inputWrapperSize[size].root[primitiveType], width: "full", height: "full" },
90
- prefixIcon ? (React.createElement(Icon, { icon: prefixIcon, size: "medium", className: clsx(iconStyles, styles.iconRoot, styles.prefixIcon, styles.iconSize[size], derivedColours.colour) })) : null,
91
- isLoading ? (React.createElement(ProgressSpinner, { className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour) })) : null,
92
- suffixIcon && !isLoading ? (React.createElement(Icon, { icon: suffixIcon, size: "medium", className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour) })) : null,
93
- React.createElement(WrappingComponent, { ...wrappingComponent }))),
94
- hintText || reserveHintSpace ? (React.createElement(HintText, { className: derivedColours.colour, hintText: hintText, disabled: disabled, reserveHintSpace: reserveHintSpace })) : null));
95
- });
96
- const stateNodeGetter = (styles) => (isHovered, isActive) => {
97
- if (isHovered)
98
- return styles.hover;
99
- if (isActive)
100
- return styles.active;
101
- return styles.default;
139
+ return _jsxs(Box, {
140
+ width: "full",
141
+ className: className,
142
+ onMouseEnter: onMouseOver,
143
+ onMouseLeave: onMouseOut,
144
+ children: [_jsx(NotchedBase, {
145
+ id: id,
146
+ prefixed: Boolean(prefixIcon),
147
+ isEmpty: isEmpty,
148
+ size: size,
149
+ disabled: disabled,
150
+ notch: notch,
151
+ placeholder: placeholder,
152
+ attach: attach,
153
+ borderMerged: borderMerged,
154
+ isFocused: isActive,
155
+ isHovered: isHovered,
156
+ placeholderColourClassName: clsx({
157
+ [derivedColours.colour]: !isEmpty
158
+ }),
159
+ borderColourClassName: derivedColours.borderColour,
160
+ children: _jsxs(Box, {
161
+ ref: wrapperRef,
162
+ className: styles.inputWrapperSize[size].root[primitiveType],
163
+ width: "full",
164
+ height: "full",
165
+ children: [prefixIcon ? _jsx(Icon, {
166
+ icon: prefixIcon,
167
+ size: "medium",
168
+ className: clsx(iconStyles, styles.iconRoot, styles.prefixIcon, styles.iconSize[size], derivedColours.colour)
169
+ }) : null, isLoading ? _jsx(ProgressSpinner, {
170
+ className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour)
171
+ }) : null, suffixIcon && !isLoading ? _jsx(Icon, {
172
+ icon: suffixIcon,
173
+ size: "medium",
174
+ className: clsx(iconStyles, styles.iconRoot, styles.suffixIcon, styles.iconSize[size], derivedColours.colour)
175
+ }) : null, _jsx(WrappingComponent, _objectSpread({}, wrappingComponent))]
176
+ })
177
+ }), hintText || reserveHintSpace ? _jsx(HintText, {
178
+ className: derivedColours.colour,
179
+ hintText: hintText,
180
+ disabled: disabled,
181
+ reserveHintSpace: reserveHintSpace
182
+ }) : null]
183
+ });
184
+ });
102
185
  };
103
- const derivedColourIntent = ({ isTouched, isValid, disabled, isHovered, isActive }, styles) => {
104
- if (disabled)
105
- return styles.disabled;
106
- if (isTouched === true) {
107
- const node = stateNodeGetter(isValid ? styles.success : styles.error);
108
- return node(isHovered, isActive);
109
- }
110
- const node = stateNodeGetter(isActive ? styles.active : styles.natural);
111
- return node(isHovered, isActive);
186
+
187
+ const stateNodeGetter = styles => (isHovered, isActive) => {
188
+ if (isHovered) return styles.hover;
189
+ if (isActive) return styles.active;
190
+ return styles.default;
112
191
  };
192
+
193
+ const derivedColourIntent = (_ref2, styles) => {
194
+ let {
195
+ isTouched,
196
+ isValid,
197
+ disabled,
198
+ isHovered,
199
+ isActive
200
+ } = _ref2;
201
+ if (disabled) return styles.disabled;
202
+
203
+ if (isTouched === true) {
204
+ const node = stateNodeGetter(isValid ? styles.success : styles.error);
205
+ return node(isHovered, isActive);
206
+ }
207
+
208
+ const node = stateNodeGetter(isActive ? styles.active : styles.natural);
209
+ return node(isHovered, isActive);
210
+ };
@@ -1 +1,3 @@
1
- export { useAttachedBoxes } from './useAttachedBoxes';
1
+ "use strict";
2
+
3
+ export { useAttachedBoxes } from "./useAttachedBoxes.js";
@@ -1,21 +1,29 @@
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+
5
+ __vanilla_filescope__.setFileScope("lib/hooks/useAttachedBoxes/useAttachedBoxes.css.ts", "@autoguru/overdrive");
6
+
1
7
  import { style } from '@vanilla-extract/css';
2
- import { themeContractVars as vars } from '../../themes/theme.css';
3
- import { makeResponsiveStyle } from '../../utils/responsiveProps.css';
8
+ import { themeContractVars as vars } from "../../themes/theme.css.js";
9
+ import { makeResponsiveStyle } from "../../utils/responsiveProps.css.js";
4
10
  export const grid = {
5
- default: style({
6
- display: 'grid',
7
- }),
8
- gaps: makeResponsiveStyle(vars.space, 'gridGap'),
9
- topLeft: style({
10
- borderTopLeftRadius: vars.border.radius['1'],
11
- }),
12
- topRight: style({
13
- borderTopRightRadius: vars.border.radius['1'],
14
- }),
15
- bottomRight: style({
16
- borderBottomRightRadius: vars.border.radius['1'],
17
- }),
18
- bottomLeft: style({
19
- borderBottomLeftRadius: vars.border.radius['1'],
20
- }),
11
+ default: style({
12
+ display: 'grid'
13
+ }, "grid_default"),
14
+ gaps: makeResponsiveStyle(vars.space, 'gridGap'),
15
+ topLeft: style({
16
+ borderTopLeftRadius: vars.border.radius['1']
17
+ }, "grid_topLeft"),
18
+ topRight: style({
19
+ borderTopRightRadius: vars.border.radius['1']
20
+ }, "grid_topRight"),
21
+ bottomRight: style({
22
+ borderBottomRightRadius: vars.border.radius['1']
23
+ }, "grid_bottomRight"),
24
+ bottomLeft: style({
25
+ borderBottomLeftRadius: vars.border.radius['1']
26
+ }, "grid_bottomLeft")
21
27
  };
28
+
29
+ __vanilla_filescope__.endFileScope();
@@ -1,51 +1,76 @@
1
+ "use strict";
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["children", "className"];
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
1
11
  import clsx from 'clsx';
2
12
  import * as React from 'react';
3
- import { Box } from '../../components';
4
- import { getEarliestKnownToken, resolveResponsiveStyle, } from '../../utils/resolveResponsiveProps';
5
- import { useMedia } from '../useMedia';
6
- import * as styles from './useAttachedBoxes.css';
13
+ import { Box } from "../../components/index.js";
14
+ import { getEarliestKnownToken, resolveResponsiveStyle } from "../../utils/resolveResponsiveProps.js";
15
+ import { useMedia } from "../useMedia/index.js";
16
+ import * as styles from "./useAttachedBoxes.css.js";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+
7
19
  function useResponsiveValue(responsiveValue) {
8
- if (!Array.isArray(responsiveValue))
9
- return responsiveValue;
10
- const activeBP = useMedia(['mobile', 'tablet', 'desktop', 'largeDesktop'], false).reduce((activeBreakPoint, current, index) => {
11
- if (current)
12
- activeBreakPoint = index + 1;
13
- return activeBreakPoint;
14
- }, 1);
15
- return getEarliestKnownToken(responsiveValue, activeBP);
20
+ if (!Array.isArray(responsiveValue)) return responsiveValue;
21
+ const activeBP = useMedia(['mobile', 'tablet', 'desktop', 'largeDesktop'], false).reduce((activeBreakPoint, current, index) => {
22
+ if (current) activeBreakPoint = index + 1;
23
+ return activeBreakPoint;
24
+ }, 1);
25
+ return getEarliestKnownToken(responsiveValue, activeBP);
16
26
  }
17
- export const useAttachedBoxes = ({ count, columnCount: incomingColumnCount, gap = '1', backgroundColour = 'gray900', }) => {
18
- const columnCount = useResponsiveValue(incomingColumnCount);
19
- const decimals = (count / columnCount) % 1;
20
- let colStart;
21
- let extend;
22
- let isLastItem;
23
- const topRightIndex = Math.min(count - 1, columnCount - 1);
24
- const bottomLeftIndex = decimals
25
- ? Math.floor(count / columnCount) * columnCount
26
- : count - columnCount;
27
- return [
28
- Array.from({ length: count }).map((_, index) => ({ children, className, ...rest }) => {
29
- isLastItem = index === count - 1;
30
- if (isLastItem && decimals) {
31
- colStart = Math.round(decimals / (1 / columnCount));
32
- extend = Math.round((1 - decimals) / (1 / columnCount));
33
- }
34
- return (React.createElement(Box, { backgroundColour: backgroundColour, className: clsx(className, {
35
- [styles.grid.topLeft]: index === 0,
36
- [styles.grid.topRight]: index === topRightIndex,
37
- [styles.grid.bottomLeft]: index === bottomLeftIndex,
38
- [styles.grid.bottomRight]: isLastItem,
39
- }), style: isLastItem && decimals
40
- ? {
41
- gridColumn: `${colStart}/${colStart + 1 + extend}`,
42
- }
43
- : void 0, ...rest }, children));
44
- }),
45
- clsx(styles.grid.default, resolveResponsiveStyle(gap, styles.grid.gaps)),
46
- {
47
- gridTemplateColumns: `repeat(${columnCount}, 1fr)`,
48
- },
49
- ];
27
+
28
+ export const useAttachedBoxes = _ref => {
29
+ let {
30
+ count,
31
+ columnCount: incomingColumnCount,
32
+ gap = '1',
33
+ backgroundColour = 'gray900'
34
+ } = _ref;
35
+ const columnCount = useResponsiveValue(incomingColumnCount);
36
+ const decimals = count / columnCount % 1;
37
+ let colStart;
38
+ let extend;
39
+ let isLastItem;
40
+ const topRightIndex = Math.min(count - 1, columnCount - 1);
41
+ const bottomLeftIndex = decimals ? Math.floor(count / columnCount) * columnCount : count - columnCount;
42
+ return [Array.from({
43
+ length: count
44
+ }).map((_, index) => _ref2 => {
45
+ let {
46
+ children,
47
+ className
48
+ } = _ref2,
49
+ rest = _objectWithoutProperties(_ref2, _excluded);
50
+
51
+ isLastItem = index === count - 1;
52
+
53
+ if (isLastItem && decimals) {
54
+ colStart = Math.round(decimals / (1 / columnCount));
55
+ extend = Math.round((1 - decimals) / (1 / columnCount));
56
+ }
57
+
58
+ return _jsx(Box, _objectSpread(_objectSpread({
59
+ backgroundColour: backgroundColour,
60
+ className: clsx(className, {
61
+ [styles.grid.topLeft]: index === 0,
62
+ [styles.grid.topRight]: index === topRightIndex,
63
+ [styles.grid.bottomLeft]: index === bottomLeftIndex,
64
+ [styles.grid.bottomRight]: isLastItem
65
+ }),
66
+ style: isLastItem && decimals ? {
67
+ gridColumn: "".concat(colStart, "/").concat(colStart + 1 + extend)
68
+ } : void 0
69
+ }, rest), {}, {
70
+ children: children
71
+ }));
72
+ }), clsx(styles.grid.default, resolveResponsiveStyle(gap, styles.grid.gaps)), {
73
+ gridTemplateColumns: "repeat(".concat(columnCount, ", 1fr)")
74
+ }];
50
75
  };
51
- export default useAttachedBoxes;
76
+ export default useAttachedBoxes;
@@ -1 +1,3 @@
1
- export { useMedia } from './useMedia';
1
+ "use strict";
2
+
3
+ export { useMedia } from "./useMedia.js";
@@ -1,36 +1,46 @@
1
+ "use strict";
2
+
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
4
  import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
2
- import { useRuntimeTokens } from '../..';
3
- import { isBrowser } from '../../utils';
4
- export const useMedia = (queries, fallbackCase = false) => {
5
- const { breakpoints } = useRuntimeTokens();
6
- if (!isBrowser)
7
- return queries.map(() => fallbackCase);
8
- const getQueries = useCallback(() => queries.map((media) => `(min-width: ${breakpoints[media]})`), [breakpoints]);
9
- const matchesInit = useMemo(() => getQueries().map((query) => window.matchMedia(query).matches), [getQueries]);
10
- const [matches, setMatches] = useState(matchesInit);
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());
31
- };
32
- }, [...queries, breakpoints]);
33
- }
34
- return matches;
5
+ import { useRuntimeTokens } from "../../index.js";
6
+ import { isBrowser } from "../../utils/index.js";
7
+ export const useMedia = function (queries) {
8
+ let fallbackCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9
+ const {
10
+ breakpoints
11
+ } = useRuntimeTokens();
12
+ if (!isBrowser) return queries.map(() => fallbackCase);
13
+ const getQueries = useCallback(() => queries.map(media => "(min-width: ".concat(breakpoints[media], ")")), [breakpoints]);
14
+ const matchesInit = useMemo(() => getQueries().map(query => window.matchMedia(query).matches), [getQueries]);
15
+ const [matches, setMatches] = useState(matchesInit);
16
+
17
+ if (isBrowser) {
18
+ useLayoutEffect(() => {
19
+ let isMounted = true;
20
+ const matchers = getQueries().map(query => window.matchMedia(query));
21
+ const removeHandlersFn = matchers.map((matcher, idx) => {
22
+ const handler = e => {
23
+ if (!isMounted) return;
24
+ setMatches(prevState => {
25
+ const newState = _toConsumableArray(prevState);
26
+
27
+ newState[idx] = e.matches;
28
+ return newState;
29
+ });
30
+ };
31
+
32
+ matcher.addEventListener('change', handler, {
33
+ passive: true
34
+ });
35
+ return () => matcher.removeEventListener('change', handler);
36
+ });
37
+ return () => {
38
+ isMounted = false;
39
+ removeHandlersFn.forEach(item => item());
40
+ };
41
+ }, [].concat(_toConsumableArray(queries), [breakpoints]));
42
+ }
43
+
44
+ return matches;
35
45
  };
36
- export default useMedia;
46
+ export default useMedia;
@@ -1,2 +1,4 @@
1
- export { useNegativeMarginLeft } from './useNegativeMarginLeft';
2
- export { useNegativeMarginTop } from './useNegativeMarginTop';
1
+ "use strict";
2
+
3
+ export { useNegativeMarginLeft } from "./useNegativeMarginLeft.js";
4
+ export { useNegativeMarginTop } from "./useNegativeMarginTop.js";
@@ -1,6 +1,14 @@
1
- import { themeContractVars as vars } from '../../themes/theme.css';
2
- import { makeResponsiveStyle } from '../../utils/responsiveProps.css';
3
- export const negativeMarginLeft = makeResponsiveStyle(vars.space, (value) => ({
4
- marginLeft: `calc(-1 * ${value})`,
5
- width: `calc(100% + ${value})`,
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+
5
+ __vanilla_filescope__.setFileScope("lib/hooks/useNegativeMargin/useNegativeMarginLeft.css.ts", "@autoguru/overdrive");
6
+
7
+ import { themeContractVars as vars } from "../../themes/theme.css.js";
8
+ import { makeResponsiveStyle } from "../../utils/responsiveProps.css.js";
9
+ export const negativeMarginLeft = makeResponsiveStyle(vars.space, value => ({
10
+ marginLeft: "calc(-1 * ".concat(value, ")"),
11
+ width: "calc(100% + ".concat(value, ")")
6
12
  }));
13
+
14
+ __vanilla_filescope__.endFileScope();
@@ -1,4 +1,6 @@
1
- import { resolveResponsiveStyle } from '../../utils/resolveResponsiveProps';
2
- import * as styles from './useNegativeMarginLeft.css';
3
- export const useNegativeMarginLeft = (space) => resolveResponsiveStyle(space, styles.negativeMarginLeft);
4
- export default useNegativeMarginLeft;
1
+ "use strict";
2
+
3
+ import { resolveResponsiveStyle } from "../../utils/resolveResponsiveProps.js";
4
+ import * as styles from "./useNegativeMarginLeft.css.js";
5
+ export const useNegativeMarginLeft = space => resolveResponsiveStyle(space, styles.negativeMarginLeft);
6
+ export default useNegativeMarginLeft;
@@ -1,5 +1,13 @@
1
- import { themeContractVars as vars } from '../../themes/theme.css';
2
- import { makeResponsiveStyle } from '../../utils/responsiveProps.css';
3
- export const negativeMarginTop = makeResponsiveStyle(vars.space, (value) => ({
4
- marginTop: `calc(-1 * ${value})`,
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+
5
+ __vanilla_filescope__.setFileScope("lib/hooks/useNegativeMargin/useNegativeMarginTop.css.ts", "@autoguru/overdrive");
6
+
7
+ import { themeContractVars as vars } from "../../themes/theme.css.js";
8
+ import { makeResponsiveStyle } from "../../utils/responsiveProps.css.js";
9
+ export const negativeMarginTop = makeResponsiveStyle(vars.space, value => ({
10
+ marginTop: "calc(-1 * ".concat(value, ")")
5
11
  }));
12
+
13
+ __vanilla_filescope__.endFileScope();