@hero-design/rn 8.3.0 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +74 -73
  3. package/lib/index.js +74 -73
  4. package/package.json +5 -5
  5. package/src/components/Carousel/CarouselItem.tsx +1 -6
  6. package/src/components/Carousel/CarouselPaginator/StyledCarouselPaginator.tsx +10 -9
  7. package/src/components/Carousel/CarouselPaginator/index.tsx +2 -3
  8. package/src/components/Carousel/StyledCarousel.tsx +9 -6
  9. package/src/components/Carousel/__tests__/StyledCarousel.spec.tsx +3 -3
  10. package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +1 -2
  11. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +600 -0
  12. package/src/components/Carousel/__tests__/index.spec.tsx +15 -7
  13. package/src/components/Carousel/index.tsx +65 -84
  14. package/src/components/Typography/Text/StyledText.tsx +1 -0
  15. package/src/components/Typography/Text/index.tsx +1 -0
  16. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +9 -2
  17. package/src/theme/components/carousel.ts +5 -2
  18. package/src/theme/components/typography.ts +2 -0
  19. package/src/theme/global/typography.ts +3 -0
  20. package/types/components/Carousel/CarouselItem.d.ts +1 -2
  21. package/types/components/Carousel/CarouselPaginator/StyledCarouselPaginator.d.ts +0 -2
  22. package/types/components/Carousel/StyledCarousel.d.ts +6 -4
  23. package/types/components/Carousel/index.d.ts +9 -23
  24. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  25. package/types/components/Typography/Text/index.d.ts +1 -1
  26. package/types/theme/components/carousel.d.ts +3 -0
  27. package/types/theme/components/typography.d.ts +2 -0
  28. package/types/theme/global/typography.d.ts +1 -0
@@ -1,9 +1,9 @@
1
- @hero-design/rn:build: cache hit, replaying output eb885563f0cea779
2
- @hero-design/rn:build: $ yarn build:js && yarn build:types
3
- @hero-design/rn:build: $ rollup -c
4
- @hero-design/rn:build: 
5
- @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
6
- @hero-design/rn:build: (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
7
- @hero-design/rn:build: (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
8
- @hero-design/rn:build: created lib/index.js, es/index.js in 25.7s
9
- @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
1
+ @hero-design/rn:build: cache hit, replaying output 3ad2304a0e6682cc
2
+ @hero-design/rn:build: $ yarn build:js && yarn build:types
3
+ @hero-design/rn:build: $ rollup -c
4
+ @hero-design/rn:build: 
5
+ @hero-design/rn:build: src/index.ts → lib/index.js, es/index.js...
6
+ @hero-design/rn:build: (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
7
+ @hero-design/rn:build: (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
8
+ @hero-design/rn:build: created lib/index.js, es/index.js in 23.8s
9
+ @hero-design/rn:build: $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -1376,6 +1376,7 @@ var getFontSizes = function getFontSizes(baseFontSize) {
1376
1376
  });
1377
1377
  return {
1378
1378
  '7xlarge': scale(fontSizes[10]),
1379
+ '6xlarge': scale(fontSizes[9]),
1379
1380
  xxxxxlarge: scale(fontSizes[8]),
1380
1381
  xxxxlarge: scale(fontSizes[7]),
1381
1382
  xxxlarge: scale(fontSizes[6]),
@@ -1392,6 +1393,7 @@ var getLineHeights = function getLineHeights(fontSizes) {
1392
1393
  var additionalSpace = 8;
1393
1394
  return {
1394
1395
  '7xlarge': fontSizes['7xlarge'] + additionalSpace,
1396
+ '6xlarge': fontSizes['6xlarge'] + additionalSpace,
1395
1397
  xxxxxlarge: fontSizes.xxxxxlarge + additionalSpace,
1396
1398
  xxxxlarge: fontSizes.xxxxlarge + additionalSpace,
1397
1399
  xxxlarge: fontSizes.xxxlarge + additionalSpace,
@@ -1804,7 +1806,10 @@ var getCarouselTheme = function getCarouselTheme(theme) {
1804
1806
  var space = {
1805
1807
  headingMarginTop: theme.space.small,
1806
1808
  headingMarginBottom: theme.space.medium,
1807
- paginatorMarginHorizontal: theme.space.small
1809
+ paginatorMarginHorizontal: theme.space.small,
1810
+ footerPaddingHorizontal: theme.space.large,
1811
+ footerPaddingVertical: theme.space.medium,
1812
+ footerMarginBottom: theme.space.large
1808
1813
  };
1809
1814
  var sizes = {
1810
1815
  indicatorWidth: theme.sizes.medium,
@@ -1815,13 +1820,13 @@ var getCarouselTheme = function getCarouselTheme(theme) {
1815
1820
  paginatorBorderRadius: theme.radii.rounded
1816
1821
  };
1817
1822
  var fontSizes = {
1818
- heading: theme.fontSizes.xxxxxlarge
1823
+ heading: theme.fontSizes['6xlarge']
1819
1824
  };
1820
1825
  var fonts = {
1821
1826
  heading: theme.fonts.playful.semiBold
1822
1827
  };
1823
1828
  var lineHeights = {
1824
- heading: theme.lineHeights.xxxlarge
1829
+ heading: theme.lineHeights['6xlarge']
1825
1830
  };
1826
1831
  return {
1827
1832
  colors: colors,
@@ -2669,6 +2674,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
2669
2674
  xlarge: theme.fontSizes.xlarge,
2670
2675
  xxxlarge: theme.fontSizes.xxxlarge,
2671
2676
  xxxxxlarge: theme.fontSizes.xxxxxlarge,
2677
+ '6xlarge': theme.fontSizes['6xlarge'],
2672
2678
  '7xlarge': theme.fontSizes['7xlarge']
2673
2679
  };
2674
2680
  var lineHeights = {
@@ -2678,6 +2684,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
2678
2684
  xlarge: theme.lineHeights.xlarge,
2679
2685
  xxxlarge: theme.lineHeights.xxxlarge,
2680
2686
  xxxxxlarge: theme.lineHeights.xxxxxlarge,
2687
+ '6xlarge': theme.lineHeights['6xlarge'],
2681
2688
  '7xlarge': theme.lineHeights['7xlarge']
2682
2689
  };
2683
2690
  return {
@@ -10489,7 +10496,8 @@ var Calendar = function Calendar(_ref) {
10489
10496
  var StyledCarouselPaginator = index$a(View)(function () {
10490
10497
  return {
10491
10498
  flexDirection: 'row',
10492
- alignItems: 'center'
10499
+ alignItems: 'center',
10500
+ marginStart: 'auto'
10493
10501
  };
10494
10502
  });
10495
10503
  var StyledCarouselPaginatorAnimatedView = index$a(Animated.View)(function (_ref) {
@@ -10510,7 +10518,7 @@ var CarouselPaginator = function CarouselPaginator(_ref) {
10510
10518
  width = _useWindowDimensions.width;
10511
10519
  var theme = useTheme();
10512
10520
  return /*#__PURE__*/React.createElement(StyledCarouselPaginator, null, new Array(numberOfSlides).fill('').map(function (_, index) {
10513
- var inputRange = [(index - 1) * width, index * width, (index + 1) * width];
10521
+ var inputRange = [(index - 1) * width - 1, index * width - 1, (index + 1) * width];
10514
10522
  var indicatorWidth = scrollX.interpolate({
10515
10523
  inputRange: inputRange,
10516
10524
  outputRange: [theme.space.small, theme.space.large, theme.space.small],
@@ -10522,7 +10530,6 @@ var CarouselPaginator = function CarouselPaginator(_ref) {
10522
10530
  extrapolate: 'clamp'
10523
10531
  });
10524
10532
  return /*#__PURE__*/React.createElement(StyledCarouselPaginatorAnimatedView, {
10525
- indicatorWidth: indicatorWidth,
10526
10533
  style: [{
10527
10534
  width: indicatorWidth,
10528
10535
  opacity: opacity
@@ -10553,10 +10560,9 @@ var Image = function Image(_ref) {
10553
10560
  }, imageNativeProps));
10554
10561
  };
10555
10562
 
10556
- var StyledCarousel = index$a(View)(function (_ref) {
10563
+ var StyledBackDrop = index$a(View)(function (_ref) {
10557
10564
  var themeSlideBackground = _ref.themeSlideBackground;
10558
10565
  return {
10559
- zIndex: 99999,
10560
10566
  position: 'absolute',
10561
10567
  backgroundColor: themeSlideBackground,
10562
10568
  top: 0,
@@ -10567,8 +10573,8 @@ var StyledCarousel = index$a(View)(function (_ref) {
10567
10573
  });
10568
10574
  var StyledCarouselView = index$a(View)(function () {
10569
10575
  return {
10570
- justifyContent: 'space-between',
10571
- height: '100%'
10576
+ flexGrow: 2,
10577
+ justifyContent: 'space-between'
10572
10578
  };
10573
10579
  });
10574
10580
  var StyledCarouselHeading = index$a(Typography.Text)(function (_ref2) {
@@ -10594,9 +10600,14 @@ var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
10594
10600
  width: width
10595
10601
  };
10596
10602
  });
10597
- var StyledCarouselFooterWrapper = index$a(Box)(function () {
10603
+ var StyledCarouselFooterWrapper = index$a(View)(function (_ref4) {
10604
+ var theme = _ref4.theme;
10598
10605
  return {
10599
- width: '100%'
10606
+ paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
10607
+ flexDirection: 'row',
10608
+ justifyContent: 'space-between',
10609
+ paddingVertical: theme.__hd__.carousel.space.footerPaddingVertical,
10610
+ marginBottom: theme.__hd__.carousel.space.footerMarginBottom
10600
10611
  };
10601
10612
  });
10602
10613
 
@@ -10605,8 +10616,7 @@ var CarouselItem = function CarouselItem(_ref) {
10605
10616
  image = _ref.image,
10606
10617
  content = _ref.content,
10607
10618
  heading = _ref.heading,
10608
- body = _ref.body,
10609
- minHeight = _ref.minHeight;
10619
+ body = _ref.body;
10610
10620
  return /*#__PURE__*/React.createElement(Box, {
10611
10621
  style: {
10612
10622
  width: width
@@ -10618,67 +10628,71 @@ var CarouselItem = function CarouselItem(_ref) {
10618
10628
  }), /*#__PURE__*/React.createElement(StyledCarouselContentWrapper, {
10619
10629
  paddingHorizontal: "large",
10620
10630
  marginTop: "large",
10621
- width: width,
10622
- style: {
10623
- minHeight: minHeight
10624
- }
10625
- }, content, /*#__PURE__*/React.createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React.createElement(Typography.Text, {
10626
- fontSize: "large"
10627
- }, body) : null));
10631
+ width: width
10632
+ }, content, /*#__PURE__*/React.createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React.createElement(Typography.Text, null, body) : null));
10628
10633
  };
10629
10634
 
10630
- var _excluded$9 = ["items", "onFinishPress", "onSkipPress", "onSlideChange", "finishButtonLabel", "skipButtonLabel", "footerHeight", "minContentHeight"];
10635
+ var _excluded$9 = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style"];
10636
+ function useStateFromProp(initialValue) {
10637
+ var _useState = useState(initialValue),
10638
+ _useState2 = _slicedToArray(_useState, 2),
10639
+ value = _useState2[0],
10640
+ setValue = _useState2[1];
10641
+ useEffect(function () {
10642
+ return setValue(initialValue);
10643
+ }, [initialValue]);
10644
+ return [value, setValue];
10645
+ }
10631
10646
  var Carousel = function Carousel(_ref) {
10632
10647
  var items = _ref.items,
10633
- onFinishPress = _ref.onFinishPress,
10634
- onSkipPress = _ref.onSkipPress,
10635
- onSlideChange = _ref.onSlideChange,
10636
- _ref$finishButtonLabe = _ref.finishButtonLabel,
10637
- finishButtonLabel = _ref$finishButtonLabe === void 0 ? "Let's go!" : _ref$finishButtonLabe,
10638
- _ref$skipButtonLabel = _ref.skipButtonLabel,
10639
- skipButtonLabel = _ref$skipButtonLabel === void 0 ? 'Skip' : _ref$skipButtonLabel,
10640
- _ref$footerHeight = _ref.footerHeight,
10641
- footerHeight = _ref$footerHeight === void 0 ? 70 : _ref$footerHeight,
10642
- _ref$minContentHeight = _ref.minContentHeight,
10643
- minContentHeight = _ref$minContentHeight === void 0 ? 250 : _ref$minContentHeight,
10648
+ onItemIndexChange = _ref.onItemIndexChange,
10649
+ renderActions = _ref.renderActions,
10650
+ _ref$selectedItemInde = _ref.selectedItemIndex,
10651
+ selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
10652
+ style = _ref.style,
10644
10653
  nativeProps = _objectWithoutProperties(_ref, _excluded$9);
10645
10654
  var carouselRef = useRef(null);
10646
- var _useState = useState(0),
10647
- _useState2 = _slicedToArray(_useState, 2),
10648
- currentSlideIndex = _useState2[0],
10649
- setCurrentSlideIndex = _useState2[1];
10655
+ var _useStateFromProp = useStateFromProp(selectedItemIndex),
10656
+ _useStateFromProp2 = _slicedToArray(_useStateFromProp, 2),
10657
+ currentSlideIndex = _useStateFromProp2[0],
10658
+ setCurrentSlideIndex = _useStateFromProp2[1];
10659
+ var internalOnItemIndexChange = useCallback(function (index) {
10660
+ setCurrentSlideIndex(index);
10661
+ if (onItemIndexChange) {
10662
+ onItemIndexChange(index);
10663
+ }
10664
+ }, [setCurrentSlideIndex, onItemIndexChange]);
10650
10665
  var _useWindowDimensions = useWindowDimensions(),
10651
10666
  width = _useWindowDimensions.width;
10652
10667
  var scrollX = useRef(new Animated.Value(0)).current;
10668
+ useEffect(function () {
10669
+ // must use setTimeout since when layout is mounted, the pagination dots are not set correct scrollX
10670
+ var handle = setTimeout(function () {
10671
+ var _carouselRef$current;
10672
+ scrollX.setValue(currentSlideIndex * width);
10673
+ (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 ? void 0 : _carouselRef$current.scrollToOffset({
10674
+ offset: currentSlideIndex * width,
10675
+ animated: true
10676
+ });
10677
+ }, 100);
10678
+ return function () {
10679
+ clearTimeout(handle);
10680
+ };
10681
+ }, [currentSlideIndex, carouselRef]);
10653
10682
  var visibleSlideChanged = useCallback(function (_ref2) {
10654
10683
  var viewableItems = _ref2.viewableItems;
10655
10684
  if (!viewableItems || viewableItems && !viewableItems.length) return;
10656
- var currentIndex = viewableItems[0].index;
10657
- setCurrentSlideIndex(viewableItems[0].index);
10658
- var currentSlide = items[currentIndex];
10659
- if (onSlideChange) {
10660
- onSlideChange(currentSlide);
10661
- }
10662
- }, [items, onSlideChange]);
10663
- var skipCarousel = useCallback(function () {
10664
- var currentSlide = items[currentSlideIndex];
10665
- if (onSkipPress) {
10666
- onSkipPress(currentSlide);
10667
- }
10668
- }, [currentSlideIndex, onSkipPress, items]);
10669
- var finishCarousel = useCallback(function () {
10670
- var currentSlide = items[currentSlideIndex];
10671
- if (onFinishPress) {
10672
- onFinishPress(currentSlide);
10673
- }
10674
- }, [onFinishPress, items, currentSlideIndex]);
10685
+ var index = viewableItems[0].index;
10686
+ internalOnItemIndexChange(index);
10687
+ }, []);
10675
10688
  var viewConfig = useRef({
10676
10689
  viewAreaCoveragePercentThreshold: 50
10677
10690
  }).current;
10678
- var isLastSlide = currentSlideIndex === items.length - 1;
10679
- return /*#__PURE__*/React.createElement(StyledCarousel, _extends$1({
10691
+ return /*#__PURE__*/React.createElement(View, _extends$1({
10692
+ style: style
10693
+ }, nativeProps), /*#__PURE__*/React.createElement(StyledBackDrop, {
10680
10694
  themeSlideBackground: items[currentSlideIndex].background
10681
- }, nativeProps), /*#__PURE__*/React.createElement(StyledCarouselView, null, /*#__PURE__*/React.createElement(FlatList, {
10695
+ }), /*#__PURE__*/React.createElement(StyledCarouselView, null, /*#__PURE__*/React.createElement(FlatList, {
10682
10696
  horizontal: true,
10683
10697
  showsHorizontalScrollIndicator: false,
10684
10698
  pagingEnabled: true,
@@ -10709,23 +10723,10 @@ var Carousel = function Carousel(_ref) {
10709
10723
  heading: heading,
10710
10724
  body: body,
10711
10725
  content: content,
10712
- minHeight: minContentHeight,
10713
10726
  width: width
10714
10727
  });
10715
10728
  }
10716
- }), /*#__PURE__*/React.createElement(StyledCarouselFooterWrapper, {
10717
- paddingHorizontal: "large",
10718
- flexDirection: "row",
10719
- justifyContent: "space-between",
10720
- style: {
10721
- height: footerHeight
10722
- }
10723
- }, /*#__PURE__*/React.createElement(CompoundButton, {
10724
- variant: isLastSlide ? 'filled' : 'text',
10725
- intent: "primary",
10726
- onPress: isLastSlide ? finishCarousel : skipCarousel,
10727
- text: isLastSlide ? finishButtonLabel : skipButtonLabel
10728
- }), /*#__PURE__*/React.createElement(CarouselPaginator, {
10729
+ }), /*#__PURE__*/React.createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), /*#__PURE__*/React.createElement(CarouselPaginator, {
10729
10730
  numberOfSlides: items.length,
10730
10731
  scrollX: scrollX
10731
10732
  }))));
package/lib/index.js CHANGED
@@ -1405,6 +1405,7 @@ var getFontSizes = function getFontSizes(baseFontSize) {
1405
1405
  });
1406
1406
  return {
1407
1407
  '7xlarge': scale(fontSizes[10]),
1408
+ '6xlarge': scale(fontSizes[9]),
1408
1409
  xxxxxlarge: scale(fontSizes[8]),
1409
1410
  xxxxlarge: scale(fontSizes[7]),
1410
1411
  xxxlarge: scale(fontSizes[6]),
@@ -1421,6 +1422,7 @@ var getLineHeights = function getLineHeights(fontSizes) {
1421
1422
  var additionalSpace = 8;
1422
1423
  return {
1423
1424
  '7xlarge': fontSizes['7xlarge'] + additionalSpace,
1425
+ '6xlarge': fontSizes['6xlarge'] + additionalSpace,
1424
1426
  xxxxxlarge: fontSizes.xxxxxlarge + additionalSpace,
1425
1427
  xxxxlarge: fontSizes.xxxxlarge + additionalSpace,
1426
1428
  xxxlarge: fontSizes.xxxlarge + additionalSpace,
@@ -1833,7 +1835,10 @@ var getCarouselTheme = function getCarouselTheme(theme) {
1833
1835
  var space = {
1834
1836
  headingMarginTop: theme.space.small,
1835
1837
  headingMarginBottom: theme.space.medium,
1836
- paginatorMarginHorizontal: theme.space.small
1838
+ paginatorMarginHorizontal: theme.space.small,
1839
+ footerPaddingHorizontal: theme.space.large,
1840
+ footerPaddingVertical: theme.space.medium,
1841
+ footerMarginBottom: theme.space.large
1837
1842
  };
1838
1843
  var sizes = {
1839
1844
  indicatorWidth: theme.sizes.medium,
@@ -1844,13 +1849,13 @@ var getCarouselTheme = function getCarouselTheme(theme) {
1844
1849
  paginatorBorderRadius: theme.radii.rounded
1845
1850
  };
1846
1851
  var fontSizes = {
1847
- heading: theme.fontSizes.xxxxxlarge
1852
+ heading: theme.fontSizes['6xlarge']
1848
1853
  };
1849
1854
  var fonts = {
1850
1855
  heading: theme.fonts.playful.semiBold
1851
1856
  };
1852
1857
  var lineHeights = {
1853
- heading: theme.lineHeights.xxxlarge
1858
+ heading: theme.lineHeights['6xlarge']
1854
1859
  };
1855
1860
  return {
1856
1861
  colors: colors,
@@ -2698,6 +2703,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
2698
2703
  xlarge: theme.fontSizes.xlarge,
2699
2704
  xxxlarge: theme.fontSizes.xxxlarge,
2700
2705
  xxxxxlarge: theme.fontSizes.xxxxxlarge,
2706
+ '6xlarge': theme.fontSizes['6xlarge'],
2701
2707
  '7xlarge': theme.fontSizes['7xlarge']
2702
2708
  };
2703
2709
  var lineHeights = {
@@ -2707,6 +2713,7 @@ var getTypographyTheme = function getTypographyTheme(theme) {
2707
2713
  xlarge: theme.lineHeights.xlarge,
2708
2714
  xxxlarge: theme.lineHeights.xxxlarge,
2709
2715
  xxxxxlarge: theme.lineHeights.xxxxxlarge,
2716
+ '6xlarge': theme.lineHeights['6xlarge'],
2710
2717
  '7xlarge': theme.lineHeights['7xlarge']
2711
2718
  };
2712
2719
  return {
@@ -10518,7 +10525,8 @@ var Calendar = function Calendar(_ref) {
10518
10525
  var StyledCarouselPaginator = index$a(reactNative.View)(function () {
10519
10526
  return {
10520
10527
  flexDirection: 'row',
10521
- alignItems: 'center'
10528
+ alignItems: 'center',
10529
+ marginStart: 'auto'
10522
10530
  };
10523
10531
  });
10524
10532
  var StyledCarouselPaginatorAnimatedView = index$a(reactNative.Animated.View)(function (_ref) {
@@ -10539,7 +10547,7 @@ var CarouselPaginator = function CarouselPaginator(_ref) {
10539
10547
  width = _useWindowDimensions.width;
10540
10548
  var theme = useTheme();
10541
10549
  return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginator, null, new Array(numberOfSlides).fill('').map(function (_, index) {
10542
- var inputRange = [(index - 1) * width, index * width, (index + 1) * width];
10550
+ var inputRange = [(index - 1) * width - 1, index * width - 1, (index + 1) * width];
10543
10551
  var indicatorWidth = scrollX.interpolate({
10544
10552
  inputRange: inputRange,
10545
10553
  outputRange: [theme.space.small, theme.space.large, theme.space.small],
@@ -10551,7 +10559,6 @@ var CarouselPaginator = function CarouselPaginator(_ref) {
10551
10559
  extrapolate: 'clamp'
10552
10560
  });
10553
10561
  return /*#__PURE__*/React__default["default"].createElement(StyledCarouselPaginatorAnimatedView, {
10554
- indicatorWidth: indicatorWidth,
10555
10562
  style: [{
10556
10563
  width: indicatorWidth,
10557
10564
  opacity: opacity
@@ -10582,10 +10589,9 @@ var Image = function Image(_ref) {
10582
10589
  }, imageNativeProps));
10583
10590
  };
10584
10591
 
10585
- var StyledCarousel = index$a(reactNative.View)(function (_ref) {
10592
+ var StyledBackDrop = index$a(reactNative.View)(function (_ref) {
10586
10593
  var themeSlideBackground = _ref.themeSlideBackground;
10587
10594
  return {
10588
- zIndex: 99999,
10589
10595
  position: 'absolute',
10590
10596
  backgroundColor: themeSlideBackground,
10591
10597
  top: 0,
@@ -10596,8 +10602,8 @@ var StyledCarousel = index$a(reactNative.View)(function (_ref) {
10596
10602
  });
10597
10603
  var StyledCarouselView = index$a(reactNative.View)(function () {
10598
10604
  return {
10599
- justifyContent: 'space-between',
10600
- height: '100%'
10605
+ flexGrow: 2,
10606
+ justifyContent: 'space-between'
10601
10607
  };
10602
10608
  });
10603
10609
  var StyledCarouselHeading = index$a(Typography.Text)(function (_ref2) {
@@ -10623,9 +10629,14 @@ var StyledCarouselContentWrapper = index$a(Box)(function (_ref3) {
10623
10629
  width: width
10624
10630
  };
10625
10631
  });
10626
- var StyledCarouselFooterWrapper = index$a(Box)(function () {
10632
+ var StyledCarouselFooterWrapper = index$a(reactNative.View)(function (_ref4) {
10633
+ var theme = _ref4.theme;
10627
10634
  return {
10628
- width: '100%'
10635
+ paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
10636
+ flexDirection: 'row',
10637
+ justifyContent: 'space-between',
10638
+ paddingVertical: theme.__hd__.carousel.space.footerPaddingVertical,
10639
+ marginBottom: theme.__hd__.carousel.space.footerMarginBottom
10629
10640
  };
10630
10641
  });
10631
10642
 
@@ -10634,8 +10645,7 @@ var CarouselItem = function CarouselItem(_ref) {
10634
10645
  image = _ref.image,
10635
10646
  content = _ref.content,
10636
10647
  heading = _ref.heading,
10637
- body = _ref.body,
10638
- minHeight = _ref.minHeight;
10648
+ body = _ref.body;
10639
10649
  return /*#__PURE__*/React__default["default"].createElement(Box, {
10640
10650
  style: {
10641
10651
  width: width
@@ -10647,67 +10657,71 @@ var CarouselItem = function CarouselItem(_ref) {
10647
10657
  }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselContentWrapper, {
10648
10658
  paddingHorizontal: "large",
10649
10659
  marginTop: "large",
10650
- width: width,
10651
- style: {
10652
- minHeight: minHeight
10653
- }
10654
- }, content, /*#__PURE__*/React__default["default"].createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
10655
- fontSize: "large"
10656
- }, body) : null));
10660
+ width: width
10661
+ }, content, /*#__PURE__*/React__default["default"].createElement(StyledCarouselHeading, null, heading), body ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, null, body) : null));
10657
10662
  };
10658
10663
 
10659
- var _excluded$9 = ["items", "onFinishPress", "onSkipPress", "onSlideChange", "finishButtonLabel", "skipButtonLabel", "footerHeight", "minContentHeight"];
10664
+ var _excluded$9 = ["items", "onItemIndexChange", "renderActions", "selectedItemIndex", "style"];
10665
+ function useStateFromProp(initialValue) {
10666
+ var _useState = React.useState(initialValue),
10667
+ _useState2 = _slicedToArray(_useState, 2),
10668
+ value = _useState2[0],
10669
+ setValue = _useState2[1];
10670
+ React.useEffect(function () {
10671
+ return setValue(initialValue);
10672
+ }, [initialValue]);
10673
+ return [value, setValue];
10674
+ }
10660
10675
  var Carousel = function Carousel(_ref) {
10661
10676
  var items = _ref.items,
10662
- onFinishPress = _ref.onFinishPress,
10663
- onSkipPress = _ref.onSkipPress,
10664
- onSlideChange = _ref.onSlideChange,
10665
- _ref$finishButtonLabe = _ref.finishButtonLabel,
10666
- finishButtonLabel = _ref$finishButtonLabe === void 0 ? "Let's go!" : _ref$finishButtonLabe,
10667
- _ref$skipButtonLabel = _ref.skipButtonLabel,
10668
- skipButtonLabel = _ref$skipButtonLabel === void 0 ? 'Skip' : _ref$skipButtonLabel,
10669
- _ref$footerHeight = _ref.footerHeight,
10670
- footerHeight = _ref$footerHeight === void 0 ? 70 : _ref$footerHeight,
10671
- _ref$minContentHeight = _ref.minContentHeight,
10672
- minContentHeight = _ref$minContentHeight === void 0 ? 250 : _ref$minContentHeight,
10677
+ onItemIndexChange = _ref.onItemIndexChange,
10678
+ renderActions = _ref.renderActions,
10679
+ _ref$selectedItemInde = _ref.selectedItemIndex,
10680
+ selectedItemIndex = _ref$selectedItemInde === void 0 ? 0 : _ref$selectedItemInde,
10681
+ style = _ref.style,
10673
10682
  nativeProps = _objectWithoutProperties(_ref, _excluded$9);
10674
10683
  var carouselRef = React.useRef(null);
10675
- var _useState = React.useState(0),
10676
- _useState2 = _slicedToArray(_useState, 2),
10677
- currentSlideIndex = _useState2[0],
10678
- setCurrentSlideIndex = _useState2[1];
10684
+ var _useStateFromProp = useStateFromProp(selectedItemIndex),
10685
+ _useStateFromProp2 = _slicedToArray(_useStateFromProp, 2),
10686
+ currentSlideIndex = _useStateFromProp2[0],
10687
+ setCurrentSlideIndex = _useStateFromProp2[1];
10688
+ var internalOnItemIndexChange = React.useCallback(function (index) {
10689
+ setCurrentSlideIndex(index);
10690
+ if (onItemIndexChange) {
10691
+ onItemIndexChange(index);
10692
+ }
10693
+ }, [setCurrentSlideIndex, onItemIndexChange]);
10679
10694
  var _useWindowDimensions = reactNative.useWindowDimensions(),
10680
10695
  width = _useWindowDimensions.width;
10681
10696
  var scrollX = React.useRef(new reactNative.Animated.Value(0)).current;
10697
+ React.useEffect(function () {
10698
+ // must use setTimeout since when layout is mounted, the pagination dots are not set correct scrollX
10699
+ var handle = setTimeout(function () {
10700
+ var _carouselRef$current;
10701
+ scrollX.setValue(currentSlideIndex * width);
10702
+ (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 ? void 0 : _carouselRef$current.scrollToOffset({
10703
+ offset: currentSlideIndex * width,
10704
+ animated: true
10705
+ });
10706
+ }, 100);
10707
+ return function () {
10708
+ clearTimeout(handle);
10709
+ };
10710
+ }, [currentSlideIndex, carouselRef]);
10682
10711
  var visibleSlideChanged = React.useCallback(function (_ref2) {
10683
10712
  var viewableItems = _ref2.viewableItems;
10684
10713
  if (!viewableItems || viewableItems && !viewableItems.length) return;
10685
- var currentIndex = viewableItems[0].index;
10686
- setCurrentSlideIndex(viewableItems[0].index);
10687
- var currentSlide = items[currentIndex];
10688
- if (onSlideChange) {
10689
- onSlideChange(currentSlide);
10690
- }
10691
- }, [items, onSlideChange]);
10692
- var skipCarousel = React.useCallback(function () {
10693
- var currentSlide = items[currentSlideIndex];
10694
- if (onSkipPress) {
10695
- onSkipPress(currentSlide);
10696
- }
10697
- }, [currentSlideIndex, onSkipPress, items]);
10698
- var finishCarousel = React.useCallback(function () {
10699
- var currentSlide = items[currentSlideIndex];
10700
- if (onFinishPress) {
10701
- onFinishPress(currentSlide);
10702
- }
10703
- }, [onFinishPress, items, currentSlideIndex]);
10714
+ var index = viewableItems[0].index;
10715
+ internalOnItemIndexChange(index);
10716
+ }, []);
10704
10717
  var viewConfig = React.useRef({
10705
10718
  viewAreaCoveragePercentThreshold: 50
10706
10719
  }).current;
10707
- var isLastSlide = currentSlideIndex === items.length - 1;
10708
- return /*#__PURE__*/React__default["default"].createElement(StyledCarousel, _extends$1({
10720
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.View, _extends$1({
10721
+ style: style
10722
+ }, nativeProps), /*#__PURE__*/React__default["default"].createElement(StyledBackDrop, {
10709
10723
  themeSlideBackground: items[currentSlideIndex].background
10710
- }, nativeProps), /*#__PURE__*/React__default["default"].createElement(StyledCarouselView, null, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
10724
+ }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselView, null, /*#__PURE__*/React__default["default"].createElement(reactNative.FlatList, {
10711
10725
  horizontal: true,
10712
10726
  showsHorizontalScrollIndicator: false,
10713
10727
  pagingEnabled: true,
@@ -10738,23 +10752,10 @@ var Carousel = function Carousel(_ref) {
10738
10752
  heading: heading,
10739
10753
  body: body,
10740
10754
  content: content,
10741
- minHeight: minContentHeight,
10742
10755
  width: width
10743
10756
  });
10744
10757
  }
10745
- }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, {
10746
- paddingHorizontal: "large",
10747
- flexDirection: "row",
10748
- justifyContent: "space-between",
10749
- style: {
10750
- height: footerHeight
10751
- }
10752
- }, /*#__PURE__*/React__default["default"].createElement(CompoundButton, {
10753
- variant: isLastSlide ? 'filled' : 'text',
10754
- intent: "primary",
10755
- onPress: isLastSlide ? finishCarousel : skipCarousel,
10756
- text: isLastSlide ? finishButtonLabel : skipButtonLabel
10757
- }), /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
10758
+ }), /*#__PURE__*/React__default["default"].createElement(StyledCarouselFooterWrapper, null, renderActions && renderActions(currentSlideIndex), /*#__PURE__*/React__default["default"].createElement(CarouselPaginator, {
10758
10759
  numberOfSlides: items.length,
10759
10760
  scrollX: scrollX
10760
10761
  }))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.3.0",
3
+ "version": "8.3.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/react": "^11.9.3",
24
- "@hero-design/colors": "8.3.0",
24
+ "@hero-design/colors": "8.3.1",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21"
@@ -44,7 +44,7 @@
44
44
  "@babel/preset-typescript": "^7.17.12",
45
45
  "@babel/runtime": "^7.18.9",
46
46
  "@emotion/jest": "^11.9.3",
47
- "@hero-design/eslint-plugin": "8.3.0",
47
+ "@hero-design/eslint-plugin": "8.3.1",
48
48
  "@react-native-community/datetimepicker": "^3.5.2",
49
49
  "@react-native-community/slider": "4.1.12",
50
50
  "@rollup/plugin-babel": "^5.3.1",
@@ -60,9 +60,9 @@
60
60
  "@types/react-native": "^0.67.7",
61
61
  "@types/react-native-vector-icons": "^6.4.10",
62
62
  "babel-plugin-inline-import": "^3.0.0",
63
- "eslint-config-hd": "8.3.0",
63
+ "eslint-config-hd": "8.3.1",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.3.0",
65
+ "prettier-config-hd": "8.3.1",
66
66
  "react": "18.0.0",
67
67
  "react-native": "0.69.7",
68
68
  "react-native-gesture-handler": "~2.1.0",
@@ -11,7 +11,6 @@ import { CarouselData } from './types';
11
11
 
12
12
  interface CarouselItemProps extends Omit<CarouselData, 'background'> {
13
13
  width: number;
14
- minHeight: number;
15
14
  }
16
15
 
17
16
  const CarouselItem = ({
@@ -20,7 +19,6 @@ const CarouselItem = ({
20
19
  content,
21
20
  heading,
22
21
  body,
23
- minHeight,
24
22
  }: CarouselItemProps) => {
25
23
  return (
26
24
  <Box style={{ width }}>
@@ -34,13 +32,10 @@ const CarouselItem = ({
34
32
  paddingHorizontal="large"
35
33
  marginTop="large"
36
34
  width={width}
37
- style={{ minHeight }}
38
35
  >
39
36
  {content}
40
37
  <StyledCarouselHeading>{heading}</StyledCarouselHeading>
41
- {body ? (
42
- <Typography.Text fontSize="large">{body}</Typography.Text>
43
- ) : null}
38
+ {body ? <Typography.Text>{body}</Typography.Text> : null}
44
39
  </StyledCarouselContentWrapper>
45
40
  </Box>
46
41
  );
@@ -4,16 +4,17 @@ import styled from '@emotion/native';
4
4
  const StyledCarouselPaginator = styled(View)(() => ({
5
5
  flexDirection: 'row',
6
6
  alignItems: 'center',
7
+ marginStart: 'auto',
7
8
  }));
8
9
 
9
- const StyledCarouselPaginatorAnimatedView = styled(Animated.View)<{
10
- indicatorWidth: Animated.AnimatedInterpolation;
11
- }>(({ theme }) => ({
12
- height: theme.__hd__.carousel.sizes.paginatorHeight,
13
- width: theme.__hd__.carousel.sizes.paginatorWidth,
14
- borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
15
- backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
16
- marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal,
17
- }));
10
+ const StyledCarouselPaginatorAnimatedView = styled(Animated.View)(
11
+ ({ theme }) => ({
12
+ height: theme.__hd__.carousel.sizes.paginatorHeight,
13
+ width: theme.__hd__.carousel.sizes.paginatorWidth,
14
+ borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
15
+ backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
16
+ marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal,
17
+ })
18
+ );
18
19
 
19
20
  export { StyledCarouselPaginator, StyledCarouselPaginatorAnimatedView };