@ovotech/element-native 3.8.0-canary-e69f528-225 → 3.8.0-canary-3cc1dc6-227

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,4 +1,4 @@
1
- interface HorizontalCarouselProps<T> {
1
+ interface ProductCarouselProps<T> {
2
2
  data: T[];
3
3
  children: (item: T) => JSX.Element;
4
4
  width?: number;
@@ -9,5 +9,5 @@ interface HorizontalCarouselProps<T> {
9
9
  loop?: boolean;
10
10
  arrowsDistanceFromTop?: number;
11
11
  }
12
- export declare function HorizontalCarousel<T>({ data, children, width, height, fullWidth, showArrows, showDots, loop, arrowsDistanceFromTop, }: HorizontalCarouselProps<T>): JSX.Element;
12
+ export declare function ProductCarousel<T>({ data, children, width, height, fullWidth, showArrows, showDots, loop, arrowsDistanceFromTop, }: ProductCarouselProps<T>): JSX.Element;
13
13
  export {};
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.ProductCarousel = void 0;
45
+ var jsx_runtime_1 = require("react/jsx-runtime");
46
+ var element_core_1 = require("@ovotech/element-core");
47
+ var react_1 = require("react");
48
+ var react_native_1 = require("react-native");
49
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
50
+ var react_native_reanimated_carousel_1 = __importDefault(require("react-native-reanimated-carousel"));
51
+ var react_native_svg_1 = __importStar(require("react-native-svg"));
52
+ var hooks_1 = require("../../hooks");
53
+ var styled_native_1 = __importStar(require("../../styled.native"));
54
+ var Icon_1 = require("../Icon");
55
+ var NavigationDots_1 = require("./NavigationDots");
56
+ var anchor_point_1 = require("./anchor-point");
57
+ function ProductCarousel(_a) {
58
+ var data = _a.data, children = _a.children, width = _a.width, height = _a.height, fullWidth = _a.fullWidth, _b = _a.showArrows, showArrows = _b === void 0 ? true : _b, _c = _a.showDots, showDots = _c === void 0 ? false : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, arrowsDistanceFromTop = _a.arrowsDistanceFromTop;
59
+ var theme = (0, styled_native_1.useTheme)();
60
+ var mediumAndUp = (0, hooks_1.useBreakpoint)().mediumAndUp;
61
+ var carouselRef = (0, react_1.useRef)(null);
62
+ var progressValue = (0, react_native_reanimated_1.useSharedValue)(0);
63
+ var windowWidth = (0, react_native_1.useWindowDimensions)().width;
64
+ var carouselWidth = fullWidth ? windowWidth : width || windowWidth;
65
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [mediumAndUp ? null : (0, jsx_runtime_1.jsx)(SkewLine, {}), (0, jsx_runtime_1.jsxs)(SCarouselContainer, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_carousel_1.default, { ref: carouselRef, data: data, renderItem: function (_a) {
66
+ var item = _a.item, animationValue = _a.animationValue;
67
+ return ((0, jsx_runtime_1.jsx)(Card, __assign({ animationValue: animationValue, height: height, width: carouselWidth }, { children: children(item) })));
68
+ }, vertical: false, width: carouselWidth, height: height, onProgressChange: function (_, absoluteProgress) {
69
+ return (progressValue.value = absoluteProgress);
70
+ }, panGestureHandlerProps: {
71
+ activeOffsetX: [-20, 20],
72
+ }, loop: loop, testID: "carousel", scrollAnimationDuration: 700 }), showArrows && data.length > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SActionPressable, __assign({ onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.prev(); }, "$top": arrowsDistanceFromTop, mediumAndUp: mediumAndUp, hitSlop: {
73
+ top: 32,
74
+ bottom: 32,
75
+ left: 16,
76
+ right: 16,
77
+ } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrow-left", size: 32, color: theme.core.color.brand.white }) })), (0, jsx_runtime_1.jsx)(SActionPressable, __assign({ "$next": true, onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.next(); }, "$top": arrowsDistanceFromTop, mediumAndUp: mediumAndUp, hitSlop: {
78
+ top: 32,
79
+ bottom: 32,
80
+ left: 16,
81
+ right: 16,
82
+ } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrow-right", size: 32, color: theme.core.color.brand.white }) }))] })), showDots && data.length > 1 && ((0, jsx_runtime_1.jsx)(NavigationDots_1.NavigationDots, { data: data, animatedValue: progressValue }))] })] }));
83
+ }
84
+ exports.ProductCarousel = ProductCarousel;
85
+ var Card = function (_a) {
86
+ var children = _a.children, animationValue = _a.animationValue, height = _a.height, width = _a.width;
87
+ var WIDTH = width / 1.3;
88
+ var HEIGHT = height / 1.3;
89
+ var cardStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
90
+ var scale = (0, react_native_reanimated_1.interpolate)(animationValue.value, [-0.1, 0, 1], [0.95, 1, 1], react_native_reanimated_1.Extrapolate.CLAMP);
91
+ var opacity = (0, react_native_reanimated_1.interpolate)(animationValue.value, [-0.75, 0, 1], [0, 1, 0]);
92
+ var translateX = (0, react_native_reanimated_1.interpolate)(animationValue.value, [-1, -0.2, 0, 1], [0, WIDTH * 0.3, 0, 0]);
93
+ var transform = {
94
+ transform: [
95
+ { scale: scale },
96
+ { translateX: translateX },
97
+ { perspective: 200 },
98
+ {
99
+ rotateY: "".concat((0, react_native_reanimated_1.interpolate)(animationValue.value, [-1, 0, 0.4, 1], [30, 0, -25, -25], react_native_reanimated_1.Extrapolate.CLAMP), "deg"),
100
+ },
101
+ ],
102
+ };
103
+ return __assign(__assign({}, (0, anchor_point_1.withAnchorPoint)(transform, { x: 0.5, y: 0.5 }, { width: WIDTH, height: HEIGHT })), { opacity: opacity });
104
+ }, []);
105
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, __assign({ style: {
106
+ flex: 1,
107
+ justifyContent: 'center',
108
+ alignItems: 'center',
109
+ } }, { children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, __assign({ style: [
110
+ {
111
+ width: WIDTH,
112
+ height: HEIGHT,
113
+ },
114
+ cardStyle,
115
+ ] }, { children: children })) })));
116
+ };
117
+ var SCarouselContainer = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n background-color: #0a9828;\n overflow: hidden;\n margin-top: -0.5px;\n"], ["\n align-items: center;\n background-color: #0a9828;\n overflow: hidden;\n margin-top: -0.5px;\n"])));
118
+ var SActionPressable = styled_native_1.default.Pressable(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n ", ";\n"], ["\n position: absolute;\n top: ", ";\n ", ";\n"])), function (_a) {
119
+ var $top = _a.$top;
120
+ return ($top ? "".concat($top, "px") : '30%');
121
+ }, function (_a) {
122
+ var theme = _a.theme, $next = _a.$next, mediumAndUp = _a.mediumAndUp;
123
+ return $next
124
+ ? "right: ".concat(mediumAndUp ? '25%' : (0, element_core_1.numToPx)(theme.core.space[14]))
125
+ : "left: ".concat(mediumAndUp ? '25%' : (0, element_core_1.numToPx)(theme.core.space[14]));
126
+ });
127
+ var SkewLine = function (props) { return ((0, jsx_runtime_1.jsx)(react_native_svg_1.default, __assign({ width: "100%", height: 69 }, props, { children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Path, { fill: "#0A9828", d: "M768 0 0 68.776h768V0Z" }) }))); };
128
+ var templateObject_1, templateObject_2;
@@ -0,0 +1,10 @@
1
+ import type { TransformsStyle } from 'react-native';
2
+ export interface Point {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export interface Size {
7
+ width: number;
8
+ height: number;
9
+ }
10
+ export declare const withAnchorPoint: (transform: TransformsStyle, anchorPoint: Point, size: Size) => TransformsStyle;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.withAnchorPoint = void 0;
13
+ var isValidSize = function (size) {
14
+ 'worklet';
15
+ return size && size.width > 0 && size.height > 0;
16
+ };
17
+ var defaultAnchorPoint = { x: 0.5, y: 0.5 };
18
+ var withAnchorPoint = function (transform, anchorPoint, size) {
19
+ 'worklet';
20
+ if (!isValidSize(size))
21
+ return transform;
22
+ var injectedTransform = transform.transform;
23
+ if (!injectedTransform)
24
+ return transform;
25
+ if (anchorPoint.x !== defaultAnchorPoint.x && size.width) {
26
+ var shiftTranslateX = [];
27
+ // shift before rotation
28
+ shiftTranslateX.push({
29
+ translateX: size.width * (anchorPoint.x - defaultAnchorPoint.x),
30
+ });
31
+ injectedTransform = __spreadArray(__spreadArray([], shiftTranslateX, true), injectedTransform, true);
32
+ // shift after rotation
33
+ injectedTransform.push({
34
+ translateX: size.width * (defaultAnchorPoint.x - anchorPoint.x),
35
+ });
36
+ }
37
+ if (!Array.isArray(injectedTransform))
38
+ return { transform: injectedTransform };
39
+ if (anchorPoint.y !== defaultAnchorPoint.y && size.height) {
40
+ var shiftTranslateY = [];
41
+ // shift before rotation
42
+ shiftTranslateY.push({
43
+ translateY: size.height * (anchorPoint.y - defaultAnchorPoint.y),
44
+ });
45
+ injectedTransform = __spreadArray(__spreadArray([], shiftTranslateY, true), injectedTransform, true);
46
+ // shift after rotation
47
+ injectedTransform.push({
48
+ translateY: size.height * (defaultAnchorPoint.y - anchorPoint.y),
49
+ });
50
+ }
51
+ return { transform: injectedTransform };
52
+ };
53
+ exports.withAnchorPoint = withAnchorPoint;
@@ -0,0 +1 @@
1
+ export { ProductCarousel } from './ProductCarousel';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductCarousel = void 0;
4
+ var ProductCarousel_1 = require("./ProductCarousel");
5
+ Object.defineProperty(exports, "ProductCarousel", { enumerable: true, get: function () { return ProductCarousel_1.ProductCarousel; } });
@@ -58,3 +58,4 @@ export * from './TextInput';
58
58
  export * from './TextLink';
59
59
  export * from './Toggle';
60
60
  export * from './Toast';
61
+ export * from './ProductCarousel';
@@ -74,3 +74,4 @@ __exportStar(require("./TextInput"), exports);
74
74
  __exportStar(require("./TextLink"), exports);
75
75
  __exportStar(require("./Toggle"), exports);
76
76
  __exportStar(require("./Toast"), exports);
77
+ __exportStar(require("./ProductCarousel"), exports);
@@ -0,0 +1,98 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { numToPx } from '@ovotech/element-core';
18
+ import { useRef } from 'react';
19
+ import { useWindowDimensions, View } from 'react-native';
20
+ import Animated, { Extrapolate, interpolate, useAnimatedStyle, useSharedValue, } from 'react-native-reanimated';
21
+ import Carousel from 'react-native-reanimated-carousel';
22
+ import Svg, { Path } from 'react-native-svg';
23
+ import { useBreakpoint } from '../../hooks';
24
+ import styled, { useTheme } from '../../styled.native';
25
+ import { Icon } from '../Icon';
26
+ import { NavigationDots } from './NavigationDots';
27
+ import { withAnchorPoint } from './anchor-point';
28
+ export function ProductCarousel(_a) {
29
+ var data = _a.data, children = _a.children, width = _a.width, height = _a.height, fullWidth = _a.fullWidth, _b = _a.showArrows, showArrows = _b === void 0 ? true : _b, _c = _a.showDots, showDots = _c === void 0 ? false : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, arrowsDistanceFromTop = _a.arrowsDistanceFromTop;
30
+ var theme = useTheme();
31
+ var mediumAndUp = useBreakpoint().mediumAndUp;
32
+ var carouselRef = useRef(null);
33
+ var progressValue = useSharedValue(0);
34
+ var windowWidth = useWindowDimensions().width;
35
+ var carouselWidth = fullWidth ? windowWidth : width || windowWidth;
36
+ return (_jsxs(View, { children: [mediumAndUp ? null : _jsx(SkewLine, {}), _jsxs(SCarouselContainer, { children: [_jsx(Carousel, { ref: carouselRef, data: data, renderItem: function (_a) {
37
+ var item = _a.item, animationValue = _a.animationValue;
38
+ return (_jsx(Card, __assign({ animationValue: animationValue, height: height, width: carouselWidth }, { children: children(item) })));
39
+ }, vertical: false, width: carouselWidth, height: height, onProgressChange: function (_, absoluteProgress) {
40
+ return (progressValue.value = absoluteProgress);
41
+ }, panGestureHandlerProps: {
42
+ activeOffsetX: [-20, 20],
43
+ }, loop: loop, testID: "carousel", scrollAnimationDuration: 700 }), showArrows && data.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SActionPressable, __assign({ onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.prev(); }, "$top": arrowsDistanceFromTop, mediumAndUp: mediumAndUp, hitSlop: {
44
+ top: 32,
45
+ bottom: 32,
46
+ left: 16,
47
+ right: 16,
48
+ } }, { children: _jsx(Icon, { name: "arrow-left", size: 32, color: theme.core.color.brand.white }) })), _jsx(SActionPressable, __assign({ "$next": true, onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.next(); }, "$top": arrowsDistanceFromTop, mediumAndUp: mediumAndUp, hitSlop: {
49
+ top: 32,
50
+ bottom: 32,
51
+ left: 16,
52
+ right: 16,
53
+ } }, { children: _jsx(Icon, { name: "arrow-right", size: 32, color: theme.core.color.brand.white }) }))] })), showDots && data.length > 1 && (_jsx(NavigationDots, { data: data, animatedValue: progressValue }))] })] }));
54
+ }
55
+ var Card = function (_a) {
56
+ var children = _a.children, animationValue = _a.animationValue, height = _a.height, width = _a.width;
57
+ var WIDTH = width / 1.3;
58
+ var HEIGHT = height / 1.3;
59
+ var cardStyle = useAnimatedStyle(function () {
60
+ var scale = interpolate(animationValue.value, [-0.1, 0, 1], [0.95, 1, 1], Extrapolate.CLAMP);
61
+ var opacity = interpolate(animationValue.value, [-0.75, 0, 1], [0, 1, 0]);
62
+ var translateX = interpolate(animationValue.value, [-1, -0.2, 0, 1], [0, WIDTH * 0.3, 0, 0]);
63
+ var transform = {
64
+ transform: [
65
+ { scale: scale },
66
+ { translateX: translateX },
67
+ { perspective: 200 },
68
+ {
69
+ rotateY: "".concat(interpolate(animationValue.value, [-1, 0, 0.4, 1], [30, 0, -25, -25], Extrapolate.CLAMP), "deg"),
70
+ },
71
+ ],
72
+ };
73
+ return __assign(__assign({}, withAnchorPoint(transform, { x: 0.5, y: 0.5 }, { width: WIDTH, height: HEIGHT })), { opacity: opacity });
74
+ }, []);
75
+ return (_jsx(Animated.View, __assign({ style: {
76
+ flex: 1,
77
+ justifyContent: 'center',
78
+ alignItems: 'center',
79
+ } }, { children: _jsx(Animated.View, __assign({ style: [
80
+ {
81
+ width: WIDTH,
82
+ height: HEIGHT,
83
+ },
84
+ cardStyle,
85
+ ] }, { children: children })) })));
86
+ };
87
+ var SCarouselContainer = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n background-color: #0a9828;\n overflow: hidden;\n margin-top: -0.5px;\n"], ["\n align-items: center;\n background-color: #0a9828;\n overflow: hidden;\n margin-top: -0.5px;\n"])));
88
+ var SActionPressable = styled.Pressable(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n ", ";\n"], ["\n position: absolute;\n top: ", ";\n ", ";\n"])), function (_a) {
89
+ var $top = _a.$top;
90
+ return ($top ? "".concat($top, "px") : '30%');
91
+ }, function (_a) {
92
+ var theme = _a.theme, $next = _a.$next, mediumAndUp = _a.mediumAndUp;
93
+ return $next
94
+ ? "right: ".concat(mediumAndUp ? '25%' : numToPx(theme.core.space[14]))
95
+ : "left: ".concat(mediumAndUp ? '25%' : numToPx(theme.core.space[14]));
96
+ });
97
+ var SkewLine = function (props) { return (_jsx(Svg, __assign({ width: "100%", height: 69 }, props, { children: _jsx(Path, { fill: "#0A9828", d: "M768 0 0 68.776h768V0Z" }) }))); };
98
+ var templateObject_1, templateObject_2;
@@ -0,0 +1,49 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ var isValidSize = function (size) {
11
+ 'worklet';
12
+ return size && size.width > 0 && size.height > 0;
13
+ };
14
+ var defaultAnchorPoint = { x: 0.5, y: 0.5 };
15
+ export var withAnchorPoint = function (transform, anchorPoint, size) {
16
+ 'worklet';
17
+ if (!isValidSize(size))
18
+ return transform;
19
+ var injectedTransform = transform.transform;
20
+ if (!injectedTransform)
21
+ return transform;
22
+ if (anchorPoint.x !== defaultAnchorPoint.x && size.width) {
23
+ var shiftTranslateX = [];
24
+ // shift before rotation
25
+ shiftTranslateX.push({
26
+ translateX: size.width * (anchorPoint.x - defaultAnchorPoint.x),
27
+ });
28
+ injectedTransform = __spreadArray(__spreadArray([], shiftTranslateX, true), injectedTransform, true);
29
+ // shift after rotation
30
+ injectedTransform.push({
31
+ translateX: size.width * (defaultAnchorPoint.x - anchorPoint.x),
32
+ });
33
+ }
34
+ if (!Array.isArray(injectedTransform))
35
+ return { transform: injectedTransform };
36
+ if (anchorPoint.y !== defaultAnchorPoint.y && size.height) {
37
+ var shiftTranslateY = [];
38
+ // shift before rotation
39
+ shiftTranslateY.push({
40
+ translateY: size.height * (anchorPoint.y - defaultAnchorPoint.y),
41
+ });
42
+ injectedTransform = __spreadArray(__spreadArray([], shiftTranslateY, true), injectedTransform, true);
43
+ // shift after rotation
44
+ injectedTransform.push({
45
+ translateY: size.height * (defaultAnchorPoint.y - anchorPoint.y),
46
+ });
47
+ }
48
+ return { transform: injectedTransform };
49
+ };
@@ -0,0 +1 @@
1
+ export { ProductCarousel } from './ProductCarousel';
@@ -58,3 +58,4 @@ export * from './TextInput';
58
58
  export * from './TextLink';
59
59
  export * from './Toggle';
60
60
  export * from './Toast';
61
+ export * from './ProductCarousel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovotech/element-native",
3
- "version": "3.8.0-canary-e69f528-225",
3
+ "version": "3.8.0-canary-3cc1dc6-227",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@backpackapp-io/react-native-toast": "^0.10.0",
17
- "@ovotech/element-core": "^2.2.0-canary-e69f528-225",
17
+ "@ovotech/element-core": "^2.2.0-canary-3cc1dc6-227",
18
18
  "deepmerge": "^4.2.2",
19
19
  "lodash.groupby": "^4.6.0",
20
20
  "react-native-reanimated-carousel": "^3.5.1"
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.HorizontalCarousel = void 0;
45
- var jsx_runtime_1 = require("react/jsx-runtime");
46
- var element_core_1 = require("@ovotech/element-core");
47
- var react_1 = require("react");
48
- var react_native_1 = require("react-native");
49
- var react_native_reanimated_1 = require("react-native-reanimated");
50
- var react_native_reanimated_carousel_1 = __importDefault(require("react-native-reanimated-carousel"));
51
- var styled_native_1 = __importStar(require("../../styled.native"));
52
- var Icon_1 = require("../Icon");
53
- var NavigationDots_1 = require("./NavigationDots");
54
- function HorizontalCarousel(_a) {
55
- var data = _a.data, children = _a.children, width = _a.width, height = _a.height, fullWidth = _a.fullWidth, _b = _a.showArrows, showArrows = _b === void 0 ? true : _b, _c = _a.showDots, showDots = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, arrowsDistanceFromTop = _a.arrowsDistanceFromTop;
56
- var theme = (0, styled_native_1.useTheme)();
57
- var carouselRef = (0, react_1.useRef)(null);
58
- var progressValue = (0, react_native_reanimated_1.useSharedValue)(0);
59
- var windowWidth = (0, react_native_1.useWindowDimensions)().width;
60
- var carouselWidth = fullWidth ? windowWidth : width || windowWidth;
61
- return ((0, jsx_runtime_1.jsxs)(SCarouselContainer, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_carousel_1.default, { ref: carouselRef, data: data, renderItem: function (_a) {
62
- var item = _a.item;
63
- return ((0, jsx_runtime_1.jsx)(SItemContainer, __assign({ "$itemWidth": carouselWidth }, { children: children(item) })));
64
- }, vertical: false, width: carouselWidth, height: height, onProgressChange: function (_, absoluteProgress) {
65
- return (progressValue.value = absoluteProgress);
66
- }, panGestureHandlerProps: {
67
- activeOffsetX: [-20, 20],
68
- }, loop: loop, testID: "carousel" }), showArrows && data.length > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SActionPressable, __assign({ onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.prev(); }, "$top": arrowsDistanceFromTop, hitSlop: {
69
- top: 32,
70
- bottom: 32,
71
- left: 16,
72
- right: 16,
73
- } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrow-left", size: 16, color: theme.core.color.brand.white }) })), (0, jsx_runtime_1.jsx)(SActionPressable, __assign({ "$next": true, onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.next(); }, "$top": arrowsDistanceFromTop, hitSlop: {
74
- top: 32,
75
- bottom: 32,
76
- left: 16,
77
- right: 16,
78
- } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrow-right", size: 16, color: theme.core.color.brand.white }) }))] })), showDots && data.length > 1 && ((0, jsx_runtime_1.jsx)(NavigationDots_1.NavigationDots, { data: data, animatedValue: progressValue }))] }));
79
- }
80
- exports.HorizontalCarousel = HorizontalCarousel;
81
- var SCarouselContainer = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n"], ["\n align-items: center;\n"])));
82
- var SItemContainer = styled_native_1.default.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n width: ", "px;\n height: 100%;\n justify-content: center;\n align-items: center;\n"], ["\n position: relative;\n width: ", "px;\n height: 100%;\n justify-content: center;\n align-items: center;\n"])), function (_a) {
83
- var $itemWidth = _a.$itemWidth;
84
- return $itemWidth;
85
- });
86
- var SActionPressable = styled_native_1.default.Pressable(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n ", ";\n"], ["\n position: absolute;\n top: ", ";\n ", ";\n"])), function (_a) {
87
- var $top = _a.$top;
88
- return ($top ? "".concat($top, "px") : '50%');
89
- }, function (_a) {
90
- var theme = _a.theme, $next = _a.$next;
91
- return $next
92
- ? "right: ".concat((0, element_core_1.numToPx)(theme.core.space[6]))
93
- : "left: ".concat((0, element_core_1.numToPx)(theme.core.space[6]));
94
- });
95
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1 +0,0 @@
1
- export * from './HorizontalCarousel';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./HorizontalCarousel"), exports);
@@ -1,65 +0,0 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
17
- import { numToPx } from '@ovotech/element-core';
18
- import { useRef } from 'react';
19
- import { useWindowDimensions } from 'react-native';
20
- import { useSharedValue } from 'react-native-reanimated';
21
- import Carousel from 'react-native-reanimated-carousel';
22
- import styled, { useTheme } from '../../styled.native';
23
- import { Icon } from '../Icon';
24
- import { NavigationDots } from './NavigationDots';
25
- export function HorizontalCarousel(_a) {
26
- var data = _a.data, children = _a.children, width = _a.width, height = _a.height, fullWidth = _a.fullWidth, _b = _a.showArrows, showArrows = _b === void 0 ? true : _b, _c = _a.showDots, showDots = _c === void 0 ? true : _c, _d = _a.loop, loop = _d === void 0 ? true : _d, arrowsDistanceFromTop = _a.arrowsDistanceFromTop;
27
- var theme = useTheme();
28
- var carouselRef = useRef(null);
29
- var progressValue = useSharedValue(0);
30
- var windowWidth = useWindowDimensions().width;
31
- var carouselWidth = fullWidth ? windowWidth : width || windowWidth;
32
- return (_jsxs(SCarouselContainer, { children: [_jsx(Carousel, { ref: carouselRef, data: data, renderItem: function (_a) {
33
- var item = _a.item;
34
- return (_jsx(SItemContainer, __assign({ "$itemWidth": carouselWidth }, { children: children(item) })));
35
- }, vertical: false, width: carouselWidth, height: height, onProgressChange: function (_, absoluteProgress) {
36
- return (progressValue.value = absoluteProgress);
37
- }, panGestureHandlerProps: {
38
- activeOffsetX: [-20, 20],
39
- }, loop: loop, testID: "carousel" }), showArrows && data.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SActionPressable, __assign({ onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.prev(); }, "$top": arrowsDistanceFromTop, hitSlop: {
40
- top: 32,
41
- bottom: 32,
42
- left: 16,
43
- right: 16,
44
- } }, { children: _jsx(Icon, { name: "arrow-left", size: 16, color: theme.core.color.brand.white }) })), _jsx(SActionPressable, __assign({ "$next": true, onPress: function () { var _a; return (_a = carouselRef.current) === null || _a === void 0 ? void 0 : _a.next(); }, "$top": arrowsDistanceFromTop, hitSlop: {
45
- top: 32,
46
- bottom: 32,
47
- left: 16,
48
- right: 16,
49
- } }, { children: _jsx(Icon, { name: "arrow-right", size: 16, color: theme.core.color.brand.white }) }))] })), showDots && data.length > 1 && (_jsx(NavigationDots, { data: data, animatedValue: progressValue }))] }));
50
- }
51
- var SCarouselContainer = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n"], ["\n align-items: center;\n"])));
52
- var SItemContainer = styled.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n width: ", "px;\n height: 100%;\n justify-content: center;\n align-items: center;\n"], ["\n position: relative;\n width: ", "px;\n height: 100%;\n justify-content: center;\n align-items: center;\n"])), function (_a) {
53
- var $itemWidth = _a.$itemWidth;
54
- return $itemWidth;
55
- });
56
- var SActionPressable = styled.Pressable(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n ", ";\n"], ["\n position: absolute;\n top: ", ";\n ", ";\n"])), function (_a) {
57
- var $top = _a.$top;
58
- return ($top ? "".concat($top, "px") : '50%');
59
- }, function (_a) {
60
- var theme = _a.theme, $next = _a.$next;
61
- return $next
62
- ? "right: ".concat(numToPx(theme.core.space[6]))
63
- : "left: ".concat(numToPx(theme.core.space[6]));
64
- });
65
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1 +0,0 @@
1
- export * from './HorizontalCarousel';