@hero-design/rn 8.2.1 → 8.2.3

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 (47) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +165 -52
  3. package/lib/index.js +163 -50
  4. package/package.json +5 -5
  5. package/src/components/BottomSheet/BottomSheetContext.ts +11 -0
  6. package/src/components/BottomSheet/ScrollView.tsx +57 -0
  7. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +9 -24
  8. package/src/components/BottomSheet/__tests__/index.spec.tsx +17 -0
  9. package/src/components/BottomSheet/index.tsx +21 -8
  10. package/src/components/Box/StyledBox.tsx +8 -6
  11. package/src/components/Card/StyledCard.tsx +1 -1
  12. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +74 -0
  13. package/src/components/Card/__tests__/index.spec.tsx +2 -0
  14. package/src/components/Card/index.tsx +1 -1
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +0 -24
  16. package/src/components/Icon/index.tsx +28 -2
  17. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +0 -72
  18. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +0 -36
  19. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +160 -0
  20. package/src/components/TextInput/__tests__/index.spec.tsx +50 -3
  21. package/src/components/TextInput/index.tsx +65 -30
  22. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +0 -24
  23. package/src/components/Toolbar/ToolbarGroup.tsx +20 -14
  24. package/src/components/Toolbar/ToolbarItem.tsx +9 -1
  25. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -0
  26. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +6 -0
  27. package/src/types.ts +4 -1
  28. package/src/utils/__tests__/helpers.spec.ts +22 -4
  29. package/src/utils/helpers.ts +10 -9
  30. package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +1 -1
  31. package/types/components/BottomSheet/BottomSheetContext.d.ts +5 -0
  32. package/types/components/BottomSheet/ScrollView.d.ts +3 -0
  33. package/types/components/BottomSheet/index.d.ts +5 -3
  34. package/types/components/Box/StyledBox.d.ts +2 -2
  35. package/types/components/Button/StyledButton.d.ts +1 -1
  36. package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
  37. package/types/components/Card/StyledCard.d.ts +1 -1
  38. package/types/components/Card/index.d.ts +1 -1
  39. package/types/components/Checkbox/StyledCheckbox.d.ts +1 -1
  40. package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -1
  41. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +1 -1
  42. package/types/components/Icon/index.d.ts +3 -3
  43. package/types/components/TextInput/StyledTextInput.d.ts +7 -7
  44. package/types/components/TextInput/index.d.ts +25 -3
  45. package/types/components/Toolbar/ToolbarItem.d.ts +6 -1
  46. package/types/types.d.ts +3 -2
  47. package/types/utils/helpers.d.ts +2 -2
package/lib/index.js CHANGED
@@ -5730,7 +5730,7 @@ var StyledText$3 = index$a(reactNative.Text)(function (_ref) {
5730
5730
  });
5731
5731
  });
5732
5732
 
5733
- var _excluded$j = ["children", "fontSize", "fontWeight", "intent", "typeface"];
5733
+ var _excluded$k = ["children", "fontSize", "fontWeight", "intent", "typeface"];
5734
5734
  var Text = function Text(_ref) {
5735
5735
  var children = _ref.children,
5736
5736
  _ref$fontSize = _ref.fontSize,
@@ -5741,7 +5741,7 @@ var Text = function Text(_ref) {
5741
5741
  intent = _ref$intent === void 0 ? 'body' : _ref$intent,
5742
5742
  _ref$typeface = _ref.typeface,
5743
5743
  typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
5744
- nativeProps = _objectWithoutProperties(_ref, _excluded$j);
5744
+ nativeProps = _objectWithoutProperties(_ref, _excluded$k);
5745
5745
  return /*#__PURE__*/React__default["default"].createElement(StyledText$3, _extends$1({}, nativeProps, {
5746
5746
  themeFontSize: fontSize,
5747
5747
  themeFontWeight: fontWeight,
@@ -6220,10 +6220,10 @@ var StyledHeroIcon = index$a(HeroIcon)(function (_ref) {
6220
6220
  };
6221
6221
  });
6222
6222
 
6223
- var _excluded$i = ["style"];
6223
+ var _excluded$j = ["style"];
6224
6224
  var AnimatedIcon = function AnimatedIcon(_ref) {
6225
6225
  var style = _ref.style,
6226
- otherProps = _objectWithoutProperties(_ref, _excluded$i);
6226
+ otherProps = _objectWithoutProperties(_ref, _excluded$j);
6227
6227
  var rotateAnimation = React.useRef(new reactNative.Animated.Value(0));
6228
6228
  React.useEffect(function () {
6229
6229
  var animation = reactNative.Animated.loop(reactNative.Animated.timing(rotateAnimation.current, {
@@ -6259,21 +6259,45 @@ var Icon = function Icon(_ref) {
6259
6259
  intent = _ref$intent === void 0 ? 'text' : _ref$intent,
6260
6260
  testID = _ref.testID,
6261
6261
  _ref$spin = _ref.spin,
6262
- spin = _ref$spin === void 0 ? false : _ref$spin;
6262
+ spin = _ref$spin === void 0 ? false : _ref$spin,
6263
+ accessibilityLabel = _ref.accessibilityLabel,
6264
+ accessibilityHint = _ref.accessibilityHint,
6265
+ accessibilityRole = _ref.accessibilityRole,
6266
+ accessibilityState = _ref.accessibilityState,
6267
+ accessibilityValue = _ref.accessibilityValue,
6268
+ accessibilityLiveRegion = _ref.accessibilityLiveRegion,
6269
+ accessibilityElementsHidden = _ref.accessibilityElementsHidden,
6270
+ accessible = _ref.accessible,
6271
+ accessibilityIgnoresInvertColors = _ref.accessibilityIgnoresInvertColors,
6272
+ accessibilityViewIsModal = _ref.accessibilityViewIsModal,
6273
+ accessibilityActions = _ref.accessibilityActions;
6263
6274
  useDeprecation("".concat(icon, " icon is deprecated and will be removed in the next major release, please use ").concat(icon.replace('carat', 'caret'), " instead."), icon.startsWith('carat'));
6264
- return spin ? /*#__PURE__*/React__default["default"].createElement(AnimatedIcon, {
6275
+ var accessibilityProps = {
6276
+ accessibilityLabel: accessibilityLabel,
6277
+ accessibilityHint: accessibilityHint,
6278
+ accessibilityRole: accessibilityRole,
6279
+ accessibilityState: accessibilityState,
6280
+ accessibilityValue: accessibilityValue,
6281
+ accessibilityLiveRegion: accessibilityLiveRegion,
6282
+ accessibilityElementsHidden: accessibilityElementsHidden,
6283
+ accessible: accessible,
6284
+ accessibilityIgnoresInvertColors: accessibilityIgnoresInvertColors,
6285
+ accessibilityViewIsModal: accessibilityViewIsModal,
6286
+ accessibilityActions: accessibilityActions
6287
+ };
6288
+ return spin ? /*#__PURE__*/React__default["default"].createElement(AnimatedIcon, _extends$1({
6265
6289
  name: icon,
6266
6290
  themeIntent: intent,
6267
6291
  themeSize: size,
6268
6292
  style: style,
6269
6293
  testID: testID
6270
- }) : /*#__PURE__*/React__default["default"].createElement(StyledHeroIcon, {
6294
+ }, accessibilityProps)) : /*#__PURE__*/React__default["default"].createElement(StyledHeroIcon, _extends$1({
6271
6295
  name: icon,
6272
6296
  themeIntent: intent,
6273
6297
  themeSize: size,
6274
6298
  style: style,
6275
6299
  testID: testID
6276
- });
6300
+ }, accessibilityProps));
6277
6301
  };
6278
6302
  Icon.List = IconList;
6279
6303
 
@@ -6305,7 +6329,7 @@ var AccordionItem = function AccordionItem(_ref) {
6305
6329
  }, content));
6306
6330
  };
6307
6331
 
6308
- var _excluded$h = ["key"];
6332
+ var _excluded$i = ["key"];
6309
6333
  var Accordion = function Accordion(_ref) {
6310
6334
  var items = _ref.items,
6311
6335
  activeItemKey = _ref.activeItemKey,
@@ -6326,7 +6350,7 @@ var Accordion = function Accordion(_ref) {
6326
6350
  testID: testID
6327
6351
  }, items.map(function (_ref2, index) {
6328
6352
  var key = _ref2.key,
6329
- props = _objectWithoutProperties(_ref2, _excluded$h);
6353
+ props = _objectWithoutProperties(_ref2, _excluded$i);
6330
6354
  var open = _activeItemKey === key;
6331
6355
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
6332
6356
  key: key
@@ -6708,7 +6732,7 @@ var StyledStatus = index$a(reactNative.Animated.View)(function (_ref3) {
6708
6732
  };
6709
6733
  });
6710
6734
 
6711
- var _excluded$g = ["children", "visible", "intent", "style", "testID"];
6735
+ var _excluded$h = ["children", "visible", "intent", "style", "testID"];
6712
6736
  var Status = function Status(_ref) {
6713
6737
  var children = _ref.children,
6714
6738
  _ref$visible = _ref.visible,
@@ -6717,7 +6741,7 @@ var Status = function Status(_ref) {
6717
6741
  intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
6718
6742
  style = _ref.style,
6719
6743
  testID = _ref.testID,
6720
- nativeProps = _objectWithoutProperties(_ref, _excluded$g);
6744
+ nativeProps = _objectWithoutProperties(_ref, _excluded$h);
6721
6745
  var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
6722
6746
  opacity = _React$useRef.current;
6723
6747
  var isFirstRendering = React__default["default"].useRef(true);
@@ -6750,7 +6774,7 @@ var Status = function Status(_ref) {
6750
6774
  }));
6751
6775
  };
6752
6776
 
6753
- var _excluded$f = ["content", "visible", "max", "intent", "style", "testID"];
6777
+ var _excluded$g = ["content", "visible", "max", "intent", "style", "testID"];
6754
6778
  var DEFAULT_MAX_NUMBER = 99;
6755
6779
  var getPaddingState = function getPaddingState(content) {
6756
6780
  return content.length > 1 ? 'wideContent' : 'narrowContent';
@@ -6765,7 +6789,7 @@ var Badge = function Badge(_ref) {
6765
6789
  intent = _ref$intent === void 0 ? 'danger' : _ref$intent,
6766
6790
  style = _ref.style,
6767
6791
  testID = _ref.testID,
6768
- nativeProps = _objectWithoutProperties(_ref, _excluded$f);
6792
+ nativeProps = _objectWithoutProperties(_ref, _excluded$g);
6769
6793
  var _React$useRef = React__default["default"].useRef(new reactNative.Animated.Value(visible ? 1 : 0)),
6770
6794
  opacity = _React$useRef.current;
6771
6795
  var isFirstRendering = React__default["default"].useRef(true);
@@ -6854,22 +6878,22 @@ var StyledBottomBarText = index$a(Typography.Text)(function (_ref3) {
6854
6878
 
6855
6879
  var isIOS = reactNative.Platform.OS === 'ios';
6856
6880
  var isAndroid = reactNative.Platform.OS === 'android';
6857
- var pick = function pick(keys, props) {
6881
+ function pick(keys, obj) {
6858
6882
  return keys.filter(function (key) {
6859
- return key in props;
6883
+ return key in obj;
6860
6884
  }).reduce(function (result, cur) {
6861
- return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, props[cur]));
6885
+ return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, obj[cur]));
6862
6886
  }, {});
6863
- };
6864
- var omit = function omit(keys, props) {
6865
- var result = props;
6887
+ }
6888
+ function omit(keys, obj) {
6889
+ var result = obj;
6866
6890
  keys.forEach(function (key) {
6867
6891
  delete result[key];
6868
6892
  });
6869
6893
  return result;
6870
- };
6894
+ }
6871
6895
 
6872
- var _excluded$e = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
6896
+ var _excluded$f = ["onTabPress", "renderActiveTabOnly", "selectedTabKey", "tabs"];
6873
6897
  var getInactiveIcon = function getInactiveIcon(icon) {
6874
6898
  var inactiveIcon = "".concat(icon, "-outlined");
6875
6899
  return isHeroIcon(inactiveIcon) ? inactiveIcon : icon;
@@ -6880,7 +6904,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
6880
6904
  renderActiveTabOnly = _ref$renderActiveTabO === void 0 ? false : _ref$renderActiveTabO,
6881
6905
  selectedTabKey = _ref.selectedTabKey,
6882
6906
  tabs = _ref.tabs,
6883
- nativeProps = _objectWithoutProperties(_ref, _excluded$e);
6907
+ nativeProps = _objectWithoutProperties(_ref, _excluded$f);
6884
6908
  var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
6885
6909
  /**
6886
6910
  * List of loaded tabs, tabs will be loaded when navigated to.
@@ -6948,6 +6972,8 @@ var BottomNavigation = function BottomNavigation(_ref) {
6948
6972
  }))));
6949
6973
  };
6950
6974
 
6975
+ var BottomSheetContext = /*#__PURE__*/React.createContext({});
6976
+
6951
6977
  var StyledDivider = index$a(reactNative.View)(function (_ref) {
6952
6978
  var themeMarginHorizontal = _ref.themeMarginHorizontal,
6953
6979
  themeMarginVertical = _ref.themeMarginVertical,
@@ -6965,13 +6991,13 @@ var StyledDivider = index$a(reactNative.View)(function (_ref) {
6965
6991
  }, horizontalMargin), verticalMargin);
6966
6992
  });
6967
6993
 
6968
- var _excluded$d = ["marginHorizontal", "marginVertical", "style", "testID"];
6994
+ var _excluded$e = ["marginHorizontal", "marginVertical", "style", "testID"];
6969
6995
  var Divider = function Divider(_ref) {
6970
6996
  var marginHorizontal = _ref.marginHorizontal,
6971
6997
  marginVertical = _ref.marginVertical,
6972
6998
  style = _ref.style,
6973
6999
  testID = _ref.testID,
6974
- nativeProps = _objectWithoutProperties(_ref, _excluded$d);
7000
+ nativeProps = _objectWithoutProperties(_ref, _excluded$e);
6975
7001
  return /*#__PURE__*/React__default["default"].createElement(StyledDivider, _extends$1({}, nativeProps, {
6976
7002
  themeMarginHorizontal: marginHorizontal,
6977
7003
  themeMarginVertical: marginVertical,
@@ -7101,7 +7127,7 @@ var StyledLoadingDot = index$a(reactNative.View)(function (_ref2) {
7101
7127
  }, themeStyling());
7102
7128
  });
7103
7129
 
7104
- var _excluded$c = ["count", "size", "testID", "themeVariant"];
7130
+ var _excluded$d = ["count", "size", "testID", "themeVariant"];
7105
7131
  var AnimatedLoadingIndicatorWrapper = reactNative.Animated.createAnimatedComponent(StyledLoadingIndicatorWrapper);
7106
7132
  var AnimatedLoadingDot = reactNative.Animated.createAnimatedComponent(StyledLoadingDot);
7107
7133
  var renderDotComponent = function renderDotComponent(_ref) {
@@ -7133,7 +7159,7 @@ var LoadingIndicator = function LoadingIndicator(_ref2) {
7133
7159
  size = _ref2$size === void 0 ? 12 : _ref2$size,
7134
7160
  testID = _ref2.testID,
7135
7161
  themeVariant = _ref2.themeVariant,
7136
- nativeProps = _objectWithoutProperties(_ref2, _excluded$c);
7162
+ nativeProps = _objectWithoutProperties(_ref2, _excluded$d);
7137
7163
  var progressAnimation = React.useRef(new reactNative.Animated.Value(0));
7138
7164
  React.useEffect(function () {
7139
7165
  var animation = reactNative.Animated.loop(reactNative.Animated.timing(progressAnimation.current, {
@@ -7529,6 +7555,36 @@ var Header = function Header(_ref) {
7529
7555
  })) : null), showDivider ? /*#__PURE__*/React__default["default"].createElement(Divider, null) : null);
7530
7556
  };
7531
7557
 
7558
+ var _excluded$c = ["scrollEventThrottle"];
7559
+ var BottomSheetScrollView = function BottomSheetScrollView(_ref) {
7560
+ var _ref$scrollEventThrot = _ref.scrollEventThrottle,
7561
+ scrollEventThrottle = _ref$scrollEventThrot === void 0 ? 100 : _ref$scrollEventThrot,
7562
+ props = _objectWithoutProperties(_ref, _excluded$c);
7563
+ var _useContext = React.useContext(BottomSheetContext),
7564
+ setInternalShowDivider = _useContext.setInternalShowDivider;
7565
+ var onScrollBeginDrag = React.useCallback(function (e) {
7566
+ var _props$onScrollBeginD;
7567
+ setInternalShowDivider(true);
7568
+ props === null || props === void 0 ? void 0 : (_props$onScrollBeginD = props.onScrollBeginDrag) === null || _props$onScrollBeginD === void 0 ? void 0 : _props$onScrollBeginD.call(props, e);
7569
+ }, []);
7570
+ var onMomentumScrollBegin = React.useCallback(function (e) {
7571
+ var _props$onMomentumScro;
7572
+ setInternalShowDivider(true);
7573
+ props === null || props === void 0 ? void 0 : (_props$onMomentumScro = props.onMomentumScrollEnd) === null || _props$onMomentumScro === void 0 ? void 0 : _props$onMomentumScro.call(props, e);
7574
+ }, []);
7575
+ var onMomentumScrollEnd = React.useCallback(function (e) {
7576
+ var _props$onMomentumScro2;
7577
+ setInternalShowDivider(false);
7578
+ props === null || props === void 0 ? void 0 : (_props$onMomentumScro2 = props.onMomentumScrollEnd) === null || _props$onMomentumScro2 === void 0 ? void 0 : _props$onMomentumScro2.call(props, e);
7579
+ }, []);
7580
+ return /*#__PURE__*/React__default["default"].createElement(reactNative.ScrollView, _extends$1({}, props, {
7581
+ onScrollBeginDrag: onScrollBeginDrag,
7582
+ onMomentumScrollBegin: onMomentumScrollBegin,
7583
+ onMomentumScrollEnd: onMomentumScrollEnd,
7584
+ scrollEventThrottle: scrollEventThrottle
7585
+ }));
7586
+ };
7587
+
7532
7588
  var BottomSheet = function BottomSheet(_ref) {
7533
7589
  var open = _ref.open,
7534
7590
  header = _ref.header,
@@ -7543,7 +7599,7 @@ var BottomSheet = function BottomSheet(_ref) {
7543
7599
  _ref$hasBackdrop = _ref.hasBackdrop,
7544
7600
  hasBackdrop = _ref$hasBackdrop === void 0 ? true : _ref$hasBackdrop,
7545
7601
  _ref$showDivider = _ref.showDivider,
7546
- showDivider = _ref$showDivider === void 0 ? true : _ref$showDivider,
7602
+ showDivider = _ref$showDivider === void 0 ? false : _ref$showDivider,
7547
7603
  style = _ref.style,
7548
7604
  testID = _ref.testID,
7549
7605
  _ref$keyboardAvoiding = _ref.keyboardAvoidingViewProps,
@@ -7556,6 +7612,10 @@ var BottomSheet = function BottomSheet(_ref) {
7556
7612
  visible = _useState2[0],
7557
7613
  setVisibility = _useState2[1];
7558
7614
  var animatedValue = React.useRef(new reactNative.Animated.Value(open ? 0 : 1));
7615
+ var _useState3 = React.useState(showDivider),
7616
+ _useState4 = _slicedToArray(_useState3, 2),
7617
+ internalShowDivider = _useState4[0],
7618
+ setInternalShowDivider = _useState4[1];
7559
7619
  React.useEffect(function () {
7560
7620
  // Show the modal before the open animation start
7561
7621
  if (open && !visible) {
@@ -7596,6 +7656,11 @@ var BottomSheet = function BottomSheet(_ref) {
7596
7656
  inputRange: [0, 1],
7597
7657
  outputRange: [0, 0.48]
7598
7658
  }) : 0;
7659
+ var BottomSheetContextValue = React.useMemo(function () {
7660
+ return {
7661
+ setInternalShowDivider: setInternalShowDivider
7662
+ };
7663
+ }, [setInternalShowDivider]);
7599
7664
  return /*#__PURE__*/React__default["default"].createElement(reactNative.Modal, {
7600
7665
  visible: visible,
7601
7666
  onRequestClose: onRequestClose,
@@ -7621,13 +7686,18 @@ var BottomSheet = function BottomSheet(_ref) {
7621
7686
  }]
7622
7687
  }, header !== undefined ? /*#__PURE__*/React__default["default"].createElement(Header, {
7623
7688
  content: header,
7624
- showDivider: showDivider,
7689
+ showDivider: internalShowDivider,
7625
7690
  onRequestClose: onRequestClose,
7626
7691
  showCloseButton: showCloseButton
7627
- }) : null, children, footer ? /*#__PURE__*/React__default["default"].createElement(Footer$1, {
7692
+ }) : null, /*#__PURE__*/React__default["default"].createElement(BottomSheetContext.Provider, {
7693
+ value: BottomSheetContextValue
7694
+ }, children), footer ? /*#__PURE__*/React__default["default"].createElement(Footer$1, {
7628
7695
  showDivider: showDivider
7629
7696
  }, footer) : null))));
7630
7697
  };
7698
+ var BottomSheet$1 = Object.assign(BottomSheet, {
7699
+ ScrollView: BottomSheetScrollView
7700
+ });
7631
7701
 
7632
7702
  var colors = {
7633
7703
  backgroundColor: {
@@ -10710,7 +10780,7 @@ var getVariant$1 = function getVariant(_ref) {
10710
10780
  // Fix issue: Placeholder is not shown on iOS when multiline is true
10711
10781
  // https://github.com/callstack/react-native-paper/pull/3331
10712
10782
  var EMPTY_PLACEHOLDER_VALUE = ' ';
10713
- var TextInput = function TextInput(_ref2) {
10783
+ var TextInput = function TextInput(_ref2, ref) {
10714
10784
  var _ref3;
10715
10785
  var label = _ref2.label,
10716
10786
  prefix = _ref2.prefix,
@@ -10750,6 +10820,35 @@ var TextInput = function TextInput(_ref2) {
10750
10820
  });
10751
10821
  var shouldShowMaxLength = maxLength !== undefined;
10752
10822
  var theme = useTheme();
10823
+ var innerTextInput = React__default["default"].useRef();
10824
+ React__default["default"].useImperativeHandle(ref, function () {
10825
+ return {
10826
+ // we don't expose this method, it's for testing https://medium.com/developer-rants/how-to-test-useref-without-mocking-useref-699165f4994e
10827
+ getNativeTextInputRef: function getNativeTextInputRef() {
10828
+ return innerTextInput.current;
10829
+ },
10830
+ focus: function focus() {
10831
+ var _innerTextInput$curre;
10832
+ (_innerTextInput$curre = innerTextInput.current) === null || _innerTextInput$curre === void 0 ? void 0 : _innerTextInput$curre.focus();
10833
+ },
10834
+ clear: function clear() {
10835
+ var _innerTextInput$curre2;
10836
+ return (_innerTextInput$curre2 = innerTextInput.current) === null || _innerTextInput$curre2 === void 0 ? void 0 : _innerTextInput$curre2.clear();
10837
+ },
10838
+ setNativeProps: function setNativeProps(args) {
10839
+ var _innerTextInput$curre3;
10840
+ return (_innerTextInput$curre3 = innerTextInput.current) === null || _innerTextInput$curre3 === void 0 ? void 0 : _innerTextInput$curre3.setNativeProps(args);
10841
+ },
10842
+ isFocused: function isFocused() {
10843
+ var _innerTextInput$curre4;
10844
+ return ((_innerTextInput$curre4 = innerTextInput.current) === null || _innerTextInput$curre4 === void 0 ? void 0 : _innerTextInput$curre4.isFocused()) || false;
10845
+ },
10846
+ blur: function blur() {
10847
+ var _innerTextInput$curre5;
10848
+ return (_innerTextInput$curre5 = innerTextInput.current) === null || _innerTextInput$curre5 === void 0 ? void 0 : _innerTextInput$curre5.blur();
10849
+ }
10850
+ };
10851
+ }, [innerTextInput]);
10753
10852
  var _useMemo = React.useMemo(function () {
10754
10853
  if (!textStyle) {
10755
10854
  return {};
@@ -10829,7 +10928,11 @@ var TextInput = function TextInput(_ref2) {
10829
10928
  testID: "input-label",
10830
10929
  fontSize: "medium",
10831
10930
  themeVariant: variant
10832
- }, label)), renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React__default["default"].createElement(StyledTextInput, nativeInputProps)), typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
10931
+ }, label)), renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React__default["default"].createElement(StyledTextInput, _extends$1({}, nativeInputProps, {
10932
+ ref: function ref(reference) {
10933
+ innerTextInput.current = reference;
10934
+ }
10935
+ }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
10833
10936
  intent: variant === 'disabled' ? 'disabled-text' : 'text',
10834
10937
  testID: "input-suffix",
10835
10938
  icon: actualSuffix,
@@ -10847,6 +10950,7 @@ var TextInput = function TextInput(_ref2) {
10847
10950
  fontSize: "small"
10848
10951
  }, displayText.length, "/", maxLength)), !!helpText && /*#__PURE__*/React__default["default"].createElement(StyledHelperText, null, helpText)));
10849
10952
  };
10953
+ var TextInput$1 = /*#__PURE__*/React__default["default"].forwardRef(TextInput);
10850
10954
 
10851
10955
  var DatePickerAndroid = function DatePickerAndroid(_ref) {
10852
10956
  var value = _ref.value,
@@ -10878,7 +10982,7 @@ var DatePickerAndroid = function DatePickerAndroid(_ref) {
10878
10982
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
10879
10983
  pointerEvents: "none",
10880
10984
  testID: "datePickerInputAndroid"
10881
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
10985
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
10882
10986
  label: label,
10883
10987
  value: displayValue,
10884
10988
  suffix: "calendar-dates-outlined",
@@ -10946,7 +11050,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
10946
11050
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
10947
11051
  pointerEvents: "none",
10948
11052
  testID: "datePickerInputIOS"
10949
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
11053
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
10950
11054
  label: label,
10951
11055
  value: displayValue,
10952
11056
  suffix: "calendar-dates-outlined",
@@ -10957,7 +11061,7 @@ var DatePickerIOS = function DatePickerIOS(_ref) {
10957
11061
  helpText: helpText,
10958
11062
  testID: testID,
10959
11063
  style: style
10960
- })), /*#__PURE__*/React__default["default"].createElement(BottomSheet, {
11064
+ })), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
10961
11065
  open: open,
10962
11066
  onRequestClose: function onRequestClose() {
10963
11067
  return setOpen(false);
@@ -13012,7 +13116,7 @@ function MultiSelect(_ref) {
13012
13116
  }
13013
13117
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13014
13118
  pointerEvents: "none"
13015
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, _extends$1({}, inputProps, {
13119
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, _extends$1({}, inputProps, {
13016
13120
  label: label,
13017
13121
  value: displayedValue,
13018
13122
  suffix: "arrow-down",
@@ -13027,7 +13131,7 @@ function MultiSelect(_ref) {
13027
13131
  renderInputValue: renderSelectedValue !== undefined ? function (props) {
13028
13132
  return renderSelectedValue(value, props);
13029
13133
  } : undefined
13030
- }))))), /*#__PURE__*/React__default["default"].createElement(BottomSheet, {
13134
+ }))))), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
13031
13135
  open: open,
13032
13136
  onRequestClose: function onRequestClose() {
13033
13137
  return setOpen(false);
@@ -13060,7 +13164,7 @@ function MultiSelect(_ref) {
13060
13164
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13061
13165
  }
13062
13166
  }
13063
- }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput, {
13167
+ }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
13064
13168
  editable: true,
13065
13169
  placeholder: "Search",
13066
13170
  suffix: "search-outlined",
@@ -13188,7 +13292,7 @@ var SingleSelect = function SingleSelect(_ref) {
13188
13292
  }
13189
13293
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13190
13294
  pointerEvents: "none"
13191
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, _extends$1({}, inputProps, {
13295
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, _extends$1({}, inputProps, {
13192
13296
  label: label,
13193
13297
  value: displayedValue,
13194
13298
  suffix: "arrow-down",
@@ -13203,7 +13307,7 @@ var SingleSelect = function SingleSelect(_ref) {
13203
13307
  renderInputValue: renderSelectedValue !== undefined ? function (props) {
13204
13308
  return renderSelectedValue(value, props);
13205
13309
  } : undefined
13206
- }))))), /*#__PURE__*/React__default["default"].createElement(BottomSheet, {
13310
+ }))))), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
13207
13311
  open: open,
13208
13312
  onRequestClose: function onRequestClose() {
13209
13313
  return setOpen(false);
@@ -13220,7 +13324,7 @@ var SingleSelect = function SingleSelect(_ref) {
13220
13324
  (_sectionListRef$curre = sectionListRef.current) === null || _sectionListRef$curre === void 0 ? void 0 : _sectionListRef$curre.scrollToLocation(scrollParams);
13221
13325
  }
13222
13326
  }
13223
- }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput, {
13327
+ }, onQueryChange && /*#__PURE__*/React__default["default"].createElement(StyledSearchBar, null, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
13224
13328
  editable: true,
13225
13329
  placeholder: "Search",
13226
13330
  suffix: "search-outlined",
@@ -13961,7 +14065,7 @@ var TimePickerAndroid = function TimePickerAndroid(_ref) {
13961
14065
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13962
14066
  pointerEvents: "none",
13963
14067
  testID: "timePickerInputAndroid"
13964
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
14068
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
13965
14069
  label: label,
13966
14070
  value: displayValue,
13967
14071
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -14029,7 +14133,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
14029
14133
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
14030
14134
  pointerEvents: "none",
14031
14135
  testID: "timePickerInputIOS"
14032
- }, /*#__PURE__*/React__default["default"].createElement(TextInput, {
14136
+ }, /*#__PURE__*/React__default["default"].createElement(TextInput$1, {
14033
14137
  label: label,
14034
14138
  value: displayValue,
14035
14139
  suffix: showSuffix ? 'clock-3' : undefined,
@@ -14040,7 +14144,7 @@ var TimePickerIOS = function TimePickerIOS(_ref) {
14040
14144
  helpText: helpText,
14041
14145
  testID: testID,
14042
14146
  style: style
14043
- })), /*#__PURE__*/React__default["default"].createElement(BottomSheet, {
14147
+ })), /*#__PURE__*/React__default["default"].createElement(BottomSheet$1, {
14044
14148
  open: open,
14045
14149
  onRequestClose: function onRequestClose() {
14046
14150
  return setOpen(false);
@@ -14429,10 +14533,12 @@ var ToolbarItem = function ToolbarItem(_ref) {
14429
14533
  _ref$intent = _ref.intent,
14430
14534
  intent = _ref$intent === void 0 ? 'primary' : _ref$intent,
14431
14535
  _ref$disabled = _ref.disabled,
14432
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
14536
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
14537
+ style = _ref.style;
14433
14538
  return /*#__PURE__*/React__default["default"].createElement(ToolbarItemWrapper, {
14434
14539
  onPress: onPress,
14435
- disabled: disabled
14540
+ disabled: disabled,
14541
+ style: style
14436
14542
  }, icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
14437
14543
  icon: icon,
14438
14544
  size: label ? 'medium' : 'large',
@@ -14441,7 +14547,8 @@ var ToolbarItem = function ToolbarItem(_ref) {
14441
14547
  }) : null, label ? /*#__PURE__*/React__default["default"].createElement(Typography.Text, {
14442
14548
  fontSize: icon ? 'small' : 'large',
14443
14549
  fontWeight: "semi-bold",
14444
- intent: disabled ? 'subdued' : intent
14550
+ intent: disabled ? 'subdued' : intent,
14551
+ maxFontSizeMultiplier: 2
14445
14552
  }, label) : null);
14446
14553
  };
14447
14554
 
@@ -14450,6 +14557,9 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
14450
14557
  align = _ref$align === void 0 ? 'right' : _ref$align,
14451
14558
  _ref$items = _ref.items,
14452
14559
  items = _ref$items === void 0 ? [] : _ref$items;
14560
+ // set maxWidth prevents overflow of items
14561
+ // issue: https://github.com/Thinkei/hero-design/issues/1619
14562
+ var maxWidth = items.length > 0 ? "".concat(100 / items.length, "%") : undefined;
14453
14563
  return /*#__PURE__*/React__default["default"].createElement(ToolbarGroupWrapper, {
14454
14564
  align: align
14455
14565
  }, items.map(function (_ref2) {
@@ -14464,7 +14574,10 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
14464
14574
  icon: icon,
14465
14575
  intent: intent,
14466
14576
  onPress: onPress,
14467
- disabled: disabled
14577
+ disabled: disabled,
14578
+ style: {
14579
+ maxWidth: maxWidth
14580
+ }
14468
14581
  });
14469
14582
  }));
14470
14583
  };
@@ -30869,7 +30982,7 @@ exports.Attachment = Attachment;
30869
30982
  exports.Avatar = index$9;
30870
30983
  exports.Badge = Badge$1;
30871
30984
  exports.BottomNavigation = BottomNavigation;
30872
- exports.BottomSheet = BottomSheet;
30985
+ exports.BottomSheet = BottomSheet$1;
30873
30986
  exports.Box = Box;
30874
30987
  exports.Button = CompoundButton;
30875
30988
  exports.Calendar = Calendar;
@@ -30898,7 +31011,7 @@ exports.Swipeable = index$5;
30898
31011
  exports.Switch = index$3;
30899
31012
  exports.Tabs = index$2;
30900
31013
  exports.Tag = Tag;
30901
- exports.TextInput = TextInput;
31014
+ exports.TextInput = TextInput$1;
30902
31015
  exports.ThemeProvider = ThemeProvider;
30903
31016
  exports.ThemeSwitcher = ThemeSwitcher;
30904
31017
  exports.TimePicker = TimePicker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.2.1",
3
+ "version": "8.2.3",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/react": "^11.9.3",
24
- "@hero-design/colors": "8.2.1",
24
+ "@hero-design/colors": "8.2.3",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21"
@@ -44,7 +44,7 @@
44
44
  "@babel/preset-typescript": "^7.17.12",
45
45
  "@babel/runtime": "^7.18.9",
46
46
  "@emotion/jest": "^11.9.3",
47
- "@hero-design/eslint-plugin": "8.2.1",
47
+ "@hero-design/eslint-plugin": "8.2.3",
48
48
  "@react-native-community/datetimepicker": "^3.5.2",
49
49
  "@react-native-community/slider": "4.1.12",
50
50
  "@rollup/plugin-babel": "^5.3.1",
@@ -60,9 +60,9 @@
60
60
  "@types/react-native": "^0.67.7",
61
61
  "@types/react-native-vector-icons": "^6.4.10",
62
62
  "babel-plugin-inline-import": "^3.0.0",
63
- "eslint-config-hd": "8.2.1",
63
+ "eslint-config-hd": "8.2.3",
64
64
  "jest": "^27.3.1",
65
- "prettier-config-hd": "8.2.1",
65
+ "prettier-config-hd": "8.2.3",
66
66
  "react": "18.0.0",
67
67
  "react-native": "0.69.7",
68
68
  "react-native-gesture-handler": "~2.1.0",
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+
3
+ export type BottomSheetContextType = {
4
+ setInternalShowDivider: (value: boolean) => void;
5
+ };
6
+
7
+ const BottomSheetContext = createContext<BottomSheetContextType>(
8
+ {} as BottomSheetContextType
9
+ );
10
+
11
+ export default BottomSheetContext;
@@ -0,0 +1,57 @@
1
+ import React, { useContext, useCallback } from 'react';
2
+ import {
3
+ NativeScrollEvent,
4
+ NativeSyntheticEvent,
5
+ ScrollView,
6
+ ScrollViewProps,
7
+ } from 'react-native';
8
+ import BottomSheetContext, {
9
+ BottomSheetContextType,
10
+ } from './BottomSheetContext';
11
+
12
+ const BottomSheetScrollView = ({
13
+ scrollEventThrottle = 100,
14
+ ...props
15
+ }: ScrollViewProps): JSX.Element => {
16
+ const { setInternalShowDivider } =
17
+ useContext<BottomSheetContextType>(BottomSheetContext);
18
+
19
+ const onScrollBeginDrag = useCallback(
20
+ (e: NativeSyntheticEvent<NativeScrollEvent>) => {
21
+ setInternalShowDivider(true);
22
+
23
+ props?.onScrollBeginDrag?.(e);
24
+ },
25
+ []
26
+ );
27
+
28
+ const onMomentumScrollBegin = useCallback(
29
+ (e: NativeSyntheticEvent<NativeScrollEvent>) => {
30
+ setInternalShowDivider(true);
31
+
32
+ props?.onMomentumScrollEnd?.(e);
33
+ },
34
+ []
35
+ );
36
+
37
+ const onMomentumScrollEnd = useCallback(
38
+ (e: NativeSyntheticEvent<NativeScrollEvent>) => {
39
+ setInternalShowDivider(false);
40
+
41
+ props?.onMomentumScrollEnd?.(e);
42
+ },
43
+ []
44
+ );
45
+
46
+ return (
47
+ <ScrollView
48
+ {...props}
49
+ onScrollBeginDrag={onScrollBeginDrag}
50
+ onMomentumScrollBegin={onMomentumScrollBegin}
51
+ onMomentumScrollEnd={onMomentumScrollEnd}
52
+ scrollEventThrottle={scrollEventThrottle}
53
+ />
54
+ );
55
+ };
56
+
57
+ export default BottomSheetScrollView;