@autoguru/overdrive 4.7.3 → 4.8.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSuggest.d.ts","sourceRoot":"","sources":["../../../lib/components/AutoSuggest/AutoSuggest.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIvE,OAAO,EACN,wBAAwB,EAIxB,YAAY,EAEZ,GAAG,EAQH,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,MAAM,WAAW,gBAAgB,CAAC,WAAW;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,oBAAY,uBAAuB,CAAC,WAAW,IAAI,CAAC,KAAK,EAAE;IAC1D,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;CAClD,KAAK,YAAY,CAAC;AAiCnB,aAAK,WAAW,CAAC,WAAW,IAAI,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;AAErE,MAAM,WAAW,KAAK,CAAC,WAAW,CACjC,SAAQ,IAAI,CACX,wBAAwB,CAAC,OAAO,SAAS,CAAC,EAC1C,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAC5C;IACD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IA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S,CAAC,EAC1C,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAC5C;IACD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEtC,YAAY,CAAC,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAEpD,QAAQ,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAEtD,OAAO,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;CACrD;AAwGD,eAAO,MAAM,WAAW;UA2FS,IAAI,gBAAgB,CAAC;MACjD,YAAY,CAAC;AAuhBlB,eAAe,WAAW,CAAC"}
@@ -4,6 +4,7 @@ import clsx from 'clsx';
4
4
  import * as React from 'react';
5
5
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, } from 'react';
6
6
  import { useMedia } from '../../hooks/useMedia';
7
+ import { useWindowScrollLock } from '../../hooks/useWindowScrollLock';
7
8
  import { setRef, useId } from '../../utils';
8
9
  import { Box } from '../Box';
9
10
  import { Button } from '../Button';
@@ -147,18 +148,7 @@ export const AutoSuggest = forwardRef(function AutoSuggest({ autoFocus = false,
147
148
  });
148
149
  const AutoSuggestFullscreenInput = forwardRef(function AutoSuggestFullscreenInput({ closeModal, ...props }, ref) {
149
150
  const [showPortal, setShowPortal] = useState(false);
150
- useEffect(() => {
151
- document.documentElement.style.position = 'fixed';
152
- document.documentElement.style.overflow = 'hidden';
153
- document.documentElement.style.maxHeight = '100%';
154
- document.documentElement.style.width = '100%';
155
- return () => {
156
- document.documentElement.style.position = '';
157
- document.documentElement.style.overflow = '';
158
- document.documentElement.style.maxHeight = '';
159
- document.documentElement.style.width = '';
160
- };
161
- }, []);
151
+ useWindowScrollLock();
162
152
  useEffect(() => {
163
153
  const cb = requestAnimationFrame(() => setShowPortal(true));
164
154
  return () => {
@@ -9,8 +9,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
  import { AccountEditIcon, AlertCircleIcon, CalendarIcon, CarIcon, CarMultipleIcon, CheckIcon, CurrencyUsdIcon, MagnifyIcon, PlusIcon, StarIcon } from '@autoguru/icons';
10
10
  import { action } from '@storybook/addon-actions';
11
11
  import * as React from 'react';
12
+ import { Box } from "../Box/index.js";
13
+ import { Stack } from "../Stack/index.js";
14
+ import { Text } from "../Text/index.js";
12
15
  import { AutoSuggest } from "./index.js";
13
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
18
  const mockSuggestions = ['Alfa Romeo', 'Aston Martin', 'Bentley', 'BMW', 'Bugatti', 'Ferrari', 'Jaguar', 'Koenigsegg', 'Lamborghini', 'Lotus', 'Maserati', 'McLaren', 'Pontiac', 'Porsche'].map(item => ({
15
19
  text: item,
16
20
  payload: item
@@ -83,7 +87,31 @@ export default {
83
87
  }
84
88
  };
85
89
 
86
- const Template = args => _jsx(AutoSuggest, _objectSpread({}, args));
90
+ const Template = args => _jsxs(Stack, {
91
+ space: "5",
92
+ children: [_jsx(Box, {
93
+ paddingTop: "8",
94
+ children: _jsx(AutoSuggest, _objectSpread({}, args))
95
+ }), _jsx(Text, {
96
+ is: "p",
97
+ children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis convallis neque a laoreet maximus. Vestibulum hendrerit quam at mi venenatis faucibus at vel nisi. In ut risus et ipsum tincidunt tempor. Suspendisse potenti. Praesent faucibus posuere risus, at congue mauris porttitor ut. Donec sit amet elit vitae purus dictum aliquet quis ut ligula. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum dui sapien, porttitor ac erat vel, malesuada rutrum mauris. Nam arcu tellus, pretium ut aliquet eget, ultrices vel est. Maecenas dapibus volutpat eros a volutpat."
98
+ }), _jsx(Text, {
99
+ is: "p",
100
+ children: "Sed ante dui, sagittis sit amet tortor nec, egestas tincidunt mauris. Phasellus sed felis arcu. Etiam sit amet pharetra risus, a posuere magna. Pellentesque finibus arcu vitae orci luctus sagittis. Proin porta metus ut dapibus pharetra. Sed interdum mi et tristique aliquam. Curabitur finibus at dolor eu fermentum. Cras diam mauris, malesuada quis lacinia eu, porttitor at lectus. Duis pellentesque ante eget efficitur lacinia. Vivamus ornare venenatis tortor euismod imperdiet."
101
+ }), _jsx(Text, {
102
+ is: "p",
103
+ children: "Nulla condimentum iaculis nisi, quis lobortis ligula. Nulla tempus semper velit, id ullamcorper orci molestie vel. Sed maximus nisi ac risus malesuada, quis varius purus interdum. Donec volutpat dolor in euismod hendrerit. Integer posuere tortor sit amet turpis viverra euismod. Mauris scelerisque ex diam, eget sodales erat accumsan vel. Etiam interdum odio a tortor fermentum, molestie interdum tellus bibendum. Vivamus vitae pulvinar ante. Aenean convallis aliquam velit congue ultricies. Aenean vel blandit erat. Mauris quis auctor nibh. Morbi dui ipsum, lobortis non nisi vitae, convallis pulvinar nunc."
104
+ }), _jsx(Text, {
105
+ is: "p",
106
+ children: "Morbi mollis massa in eros tempus, ut venenatis ligula posuere. Nam ut ante lectus. Integer congue risus arcu, et ornare odio hendrerit eu. Mauris arcu ligula, interdum vitae consectetur vitae, volutpat a elit. Nulla luctus faucibus ipsum vitae maximus. Quisque in est nec libero commodo egestas. Donec faucibus, felis eget euismod facilisis, urna tortor molestie ex, eu eleifend leo tellus vel ligula. Mauris et urna massa. Integer ultrices massa commodo eleifend facilisis. Vestibulum dapibus magna cursus metus pellentesque tempor. Donec blandit elementum feugiat. Sed nec congue est."
107
+ }), _jsx(Text, {
108
+ is: "p",
109
+ children: "Nulla quam magna, aliquet et odio non, porta condimentum tellus. Maecenas fringilla sodales erat eu facilisis. Nunc rutrum purus quis diam tempus laoreet. Fusce gravida arcu et lectus ultricies suscipit. Quisque sagittis tempus diam, malesuada posuere lorem sagittis et. Duis eget eros nibh. Aenean at augue tincidunt nunc consequat porta."
110
+ }), _jsx(Text, {
111
+ is: "p",
112
+ children: "Nunc ac congue lacus, ac vulputate lectus. Suspendisse vel malesuada tellus. In nec fringilla elit. Cras vitae metus et leo convallis consectetur. Cras quis congue sapien, vitae aliquet ante. Integer sed lorem pretium, vestibulum arcu eu, imperdiet mauris. Nam blandit pharetra feugiat. Maecenas eget ante metus. Vivamus pretium ipsum justo, a faucibus ex dictum non. Vestibulum et dui diam."
113
+ })]
114
+ });
87
115
 
88
116
  const standardProps = {
89
117
  value: null,
@@ -14,6 +14,7 @@ export interface Props extends Pick<ButtonPrimitive, 'id' | 'onClick' | 'type' |
14
14
  rounded?: boolean;
15
15
  size?: keyof typeof styles.size;
16
16
  variant?: keyof typeof styles.variant;
17
+ withDoubleClicks?: boolean;
17
18
  }
18
19
  export declare const Button: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLButtonElement>>;
19
20
  export default Button;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../lib/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,cAAc,EACd,oBAAoB,EAIpB,WAAW,EAGX,YAAY,EAEZ,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAEvC,aAAK,eAAe,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAE/D,aAAK,eAAe,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEzC,MAAM,WAAW,KAChB,SAAQ,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW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,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC,OAAO,CAAC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAqBD,eAAO,MAAM,MAAM,iFAgLlB,CAAC;AAqCF,eAAe,MAAM,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import clsx from 'clsx';
2
2
  import * as React from 'react';
3
- import { cloneElement, createElement, forwardRef, isValidElement, useMemo, } from 'react';
3
+ import { cloneElement, createElement, forwardRef, isValidElement, useCallback, useEffect, useMemo, useState, } from 'react';
4
4
  import { Box, useBoxStyles } from '../Box';
5
5
  import { Icon } from '../Icon';
6
6
  import { ProgressSpinner } from '../ProgressSpinner';
7
7
  import { useTextStyles } from '../Text';
8
8
  import * as styles from './Button.css';
9
+ const DOUBLE_CLICK_DETECTION_PERIOD = 700;
9
10
  const getSpinnerColour = (variant, minimal) => minimal || variant === 'secondary' ? 'secondary' : 'light';
10
11
  const getBorderRadius = (rounded) => rounded ? 'pill' : '1';
11
12
  const getPadding = (size, loading) => {
@@ -13,7 +14,7 @@ const getPadding = (size, loading) => {
13
14
  return 'none';
14
15
  return size === 'small' ? '3' : '4';
15
16
  };
16
- export const Button = forwardRef(({ children, className = '', disabled = false, id, is: Component = 'button', isLoading = false, isFullWidth = false, minimal = false, onClick, rounded = false, size = 'medium', type = 'button', variant = 'secondary', 'aria-label': ariaLabel, }, ref) => {
17
+ export const Button = forwardRef(({ children, className = '', disabled = false, id, is: Component = 'button', withDoubleClicks = false, isLoading = false, isFullWidth = false, minimal = false, onClick: incomingOnClick, rounded = false, size = 'medium', type = 'button', variant = 'secondary', 'aria-label': ariaLabel, }, ref) => {
17
18
  const { isSingleIconChild, props: maybeIconProps } = useMemo(() => {
18
19
  const maybeIcon = isValidElement(children) && children.type === Icon;
19
20
  const maybeProps = children;
@@ -24,11 +25,19 @@ export const Button = forwardRef(({ children, className = '', disabled = false,
24
25
  }
25
26
  : { isSingleIconChild: false };
26
27
  }, [children]);
28
+ const [functionallyDisabled, setFunctionallyDisabled] = useState(false);
29
+ const onClick = useCallback((event) => {
30
+ if (!withDoubleClicks)
31
+ setFunctionallyDisabled(true);
32
+ if (typeof incomingOnClick === 'function')
33
+ incomingOnClick(event);
34
+ }, [withDoubleClicks, incomingOnClick]);
27
35
  const props = {
28
36
  type: Component === 'button' ? type : undefined,
29
37
  id,
30
38
  onClick,
31
39
  disabled: disabled || isLoading,
40
+ tabIndex: disabled ? -1 : void 0,
32
41
  'aria-label': ariaLabel,
33
42
  className: clsx(useBoxStyles({
34
43
  is: typeof Component === 'string' ? Component : undefined,
@@ -40,6 +49,7 @@ export const Button = forwardRef(({ children, className = '', disabled = false,
40
49
  paddingY: 'none',
41
50
  paddingX: getPadding(size, isLoading),
42
51
  width: isFullWidth ? 'full' : void 0,
52
+ pointerEvents: functionallyDisabled ? 'none' : void 0,
43
53
  }), useTextStyles({
44
54
  colour: 'white',
45
55
  fontWeight: 'semiBold',
@@ -54,6 +64,12 @@ export const Button = forwardRef(({ children, className = '', disabled = false,
54
64
  const buttonContents = useMemo(() => (React.createElement(React.Fragment, null, isSingleIconChild && maybeIconProps ? (React.createElement(Icon, { size: maybeIconProps.size ?? size === 'small'
55
65
  ? 'small'
56
66
  : 'medium', ...maybeIconProps })) : (children))), [maybeIconProps, isSingleIconChild, children, size]);
67
+ useEffect(() => {
68
+ let timeout;
69
+ if (functionallyDisabled)
70
+ timeout = setTimeout(() => setFunctionallyDisabled(false), DOUBLE_CLICK_DETECTION_PERIOD);
71
+ return () => (timeout ? clearTimeout(timeout) : void 0);
72
+ }, [functionallyDisabled]);
57
73
  const child = isLoading ? (React.createElement(Box, { display: "flex", justifyContent: "center", position: "relative", alignItems: "center", width: "full", height: "full" },
58
74
  React.createElement(Box, { position: "absolute", alignItems: "center", justifyContent: "center", display: "flex", width: "full", height: "full" },
59
75
  React.createElement(ProgressSpinner, { className: styles.spinner, colour: getSpinnerColour(variant, minimal) })),
@@ -7,6 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  import { AccountBoxIcon } from '@autoguru/icons';
10
+ import { action } from '@storybook/addon-actions';
10
11
  import * as React from 'react';
11
12
  import { Column, Columns } from "../Columns/index.js";
12
13
  import { Icon } from "../Icon/index.js";
@@ -14,6 +15,7 @@ import { Button } from "./index.js";
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ const onClick = action('onClick');
17
19
  export default {
18
20
  title: 'Components/Buttons',
19
21
  component: Button,
@@ -204,67 +206,78 @@ const standardProps = {
204
206
  isFullWidth: void 0,
205
207
  size: void 0,
206
208
  variant: void 0,
207
- children: 'Login'
209
+ children: 'Login',
210
+ onClick
208
211
  };
209
212
  export const standard = Template.bind(standardProps);
210
213
  standard.args = standardProps;
211
214
  const primarySmallProps = {
212
215
  size: 'small',
213
- variant: 'primary'
216
+ variant: 'primary',
217
+ onClick
214
218
  };
215
219
  export const primarySmall = TemplateMulti.bind(primarySmallProps);
216
220
  primarySmall.args = primarySmallProps;
217
221
  const primaryMediumProps = {
218
222
  size: 'medium',
219
- variant: 'primary'
223
+ variant: 'primary',
224
+ onClick
220
225
  };
221
226
  export const primaryMedium = TemplateMulti.bind(primaryMediumProps);
222
227
  primaryMedium.args = primaryMediumProps;
223
228
  const secondarySmallProps = {
224
229
  size: 'small',
225
- variant: 'secondary'
230
+ variant: 'secondary',
231
+ onClick
226
232
  };
227
233
  export const secondarySmall = TemplateMulti.bind(secondarySmallProps);
228
234
  secondarySmall.args = secondarySmallProps;
229
235
  const secondaryMediumProps = {
230
236
  size: 'medium',
231
- variant: 'secondary'
237
+ variant: 'secondary',
238
+ onClick
232
239
  };
233
240
  export const secondaryMedium = TemplateMulti.bind(secondaryMediumProps);
234
241
  secondaryMedium.args = secondaryMediumProps;
235
242
  const informationSmallProps = {
236
243
  size: 'small',
237
- variant: 'information'
244
+ variant: 'information',
245
+ onClick
238
246
  };
239
247
  export const informationSmall = TemplateMulti.bind(informationSmallProps);
240
248
  informationSmall.args = informationSmallProps;
241
249
  const informationMediumProps = {
242
250
  size: 'medium',
243
- variant: 'information'
251
+ variant: 'information',
252
+ onClick
244
253
  };
245
254
  export const informationMedium = TemplateMulti.bind(informationMediumProps);
246
255
  informationMedium.args = informationMediumProps;
247
256
  const warningSmallProps = {
248
257
  size: 'small',
249
- variant: 'warning'
258
+ variant: 'warning',
259
+ onClick
250
260
  };
251
261
  export const warningSmall = TemplateMulti.bind(warningSmallProps);
252
262
  warningSmall.args = warningSmallProps;
253
263
  const warningMediumProps = {
254
264
  size: 'medium',
255
- variant: 'warning'
265
+ variant: 'warning',
266
+ onClick
256
267
  };
257
268
  export const warningMedium = TemplateMulti.bind(warningMediumProps);
258
269
  warningMedium.args = warningMediumProps;
259
270
  const successSmallProps = {
260
271
  size: 'small',
261
- variant: 'success'
272
+ variant: 'success',
273
+ onClick
262
274
  };
263
275
  export const successSmall = TemplateMulti.bind(successSmallProps);
264
276
  successSmall.args = successSmallProps;
265
277
  const successMediumProps = {
266
278
  size: 'medium',
267
- variant: 'success'
279
+ variant: 'success',
280
+ onClick
268
281
  };
269
282
  export const successMedium = TemplateMulti.bind(successMediumProps);
270
283
  successMedium.args = successMediumProps;
@@ -1 +1 @@
1
- {"version":3,"file":"SimplePagination.d.ts","sourceRoot":"","sources":["../../../lib/components/SimplePagination/SimplePagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAO1C,oBAAY,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,IAAI,SAAS;CACb;AAED,aAAK,qBAAqB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAE/D,MAAM,WAAW,KAAK;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,KAAK,CAuCrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SimplePagination.d.ts","sourceRoot":"","sources":["../../../lib/components/SimplePagination/SimplePagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAO1C,oBAAY,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,IAAI,SAAS;CACb;AAED,aAAK,qBAAqB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAE/D,MAAM,WAAW,KAAK;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,KAAK,CAyCrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -14,9 +14,9 @@ export const SimplePagination = ({ hasNext = false, hasPrevious = false, onChang
14
14
  onChange(direction);
15
15
  };
16
16
  return (React.createElement(Inline, { is: "nav", space: "6", "aria-label": "pagination", alignX: "center", alignY: "center" },
17
- React.createElement(Button, { rounded: true, disabled: !hasPrevious, size: "small", variant: "secondary", "aria-label": "previous page", onClick: handleClick(EChangeDirection.Previous) },
17
+ React.createElement(Button, { rounded: true, withDoubleClicks: true, disabled: !hasPrevious, size: "small", variant: "secondary", "aria-label": "previous page", onClick: handleClick(EChangeDirection.Previous) },
18
18
  React.createElement(Icon, { size: "medium", icon: ChevronLeftIcon })),
19
- React.createElement(Button, { rounded: true, disabled: !hasNext, size: "small", variant: "secondary", "aria-label": "next page", onClick: handleClick(EChangeDirection.Next) },
19
+ React.createElement(Button, { rounded: true, withDoubleClicks: true, disabled: !hasNext, size: "small", variant: "secondary", "aria-label": "next page", onClick: handleClick(EChangeDirection.Next) },
20
20
  React.createElement(Icon, { size: "medium", icon: ChevronRightIcon }))));
21
21
  };
22
22
  export default SimplePagination;
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../lib/components/Switch/Switch.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,OAAO,CAAC;AAOjE,MAAM,WAAW,KAAK;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,QAAQ,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAgE3C,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../lib/components/Switch/Switch.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAOvD,MAAM,WAAW,KAAK;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,QAAQ,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAsD3C,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,12 +1,10 @@
1
1
  import clsx from 'clsx';
2
2
  import * as React from 'react';
3
- import { useCallback, useState } from 'react';
3
+ import { useCallback } from 'react';
4
4
  import { Box, useBoxStyles } from '../Box';
5
5
  import { useTextStyles } from '../Text';
6
6
  import * as styles from './Switch.css';
7
- export const Switch = ({ className = '', disabled = false, toggled: incomingToggled = false, onChange, }) => {
8
- const [toggled, setToggled] = useState(incomingToggled);
9
- const [prevValue, setPrevValue] = useState(incomingToggled);
7
+ export const Switch = ({ className = '', disabled = false, toggled = false, onChange, }) => {
10
8
  const onToggle = useCallback(() => {
11
9
  if (disabled) {
12
10
  return;
@@ -14,17 +12,12 @@ export const Switch = ({ className = '', disabled = false, toggled: incomingTogg
14
12
  if (typeof onChange === 'function') {
15
13
  onChange(!toggled);
16
14
  }
17
- setToggled(!toggled);
18
- }, [incomingToggled, disabled, toggled]);
19
- if (prevValue !== incomingToggled) {
20
- setToggled(incomingToggled);
21
- setPrevValue(incomingToggled);
22
- }
15
+ }, [disabled, toggled]);
23
16
  return (React.createElement(Box, { is: "button", className: clsx(styles.root, useTextStyles({ size: '5' }), {
24
17
  [styles.toggled]: toggled,
25
18
  [styles.disabled.default]: disabled,
26
19
  [styles.disabled.toggled]: toggled && disabled,
27
- }, className), borderRadius: "pill", position: "relative", "aria-disabled": disabled, "aria-label": `toggle ${toggled ? 'on' : 'off'}`, onClick: onToggle },
20
+ }, className), tabIndex: disabled ? -1 : void 0, borderRadius: "pill", position: "relative", "aria-disabled": disabled, "aria-label": `toggle ${toggled ? 'on' : 'off'}`, onClick: onToggle },
28
21
  React.createElement(Box, { borderWidth: "1", position: "absolute", borderRadius: "pill", backgroundColour: "white", padding: "none", boxShadow: "2", className: clsx(styles.handle.default, useBoxStyles({ is: 'button' }), useTextStyles({ colour: 'white' }), {
29
22
  [styles.handle.transition]: toggled,
30
23
  }) })));
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["onChange", "value"];
4
6
 
5
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; }
6
8
 
@@ -15,7 +17,21 @@ export default {
15
17
  component: Switch
16
18
  };
17
19
 
18
- const Template = args => _jsx(Switch, _objectSpread({}, args));
20
+ const Template = _ref => {
21
+ let {
22
+ onChange: incomingOnChange,
23
+ value
24
+ } = _ref,
25
+ args = _objectWithoutProperties(_ref, _excluded);
26
+
27
+ return _jsx(Switch, _objectSpread({
28
+ onChange: stepValue => {
29
+ setValue(stepValue);
30
+ incomingOnChange(stepValue);
31
+ },
32
+ value: value
33
+ }, args));
34
+ };
19
35
 
20
36
  const standardProps = {
21
37
  disabled: false,
@@ -23,4 +39,26 @@ const standardProps = {
23
39
  onChange: action('onChange')
24
40
  };
25
41
  export const untoggled = Template.bind(standardProps);
26
- untoggled.args = standardProps;
42
+ untoggled.args = standardProps;
43
+
44
+ const untoggledDisabledProps = _objectSpread(_objectSpread({}, standardProps), {}, {
45
+ disabled: true
46
+ });
47
+
48
+ export const untoggledDisabled = Template.bind(untoggledDisabledProps);
49
+ untoggledDisabled.args = untoggledDisabledProps;
50
+
51
+ const toggledProps = _objectSpread(_objectSpread({}, standardProps), {}, {
52
+ toggled: true
53
+ });
54
+
55
+ export const toggled = Template.bind(toggledProps);
56
+ toggled.args = toggledProps;
57
+
58
+ const toggledDisabledProps = _objectSpread(_objectSpread({}, standardProps), {}, {
59
+ toggled: true,
60
+ disabled: true
61
+ });
62
+
63
+ export const toggledDisabled = Template.bind(toggledDisabledProps);
64
+ toggledDisabled.args = toggledDisabledProps;
@@ -1 +1 @@
1
- {"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../lib/components/Tabs/TabList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIN,SAAS,EAKT,MAAM,OAAO,CAAC;AAWf,MAAM,WAAW,KAAK;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,uBAAqC,CAAC;AAEjE,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAqI5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../lib/components/Tabs/TabList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIN,SAAS,EAKT,MAAM,OAAO,CAAC;AAWf,MAAM,WAAW,KAAK;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,uBAAqC,CAAC;AAEjE,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAuI5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -66,11 +66,11 @@ export const TabList = ({ children, stretch = false, scrollable = false, }) => {
66
66
  styles.root.default,
67
67
  shouldShowScrollButtons && styles.root.scroll,
68
68
  ] },
69
- shouldShowScrollButtons ? (React.createElement(Button, { minimal: true, rounded: true, size: "small", disabled: !displayScroll.start, onClick: handleStartButton },
69
+ shouldShowScrollButtons ? (React.createElement(Button, { minimal: true, rounded: true, withDoubleClicks: true, size: "small", disabled: !displayScroll.start, onClick: handleStartButton },
70
70
  React.createElement(Icon, { icon: ArrowLeftIcon }))) : null,
71
71
  React.createElement(Box, { ref: wrapperRef, className: [scrollable && styles.listWrapperScroll], onScroll: handleOnScroll },
72
72
  React.createElement(Box, { ref: innerRef, display: stretch ? 'flex' : 'block', flexWrap: "nowrap", width: "full", role: "tablist", "aria-orientation": "horizontal", className: useTextStyles({ noWrap: true }) }, tabs)),
73
- shouldShowScrollButtons ? (React.createElement(Button, { minimal: true, rounded: true, size: "small", disabled: !displayScroll.end, onClick: handleEndButton },
73
+ shouldShowScrollButtons ? (React.createElement(Button, { minimal: true, rounded: true, withDoubleClicks: true, size: "small", disabled: !displayScroll.end, onClick: handleEndButton },
74
74
  React.createElement(Icon, { icon: ArrowRightIcon }))) : null));
75
75
  };
76
76
  export default TabList;
@@ -1 +1 @@
1
- {"version":3,"file":"CheckableBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/CheckableBase/CheckableBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA2B,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3D,MAAM,WAAW,KAAK;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,WAAW,CAAC,KAAK,KAAA,GAAG,IAAI,CAAC;IAEzB,YAAY,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,aAAa,gFAgGzB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"CheckableBase.d.ts","sourceRoot":"","sources":["../../../../lib/components/private/CheckableBase/CheckableBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA2B,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3D,MAAM,WAAW,KAAK;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,WAAW,CAAC,KAAK,KAAA,GAAG,IAAI,CAAC;IAEzB,YAAY,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,aAAa,gFAiGzB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -17,7 +17,7 @@ export const CheckableBase = forwardRef(({ className = '', label = '', checked =
17
17
  className,
18
18
  { [styles.disabled]: disabled },
19
19
  ] },
20
- React.createElement(Box, { ref: ref, is: "input", position: "absolute", width: "full", height: "full", margin: "none", padding: "none", name: inputName, value: value, checked: checked, disabled: disabled, type: inputType, pointerEvents: disabled ? 'none' : void 0, className: clsx(useBoxStyles({ is: 'button' }), styles.nativeInput.default, {
20
+ React.createElement(Box, { ref: ref, is: "input", position: "absolute", width: "full", height: "full", margin: "none", padding: "none", name: inputName, value: value, checked: checked, disabled: disabled, tabIndex: disabled ? -1 : void 0, type: inputType, pointerEvents: disabled ? 'none' : void 0, className: clsx(useBoxStyles({ is: 'button' }), styles.nativeInput.default, {
21
21
  [styles.nativeInput.checked]: checked,
22
22
  }), onClick: handleClick, onChange: onChange }),
23
23
  React.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center", position: "relative", className: [
@@ -0,0 +1,2 @@
1
+ export declare const useWindowScrollLock: () => void;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/hooks/useWindowScrollLock/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAezB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { useEffect } from 'react';
2
+ export const useWindowScrollLock = () => useEffect(() => {
3
+ const scrollPos = window.scrollY;
4
+ document.documentElement.style.position = 'fixed';
5
+ document.documentElement.style.overflow = 'hidden';
6
+ document.documentElement.style.maxHeight = '100%';
7
+ document.documentElement.style.width = '100%';
8
+ return () => {
9
+ document.documentElement.style.position = '';
10
+ document.documentElement.style.overflow = '';
11
+ document.documentElement.style.maxHeight = '';
12
+ document.documentElement.style.width = '';
13
+ window.scrollTo(0, scrollPos);
14
+ };
15
+ }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.7.3",
3
+ "version": "4.8.1",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",