@autoguru/overdrive 4.13.0 → 4.14.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.
@@ -0,0 +1,7 @@
1
+ export declare const controllerBtn: string;
2
+ export declare const controllerCol: string;
3
+ export declare const prevBtn: string;
4
+ export declare const nextBtn: string;
5
+ export declare const item: string;
6
+ export declare const active: string;
7
+ //# sourceMappingURL=HorizontalAutoScroller.css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalAutoScroller.css.d.ts","sourceRoot":"","sources":["../../../lib/components/HorizontalAutoScroller/HorizontalAutoScroller.css.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,QAKxB,CAAC;AACH,eAAO,MAAM,aAAa,QAExB,CAAC;AAEH,eAAO,MAAM,OAAO,QAIlB,CAAC;AAEH,eAAO,MAAM,OAAO,QAIlB,CAAC;AAEH,eAAO,MAAM,IAAI,QAMf,CAAC;AACH,eAAO,MAAM,MAAM,QAGjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+ __vanilla_filescope__.setFileScope("lib/components/HorizontalAutoScroller/HorizontalAutoScroller.css.ts", "@autoguru/overdrive");
5
+ import { style } from '@vanilla-extract/css';
6
+ import { themeContractVars as vars } from "../../themes/theme.css.js";
7
+ const actionWidth = 50;
8
+ export const controllerBtn = style({
9
+ top: 0,
10
+ height: '100%',
11
+ width: actionWidth,
12
+ zIndex: 9
13
+ }, "controllerBtn");
14
+ export const controllerCol = style({
15
+ width: actionWidth
16
+ }, "controllerCol");
17
+ export const prevBtn = style({
18
+ left: 0,
19
+ background: 'linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.6769301470588236) 70%, rgba(255,255,255,0) 100%)'
20
+ }, "prevBtn");
21
+ export const nextBtn = style({
22
+ right: 0,
23
+ background: 'linear-gradient(-90deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.6769301470588236) 70%, rgba(255,255,255,0) 100%)'
24
+ }, "nextBtn");
25
+ export const item = style({
26
+ userSelect: 'none',
27
+ willChange: 'transform',
28
+ transition: "opacity 0.3s ".concat(vars.animation.easing.standard, " 0s, transform 0.3s ").concat(vars.animation.easing.standard, " 0s"),
29
+ transform: 'scale(0.9)',
30
+ opacity: 0.6
31
+ }, "item");
32
+ export const active = style({
33
+ transform: 'scale(1)',
34
+ opacity: 1
35
+ }, "active");
36
+ __vanilla_filescope__.endFileScope();
@@ -0,0 +1,15 @@
1
+ import { ComponentProps, FunctionComponent, ReactNode } from 'react';
2
+ import { SliderProgress } from '..';
3
+ import { Column, Columns } from '../Columns';
4
+ import { UseHorizontalAutoScrollerProps } from './useHorizontalAutoScroller';
5
+ export interface Props extends Pick<ComponentProps<typeof Columns>, 'space'>, Omit<UseHorizontalAutoScrollerProps, 'itemsRef'> {
6
+ durationSeconds?: number;
7
+ className?: string;
8
+ columnWidth?: ComponentProps<typeof Column>['width'];
9
+ sliderProgressColour?: ComponentProps<typeof SliderProgress>['backgroundColour'];
10
+ noControls?: boolean;
11
+ children: ReactNode | ReactNode[];
12
+ }
13
+ export declare const HorizontalAutoScroller: FunctionComponent<Props>;
14
+ export default HorizontalAutoScroller;
15
+ //# sourceMappingURL=HorizontalAutoScroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HorizontalAutoScroller.d.ts","sourceRoot":"","sources":["../../../lib/components/HorizontalAutoScroller/HorizontalAutoScroller.tsx"],"names":[],"mappings":"AAGA,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,SAAS,EAGT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAEN,8BAA8B,EAC9B,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,KAChB,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,EAAE,OAAO,CAAC,EACpD,IAAI,CAAC,8BAA8B,EAAE,UAAU,CAAC;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;IACrD,oBAAoB,CAAC,EAAE,cAAc,CACpC,OAAO,cAAc,CACrB,CAAC,kBAAkB,CAAC,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,KAAK,CA0J3D,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ import { ChevronLeftIcon, ChevronRightIcon } from '@autoguru/icons';
4
+ import clsx from 'clsx';
5
+ import * as React from 'react';
6
+ import { useMemo, useState } from 'react';
7
+ import flattenChildren from 'react-keyed-flatten-children';
8
+ import { SliderProgress } from "../index.js";
9
+ import { Box } from "../Box/index.js";
10
+ import { Button } from "../Button/index.js";
11
+ import { Column, Columns } from "../Columns/index.js";
12
+ import { Icon } from "../Icon/index.js";
13
+ import Section from "../Section/Section.js";
14
+ import { Stack } from "../Stack/index.js";
15
+ import * as styles from "./HorizontalAutoScroller.css.js";
16
+ import { useHorizontalAutoScroller } from "./useHorizontalAutoScroller.js";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { Fragment as _Fragment } from "react/jsx-runtime";
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ export const HorizontalAutoScroller = _ref => {
21
+ let {
22
+ sliderProgressColour = 'primary',
23
+ noControls = false,
24
+ space = '5',
25
+ durationSeconds = 10,
26
+ children,
27
+ itemsPerPage: incomingItemsPerPage,
28
+ paused: incomingIsPaused,
29
+ activePage: incomingActivePage,
30
+ columnWidth = '1/2',
31
+ className
32
+ } = _ref;
33
+ const incomingItems = useMemo(() => flattenChildren(children), [children]);
34
+ const [activeIndex, setActiveIndex] = useState(incomingActivePage);
35
+ const [itemsRef, setItemsRef] = useState();
36
+ const items = useMemo(() => {
37
+ const itemsRef = [];
38
+ const list = incomingItems.map((item, index) => _jsx(Column, {
39
+ ref: el => {
40
+ if (el) itemsRef.push(el);
41
+ },
42
+ noShrink: true,
43
+ width: columnWidth,
44
+ justifyContent: "stretch",
45
+ alignSelf: "stretch",
46
+ children: _jsx(Box, {
47
+ width: "full",
48
+ className: clsx(styles.item, {
49
+ [styles.active]: index === activeIndex
50
+ }),
51
+ children: item
52
+ })
53
+ }, index));
54
+ setItemsRef(itemsRef);
55
+ return list;
56
+ }, [incomingItems, activeIndex, columnWidth]);
57
+ const {
58
+ containerRef,
59
+ pageCount,
60
+ activePage,
61
+ paused,
62
+ next,
63
+ prev,
64
+ onClick,
65
+ pause,
66
+ resume
67
+ } = useHorizontalAutoScroller({
68
+ itemsRef,
69
+ itemsPerPage: incomingItemsPerPage,
70
+ paused: incomingIsPaused,
71
+ activePage: incomingActivePage,
72
+ onChange: setActiveIndex
73
+ });
74
+ if (items.length < 2) {
75
+ return _jsx(_Fragment, {
76
+ children: items
77
+ });
78
+ }
79
+ return _jsxs(Stack, {
80
+ className: className,
81
+ space: "5",
82
+ children: [_jsxs(Box, {
83
+ overflow: "hidden",
84
+ position: "relative",
85
+ onContextMenu: event => {
86
+ event.preventDefault();
87
+ event.stopPropagation();
88
+ },
89
+ onTouchStart: pause,
90
+ onTouchEnd: resume,
91
+ onClick: onClick,
92
+ children: [noControls ? null : _jsx(Box, {
93
+ className: [styles.controllerBtn, styles.prevBtn],
94
+ display: "flex",
95
+ alignItems: "center",
96
+ justifyContent: "flexStart",
97
+ position: "absolute",
98
+ children: _jsx(Button, {
99
+ rounded: true,
100
+ onClick: event => {
101
+ event.stopPropagation();
102
+ event.preventDefault();
103
+ prev();
104
+ },
105
+ variant: "secondary",
106
+ children: _jsx(Icon, {
107
+ icon: ChevronLeftIcon
108
+ })
109
+ })
110
+ }), _jsxs(Columns, {
111
+ ref: containerRef,
112
+ overflow: "hidden",
113
+ noWrap: true,
114
+ width: "full",
115
+ space: space,
116
+ children: [noControls ? null : _jsx(Column, {
117
+ noShrink: true,
118
+ className: styles.controllerCol,
119
+ children: _jsx("span", {})
120
+ }), items, noControls ? null : _jsx(Column, {
121
+ noShrink: true,
122
+ className: styles.controllerCol,
123
+ children: _jsx("span", {})
124
+ })]
125
+ }), noControls ? null : _jsx(Box, {
126
+ className: [styles.controllerBtn, styles.nextBtn],
127
+ display: "flex",
128
+ alignItems: "center",
129
+ justifyContent: "flexEnd",
130
+ position: "absolute",
131
+ children: _jsx(Button, {
132
+ rounded: true,
133
+ onClick: event => {
134
+ event.stopPropagation();
135
+ event.preventDefault();
136
+ next();
137
+ },
138
+ variant: "secondary",
139
+ children: _jsx(Icon, {
140
+ icon: ChevronRightIcon
141
+ })
142
+ })
143
+ })]
144
+ }), _jsx(Section, {
145
+ width: "small",
146
+ children: _jsx(SliderProgress, {
147
+ backgroundColour: sliderProgressColour,
148
+ duration: "".concat(durationSeconds, "s"),
149
+ paused: paused,
150
+ onRequestNext: next,
151
+ totalCount: pageCount,
152
+ activeIndex: activePage || 0
153
+ })
154
+ })]
155
+ });
156
+ };
157
+ export default HorizontalAutoScroller;
@@ -0,0 +1,3 @@
1
+ export { HorizontalAutoScroller } from './HorizontalAutoScroller';
2
+ export { useHorizontalAutoScroller } from './useHorizontalAutoScroller';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/HorizontalAutoScroller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { HorizontalAutoScroller } from "./HorizontalAutoScroller.js";
4
+ export { useHorizontalAutoScroller } from "./useHorizontalAutoScroller.js";
@@ -0,0 +1,88 @@
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 = ["childrenNum"];
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ 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
+ import * as React from 'react';
9
+ import { Box } from "../Box/index.js";
10
+ import { boxArgTypes, scaleOptions } from "../Box/argTypes.js";
11
+ import { HorizontalAutoScroller } from "./index.js";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export default {
14
+ title: 'Components/HorizontalAutoScroller',
15
+ component: HorizontalAutoScroller,
16
+ argTypes: {
17
+ sliderProgressColour: boxArgTypes.backgroundColour,
18
+ space: {
19
+ options: scaleOptions,
20
+ control: {
21
+ type: 'select'
22
+ }
23
+ },
24
+ paused: {
25
+ control: {
26
+ type: 'boolean'
27
+ }
28
+ },
29
+ noControls: {
30
+ control: {
31
+ type: 'boolean'
32
+ }
33
+ }
34
+ }
35
+ };
36
+ const template = _ref => {
37
+ let {
38
+ childrenNum
39
+ } = _ref,
40
+ args = _objectWithoutProperties(_ref, _excluded);
41
+ return _jsx(HorizontalAutoScroller, _objectSpread(_objectSpread({}, args), {}, {
42
+ children: Array.from({
43
+ length: childrenNum
44
+ }).map((_, index) => _jsx(Box, {
45
+ backgroundColour: "gray200",
46
+ padding: "3",
47
+ display: "flex",
48
+ width: "full",
49
+ height: "full",
50
+ alignItems: "center",
51
+ justifyContent: "center",
52
+ children: _jsx(Box, {
53
+ style: {
54
+ width: '100%',
55
+ height: 20 + Math.ceil(Math.random() * 300)
56
+ },
57
+ backgroundColour: "gray900"
58
+ })
59
+ }, index))
60
+ }));
61
+ };
62
+ const standardProps = {
63
+ paused: false,
64
+ activePage: 0,
65
+ childrenNum: 9
66
+ };
67
+ export const standard = template.bind(standardProps);
68
+ standard.args = standardProps;
69
+ const widthStartPageProps = _objectSpread(_objectSpread({}, standardProps), {}, {
70
+ activePage: 3
71
+ });
72
+ export const widthStartPage = template.bind(widthStartPageProps);
73
+ widthStartPage.args = widthStartPageProps;
74
+ const withCustomDurationProps = _objectSpread(_objectSpread({}, standardProps), {}, {
75
+ durationSeconds: 1
76
+ });
77
+ export const withCustomDuration = template.bind(withCustomDurationProps);
78
+ withCustomDuration.args = withCustomDurationProps;
79
+ const withProgressColourProps = _objectSpread(_objectSpread({}, standardProps), {}, {
80
+ sliderProgressColour: 'yellow500'
81
+ });
82
+ export const withProgressColour = template.bind(withProgressColourProps);
83
+ withProgressColour.args = withProgressColourProps;
84
+ const withManySlidesProps = _objectSpread(_objectSpread({}, standardProps), {}, {
85
+ childrenNum: 50
86
+ });
87
+ export const withManySlides = template.bind(withManySlidesProps);
88
+ withManySlides.args = withManySlidesProps;
@@ -0,0 +1,23 @@
1
+ import { useInView } from 'react-intersection-observer';
2
+ interface State {
3
+ pageCount: number;
4
+ activePage?: number | null;
5
+ paused: boolean;
6
+ }
7
+ export interface UseHorizontalAutoScrollerProps extends Partial<Omit<State, 'pageCount'>> {
8
+ itemsRef?: Array<HTMLElement>;
9
+ itemsPerPage?: number;
10
+ onChange?(page: number): void;
11
+ }
12
+ interface Returns extends State {
13
+ containerRef: ReturnType<typeof useInView>[0];
14
+ next(): void;
15
+ prev(): void;
16
+ pause(): void;
17
+ resume(): void;
18
+ onClick(): void;
19
+ goToPage(page: number): void;
20
+ }
21
+ export declare const useHorizontalAutoScroller: ({ itemsRef, itemsPerPage, paused: incomingIsPaused, activePage: incomingActivePage, onChange, }: UseHorizontalAutoScrollerProps) => Returns;
22
+ export {};
23
+ //# sourceMappingURL=useHorizontalAutoScroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHorizontalAutoScroller.d.ts","sourceRoot":"","sources":["../../../lib/components/HorizontalAutoScroller/useHorizontalAutoScroller.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,UAAU,KAAK;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,8BAChB,SAAQ,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,UAAU,OAAQ,SAAQ,KAAK;IAC9B,YAAY,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,IAAI,IAAI,IAAI,CAAC;IAEb,IAAI,IAAI,IAAI,CAAC;IAEb,KAAK,IAAI,IAAI,CAAC;IAEd,MAAM,IAAI,IAAI,CAAC;IAEf,OAAO,IAAI,IAAI,CAAC;IAEhB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAmGD,eAAO,MAAM,yBAAyB,oGAMnC,8BAA8B,KAAG,OA8FnC,CAAC"}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ 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; }
5
+ 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; }
6
+ import { startTransition, useCallback, useEffect, useMemo, useReducer } from 'react';
7
+ import { useInView } from 'react-intersection-observer';
8
+ const getNextPge = prevState => {
9
+ if (typeof prevState.activePage === 'number' && prevState.activePage + 1 < prevState.pageCount) {
10
+ return prevState.activePage + 1;
11
+ }
12
+ return 0;
13
+ };
14
+ const getPrevPage = prevState => {
15
+ if (typeof prevState.activePage === 'number' && prevState.activePage - 1 >= 0) {
16
+ return prevState.activePage - 1;
17
+ }
18
+ return prevState.pageCount - 1;
19
+ };
20
+ const stateReducer = (prevState, action) => {
21
+ switch (action.type) {
22
+ case 'GO_TO_PAGE':
23
+ {
24
+ return _objectSpread(_objectSpread({}, prevState), {}, {
25
+ activePage: action.payload
26
+ });
27
+ }
28
+ case 'SET_PAGE_COUNT':
29
+ {
30
+ return _objectSpread(_objectSpread({}, prevState), {}, {
31
+ pageCount: action.payload
32
+ });
33
+ }
34
+ case 'NEXT_PAGE':
35
+ {
36
+ return _objectSpread(_objectSpread({}, prevState), {}, {
37
+ paused: false,
38
+ activePage: getNextPge(prevState)
39
+ });
40
+ }
41
+ case 'CLICK_NEXT':
42
+ {
43
+ return _objectSpread(_objectSpread({}, prevState), {}, {
44
+ paused: false,
45
+ activePage: getNextPge(prevState)
46
+ });
47
+ }
48
+ case 'PREV_PAGE':
49
+ {
50
+ return _objectSpread(_objectSpread({}, prevState), {}, {
51
+ paused: false,
52
+ activePage: getPrevPage(prevState)
53
+ });
54
+ }
55
+ case 'PAUSE':
56
+ {
57
+ return _objectSpread(_objectSpread({}, prevState), {}, {
58
+ paused: true
59
+ });
60
+ }
61
+ case 'RESUME':
62
+ {
63
+ return _objectSpread(_objectSpread({}, prevState), {}, {
64
+ paused: false
65
+ });
66
+ }
67
+ default:
68
+ return prevState;
69
+ }
70
+ };
71
+ export const useHorizontalAutoScroller = _ref => {
72
+ let {
73
+ itemsRef,
74
+ itemsPerPage = 1,
75
+ paused: incomingIsPaused = false,
76
+ activePage: incomingActivePage = null,
77
+ onChange = () => void 0
78
+ } = _ref;
79
+ const [{
80
+ pageCount,
81
+ activePage,
82
+ paused
83
+ }, dispatch] = useReducer(stateReducer, {
84
+ paused: incomingIsPaused,
85
+ activePage: void 0,
86
+ pageCount: itemsRef !== null && itemsRef !== void 0 && itemsRef.length ? Math.ceil(itemsRef.length / itemsPerPage) : 1
87
+ });
88
+ useEffect(() => {
89
+ dispatch({
90
+ type: 'SET_PAGE_COUNT',
91
+ payload: itemsRef !== null && itemsRef !== void 0 && itemsRef.length ? Math.ceil(itemsRef.length / itemsPerPage) : 1
92
+ });
93
+ }, [itemsRef === null || itemsRef === void 0 ? void 0 : itemsRef.length, itemsPerPage]);
94
+ const onViewChange = useCallback(inView => {
95
+ if (inView && typeof activePage !== 'number') dispatch({
96
+ type: 'GO_TO_PAGE',
97
+ payload: typeof incomingActivePage === 'number' ? incomingActivePage : 0
98
+ });
99
+ }, [incomingActivePage, activePage]);
100
+ const [containerRef, inView, entry] = useInView({
101
+ triggerOnce: false,
102
+ rootMargin: '0px',
103
+ onChange: onViewChange
104
+ });
105
+ const next = useCallback(() => {
106
+ dispatch({
107
+ type: 'NEXT_PAGE'
108
+ });
109
+ }, []);
110
+ const prev = useCallback(() => {
111
+ dispatch({
112
+ type: 'PREV_PAGE'
113
+ });
114
+ }, []);
115
+ const goToPage = useCallback(page => {
116
+ dispatch({
117
+ type: 'GO_TO_PAGE',
118
+ payload: page
119
+ });
120
+ }, []);
121
+ const onClick = useCallback(() => {
122
+ dispatch({
123
+ type: 'CLICK_NEXT'
124
+ });
125
+ }, []);
126
+ const pause = useCallback(() => {
127
+ dispatch({
128
+ type: 'PAUSE'
129
+ });
130
+ }, []);
131
+ const resume = useCallback(() => {
132
+ dispatch({
133
+ type: 'RESUME'
134
+ });
135
+ }, []);
136
+ useEffect(() => {
137
+ if (typeof activePage !== 'number' || !(itemsRef !== null && itemsRef !== void 0 && itemsRef.length)) return;
138
+ onChange(activePage);
139
+ startTransition(() => {
140
+ entry === null || entry === void 0 ? void 0 : entry.target.scrollTo({
141
+ top: 0,
142
+ left: itemsRef[activePage].getBoundingClientRect().left - itemsRef[0].getBoundingClientRect().left,
143
+ behavior: 'smooth'
144
+ });
145
+ });
146
+ }, [itemsRef, activePage, entry === null || entry === void 0 ? void 0 : entry.target, onChange]);
147
+ return useMemo(() => ({
148
+ containerRef,
149
+ paused: paused || !inView,
150
+ pageCount,
151
+ activePage,
152
+ next,
153
+ prev,
154
+ goToPage,
155
+ onClick,
156
+ pause,
157
+ resume
158
+ }), [containerRef, pageCount, activePage, paused, inView]);
159
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"ProgressStep.d.ts","sourceRoot":"","sources":["../../../lib/components/SliderProgress/ProgressStep.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAQ,oBAAoB,EAAe,MAAM,OAAO,CAAC;AAGhF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,UAAU,KAAM,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,kBAAkB,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,IAAI,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,KAAK,CAoDpD,CAAC"}
1
+ {"version":3,"file":"ProgressStep.d.ts","sourceRoot":"","sources":["../../../lib/components/SliderProgress/ProgressStep.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAQ,oBAAoB,EAAe,MAAM,OAAO,CAAC;AAGhF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,UAAU,KAAM,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,kBAAkB,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,IAAI,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,oBAAoB,CAAC,KAAK,CA+CpD,CAAC"}
@@ -1,11 +1,10 @@
1
1
  import { ComponentProps, NamedExoticComponent } from 'react';
2
2
  import { Box } from '../Box';
3
- interface Props extends Pick<ComponentProps<typeof Box>, 'backgroundColour'> {
3
+ import { ProgressStep } from './ProgressStep';
4
+ interface Props extends Pick<ComponentProps<typeof Box>, 'backgroundColour'>, Pick<ComponentProps<typeof ProgressStep>, 'paused' | 'duration'> {
4
5
  className?: string;
5
- paused: boolean;
6
6
  totalCount: number;
7
7
  activeIndex: number;
8
- duration: string;
9
8
  onRequestNext(): void;
10
9
  }
11
10
  export declare const SliderProgress: NamedExoticComponent<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"SliderProgress.d.ts","sourceRoot":"","sources":["../../../lib/components/SliderProgress/SliderProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAQ,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAK7B,UAAU,KAAM,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,kBAAkB,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,IAAI,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,EAAE,oBAAoB,CAAC,KAAK,CAgCtD,CAAC"}
1
+ {"version":3,"file":"SliderProgress.d.ts","sourceRoot":"","sources":["../../../lib/components/SliderProgress/SliderProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAQ,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,UAAU,KACT,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,kBAAkB,CAAC,EAC3D,IAAI,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,aAAa,IAAI,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,EAAE,oBAAoB,CAAC,KAAK,CAgCtD,CAAC"}
@@ -56,4 +56,5 @@ export * from './ColourInput';
56
56
  export * from './DividerLine';
57
57
  export * from './ThemeOverrideProvider';
58
58
  export * from './SliderProgress';
59
+ export * from './HorizontalAutoScroller';
59
60
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
@@ -57,4 +57,5 @@ export * from "./TextBubble/index.js";
57
57
  export * from "./ColourInput/index.js";
58
58
  export * from "./DividerLine/index.js";
59
59
  export * from "./ThemeOverrideProvider/index.js";
60
- export * from "./SliderProgress/index.js";
60
+ export * from "./SliderProgress/index.js";
61
+ export * from "./HorizontalAutoScroller/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
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",
@@ -49,9 +49,11 @@
49
49
  "csstype": "3.1.1",
50
50
  "deepmerge": "^4.2.2",
51
51
  "eslint-plugin-jest": "26.2.2",
52
+ "intersection-observer": "^0.12.2",
52
53
  "react": "^18.1.0",
53
54
  "react-dom": "^18.1.0",
54
55
  "react-focus-lock": "2.8.1",
56
+ "react-intersection-observer": "^9.4.3",
55
57
  "react-keyed-flatten-children": "1.3.0",
56
58
  "webpack": "5.74.0"
57
59
  },
@@ -66,6 +68,7 @@
66
68
  "react": ">=16.8",
67
69
  "react-dom": ">=16.8",
68
70
  "react-focus-lock": "^2.5.0",
71
+ "react-intersection-observer": ">=9.4.3",
69
72
  "react-keyed-flatten-children": "^1.3.0",
70
73
  "webpack": "*"
71
74
  }