@hero-design/rn 8.30.3 → 8.30.4

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.
@@ -4,5 +4,5 @@ $ rollup -c
4
4
  src/index.ts → lib/index.js, es/index.js...
5
5
  (!) 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`.
6
6
  (!) 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
7
- created lib/index.js, es/index.js in 23.8s
7
+ created lib/index.js, es/index.js in 27.5s
8
8
  $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -11558,12 +11558,18 @@ var Carousel = function Carousel(_ref) {
11558
11558
  clearTimeout(handle);
11559
11559
  };
11560
11560
  }, [currentSlideIndex, carouselRef]);
11561
- var visibleSlideChanged = useCallback(function (_ref2) {
11562
- var viewableItems = _ref2.viewableItems;
11563
- if (!viewableItems || viewableItems && !viewableItems.length) return;
11564
- var index = viewableItems[0].index;
11561
+ var handleMomentumScrollEnd = function handleMomentumScrollEnd(event) {
11562
+ // Calculate the current index based on the scroll position and container width
11563
+ var containerWidth = event.nativeEvent.layoutMeasurement.width;
11564
+ var scrollPosition = event.nativeEvent.contentOffset.x;
11565
+ /**
11566
+ * By rounding down, we ensure that any partial visibility of the next item does not affect the index value
11567
+ * This helps maintain consistent behavior and aligns with the desired functionality of considering the left-most visible item as the current item.
11568
+ */
11569
+ var index = Math.floor(scrollPosition / containerWidth);
11570
+ // Call the callback function with the current index
11565
11571
  internalOnItemIndexChange(index);
11566
- }, []);
11572
+ };
11567
11573
  var viewConfig = useRef({
11568
11574
  viewAreaCoveragePercentThreshold: 50
11569
11575
  }).current;
@@ -11580,7 +11586,7 @@ var Carousel = function Carousel(_ref) {
11580
11586
  pagingEnabled: true,
11581
11587
  bounces: false,
11582
11588
  data: items,
11583
- onViewableItemsChanged: visibleSlideChanged,
11589
+ onMomentumScrollEnd: handleMomentumScrollEnd,
11584
11590
  viewabilityConfig: viewConfig,
11585
11591
  scrollEventThrottle: 32,
11586
11592
  ref: carouselRef,
@@ -11593,8 +11599,8 @@ var Carousel = function Carousel(_ref) {
11593
11599
  }], {
11594
11600
  useNativeDriver: false
11595
11601
  }),
11596
- renderItem: function renderItem(_ref3) {
11597
- var item = _ref3.item;
11602
+ renderItem: function renderItem(_ref2) {
11603
+ var item = _ref2.item;
11598
11604
  if (!item) return null;
11599
11605
  var image = item.image,
11600
11606
  heading = item.heading,
@@ -12974,9 +12980,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
12974
12980
  iconProps = _objectWithoutProperties(_ref, _excluded$c);
12975
12981
  var rotateAnimation = useRef(new Animated.Value(active ? 1 : 0));
12976
12982
  useEffect(function () {
12977
- var animation = Animated.spring(rotateAnimation.current, {
12983
+ var animation = Animated.timing(rotateAnimation.current, {
12978
12984
  toValue: active ? 1 : 0,
12979
- useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android'
12985
+ useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
12986
+ easing: Easing.inOut(Easing.ease),
12987
+ duration: 300
12980
12988
  });
12981
12989
  animation.start();
12982
12990
  return function () {
@@ -12998,11 +13006,6 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
12998
13006
  }, iconProps)));
12999
13007
  };
13000
13008
 
13001
- if (Platform.OS === 'android') {
13002
- if (UIManager.setLayoutAnimationEnabledExperimental) {
13003
- UIManager.setLayoutAnimationEnabledExperimental(true);
13004
- }
13005
- }
13006
13009
  var IconOnlyContent = function IconOnlyContent(_ref) {
13007
13010
  var icon = _ref.icon,
13008
13011
  animated = _ref.animated,
@@ -13028,19 +13031,7 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
13028
13031
  testID: "styled-fab-icon"
13029
13032
  })), /*#__PURE__*/React.createElement(StyledFABText, null, title));
13030
13033
  };
13031
- var defaultAnimation = {
13032
- create: {
13033
- type: 'easeInEaseOut',
13034
- property: 'opacity'
13035
- },
13036
- update: {
13037
- type: 'spring',
13038
- springDamping: 1
13039
- },
13040
- duration: 400
13041
- };
13042
- var FAB = /*#__PURE__*/forwardRef(function (_ref3, ref) {
13043
- var _StyleSheet$flatten, _StyleSheet$flatten2;
13034
+ var FAB = function FAB(_ref3) {
13044
13035
  var onPress = _ref3.onPress,
13045
13036
  title = _ref3.title,
13046
13037
  icon = _ref3.icon,
@@ -13048,75 +13039,22 @@ var FAB = /*#__PURE__*/forwardRef(function (_ref3, ref) {
13048
13039
  testID = _ref3.testID,
13049
13040
  active = _ref3.active,
13050
13041
  style = _ref3.style;
13042
+ var isIconOnly = !title;
13051
13043
  var theme = useTheme();
13052
- var _React$useState = React.useState({
13053
- hideTitle: false,
13054
- hideButton: false
13055
- }),
13056
- _React$useState2 = _slicedToArray(_React$useState, 2),
13057
- displayState = _React$useState2[0],
13058
- setDisplayState = _React$useState2[1];
13059
- var _React$useState3 = React.useState(false),
13060
- _React$useState4 = _slicedToArray(_React$useState3, 2),
13061
- canAnimate = _React$useState4[0],
13062
- setCanAnimate = _React$useState4[1];
13063
- var isIconOnly = displayState.hideTitle || active || !title;
13064
- useImperativeHandle(ref, function () {
13065
- return {
13066
- show: function show() {
13067
- setDisplayState({
13068
- hideButton: false,
13069
- hideTitle: false
13070
- });
13071
- },
13072
- collapse: function collapse() {
13073
- setDisplayState({
13074
- hideButton: false,
13075
- hideTitle: true
13076
- });
13077
- },
13078
- hide: function hide() {
13079
- setDisplayState(function (previousState) {
13080
- return _objectSpread2(_objectSpread2({}, previousState), {}, {
13081
- hideButton: true
13082
- });
13083
- });
13084
- }
13085
- };
13086
- }, [displayState]);
13087
- useEffect(function () {
13088
- if (canAnimate) {
13089
- LayoutAnimation.configureNext(defaultAnimation);
13090
- }
13091
- }, [isIconOnly]);
13092
- useEffect(function () {
13093
- if (canAnimate) {
13094
- LayoutAnimation.configureNext(defaultAnimation);
13095
- }
13096
- }, [displayState.hideButton]);
13097
- var marginBottom = Number((_StyleSheet$flatten = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
13098
- return /*#__PURE__*/React.createElement(StyledFAB$1
13099
- /** Add a small timeout before executing animation to prevent flakiness on android */, {
13100
- onLayout: function onLayout() {
13101
- return setTimeout(function () {
13102
- return setCanAnimate(true);
13103
- }, 200);
13104
- },
13044
+ return /*#__PURE__*/React.createElement(StyledFAB$1, {
13105
13045
  underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
13106
13046
  onPress: onPress,
13107
- style: [style, {
13108
- bottom: displayState.hideButton ? -(marginBottom + theme.__hd__.fab.sizes.height * 2) : (_StyleSheet$flatten2 = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.bottom
13109
- }],
13047
+ style: style,
13110
13048
  testID: testID
13111
13049
  }, isIconOnly ? /*#__PURE__*/React.createElement(IconOnlyContent, {
13112
13050
  animated: animated,
13113
13051
  active: active,
13114
- icon: active ? 'add' : icon
13052
+ icon: icon
13115
13053
  }) : /*#__PURE__*/React.createElement(IconWithTextContent, {
13116
13054
  icon: icon,
13117
13055
  title: title
13118
13056
  }));
13119
- });
13057
+ };
13120
13058
 
13121
13059
  var StyledActionItem = index$a(TouchableHighlight)(function (_ref) {
13122
13060
  var theme = _ref.theme;
@@ -13213,55 +13151,40 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
13213
13151
  };
13214
13152
  });
13215
13153
 
13216
- var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
13217
- var headerTitle = _ref.headerTitle,
13218
- onPress = _ref.onPress,
13219
- active = _ref.active,
13220
- style = _ref.style,
13221
- items = _ref.items,
13222
- testID = _ref.testID,
13223
- fabTitle = _ref.fabTitle,
13224
- _ref$fabIcon = _ref.fabIcon,
13225
- fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
13226
- var fabRef = useRef(null);
13154
+ var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
13155
+ var style = _ref.style,
13156
+ items = _ref.items;
13157
+ return /*#__PURE__*/React.createElement(View, {
13158
+ style: style
13159
+ }, items === null || items === void 0 ? void 0 : items.map(function (itemProp) {
13160
+ return /*#__PURE__*/React.createElement(ActionItem, _extends$1({
13161
+ key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13162
+ }, itemProp));
13163
+ }));
13164
+ };
13165
+ var ActionGroup = function ActionGroup(_ref2) {
13166
+ var headerTitle = _ref2.headerTitle,
13167
+ onPress = _ref2.onPress,
13168
+ active = _ref2.active,
13169
+ style = _ref2.style,
13170
+ items = _ref2.items,
13171
+ testID = _ref2.testID,
13172
+ fabTitle = _ref2.fabTitle,
13173
+ _ref2$fabIcon = _ref2.fabIcon,
13174
+ fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
13227
13175
  var tranlateXAnimation = useRef(new Animated.Value(active ? 1 : 0));
13228
- var animatedValues = useRef((items === null || items === void 0 ? void 0 : items.map(function () {
13229
- return new Animated.Value(0);
13230
- })) || []).current;
13231
- var translateYAnimations = animatedValues === null || animatedValues === void 0 ? void 0 : animatedValues.map(function (value) {
13232
- return value.interpolate({
13233
- inputRange: [0, 1],
13234
- outputRange: active ? [100, 0] : [40, 0]
13235
- });
13236
- });
13237
- useImperativeHandle(ref, function () {
13238
- return {
13239
- showFAB: function showFAB() {
13240
- var _fabRef$current;
13241
- return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
13242
- },
13243
- collapseFAB: function collapseFAB() {
13244
- var _fabRef$current2;
13245
- return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
13246
- },
13247
- hideFAB: function hideFAB() {
13248
- var _fabRef$current3;
13249
- return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
13250
- }
13251
- };
13252
- }, [fabRef]);
13253
13176
  useEffect(function () {
13254
- Animated.spring(tranlateXAnimation.current, {
13177
+ var animation = Animated.timing(tranlateXAnimation.current, {
13255
13178
  toValue: active ? 1 : 0,
13256
- useNativeDriver: Platform.OS !== 'web'
13257
- }).start();
13258
- Animated.stagger(20, animatedValues.map(function (value) {
13259
- return Animated.spring(value, {
13260
- toValue: active ? 1 : 0,
13261
- useNativeDriver: Platform.OS !== 'web'
13262
- });
13263
- }).reverse()).start();
13264
- }, [active, animatedValues]);
13179
+ useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
13180
+ easing: Easing.inOut(Easing.cubic)
13181
+ });
13182
+ animation.start();
13183
+ }, [active]);
13184
+ var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
13185
+ inputRange: [0, 1],
13186
+ outputRange: [400, 0]
13187
+ });
13265
13188
  var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
13266
13189
  inputRange: [0, 1],
13267
13190
  outputRange: [0, 0.4]
@@ -13284,39 +13207,24 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
13284
13207
  pointerEvents: active ? 'auto' : 'none',
13285
13208
  testID: "action-group",
13286
13209
  style: {
13287
- opacity: interpolatedActionGroupOpacityAnimation
13288
- }
13289
- }, !!headerTitle && /*#__PURE__*/React.createElement(Animated.View, {
13290
- style: {
13210
+ opacity: interpolatedActionGroupOpacityAnimation,
13291
13211
  transform: [{
13292
- translateY: translateYAnimations[0]
13212
+ translateX: interpolatedTranlateXAnimation
13293
13213
  }]
13294
13214
  }
13295
- }, /*#__PURE__*/React.createElement(StyledHeaderText, {
13215
+ }, !!headerTitle && /*#__PURE__*/React.createElement(StyledHeaderText, {
13296
13216
  testID: "header-text"
13297
- }, headerTitle)), /*#__PURE__*/React.createElement(Box, {
13298
- style: [style, {
13299
- paddingBottom: 0
13300
- }]
13301
- }, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
13302
- return /*#__PURE__*/React.createElement(Animated.View, {
13303
- key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title),
13304
- style: {
13305
- transform: [{
13306
- translateY: translateYAnimations[index]
13307
- }]
13308
- }
13309
- }, /*#__PURE__*/React.createElement(ActionItem, itemProp));
13310
- }))), /*#__PURE__*/React.createElement(StyledFAB, {
13217
+ }, headerTitle), /*#__PURE__*/React.createElement(ActionItemsListComponent, {
13218
+ items: items
13219
+ })), /*#__PURE__*/React.createElement(StyledFAB, {
13311
13220
  testID: "fab",
13312
13221
  icon: fabIcon,
13313
13222
  onPress: onPress,
13314
13223
  animated: true,
13315
13224
  active: active,
13316
- title: fabTitle,
13317
- ref: fabRef
13225
+ title: fabTitle
13318
13226
  }));
13319
- });
13227
+ };
13320
13228
 
13321
13229
  var index$6 = Object.assign(FAB, {
13322
13230
  ActionGroup: ActionGroup
@@ -14999,7 +14907,7 @@ var getGradientColors = function getGradientColors(theme, intent) {
14999
14907
  }
15000
14908
  };
15001
14909
  var Skeleton = function Skeleton(_ref) {
15002
- var _StyleSheet$flatten, _StyleSheet$flatten2;
14910
+ var _StyleSheet$flatten;
15003
14911
  var _ref$intent = _ref.intent,
15004
14912
  intent = _ref$intent === void 0 ? 'light' : _ref$intent,
15005
14913
  _ref$variant = _ref.variant,
@@ -15015,14 +14923,10 @@ var Skeleton = function Skeleton(_ref) {
15015
14923
  _useState2 = _slicedToArray(_useState, 2),
15016
14924
  containerWidth = _useState2[0],
15017
14925
  setContainerWidth = _useState2[1];
15018
- var _useState3 = useState(Number((_StyleSheet$flatten2 = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.height) || 0),
14926
+ var _useState3 = useState(false),
15019
14927
  _useState4 = _slicedToArray(_useState3, 2),
15020
- containerHeight = _useState4[0],
15021
- setContainerHeight = _useState4[1];
15022
- var _useState5 = useState(false),
15023
- _useState6 = _slicedToArray(_useState5, 2),
15024
- shouldStartAnimation = _useState6[0],
15025
- setShouldStartAnimation = _useState6[1];
14928
+ shouldStartAnimation = _useState4[0],
14929
+ setShouldStartAnimation = _useState4[1];
15026
14930
  var animatedValue = useRef(new Animated.Value(0)).current;
15027
14931
  useEffect(function () {
15028
14932
  if (shouldStartAnimation) {
@@ -15039,10 +14943,7 @@ var Skeleton = function Skeleton(_ref) {
15039
14943
  outputRange: [-containerWidth, containerWidth]
15040
14944
  });
15041
14945
  var onContainerLayout = useCallback(function (e) {
15042
- var _e$nativeEvent$layout = e.nativeEvent.layout,
15043
- width = _e$nativeEvent$layout.width,
15044
- height = _e$nativeEvent$layout.height;
15045
- setContainerHeight(height);
14946
+ var width = e.nativeEvent.layout.width;
15046
14947
  setContainerWidth(width);
15047
14948
  if (!shouldStartAnimation) {
15048
14949
  setShouldStartAnimation(true);
@@ -15060,8 +14961,8 @@ var Skeleton = function Skeleton(_ref) {
15060
14961
  start: gradientPositions.start,
15061
14962
  end: gradientPositions.end,
15062
14963
  style: {
15063
- width: containerWidth,
15064
- height: containerHeight,
14964
+ width: '100%',
14965
+ height: '100%',
15065
14966
  transform: [{
15066
14967
  translateX: translateX
15067
14968
  }]