@hero-design/rn 8.30.4 → 9.1.0-rc.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.
@@ -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 27.5s
7
+ created lib/index.js, es/index.js in 27.9s
8
8
  $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -995,6 +995,7 @@ var palette$b = {
995
995
  dodgerBlue: ultramarineBlue$3.base,
996
996
  dodgerBlueDark15: ultramarineBlue$3.darken15,
997
997
  dodgerBlueDark30: ultramarineBlue$3.darken30,
998
+ dodgerBlueDark60: ultramarineBlue$3.darken60,
998
999
  dodgerBlueLight30: ultramarineBlue$3.lighten30,
999
1000
  dodgerBlueLight45: ultramarineBlue$3.lighten45,
1000
1001
  dodgerBlueLight60: ultramarineBlue$3.lighten60,
@@ -1003,6 +1004,7 @@ var palette$b = {
1003
1004
  green: green$1.base,
1004
1005
  greenDark15: green$1.darken15,
1005
1006
  greenDark30: green$1.darken30,
1007
+ greenDark60: green$1.darken60,
1006
1008
  greenDark75: green$1.darken75,
1007
1009
  greenLight30: green$1.lighten30,
1008
1010
  greenLight75: green$1.lighten75,
@@ -1013,6 +1015,7 @@ var palette$b = {
1013
1015
  greyDark45: grey$2.darken45,
1014
1016
  greyDark60: grey$2.darken60,
1015
1017
  greyDark75: grey$2.darken75,
1018
+ greyLight30: grey$2.lighten30,
1016
1019
  greyLight45: grey$2.lighten45,
1017
1020
  greyLight60: grey$2.lighten60,
1018
1021
  greyLight75: grey$2.lighten75,
@@ -1028,6 +1031,7 @@ var palette$b = {
1028
1031
  orange: deepSaffron$3.base,
1029
1032
  orangeDark15: deepSaffron$3.darken15,
1030
1033
  orangeDark30: deepSaffron$3.darken30,
1034
+ orangeDark60: deepSaffron$3.darken60,
1031
1035
  orangeDark75: deepSaffron$3.darken75,
1032
1036
  orangeLight30: deepSaffron$3.lighten30,
1033
1037
  orangeLight75: deepSaffron$3.lighten75,
@@ -1036,6 +1040,7 @@ var palette$b = {
1036
1040
  pinkDark15: pink$1.darken15,
1037
1041
  pinkDark30: pink$1.darken30,
1038
1042
  pinkDark45: pink$1.darken45,
1043
+ pinkDark60: pink$1.darken60,
1039
1044
  pinkDark75: pink$1.darken75,
1040
1045
  pinkLight30: pink$1.lighten30,
1041
1046
  pinkLight45: pink$1.lighten45,
@@ -1046,6 +1051,7 @@ var palette$b = {
1046
1051
  red: vermilion$3.base,
1047
1052
  redDark15: vermilion$3.darken15,
1048
1053
  redDark30: vermilion$3.darken30,
1054
+ redDark60: vermilion$3.darken60,
1049
1055
  redDark75: vermilion$3.darken75,
1050
1056
  redLight15: vermilion$3.lighten15,
1051
1057
  redLight30: vermilion$3.lighten30,
@@ -1070,6 +1076,7 @@ var palette$b = {
1070
1076
  violetLight90: violet$2.lighten90,
1071
1077
  yellow: yellow$1.base,
1072
1078
  yellowDark15: yellow$1.darken15,
1079
+ yellowDark45: yellow$1.darken45,
1073
1080
  yellowDark75: yellow$1.darken75,
1074
1081
  yellowLight45: yellow$1.lighten45,
1075
1082
  yellowLight60: yellow$1.lighten60,
@@ -11558,18 +11565,12 @@ var Carousel = function Carousel(_ref) {
11558
11565
  clearTimeout(handle);
11559
11566
  };
11560
11567
  }, [currentSlideIndex, carouselRef]);
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
11568
+ var visibleSlideChanged = useCallback(function (_ref2) {
11569
+ var viewableItems = _ref2.viewableItems;
11570
+ if (!viewableItems || viewableItems && !viewableItems.length) return;
11571
+ var index = viewableItems[0].index;
11571
11572
  internalOnItemIndexChange(index);
11572
- };
11573
+ }, []);
11573
11574
  var viewConfig = useRef({
11574
11575
  viewAreaCoveragePercentThreshold: 50
11575
11576
  }).current;
@@ -11586,7 +11587,7 @@ var Carousel = function Carousel(_ref) {
11586
11587
  pagingEnabled: true,
11587
11588
  bounces: false,
11588
11589
  data: items,
11589
- onMomentumScrollEnd: handleMomentumScrollEnd,
11590
+ onViewableItemsChanged: visibleSlideChanged,
11590
11591
  viewabilityConfig: viewConfig,
11591
11592
  scrollEventThrottle: 32,
11592
11593
  ref: carouselRef,
@@ -11599,8 +11600,8 @@ var Carousel = function Carousel(_ref) {
11599
11600
  }], {
11600
11601
  useNativeDriver: false
11601
11602
  }),
11602
- renderItem: function renderItem(_ref2) {
11603
- var item = _ref2.item;
11603
+ renderItem: function renderItem(_ref3) {
11604
+ var item = _ref3.item;
11604
11605
  if (!item) return null;
11605
11606
  var image = item.image,
11606
11607
  heading = item.heading,
@@ -12980,11 +12981,9 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
12980
12981
  iconProps = _objectWithoutProperties(_ref, _excluded$c);
12981
12982
  var rotateAnimation = useRef(new Animated.Value(active ? 1 : 0));
12982
12983
  useEffect(function () {
12983
- var animation = Animated.timing(rotateAnimation.current, {
12984
+ var animation = Animated.spring(rotateAnimation.current, {
12984
12985
  toValue: active ? 1 : 0,
12985
- useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
12986
- easing: Easing.inOut(Easing.ease),
12987
- duration: 300
12986
+ useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android'
12988
12987
  });
12989
12988
  animation.start();
12990
12989
  return function () {
@@ -13006,6 +13005,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13006
13005
  }, iconProps)));
13007
13006
  };
13008
13007
 
13008
+ if (Platform.OS === 'android') {
13009
+ if (UIManager.setLayoutAnimationEnabledExperimental) {
13010
+ UIManager.setLayoutAnimationEnabledExperimental(true);
13011
+ }
13012
+ }
13009
13013
  var IconOnlyContent = function IconOnlyContent(_ref) {
13010
13014
  var icon = _ref.icon,
13011
13015
  animated = _ref.animated,
@@ -13031,7 +13035,19 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
13031
13035
  testID: "styled-fab-icon"
13032
13036
  })), /*#__PURE__*/React.createElement(StyledFABText, null, title));
13033
13037
  };
13034
- var FAB = function FAB(_ref3) {
13038
+ var defaultAnimation = {
13039
+ create: {
13040
+ type: 'easeInEaseOut',
13041
+ property: 'opacity'
13042
+ },
13043
+ update: {
13044
+ type: 'spring',
13045
+ springDamping: 1
13046
+ },
13047
+ duration: 400
13048
+ };
13049
+ var FAB = /*#__PURE__*/forwardRef(function (_ref3, ref) {
13050
+ var _StyleSheet$flatten, _StyleSheet$flatten2;
13035
13051
  var onPress = _ref3.onPress,
13036
13052
  title = _ref3.title,
13037
13053
  icon = _ref3.icon,
@@ -13039,22 +13055,75 @@ var FAB = function FAB(_ref3) {
13039
13055
  testID = _ref3.testID,
13040
13056
  active = _ref3.active,
13041
13057
  style = _ref3.style;
13042
- var isIconOnly = !title;
13043
13058
  var theme = useTheme();
13044
- return /*#__PURE__*/React.createElement(StyledFAB$1, {
13059
+ var _React$useState = React.useState({
13060
+ hideTitle: false,
13061
+ hideButton: false
13062
+ }),
13063
+ _React$useState2 = _slicedToArray(_React$useState, 2),
13064
+ displayState = _React$useState2[0],
13065
+ setDisplayState = _React$useState2[1];
13066
+ var _React$useState3 = React.useState(false),
13067
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
13068
+ canAnimate = _React$useState4[0],
13069
+ setCanAnimate = _React$useState4[1];
13070
+ var isIconOnly = displayState.hideTitle || active || !title;
13071
+ useImperativeHandle(ref, function () {
13072
+ return {
13073
+ show: function show() {
13074
+ setDisplayState({
13075
+ hideButton: false,
13076
+ hideTitle: false
13077
+ });
13078
+ },
13079
+ collapse: function collapse() {
13080
+ setDisplayState({
13081
+ hideButton: false,
13082
+ hideTitle: true
13083
+ });
13084
+ },
13085
+ hide: function hide() {
13086
+ setDisplayState(function (previousState) {
13087
+ return _objectSpread2(_objectSpread2({}, previousState), {}, {
13088
+ hideButton: true
13089
+ });
13090
+ });
13091
+ }
13092
+ };
13093
+ }, [displayState]);
13094
+ useEffect(function () {
13095
+ if (canAnimate) {
13096
+ LayoutAnimation.configureNext(defaultAnimation);
13097
+ }
13098
+ }, [isIconOnly]);
13099
+ useEffect(function () {
13100
+ if (canAnimate) {
13101
+ LayoutAnimation.configureNext(defaultAnimation);
13102
+ }
13103
+ }, [displayState.hideButton]);
13104
+ var marginBottom = Number((_StyleSheet$flatten = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
13105
+ return /*#__PURE__*/React.createElement(StyledFAB$1
13106
+ /** Add a small timeout before executing animation to prevent flakiness on android */, {
13107
+ onLayout: function onLayout() {
13108
+ return setTimeout(function () {
13109
+ return setCanAnimate(true);
13110
+ }, 200);
13111
+ },
13045
13112
  underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
13046
13113
  onPress: onPress,
13047
- style: style,
13114
+ style: [style, {
13115
+ 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
13116
+ }],
13048
13117
  testID: testID
13049
13118
  }, isIconOnly ? /*#__PURE__*/React.createElement(IconOnlyContent, {
13050
13119
  animated: animated,
13051
13120
  active: active,
13052
- icon: icon
13121
+ icon: active ? 'add' : icon
13053
13122
  }) : /*#__PURE__*/React.createElement(IconWithTextContent, {
13054
13123
  icon: icon,
13055
13124
  title: title
13056
13125
  }));
13057
- };
13126
+ });
13058
13127
 
13059
13128
  var StyledActionItem = index$a(TouchableHighlight)(function (_ref) {
13060
13129
  var theme = _ref.theme;
@@ -13151,40 +13220,55 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
13151
13220
  };
13152
13221
  });
13153
13222
 
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;
13223
+ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
13224
+ var headerTitle = _ref.headerTitle,
13225
+ onPress = _ref.onPress,
13226
+ active = _ref.active,
13227
+ style = _ref.style,
13228
+ items = _ref.items,
13229
+ testID = _ref.testID,
13230
+ fabTitle = _ref.fabTitle,
13231
+ _ref$fabIcon = _ref.fabIcon,
13232
+ fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
13233
+ var fabRef = useRef(null);
13175
13234
  var tranlateXAnimation = useRef(new Animated.Value(active ? 1 : 0));
13176
- useEffect(function () {
13177
- var animation = Animated.timing(tranlateXAnimation.current, {
13178
- toValue: active ? 1 : 0,
13179
- useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
13180
- easing: Easing.inOut(Easing.cubic)
13235
+ var animatedValues = useRef((items === null || items === void 0 ? void 0 : items.map(function () {
13236
+ return new Animated.Value(0);
13237
+ })) || []).current;
13238
+ var translateYAnimations = animatedValues === null || animatedValues === void 0 ? void 0 : animatedValues.map(function (value) {
13239
+ return value.interpolate({
13240
+ inputRange: [0, 1],
13241
+ outputRange: active ? [100, 0] : [40, 0]
13181
13242
  });
13182
- animation.start();
13183
- }, [active]);
13184
- var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
13185
- inputRange: [0, 1],
13186
- outputRange: [400, 0]
13187
13243
  });
13244
+ useImperativeHandle(ref, function () {
13245
+ return {
13246
+ showFAB: function showFAB() {
13247
+ var _fabRef$current;
13248
+ return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
13249
+ },
13250
+ collapseFAB: function collapseFAB() {
13251
+ var _fabRef$current2;
13252
+ return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
13253
+ },
13254
+ hideFAB: function hideFAB() {
13255
+ var _fabRef$current3;
13256
+ return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
13257
+ }
13258
+ };
13259
+ }, [fabRef]);
13260
+ useEffect(function () {
13261
+ Animated.spring(tranlateXAnimation.current, {
13262
+ toValue: active ? 1 : 0,
13263
+ useNativeDriver: Platform.OS !== 'web'
13264
+ }).start();
13265
+ Animated.stagger(20, animatedValues.map(function (value) {
13266
+ return Animated.spring(value, {
13267
+ toValue: active ? 1 : 0,
13268
+ useNativeDriver: Platform.OS !== 'web'
13269
+ });
13270
+ }).reverse()).start();
13271
+ }, [active, animatedValues]);
13188
13272
  var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
13189
13273
  inputRange: [0, 1],
13190
13274
  outputRange: [0, 0.4]
@@ -13207,24 +13291,39 @@ var ActionGroup = function ActionGroup(_ref2) {
13207
13291
  pointerEvents: active ? 'auto' : 'none',
13208
13292
  testID: "action-group",
13209
13293
  style: {
13210
- opacity: interpolatedActionGroupOpacityAnimation,
13294
+ opacity: interpolatedActionGroupOpacityAnimation
13295
+ }
13296
+ }, !!headerTitle && /*#__PURE__*/React.createElement(Animated.View, {
13297
+ style: {
13211
13298
  transform: [{
13212
- translateX: interpolatedTranlateXAnimation
13299
+ translateY: translateYAnimations[0]
13213
13300
  }]
13214
13301
  }
13215
- }, !!headerTitle && /*#__PURE__*/React.createElement(StyledHeaderText, {
13302
+ }, /*#__PURE__*/React.createElement(StyledHeaderText, {
13216
13303
  testID: "header-text"
13217
- }, headerTitle), /*#__PURE__*/React.createElement(ActionItemsListComponent, {
13218
- items: items
13219
- })), /*#__PURE__*/React.createElement(StyledFAB, {
13304
+ }, headerTitle)), /*#__PURE__*/React.createElement(Box, {
13305
+ style: [style, {
13306
+ paddingBottom: 0
13307
+ }]
13308
+ }, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
13309
+ return /*#__PURE__*/React.createElement(Animated.View, {
13310
+ key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title),
13311
+ style: {
13312
+ transform: [{
13313
+ translateY: translateYAnimations[index]
13314
+ }]
13315
+ }
13316
+ }, /*#__PURE__*/React.createElement(ActionItem, itemProp));
13317
+ }))), /*#__PURE__*/React.createElement(StyledFAB, {
13220
13318
  testID: "fab",
13221
13319
  icon: fabIcon,
13222
13320
  onPress: onPress,
13223
13321
  animated: true,
13224
13322
  active: active,
13225
- title: fabTitle
13323
+ title: fabTitle,
13324
+ ref: fabRef
13226
13325
  }));
13227
- };
13326
+ });
13228
13327
 
13229
13328
  var index$6 = Object.assign(FAB, {
13230
13329
  ActionGroup: ActionGroup
@@ -14907,7 +15006,7 @@ var getGradientColors = function getGradientColors(theme, intent) {
14907
15006
  }
14908
15007
  };
14909
15008
  var Skeleton = function Skeleton(_ref) {
14910
- var _StyleSheet$flatten;
15009
+ var _StyleSheet$flatten, _StyleSheet$flatten2;
14911
15010
  var _ref$intent = _ref.intent,
14912
15011
  intent = _ref$intent === void 0 ? 'light' : _ref$intent,
14913
15012
  _ref$variant = _ref.variant,
@@ -14923,10 +15022,14 @@ var Skeleton = function Skeleton(_ref) {
14923
15022
  _useState2 = _slicedToArray(_useState, 2),
14924
15023
  containerWidth = _useState2[0],
14925
15024
  setContainerWidth = _useState2[1];
14926
- var _useState3 = useState(false),
15025
+ var _useState3 = useState(Number((_StyleSheet$flatten2 = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.height) || 0),
14927
15026
  _useState4 = _slicedToArray(_useState3, 2),
14928
- shouldStartAnimation = _useState4[0],
14929
- setShouldStartAnimation = _useState4[1];
15027
+ containerHeight = _useState4[0],
15028
+ setContainerHeight = _useState4[1];
15029
+ var _useState5 = useState(false),
15030
+ _useState6 = _slicedToArray(_useState5, 2),
15031
+ shouldStartAnimation = _useState6[0],
15032
+ setShouldStartAnimation = _useState6[1];
14930
15033
  var animatedValue = useRef(new Animated.Value(0)).current;
14931
15034
  useEffect(function () {
14932
15035
  if (shouldStartAnimation) {
@@ -14943,7 +15046,10 @@ var Skeleton = function Skeleton(_ref) {
14943
15046
  outputRange: [-containerWidth, containerWidth]
14944
15047
  });
14945
15048
  var onContainerLayout = useCallback(function (e) {
14946
- var width = e.nativeEvent.layout.width;
15049
+ var _e$nativeEvent$layout = e.nativeEvent.layout,
15050
+ width = _e$nativeEvent$layout.width,
15051
+ height = _e$nativeEvent$layout.height;
15052
+ setContainerHeight(height);
14947
15053
  setContainerWidth(width);
14948
15054
  if (!shouldStartAnimation) {
14949
15055
  setShouldStartAnimation(true);
@@ -14961,8 +15067,8 @@ var Skeleton = function Skeleton(_ref) {
14961
15067
  start: gradientPositions.start,
14962
15068
  end: gradientPositions.end,
14963
15069
  style: {
14964
- width: '100%',
14965
- height: '100%',
15070
+ width: containerWidth,
15071
+ height: containerHeight,
14966
15072
  transform: [{
14967
15073
  translateX: translateX
14968
15074
  }]