@hero-design/rn 8.32.1 → 8.33.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 (29) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/es/index.js +163 -54
  3. package/lib/index.js +163 -54
  4. package/package.json +5 -5
  5. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +2 -1
  6. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +10 -10
  7. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +6 -6
  8. package/src/components/FAB/ActionGroup/ActionItem.tsx +44 -15
  9. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +982 -819
  10. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +4 -11
  11. package/src/components/FAB/ActionGroup/index.tsx +119 -93
  12. package/src/components/FAB/AnimatedFABIcon.tsx +3 -5
  13. package/src/components/FAB/FAB.tsx +108 -28
  14. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +27 -9
  15. package/src/components/FAB/__tests__/index.spec.tsx +22 -2
  16. package/src/components/Typography/Text/index.tsx +19 -12
  17. package/src/components/Typography/index.tsx +3 -0
  18. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -0
  19. package/src/theme/components/button.ts +1 -0
  20. package/src/types.ts +4 -0
  21. package/testUtils/setup.tsx +2 -0
  22. package/types/components/FAB/ActionGroup/ActionItem.d.ts +6 -2
  23. package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +1 -1
  24. package/types/components/FAB/ActionGroup/index.d.ts +7 -1
  25. package/types/components/FAB/FAB.d.ts +8 -2
  26. package/types/components/FAB/index.d.ts +3 -2
  27. package/types/components/Typography/index.d.ts +3 -0
  28. package/types/theme/components/button.d.ts +1 -0
  29. package/types/types.d.ts +3 -1
@@ -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 25.6s
7
+ created lib/index.js, es/index.js in 29s
8
8
  $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -1939,7 +1939,8 @@ var getButtonTheme = function getButtonTheme(theme) {
1939
1939
  buttonPadding: theme.space.medium,
1940
1940
  textButtonPadding: theme.space.smallMedium,
1941
1941
  iconPadding: theme.space.smallMedium,
1942
- utilityPadding: theme.space.small
1942
+ utilityPadding: theme.space.small,
1943
+ loadingIndicatorWrapperVerticalPadding: theme.space.xxsmall / 2
1943
1944
  };
1944
1945
  var sizes = {
1945
1946
  iconSize: theme.fontSizes.xxlarge
@@ -6350,6 +6351,7 @@ var Text = function Text(_ref) {
6350
6351
  _ref$allowFontScaling = _ref.allowFontScaling,
6351
6352
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
6352
6353
  nativeProps = _objectWithoutProperties(_ref, _excluded$y);
6354
+ useDeprecation('Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.');
6353
6355
  return /*#__PURE__*/React.createElement(StyledText$3, _extends$1({}, nativeProps, {
6354
6356
  themeFontSize: fontSize,
6355
6357
  themeFontWeight: fontWeight,
@@ -7904,7 +7906,7 @@ var StyledLoadingIndicatorWrapper = index$a(View)(function (_ref) {
7904
7906
  flexDirection: 'row',
7905
7907
  justifyContent: 'center',
7906
7908
  alignItems: 'center',
7907
- paddingVertical: theme.space.xxsmall
7909
+ paddingVertical: theme.__hd__.button.space.loadingIndicatorWrapperVerticalPadding
7908
7910
  };
7909
7911
  });
7910
7912
  var StyledLoadingDot = index$a(View)(function (_ref2) {
@@ -13249,11 +13251,9 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13249
13251
  iconProps = _objectWithoutProperties(_ref, _excluded$c);
13250
13252
  var rotateAnimation = useRef(new Animated.Value(active ? 1 : 0));
13251
13253
  useEffect(function () {
13252
- var animation = Animated.timing(rotateAnimation.current, {
13254
+ var animation = Animated.spring(rotateAnimation.current, {
13253
13255
  toValue: active ? 1 : 0,
13254
- useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
13255
- easing: Easing.inOut(Easing.ease),
13256
- duration: 300
13256
+ useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android'
13257
13257
  });
13258
13258
  animation.start();
13259
13259
  return function () {
@@ -13275,6 +13275,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13275
13275
  }, iconProps)));
13276
13276
  };
13277
13277
 
13278
+ if (Platform.OS === 'android') {
13279
+ if (UIManager.setLayoutAnimationEnabledExperimental) {
13280
+ UIManager.setLayoutAnimationEnabledExperimental(true);
13281
+ }
13282
+ }
13278
13283
  var IconOnlyContent = function IconOnlyContent(_ref) {
13279
13284
  var icon = _ref.icon,
13280
13285
  animated = _ref.animated,
@@ -13300,7 +13305,19 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
13300
13305
  testID: "styled-fab-icon"
13301
13306
  })), /*#__PURE__*/React.createElement(StyledFABText, null, title));
13302
13307
  };
13303
- var FAB = function FAB(_ref3) {
13308
+ var defaultAnimation = {
13309
+ create: {
13310
+ type: 'easeInEaseOut',
13311
+ property: 'opacity'
13312
+ },
13313
+ update: {
13314
+ type: 'spring',
13315
+ springDamping: Platform.OS === 'ios' ? 0.7 : 1
13316
+ },
13317
+ duration: 400
13318
+ };
13319
+ var FAB = /*#__PURE__*/forwardRef(function (_ref3, ref) {
13320
+ var _StyleSheet$flatten, _StyleSheet$flatten2;
13304
13321
  var onPress = _ref3.onPress,
13305
13322
  title = _ref3.title,
13306
13323
  icon = _ref3.icon,
@@ -13308,22 +13325,71 @@ var FAB = function FAB(_ref3) {
13308
13325
  testID = _ref3.testID,
13309
13326
  active = _ref3.active,
13310
13327
  style = _ref3.style;
13311
- var isIconOnly = !title;
13312
13328
  var theme = useTheme();
13313
- return /*#__PURE__*/React.createElement(StyledFAB$1, {
13329
+ var _React$useState = React.useState({
13330
+ hideTitle: false,
13331
+ hideButton: false
13332
+ }),
13333
+ _React$useState2 = _slicedToArray(_React$useState, 2),
13334
+ displayState = _React$useState2[0],
13335
+ setDisplayState = _React$useState2[1];
13336
+ var _React$useState3 = React.useState(false),
13337
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
13338
+ canAnimate = _React$useState4[0],
13339
+ setCanAnimate = _React$useState4[1];
13340
+ var isIconOnly = displayState.hideTitle || active || !title;
13341
+ React.useImperativeHandle(ref, function () {
13342
+ return {
13343
+ show: function show() {
13344
+ setDisplayState({
13345
+ hideButton: false,
13346
+ hideTitle: false
13347
+ });
13348
+ },
13349
+ collapse: function collapse() {
13350
+ setDisplayState({
13351
+ hideButton: false,
13352
+ hideTitle: true
13353
+ });
13354
+ },
13355
+ hide: function hide() {
13356
+ setDisplayState(function (previousState) {
13357
+ return _objectSpread2(_objectSpread2({}, previousState), {}, {
13358
+ hideButton: true
13359
+ });
13360
+ });
13361
+ }
13362
+ };
13363
+ }, []);
13364
+ React.useEffect(function () {
13365
+ if (canAnimate) {
13366
+ LayoutAnimation.configureNext(defaultAnimation);
13367
+ }
13368
+ }, [isIconOnly, displayState.hideButton, canAnimate]);
13369
+ var marginBottom = Number((_StyleSheet$flatten = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
13370
+ return /*#__PURE__*/React.createElement(StyledFAB$1
13371
+ /** Add a small timeout before executing animation to prevent flakiness */, {
13372
+ onLayout: function onLayout() {
13373
+ return setTimeout(function () {
13374
+ return setCanAnimate(true);
13375
+ }, 500);
13376
+ },
13314
13377
  underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
13315
13378
  onPress: onPress,
13316
- style: style,
13379
+ style: [style, {
13380
+ 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
13381
+ }],
13317
13382
  testID: testID
13318
13383
  }, isIconOnly ? /*#__PURE__*/React.createElement(IconOnlyContent, {
13319
13384
  animated: animated,
13320
13385
  active: active,
13321
- icon: icon
13386
+ icon: active ? 'add' : icon
13322
13387
  }) : /*#__PURE__*/React.createElement(IconWithTextContent, {
13323
13388
  icon: icon,
13324
13389
  title: title
13325
13390
  }));
13326
- };
13391
+ });
13392
+ FAB.displayName = 'FAB';
13327
13393
 
13328
13394
  var StyledActionItem = index$a(TouchableHighlight)(function (_ref) {
13329
13395
  var theme = _ref.theme;
@@ -13361,9 +13427,30 @@ var ActionItem = function ActionItem(_ref) {
13361
13427
  title = _ref.title,
13362
13428
  onPress = _ref.onPress,
13363
13429
  style = _ref.style,
13364
- testID = _ref.testID;
13430
+ testID = _ref.testID,
13431
+ index = _ref.index,
13432
+ _ref$active = _ref.active,
13433
+ active = _ref$active === void 0 ? false : _ref$active;
13365
13434
  var theme = useTheme();
13366
- return /*#__PURE__*/React.createElement(StyledActionItem, {
13435
+ var animatedValue = React.useRef(new Animated.Value(0));
13436
+ var translateY = animatedValue.current.interpolate({
13437
+ inputRange: [0, 1],
13438
+ outputRange: [50, 0]
13439
+ });
13440
+ React.useEffect(function () {
13441
+ Animated.spring(animatedValue.current, {
13442
+ toValue: active ? 1 : 0,
13443
+ useNativeDriver: Platform.OS !== 'web',
13444
+ delay: index * 20
13445
+ }).start();
13446
+ }, [active, index]);
13447
+ return /*#__PURE__*/React.createElement(Animated.View, {
13448
+ style: {
13449
+ transform: [{
13450
+ translateY: translateY
13451
+ }]
13452
+ }
13453
+ }, /*#__PURE__*/React.createElement(StyledActionItem, {
13367
13454
  underlayColor: theme.__hd__.fab.colors.actionItemPressedBackground,
13368
13455
  style: style,
13369
13456
  onPress: onPress,
@@ -13371,7 +13458,7 @@ var ActionItem = function ActionItem(_ref) {
13371
13458
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledIconContainer, null, /*#__PURE__*/React.createElement(StyledIcon, {
13372
13459
  size: "xsmall",
13373
13460
  icon: icon
13374
- })), /*#__PURE__*/React.createElement(StyledActionItemText, null, title)));
13461
+ })), /*#__PURE__*/React.createElement(StyledActionItemText, null, title))));
13375
13462
  };
13376
13463
 
13377
13464
  var StyledContainer$2 = index$a(View)({
@@ -13420,40 +13507,48 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
13420
13507
  };
13421
13508
  });
13422
13509
 
13423
- var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
13424
- var style = _ref.style,
13425
- items = _ref.items;
13426
- return /*#__PURE__*/React.createElement(View, {
13427
- style: style
13428
- }, items === null || items === void 0 ? void 0 : items.map(function (itemProp) {
13429
- return /*#__PURE__*/React.createElement(ActionItem, _extends$1({
13430
- key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13431
- }, itemProp));
13432
- }));
13433
- };
13434
- var ActionGroup = function ActionGroup(_ref2) {
13435
- var headerTitle = _ref2.headerTitle,
13436
- onPress = _ref2.onPress,
13437
- active = _ref2.active,
13438
- style = _ref2.style,
13439
- items = _ref2.items,
13440
- testID = _ref2.testID,
13441
- fabTitle = _ref2.fabTitle,
13442
- _ref2$fabIcon = _ref2.fabIcon,
13443
- fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
13510
+ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
13511
+ var headerTitle = _ref.headerTitle,
13512
+ onPress = _ref.onPress,
13513
+ active = _ref.active,
13514
+ style = _ref.style,
13515
+ items = _ref.items,
13516
+ testID = _ref.testID,
13517
+ fabTitle = _ref.fabTitle,
13518
+ _ref$fabIcon = _ref.fabIcon,
13519
+ fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
13520
+ var fabRef = useRef(null);
13444
13521
  var tranlateXAnimation = useRef(new Animated.Value(active ? 1 : 0));
13445
- useEffect(function () {
13446
- var animation = Animated.timing(tranlateXAnimation.current, {
13447
- toValue: active ? 1 : 0,
13448
- useNativeDriver: Platform.OS === 'ios' || Platform.OS === 'android',
13449
- easing: Easing.inOut(Easing.cubic)
13450
- });
13451
- animation.start();
13452
- }, [active]);
13453
- var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
13522
+ var titleTranslateYValue = React.useRef(new Animated.Value(0));
13523
+ var titleTranslateY = titleTranslateYValue.current.interpolate({
13454
13524
  inputRange: [0, 1],
13455
- outputRange: [400, 0]
13525
+ outputRange: [50, 0]
13456
13526
  });
13527
+ React.useImperativeHandle(ref, function () {
13528
+ return {
13529
+ showFAB: function showFAB() {
13530
+ var _fabRef$current;
13531
+ return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
13532
+ },
13533
+ collapseFAB: function collapseFAB() {
13534
+ var _fabRef$current2;
13535
+ return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
13536
+ },
13537
+ hideFAB: function hideFAB() {
13538
+ var _fabRef$current3;
13539
+ return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
13540
+ }
13541
+ };
13542
+ }, [fabRef]);
13543
+ React.useEffect(function () {
13544
+ Animated.parallel([Animated.spring(tranlateXAnimation.current, {
13545
+ toValue: active ? 1 : 0,
13546
+ useNativeDriver: Platform.OS !== 'web'
13547
+ }), Animated.spring(titleTranslateYValue.current, {
13548
+ toValue: active ? 1 : 0,
13549
+ useNativeDriver: Platform.OS !== 'web'
13550
+ })]).start();
13551
+ }, [active]);
13457
13552
  var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
13458
13553
  inputRange: [0, 1],
13459
13554
  outputRange: [0, 0.4]
@@ -13476,24 +13571,38 @@ var ActionGroup = function ActionGroup(_ref2) {
13476
13571
  pointerEvents: active ? 'auto' : 'none',
13477
13572
  testID: "action-group",
13478
13573
  style: {
13479
- opacity: interpolatedActionGroupOpacityAnimation,
13574
+ opacity: interpolatedActionGroupOpacityAnimation
13575
+ }
13576
+ }, !!headerTitle && /*#__PURE__*/React.createElement(Animated.View, {
13577
+ style: {
13480
13578
  transform: [{
13481
- translateX: interpolatedTranlateXAnimation
13579
+ translateY: titleTranslateY
13482
13580
  }]
13483
13581
  }
13484
- }, !!headerTitle && /*#__PURE__*/React.createElement(StyledHeaderText, {
13582
+ }, /*#__PURE__*/React.createElement(StyledHeaderText, {
13485
13583
  testID: "header-text"
13486
- }, headerTitle), /*#__PURE__*/React.createElement(ActionItemsListComponent, {
13487
- items: items
13488
- })), /*#__PURE__*/React.createElement(StyledFAB, {
13584
+ }, headerTitle)), /*#__PURE__*/React.createElement(Box, {
13585
+ style: [style, {
13586
+ paddingBottom: 0
13587
+ }]
13588
+ }, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
13589
+ return /*#__PURE__*/React.createElement(ActionItem, _extends$1({
13590
+ key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13591
+ }, itemProp, {
13592
+ index: active ? index : items.length - index,
13593
+ active: active
13594
+ }));
13595
+ }))), /*#__PURE__*/React.createElement(StyledFAB, {
13489
13596
  testID: "fab",
13490
13597
  icon: fabIcon,
13491
13598
  onPress: onPress,
13492
13599
  animated: true,
13493
13600
  active: active,
13494
- title: fabTitle
13601
+ title: fabTitle,
13602
+ ref: fabRef
13495
13603
  }));
13496
- };
13604
+ });
13605
+ ActionGroup.displayName = 'FAB.ActionGroup';
13497
13606
 
13498
13607
  var index$6 = Object.assign(FAB, {
13499
13608
  ActionGroup: ActionGroup
package/lib/index.js CHANGED
@@ -1969,7 +1969,8 @@ var getButtonTheme = function getButtonTheme(theme) {
1969
1969
  buttonPadding: theme.space.medium,
1970
1970
  textButtonPadding: theme.space.smallMedium,
1971
1971
  iconPadding: theme.space.smallMedium,
1972
- utilityPadding: theme.space.small
1972
+ utilityPadding: theme.space.small,
1973
+ loadingIndicatorWrapperVerticalPadding: theme.space.xxsmall / 2
1973
1974
  };
1974
1975
  var sizes = {
1975
1976
  iconSize: theme.fontSizes.xxlarge
@@ -6380,6 +6381,7 @@ var Text = function Text(_ref) {
6380
6381
  _ref$allowFontScaling = _ref.allowFontScaling,
6381
6382
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
6382
6383
  nativeProps = _objectWithoutProperties(_ref, _excluded$y);
6384
+ useDeprecation('Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.');
6383
6385
  return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
6384
6386
  themeFontSize: fontSize,
6385
6387
  themeFontWeight: fontWeight,
@@ -7934,7 +7936,7 @@ var StyledLoadingIndicatorWrapper = index$a(reactNative.View)(function (_ref) {
7934
7936
  flexDirection: 'row',
7935
7937
  justifyContent: 'center',
7936
7938
  alignItems: 'center',
7937
- paddingVertical: theme.space.xxsmall
7939
+ paddingVertical: theme.__hd__.button.space.loadingIndicatorWrapperVerticalPadding
7938
7940
  };
7939
7941
  });
7940
7942
  var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
@@ -13279,11 +13281,9 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13279
13281
  iconProps = _objectWithoutProperties(_ref, _excluded$c);
13280
13282
  var rotateAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
13281
13283
  React.useEffect(function () {
13282
- var animation = reactNative.Animated.timing(rotateAnimation.current, {
13284
+ var animation = reactNative.Animated.spring(rotateAnimation.current, {
13283
13285
  toValue: active ? 1 : 0,
13284
- useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
13285
- easing: reactNative.Easing.inOut(reactNative.Easing.ease),
13286
- duration: 300
13286
+ useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android'
13287
13287
  });
13288
13288
  animation.start();
13289
13289
  return function () {
@@ -13305,6 +13305,11 @@ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
13305
13305
  }, iconProps)));
13306
13306
  };
13307
13307
 
13308
+ if (reactNative.Platform.OS === 'android') {
13309
+ if (reactNative.UIManager.setLayoutAnimationEnabledExperimental) {
13310
+ reactNative.UIManager.setLayoutAnimationEnabledExperimental(true);
13311
+ }
13312
+ }
13308
13313
  var IconOnlyContent = function IconOnlyContent(_ref) {
13309
13314
  var icon = _ref.icon,
13310
13315
  animated = _ref.animated,
@@ -13330,7 +13335,19 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
13330
13335
  testID: "styled-fab-icon"
13331
13336
  })), /*#__PURE__*/React__default["default"].createElement(StyledFABText, null, title));
13332
13337
  };
13333
- var FAB = function FAB(_ref3) {
13338
+ var defaultAnimation = {
13339
+ create: {
13340
+ type: 'easeInEaseOut',
13341
+ property: 'opacity'
13342
+ },
13343
+ update: {
13344
+ type: 'spring',
13345
+ springDamping: reactNative.Platform.OS === 'ios' ? 0.7 : 1
13346
+ },
13347
+ duration: 400
13348
+ };
13349
+ var FAB = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
13350
+ var _StyleSheet$flatten, _StyleSheet$flatten2;
13334
13351
  var onPress = _ref3.onPress,
13335
13352
  title = _ref3.title,
13336
13353
  icon = _ref3.icon,
@@ -13338,22 +13355,71 @@ var FAB = function FAB(_ref3) {
13338
13355
  testID = _ref3.testID,
13339
13356
  active = _ref3.active,
13340
13357
  style = _ref3.style;
13341
- var isIconOnly = !title;
13342
13358
  var theme = useTheme();
13343
- return /*#__PURE__*/React__default["default"].createElement(StyledFAB$1, {
13359
+ var _React$useState = React__default["default"].useState({
13360
+ hideTitle: false,
13361
+ hideButton: false
13362
+ }),
13363
+ _React$useState2 = _slicedToArray(_React$useState, 2),
13364
+ displayState = _React$useState2[0],
13365
+ setDisplayState = _React$useState2[1];
13366
+ var _React$useState3 = React__default["default"].useState(false),
13367
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
13368
+ canAnimate = _React$useState4[0],
13369
+ setCanAnimate = _React$useState4[1];
13370
+ var isIconOnly = displayState.hideTitle || active || !title;
13371
+ React__default["default"].useImperativeHandle(ref, function () {
13372
+ return {
13373
+ show: function show() {
13374
+ setDisplayState({
13375
+ hideButton: false,
13376
+ hideTitle: false
13377
+ });
13378
+ },
13379
+ collapse: function collapse() {
13380
+ setDisplayState({
13381
+ hideButton: false,
13382
+ hideTitle: true
13383
+ });
13384
+ },
13385
+ hide: function hide() {
13386
+ setDisplayState(function (previousState) {
13387
+ return _objectSpread2(_objectSpread2({}, previousState), {}, {
13388
+ hideButton: true
13389
+ });
13390
+ });
13391
+ }
13392
+ };
13393
+ }, []);
13394
+ React__default["default"].useEffect(function () {
13395
+ if (canAnimate) {
13396
+ reactNative.LayoutAnimation.configureNext(defaultAnimation);
13397
+ }
13398
+ }, [isIconOnly, displayState.hideButton, canAnimate]);
13399
+ var marginBottom = Number((_StyleSheet$flatten = reactNative.StyleSheet.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
13400
+ return /*#__PURE__*/React__default["default"].createElement(StyledFAB$1
13401
+ /** Add a small timeout before executing animation to prevent flakiness */, {
13402
+ onLayout: function onLayout() {
13403
+ return setTimeout(function () {
13404
+ return setCanAnimate(true);
13405
+ }, 500);
13406
+ },
13344
13407
  underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
13345
13408
  onPress: onPress,
13346
- style: style,
13409
+ style: [style, {
13410
+ 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
13411
+ }],
13347
13412
  testID: testID
13348
13413
  }, isIconOnly ? /*#__PURE__*/React__default["default"].createElement(IconOnlyContent, {
13349
13414
  animated: animated,
13350
13415
  active: active,
13351
- icon: icon
13416
+ icon: active ? 'add' : icon
13352
13417
  }) : /*#__PURE__*/React__default["default"].createElement(IconWithTextContent, {
13353
13418
  icon: icon,
13354
13419
  title: title
13355
13420
  }));
13356
- };
13421
+ });
13422
+ FAB.displayName = 'FAB';
13357
13423
 
13358
13424
  var StyledActionItem = index$a(reactNative.TouchableHighlight)(function (_ref) {
13359
13425
  var theme = _ref.theme;
@@ -13391,9 +13457,30 @@ var ActionItem = function ActionItem(_ref) {
13391
13457
  title = _ref.title,
13392
13458
  onPress = _ref.onPress,
13393
13459
  style = _ref.style,
13394
- testID = _ref.testID;
13460
+ testID = _ref.testID,
13461
+ index = _ref.index,
13462
+ _ref$active = _ref.active,
13463
+ active = _ref$active === void 0 ? false : _ref$active;
13395
13464
  var theme = useTheme();
13396
- return /*#__PURE__*/React__default["default"].createElement(StyledActionItem, {
13465
+ var animatedValue = React__default["default"].useRef(new reactNative.Animated.Value(0));
13466
+ var translateY = animatedValue.current.interpolate({
13467
+ inputRange: [0, 1],
13468
+ outputRange: [50, 0]
13469
+ });
13470
+ React__default["default"].useEffect(function () {
13471
+ reactNative.Animated.spring(animatedValue.current, {
13472
+ toValue: active ? 1 : 0,
13473
+ useNativeDriver: reactNative.Platform.OS !== 'web',
13474
+ delay: index * 20
13475
+ }).start();
13476
+ }, [active, index]);
13477
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13478
+ style: {
13479
+ transform: [{
13480
+ translateY: translateY
13481
+ }]
13482
+ }
13483
+ }, /*#__PURE__*/React__default["default"].createElement(StyledActionItem, {
13397
13484
  underlayColor: theme.__hd__.fab.colors.actionItemPressedBackground,
13398
13485
  style: style,
13399
13486
  onPress: onPress,
@@ -13401,7 +13488,7 @@ var ActionItem = function ActionItem(_ref) {
13401
13488
  }, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledIconContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledIcon, {
13402
13489
  size: "xsmall",
13403
13490
  icon: icon
13404
- })), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title)));
13491
+ })), /*#__PURE__*/React__default["default"].createElement(StyledActionItemText, null, title))));
13405
13492
  };
13406
13493
 
13407
13494
  var StyledContainer$2 = index$a(reactNative.View)({
@@ -13450,40 +13537,48 @@ var StyledHeaderText = index$a(Typography.Text)(function (_ref3) {
13450
13537
  };
13451
13538
  });
13452
13539
 
13453
- var ActionItemsListComponent = function ActionItemsListComponent(_ref) {
13454
- var style = _ref.style,
13455
- items = _ref.items;
13456
- return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13457
- style: style
13458
- }, items === null || items === void 0 ? void 0 : items.map(function (itemProp) {
13459
- return /*#__PURE__*/React__default["default"].createElement(ActionItem, _extends$1({
13460
- key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13461
- }, itemProp));
13462
- }));
13463
- };
13464
- var ActionGroup = function ActionGroup(_ref2) {
13465
- var headerTitle = _ref2.headerTitle,
13466
- onPress = _ref2.onPress,
13467
- active = _ref2.active,
13468
- style = _ref2.style,
13469
- items = _ref2.items,
13470
- testID = _ref2.testID,
13471
- fabTitle = _ref2.fabTitle,
13472
- _ref2$fabIcon = _ref2.fabIcon,
13473
- fabIcon = _ref2$fabIcon === void 0 ? 'add' : _ref2$fabIcon;
13540
+ var ActionGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
13541
+ var headerTitle = _ref.headerTitle,
13542
+ onPress = _ref.onPress,
13543
+ active = _ref.active,
13544
+ style = _ref.style,
13545
+ items = _ref.items,
13546
+ testID = _ref.testID,
13547
+ fabTitle = _ref.fabTitle,
13548
+ _ref$fabIcon = _ref.fabIcon,
13549
+ fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
13550
+ var fabRef = React.useRef(null);
13474
13551
  var tranlateXAnimation = React.useRef(new reactNative.Animated.Value(active ? 1 : 0));
13475
- React.useEffect(function () {
13476
- var animation = reactNative.Animated.timing(tranlateXAnimation.current, {
13477
- toValue: active ? 1 : 0,
13478
- useNativeDriver: reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android',
13479
- easing: reactNative.Easing.inOut(reactNative.Easing.cubic)
13480
- });
13481
- animation.start();
13482
- }, [active]);
13483
- var interpolatedTranlateXAnimation = tranlateXAnimation.current.interpolate({
13552
+ var titleTranslateYValue = React__default["default"].useRef(new reactNative.Animated.Value(0));
13553
+ var titleTranslateY = titleTranslateYValue.current.interpolate({
13484
13554
  inputRange: [0, 1],
13485
- outputRange: [400, 0]
13555
+ outputRange: [50, 0]
13486
13556
  });
13557
+ React__default["default"].useImperativeHandle(ref, function () {
13558
+ return {
13559
+ showFAB: function showFAB() {
13560
+ var _fabRef$current;
13561
+ return (_fabRef$current = fabRef.current) === null || _fabRef$current === void 0 ? void 0 : _fabRef$current.show();
13562
+ },
13563
+ collapseFAB: function collapseFAB() {
13564
+ var _fabRef$current2;
13565
+ return (_fabRef$current2 = fabRef.current) === null || _fabRef$current2 === void 0 ? void 0 : _fabRef$current2.collapse();
13566
+ },
13567
+ hideFAB: function hideFAB() {
13568
+ var _fabRef$current3;
13569
+ return (_fabRef$current3 = fabRef.current) === null || _fabRef$current3 === void 0 ? void 0 : _fabRef$current3.hide();
13570
+ }
13571
+ };
13572
+ }, [fabRef]);
13573
+ React__default["default"].useEffect(function () {
13574
+ reactNative.Animated.parallel([reactNative.Animated.spring(tranlateXAnimation.current, {
13575
+ toValue: active ? 1 : 0,
13576
+ useNativeDriver: reactNative.Platform.OS !== 'web'
13577
+ }), reactNative.Animated.spring(titleTranslateYValue.current, {
13578
+ toValue: active ? 1 : 0,
13579
+ useNativeDriver: reactNative.Platform.OS !== 'web'
13580
+ })]).start();
13581
+ }, [active]);
13487
13582
  var interpolatedBackdropOpacityAnimation = tranlateXAnimation.current.interpolate({
13488
13583
  inputRange: [0, 1],
13489
13584
  outputRange: [0, 0.4]
@@ -13506,24 +13601,38 @@ var ActionGroup = function ActionGroup(_ref2) {
13506
13601
  pointerEvents: active ? 'auto' : 'none',
13507
13602
  testID: "action-group",
13508
13603
  style: {
13509
- opacity: interpolatedActionGroupOpacityAnimation,
13604
+ opacity: interpolatedActionGroupOpacityAnimation
13605
+ }
13606
+ }, !!headerTitle && /*#__PURE__*/React__default["default"].createElement(reactNative.Animated.View, {
13607
+ style: {
13510
13608
  transform: [{
13511
- translateX: interpolatedTranlateXAnimation
13609
+ translateY: titleTranslateY
13512
13610
  }]
13513
13611
  }
13514
- }, !!headerTitle && /*#__PURE__*/React__default["default"].createElement(StyledHeaderText, {
13612
+ }, /*#__PURE__*/React__default["default"].createElement(StyledHeaderText, {
13515
13613
  testID: "header-text"
13516
- }, headerTitle), /*#__PURE__*/React__default["default"].createElement(ActionItemsListComponent, {
13517
- items: items
13518
- })), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
13614
+ }, headerTitle)), /*#__PURE__*/React__default["default"].createElement(Box, {
13615
+ style: [style, {
13616
+ paddingBottom: 0
13617
+ }]
13618
+ }, items === null || items === void 0 ? void 0 : items.map(function (itemProp, index) {
13619
+ return /*#__PURE__*/React__default["default"].createElement(ActionItem, _extends$1({
13620
+ key: itemProp.key || "".concat(itemProp.icon, "_").concat(itemProp.title)
13621
+ }, itemProp, {
13622
+ index: active ? index : items.length - index,
13623
+ active: active
13624
+ }));
13625
+ }))), /*#__PURE__*/React__default["default"].createElement(StyledFAB, {
13519
13626
  testID: "fab",
13520
13627
  icon: fabIcon,
13521
13628
  onPress: onPress,
13522
13629
  animated: true,
13523
13630
  active: active,
13524
- title: fabTitle
13631
+ title: fabTitle,
13632
+ ref: fabRef
13525
13633
  }));
13526
- };
13634
+ });
13635
+ ActionGroup.displayName = 'FAB.ActionGroup';
13527
13636
 
13528
13637
  var index$6 = Object.assign(FAB, {
13529
13638
  ActionGroup: ActionGroup