@draftbit/core 49.7.6-e09d3d.2 → 49.7.7-ba2f6c.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Swiper/Swiper.js +1 -1
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +1 -0
- package/lib/typescript/src/components/BottomSheet/BottomSheet.js +8 -3
- package/lib/typescript/src/components/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/typescript/src/components/Swiper/Swiper.d.ts +6 -1
- package/lib/typescript/src/components/Swiper/Swiper.js +17 -3
- package/lib/typescript/src/components/Swiper/Swiper.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/BottomSheet/BottomSheet.js +8 -3
- package/src/components/BottomSheet/BottomSheet.js.map +1 -1
- package/src/components/BottomSheet/BottomSheet.tsx +10 -1
- package/src/components/Swiper/Swiper.js +17 -3
- package/src/components/Swiper/Swiper.js.map +1 -1
- package/src/components/Swiper/Swiper.tsx +134 -111
|
@@ -1 +1 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["snapPoints","topSnapPosition","middleSnapPosition","bottomSnapPosition","initialSnapIndex","initialSnapPosition","showHandle","handleColor","topBorderRadius","borderWidth","borderColor","onSettle","style","children"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/BottomSheet/BottomSheet.tsx";import React from"react";import{StyleSheet,Dimensions}from"react-native";import BottomSheetComponent,{BottomSheetScrollView}from"@gorhom/bottom-sheet";import{useTheme}from"@draftbit/theme";import{extractPercentNumber,useDeepCompareMemo}from"../../utilities";import{jsx as _jsx}from"react/jsx-runtime";var windowHeight=Dimensions.get("window").height;var BottomSheet=React.forwardRef(function(_ref,ref){var snapPointsProp=_ref.snapPoints,_ref$topSnapPosition=_ref.topSnapPosition,topSnapPosition=_ref$topSnapPosition===void 0?"10%":_ref$topSnapPosition,_ref$middleSnapPositi=_ref.middleSnapPosition,middleSnapPosition=_ref$middleSnapPositi===void 0?"50%":_ref$middleSnapPositi,_ref$bottomSnapPositi=_ref.bottomSnapPosition,bottomSnapPosition=_ref$bottomSnapPositi===void 0?"80%":_ref$bottomSnapPositi,initialSnapIndex=_ref.initialSnapIndex,_ref$initialSnapPosit=_ref.initialSnapPosition,initialSnapPosition=_ref$initialSnapPosit===void 0?"bottom":_ref$initialSnapPosit,_ref$showHandle=_ref.showHandle,showHandle=_ref$showHandle===void 0?true:_ref$showHandle,handleColor=_ref.handleColor,_ref$topBorderRadius=_ref.topBorderRadius,topBorderRadius=_ref$topBorderRadius===void 0?20:_ref$topBorderRadius,_ref$borderWidth=_ref.borderWidth,borderWidth=_ref$borderWidth===void 0?1:_ref$borderWidth,borderColor=_ref.borderColor,onSettle=_ref.onSettle,style=_ref.style,children=_ref.children,rest=_objectWithoutProperties(_ref,_excluded);var theme=useTheme();var backgroundColor=(style==null?void 0:style.backgroundColor)||theme.colors.background.brand;var snapPoints=snapPointsProp!=null?snapPointsProp:[topSnapPosition,middleSnapPosition,bottomSnapPosition];var mappedSnapPoints=useDeepCompareMemo(function(){return convertSnapPointsForNewImplementation(snapPoints);},snapPoints);var getSnapIndexFromPosition=function getSnapIndexFromPosition(position){switch(position){case"bottom":return 0;case"middle":return 1;case"top":return 2;}};return _jsx(BottomSheetComponent,{ref:ref,snapPoints:mappedSnapPoints,index:initialSnapIndex!==undefined?mappedSnapPoints.length-initialSnapIndex-1:getSnapIndexFromPosition(initialSnapPosition),handleIndicatorStyle:[{backgroundColor:handleColor!=null?handleColor:theme.colors.border.brand},!showHandle?{display:"none"}:{}],backgroundStyle:{backgroundColor:backgroundColor,borderTopLeftRadius:topBorderRadius,borderTopRightRadius:topBorderRadius,borderWidth:borderWidth,borderColor:borderColor!=null?borderColor:theme.colors.border.brand},onChange:function onChange(index){return onSettle==null?void 0:onSettle(mappedSnapPoints.length-index-1);},children:_jsx(BottomSheetScrollView,Object.assign({contentContainerStyle:[styles.contentContainerStyle,style]},rest,{children:children}))});});function convertSnapPointsForNewImplementation(snapPoints){var reversedSnapPoints=_toConsumableArray(snapPoints).reverse();return reversedSnapPoints.map(function(point){if(typeof point==="string"){var percentNumber=extractPercentNumber(point);if(percentNumber!==undefined){return`${100-percentNumber}%`;}return point;}else if(typeof point==="number"){return windowHeight-point;}else{return point;}});}var styles=StyleSheet.create({contentContainerStyle:{paddingHorizontal:16,paddingVertical:10}});export default BottomSheet;
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["snapPoints","topSnapPosition","middleSnapPosition","bottomSnapPosition","initialSnapIndex","initialSnapPosition","showHandle","handleColor","topBorderRadius","borderWidth","borderColor","enableDynamicSizing","onSettle","style","children"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/BottomSheet/BottomSheet.tsx";import React from"react";import{StyleSheet,Dimensions}from"react-native";import BottomSheetComponent,{BottomSheetScrollView}from"@gorhom/bottom-sheet";import{useTheme}from"@draftbit/theme";import{extractPercentNumber,useDeepCompareMemo}from"../../utilities";import{jsx as _jsx}from"react/jsx-runtime";var windowHeight=Dimensions.get("window").height;var BottomSheet=React.forwardRef(function(_ref,ref){var snapPointsProp=_ref.snapPoints,_ref$topSnapPosition=_ref.topSnapPosition,topSnapPosition=_ref$topSnapPosition===void 0?"10%":_ref$topSnapPosition,_ref$middleSnapPositi=_ref.middleSnapPosition,middleSnapPosition=_ref$middleSnapPositi===void 0?"50%":_ref$middleSnapPositi,_ref$bottomSnapPositi=_ref.bottomSnapPosition,bottomSnapPosition=_ref$bottomSnapPositi===void 0?"80%":_ref$bottomSnapPositi,initialSnapIndex=_ref.initialSnapIndex,_ref$initialSnapPosit=_ref.initialSnapPosition,initialSnapPosition=_ref$initialSnapPosit===void 0?"bottom":_ref$initialSnapPosit,_ref$showHandle=_ref.showHandle,showHandle=_ref$showHandle===void 0?true:_ref$showHandle,handleColor=_ref.handleColor,_ref$topBorderRadius=_ref.topBorderRadius,topBorderRadius=_ref$topBorderRadius===void 0?20:_ref$topBorderRadius,_ref$borderWidth=_ref.borderWidth,borderWidth=_ref$borderWidth===void 0?1:_ref$borderWidth,borderColor=_ref.borderColor,_ref$enableDynamicSiz=_ref.enableDynamicSizing,enableDynamicSizing=_ref$enableDynamicSiz===void 0?true:_ref$enableDynamicSiz,onSettle=_ref.onSettle,style=_ref.style,children=_ref.children,rest=_objectWithoutProperties(_ref,_excluded);var theme=useTheme();var backgroundColor=(style==null?void 0:style.backgroundColor)||theme.colors.background.brand;var snapPoints=snapPointsProp!=null?snapPointsProp:[topSnapPosition,middleSnapPosition,bottomSnapPosition];var mappedSnapPoints=useDeepCompareMemo(function(){return convertSnapPointsForNewImplementation(snapPoints);},snapPoints);var getSnapIndexFromPosition=function getSnapIndexFromPosition(position){switch(position){case"bottom":return 0;case"middle":return 1;case"top":return 2;}};return _jsx(BottomSheetComponent,{ref:ref,enableDynamicSizing:enableDynamicSizing,snapPoints:mappedSnapPoints,index:initialSnapIndex!==undefined?mappedSnapPoints.length-initialSnapIndex-1:getSnapIndexFromPosition(initialSnapPosition),handleIndicatorStyle:[{backgroundColor:handleColor!=null?handleColor:theme.colors.border.brand},!showHandle?{display:"none"}:{}],backgroundStyle:{backgroundColor:backgroundColor,borderTopLeftRadius:topBorderRadius,borderTopRightRadius:topBorderRadius,borderWidth:borderWidth,borderColor:borderColor!=null?borderColor:theme.colors.border.brand},onChange:function onChange(index){return enableDynamicSizing?onSettle==null?void 0:onSettle(mappedSnapPoints.length-index):onSettle==null?void 0:onSettle(mappedSnapPoints.length-index-1);},children:_jsx(BottomSheetScrollView,Object.assign({contentContainerStyle:[styles.contentContainerStyle,style]},rest,{children:children}))});});function convertSnapPointsForNewImplementation(snapPoints){var reversedSnapPoints=_toConsumableArray(snapPoints).reverse();return reversedSnapPoints.map(function(point){if(typeof point==="string"){var percentNumber=extractPercentNumber(point);if(percentNumber!==undefined){return`${100-percentNumber}%`;}return point;}else if(typeof point==="number"){return windowHeight-point;}else{return point;}});}var styles=StyleSheet.create({contentContainerStyle:{paddingHorizontal:16,paddingVertical:10}});export default BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Swiper/Swiper.tsx";import{withTheme}from"@draftbit/theme";import React
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Swiper/Swiper.tsx";import{withTheme}from"@draftbit/theme";import React,{forwardRef,useImperativeHandle}from"react";import{View}from"react-native";import SwiperComponent from"react-native-web-swiper";import{jsx as _jsx}from"react/jsx-runtime";var Swiper=forwardRef(function(_ref,ref){var _data$length;var theme=_ref.theme,_ref$vertical=_ref.vertical,vertical=_ref$vertical===void 0?false:_ref$vertical,_ref$loop=_ref.loop,loop=_ref$loop===void 0?false:_ref$loop,_ref$timeout=_ref.timeout,timeout=_ref$timeout===void 0?0:_ref$timeout,_ref$from=_ref.from,from=_ref$from===void 0?0:_ref$from,_ref$prevTitle=_ref.prevTitle,prevTitle=_ref$prevTitle===void 0?"":_ref$prevTitle,_ref$nextTitle=_ref.nextTitle,nextTitle=_ref$nextTitle===void 0?"":_ref$nextTitle,prevTitleColor=_ref.prevTitleColor,nextTitleColor=_ref.nextTitleColor,_ref$dotsTouchable=_ref.dotsTouchable,dotsTouchable=_ref$dotsTouchable===void 0?true:_ref$dotsTouchable,_ref$dotColor=_ref.dotColor,dotColor=_ref$dotColor===void 0?theme==null?void 0:theme.colors.foreground.brand:_ref$dotColor,_ref$dotActiveColor=_ref.dotActiveColor,dotActiveColor=_ref$dotActiveColor===void 0?theme==null?void 0:theme.colors.branding.primary:_ref$dotActiveColor,data=_ref.data,keyExtractor=_ref.keyExtractor,renderItem=_ref.renderItem,childrenProp=_ref.children,onIndexChangedProp=_ref.onIndexChanged,onSwipe=_ref.onSwipe,onSwipedNext=_ref.onSwipedNext,onSwipedPrevious=_ref.onSwipedPrevious,minDistanceForAction=_ref.minDistanceForAction,minDistanceToCapture=_ref.minDistanceToCapture,style=_ref.style;var _React$useState=React.useState(0),_React$useState2=_slicedToArray(_React$useState,2),currentIndex=_React$useState2[0],setCurrentIndex=_React$useState2[1];var numberOfItems=(_data$length=data==null?void 0:data.length)!=null?_data$length:React.Children.count(childrenProp);var swiperRef=React.useRef(null);var onIndexChanged=function onIndexChanged(index){var previous=currentIndex;var current=index;onIndexChangedProp==null?void 0:onIndexChangedProp(index);setCurrentIndex(index);if(previous===numberOfItems-1&¤t===0){onSwipedNext==null?void 0:onSwipedNext(previous);}else if(previous===0&¤t===numberOfItems-1){onSwipedPrevious==null?void 0:onSwipedPrevious(previous);}else if(current>previous){onSwipedNext==null?void 0:onSwipedNext(previous);}else if(current<previous){onSwipedPrevious==null?void 0:onSwipedPrevious(previous);}onSwipe==null?void 0:onSwipe(previous);};var children=React.useMemo(function(){return Array.isArray(data)&&renderItem?data.map(function(item,index){var component=renderItem({item:item,index:index});if(!component){return null;}var key=keyExtractor?keyExtractor(item,index):index;return React.cloneElement(component,{key:key});}):childrenProp;},[childrenProp,data,renderItem,keyExtractor]);React.useEffect(function(){var _swiperRef$current,_swiperRef$current$pr;var childrenArray=React.Children.toArray((_swiperRef$current=swiperRef.current)==null?void 0:(_swiperRef$current$pr=_swiperRef$current.props)==null?void 0:_swiperRef$current$pr.children);if(swiperRef.current){swiperRef.current.children=childrenArray;swiperRef.current.count=childrenArray.length;swiperRef.current.forceUpdate();}},[children]);useImperativeHandle(ref,function(){return{swipeTo:function swipeTo(index){var _swiperRef$current2;(_swiperRef$current2=swiperRef.current)==null?void 0:_swiperRef$current2.goTo(index);},swipeNext:function swipeNext(){var _swiperRef$current3;(_swiperRef$current3=swiperRef.current)==null?void 0:_swiperRef$current3.goToNext();},swipePrev:function swipePrev(){var _swiperRef$current4;(_swiperRef$current4=swiperRef.current)==null?void 0:_swiperRef$current4.goToPrev();}};});return _jsx(View,{style:style,children:_jsx(SwiperComponent,{ref:swiperRef,from:from,loop:loop,timeout:timeout,vertical:vertical,onIndexChanged:onIndexChanged,minDistanceForAction:minDistanceForAction,minDistanceToCapture:minDistanceToCapture,controlsProps:Object.assign({prevTitle:prevTitle,nextTitle:nextTitle,prevTitleStyle:{color:prevTitleColor},nextTitleStyle:{color:nextTitleColor},dotsTouchable:dotsTouchable},dotColor?{dotProps:{badgeStyle:{backgroundColor:dotColor}}}:{},dotActiveColor?{dotActiveStyle:{backgroundColor:dotActiveColor}}:{}),children:children})});});export default withTheme(Swiper);
|
|
@@ -7,7 +7,7 @@ const windowHeight = Dimensions.get("window").height;
|
|
|
7
7
|
// Clarification:
|
|
8
8
|
// Input of snap points is sorted top -> bottom where each value represents distance from top
|
|
9
9
|
// Implementation using `@gorhom/bottom-sheet` is sorted bottom -> top where each value represents distance from bottom
|
|
10
|
-
const BottomSheet = React.forwardRef(({ snapPoints: snapPointsProp, topSnapPosition = "10%", middleSnapPosition = "50%", bottomSnapPosition = "80%", initialSnapIndex, initialSnapPosition = "bottom", showHandle = true, handleColor, topBorderRadius = 20, borderWidth = 1, borderColor, onSettle, style, children, ...rest }, ref) => {
|
|
10
|
+
const BottomSheet = React.forwardRef(({ snapPoints: snapPointsProp, topSnapPosition = "10%", middleSnapPosition = "50%", bottomSnapPosition = "80%", initialSnapIndex, initialSnapPosition = "bottom", showHandle = true, handleColor, topBorderRadius = 20, borderWidth = 1, borderColor, enableDynamicSizing = true, onSettle, style, children, ...rest }, ref) => {
|
|
11
11
|
const theme = useTheme();
|
|
12
12
|
const backgroundColor = (style === null || style === void 0 ? void 0 : style.backgroundColor) || theme.colors.background.brand;
|
|
13
13
|
const snapPoints = snapPointsProp !== null && snapPointsProp !== void 0 ? snapPointsProp : [
|
|
@@ -26,7 +26,7 @@ const BottomSheet = React.forwardRef(({ snapPoints: snapPointsProp, topSnapPosit
|
|
|
26
26
|
return 2;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
return (React.createElement(BottomSheetComponent, { ref: ref, snapPoints: mappedSnapPoints, index: initialSnapIndex !== undefined
|
|
29
|
+
return (React.createElement(BottomSheetComponent, { ref: ref, enableDynamicSizing: enableDynamicSizing, snapPoints: mappedSnapPoints, index: initialSnapIndex !== undefined
|
|
30
30
|
? mappedSnapPoints.length - initialSnapIndex - 1
|
|
31
31
|
: getSnapIndexFromPosition(initialSnapPosition), handleIndicatorStyle: [
|
|
32
32
|
{ backgroundColor: handleColor !== null && handleColor !== void 0 ? handleColor : theme.colors.border.brand },
|
|
@@ -37,7 +37,12 @@ const BottomSheet = React.forwardRef(({ snapPoints: snapPointsProp, topSnapPosit
|
|
|
37
37
|
borderTopRightRadius: topBorderRadius,
|
|
38
38
|
borderWidth,
|
|
39
39
|
borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : theme.colors.border.brand,
|
|
40
|
-
}, onChange: (index) =>
|
|
40
|
+
}, onChange: (index) =>
|
|
41
|
+
// Convert bottom-sheet index to match our top-to-bottom ordering
|
|
42
|
+
// When dynamic sizing is enabled, we don't need to subtract 1 since an extra snap point may be added
|
|
43
|
+
enableDynamicSizing
|
|
44
|
+
? onSettle === null || onSettle === void 0 ? void 0 : onSettle(mappedSnapPoints.length - index)
|
|
45
|
+
: onSettle === null || onSettle === void 0 ? void 0 : onSettle(mappedSnapPoints.length - index - 1) },
|
|
41
46
|
React.createElement(BottomSheetScrollView, { contentContainerStyle: [styles.contentContainerStyle, style], ...rest }, children)));
|
|
42
47
|
});
|
|
43
48
|
// @gorhom/bottom-sheet has a different format for snap points and requires some manipulation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../../../src/components/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EAIV,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,oBAAoB,EAAE,EAC3B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../../../src/components/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EAIV,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,oBAAoB,EAAE,EAC3B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAyBrD,iBAAiB;AACjB,6FAA6F;AAC7F,uHAAuH;AACvH,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CACE,EACE,UAAU,EAAE,cAAc,EAC1B,eAAe,GAAG,KAAK,EACvB,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB,GAAG,KAAK,EAC1B,gBAAgB,EAChB,mBAAmB,GAAG,QAAQ,EAC9B,UAAU,GAAG,IAAI,EACjB,WAAW,EACX,eAAe,GAAG,EAAE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AAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,qBAAqB,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,EAAE;KACpB;CACF,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ReadTheme } from "@draftbit/theme";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { StyleProp, ViewStyle } from "react-native";
|
|
4
|
+
export interface SwiperRef {
|
|
5
|
+
swipeTo: (index: number) => void;
|
|
6
|
+
swipeNext: () => void;
|
|
7
|
+
swipePrev: () => void;
|
|
8
|
+
}
|
|
4
9
|
export interface SwiperProps<T> {
|
|
5
10
|
onSwipe?: (index: number) => void;
|
|
6
11
|
onSwipedNext?: (index: number) => void;
|
|
@@ -29,5 +34,5 @@ export interface SwiperProps<T> {
|
|
|
29
34
|
minDistanceToCapture?: number;
|
|
30
35
|
theme: ReadTheme;
|
|
31
36
|
}
|
|
32
|
-
declare const _default: React.ForwardRefExoticComponent<Omit<SwiperProps<any>, "theme"> & React.RefAttributes<any>>;
|
|
37
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<Omit<SwiperProps<any> & React.RefAttributes<SwiperRef>, "theme">, "ref"> & React.RefAttributes<any>>;
|
|
33
38
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from "@draftbit/theme";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { forwardRef, useImperativeHandle } from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import SwiperComponent from "react-native-web-swiper";
|
|
5
|
-
const Swiper = ({ theme, vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor = theme.colors.foreground.brand, dotActiveColor = theme.colors.branding.primary, data, keyExtractor, renderItem, children: childrenProp, onIndexChanged: onIndexChangedProp, onSwipe, onSwipedNext, onSwipedPrevious, minDistanceForAction, minDistanceToCapture, style, }) => {
|
|
5
|
+
const Swiper = forwardRef(({ theme, vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor = theme === null || theme === void 0 ? void 0 : theme.colors.foreground.brand, dotActiveColor = theme === null || theme === void 0 ? void 0 : theme.colors.branding.primary, data, keyExtractor, renderItem, children: childrenProp, onIndexChanged: onIndexChangedProp, onSwipe, onSwipedNext, onSwipedPrevious, minDistanceForAction, minDistanceToCapture, style, }, ref) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const [currentIndex, setCurrentIndex] = React.useState(0);
|
|
8
8
|
const numberOfItems = (_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : React.Children.count(childrenProp);
|
|
@@ -56,6 +56,20 @@ const Swiper = ({ theme, vertical = false, loop = false, timeout = 0, from = 0,
|
|
|
56
56
|
swiperRef.current.forceUpdate();
|
|
57
57
|
}
|
|
58
58
|
}, [children]);
|
|
59
|
+
useImperativeHandle(ref, () => ({
|
|
60
|
+
swipeTo: (index) => {
|
|
61
|
+
var _a;
|
|
62
|
+
(_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.goTo(index);
|
|
63
|
+
},
|
|
64
|
+
swipeNext: () => {
|
|
65
|
+
var _a;
|
|
66
|
+
(_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.goToNext();
|
|
67
|
+
},
|
|
68
|
+
swipePrev: () => {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.goToPrev();
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
59
73
|
return (React.createElement(View, { style: style },
|
|
60
74
|
React.createElement(SwiperComponent, { ref: swiperRef, from: from, loop: loop, timeout: timeout, vertical: vertical, onIndexChanged: onIndexChanged, minDistanceForAction: minDistanceForAction, minDistanceToCapture: minDistanceToCapture, controlsProps: {
|
|
61
75
|
prevTitle,
|
|
@@ -70,6 +84,6 @@ const Swiper = ({ theme, vertical = false, loop = false, timeout = 0, from = 0,
|
|
|
70
84
|
? { dotActiveStyle: { backgroundColor: dotActiveColor } }
|
|
71
85
|
: {}),
|
|
72
86
|
} }, children)));
|
|
73
|
-
};
|
|
87
|
+
});
|
|
74
88
|
export default withTheme(Swiper);
|
|
75
89
|
//# sourceMappingURL=Swiper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swiper.js","sourceRoot":"","sources":["../../../../../src/components/Swiper/Swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Swiper.js","sourceRoot":"","sources":["../../../../../src/components/Swiper/Swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAwB,MAAM,cAAc,CAAC;AAC1D,OAAO,eAAe,MAAM,yBAAyB,CAAC;AAkCtD,MAAM,MAAM,GAAG,UAAU,CACvB,CACE,EACE,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,CAAC,EACX,IAAI,GAAG,CAAC,EACR,SAAS,GAAG,EAAE,EACd,SAAS,GAAG,EAAE,EACd,cAAc,EACd,cAAc,EACd,aAAa,GAAG,IAAI,EACpB,QAAQ,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,UAAU,CAAC,KAAK,EACzC,cAAc,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAC/C,IAAI,EACJ,YAAY,EACZ,UAAU,EAC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