@hero-design/rn 7.1.3-alpha7 → 7.2.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 (97) hide show
  1. package/.turbo/turbo-build.log +8 -0
  2. package/.turbo/turbo-publish:npm.log +0 -0
  3. package/es/index.js +148 -94
  4. package/lib/index.js +148 -94
  5. package/package.json +2 -38
  6. package/playground/components/BottomNavigation.tsx +1 -1
  7. package/playground/components/Card.tsx +1 -1
  8. package/playground/components/Tabs.tsx +1 -1
  9. package/playground/index.tsx +39 -31
  10. package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +0 -1
  11. package/src/components/BottomNavigation/__tests__/index.spec.tsx +2 -2
  12. package/src/components/BottomNavigation/index.tsx +6 -10
  13. package/src/components/FAB/ActionGroup/index.tsx +1 -2
  14. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +0 -1
  15. package/src/components/Tabs/__tests__/index.spec.tsx +2 -2
  16. package/src/components/Tabs/index.tsx +19 -15
  17. package/src/theme/global/borders.ts +8 -2
  18. package/src/theme/global/colors.ts +4 -2
  19. package/src/theme/global/index.ts +31 -17
  20. package/src/theme/global/scale.ts +18 -0
  21. package/src/theme/global/space.ts +23 -13
  22. package/src/theme/global/typography.ts +71 -27
  23. package/src/theme/index.ts +27 -14
  24. package/types/playground/components/Badge.d.ts +0 -0
  25. package/types/playground/components/BottomNavigation.d.ts +0 -0
  26. package/types/playground/components/Button.d.ts +0 -0
  27. package/types/playground/components/Card.d.ts +0 -0
  28. package/types/playground/components/Divider.d.ts +0 -0
  29. package/types/playground/components/FAB.d.ts +0 -0
  30. package/types/playground/components/Icon.d.ts +0 -0
  31. package/types/playground/components/Tabs.d.ts +0 -0
  32. package/types/playground/components/Typography.d.ts +0 -0
  33. package/types/playground/index.d.ts +0 -0
  34. package/types/src/components/Badge/StyledBadge.d.ts +0 -0
  35. package/types/src/components/Badge/__tests__/Badge.spec.d.ts +0 -0
  36. package/types/src/components/Badge/index.d.ts +0 -0
  37. package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
  38. package/types/src/components/BottomNavigation/__tests__/index.spec.d.ts +0 -0
  39. package/types/src/components/BottomNavigation/index.d.ts +3 -3
  40. package/types/src/components/Button/IconButton.d.ts +0 -0
  41. package/types/src/components/Button/__tests__/index.spec.d.ts +0 -0
  42. package/types/src/components/Button/index.d.ts +0 -0
  43. package/types/src/components/Card/StyledCard.d.ts +0 -0
  44. package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +0 -0
  45. package/types/src/components/Card/__tests__/index.spec.d.ts +0 -0
  46. package/types/src/components/Card/index.d.ts +0 -0
  47. package/types/src/components/Divider/StyledDivider.d.ts +0 -0
  48. package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -0
  49. package/types/src/components/Divider/index.d.ts +0 -0
  50. package/types/src/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
  51. package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
  52. package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
  53. package/types/src/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -0
  54. package/types/src/components/FAB/ActionGroup/index.d.ts +3 -0
  55. package/types/src/components/FAB/AnimatedFABIcon.d.ts +0 -0
  56. package/types/src/components/FAB/FAB.d.ts +0 -0
  57. package/types/src/components/FAB/StyledFAB.d.ts +0 -0
  58. package/types/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -0
  59. package/types/src/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -0
  60. package/types/src/components/FAB/__tests__/index.spec.d.ts +0 -0
  61. package/types/src/components/FAB/index.d.ts +0 -0
  62. package/types/src/components/Icon/HeroIcon/index.d.ts +0 -0
  63. package/types/src/components/Icon/IconList.d.ts +0 -0
  64. package/types/src/components/Icon/__tests__/index.spec.d.ts +0 -0
  65. package/types/src/components/Icon/index.d.ts +0 -0
  66. package/types/src/components/Icon/utils.d.ts +0 -0
  67. package/types/src/components/Tabs/StyledTabs.d.ts +0 -0
  68. package/types/src/components/Tabs/__tests__/index.spec.d.ts +0 -0
  69. package/types/src/components/Tabs/index.d.ts +3 -3
  70. package/types/src/components/Typography/Text/StyledText.d.ts +0 -0
  71. package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -0
  72. package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +0 -0
  73. package/types/src/components/Typography/Text/index.d.ts +0 -0
  74. package/types/src/components/Typography/index.d.ts +0 -0
  75. package/types/src/index.d.ts +0 -0
  76. package/types/src/testHelpers/renderWithTheme.d.ts +0 -0
  77. package/types/src/theme/__tests__/index.spec.d.ts +0 -0
  78. package/types/src/theme/components/badge.d.ts +0 -0
  79. package/types/src/theme/components/bottomNavigation.d.ts +0 -0
  80. package/types/src/theme/components/card.d.ts +0 -0
  81. package/types/src/theme/components/divider.d.ts +0 -0
  82. package/types/src/theme/components/fab.d.ts +0 -0
  83. package/types/src/theme/components/icon.d.ts +0 -0
  84. package/types/src/theme/components/tabs.d.ts +0 -0
  85. package/types/src/theme/components/typography.d.ts +0 -0
  86. package/types/src/theme/global/borders.d.ts +4 -3
  87. package/types/src/theme/global/colors.d.ts +2 -2
  88. package/types/src/theme/global/index.d.ts +10 -45
  89. package/types/src/theme/global/scale.d.ts +8 -0
  90. package/types/src/theme/global/space.d.ts +8 -7
  91. package/types/src/theme/global/typography.d.ts +9 -16
  92. package/types/src/theme/index.d.ts +2 -2
  93. package/types/src/types.d.ts +0 -0
  94. package/types/src/utils/__tests__/scale.spec.d.ts +0 -0
  95. package/types/src/utils/helpers.d.ts +0 -0
  96. package/types/src/utils/scale.d.ts +0 -0
  97. package/yarn-error.log +0 -140
package/lib/index.js CHANGED
@@ -1214,6 +1214,21 @@ function prefixer(element, index, children, callback) {
1214
1214
  }
1215
1215
  }
1216
1216
 
1217
+ var weakMemoize = function weakMemoize(func) {
1218
+ // $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
1219
+ var cache = new WeakMap();
1220
+ return function (arg) {
1221
+ if (cache.has(arg)) {
1222
+ // $FlowFixMe
1223
+ return cache.get(arg);
1224
+ }
1225
+
1226
+ var ret = func(arg);
1227
+ cache.set(arg, ret);
1228
+ return ret;
1229
+ };
1230
+ };
1231
+
1217
1232
  var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
1218
1233
  var previous = 0;
1219
1234
  var character = 0;
@@ -1451,21 +1466,6 @@ function _extends$1() {
1451
1466
  return _extends$1.apply(this, arguments);
1452
1467
  }
1453
1468
 
1454
- var weakMemoize = function weakMemoize(func) {
1455
- // $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
1456
- var cache = new WeakMap();
1457
- return function (arg) {
1458
- if (cache.has(arg)) {
1459
- // $FlowFixMe
1460
- return cache.get(arg);
1461
- }
1462
-
1463
- var ret = func(arg);
1464
- cache.set(arg, ret);
1465
- return ret;
1466
- };
1467
- };
1468
-
1469
1469
  var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
1470
1470
  // because this module is primarily intended for the browser and node
1471
1471
  // but it's also required in react native and similar environments sometimes
@@ -1512,6 +1512,17 @@ var ThemeProvider = function ThemeProvider(props) {
1512
1512
  }, props.children);
1513
1513
  };
1514
1514
 
1515
+ var BASE_BORDER_WIDTH = 1;
1516
+ var BASE_SPACE = 8;
1517
+ var BASE_FONT = 'BeVietnamPro';
1518
+ var BASE_FONT_SIZE = 10;
1519
+ var scale$1 = {
1520
+ borderWidth: BASE_BORDER_WIDTH,
1521
+ space: BASE_SPACE,
1522
+ font: BASE_FONT,
1523
+ fontSize: BASE_FONT_SIZE
1524
+ };
1525
+
1515
1526
  var palette = {
1516
1527
  black: '#000000',
1517
1528
  blue: '#1dbeee',
@@ -1579,6 +1590,7 @@ var palette = {
1579
1590
  smaltDark75: '#000d20',
1580
1591
  smaltLight30: '#4d72a6',
1581
1592
  smaltLight45: '#7390b9',
1593
+ smaltLight75: '#bfcddf',
1582
1594
  smaltLight90: '#e6ebf2',
1583
1595
  violet: '#7622d7',
1584
1596
  violetDark15: '#641db7',
@@ -1637,60 +1649,94 @@ var scale = function scale(size) {
1637
1649
  return size + (horizontalScale(size) - size) * factor;
1638
1650
  };
1639
1651
 
1640
- var BASE$1 = 8;
1641
- var space = {
1642
- xxsmall: scale(BASE$1 * 0.25),
1643
- xsmall: scale(BASE$1 * 0.5),
1644
- small: scale(BASE$1),
1645
- medium: scale(BASE$1 * 2),
1646
- large: scale(BASE$1 * 3),
1647
- xlarge: scale(BASE$1 * 4),
1648
- xxlarge: scale(BASE$1 * 5),
1649
- xxxlarge: scale(BASE$1 * 6),
1650
- xxxxlarge: scale(BASE$1 * 7)
1652
+ // https://www.ibm.com/design/language/typography/type-specs-ui#scales
1653
+
1654
+ var genFontSize = function genFontSize(prev, at) {
1655
+ return prev + Math.floor(Math.abs((at - 2) / 4) + 1) * 2;
1656
+ };
1657
+
1658
+ var getFonts = function getFonts(baseFont) {
1659
+ return {
1660
+ light: "".concat(baseFont, "-Light"),
1661
+ regular: "".concat(baseFont, "-Regular"),
1662
+ semiBold: "".concat(baseFont, "-SemiBold")
1663
+ };
1651
1664
  };
1652
1665
 
1653
- var BASE = 16;
1654
- var fonts = {
1655
- light: 'BeVietnamPro-Light',
1656
- regular: 'BeVietnamPro-Regular',
1657
- semiBold: 'BeVietnamPro-SemiBold'
1666
+ var getFontSizes = function getFontSizes(baseFontSize) {
1667
+ var fontSizes = Array.from(new Array(9));
1668
+ fontSizes.forEach(function (_, index) {
1669
+ if (index === 0) {
1670
+ fontSizes[0] = baseFontSize;
1671
+ } else {
1672
+ fontSizes[index] = genFontSize(fontSizes[index - 1], index);
1673
+ }
1674
+
1675
+ return undefined;
1676
+ });
1677
+ return {
1678
+ xxxxxlarge: scale(fontSizes[8]),
1679
+ xxxxlarge: scale(fontSizes[7]),
1680
+ xxxlarge: scale(fontSizes[6]),
1681
+ xxlarge: scale(fontSizes[5]),
1682
+ xlarge: scale(fontSizes[4]),
1683
+ large: scale(fontSizes[3]),
1684
+ medium: scale(fontSizes[2]),
1685
+ small: scale(fontSizes[1]),
1686
+ xsmall: scale(fontSizes[0]) // 10
1687
+
1688
+ };
1658
1689
  };
1659
- var fontSizes = {
1660
- xxxxxlarge: scale(BASE * 2),
1661
- xxxxlarge: scale(BASE * 1.75),
1662
- xxxlarge: scale(BASE * 1.5),
1663
- xxlarge: scale(BASE * 1.25),
1664
- xlarge: scale(BASE * 1.125),
1665
- large: scale(BASE),
1666
- medium: scale(BASE * 0.875),
1667
- small: scale(BASE * 0.75),
1668
- xsmall: scale(BASE * 0.625) // 10
1669
1690
 
1691
+ var getLineHeights = function getLineHeights(fontSizes) {
1692
+ var additionalSpace = 8;
1693
+ return {
1694
+ xxxxxlarge: fontSizes.xxxxxlarge + additionalSpace,
1695
+ xxxxlarge: fontSizes.xxxxlarge + additionalSpace,
1696
+ xxxlarge: fontSizes.xxxlarge + additionalSpace,
1697
+ xxlarge: fontSizes.xxlarge + additionalSpace,
1698
+ xlarge: fontSizes.xlarge + additionalSpace,
1699
+ large: fontSizes.large + additionalSpace,
1700
+ medium: fontSizes.medium + additionalSpace,
1701
+ small: fontSizes.small + additionalSpace,
1702
+ xsmall: fontSizes.xsmall + additionalSpace
1703
+ };
1670
1704
  };
1671
- var lineHeights = {
1672
- xxxxxlarge: fontSizes.xxxxxlarge + 8,
1673
- xxxxlarge: fontSizes.xxxxlarge + 8,
1674
- xxxlarge: fontSizes.xxxlarge + 8,
1675
- xxlarge: fontSizes.xxlarge + 8,
1676
- xlarge: fontSizes.xlarge + 8,
1677
- large: fontSizes.large + 8,
1678
- medium: fontSizes.medium + 8,
1679
- small: fontSizes.small + 8,
1680
- xsmall: fontSizes.xsmall + 8
1705
+
1706
+ var getSpace = function getSpace(baseSpace) {
1707
+ return {
1708
+ xxsmall: scale(baseSpace * 0.25),
1709
+ xsmall: scale(baseSpace * 0.5),
1710
+ small: scale(baseSpace),
1711
+ medium: scale(baseSpace * 2),
1712
+ large: scale(baseSpace * 3),
1713
+ xlarge: scale(baseSpace * 4),
1714
+ xxlarge: scale(baseSpace * 5),
1715
+ xxxlarge: scale(baseSpace * 6),
1716
+ xxxxlarge: scale(baseSpace * 7)
1717
+ };
1681
1718
  };
1682
1719
 
1683
- var borderWidths = {
1684
- base: 1
1720
+ var getBorderWidths = function getBorderWidths(baseBorderWidth) {
1721
+ return {
1722
+ base: baseBorderWidth
1723
+ };
1685
1724
  };
1686
1725
 
1687
- var globalTheme = {
1688
- colors: _objectSpread2({}, systemPalette),
1689
- space: space,
1690
- fonts: fonts,
1691
- fontSizes: fontSizes,
1692
- lineHeights: lineHeights,
1693
- borderWidths: borderWidths
1726
+ var getGlobalTheme = function getGlobalTheme(scale, systemPalette) {
1727
+ var fonts = getFonts(scale.font);
1728
+ var fontSizes = getFontSizes(scale.fontSize);
1729
+ var lineHeights = getLineHeights(fontSizes);
1730
+ var borderWidths = getBorderWidths(scale.borderWidth);
1731
+ var space = getSpace(scale.space);
1732
+ return {
1733
+ colors: _objectSpread2({}, systemPalette),
1734
+ fonts: fonts,
1735
+ fontSizes: fontSizes,
1736
+ lineHeights: lineHeights,
1737
+ borderWidths: borderWidths,
1738
+ space: space
1739
+ };
1694
1740
  };
1695
1741
 
1696
1742
  var getBadgeTheme = function getBadgeTheme(theme) {
@@ -1916,17 +1962,19 @@ var getFABTheme = function getFABTheme(theme) {
1916
1962
  };
1917
1963
 
1918
1964
  var getTheme = function getTheme() {
1919
- var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalTheme;
1920
- return _objectSpread2(_objectSpread2({}, theme), {}, {
1965
+ var scale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : scale$1;
1966
+ var systemPallete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : systemPalette;
1967
+ var globalTheme = getGlobalTheme(scale, systemPallete);
1968
+ return _objectSpread2(_objectSpread2({}, globalTheme), {}, {
1921
1969
  __hd__: {
1922
- badge: getBadgeTheme(theme),
1923
- bottomNavigation: getBottomNavigationTheme(theme),
1924
- card: getCardTheme(theme),
1925
- divider: getDividerTheme(theme),
1926
- icon: getIconTheme(theme),
1927
- tabs: getTabsTheme(theme),
1928
- typography: getTypographyTheme(theme),
1929
- fab: getFABTheme(theme)
1970
+ badge: getBadgeTheme(globalTheme),
1971
+ bottomNavigation: getBottomNavigationTheme(globalTheme),
1972
+ card: getCardTheme(globalTheme),
1973
+ divider: getDividerTheme(globalTheme),
1974
+ icon: getIconTheme(globalTheme),
1975
+ tabs: getTabsTheme(globalTheme),
1976
+ typography: getTypographyTheme(globalTheme),
1977
+ fab: getFABTheme(globalTheme)
1930
1978
  }
1931
1979
  });
1932
1980
  };
@@ -13666,7 +13714,7 @@ var StyledBottomBarText = index$1(Typography.Text)(function (_ref3) {
13666
13714
  var isIOS = reactNative.Platform.OS === 'ios';
13667
13715
  reactNative.Platform.OS === 'android';
13668
13716
 
13669
- var _excluded$3 = ["onChange", "renderActiveTabOnly", "selectedTabKey", "tabs"];
13717
+ var _excluded$3 = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
13670
13718
 
13671
13719
  var getInactiveIcon = function getInactiveIcon(icon) {
13672
13720
  var inactiveIcon = "".concat(icon, "-outlined");
@@ -13674,7 +13722,7 @@ var getInactiveIcon = function getInactiveIcon(icon) {
13674
13722
  };
13675
13723
 
13676
13724
  var BottomNavigation = function BottomNavigation(_ref) {
13677
- var onChange = _ref.onChange,
13725
+ var onTabPress = _ref.onTabPress,
13678
13726
  _ref$renderActiveTabO = _ref.renderActiveTabOnly,
13679
13727
  renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
13680
13728
  selectedTabKey = _ref.selectedTabKey,
@@ -13700,7 +13748,8 @@ var BottomNavigation = function BottomNavigation(_ref) {
13700
13748
 
13701
13749
  return /*#__PURE__*/React__default["default"].createElement(BottomNavigationContainer, nativeProps, /*#__PURE__*/React__default["default"].createElement(ContentWrapper$1, null, tabs.map(function (tab) {
13702
13750
  var key = tab.key,
13703
- component = tab.component;
13751
+ component = tab.component,
13752
+ testID = tab.testID;
13704
13753
  var active = selectedTabKey === key;
13705
13754
 
13706
13755
  if (renderActiveTabOnly && !active) {
@@ -13714,7 +13763,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
13714
13763
 
13715
13764
  return /*#__PURE__*/React__default["default"].createElement(BottomNavigationTab, {
13716
13765
  key: key,
13717
- testID: "route-screen-".concat(selectedTabKey),
13766
+ testID: testID ? "route-screen-".concat(testID) : undefined,
13718
13767
  pointerEvents: active ? 'auto' : 'none',
13719
13768
  accessibilityElementsHidden: !active,
13720
13769
  importantForAccessibility: active ? 'auto' : 'no-hide-descendants',
@@ -13736,9 +13785,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
13736
13785
  return /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableWithoutFeedback, {
13737
13786
  key: key,
13738
13787
  onPress: function onPress() {
13739
- if (key !== selectedTabKey) {
13740
- onChange(key);
13741
- }
13788
+ return onTabPress(key);
13742
13789
  },
13743
13790
  testID: testID
13744
13791
  }, /*#__PURE__*/React__default["default"].createElement(BottomBarItem, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
@@ -14111,10 +14158,10 @@ var StyledHeaderTabText = index$1(Typography.Text)(function (_ref6) {
14111
14158
  };
14112
14159
  });
14113
14160
 
14114
- var _excluded = ["onChange", "renderActiveTabOnly", "selectedTabKey", "tabs"];
14161
+ var _excluded = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
14115
14162
 
14116
14163
  var Tabs = function Tabs(_ref) {
14117
- var onChange = _ref.onChange,
14164
+ var onTabPress = _ref.onTabPress,
14118
14165
  _ref$renderActiveTabO = _ref.renderActiveTabOnly,
14119
14166
  renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
14120
14167
  selectedTabKey = _ref.selectedTabKey,
@@ -14132,6 +14179,21 @@ var Tabs = function Tabs(_ref) {
14132
14179
  loaded = _React$useState2[0],
14133
14180
  setLoaded = _React$useState2[1];
14134
14181
 
14182
+ React__default["default"].useEffect(function () {
14183
+ var selectedTabIndex = tabs.findIndex(function (item) {
14184
+ return item.key === selectedTabKey;
14185
+ });
14186
+
14187
+ if (selectedTabIndex !== -1) {
14188
+ var _flatListRef$current;
14189
+
14190
+ (_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
14191
+ index: selectedTabIndex,
14192
+ viewPosition: 0.5
14193
+ });
14194
+ }
14195
+ }, [selectedTabKey, tabs]);
14196
+
14135
14197
  if (!loaded.includes(selectedTabKey)) {
14136
14198
  // Set the current tab to be loaded if it was not loaded before
14137
14199
  setLoaded(function (loadedState) {
@@ -14152,17 +14214,16 @@ var Tabs = function Tabs(_ref) {
14152
14214
  onScrollToIndexFailed: function onScrollToIndexFailed(_ref2) {
14153
14215
  var index = _ref2.index;
14154
14216
  setTimeout(function () {
14155
- var _flatListRef$current;
14217
+ var _flatListRef$current2;
14156
14218
 
14157
- return (_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToIndex({
14219
+ return (_flatListRef$current2 = flatListRef.current) === null || _flatListRef$current2 === void 0 ? void 0 : _flatListRef$current2.scrollToIndex({
14158
14220
  index: index,
14159
14221
  viewPosition: 0.5
14160
14222
  });
14161
14223
  }, 100);
14162
14224
  },
14163
14225
  renderItem: function renderItem(_ref3) {
14164
- var tab = _ref3.item,
14165
- index = _ref3.index;
14226
+ var tab = _ref3.item;
14166
14227
  var key = tab.key,
14167
14228
  icon = tab.icon,
14168
14229
  title = tab.title,
@@ -14171,15 +14232,7 @@ var Tabs = function Tabs(_ref) {
14171
14232
  return /*#__PURE__*/React__default["default"].createElement(reactNative.TouchableOpacity, {
14172
14233
  key: key,
14173
14234
  onPress: function onPress() {
14174
- if (key !== selectedTabKey) {
14175
- var _flatListRef$current2;
14176
-
14177
- onChange(key);
14178
- (_flatListRef$current2 = flatListRef.current) === null || _flatListRef$current2 === void 0 ? void 0 : _flatListRef$current2.scrollToIndex({
14179
- index: index,
14180
- viewPosition: 0.5
14181
- });
14182
- }
14235
+ return onTabPress(key);
14183
14236
  },
14184
14237
  testID: testID
14185
14238
  }, /*#__PURE__*/React__default["default"].createElement(HeaderTabItem, null, /*#__PURE__*/React__default["default"].createElement(StyledHeaderTabIcon, {
@@ -14194,7 +14247,8 @@ var Tabs = function Tabs(_ref) {
14194
14247
  }
14195
14248
  })), /*#__PURE__*/React__default["default"].createElement(ContentWrapper, null, tabs.map(function (tab) {
14196
14249
  var key = tab.key,
14197
- component = tab.component;
14250
+ component = tab.component,
14251
+ testID = tab.testID;
14198
14252
  var active = selectedTabKey === key;
14199
14253
 
14200
14254
  if (renderActiveTabOnly && !active) {
@@ -14208,7 +14262,7 @@ var Tabs = function Tabs(_ref) {
14208
14262
 
14209
14263
  return /*#__PURE__*/React__default["default"].createElement(TabScreen, {
14210
14264
  key: key,
14211
- testID: "tab-screen-".concat(selectedTabKey),
14265
+ testID: testID ? "tab-screen-".concat(testID) : undefined,
14212
14266
  pointerEvents: active ? 'auto' : 'none',
14213
14267
  accessibilityElementsHidden: !active,
14214
14268
  importantForAccessibility: active ? 'auto' : 'no-hide-descendants',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.1.3-alpha7",
3
+ "version": "7.2.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@emotion/native": "^11.9.3",
22
22
  "@emotion/react": "^11.9.3",
23
- "@hero-design/colors": "7.1.2"
23
+ "@hero-design/colors": "7.2.1"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "17.0.2",
@@ -70,41 +70,5 @@
70
70
  "rollup-plugin-copy": "^3.4.0",
71
71
  "ts-jest": "^27.0.7",
72
72
  "typescript": "^4.5.5"
73
- },
74
- "nx": {
75
- "targets": {
76
- "type-check": {
77
- "dependsOn": [
78
- {
79
- "target": "build:types",
80
- "projects": "dependencies"
81
- }
82
- ]
83
- },
84
- "lint": {
85
- "dependsOn": [
86
- {
87
- "target": "build:js",
88
- "projects": "dependencies"
89
- }
90
- ]
91
- },
92
- "test:ci": {
93
- "dependsOn": [
94
- {
95
- "target": "build",
96
- "projects": "dependencies"
97
- }
98
- ]
99
- },
100
- "dev": {
101
- "dependsOn": [
102
- {
103
- "target": "build",
104
- "projects": "dependencies"
105
- }
106
- ]
107
- }
108
- }
109
73
  }
110
74
  }
@@ -62,7 +62,7 @@ const BottomNavigationPlayground = () => {
62
62
 
63
63
  return (
64
64
  <BottomNavigation
65
- onChange={newTabKey => setSelectedTabKey(newTabKey)}
65
+ onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
66
66
  selectedTabKey={selectedTabKey}
67
67
  tabs={tabs}
68
68
  />
@@ -6,7 +6,7 @@ import {
6
6
  TouchableOpacity,
7
7
  ScrollView,
8
8
  } from 'react-native';
9
- import { palette } from '@hero-design/colors';
9
+ import palette from '@hero-design/colors';
10
10
  import {
11
11
  scale,
12
12
  Card,
@@ -34,7 +34,7 @@ const TabsPlayground = () => {
34
34
 
35
35
  return (
36
36
  <Tabs
37
- onChange={newTabKey => setSelectedTabKey(newTabKey)}
37
+ onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
38
38
  selectedTabKey={selectedTabKey}
39
39
  tabs={tabs}
40
40
  />
@@ -6,8 +6,15 @@ import {
6
6
  NativeStackScreenProps,
7
7
  } from '@react-navigation/native-stack';
8
8
  import { useFonts } from 'expo-font';
9
- import { SafeAreaView, FlatList } from 'react-native';
10
- import { ThemeProvider, theme, useTheme, Typography } from '../src/index';
9
+ import { SafeAreaView, FlatList, View, TouchableOpacity } from 'react-native';
10
+ import {
11
+ ThemeProvider,
12
+ theme,
13
+ useTheme,
14
+ Typography,
15
+ Icon,
16
+ Divider,
17
+ } from '../src/index';
11
18
  import BadgePlayground from './components/Badge';
12
19
  import BottomNavigation from './components/BottomNavigation';
13
20
  import Button from './components/Button';
@@ -52,44 +59,45 @@ const components = [
52
59
  { name: 'Typography', component: TypographyPlayground },
53
60
  ] as const;
54
61
 
55
- const ComponentItem = ({
56
- name,
57
- onPress,
58
- }: {
59
- name: string;
60
- onPress: () => void;
61
- }) => {
62
+ const ComponentItem = ({ name }: { name: string }) => {
62
63
  const hdTheme = useTheme();
63
64
  return (
64
- <Typography.Text
65
- fontSize="large"
66
- onPress={onPress}
65
+ <View
67
66
  style={{
68
- marginTop: hdTheme.space.medium,
67
+ flex: 1,
68
+ flexDirection: 'row',
69
+ alignItems: 'center',
70
+ justifyContent: 'space-between',
71
+ marginHorizontal: hdTheme.space.medium,
72
+ marginVertical: hdTheme.space.medium,
69
73
  }}
70
74
  >
71
- {name}
72
- </Typography.Text>
73
- );
74
- };
75
-
76
- const ComponentList = ({ navigation }: Navigation) => {
77
- const hdTheme = useTheme();
78
- return (
79
- <SafeAreaView style={{ marginHorizontal: hdTheme.space.large }}>
80
- <FlatList
81
- data={components}
82
- renderItem={({ item }) => (
83
- <ComponentItem
84
- name={item.name}
85
- onPress={() => navigation.navigate(item.name)}
86
- />
87
- )}
75
+ <Typography.Text fontSize="large">{name}</Typography.Text>
76
+ <Icon
77
+ icon="arrow-right"
78
+ size="small"
79
+ style={{ color: hdTheme.colors.disabledText }}
88
80
  />
89
- </SafeAreaView>
81
+ </View>
90
82
  );
91
83
  };
92
84
 
85
+ const ComponentList = ({ navigation }: Navigation) => (
86
+ <SafeAreaView>
87
+ <FlatList
88
+ data={components}
89
+ renderItem={({ item }) => (
90
+ <>
91
+ <TouchableOpacity onPress={() => navigation.navigate(item.name)}>
92
+ <ComponentItem name={item.name} />
93
+ </TouchableOpacity>
94
+ <Divider marginHorizontal="small" />
95
+ </>
96
+ )}
97
+ />
98
+ </SafeAreaView>
99
+ );
100
+
93
101
  const App = () => {
94
102
  const CustomNavigationTheme = {
95
103
  ...DefaultTheme,
@@ -48,7 +48,6 @@ exports[`BottomNavigation renders correctly 1`] = `
48
48
  undefined,
49
49
  ]
50
50
  }
51
- testID="route-screen-home"
52
51
  themeVisibility={true}
53
52
  >
54
53
  <Text>
@@ -8,7 +8,7 @@ import BottomNavigation, { BottomNavigationTabType } from '..';
8
8
  const TestComponent = (
9
9
  props: Omit<
10
10
  ComponentProps<typeof BottomNavigation>,
11
- 'selectedTabKey' | 'onChange' | 'tabs'
11
+ 'selectedTabKey' | 'onTabPress' | 'tabs'
12
12
  >
13
13
  ) => {
14
14
  const [selectedTabKey, setSelectedTabKey] = React.useState('home');
@@ -50,7 +50,7 @@ const TestComponent = (
50
50
  {...props}
51
51
  tabs={tabs}
52
52
  selectedTabKey={selectedTabKey}
53
- onChange={newTabKey => setSelectedTabKey(newTabKey)}
53
+ onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
54
54
  />
55
55
  </SafeAreaProvider>
56
56
  );
@@ -29,9 +29,9 @@ export type BottomNavigationTabType = {
29
29
 
30
30
  interface BottomNavigationProps extends ViewProps {
31
31
  /**
32
- * Callback which is called on tab change, receiving id of upcoming active Tab.
32
+ * Callback which is called on tab press, receiving key of upcoming active Tab.
33
33
  */
34
- onChange: (key: string) => void;
34
+ onTabPress: (key: string) => void;
35
35
  /**
36
36
  * Whether inactive tabs should be removed and unmounted in React.
37
37
  * Defaults to `false`.
@@ -67,7 +67,7 @@ const getInactiveIcon = (icon: IconName): IconName => {
67
67
  };
68
68
 
69
69
  const BottomNavigation = ({
70
- onChange,
70
+ onTabPress,
71
71
  renderActiveTabOnly = false,
72
72
  selectedTabKey,
73
73
  tabs,
@@ -89,7 +89,7 @@ const BottomNavigation = ({
89
89
  <BottomNavigationContainer {...nativeProps}>
90
90
  <ContentWrapper>
91
91
  {tabs.map(tab => {
92
- const { key, component } = tab;
92
+ const { key, component, testID } = tab;
93
93
  const active = selectedTabKey === key;
94
94
 
95
95
  if (renderActiveTabOnly && !active) {
@@ -104,7 +104,7 @@ const BottomNavigation = ({
104
104
  return (
105
105
  <BottomNavigationTab
106
106
  key={key}
107
- testID={`route-screen-${selectedTabKey}`}
107
+ testID={testID ? `route-screen-${testID}` : undefined}
108
108
  pointerEvents={active ? 'auto' : 'none'}
109
109
  accessibilityElementsHidden={!active}
110
110
  importantForAccessibility={
@@ -133,11 +133,7 @@ const BottomNavigation = ({
133
133
  return (
134
134
  <TouchableWithoutFeedback
135
135
  key={key}
136
- onPress={() => {
137
- if (key !== selectedTabKey) {
138
- onChange(key);
139
- }
140
- }}
136
+ onPress={() => onTabPress(key)}
141
137
  testID={testID}
142
138
  >
143
139
  <BottomBarItem>
@@ -25,7 +25,7 @@ const ActionItemsListComponent = ({
25
25
  );
26
26
 
27
27
  export interface ActionGroupProps {
28
- /*
28
+ /**
29
29
  * Title of the action group header.
30
30
  */
31
31
  headerTitle?: string;
@@ -37,7 +37,6 @@ export interface ActionGroupProps {
37
37
  * Specify if the FAB button is in active state and the action group is shown.
38
38
  * */
39
39
  active?: boolean;
40
-
41
40
  /**
42
41
  * Additional style.
43
42
  */
@@ -309,7 +309,6 @@ exports[`Tabs renders correctly 1`] = `
309
309
  undefined,
310
310
  ]
311
311
  }
312
- testID="tab-screen-work"
313
312
  themeVisibility={true}
314
313
  >
315
314
  <Text>
@@ -8,7 +8,7 @@ import Tabs, { TabType } from '..';
8
8
  const TestTabsComponent = (
9
9
  props: Omit<
10
10
  ComponentProps<typeof Tabs>,
11
- 'selectedTabKey' | 'onChange' | 'tabs'
11
+ 'selectedTabKey' | 'onTabPress' | 'tabs'
12
12
  >
13
13
  ) => {
14
14
  const [selectedTabKey, setSelectedTabKey] = React.useState('work');
@@ -38,7 +38,7 @@ const TestTabsComponent = (
38
38
  {...props}
39
39
  tabs={tabs}
40
40
  selectedTabKey={selectedTabKey}
41
- onChange={newTabKey => setSelectedTabKey(newTabKey)}
41
+ onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
42
42
  />
43
43
  </SafeAreaProvider>
44
44
  );