@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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +15 -0
- package/es/index.js +139 -72
- package/lib/index.js +139 -72
- package/package.json +6 -6
- package/src/components/Calendar/__tests__/index.spec.tsx +5 -5
- package/src/components/Carousel/CardCarousel.tsx +7 -9
- package/src/components/Carousel/__tests__/index.spec.tsx +14 -0
- package/src/components/DatePicker/__tests__/DatePickerCalendar.spec.tsx +32 -29
- package/src/components/TextInput/__tests__/index.spec.tsx +148 -1
- package/src/components/TextInput/index.tsx +135 -57
- package/src/components/Toast/ToastContext.ts +20 -2
- package/src/components/Toast/ToastProvider.tsx +7 -4
- package/types/components/Carousel/CardCarousel.d.ts +1 -0
- package/types/components/TextInput/index.d.ts +29 -1
- package/types/components/Toast/ToastContext.d.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
3
3
|
[1m[33m(!) 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`.[39m[22m
|
|
4
4
|
[1m[33m(!) 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[39m[22m
|
|
5
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [
|
|
5
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m57.2s[22m[39m
|
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 =
|
|
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
|
-
}, [
|
|
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
|
-
}, [
|
|
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
|
|
12850
|
-
var
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
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
|
-
},
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
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,
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
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
|
-
}))
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
}, [
|
|
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
|
-
}, [
|
|
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
|
|
12880
|
-
var
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
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
|
-
},
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
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,
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
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
|
-
}))
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
53
|
-
"@react-native-community/datetimepicker": "
|
|
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",
|