@hero-design/rn 8.57.0 → 8.57.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.
@@ -2,4 +2,4 @@
2
2
  src/index.ts → lib/index.js, es/index.js...
3
3
  (!) 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`.
4
4
  (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
5
- created lib/index.js, es/index.js in 44.3s
5
+ created lib/index.js, es/index.js in 57.2s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.57.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2717](https://github.com/Thinkei/hero-design/pull/2717) [`7d56b99af`](https://github.com/Thinkei/hero-design/commit/7d56b99afa8cf585f78c2aba57e97817f9365441) Thanks [@ttkien](https://github.com/ttkien)! - refactor card carousel to reduce cognitive comlexity to 15
8
+
9
+ - [#2738](https://github.com/Thinkei/hero-design/pull/2738) [`819421b35`](https://github.com/Thinkei/hero-design/commit/819421b357b3e87f36326759c636b9958622215c) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - Upgrade Expo SDK to 49
10
+
11
+ - [#2719](https://github.com/Thinkei/hero-design/pull/2719) [`6985126e1`](https://github.com/Thinkei/hero-design/commit/6985126e14c4a1e43d9daf029afcbf21937d040e) Thanks [@ttkien](https://github.com/ttkien)! - [TextInput] refactor code
12
+
13
+ - [#2716](https://github.com/Thinkei/hero-design/pull/2716) [`481838499`](https://github.com/Thinkei/hero-design/commit/4818384992a154a309b6c66099069822082f2f77) Thanks [@phucdph](https://github.com/phucdph)! - Fix typing issue
14
+
15
+ - Updated dependencies [[`819421b35`](https://github.com/Thinkei/hero-design/commit/819421b357b3e87f36326759c636b9958622215c)]:
16
+ - @hero-design/react-native-month-year-picker@8.42.7
17
+
3
18
  ## 8.57.0
4
19
 
5
20
  ### Minor Changes
package/es/index.js CHANGED
@@ -12039,6 +12039,9 @@ var ITEM_WIDTH_RATE = 0.85;
12039
12039
  */
12040
12040
  var VIEW_POSITION_CENTER = 0.5;
12041
12041
 
12042
+ var getCardCarouselValidIndex = function getCardCarouselValidIndex(index, length) {
12043
+ return Math.min(Math.max(index, 0), length - 1);
12044
+ };
12042
12045
  var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
12043
12046
  var onItemIndexChange = _ref.onItemIndexChange,
12044
12047
  items = _ref.items,
@@ -12065,18 +12068,13 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
12065
12068
  var viewPosition = Platform.OS === 'ios' ? VIEW_POSITION_CENTER : undefined;
12066
12069
  var _snapToIndex = useCallback(function (index) {
12067
12070
  var _carouselRef$current;
12068
- var validIndex = 0;
12069
- if (index >= items.length) {
12070
- validIndex = items.length - 1;
12071
- } else if (index >= 0) {
12072
- validIndex = index;
12073
- }
12071
+ var validIndex = getCardCarouselValidIndex(index, items.length);
12074
12072
  (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 || _carouselRef$current.scrollToIndex({
12075
12073
  index: validIndex,
12076
12074
  animated: true,
12077
12075
  viewPosition: viewPosition
12078
12076
  });
12079
- }, [carouselRef, itemWidth]);
12077
+ }, [items.length, viewPosition]);
12080
12078
  /*
12081
12079
  * snap to the next index. If the curent index is the last one, snap to the first one.
12082
12080
  */
@@ -12091,7 +12089,7 @@ var CardCarousel = /*#__PURE__*/forwardRef(function (_ref, ref) {
12091
12089
  animated: true,
12092
12090
  viewPosition: viewPosition
12093
12091
  });
12094
- }, [carouselRef, currentIndex, itemWidth, items.length]);
12092
+ }, [currentIndex, items.length, viewPosition]);
12095
12093
  React.useImperativeHandle(ref, function () {
12096
12094
  return {
12097
12095
  snapToIndex: function snapToIndex(index) {
@@ -12846,38 +12844,96 @@ var getState$1 = function getState(_ref) {
12846
12844
  // https://github.com/callstack/react-native-paper/pull/3331
12847
12845
  var EMPTY_PLACEHOLDER_VALUE = ' ';
12848
12846
  var LABEL_ANIMATION_DURATION = 150;
12849
- var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
12850
- var _ref3;
12851
- var label = _ref2.label,
12852
- prefix = _ref2.prefix,
12853
- suffix = _ref2.suffix,
12854
- style = _ref2.style,
12855
- textStyle = _ref2.textStyle,
12856
- testID = _ref2.testID,
12857
- accessibilityLabelledBy = _ref2.accessibilityLabelledBy,
12858
- error = _ref2.error,
12859
- required = _ref2.required,
12860
- _ref2$editable = _ref2.editable,
12861
- editable = _ref2$editable === void 0 ? true : _ref2$editable,
12862
- _ref2$disabled = _ref2.disabled,
12863
- disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
12864
- _ref2$loading = _ref2.loading,
12865
- loading = _ref2$loading === void 0 ? false : _ref2$loading,
12866
- maxLength = _ref2.maxLength,
12867
- _ref2$hideCharacterCo = _ref2.hideCharacterCount,
12868
- hideCharacterCount = _ref2$hideCharacterCo === void 0 ? false : _ref2$hideCharacterCo,
12869
- helpText = _ref2.helpText,
12870
- value = _ref2.value,
12871
- defaultValue = _ref2.defaultValue,
12872
- renderInputValue = _ref2.renderInputValue,
12873
- _ref2$allowFontScalin = _ref2.allowFontScaling,
12874
- allowFontScaling = _ref2$allowFontScalin === void 0 ? false : _ref2$allowFontScalin,
12875
- _ref2$variant = _ref2.variant,
12876
- variant = _ref2$variant === void 0 ? 'text' : _ref2$variant,
12877
- nativeProps = _objectWithoutProperties(_ref2, _excluded$j);
12878
- var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
12879
- var isEmptyValue = displayText.length === 0;
12847
+ var renderErrorOrHelpText = function renderErrorOrHelpText(_ref2) {
12848
+ var error = _ref2.error,
12849
+ helpText = _ref2.helpText;
12850
+ return error ? /*#__PURE__*/React.createElement(StyledErrorContainer$2, null, /*#__PURE__*/React.createElement(Icon, {
12851
+ testID: "input-error-icon",
12852
+ icon: "circle-info",
12853
+ size: "xsmall",
12854
+ intent: "danger"
12855
+ }), /*#__PURE__*/React.createElement(StyledError, {
12856
+ testID: "input-error-message"
12857
+ }, error)) : !!helpText && /*#__PURE__*/React.createElement(StyledHelperText, null, helpText);
12858
+ };
12859
+ var renderInput = function renderInput(_ref3) {
12860
+ var variant = _ref3.variant,
12861
+ nativeInputProps = _ref3.nativeInputProps,
12862
+ renderInputValue = _ref3.renderInputValue,
12863
+ ref = _ref3.ref;
12864
+ return renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React.createElement(StyledTextInput, _extends$1({}, nativeInputProps, {
12865
+ themeVariant: variant,
12866
+ multiline: variant === 'textarea' || nativeInputProps.multiline,
12867
+ ref: ref
12868
+ }));
12869
+ };
12870
+ var renderSuffix = function renderSuffix(_ref4) {
12871
+ var state = _ref4.state,
12872
+ loading = _ref4.loading,
12873
+ suffix = _ref4.suffix;
12880
12874
  var actualSuffix = loading ? 'loading' : suffix;
12875
+ return typeof actualSuffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
12876
+ intent: state === 'disabled' ? 'disabled-text' : 'text',
12877
+ testID: "input-suffix",
12878
+ icon: actualSuffix,
12879
+ spin: actualSuffix === 'loading',
12880
+ size: "medium"
12881
+ }) : suffix;
12882
+ };
12883
+ var renderPrefix = function renderPrefix(_ref5) {
12884
+ var state = _ref5.state,
12885
+ prefix = _ref5.prefix;
12886
+ return typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
12887
+ intent: state === 'disabled' ? 'disabled-text' : 'text',
12888
+ testID: "input-prefix",
12889
+ icon: prefix,
12890
+ size: "xsmall"
12891
+ }) : prefix;
12892
+ };
12893
+ var renderMaxLengthMessage = function renderMaxLengthMessage(_ref6) {
12894
+ var maxLength = _ref6.maxLength,
12895
+ state = _ref6.state,
12896
+ currentLength = _ref6.currentLength,
12897
+ hideCharacterCount = _ref6.hideCharacterCount;
12898
+ var shouldShowMaxLength = maxLength !== undefined && !hideCharacterCount;
12899
+ return shouldShowMaxLength && /*#__PURE__*/React.createElement(StyledMaxLengthMessage, {
12900
+ themeState: state
12901
+ }, currentLength, "/", maxLength);
12902
+ };
12903
+ var getDisplayText = function getDisplayText(value, defaultValue) {
12904
+ var _ref7;
12905
+ return (_ref7 = value !== undefined ? value : defaultValue) !== null && _ref7 !== void 0 ? _ref7 : '';
12906
+ };
12907
+ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
12908
+ var label = _ref8.label,
12909
+ prefix = _ref8.prefix,
12910
+ suffix = _ref8.suffix,
12911
+ style = _ref8.style,
12912
+ textStyle = _ref8.textStyle,
12913
+ testID = _ref8.testID,
12914
+ accessibilityLabelledBy = _ref8.accessibilityLabelledBy,
12915
+ error = _ref8.error,
12916
+ required = _ref8.required,
12917
+ _ref8$editable = _ref8.editable,
12918
+ editable = _ref8$editable === void 0 ? true : _ref8$editable,
12919
+ _ref8$disabled = _ref8.disabled,
12920
+ disabled = _ref8$disabled === void 0 ? false : _ref8$disabled,
12921
+ _ref8$loading = _ref8.loading,
12922
+ loading = _ref8$loading === void 0 ? false : _ref8$loading,
12923
+ maxLength = _ref8.maxLength,
12924
+ _ref8$hideCharacterCo = _ref8.hideCharacterCount,
12925
+ hideCharacterCount = _ref8$hideCharacterCo === void 0 ? false : _ref8$hideCharacterCo,
12926
+ helpText = _ref8.helpText,
12927
+ value = _ref8.value,
12928
+ defaultValue = _ref8.defaultValue,
12929
+ renderInputValue = _ref8.renderInputValue,
12930
+ _ref8$allowFontScalin = _ref8.allowFontScaling,
12931
+ allowFontScaling = _ref8$allowFontScalin === void 0 ? false : _ref8$allowFontScalin,
12932
+ _ref8$variant = _ref8.variant,
12933
+ variant = _ref8$variant === void 0 ? 'text' : _ref8$variant,
12934
+ nativeProps = _objectWithoutProperties(_ref8, _excluded$j);
12935
+ var displayText = getDisplayText(value, defaultValue);
12936
+ var isEmptyValue = displayText.length === 0;
12881
12937
  var _React$useState = React.useState({
12882
12938
  height: 0,
12883
12939
  width: 0
@@ -12905,7 +12961,6 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
12905
12961
  isFocused: isFocused,
12906
12962
  isEmptyValue: isEmptyValue
12907
12963
  });
12908
- var shouldShowMaxLength = maxLength !== undefined && !hideCharacterCount;
12909
12964
  var theme = useTheme();
12910
12965
  var focusAnimation = useRef(new Animated.Value(0)).current;
12911
12966
  useEffect(function () {
@@ -13043,12 +13098,10 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
13043
13098
  }, borderStyle]
13044
13099
  }), /*#__PURE__*/React.createElement(View, {
13045
13100
  onLayout: onPrefixLayout
13046
- }, typeof prefix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
13047
- intent: state === 'disabled' ? 'disabled-text' : 'text',
13048
- testID: "input-prefix",
13049
- icon: prefix,
13050
- size: "xsmall"
13051
- }) : prefix), /*#__PURE__*/React.createElement(StyledLabelContainerInsideTextInput, {
13101
+ }, renderPrefix({
13102
+ state: state,
13103
+ prefix: prefix
13104
+ })), /*#__PURE__*/React.createElement(StyledLabelContainerInsideTextInput, {
13052
13105
  themeVariant: variant,
13053
13106
  pointerEvents: "none",
13054
13107
  style: [{
@@ -13085,28 +13138,26 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref2, ref) {
13085
13138
  testID: "input-label",
13086
13139
  themeState: state,
13087
13140
  onLayout: onLabelLayout
13088
- }, label)), /*#__PURE__*/React.createElement(StyledTextInputAndLabelContainer, null, renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React.createElement(StyledTextInput, _extends$1({}, nativeInputProps, {
13089
- themeVariant: variant,
13090
- multiline: variant === 'textarea' || nativeProps.multiline,
13091
- ref: function ref(reference) {
13092
- innerTextInput.current = reference;
13141
+ }, label)), /*#__PURE__*/React.createElement(StyledTextInputAndLabelContainer, null, renderInput({
13142
+ variant: variant,
13143
+ nativeInputProps: nativeInputProps,
13144
+ renderInputValue: renderInputValue,
13145
+ ref: function ref(rnTextInputRef) {
13146
+ innerTextInput.current = rnTextInputRef;
13093
13147
  }
13094
- }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React.createElement(Icon, {
13095
- intent: state === 'disabled' ? 'disabled-text' : 'text',
13096
- testID: "input-suffix",
13097
- icon: actualSuffix,
13098
- spin: actualSuffix === 'loading',
13099
- size: "medium"
13100
- }) : suffix), /*#__PURE__*/React.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React.createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React.createElement(StyledErrorContainer$2, null, /*#__PURE__*/React.createElement(Icon, {
13101
- testID: "input-error-icon",
13102
- icon: "circle-info",
13103
- size: "xsmall",
13104
- intent: "danger"
13105
- }), /*#__PURE__*/React.createElement(StyledError, {
13106
- testID: "input-error-message"
13107
- }, error)) : !!helpText && /*#__PURE__*/React.createElement(StyledHelperText, null, helpText), shouldShowMaxLength && /*#__PURE__*/React.createElement(StyledMaxLengthMessage, {
13108
- themeState: state
13109
- }, displayText.length, "/", maxLength))));
13148
+ })), renderSuffix({
13149
+ state: state,
13150
+ loading: loading,
13151
+ suffix: suffix
13152
+ })), /*#__PURE__*/React.createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React.createElement(StyledErrorAndMaxLengthContainer, null, renderErrorOrHelpText({
13153
+ error: error,
13154
+ helpText: helpText
13155
+ }), renderMaxLengthMessage({
13156
+ state: state,
13157
+ currentLength: displayText.length,
13158
+ maxLength: maxLength,
13159
+ hideCharacterCount: hideCharacterCount
13160
+ }))));
13110
13161
  });
13111
13162
 
13112
13163
  var getDateValue = function getDateValue(value, minDate, maxDate) {
@@ -14791,13 +14842,30 @@ var CTAWrapper = index$9(TouchableOpacity)(function (_ref6) {
14791
14842
  };
14792
14843
  });
14793
14844
 
14794
- var ToastContext = /*#__PURE__*/createContext({});
14845
+ var fallbackToastControlContext = {
14846
+ show: function show(_) {
14847
+ return '';
14848
+ },
14849
+ hide: function hide(_) {
14850
+ // Fallback empty function
14851
+ },
14852
+ clearAll: function clearAll() {
14853
+ // Fallback empty function
14854
+ }
14855
+ };
14856
+ var ToastContext = /*#__PURE__*/createContext(fallbackToastControlContext);
14795
14857
  var ToastConfigContext = /*#__PURE__*/createContext({});
14796
14858
  var useToastConfig = function useToastConfig() {
14797
14859
  return useContext(ToastConfigContext);
14798
14860
  };
14799
14861
  var useToast = function useToast() {
14800
- return useContext(ToastContext);
14862
+ var context = useContext(ToastContext);
14863
+ if (!context) {
14864
+ // eslint-disable-next-line no-console
14865
+ console.warn('Toast was used without ToastProvider');
14866
+ return fallbackToastControlContext;
14867
+ }
14868
+ return context;
14801
14869
  };
14802
14870
 
14803
14871
  var getIntentIcon = function getIntentIcon(intent) {
@@ -14996,8 +15064,7 @@ var ToastProvider = function ToastProvider(_ref) {
14996
15064
  var position = _position === undefined ? 'bottom' : _position;
14997
15065
  useDeprecation("Toast's position prop is deprecated and will be removed in the next major release.\nPlease remove it.", _position !== undefined);
14998
15066
  var toastRef = useRef(null);
14999
- // @ts-expect-error: TODO: @tungv Fix this type error
15000
- var _useState = useState(null),
15067
+ var _useState = useState(),
15001
15068
  _useState2 = _slicedToArray(_useState, 2),
15002
15069
  refState = _useState2[0],
15003
15070
  setRefState = _useState2[1];
@@ -15013,7 +15080,7 @@ var ToastProvider = function ToastProvider(_ref) {
15013
15080
  };
15014
15081
  }, [displayType, position]);
15015
15082
  return /*#__PURE__*/React.createElement(ToastContext.Provider, {
15016
- value: refState
15083
+ value: refState || fallbackToastControlContext
15017
15084
  }, /*#__PURE__*/React.createElement(View, {
15018
15085
  style: {
15019
15086
  flex: 1
package/lib/index.js CHANGED
@@ -12069,6 +12069,9 @@ var ITEM_WIDTH_RATE = 0.85;
12069
12069
  */
12070
12070
  var VIEW_POSITION_CENTER = 0.5;
12071
12071
 
12072
+ var getCardCarouselValidIndex = function getCardCarouselValidIndex(index, length) {
12073
+ return Math.min(Math.max(index, 0), length - 1);
12074
+ };
12072
12075
  var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12073
12076
  var onItemIndexChange = _ref.onItemIndexChange,
12074
12077
  items = _ref.items,
@@ -12095,18 +12098,13 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12095
12098
  var viewPosition = reactNative.Platform.OS === 'ios' ? VIEW_POSITION_CENTER : undefined;
12096
12099
  var _snapToIndex = React.useCallback(function (index) {
12097
12100
  var _carouselRef$current;
12098
- var validIndex = 0;
12099
- if (index >= items.length) {
12100
- validIndex = items.length - 1;
12101
- } else if (index >= 0) {
12102
- validIndex = index;
12103
- }
12101
+ var validIndex = getCardCarouselValidIndex(index, items.length);
12104
12102
  (_carouselRef$current = carouselRef.current) === null || _carouselRef$current === void 0 || _carouselRef$current.scrollToIndex({
12105
12103
  index: validIndex,
12106
12104
  animated: true,
12107
12105
  viewPosition: viewPosition
12108
12106
  });
12109
- }, [carouselRef, itemWidth]);
12107
+ }, [items.length, viewPosition]);
12110
12108
  /*
12111
12109
  * snap to the next index. If the curent index is the last one, snap to the first one.
12112
12110
  */
@@ -12121,7 +12119,7 @@ var CardCarousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12121
12119
  animated: true,
12122
12120
  viewPosition: viewPosition
12123
12121
  });
12124
- }, [carouselRef, currentIndex, itemWidth, items.length]);
12122
+ }, [currentIndex, items.length, viewPosition]);
12125
12123
  React__default["default"].useImperativeHandle(ref, function () {
12126
12124
  return {
12127
12125
  snapToIndex: function snapToIndex(index) {
@@ -12876,38 +12874,96 @@ var getState$1 = function getState(_ref) {
12876
12874
  // https://github.com/callstack/react-native-paper/pull/3331
12877
12875
  var EMPTY_PLACEHOLDER_VALUE = ' ';
12878
12876
  var LABEL_ANIMATION_DURATION = 150;
12879
- var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
12880
- var _ref3;
12881
- var label = _ref2.label,
12882
- prefix = _ref2.prefix,
12883
- suffix = _ref2.suffix,
12884
- style = _ref2.style,
12885
- textStyle = _ref2.textStyle,
12886
- testID = _ref2.testID,
12887
- accessibilityLabelledBy = _ref2.accessibilityLabelledBy,
12888
- error = _ref2.error,
12889
- required = _ref2.required,
12890
- _ref2$editable = _ref2.editable,
12891
- editable = _ref2$editable === void 0 ? true : _ref2$editable,
12892
- _ref2$disabled = _ref2.disabled,
12893
- disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
12894
- _ref2$loading = _ref2.loading,
12895
- loading = _ref2$loading === void 0 ? false : _ref2$loading,
12896
- maxLength = _ref2.maxLength,
12897
- _ref2$hideCharacterCo = _ref2.hideCharacterCount,
12898
- hideCharacterCount = _ref2$hideCharacterCo === void 0 ? false : _ref2$hideCharacterCo,
12899
- helpText = _ref2.helpText,
12900
- value = _ref2.value,
12901
- defaultValue = _ref2.defaultValue,
12902
- renderInputValue = _ref2.renderInputValue,
12903
- _ref2$allowFontScalin = _ref2.allowFontScaling,
12904
- allowFontScaling = _ref2$allowFontScalin === void 0 ? false : _ref2$allowFontScalin,
12905
- _ref2$variant = _ref2.variant,
12906
- variant = _ref2$variant === void 0 ? 'text' : _ref2$variant,
12907
- nativeProps = _objectWithoutProperties(_ref2, _excluded$j);
12908
- var displayText = (_ref3 = value !== undefined ? value : defaultValue) !== null && _ref3 !== void 0 ? _ref3 : '';
12909
- var isEmptyValue = displayText.length === 0;
12877
+ var renderErrorOrHelpText = function renderErrorOrHelpText(_ref2) {
12878
+ var error = _ref2.error,
12879
+ helpText = _ref2.helpText;
12880
+ return error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
12881
+ testID: "input-error-icon",
12882
+ icon: "circle-info",
12883
+ size: "xsmall",
12884
+ intent: "danger"
12885
+ }), /*#__PURE__*/React__default["default"].createElement(StyledError, {
12886
+ testID: "input-error-message"
12887
+ }, error)) : !!helpText && /*#__PURE__*/React__default["default"].createElement(StyledHelperText, null, helpText);
12888
+ };
12889
+ var renderInput = function renderInput(_ref3) {
12890
+ var variant = _ref3.variant,
12891
+ nativeInputProps = _ref3.nativeInputProps,
12892
+ renderInputValue = _ref3.renderInputValue,
12893
+ ref = _ref3.ref;
12894
+ return renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React__default["default"].createElement(StyledTextInput, _extends$1({}, nativeInputProps, {
12895
+ themeVariant: variant,
12896
+ multiline: variant === 'textarea' || nativeInputProps.multiline,
12897
+ ref: ref
12898
+ }));
12899
+ };
12900
+ var renderSuffix = function renderSuffix(_ref4) {
12901
+ var state = _ref4.state,
12902
+ loading = _ref4.loading,
12903
+ suffix = _ref4.suffix;
12910
12904
  var actualSuffix = loading ? 'loading' : suffix;
12905
+ return typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
12906
+ intent: state === 'disabled' ? 'disabled-text' : 'text',
12907
+ testID: "input-suffix",
12908
+ icon: actualSuffix,
12909
+ spin: actualSuffix === 'loading',
12910
+ size: "medium"
12911
+ }) : suffix;
12912
+ };
12913
+ var renderPrefix = function renderPrefix(_ref5) {
12914
+ var state = _ref5.state,
12915
+ prefix = _ref5.prefix;
12916
+ return typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
12917
+ intent: state === 'disabled' ? 'disabled-text' : 'text',
12918
+ testID: "input-prefix",
12919
+ icon: prefix,
12920
+ size: "xsmall"
12921
+ }) : prefix;
12922
+ };
12923
+ var renderMaxLengthMessage = function renderMaxLengthMessage(_ref6) {
12924
+ var maxLength = _ref6.maxLength,
12925
+ state = _ref6.state,
12926
+ currentLength = _ref6.currentLength,
12927
+ hideCharacterCount = _ref6.hideCharacterCount;
12928
+ var shouldShowMaxLength = maxLength !== undefined && !hideCharacterCount;
12929
+ return shouldShowMaxLength && /*#__PURE__*/React__default["default"].createElement(StyledMaxLengthMessage, {
12930
+ themeState: state
12931
+ }, currentLength, "/", maxLength);
12932
+ };
12933
+ var getDisplayText = function getDisplayText(value, defaultValue) {
12934
+ var _ref7;
12935
+ return (_ref7 = value !== undefined ? value : defaultValue) !== null && _ref7 !== void 0 ? _ref7 : '';
12936
+ };
12937
+ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
12938
+ var label = _ref8.label,
12939
+ prefix = _ref8.prefix,
12940
+ suffix = _ref8.suffix,
12941
+ style = _ref8.style,
12942
+ textStyle = _ref8.textStyle,
12943
+ testID = _ref8.testID,
12944
+ accessibilityLabelledBy = _ref8.accessibilityLabelledBy,
12945
+ error = _ref8.error,
12946
+ required = _ref8.required,
12947
+ _ref8$editable = _ref8.editable,
12948
+ editable = _ref8$editable === void 0 ? true : _ref8$editable,
12949
+ _ref8$disabled = _ref8.disabled,
12950
+ disabled = _ref8$disabled === void 0 ? false : _ref8$disabled,
12951
+ _ref8$loading = _ref8.loading,
12952
+ loading = _ref8$loading === void 0 ? false : _ref8$loading,
12953
+ maxLength = _ref8.maxLength,
12954
+ _ref8$hideCharacterCo = _ref8.hideCharacterCount,
12955
+ hideCharacterCount = _ref8$hideCharacterCo === void 0 ? false : _ref8$hideCharacterCo,
12956
+ helpText = _ref8.helpText,
12957
+ value = _ref8.value,
12958
+ defaultValue = _ref8.defaultValue,
12959
+ renderInputValue = _ref8.renderInputValue,
12960
+ _ref8$allowFontScalin = _ref8.allowFontScaling,
12961
+ allowFontScaling = _ref8$allowFontScalin === void 0 ? false : _ref8$allowFontScalin,
12962
+ _ref8$variant = _ref8.variant,
12963
+ variant = _ref8$variant === void 0 ? 'text' : _ref8$variant,
12964
+ nativeProps = _objectWithoutProperties(_ref8, _excluded$j);
12965
+ var displayText = getDisplayText(value, defaultValue);
12966
+ var isEmptyValue = displayText.length === 0;
12911
12967
  var _React$useState = React__default["default"].useState({
12912
12968
  height: 0,
12913
12969
  width: 0
@@ -12935,7 +12991,6 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
12935
12991
  isFocused: isFocused,
12936
12992
  isEmptyValue: isEmptyValue
12937
12993
  });
12938
- var shouldShowMaxLength = maxLength !== undefined && !hideCharacterCount;
12939
12994
  var theme = useTheme();
12940
12995
  var focusAnimation = React.useRef(new reactNative.Animated.Value(0)).current;
12941
12996
  React.useEffect(function () {
@@ -13073,12 +13128,10 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
13073
13128
  }, borderStyle]
13074
13129
  }), /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
13075
13130
  onLayout: onPrefixLayout
13076
- }, typeof prefix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
13077
- intent: state === 'disabled' ? 'disabled-text' : 'text',
13078
- testID: "input-prefix",
13079
- icon: prefix,
13080
- size: "xsmall"
13081
- }) : prefix), /*#__PURE__*/React__default["default"].createElement(StyledLabelContainerInsideTextInput, {
13131
+ }, renderPrefix({
13132
+ state: state,
13133
+ prefix: prefix
13134
+ })), /*#__PURE__*/React__default["default"].createElement(StyledLabelContainerInsideTextInput, {
13082
13135
  themeVariant: variant,
13083
13136
  pointerEvents: "none",
13084
13137
  style: [{
@@ -13115,28 +13168,26 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
13115
13168
  testID: "input-label",
13116
13169
  themeState: state,
13117
13170
  onLayout: onLabelLayout
13118
- }, label)), /*#__PURE__*/React__default["default"].createElement(StyledTextInputAndLabelContainer, null, renderInputValue ? renderInputValue(nativeInputProps) : /*#__PURE__*/React__default["default"].createElement(StyledTextInput, _extends$1({}, nativeInputProps, {
13119
- themeVariant: variant,
13120
- multiline: variant === 'textarea' || nativeProps.multiline,
13121
- ref: function ref(reference) {
13122
- innerTextInput.current = reference;
13171
+ }, label)), /*#__PURE__*/React__default["default"].createElement(StyledTextInputAndLabelContainer, null, renderInput({
13172
+ variant: variant,
13173
+ nativeInputProps: nativeInputProps,
13174
+ renderInputValue: renderInputValue,
13175
+ ref: function ref(rnTextInputRef) {
13176
+ innerTextInput.current = rnTextInputRef;
13123
13177
  }
13124
- }))), typeof actualSuffix === 'string' ? /*#__PURE__*/React__default["default"].createElement(Icon, {
13125
- intent: state === 'disabled' ? 'disabled-text' : 'text',
13126
- testID: "input-suffix",
13127
- icon: actualSuffix,
13128
- spin: actualSuffix === 'loading',
13129
- size: "medium"
13130
- }) : suffix), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, error ? /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$2, null, /*#__PURE__*/React__default["default"].createElement(Icon, {
13131
- testID: "input-error-icon",
13132
- icon: "circle-info",
13133
- size: "xsmall",
13134
- intent: "danger"
13135
- }), /*#__PURE__*/React__default["default"].createElement(StyledError, {
13136
- testID: "input-error-message"
13137
- }, error)) : !!helpText && /*#__PURE__*/React__default["default"].createElement(StyledHelperText, null, helpText), shouldShowMaxLength && /*#__PURE__*/React__default["default"].createElement(StyledMaxLengthMessage, {
13138
- themeState: state
13139
- }, displayText.length, "/", maxLength))));
13178
+ })), renderSuffix({
13179
+ state: state,
13180
+ loading: loading,
13181
+ suffix: suffix
13182
+ })), /*#__PURE__*/React__default["default"].createElement(StyledErrorAndHelpTextContainer, null, /*#__PURE__*/React__default["default"].createElement(StyledErrorAndMaxLengthContainer, null, renderErrorOrHelpText({
13183
+ error: error,
13184
+ helpText: helpText
13185
+ }), renderMaxLengthMessage({
13186
+ state: state,
13187
+ currentLength: displayText.length,
13188
+ maxLength: maxLength,
13189
+ hideCharacterCount: hideCharacterCount
13190
+ }))));
13140
13191
  });
13141
13192
 
13142
13193
  var getDateValue = function getDateValue(value, minDate, maxDate) {
@@ -14821,13 +14872,30 @@ var CTAWrapper = index$9(reactNative.TouchableOpacity)(function (_ref6) {
14821
14872
  };
14822
14873
  });
14823
14874
 
14824
- var ToastContext = /*#__PURE__*/React.createContext({});
14875
+ var fallbackToastControlContext = {
14876
+ show: function show(_) {
14877
+ return '';
14878
+ },
14879
+ hide: function hide(_) {
14880
+ // Fallback empty function
14881
+ },
14882
+ clearAll: function clearAll() {
14883
+ // Fallback empty function
14884
+ }
14885
+ };
14886
+ var ToastContext = /*#__PURE__*/React.createContext(fallbackToastControlContext);
14825
14887
  var ToastConfigContext = /*#__PURE__*/React.createContext({});
14826
14888
  var useToastConfig = function useToastConfig() {
14827
14889
  return React.useContext(ToastConfigContext);
14828
14890
  };
14829
14891
  var useToast = function useToast() {
14830
- return React.useContext(ToastContext);
14892
+ var context = React.useContext(ToastContext);
14893
+ if (!context) {
14894
+ // eslint-disable-next-line no-console
14895
+ console.warn('Toast was used without ToastProvider');
14896
+ return fallbackToastControlContext;
14897
+ }
14898
+ return context;
14831
14899
  };
14832
14900
 
14833
14901
  var getIntentIcon = function getIntentIcon(intent) {
@@ -15026,8 +15094,7 @@ var ToastProvider = function ToastProvider(_ref) {
15026
15094
  var position = _position === undefined ? 'bottom' : _position;
15027
15095
  useDeprecation("Toast's position prop is deprecated and will be removed in the next major release.\nPlease remove it.", _position !== undefined);
15028
15096
  var toastRef = React.useRef(null);
15029
- // @ts-expect-error: TODO: @tungv Fix this type error
15030
- var _useState = React.useState(null),
15097
+ var _useState = React.useState(),
15031
15098
  _useState2 = _slicedToArray(_useState, 2),
15032
15099
  refState = _useState2[0],
15033
15100
  setRefState = _useState2[1];
@@ -15043,7 +15110,7 @@ var ToastProvider = function ToastProvider(_ref) {
15043
15110
  };
15044
15111
  }, [displayType, position]);
15045
15112
  return /*#__PURE__*/React__default["default"].createElement(ToastContext.Provider, {
15046
- value: refState
15113
+ value: refState || fallbackToastControlContext
15047
15114
  }, /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
15048
15115
  style: {
15049
15116
  flex: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.57.0",
3
+ "version": "8.57.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,13 +24,12 @@
24
24
  "@emotion/react": "^11.9.3",
25
25
  "@hero-design/colors": "8.42.5",
26
26
  "date-fns": "^2.16.1",
27
- "events": "^3.2.0",
28
27
  "hero-editor": "^1.9.21",
29
28
  "nanoid": "^4.0.2"
30
29
  },
31
30
  "peerDependencies": {
32
- "@hero-design/react-native-month-year-picker": "^8.42.6",
33
- "@react-native-community/datetimepicker": "^3.5.2",
31
+ "@hero-design/react-native-month-year-picker": "^8.42.7",
32
+ "@react-native-community/datetimepicker": "^3.5.2 || ^7.2.0",
34
33
  "@react-native-community/slider": "4.4.3",
35
34
  "react": "18.2.0",
36
35
  "react-native": "^0.71.0",
@@ -49,8 +48,8 @@
49
48
  "@babel/runtime": "^7.20.0",
50
49
  "@emotion/jest": "^11.11.0",
51
50
  "@hero-design/eslint-plugin": "9.0.0",
52
- "@hero-design/react-native-month-year-picker": "^8.42.6",
53
- "@react-native-community/datetimepicker": "3.5.2",
51
+ "@hero-design/react-native-month-year-picker": "^8.42.7",
52
+ "@react-native-community/datetimepicker": "7.2.0",
54
53
  "@react-native-community/slider": "4.4.3",
55
54
  "@rollup/plugin-babel": "^5.3.1",
56
55
  "@rollup/plugin-commonjs": "^21.0.1",
@@ -60,6 +59,7 @@
60
59
  "@rollup/plugin-typescript": "^8.3.0",
61
60
  "@testing-library/jest-native": "^5.4.2",
62
61
  "@testing-library/react-native": "^9.1.0",
62
+ "@types/events": "^3.0.3",
63
63
  "@types/jest": "^29.5.3",
64
64
  "@types/react": "^18.2.0",
65
65
  "@types/react-native-vector-icons": "^6.4.10",