@draftbit/core 47.2.6-f74750.2 → 47.2.7-85855.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.
@@ -10,6 +10,10 @@ var _reactNativeDeckSwiper = _interopRequireDefault(require("react-native-deck-s
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const DeckSwiper = _ref => {
12
12
  let {
13
+ onSwipedLeft,
14
+ onSwipedRight,
15
+ onSwipedUp,
16
+ onSwipedDown,
13
17
  onIndexChanged,
14
18
  onEndReached,
15
19
  startCardIndex = 0,
@@ -87,7 +91,11 @@ const DeckSwiper = _ref => {
87
91
  stackSize: visibleCardCount,
88
92
  backgroundColor: "transparent",
89
93
  cardVerticalMargin: 0,
90
- cardHorizontalMargin: 0
94
+ cardHorizontalMargin: 0,
95
+ onSwipedLeft: onSwipedLeft,
96
+ onSwipedRight: onSwipedRight,
97
+ onSwipedTop: onSwipedUp,
98
+ onSwipedBottom: onSwipedDown
91
99
  }));
92
100
  };
93
101
  const styles = _reactNative.StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"names":["DeckSwiper","onIndexChanged","onEndReached","startCardIndex","infiniteSwiping","verticalEnabled","horizontalEnabled","visibleCardCount","data","keyExtractor","renderItem","style","children","Error","console","warn","childrenArray","React","useMemo","Children","toArray","cardsFillerData","Array","from","length","keys","cardsData","renderCard","card","index","item","renderFirstCard","undefined","cardKeyExtractor","toString","styles","containerHeightFiller","StyleSheet","flatten","cardsContainer","create","position","left","right","width","height","opacity"],"sourceRoot":"../../../../src","sources":["components/DeckSwiper/DeckSwiper.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAA2D;AAgB3D,MAAMA,UAAU,GAAG,QAagC;EAAA,IAbb;IACpCC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAG,CAAC;IAClBC,eAAe,GAAG,KAAK;IACvBC,eAAe,GAAG,IAAI;IACtBC,iBAAiB,GAAG,IA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C,MAAM;MACL,OAAOA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEM,QAAQ,EAAE;IACzB;EACF,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAEE,oBACE,6BAAC,iBAAI,qBACH,6BAAC,iBAAI;IAAC,KAAK,EAAEC,MAAM,CAACC;EAAsB,GAAEL,eAAe,EAAE,CAAQ,eACrE,6BAAC,8BAAmB;IAClB,KAAK,EAAEL,SAAmB;IAC1B,UAAU,EAAEC,UAAW;IACvB,YAAY,EAAEM,gBAAiB;IAC/B,cAAc,EACZI,uBAAU,CAACC,OAAO,CAAC,CAACH,MAAM,CAACI,cAAc,EAAE5B,KAAK,CAAC,CAGlD;IACD,SAAS,EAAEwB,MAAM,CAACP,IAA2B;IAC7C,QAAQ,EAAE3B,cAAe;IACzB,WAAW,EAAEC,YAAa;IAC1B,SAAS,EAAEC,cAAe;IAC1B,QAAQ,EAAEC,eAAgB;IAC1B,aAAa,EAAEC,eAAgB;IAC/B,eAAe,EAAEC,iBAAkB;IACnC,cAAc,EAAEC,gBAAgB,GAAG,CAAE;IACrC,SAAS,EAAEA,gBAAiB;IAC5B,eAAe,EAAC,aAAa;IAC7B,kBAAkB,EAAE,CAAE;IACtB,oBAAoB,EAAE;EAAE,EACxB,CACG;AAEX,CAAC;AAED,MAAM4B,MAAM,GAAGE,uBAAU,CAACG,MAAM,CAAC;EAC/BD,cAAc,EAAE;IACdE,QAAQ,EAAE;EACZ,CAAC;EACDb,IAAI,EAAE;IACJc,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDT,qBAAqB,EAAE;IACrBU,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAAC,eAEY9C,UAAU;AAAA"}
1
+ {"version":3,"names":["DeckSwiper","onSwipedLeft","onSwipedRight","onSwipedUp","onSwipedDown","onIndexChanged","onEndReached","startCardIndex","infiniteSwiping","verticalEnabled","horizontalEnabled","visibleCardCount","data","keyExtractor","renderItem","style","children","Error","console","warn","childrenArray","React","useMemo","Children","toArray","cardsFillerData","Array","from","length","keys","cardsData","renderCard","card","index","item","renderFirstCard","undefined","cardKeyExtractor","toString","styles","containerHeightFiller","StyleSheet","flatten","cardsContainer","create","position","left","right","width","height","opacity"],"sourceRoot":"../../../../src","sources":["components/DeckSwiper/DeckSwiper.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAA2D;AAoB3D,MAAMA,UAAU,GAAG,QAiBgC;EAAA,IAjBb;IACpCC,YAAY;IACZC,aAAa;IACbC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAG,CAAC;IAClBC,eAAe,GAAG,KAAK;IACvBC,eAAe,GAAG,IAAI;IACtBC,iBAAiB,GAAG,IAAI;IACxBC,gBAAgB,GAAG,CAAC;IACpBC,IAAI;IACJC,YAAY;IACZC,UAAU;IACVC,KAAK;IACLC;EAC2C,CAAC;EAC5C;EACA,IAAKJ,IAAI,IAAI,CAACE,UAAU,IAAMA,UAAU,IAAI,CAACF,IAAK,EAAE;IAClD,MAAM,IAAIK,KAAK,CACb,gHAAgH,CACjH;EACH;EAEA,IAAIL,IAAI,IAAIE,UAAU,IAAIE,QAAQ,EAAE;IAClCE,OAAO,CAACC,IAAI,CACV,0EAA0E,CAC3E;EACH;EAEA,MAAMC,aAAa,GAAGC,cAAK,CAACC,OAAO,CACjC,MAAMD,cAAK,CAACE,QAAQ,CAACC,OAAO,CAACR,QAAQ,CAAC,EACtC,CAACA,QAAQ,CAAC,CACX;;EAED;EACA,MAAMS,eAAe,GAAGJ,cAAK,CAACC,OAAO,CACnC,MAAMI,KAAK,CAACC,IAAI,CAACD,KAAK,CAACN,aAAa,CAACQ,MAAM,CAAC,CAACC,IAAI,EAAE,CAAC,EACpD,CAACT,aAAa,CAAC,CAChB;EAED,MAAMU,SAAS,GAAGlB,IAAI,IAAIa,eAAe;EAEzC,M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AEA,gBAAiB;IAC5B,eAAe,EAAC,aAAa;IAC7B,kBAAkB,EAAE,CAAE;IACtB,oBAAoB,EAAE,CAAE;IACxB,YAAY,EAAEV,YAAa;IAC3B,aAAa,EAAEC,aAAc;IAC7B,WAAW,EAAEC,UAAW;IACxB,cAAc,EAAEC;EAAa,EAC7B,CACG;AAEX,CAAC;AAED,MAAMmC,MAAM,GAAGE,uBAAU,CAACG,MAAM,CAAC;EAC/BD,cAAc,EAAE;IACdE,QAAQ,EAAE;EACZ,CAAC;EACDb,IAAI,EAAE;IACJc,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDT,qBAAqB,EAAE;IACrBU,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAAC,eAEYlD,UAAU;AAAA"}
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
9
9
  var _theming = require("../theming");
10
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
13
  const Divider = _ref => {
13
14
  let {
14
15
  style,
@@ -18,18 +19,6 @@ const Divider = _ref => {
18
19
  },
19
20
  ...rest
20
21
  } = _ref;
21
- return /*#__PURE__*/React.createElement(_reactNative.View, {
22
- style: [{
23
- backgroundColor: color || colors.divider,
24
- height: _reactNative.StyleSheet.hairlineWidth
25
- }, style],
26
- ...rest
27
- });
28
- };
29
- var _default = (0, _theming.withTheme)(Divider);
30
- exports.default = _default;
31
- //# sourceMappingURL=Divider.js.mapst
32
- } = _ref;
33
22
  return /*#__PURE__*/React.createElement(_reactNative.View, _extends({
34
23
  style: [{
35
24
  backgroundColor: color || colors.divider,
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
9
9
  var _reactNativeWebSwiper = _interopRequireDefault(require("react-native-web-swiper"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const Swiper = _ref => {
12
+ var _data$length;
12
13
  let {
13
14
  vertical = false,
14
15
  loop = false,
@@ -25,9 +26,30 @@ const Swiper = _ref => {
25
26
  keyExtractor,
26
27
  renderItem,
27
28
  children,
28
- onIndexChanged,
29
+ onIndexChanged: onIndexChangedProp,
30
+ onSwipedNext,
31
+ onSwipedPrevious,
29
32
  style
30
33
  } = _ref;
34
+ const [currentIndex, setCurrentIndex] = _react.default.useState(0);
35
+ const numberOfItems = (_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : _react.default.Children.count(children);
36
+ const onIndexChanged = index => {
37
+ const previous = currentIndex;
38
+ const current = index;
39
+ onIndexChangedProp === null || onIndexChangedProp === void 0 ? void 0 : onIndexChangedProp(index);
40
+ setCurrentIndex(index);
41
+ if (previous === numberOfItems - 1 && current === 0) {
42
+ //Last -> first swipe
43
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
44
+ } else if (previous === 0 && current === numberOfItems - 1) {
45
+ //First -> last swipe
46
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
47
+ } else if (current > previous) {
48
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
49
+ } else if (current < previous) {
50
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
51
+ }
52
+ };
31
53
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
32
54
  style: style
33
55
  }, /*#__PURE__*/_react.default.createElement(_reactNativeWebSwiper.default, {
@@ -1 +1 @@
1
- {"version":3,"names":["Swiper","vertical","loop","timeout","from","prevTitle","nextTitle","prevTitleColor","nextTitleColor","dotsTouchable","dotColor","dotActiveColor","data","keyExtractor","renderItem","children","onIndexChanged","style","prevTitleStyle","color","nextTitleStyle","dotProps","badgeStyle","backgroundColor","dotActiveStyle","map","item","index","component","key","React","cloneElement"],"sourceRoot":"../../../../src","sources":["components/Swiper/Swiper.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAAsD;AAsBtD,MAAMA,MAAM,GAAG;EAAA,IAAC;IACdC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,OAAO,GAAG,CAAC;IACXC,IAAI,GAAG,CAAC;IACRC,SAAS,GAAG,EAAE;IACdC,SAAS,GAAG,EAAE;IACdC,cAAc;IACdC,cAAc;IACdC,aAAa,GAAG,IAAI;IACpBC,QAAQ;IACRC,cAAc;IACdC,IAAI;IACJC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,cAAc;IACdC;EACgB,CAAC;EAAA,oBACjB,6BAAC,iBAAI;IAAC,KAAK,EAAEA;EAAM,gBAEjB,6BAAC,6BAAe;IACd,IAAI,EAAEb,IAAK;IACX,IAAI,EAAEF,IAAK;IACX,OAAO,EAAEC,OAAQ;IACjB,QAAQ,EAAEF,QAAS;IACnB,cAAc,EAAEe,cAAe;IAC/B,aAAa,EAAE;MACbX,SAAS;MACTC,SAAS;MACTY,cAAc,EAAE;QAAEC,KAAK,EAAEZ;MAAe,CAAC;MACzCa,cAAc,EAAE;QAAED,KAAK,EAAEX;MAAe,CAAC;MACzCC,aAAa;MACb,IAAIC,QAAQ,GACR;QAAEW,QAAQ,EAAE;UAAEC,UAAU,EAAE;YAAEC,eAAe,EAAEb;UAAS;QAAE;MAAE,CAAC,GAC3D,CAAC,CAAC,CAAC;MACP,IAAIC,cAAc,GACd;QAAEa,cAAc,EAAE;UAAED,eAAe,EAAEZ;QAAe;MAAE,CAAC,GACvD,CAAC,CAAC;IACR;EAAE,GAEDC,IAAI,IAAIE,UAAU,GACfF,IAAI,CAACa,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;IACxB,MAAMC,SAAS,GAAGd,UAAU,CAAC;MAAEY,IAAI;MAAEC;IAAM,CAAC,CAAC;IAE7C,IAAI,CAACC,SAAS,EAAE;MACd,OAAO,IAAI;IACb;IAEA,MAAMC,GAAG,GAAGhB,YAAY,GAAGA,YAAY,CAACa,IAAI,EAAEC,KAAK,CAAC,GAAGA,KAAK;IAC5D,oBAAOG,cAAK,CAACC,YAAY,CAACH,SAAS,EAAE;MACnCC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,GACFd,QAAQ,CACI,CACb;AAAA,CACR;AAAC,eAEaf,MAAM;AAAA"}
1
+ {"version":3,"names":["Swiper","vertical","loop","timeout","from","prevTitle","nextTitle","prevTitleColor","nextTitleColor","dotsTouchable","dotColor","dotActiveColor","data","keyExtractor","renderItem","children","onIndexChanged","onIndexChangedProp","onSwipedNext","onSwipedPrevious","style","currentIndex","setCurrentIndex","React","useState","numberOfItems","length","Children","count","index","previous","current","prevTitleStyle","color","nextTitleStyle","dotProps","badgeStyle","backgroundColor","dotActiveStyle","map","item","component","key","cloneElement"],"sourceRoot":"../../../../src","sources":["components/Swiper/Swiper.t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F3B,QAAQ,CACI,CACb;AAEX,CAAC;AAAC,eAEaf,MAAM;AAAA"}
@@ -3,6 +3,10 @@ import { StyleSheet, View } from "react-native";
3
3
  import DeckSwiperComponent from "react-native-deck-swiper";
4
4
  const DeckSwiper = _ref => {
5
5
  let {
6
+ onSwipedLeft,
7
+ onSwipedRight,
8
+ onSwipedUp,
9
+ onSwipedDown,
6
10
  onIndexChanged,
7
11
  onEndReached,
8
12
  startCardIndex = 0,
@@ -80,7 +84,11 @@ const DeckSwiper = _ref => {
80
84
  stackSize: visibleCardCount,
81
85
  backgroundColor: "transparent",
82
86
  cardVerticalMargin: 0,
83
- cardHorizontalMargin: 0
87
+ cardHorizontalMargin: 0,
88
+ onSwipedLeft: onSwipedLeft,
89
+ onSwipedRight: onSwipedRight,
90
+ onSwipedTop: onSwipedUp,
91
+ onSwipedBottom: onSwipedDown
84
92
  }));
85
93
  };
86
94
  const styles = StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"names":["React","StyleSheet","View","DeckSwiperComponent","DeckSwiper","onIndexChanged","onEndReached","startCardIndex","infiniteSwiping","verticalEnabled","horizontalEnabled","visibleCardCount","data","keyExtractor","renderItem","style","children","Error","console","warn","childrenArray","useMemo","Children","toArray","cardsFillerData","Array","from","length","keys","cardsData","renderCard","card","index","item","renderFirstCard","undefined","cardKeyExtractor","toString","styles","containerHeightFiller","flatten","cardsContainer","create","position","left","right","width","height","opacity"],"sourceRoot":"../../../../src","sources":["components/DeckSwiper/DeckSwiper.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAA+BC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACrE,OAAOC,mBAAmB,MAAM,0BAA0B;AAgB1D,MAAMC,UAAU,GAAG,QAagC;EAAA,IAbb;IACpCC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAG,CAAC;IAClBC,eAAe,GAAG,KAAK;IACvBC,eAAe,GAAG,IAAI;IACtBC,iBAAiB,GAAG,IAAI;IACx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AAC,MAAM;MACL,OAAOA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEM,QAAQ,EAAE;IACzB;EACF,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAEE,oBACE,oBAAC,IAAI,qBACH,oBAAC,IAAI;IAAC,KAAK,EAAEC,MAAM,CAACC;EAAsB,GAAEL,eAAe,EAAE,CAAQ,eACrE,oBAAC,mBAAmB;IAClB,KAAK,EAAEL,SAAmB;IAC1B,UAAU,EAAEC,UAAW;IACvB,YAAY,EAAEM,gBAAiB;IAC/B,cAAc,EACZnC,UAAU,CAACuC,OAAO,CAAC,CAACF,MAAM,CAACG,cAAc,EAAE1B,KAAK,CAAC,CAGlD;IACD,SAAS,EAAEuB,MAAM,CAACP,IAA2B;IAC7C,QAAQ,EAAE1B,cAAe;IACzB,WAAW,EAAEC,YAAa;IAC1B,SAAS,EAAEC,cAAe;IAC1B,QAAQ,EAAEC,eAAgB;IAC1B,aAAa,EAAEC,eAAgB;IAC/B,eAAe,EAAEC,iBAAkB;IACnC,cAAc,EAAEC,gBAAgB,GAAG,CAAE;IACrC,SAAS,EAAEA,gBAAiB;IAC5B,eAAe,EAAC,aAAa;IAC7B,kBAAkB,EAAE,CAAE;IACtB,oBAAoB,EAAE;EAAE,EACxB,CACG;AAEX,CAAC;AAED,MAAM2B,MAAM,GAAGrC,UAAU,CAACyC,MAAM,CAAC;EAC/BD,cAAc,EAAE;IACdE,QAAQ,EAAE;EACZ,CAAC;EACDZ,IAAI,EAAE;IACJa,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDR,qBAAqB,EAAE;IACrBS,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAEF,eAAe5C,UAAU"}
1
+ {"version":3,"names":["React","StyleSheet","View","DeckSwiperComponent","DeckSwiper","onSwipedLeft","onSwipedRight","onSwipedUp","onSwipedDown","onIndexChanged","onEndReached","startCardIndex","infiniteSwiping","verticalEnabled","horizontalEnabled","visibleCardCount","data","keyExtractor","renderItem","style","children","Error","console","warn","childrenArray","useMemo","Children","toArray","cardsFillerData","Array","from","length","keys","cardsData","renderCard","card","index","item","renderFirstCard","undefined","cardKeyExtractor","toString","styles","containerHeightFiller","flatten","cardsContainer","create","position","left","right","width","height","opacity"],"sourceRoot":"../../../../src","sources":["components/DeckSwiper/DeckSwiper.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAA+BC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACrE,OAAOC,mBAAmB,MAAM,0BAA0B;AAoB1D,MAAMC,UAAU,GAAG,QAiBgC;EAAA,IAjBb;IACpCC,YAAY;IACZC,aAAa;IACbC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,YAAY;IACZC,cAAc,GAAG,CAAC;IAClBC,eAAe,GAAG,KAAK;IACvBC,eAAe,GAAG,IAAI;IACtBC,iBAAiB,GAAG,IAAI;IACxBC,gBAAgB,GAAG,CAAC;IACpBC,IAAI;IACJC,YAAY;IACZC,UAAU;IACVC,KAAK;IACLC;EAC2C,CAAC;EAC5C;EACA,IAAKJ,IAAI,IAAI,CAACE,UAAU,IAAMA,UAAU,IAAI,CAACF,IAAK,EAAE;IAClD,MAAM,IAAIK,KAAK,CACb,gHAAgH,CACjH;EACH;EAEA,IAAIL,IAAI,IAAIE,UAAU,IAAIE,QAAQ,EAAE;IAClCE,OAAO,CAACC,IAAI,CACV,0EAA0E,CAC3E;EACH;EAEA,MAAMC,aAAa,GAAGxB,KAAK,CAACyB,OAAO,CACjC,MAAMzB,KAAK,CAAC0B,QAAQ,CAACC,OAAO,CAACP,QAAQ,CAAC,EACtC,CAACA,QAAQ,CAAC,CACX;;EAED;EACA,MAAMQ,eAAe,GAAG5B,KAAK,CAACyB,OAAO,CACnC,MAAMI,KAAK,CAACC,IAAI,CAACD,KAAK,CAACL,aAAa,CAACO,MAAM,CAAC,CA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AC1B,aAAa,EAAEC,eAAgB;IAC/B,eAAe,EAAEC,iBAAkB;IACnC,cAAc,EAAEC,gBAAgB,GAAG,CAAE;IACrC,SAAS,EAAEA,gBAAiB;IAC5B,eAAe,EAAC,aAAa;IAC7B,kBAAkB,EAAE,CAAE;IACtB,oBAAoB,EAAE,CAAE;IACxB,YAAY,EAAEV,YAAa;IAC3B,aAAa,EAAEC,aAAc;IAC7B,WAAW,EAAEC,UAAW;IACxB,cAAc,EAAEC;EAAa,EAC7B,CACG;AAEX,CAAC;AAED,MAAMkC,MAAM,GAAGzC,UAAU,CAAC6C,MAAM,CAAC;EAC/BD,cAAc,EAAE;IACdE,QAAQ,EAAE;EACZ,CAAC;EACDZ,IAAI,EAAE;IACJa,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDR,qBAAqB,EAAE;IACrBS,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAEF,eAAehD,UAAU"}
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { View } from "react-native";
3
3
  import SwiperComponent from "react-native-web-swiper";
4
4
  const Swiper = _ref => {
5
+ var _data$length;
5
6
  let {
6
7
  vertical = false,
7
8
  loop = false,
@@ -18,9 +19,30 @@ const Swiper = _ref => {
18
19
  keyExtractor,
19
20
  renderItem,
20
21
  children,
21
- onIndexChanged,
22
+ onIndexChanged: onIndexChangedProp,
23
+ onSwipedNext,
24
+ onSwipedPrevious,
22
25
  style
23
26
  } = _ref;
27
+ const [currentIndex, setCurrentIndex] = React.useState(0);
28
+ const numberOfItems = (_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : React.Children.count(children);
29
+ const onIndexChanged = index => {
30
+ const previous = currentIndex;
31
+ const current = index;
32
+ onIndexChangedProp === null || onIndexChangedProp === void 0 ? void 0 : onIndexChangedProp(index);
33
+ setCurrentIndex(index);
34
+ if (previous === numberOfItems - 1 && current === 0) {
35
+ //Last -> first swipe
36
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
37
+ } else if (previous === 0 && current === numberOfItems - 1) {
38
+ //First -> last swipe
39
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
40
+ } else if (current > previous) {
41
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
42
+ } else if (current < previous) {
43
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
44
+ }
45
+ };
24
46
  return /*#__PURE__*/React.createElement(View, {
25
47
  style: style
26
48
  }, /*#__PURE__*/React.createElement(SwiperComponent, {
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","SwiperComponent","Swiper","vertical","loop","timeout","from","prevTitle","nextTitle","prevTitleColor","nextTitleColor","dotsTouchable","dotColor","dotActiveColor","data","keyExtractor","renderItem","children","onIndexChanged","style","prevTitleStyle","color","nextTitleStyle","dotProps","badgeStyle","backgroundColor","dotActiveStyle","map","item","index","component","key","cloneElement"],"sourceRoot":"../../../../src","sources":["components/Swiper/Swiper.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAA8B,cAAc;AACzD,OAAOC,eAAe,MAAM,yBAAyB;AAsBrD,MAAMC,MAAM,GAAG;EAAA,IAAC;IACdC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,OAAO,GAAG,CAAC;IACXC,IAAI,GAAG,CAAC;IACRC,SAAS,GAAG,EAAE;IACdC,SAAS,GAAG,EAAE;IACdC,cAAc;IACdC,cAAc;IACdC,aAAa,GAAG,IAAI;IACpBC,QAAQ;IACRC,cAAc;IACdC,IAAI;IACJC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,cAAc;IACdC;EACgB,CAAC;EAAA,oBACjB,oBAAC,IAAI;IAAC,KAAK,EAAEA;EAAM,gBAEjB,oBAAC,eAAe;IACd,IAAI,EAAEb,IAAK;IACX,IAAI,EAAEF,IAAK;IACX,OAAO,EAAEC,OAAQ;IACjB,QAAQ,EAAEF,QAAS;IACnB,cAAc,EAAEe,cAAe;IAC/B,aAAa,EAAE;MACbX,SAAS;MACTC,SAAS;MACTY,cAAc,EAAE;QAAEC,KAAK,EAAEZ;MAAe,CAAC;MACzCa,cAAc,EAAE;QAAED,KAAK,EAAEX;MAAe,CAAC;MACzCC,aAAa;MACb,IAAIC,QAAQ,GACR;QAAEW,QAAQ,EAAE;UAAEC,UAAU,EAAE;YAAEC,eAAe,EAAEb;UAAS;QAAE;MAAE,CAAC,GAC3D,CAAC,CAAC,CAAC;MACP,IAAIC,cAAc,GACd;QAAEa,cAAc,EAAE;UAAED,eAAe,EAAEZ;QAAe;MAAE,CAAC,GACvD,CAAC,CAAC;IACR;EAAE,GAEDC,IAAI,IAAIE,UAAU,GACfF,IAAI,CAACa,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;IACxB,MAAMC,SAAS,GAAGd,UAAU,CAAC;MAAEY,IAAI;MAAEC;IAAM,CAAC,CAAC;IAE7C,IAAI,CAACC,SAAS,EAAE;MACd,OAAO,IAAI;IACb;IAEA,MAAMC,GAAG,GAAGhB,YAAY,GAAGA,YAAY,CAACa,IAAI,EAAEC,KAAK,CAAC,GAAGA,KAAK;IAC5D,oBAAO9B,KAAK,CAACiC,YAAY,CAACF,SAAS,EAAE;MACnCC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,GACFd,QAAQ,CACI,CACb;AAAA,CACR;AAED,eAAef,MAAM"}
1
+ {"version":3,"names":["React","View","SwiperComponent","Swiper","vertical","loop","timeout","from","prevTitle","nextTitle","prevTitleColor","nextTitleColor","dotsTouchable","dotColor","dotActiveColor","data","keyExtractor","renderItem","children","onIndexChanged","onIndexChangedProp","onSwipedNext","onSwipedPrevious","style","currentIndex","setCurrentIndex","useState","numberOfItems","length","Children","count","index","previous","current","prevTitleStyle","color","nextTitleStyle","dotProps","badgeStyle","backgroundColor","dotActiveStyle","map","item","component","key","cloneElement"],"sourceRoot":"../../../../src","sources":["components/Swiper/Swiper.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAA8B,cAAc;AACzD,OAAOC,eAAe,MAAM,yBAAyB;AAwBrD,MAAMC,MAAM,GAAG,QAoBS;EAAA;EAAA,IApBR;IACdC,QAAQ,GAAG,KAAK;IAChBC,IAAI,GAAG,KAAK;IACZC,OAAO,GAAG,CAAC;IACXC,IAAI,GAAG,CAAC;IACRC,SAAS,GAAG,EAAE;IACdC,SAAS,GAAG,EAAE;IACdC,cAAc;IACdC,cAAc;IACdC,aAAa,GAAG,IAAI;IACpBC,QAAQ;IACRC,cAAc;IACdC,IAAI;IACJC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,cAAc,EAAEC,kBAAkB;IAClCC,YAAY;IACZC,gBAAgB;IAChBC;EACgB,CAAC;EACjB,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGzB,KAAK,CAAC0B,QAAQ,CAAC,CAAC,CAAC;EACzD,MAAMC,aAAa,mBAAGZ,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEa,MAAM,uDAAI5B,KAAK,CAAC6B,QAAQ,CAACC,KAAK,CAACZ,QAAQ,CAAC;EAEpE,MAAMC,cAAc,GAAIY,KAAa,IAAK;IACxC,MAAMC,QAAQ,GAAGR,YAAY;IAC7B,MAAMS,OAAO,GAAGF,KAAK;IAErBX,kBAAkB,aAAlBA,kBAAkB,uBAAlBA,kBAAkB,CAAGW,KAAK,CAAC;IAC3BN,eAAe,CAACM,KAAK,CAAC;IAEtB,IAAIC,QAAQ,KAAKL,aAAa,GAAG,CAAC,IAAIM,OAAO,KAAK,CAAC,EAAE;MACnD;MACAZ,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAGW,QAAQ,CAAC;IAC1B,CAAC,MAAM,IAAIA,QAAQ,KAAK,CAAC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5B,YAAY,GAAGA,YAAY,CAAC0B,IAAI,EAAEX,KAAK,CAAC,GAAGA,KAAK;IAC5D,oBAAO/B,KAAK,CAAC6C,YAAY,CAACF,SAAS,EAAE;MACnCC;IACF,CAAC,CAAC;EACJ,CAAC,CAAC,GACF1B,QAAQ,CACI,CACb;AAEX,CAAC;AAED,eAAef,MAAM"}
@@ -1,6 +1,10 @@
1
1
  import React from "react";
2
2
  import { StyleProp, ViewStyle } from "react-native";
3
3
  export interface DeckSwiperProps<T> {
4
+ onSwipedLeft?: (index: number) => void;
5
+ onSwipedRight?: (index: number) => void;
6
+ onSwipedUp?: (index: number) => void;
7
+ onSwipedDown?: (index: number) => void;
4
8
  onIndexChanged?: (index: number) => void;
5
9
  onEndReached?: () => void;
6
10
  startCardIndex?: number;
@@ -16,6 +20,6 @@ export interface DeckSwiperProps<T> {
16
20
  }) => JSX.Element;
17
21
  style?: StyleProp<ViewStyle>;
18
22
  }
19
- declare const DeckSwiper: <T extends object>({ onIndexChanged, onEndReached, startCardIndex, infiniteSwiping, verticalEnabled, horizontalEnabled, visibleCardCount, data, keyExtractor, renderItem, style, children, }: React.PropsWithChildren<DeckSwiperProps<T>>) => JSX.Element;
23
+ declare const DeckSwiper: <T extends object>({ onSwipedLeft, onSwipedRight, onSwipedUp, onSwipedDown, onIndexChanged, onEndReached, startCardIndex, infiniteSwiping, verticalEnabled, horizontalEnabled, visibleCardCount, data, keyExtractor, renderItem, style, children, }: React.PropsWithChildren<DeckSwiperProps<T>>) => JSX.Element;
20
24
  export default DeckSwiper;
21
25
  //# sourceMappingURL=DeckSwiper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeckSwiper.d.ts","sourceRoot":"","sources":["../../../../../src/components/DeckSwiper/DeckSwiper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAGtE,MAAM,WAAW,eAAe,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CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACnC,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAC;IAC1E,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,QAAA,MAAM,UAAU,kTA4Gf,CAAC;AAiBF,eAAe,UAAU,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import { StyleProp, ViewStyle } from "react-native";
3
3
  export interface SwiperProps<T> {
4
+ onSwipedNext?: (index: number) => void;
5
+ onSwipedPrevious?: (index: number) => void;
4
6
  vertical?: boolean;
5
7
  loop?: boolean;
6
8
  from?: number;
@@ -22,6 +24,6 @@ export interface SwiperProps<T> {
22
24
  style?: StyleProp<ViewStyle>;
23
25
  onIndexChanged?: (index: number) => void;
24
26
  }
25
- declare const Swiper: ({ vertical, loop, timeout, from, prevTitle, nextTitle, prevTitleColor, nextTitleColor, dotsTouchable, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged, style, }: SwiperProps<any>) => JSX.Element;
27
+ declare const Swiper: ({ vertical, loop, timeout, from, prevTitle, nextTitle, prevTitleColor, nextTitleColor, dotsTouchable, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged: onIndexChangedProp, onSwipedNext, onSwipedPrevious, style, }: SwiperProps<any>) => JSX.Element;
26
28
  export default Swiper;
27
29
  //# sourceMappingURL=Swiper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Swiper.d.ts","sourceRoot":"","sources":["../../../../../src/components/Swiper/Swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG1D,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAC;IAC1E,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IA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E,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,QAAA,MAAM,MAAM,2PAoBT,YAAY,GAAG,CAAC,gBAgElB,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "47.2.6-f74750.2+f74750b",
3
+ "version": "47.2.7-085855.2+085855c",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "^47.2.6-f74750.2+f74750b",
44
+ "@draftbit/types": "^47.2.7-085855.2+085855c",
45
45
  "@material-ui/core": "^4.11.0",
46
46
  "@material-ui/pickers": "^3.2.10",
47
47
  "@react-native-community/slider": "4.2.4",
@@ -94,5 +94,5 @@
94
94
  "node_modules/",
95
95
  "lib/"
96
96
  ],
97
- "gitHead": "f74750bfd42203f3194c16fcc6e7d4b86705227d"
97
+ "gitHead": "085855c012a7d23bf3cc503a22cc7e5a97dcbefa"
98
98
  }
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { StyleSheet, View } from "react-native";
3
3
  import DeckSwiperComponent from "react-native-deck-swiper";
4
- const DeckSwiper = ({ onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, data, keyExtractor, renderItem, style, children, }) => {
4
+ const DeckSwiper = ({ onSwipedLeft, onSwipedRight, onSwipedUp, onSwipedDown, onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, data, keyExtractor, renderItem, style, children, }) => {
5
5
  //Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
6
6
  if ((data && !renderItem) || (renderItem && !data)) {
7
7
  throw new Error("'renderItem' and 'data' need to both be provided to lazily render. Either remove them entirley or include both");
@@ -46,7 +46,7 @@ const DeckSwiper = ({ onIndexChanged, onEndReached, startCardIndex = 0, infinite
46
46
  */
47
47
  return (React.createElement(View, null,
48
48
  React.createElement(View, { style: styles.containerHeightFiller }, renderFirstCard()),
49
- React.createElement(DeckSwiperComponent, { cards: cardsData, renderCard: renderCard, keyExtractor: cardKeyExtractor, containerStyle: StyleSheet.flatten([styles.cardsContainer, style]), cardStyle: styles.card, onSwiped: onIndexChanged, onSwipedAll: onEndReached, cardIndex: startCardIndex, infinite: infiniteSwiping, verticalSwipe: verticalEnabled, horizontalSwipe: horizontalEnabled, showSecondCard: visibleCardCount > 1, stackSize: visibleCardCount, backgroundColor: "transparent", cardVerticalMargin: 0, cardHorizontalMargin: 0 })));
49
+ React.createElement(DeckSwiperComponent, { cards: cardsData, renderCard: renderCard, keyExtractor: cardKeyExtractor, containerStyle: StyleSheet.flatten([styles.cardsContainer, style]), cardStyle: styles.card, onSwiped: onIndexChanged, onSwipedAll: onEndReached, cardIndex: startCardIndex, infinite: infiniteSwiping, verticalSwipe: verticalEnabled, horizontalSwipe: horizontalEnabled, showSecondCard: visibleCardCount > 1, stackSize: visibleCardCount, backgroundColor: "transparent", cardVerticalMargin: 0, cardHorizontalMargin: 0, onSwipedLeft: onSwipedLeft, onSwipedRight: onSwipedRight, onSwipedTop: onSwipedUp, onSwipedBottom: onSwipedDown })));
50
50
  };
51
51
  const styles = StyleSheet.create({
52
52
  cardsContainer: {
@@ -3,6 +3,10 @@ import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
3
3
  import DeckSwiperComponent from "react-native-deck-swiper";
4
4
 
5
5
  export interface DeckSwiperProps<T> {
6
+ onSwipedLeft?: (index: number) => void;
7
+ onSwipedRight?: (index: number) => void;
8
+ onSwipedUp?: (index: number) => void;
9
+ onSwipedDown?: (index: number) => void;
6
10
  onIndexChanged?: (index: number) => void;
7
11
  onEndReached?: () => void;
8
12
  startCardIndex?: number;
@@ -17,6 +21,10 @@ export interface DeckSwiperProps<T> {
17
21
  }
18
22
 
19
23
  const DeckSwiper = <T extends object>({
24
+ onSwipedLeft,
25
+ onSwipedRight,
26
+ onSwipedUp,
27
+ onSwipedDown,
20
28
  onIndexChanged,
21
29
  onEndReached,
22
30
  startCardIndex = 0,
@@ -113,6 +121,10 @@ const DeckSwiper = <T extends object>({
113
121
  backgroundColor="transparent"
114
122
  cardVerticalMargin={0}
115
123
  cardHorizontalMargin={0}
124
+ onSwipedLeft={onSwipedLeft}
125
+ onSwipedRight={onSwipedRight}
126
+ onSwipedTop={onSwipedUp}
127
+ onSwipedBottom={onSwipedDown}
116
128
  />
117
129
  </View>
118
130
  );
@@ -1,29 +1,54 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
3
  import SwiperComponent from "react-native-web-swiper";
4
- const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged, style, }) => (React.createElement(View, { style: style },
5
- React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, onIndexChanged: onIndexChanged, controlsProps: {
6
- prevTitle,
7
- nextTitle,
8
- prevTitleStyle: { color: prevTitleColor },
9
- nextTitleStyle: { color: nextTitleColor },
10
- dotsTouchable,
11
- ...(dotColor
12
- ? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
13
- : {}),
14
- ...(dotActiveColor
15
- ? { dotActiveStyle: { backgroundColor: dotActiveColor } }
16
- : {}),
17
- } }, data && renderItem
18
- ? data.map((item, index) => {
19
- const component = renderItem({ item, index });
20
- if (!component) {
21
- return null;
22
- }
23
- const key = keyExtractor ? keyExtractor(item, index) : index;
24
- return React.cloneElement(component, {
25
- key,
26
- });
27
- })
28
- : children)));
4
+ const Swiper = ({ vertical = false, loop = false, timeout = 0, from = 0, prevTitle = "", nextTitle = "", prevTitleColor, nextTitleColor, dotsTouchable = true, dotColor, dotActiveColor, data, keyExtractor, renderItem, children, onIndexChanged: onIndexChangedProp, onSwipedNext, onSwipedPrevious, style, }) => {
5
+ var _a;
6
+ const [currentIndex, setCurrentIndex] = React.useState(0);
7
+ const numberOfItems = (_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : React.Children.count(children);
8
+ const onIndexChanged = (index) => {
9
+ const previous = currentIndex;
10
+ const current = index;
11
+ onIndexChangedProp === null || onIndexChangedProp === void 0 ? void 0 : onIndexChangedProp(index);
12
+ setCurrentIndex(index);
13
+ if (previous === numberOfItems - 1 && current === 0) {
14
+ //Last -> first swipe
15
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
16
+ }
17
+ else if (previous === 0 && current === numberOfItems - 1) {
18
+ //First -> last swipe
19
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
20
+ }
21
+ else if (current > previous) {
22
+ onSwipedNext === null || onSwipedNext === void 0 ? void 0 : onSwipedNext(previous);
23
+ }
24
+ else if (current < previous) {
25
+ onSwipedPrevious === null || onSwipedPrevious === void 0 ? void 0 : onSwipedPrevious(previous);
26
+ }
27
+ };
28
+ return (React.createElement(View, { style: style },
29
+ React.createElement(SwiperComponent, { from: from, loop: loop, timeout: timeout, vertical: vertical, onIndexChanged: onIndexChanged, controlsProps: {
30
+ prevTitle,
31
+ nextTitle,
32
+ prevTitleStyle: { color: prevTitleColor },
33
+ nextTitleStyle: { color: nextTitleColor },
34
+ dotsTouchable,
35
+ ...(dotColor
36
+ ? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
37
+ : {}),
38
+ ...(dotActiveColor
39
+ ? { dotActiveStyle: { backgroundColor: dotActiveColor } }
40
+ : {}),
41
+ } }, data && renderItem
42
+ ? data.map((item, index) => {
43
+ const component = renderItem({ item, index });
44
+ if (!component) {
45
+ return null;
46
+ }
47
+ const key = keyExtractor ? keyExtractor(item, index) : index;
48
+ return React.cloneElement(component, {
49
+ key,
50
+ });
51
+ })
52
+ : children)));
53
+ };
29
54
  export default Swiper;
@@ -3,6 +3,8 @@ import { View, StyleProp, ViewStyle } from "react-native";
3
3
  import SwiperComponent from "react-native-web-swiper";
4
4
 
5
5
  export interface SwiperProps<T> {
6
+ onSwipedNext?: (index: number) => void;
7
+ onSwipedPrevious?: (index: number) => void;
6
8
  vertical?: boolean;
7
9
  loop?: boolean;
8
10
  from?: number;
@@ -38,47 +40,74 @@ const Swiper = ({
38
40
  keyExtractor,
39
41
  renderItem,
40
42
  children,
41
- onIndexChanged,
43
+ onIndexChanged: onIndexChangedProp,
44
+ onSwipedNext,
45
+ onSwipedPrevious,
42
46
  style,
43
- }: SwiperProps<any>) => (
44
- <View style={style}>
45
- {/* @ts-ignore */}
46
- <SwiperComponent
47
- from={from}
48
- loop={loop}
49
- timeout={timeout}
50
- vertical={vertical}
51
- onIndexChanged={onIndexChanged}
52
- controlsProps={{
53
- prevTitle,
54
- nextTitle,
55
- prevTitleStyle: { color: prevTitleColor },
56
- nextTitleStyle: { color: nextTitleColor },
57
- dotsTouchable,
58
- ...(dotColor
59
- ? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
60
- : {}),
61
- ...(dotActiveColor
62
- ? { dotActiveStyle: { backgroundColor: dotActiveColor } }
63
- : {}),
64
- }}
65
- >
66
- {data && renderItem
67
- ? data.map((item, index) => {
68
- const component = renderItem({ item, index });
47
+ }: SwiperProps<any>) => {
48
+ const [currentIndex, setCurrentIndex] = React.useState(0);
49
+ const numberOfItems = data?.length ?? React.Children.count(children);
69
50
 
70
- if (!component) {
71
- return null;
72
- }
51
+ const onIndexChanged = (index: number) => {
52
+ const previous = currentIndex;
53
+ const current = index;
73
54
 
74
- const key = keyExtractor ? keyExtractor(item, index) : index;
75
- return React.cloneElement(component, {
76
- key,
77
- });
78
- })
79
- : children}
80
- </SwiperComponent>
81
- </View>
82
- );
55
+ onIndexChangedProp?.(index);
56
+ setCurrentIndex(index);
57
+
58
+ if (previous === numberOfItems - 1 && current === 0) {
59
+ //Last -> first swipe
60
+ onSwipedNext?.(previous);
61
+ } else if (previous === 0 && current === numberOfItems - 1) {
62
+ //First -> last swipe
63
+ onSwipedPrevious?.(previous);
64
+ } else if (current > previous) {
65
+ onSwipedNext?.(previous);
66
+ } else if (current < previous) {
67
+ onSwipedPrevious?.(previous);
68
+ }
69
+ };
70
+
71
+ return (
72
+ <View style={style}>
73
+ {/* @ts-ignore */}
74
+ <SwiperComponent
75
+ from={from}
76
+ loop={loop}
77
+ timeout={timeout}
78
+ vertical={vertical}
79
+ onIndexChanged={onIndexChanged}
80
+ controlsProps={{
81
+ prevTitle,
82
+ nextTitle,
83
+ prevTitleStyle: { color: prevTitleColor },
84
+ nextTitleStyle: { color: nextTitleColor },
85
+ dotsTouchable,
86
+ ...(dotColor
87
+ ? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }
88
+ : {}),
89
+ ...(dotActiveColor
90
+ ? { dotActiveStyle: { backgroundColor: dotActiveColor } }
91
+ : {}),
92
+ }}
93
+ >
94
+ {data && renderItem
95
+ ? data.map((item, index) => {
96
+ const component = renderItem({ item, index });
97
+
98
+ if (!component) {
99
+ return null;
100
+ }
101
+
102
+ const key = keyExtractor ? keyExtractor(item, index) : index;
103
+ return React.cloneElement(component, {
104
+ key,
105
+ });
106
+ })
107
+ : children}
108
+ </SwiperComponent>
109
+ </View>
110
+ );
111
+ };
83
112
 
84
113
  export default Swiper;