@hero-design/rn 8.30.3 → 8.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/es/index.js +116 -176
  3. package/lib/index.js +116 -176
  4. package/package.json +5 -5
  5. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +3 -33
  6. package/src/components/Carousel/index.tsx +18 -5
  7. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +818 -981
  8. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +11 -4
  9. package/src/components/FAB/ActionGroup/index.tsx +98 -142
  10. package/src/components/FAB/AnimatedFABIcon.tsx +5 -3
  11. package/src/components/FAB/FAB.tsx +28 -112
  12. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +9 -27
  13. package/src/components/FAB/__tests__/index.spec.tsx +2 -22
  14. package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +14 -14
  15. package/src/components/Skeleton/index.tsx +3 -7
  16. package/src/components/Typography/Caption/StyledCaption.tsx +19 -0
  17. package/src/components/Typography/Caption/__tests__/StyledCaption.spec.tsx +39 -0
  18. package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +211 -0
  19. package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +287 -0
  20. package/src/components/Typography/Caption/__tests__/index.spec.tsx +46 -0
  21. package/src/components/Typography/Caption/index.tsx +61 -0
  22. package/src/components/Typography/index.tsx +3 -0
  23. package/src/components/Typography/types.ts +18 -0
  24. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -0
  25. package/src/theme/components/typography.ts +2 -0
  26. package/src/types.ts +0 -4
  27. package/src/utils/helpers.ts +4 -1
  28. package/testUtils/setup.tsx +0 -2
  29. package/types/components/Accordion/AccordionItem.d.ts +1 -1
  30. package/types/components/Accordion/StyledAccordion.d.ts +1 -1
  31. package/types/components/Avatar/StyledAvatar.d.ts +2 -2
  32. package/types/components/Badge/StyledBadge.d.ts +2 -2
  33. package/types/components/BottomNavigation/index.d.ts +1 -1
  34. package/types/components/BottomSheet/BottomSheetContext.d.ts +1 -1
  35. package/types/components/Box/config.d.ts +2 -2
  36. package/types/components/Box/types.d.ts +3 -3
  37. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +1 -1
  38. package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
  39. package/types/components/Button/StyledButton.d.ts +2 -2
  40. package/types/components/Carousel/CardCarousel.d.ts +1 -1
  41. package/types/components/Carousel/types.d.ts +2 -2
  42. package/types/components/Divider/StyledDivider.d.ts +1 -1
  43. package/types/components/Drawer/DragableDrawer/helpers.d.ts +1 -1
  44. package/types/components/Empty/StyledEmpty.d.ts +1 -1
  45. package/types/components/Error/StyledError.d.ts +1 -1
  46. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -1
  47. package/types/components/FAB/ActionGroup/index.d.ts +1 -7
  48. package/types/components/FAB/AnimatedFABIcon.d.ts +1 -1
  49. package/types/components/FAB/FAB.d.ts +2 -8
  50. package/types/components/FAB/index.d.ts +2 -3
  51. package/types/components/Icon/AnimatedIcon.d.ts +1 -1
  52. package/types/components/Icon/HeroIcon/index.d.ts +2 -2
  53. package/types/components/Icon/index.d.ts +1 -1
  54. package/types/components/List/StyledListItem.d.ts +2 -2
  55. package/types/components/PinInput/StyledPinInput.d.ts +1 -1
  56. package/types/components/Progress/types.d.ts +1 -1
  57. package/types/components/Radio/types.d.ts +1 -1
  58. package/types/components/RefreshControl/index.d.ts +1 -1
  59. package/types/components/RichTextEditor/RichTextEditor.d.ts +1 -1
  60. package/types/components/RichTextEditor/types.d.ts +1 -1
  61. package/types/components/Select/BaseOptionList.d.ts +1 -1
  62. package/types/components/Select/MultiSelect/OptionList.d.ts +1 -1
  63. package/types/components/Select/SingleSelect/OptionList.d.ts +1 -1
  64. package/types/components/Select/helpers.d.ts +1 -1
  65. package/types/components/Select/types.d.ts +6 -6
  66. package/types/components/Skeleton/StyledSkeleton.d.ts +2 -2
  67. package/types/components/Success/StyledSuccess.d.ts +1 -1
  68. package/types/components/Swipeable/StyledSwipeable.d.ts +1 -1
  69. package/types/components/Swipeable/index.d.ts +2 -2
  70. package/types/components/Switch/SelectorSwitch/index.d.ts +3 -3
  71. package/types/components/Switch/StyledSwitch.d.ts +1 -1
  72. package/types/components/Tabs/TabWithBadge.d.ts +3 -3
  73. package/types/components/Tabs/index.d.ts +2 -2
  74. package/types/components/Tag/StyledTag.d.ts +2 -2
  75. package/types/components/TextInput/StyledTextInput.d.ts +2 -2
  76. package/types/components/TextInput/index.d.ts +1 -1
  77. package/types/components/Toast/ToastContext.d.ts +2 -2
  78. package/types/components/Toast/ToastProvider.d.ts +1 -1
  79. package/types/components/Toast/types.d.ts +2 -2
  80. package/types/components/Typography/Caption/StyledCaption.d.ts +13 -0
  81. package/types/components/Typography/Caption/index.d.ts +26 -0
  82. package/types/components/Typography/index.d.ts +2 -0
  83. package/types/components/Typography/types.d.ts +6 -0
  84. package/types/theme/ThemeSwitcher.d.ts +1 -1
  85. package/types/theme/components/typography.d.ts +2 -0
  86. package/types/theme/getTheme.d.ts +1 -1
  87. package/types/theme/global/colors/types.d.ts +3 -3
  88. package/types/theme/global/index.d.ts +1 -1
  89. package/types/theme/global/scale.d.ts +1 -1
  90. package/types/theme/global/typography.d.ts +1 -1
  91. package/types/types.d.ts +1 -3
  92. package/types/utils/helpers.d.ts +1 -1
package/lib/index.js CHANGED
@@ -3148,7 +3148,8 @@ var getTypographyTheme = function getTypographyTheme(theme) {
3148
3148
  xxxxlarge: theme.fontSizes.xxxxlarge,
3149
3149
  xxxxxlarge: theme.fontSizes.xxxxxlarge,
3150
3150
  '6xlarge': theme.fontSizes['6xlarge'],
3151
- '7xlarge': theme.fontSizes['7xlarge']
3151
+ '7xlarge': theme.fontSizes['7xlarge'],
3152
+ caption: theme.fontSizes.small
3152
3153
  };
3153
3154
  var lineHeights = {
3154
3155
  xsmall: theme.lineHeights.xsmall,
@@ -3160,7 +3161,8 @@ var getTypographyTheme = function getTypographyTheme(theme) {
3160
3161
  xxxxlarge: theme.lineHeights.xxxxlarge,
3161
3162
  xxxxxlarge: theme.lineHeights.xxxxxlarge,
3162
3163
  '6xlarge': theme.lineHeights['6xlarge'],
3163
- '7xlarge': theme.lineHeights['7xlarge']
3164
+ '7xlarge': theme.lineHeights['7xlarge'],
3165
+ caption: theme.lineHeights.small
3164
3166
  };
3165
3167
  return {
3166
3168
  colors: colors,
@@ -6220,7 +6222,7 @@ var Spacer$1 = index$a(reactNative.View)(function (_ref3) {
6220
6222
  };
6221
6223
  });
6222
6224
 
6223
- var FONTWEIGHT_MAP = {
6225
+ var FONTWEIGHT_MAP$1 = {
6224
6226
  light: 'light',
6225
6227
  regular: 'regular',
6226
6228
  'semi-bold': 'semiBold'
@@ -6237,12 +6239,12 @@ var StyledText$3 = index$a(reactNative.Text)(function (_ref) {
6237
6239
  letterSpacing: theme.__hd__.typography.fontSizes[themeFontSize] * 0.03
6238
6240
  };
6239
6241
  return _objectSpread2(_objectSpread2({}, sizeStyles), {}, {
6240
- fontFamily: theme.__hd__.typography.fonts[themeTypeface][FONTWEIGHT_MAP[themeFontWeight]],
6242
+ fontFamily: theme.__hd__.typography.fonts[themeTypeface][FONTWEIGHT_MAP$1[themeFontWeight]],
6241
6243
  color: theme.__hd__.typography.colors[themeIntent]
6242
6244
  });
6243
6245
  });
6244
6246
 
6245
- var _excluded$u = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
6247
+ var _excluded$v = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
6246
6248
  var Text = function Text(_ref) {
6247
6249
  var children = _ref.children,
6248
6250
  _ref$fontSize = _ref.fontSize,
@@ -6255,7 +6257,7 @@ var Text = function Text(_ref) {
6255
6257
  typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
6256
6258
  _ref$allowFontScaling = _ref.allowFontScaling,
6257
6259
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
6258
- nativeProps = _objectWithoutProperties(_ref, _excluded$u);
6260
+ nativeProps = _objectWithoutProperties(_ref, _excluded$v);
6259
6261
  return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
6260
6262
  themeFontSize: fontSize,
6261
6263
  themeFontWeight: fontWeight,
@@ -6265,8 +6267,45 @@ var Text = function Text(_ref) {
6265
6267
  }), children);
6266
6268
  };
6267
6269
 
6270
+ var FONTWEIGHT_MAP = {
6271
+ light: 'light',
6272
+ regular: 'regular',
6273
+ 'semi-bold': 'semiBold'
6274
+ };
6275
+
6276
+ var StyledCaption = index$a(reactNative.Text)(function (_ref) {
6277
+ var themeFontWeight = _ref.themeFontWeight,
6278
+ themeIntent = _ref.themeIntent,
6279
+ theme = _ref.theme;
6280
+ return {
6281
+ fontSize: theme.__hd__.typography.fontSizes.caption,
6282
+ lineHeight: theme.__hd__.typography.lineHeights.caption,
6283
+ letterSpacing: theme.__hd__.typography.fontSizes.caption * (themeFontWeight === 'regular' ? 0.04 : 0.02),
6284
+ color: theme.__hd__.typography.colors[themeIntent],
6285
+ fontFamily: theme.__hd__.typography.fonts.neutral[FONTWEIGHT_MAP[themeFontWeight]]
6286
+ };
6287
+ });
6288
+
6289
+ var _excluded$u = ["children", "fontWeight", "intent", "allowFontScaling"];
6290
+ var Caption = function Caption(_ref) {
6291
+ var children = _ref.children,
6292
+ _ref$fontWeight = _ref.fontWeight,
6293
+ fontWeight = _ref$fontWeight === void 0 ? 'regular' : _ref$fontWeight,
6294
+ _ref$intent = _ref.intent,
6295
+ intent = _ref$intent === void 0 ? 'body' : _ref$intent,
6296
+ _ref$allowFontScaling = _ref.allowFontScaling,
6297
+ allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
6298
+ nativeProps = _objectWithoutProperties(_ref, _excluded$u);
6299
+ return /*#__PURE__*/React__default["default"].createElement(StyledCaption, _extends$1({}, nativeProps, {
6300
+ themeFontWeight: fontWeight,
6301
+ themeIntent: intent,
6302
+ allowFontScaling: allowFontScaling
6303
+ }), children);
6304
+ };
6305
+
6268
6306
  var Typography = {
6269
- Text: Text
6307
+ Text: Text,
6308
+ Caption: Caption
6270
6309
  };
6271
6310
 
6272
6311
  // 🔴 DO NOT EDIT — This file is generated automatically.
@@ -11588,12 +11627,18 @@ var Carousel = function Carousel(_ref) {
11588
11627
  clearTimeout(handle);
11589
11628
  };
11590
11629
  }, [currentSlideIndex, carouselRef]);
11591
- var visibleSlideChanged = React.useCallback(function (_ref2) {
11592
- var viewableItems = _ref2.viewableItems;
11593
- if (!viewableItems || viewableItems && !viewableItems.length) return;
11594
- var index = viewableItems[0].index;
11630
+ var handleMomentumScrollEnd = function handleMomentumScrollEnd(event) {
11631
+ // Calculate the current index based on the scroll position and container width
11632
+ var containerWidth = event.nativeEvent.layoutMeasurement.width;
11633
+ var scrollPosition = event.nativeEvent.contentOffset.x;
11634
+ /**
11635
+ * By rounding down, we ensure that any partial visibility of the next item does not affect the index value
11636
+ * This helps maintain consistent behavior and aligns with the desired functionality of considering the left-most visible item as the current item.
11637
+ */
11638
+ var index = Math.floor(scrollPosition / containerWidth);
11639
+ // Call the callback function with the current index
11595
11640
  internalOnItemIndexChange(index);
11596
- }, []);
11641
+ };
11597
11642
  var viewConfig = React.useRef({
11598
11643
  viewAreaCoveragePercentThreshold: 50
11599
11644
  }).current;
@@ -11610,7 +11655,7 @@ var Carousel = function Carousel(_ref) {
11610
11655
  pagingEnabled: true,
11611
11656
  bounces: false,
11612
11657
  data: items,
11613
- onViewableItemsChanged: visibleSlideChanged,
11658
+ onMomentumScrollEnd: handleMomentumScrollEnd,
11614
11659
  viewabilityConfig: viewConfig,
11615
11660
  scrollEventThrottle: 32,
11616
11661
  ref: carouselRef,
@@ -11623,8 +11668,8 @@ var Carousel = function Carousel(_ref) {
11623
11668
  }], {
11624
11669
  useNativeDriver: false
11625
11670
  }),
11626
- renderItem: function renderItem(_ref3) {
11627
- var item = _ref3.item;
11671
+ renderItem: function renderItem(_ref2) {
11672
+ var item = _ref2.item;
11628
11673
  if (!item) return null;
11629
11674
  var image = item.image,
11630
11675
  heading = item.heading,
@@ -13004,9 +13049,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13004
13049
  iconProps = _objectWithoutProperties(_ref, _excluded$c);
13005
13050
  var rotateAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
13006
13051
  React.useEffect(function () {
13007
- var animation = reactNative.Animated.spring(rotateAnimation.current, {
13052
+ var animation = reactNative.Animated.timing(rotateAnimation.current, {
13008
13053
  toValue: active ? 1 : 0,
13009
- useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android'
13054
+ useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
13055
+ easing: reactNative.Easing.inOut(reactNative.Easing.ease),
13056
+ duration: 300
13010
13057
  });
13011
13058
  animation.start();
13012
13059
  return function () {
@@ -13028,11 +13075,6 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13028
13075
  }, iconProps)));
13029
13076
  };
13030
13077
 
13031
- if (reactNative.Platform.OS === 'android') {
13032
- if (reactNative.UIManager.setLayoutAnimationEnabledExperimental) {
13033
- reactNative.UIManager.setLayoutAnimationEnabledExperimental(true);
13034
- }
13035
- }
13036
13078
  var IconOnlyContent = function IconOnlyContent(_ref) {
13037
13079
  var icon = _ref.icon,
13038
13080
  animated = _ref.animated,
@@ -13058,19 +13100,7 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
13058
13100
  testID: "styled-fab-icon"
13059
13101
  })), /*#__PURE__*/React__default["default"].createElement(StyledFABText, null, title));
13060
13102
  };
13061
- var defaultAnimation = {
13062
- create: {
13063
- type: 'easeInEaseOut',
13064
- property: 'opacity'
13065
- },
13066
- update: {
13067
- type: 'spring',
13068
- springDamping: 1
13069
- },
13070
- duration: 400
13071
- };
13072
- var FAB = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
13073
- var _StyleSheet$flatten, _StyleSheet$flatten2;
13103
+ var FAB = function FAB(_ref3) {
13074
13104
  var onPress = _ref3.onPress,
13075
13105
  title = _ref3.title,
13076
13106
  icon = _ref3.icon,
@@ -13078,75 +13108,22 @@ var FAB = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
13078
13108
  testID = _ref3.testID,
13079
13109
  active = _ref3.active,
13080
13110
  style = _ref3.style;
13111
+ var isIconOnly = !title;
13081
13112
  var theme = useTheme();
13082
- var _React$useState = React__default["default"].useState({
13083
- hideTitle: false,
13084
- hideButton: false
13085
- }),
13086
- _React$useState2 = _slicedToArray(_React$useState, 2),
13087
- displayState = _React$useState2[0],
13088
- setDisplayState = _React$useState2[1];
13089
- var _React$useState3 = React__default["default"].useState(false),
13090
- _React$useState4 = _slicedToArray(_React$useState3, 2),
13091
- canAnimate = _React$useState4[0],
13092
- setCanAnimate = _React$useState4[1];
13093
- var isIconOnly = displayState.hideTitle || active || !title;
13094
- React.useImperativeHandle(ref, function () {
13095
- return {
13096
- show: function show() {
13097
- setDisplayState({
13098
- hideButton: false,
13099
- hideTitle: false
13100
- });
13101
- },
13102
- collapse: function collapse() {
13103
- setDisplayState({
13104
- hideButton: false,
13105
- hideTitle: true
13106
- });
13107
- },
13108
- hide: function hide() {
13109
- setDisplayState(function (previousState) {
13110
- return _objectSpread2(_objectSpread2({}, previousState), {}, {
13111
- hideButton: true
13112
- });
13113
- });
13114
- }
13115
- };
13116
- }, [displayState]);
13117
- React.useEffect(function () {
13118
- if (canAnimate) {
13119
- reactNative.LayoutAnimation.configureNext(defaultAnimation);
13120
- }
13121
- }, [isIconOnly]);
13122
- React.useEffect(function () {
13123
- if (canAnimate) {
13124
- reactNative.LayoutAnimation.configureNext(defaultAnimation);
13125
- }
13126
- }, [displayState.hideButton]);
13127
- var marginBottom = Number((_StyleSheet$flatten = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
13128
- return /*#__PURE__*/React__default["default"].createElement(StyledFAB$1
13129
- /** Add a small timeout before executing animation to prevent flakiness on android */, {
13130
- onLayout: function onLayout() {
13131
- return setTimeout(function () {
13132
- return setCanAnimate(true);
13133
- }, 200);
13134
- },
13113
+ return /*#__PURE__*/React__default["default"].createElement(StyledFAB$1, {
13135
13114
  underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
13136
13115
  onPress: onPress,
13137
- style: [style, {
13138
- bottom: displayState.hideButton ? -(marginBottom + theme.__hd__.fab.sizes.height * 2) : (_StyleSheet$flatten2 = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.bottom
13139
- }],
13116
+ style: style,
13140
13117
  testID: testID
13141
13118
  }, isIconOnly ? /*#__PURE__*/React__default["default"].createElement(IconOnlyContent, {
13142
13119
  animated: animated,
13143
13120
  active: active,
13144
- icon: active ? 'add' : icon
13121
+ icon: icon
13145
13122
  }) : /*#__PURE__*/React__default["default"].createElement(IconWithTextContent, {
13146
13123
  icon: icon,
13147
13124
  title: title
13148
13125
  }));
13149
- });
13126
+ };
13150
13127
 
13151
13128
  var StyledActionItem = index$a(reactNative.TouchableHighlight)(function (_ref) {
13152
13129
  var theme = _ref.theme;
@@ -13243,55 +13220,40 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
13243
13220
  };
13244
13221
  });
13245
13222
 
13246
- var ActionGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13247
- var headerTitle = _ref.headerTitle,
13248
- onPress = _ref.onPress,
13249
- active = _ref.active,
13250
- style = _ref.style,
13251
- items = _ref.items,
13252
- testID = _ref.testID,
13253
- fabTitle = _ref.fabTitle,
13254
- _ref$fabIcon = _ref.fabIcon,
13255
- fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
13256
- var fabRef = React.useRef(null);
13223
+ var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
13224
+ var style = _ref.style,
13225
+ items = _ref.items;
13226
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13227
+ style: style
13228
+ }, items === null || items === void 0 ? void 0 : items.map(function (itemProp) {
13229
+ return /*#__PURE__*/React__default["default"].createElement(ActionItem, _extends$1({
13230
+ key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13231
+ }, itemProp));
13232
+ }));
13233
+ };
13234
+ var ActionGroup = function ActionGroup(_ref2) {
13235
+ var headerTitle = _ref2.headerTitle,
13236
+ onPress = _ref2.onPress,
13237
+ active = _ref2.active,
13238
+ style = _ref2.style,
13239
+ items = _ref2.items,
13240
+ testID = _ref2.testID,
13241
+ fabTitle = _ref2.fabTitle,
13242
+ _ref2$fabIcon = _ref2.fabIcon,
13243
+ fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
13257
13244
  var tranlateXAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
13258
- var animatedValues = React.useRef((items === null || items === void 0 ? void 0 : items.map(function () {
13259
- return new reactNative.Animated.Value(0);
13260
- })) || []).current;
13261
- var translateYAnimations = animatedValues === null || animatedValues === void 0 ? void 0 : animatedValues.map(function (value) {
13262
- return value.interpolate({
13263
- inputRange: [0, 1],
13264
- outputRange: active ? [100, 0] : [40, 0]
13265
- });
13266
- });
13267
- React.useImperativeHandle(ref, function () {
13268
- return {
13269
- showFAB: function showFAB() {
13270
- var _fabRef$current;
13271
- return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
13272
- },
13273
- collapseFAB: function collapseFAB() {
13274
- var _fabRef$current2;
13275
- return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
13276
- },
13277
- hideFAB: function hideFAB() {
13278
- var _fabRef$current3;
13279
- return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
13280
- }
13281
- };
13282
- }, [fabRef]);
13283
13245
  React.useEffect(function () {
13284
- reactNative.Animated.spring(tranlateXAnimation.current, {
13246
+ var animation = reactNative.Animated.timing(tranlateXAnimation.current, {
13285
13247
  toValue: active ? 1 : 0,
13286
- useNativeDriver: reactNative.Platform.OS !== 'web'
13287
- }).start();
13288
- reactNative.Animated.stagger(20, animatedValues.map(function (value) {
13289
- return reactNative.Animated.spring(value, {
13290
- toValue: active ? 1 : 0,
13291
- useNativeDriver: reactNative.Platform.OS !== 'web'
13292
- });
13293
- }).reverse()).start();
13294
- }, [active, animatedValues]);
13248
+ useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
13249
+ easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
13250
+ });
13251
+ animation.start();
13252
+ }, [active]);
13253
+ var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
13254
+ inputRange: [0, 1],
13255
+ outputRange: [400, 0]
13256
+ });
13295
13257
  var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
13296
13258
  inputRange: [0, 1],
13297
13259
  outputRange: [0, 0.4]
@@ -13314,39 +13276,24 @@ var ActionGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13314
13276
  pointerEvents: active ? 'auto' : 'none',
13315
13277
  testID: "action-group",
13316
13278
  style: {
13317
- opacity: interpolatedActionGroupOpacityAnimation
13318
- }
13319
- }, !!headerTitle && /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13320
- style: {
13279
+ opacity: interpolatedActionGroupOpacityAnimation,
13321
13280
  transform: [{
13322
- translateY: translateYAnimations[0]
13281
+ translateX: interpolatedTranlateXAnimation
13323
13282
  }]
13324
13283
  }
13325
- }, /*#__PURE__*/React__default["default"].createElement(StyledHeaderText, {
13284
+ }, !!headerTitle && /*#__PURE__*/React__default["default"].createElement(StyledHeaderText, {
13326
13285
  testID: "header-text"
13327
- }, headerTitle)), /*#__PURE__*/React__default["default"].createElement(Box, {
13328
- style: [style, {
13329
- paddingBottom: 0
13330
- }]
13331
- }, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
13332
- return /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13333
- key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title),
13334
- style: {
13335
- transform: [{
13336
- translateY: translateYAnimations[index]
13337
- }]
13338
- }
13339
- }, /*#__PURE__*/React__default["default"].createElement(ActionItem, itemProp));
13340
- }))), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
13286
+ }, headerTitle), /*#__PURE__*/React__default["default"].createElement(ActionItemsListComponent, {
13287
+ items: items
13288
+ })), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
13341
13289
  testID: "fab",
13342
13290
  icon: fabIcon,
13343
13291
  onPress: onPress,
13344
13292
  animated: true,
13345
13293
  active: active,
13346
- title: fabTitle,
13347
- ref: fabRef
13294
+ title: fabTitle
13348
13295
  }));
13349
- });
13296
+ };
13350
13297
 
13351
13298
  var index$6 = Object.assign(FAB, {
13352
13299
  ActionGroup: ActionGroup
@@ -15029,7 +14976,7 @@ var getGradientColors = function getGradientColors(theme, intent) {
15029
14976
  }
15030
14977
  };
15031
14978
  var Skeleton = function Skeleton(_ref) {
15032
- var _StyleSheet$flatten, _StyleSheet$flatten2;
14979
+ var _StyleSheet$flatten;
15033
14980
  var _ref$intent = _ref.intent,
15034
14981
  intent = _ref$intent === void 0 ? 'light' : _ref$intent,
15035
14982
  _ref$variant = _ref.variant,
@@ -15045,14 +14992,10 @@ var Skeleton = function Skeleton(_ref) {
15045
14992
  _useState2 = _slicedToArray(_useState, 2),
15046
14993
  containerWidth = _useState2[0],
15047
14994
  setContainerWidth = _useState2[1];
15048
- var _useState3 = React.useState(Number((_StyleSheet$flatten2 = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.height) || 0),
14995
+ var _useState3 = React.useState(false),
15049
14996
  _useState4 = _slicedToArray(_useState3, 2),
15050
- containerHeight = _useState4[0],
15051
- setContainerHeight = _useState4[1];
15052
- var _useState5 = React.useState(false),
15053
- _useState6 = _slicedToArray(_useState5, 2),
15054
- shouldStartAnimation = _useState6[0],
15055
- setShouldStartAnimation = _useState6[1];
14997
+ shouldStartAnimation = _useState4[0],
14998
+ setShouldStartAnimation = _useState4[1];
15056
14999
  var animatedValue = React.useRef(new reactNative.Animated.Value(0)).current;
15057
15000
  React.useEffect(function () {
15058
15001
  if (shouldStartAnimation) {
@@ -15069,10 +15012,7 @@ var Skeleton = function Skeleton(_ref) {
15069
15012
  outputRange: [-containerWidth, containerWidth]
15070
15013
  });
15071
15014
  var onContainerLayout = React.useCallback(function (e) {
15072
- var _e$nativeEvent$layout = e.nativeEvent.layout,
15073
- width = _e$nativeEvent$layout.width,
15074
- height = _e$nativeEvent$layout.height;
15075
- setContainerHeight(height);
15015
+ var width = e.nativeEvent.layout.width;
15076
15016
  setContainerWidth(width);
15077
15017
  if (!shouldStartAnimation) {
15078
15018
  setShouldStartAnimation(true);
@@ -15090,8 +15030,8 @@ var Skeleton = function Skeleton(_ref) {
15090
15030
  start: gradientPositions.start,
15091
15031
  end: gradientPositions.end,
15092
15032
  style: {
15093
- width: containerWidth,
15094
- height: containerHeight,
15033
+ width: '100%',
15034
+ height: '100%',
15095
15035
  transform: [{
15096
15036
  translateX: translateX
15097
15037
  }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.30.3",
3
+ "version": "8.31.0",
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.30.3",
24
+ "@hero-design/colors": "8.31.0",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21"
@@ -45,7 +45,7 @@
45
45
  "@babel/preset-typescript": "^7.17.12",
46
46
  "@babel/runtime": "^7.18.9",
47
47
  "@emotion/jest": "^11.9.3",
48
- "@hero-design/eslint-plugin": "8.30.3",
48
+ "@hero-design/eslint-plugin": "8.31.0",
49
49
  "@react-native-community/datetimepicker": "^3.5.2",
50
50
  "@react-native-community/slider": "4.1.12",
51
51
  "@rollup/plugin-babel": "^5.3.1",
@@ -61,10 +61,10 @@
61
61
  "@types/react-native": "^0.67.7",
62
62
  "@types/react-native-vector-icons": "^6.4.10",
63
63
  "babel-plugin-inline-import": "^3.0.0",
64
- "eslint-config-hd": "8.30.3",
64
+ "eslint-config-hd": "8.31.0",
65
65
  "eslint-plugin-import": "^2.27.5",
66
66
  "jest": "^27.3.1",
67
- "prettier-config-hd": "8.30.3",
67
+ "prettier-config-hd": "8.31.0",
68
68
  "react": "18.0.0",
69
69
  "react-native": "0.69.7",
70
70
  "react-native-gesture-handler": "~2.1.0",
@@ -99,7 +99,6 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
99
99
  onScroll={[Function]}
100
100
  onScrollBeginDrag={[Function]}
101
101
  onScrollEndDrag={[Function]}
102
- onViewableItemsChanged={[Function]}
103
102
  pagingEnabled={true}
104
103
  removeClippedSubviews={false}
105
104
  renderItem={[Function]}
@@ -111,16 +110,7 @@ exports[`Carousel renders correctly with pageControlPosition bottom 1`] = `
111
110
  "viewAreaCoveragePercentThreshold": 50,
112
111
  }
113
112
  }
114
- viewabilityConfigCallbackPairs={
115
- Array [
116
- Object {
117
- "onViewableItemsChanged": [Function],
118
- "viewabilityConfig": Object {
119
- "viewAreaCoveragePercentThreshold": 50,
120
- },
121
- },
122
- ]
123
- }
113
+ viewabilityConfigCallbackPairs={Array []}
124
114
  >
125
115
  <View>
126
116
  <View
@@ -933,7 +923,6 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
933
923
  onScroll={[Function]}
934
924
  onScrollBeginDrag={[Function]}
935
925
  onScrollEndDrag={[Function]}
936
- onViewableItemsChanged={[Function]}
937
926
  pagingEnabled={true}
938
927
  removeClippedSubviews={false}
939
928
  renderItem={[Function]}
@@ -945,16 +934,7 @@ exports[`Carousel renders correctly with pageControlPosition top 1`] = `
945
934
  "viewAreaCoveragePercentThreshold": 50,
946
935
  }
947
936
  }
948
- viewabilityConfigCallbackPairs={
949
- Array [
950
- Object {
951
- "onViewableItemsChanged": [Function],
952
- "viewabilityConfig": Object {
953
- "viewAreaCoveragePercentThreshold": 50,
954
- },
955
- },
956
- ]
957
- }
937
+ viewabilityConfigCallbackPairs={Array []}
958
938
  >
959
939
  <View>
960
940
  <View
@@ -1620,7 +1600,6 @@ exports[`Carousel should call skip call back when press skip 1`] = `
1620
1600
  onScroll={[Function]}
1621
1601
  onScrollBeginDrag={[Function]}
1622
1602
  onScrollEndDrag={[Function]}
1623
- onViewableItemsChanged={[Function]}
1624
1603
  pagingEnabled={true}
1625
1604
  removeClippedSubviews={false}
1626
1605
  renderItem={[Function]}
@@ -1632,16 +1611,7 @@ exports[`Carousel should call skip call back when press skip 1`] = `
1632
1611
  "viewAreaCoveragePercentThreshold": 50,
1633
1612
  }
1634
1613
  }
1635
- viewabilityConfigCallbackPairs={
1636
- Array [
1637
- Object {
1638
- "onViewableItemsChanged": [Function],
1639
- "viewabilityConfig": Object {
1640
- "viewAreaCoveragePercentThreshold": 50,
1641
- },
1642
- },
1643
- ]
1644
- }
1614
+ viewabilityConfigCallbackPairs={Array []}
1645
1615
  >
1646
1616
  <View>
1647
1617
  <View
@@ -9,6 +9,8 @@ import React, {
9
9
  import {
10
10
  Animated,
11
11
  FlatList,
12
+ NativeScrollEvent,
13
+ NativeSyntheticEvent,
12
14
  StyleProp,
13
15
  useWindowDimensions,
14
16
  View,
@@ -127,11 +129,22 @@ const Carousel = ({
127
129
  };
128
130
  }, [currentSlideIndex, carouselRef]);
129
131
 
130
- const visibleSlideChanged = useCallback(({ viewableItems }) => {
131
- if (!viewableItems || (viewableItems && !viewableItems.length)) return;
132
- const { index } = viewableItems[0];
132
+ const handleMomentumScrollEnd = (
133
+ event: NativeSyntheticEvent<NativeScrollEvent>
134
+ ) => {
135
+ // Calculate the current index based on the scroll position and container width
136
+ const containerWidth = event.nativeEvent.layoutMeasurement.width;
137
+ const scrollPosition = event.nativeEvent.contentOffset.x;
138
+
139
+ /**
140
+ * By rounding down, we ensure that any partial visibility of the next item does not affect the index value
141
+ * This helps maintain consistent behavior and aligns with the desired functionality of considering the left-most visible item as the current item.
142
+ */
143
+ const index = Math.floor(scrollPosition / containerWidth);
144
+
145
+ // Call the callback function with the current index
133
146
  internalOnItemIndexChange(index);
134
- }, []);
147
+ };
135
148
 
136
149
  const viewConfig = useRef({ viewAreaCoveragePercentThreshold: 50 }).current;
137
150
 
@@ -158,7 +171,7 @@ const Carousel = ({
158
171
  pagingEnabled
159
172
  bounces={false}
160
173
  data={items}
161
- onViewableItemsChanged={visibleSlideChanged}
174
+ onMomentumScrollEnd={handleMomentumScrollEnd}
162
175
  viewabilityConfig={viewConfig}
163
176
  scrollEventThrottle={32}
164
177
  ref={carouselRef}