@hero-design/rn-work-uikit 1.2.1 → 1.2.3-alpha.0
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/CHANGELOG.md +20 -2
- package/lib/index.js +10 -6
- package/package.json +2 -2
- package/src/components/TextInput/FloatingLabel.tsx +7 -1
- package/src/components/TextInput/Group/__tests__/__snapshots__/index.spec.tsx.snap +6 -3
- package/src/components/TextInput/MIGRATION.md +2 -37
- package/src/components/TextInput/__tests__/FloatingLabel.spec.tsx +3 -3
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +34 -17
- package/src/components/TextInput/index.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
# @hero-design/rn-work-uikit
|
|
2
2
|
|
|
3
|
+
## 1.2.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`e92d1dab57316441e7b5054debe823328e1a1083`](https://github.com/Thinkei/hero-design/commit/e92d1dab57316441e7b5054debe823328e1a1083)]:
|
|
8
|
+
- @hero-design/rn@8.103.2-alpha.0
|
|
9
|
+
|
|
10
|
+
## 1.2.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#4020](https://github.com/Thinkei/hero-design/pull/4020) [`23b0c7f7744bb4972504237b57cce57da9da5a73`](https://github.com/Thinkei/hero-design/commit/23b0c7f7744bb4972504237b57cce57da9da5a73) Thanks [@cuongnguyeneh](https://github.com/cuongnguyeneh)! - [TextInput] Update testId for label of input
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`23b0c7f7744bb4972504237b57cce57da9da5a73`](https://github.com/Thinkei/hero-design/commit/23b0c7f7744bb4972504237b57cce57da9da5a73)]:
|
|
17
|
+
- @hero-design/rn@8.103.1
|
|
18
|
+
|
|
3
19
|
## 1.2.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
6
22
|
|
|
7
23
|
- [#4007](https://github.com/Thinkei/hero-design/pull/4007) [`be4d27a22908e6e5b9dfd429f21dfbdfadaf4949`](https://github.com/Thinkei/hero-design/commit/be4d27a22908e6e5b9dfd429f21dfbdfadaf4949) Thanks [@cuongnguyeneh](https://github.com/cuongnguyeneh)! - [TextInput] Update testId of native input
|
|
8
24
|
|
|
9
|
-
-
|
|
10
|
-
|
|
25
|
+
- [#4011](https://github.com/Thinkei/hero-design/pull/4011) [`ea8f4a15e1bc9a08c266d939e3aed2e98797b783`](https://github.com/Thinkei/hero-design/commit/ea8f4a15e1bc9a08c266d939e3aed2e98797b783) Thanks [@cuongnguyeneh](https://github.com/cuongnguyeneh)! - [TextInput] Update migration.md
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`8ba84012be721c8a18a2ba9453b6cde66f8b3e49`](https://github.com/Thinkei/hero-design/commit/8ba84012be721c8a18a2ba9453b6cde66f8b3e49), [`7e0859459ea48c43c9edcc01a64c80ab715b4d15`](https://github.com/Thinkei/hero-design/commit/7e0859459ea48c43c9edcc01a64c80ab715b4d15)]:
|
|
28
|
+
- @hero-design/rn@8.103.0
|
|
11
29
|
|
|
12
30
|
## 1.2.0
|
|
13
31
|
|
package/lib/index.js
CHANGED
|
@@ -1684,7 +1684,7 @@ var yMax=React__default.useMemo(function(){return Math.max.apply(Math,_toConsuma
|
|
|
1684
1684
|
var EMPTY_PLACEHOLDER_VALUE$1=' ';var LABEL_ANIMATION_DURATION$1=150;var renderErrorOrHelpText=function renderErrorOrHelpText(_ref2){var error=_ref2.error,helpText=_ref2.helpText;return error?/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorContainer$2,null,/*#__PURE__*/React__default__namespace.default.createElement(Icon,{testID:"input-error-icon",icon:"circle-info",size:"xsmall",intent:"danger"}),/*#__PURE__*/React__default__namespace.default.createElement(StyledError$1,{testID:"input-error-message"},error)):!!helpText&&/*#__PURE__*/React__default__namespace.default.createElement(StyledHelperText$1,null,helpText);};var renderInput$1=function renderInput(_ref3){var variant=_ref3.variant,nativeInputProps=_ref3.nativeInputProps,renderInputValue=_ref3.renderInputValue,ref=_ref3.ref,theme=_ref3.theme;return renderInputValue?renderInputValue(nativeInputProps):/*#__PURE__*/React__default__namespace.default.createElement(StyledTextInput$1,_extends$1({},nativeInputProps,{themeVariant:variant,multiline:variant==='textarea'||nativeInputProps.multiline,ref:ref,placeholderTextColor:theme.__hd__.textInput.colors.placeholder}));};var renderSuffix$1=function renderSuffix(_ref4){var state=_ref4.state,loading=_ref4.loading,suffix=_ref4.suffix;var actualSuffix=loading?'loading':suffix;return typeof actualSuffix==='string'?/*#__PURE__*/React__default__namespace.default.createElement(Icon,{intent:state==='disabled'?'disabled-text':'text',testID:"input-suffix",icon:actualSuffix,spin:actualSuffix==='loading',size:"medium"}):suffix;};var renderPrefix$1=function renderPrefix(_ref5){var state=_ref5.state,prefix=_ref5.prefix;return typeof prefix==='string'?/*#__PURE__*/React__default__namespace.default.createElement(Icon,{intent:state==='disabled'?'disabled-text':'text',testID:"input-prefix",icon:prefix,size:"xsmall"}):prefix;};var renderMaxLengthMessage=function renderMaxLengthMessage(_ref6){var maxLength=_ref6.maxLength,state=_ref6.state,currentLength=_ref6.currentLength,hideCharacterCount=_ref6.hideCharacterCount;var shouldShowMaxLength=maxLength!==undefined&&!hideCharacterCount;return shouldShowMaxLength&&/*#__PURE__*/React__default__namespace.default.createElement(StyledMaxLengthMessage,{themeState:state},currentLength,"/",maxLength);};var getDisplayText=function getDisplayText(value,defaultValue){var _ref7;return (_ref7=value!==undefined?value:defaultValue)!==null&&_ref7!==void 0?_ref7:'';};var TextInput$1=/*#__PURE__*/React__default.forwardRef(function(_ref8,ref){var label=_ref8.label,prefix=_ref8.prefix,suffix=_ref8.suffix,style=_ref8.style,textStyle=_ref8.textStyle,testID=_ref8.testID,accessibilityLabelledBy=_ref8.accessibilityLabelledBy,error=_ref8.error,required=_ref8.required,_ref8$editable=_ref8.editable,editable=_ref8$editable===void 0?true:_ref8$editable,_ref8$disabled=_ref8.disabled,disabled=_ref8$disabled===void 0?false:_ref8$disabled,_ref8$loading=_ref8.loading,loading=_ref8$loading===void 0?false:_ref8$loading,maxLength=_ref8.maxLength,_ref8$hideCharacterCo=_ref8.hideCharacterCount,hideCharacterCount=_ref8$hideCharacterCo===void 0?false:_ref8$hideCharacterCo,helpText=_ref8.helpText,value=_ref8.value,defaultValue=_ref8.defaultValue,renderInputValue=_ref8.renderInputValue,_ref8$allowFontScalin=_ref8.allowFontScaling,allowFontScaling=_ref8$allowFontScalin===void 0?false:_ref8$allowFontScalin,_ref8$variant=_ref8.variant,variant=_ref8$variant===void 0?'text':_ref8$variant,nativeProps=_objectWithoutProperties(_ref8,_excluded$r);var displayText=getDisplayText(value,defaultValue);var isEmptyValue=displayText.length===0;var _React$useState=React__default__namespace.default.useState({height:0,width:0}),_React$useState2=_slicedToArray(_React$useState,2),inputSize=_React$useState2[0],setInputSize=_React$useState2[1];var _React$useState3=React__default__namespace.default.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),isFocused=_React$useState4[0],setIsFocused=_React$useState4[1];var state=getState$3({disabled:disabled,error:error,editable:editable,loading:loading,isFocused:isFocused,isEmptyValue:isEmptyValue});var theme=useTheme();var focusAnimation=React__default.useRef(new reactNative.Animated.Value(0)).current;React__default.useEffect(function(){reactNative.Animated.timing(focusAnimation,{toValue:isFocused||!isEmptyValue?1:0,duration:LABEL_ANIMATION_DURATION$1,easing:reactNative.Easing.bezier(0.4,0,0.2,1),useNativeDriver:true}).start();},[focusAnimation,isEmptyValue,isFocused]);var onLayout=React__default.useCallback(function(event){var _event$nativeEvent$la=event.nativeEvent.layout,height=_event$nativeEvent$la.height,width=_event$nativeEvent$la.width;setInputSize(function(prev){return _objectSpread2(_objectSpread2({},prev),{},{height:height,width:width});});},[]);var innerTextInput=React__default__namespace.default.useRef();React__default__namespace.default.useImperativeHandle(ref,function(){return {// we don't expose this method, it's for testing https://medium.com/developer-rants/how-to-test-useref-without-mocking-useref-699165f4994e
|
|
1685
1685
|
getNativeTextInputRef:function getNativeTextInputRef(){return innerTextInput.current;},focus:function focus(){var _innerTextInput$curre;(_innerTextInput$curre=innerTextInput.current)===null||_innerTextInput$curre===void 0||_innerTextInput$curre.focus();},clear:function clear(){var _innerTextInput$curre2;return (_innerTextInput$curre2=innerTextInput.current)===null||_innerTextInput$curre2===void 0?void 0:_innerTextInput$curre2.clear();},setNativeProps:function setNativeProps(args){var _innerTextInput$curre3;return (_innerTextInput$curre3=innerTextInput.current)===null||_innerTextInput$curre3===void 0?void 0:_innerTextInput$curre3.setNativeProps(args);},isFocused:function isFocused(){var _innerTextInput$curre4;return ((_innerTextInput$curre4=innerTextInput.current)===null||_innerTextInput$curre4===void 0?void 0:_innerTextInput$curre4.isFocused())||false;},blur:function blur(){var _innerTextInput$curre5;return (_innerTextInput$curre5=innerTextInput.current)===null||_innerTextInput$curre5===void 0?void 0:_innerTextInput$curre5.blur();}};},[innerTextInput]);var _useMemo=React__default.useMemo(function(){if(!textStyle){return {};}var flattenTextStyle=reactNative.StyleSheet.flatten(textStyle);var borderKeys=Object.keys(flattenTextStyle).filter(function(key){return key.startsWith('border');});return {borderStyle:pick(borderKeys,flattenTextStyle),textStyleWithoutBorderStyle:omit(borderKeys,flattenTextStyle)};},[textStyle]),borderStyle=_useMemo.borderStyle,textStyleWithoutBorderStyle=_useMemo.textStyleWithoutBorderStyle;var _useMemo2=React__default.useMemo(function(){var _flattenTextStyle$bac;if(!style){return {backgroundColor:theme.__hd__.textInput.colors.containerBackground};}var flattenTextStyle=reactNative.StyleSheet.flatten(style);return {backgroundColor:(_flattenTextStyle$bac=flattenTextStyle.backgroundColor)!==null&&_flattenTextStyle$bac!==void 0?_flattenTextStyle$bac:theme.__hd__.textInput.colors.containerBackground,styleWithoutBackgroundColor:omit(['backgroundColor'],flattenTextStyle)};},[style,theme]),backgroundColor=_useMemo2.backgroundColor,styleWithoutBackgroundColor=_useMemo2.styleWithoutBackgroundColor;var nativeInputTestIDSuffix=testID?"-".concat(testID):'';var nativeInputProps=_objectSpread2(_objectSpread2({style:reactNative.StyleSheet.flatten([{backgroundColor:backgroundColor,color:theme.__hd__.textInput.colors.text},textStyleWithoutBorderStyle]),testID:"text-input".concat(nativeInputTestIDSuffix),accessibilityState:{disabled:state==='disabled'||state==='readonly'},// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1686
1686
|
// @ts-ignore
|
|
1687
|
-
accessibilityLabelledBy:accessibilityLabelledBy,allowFontScaling:allowFontScaling},nativeProps),{},{onFocus:function onFocus(event){var _nativeProps$onFocus;setIsFocused(true);(_nativeProps$onFocus=nativeProps.onFocus)===null||_nativeProps$onFocus===void 0||_nativeProps$onFocus.call(nativeProps,event);},onBlur:function onBlur(event){var _nativeProps$onBlur;setIsFocused(false);(_nativeProps$onBlur=nativeProps.onBlur)===null||_nativeProps$onBlur===void 0||_nativeProps$onBlur.call(nativeProps,event);},editable:editable,maxLength:maxLength,value:value,onChangeText:function onChangeText(text){var _nativeProps$onChange;(_nativeProps$onChange=nativeProps.onChangeText)===null||_nativeProps$onChange===void 0||_nativeProps$onChange.call(nativeProps,text);},defaultValue:defaultValue,placeholder:isFocused||label===undefined?nativeProps.placeholder:EMPTY_PLACEHOLDER_VALUE$1});return/*#__PURE__*/React__default__namespace.default.createElement(StyledContainer$6,{style:styleWithoutBackgroundColor,pointerEvents:state==='disabled'||state==='readonly'?'none':'auto',testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(StyledTextInputContainer,{onLayout:onLayout},/*#__PURE__*/React__default__namespace.default.createElement(StyledBorderBackDrop,{themeFocused:isFocused,themeState:state,testID:"text-input-border",style:[{backgroundColor:backgroundColor},borderStyle]}),/*#__PURE__*/React__default__namespace.default.createElement(reactNative.View,null,renderPrefix$1({state:state,prefix:prefix})),/*#__PURE__*/React__default__namespace.default.createElement(StyledLabelContainerInsideTextInput,{themeHasPrefix:!!prefix,themeVariant:variant,pointerEvents:"none",style:[{transformOrigin:'left top'},{transform:[{translateY:focusAnimation.interpolate({inputRange:[0,1],outputRange:[variant!=='textarea'?inputSize.height/2:theme.space.large,theme.space.xsmall]})},{scale:focusAnimation.interpolate({inputRange:[0,1],outputRange:[1,0.75]})}]}]},!!label&&/*#__PURE__*/React__default__namespace.default.createElement(StyledLabelInsideTextInput,{style:{backgroundColor:backgroundColor},nativeID:accessibilityLabelledBy,testID:"input-label",themeState:state},required&&/*#__PURE__*/React__default__namespace.default.createElement(StyledAsteriskLabelInsideTextInput,{style:{backgroundColor:backgroundColor},themeState:state,testID:"input-label-asterisk"},"*"),/*#__PURE__*/React__default__namespace.default.createElement(Typography.Body,{numberOfLines:1},label))),/*#__PURE__*/React__default__namespace.default.createElement(StyledTextInputAndLabelContainer,null,renderInput$1({variant:variant,nativeInputProps:nativeInputProps,renderInputValue:renderInputValue,ref:function ref(rnTextInputRef){innerTextInput.current=rnTextInputRef;},theme:theme})),renderSuffix$1({state:state,loading:loading,suffix:suffix})),/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorAndHelpTextContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorAndMaxLengthContainer,null,renderErrorOrHelpText({error:error,helpText:helpText}),renderMaxLengthMessage({state:state,currentLength:displayText.length,maxLength:maxLength,hideCharacterCount:hideCharacterCount}))));});var AndroidDatePickerDialog=function AndroidDatePickerDialog(_ref){var open=_ref.open,onClose=_ref.onClose,value=_ref.value,minDate=_ref.minDate,maxDate=_ref.maxDate,_onChange=_ref.onChange,testID=_ref.testID,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'default':_ref$variant;var theme=useTheme();if(!open)return null;var pickerInitValue=value||new Date();return/*#__PURE__*/React__default__namespace.default.createElement(Box,{testID:testID},open&&variant==='month-year'?/*#__PURE__*/React__default__namespace.default.createElement(Box,{testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(reactNativeMonthYearPicker.MonthYearPickerDialogueAndroid,{themeVariant:theme.themeMode==='dark'?'dark':'light',value:value,minimumDate:minDate,maximumDate:maxDate,onChange:function onChange(action,date){onClose();if(action==='dateSetAction'&&!!date){_onChange(date);}}})):null,open&&variant==='default'?/*#__PURE__*/React__default__namespace.default.createElement(DateTimePicker__default.default,{testID:"datePickerAndroid",mode:"date",value:pickerInitValue,minimumDate:minDate,maximumDate:maxDate,display:"default",onChange:function onChange(_,date){onClose();if(date){_onChange(date);}}}):null);};var getDateValue=function getDateValue(value,minDate,maxDate){if(minDate&&value<minDate){return minDate;}if(maxDate&&value>maxDate){return maxDate;}return value;};var useCalculateDate=function useCalculateDate(_ref){var maxDate=_ref.maxDate,minDate=_ref.minDate,onChange=_ref.onChange,value=_ref.value;React__default.useEffect(function(){var newDate=getDateValue(value||new Date(),minDate,maxDate);if(value&&newDate.toDateString()!==value.toDateString()){onChange(newDate);}},[maxDate,minDate,value]);};var locale$3={lang:'en-AU',dateTimeFormats:{fullDate:'dd/MM/yyyy'}};var LocaleContext=/*#__PURE__*/React__default.createContext(locale$3);var useLocale=function useLocale(){var context=React__default.useContext(LocaleContext);if(!context)return locale$3;return context;};var useDateTimeFormat=function useDateTimeFormat(){var _useLocale=useLocale(),dateTimeFormats=_useLocale.dateTimeFormats;var localizeDateTime=React__default.useCallback(function(key){return dateTimeFormats===null||dateTimeFormats===void 0?void 0:dateTimeFormats[key];},[dateTimeFormats]);return {localizeDateTime:localizeDateTime};};var locale$2={lang:'en-CA',dateTimeFormats:{fullDate:'MMM dd, yyyy'}};var locales={'en-AU':locale$3,'en-CA':locale$2};// Function to get the date format based on the displayFormat and locale,
|
|
1687
|
+
accessibilityLabelledBy:accessibilityLabelledBy,allowFontScaling:allowFontScaling},nativeProps),{},{onFocus:function onFocus(event){var _nativeProps$onFocus;setIsFocused(true);(_nativeProps$onFocus=nativeProps.onFocus)===null||_nativeProps$onFocus===void 0||_nativeProps$onFocus.call(nativeProps,event);},onBlur:function onBlur(event){var _nativeProps$onBlur;setIsFocused(false);(_nativeProps$onBlur=nativeProps.onBlur)===null||_nativeProps$onBlur===void 0||_nativeProps$onBlur.call(nativeProps,event);},editable:editable,maxLength:maxLength,value:value,onChangeText:function onChangeText(text){var _nativeProps$onChange;(_nativeProps$onChange=nativeProps.onChangeText)===null||_nativeProps$onChange===void 0||_nativeProps$onChange.call(nativeProps,text);},defaultValue:defaultValue,placeholder:isFocused||label===undefined?nativeProps.placeholder:EMPTY_PLACEHOLDER_VALUE$1});return/*#__PURE__*/React__default__namespace.default.createElement(StyledContainer$6,{style:styleWithoutBackgroundColor,pointerEvents:state==='disabled'||state==='readonly'?'none':'auto',testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(StyledTextInputContainer,{onLayout:onLayout},/*#__PURE__*/React__default__namespace.default.createElement(StyledBorderBackDrop,{themeFocused:isFocused,themeState:state,testID:"text-input-border",style:[{backgroundColor:backgroundColor},borderStyle]}),/*#__PURE__*/React__default__namespace.default.createElement(reactNative.View,null,renderPrefix$1({state:state,prefix:prefix})),/*#__PURE__*/React__default__namespace.default.createElement(StyledLabelContainerInsideTextInput,{themeHasPrefix:!!prefix,themeVariant:variant,pointerEvents:"none",style:[{transformOrigin:'left top'},{transform:[{translateY:focusAnimation.interpolate({inputRange:[0,1],outputRange:[variant!=='textarea'?inputSize.height/2:theme.space.large,theme.space.xsmall]})},{scale:focusAnimation.interpolate({inputRange:[0,1],outputRange:[1,0.75]})}]}]},!!label&&/*#__PURE__*/React__default__namespace.default.createElement(StyledLabelInsideTextInput,{style:{backgroundColor:backgroundColor},nativeID:accessibilityLabelledBy,testID:"input-label".concat(nativeInputTestIDSuffix),themeState:state},required&&/*#__PURE__*/React__default__namespace.default.createElement(StyledAsteriskLabelInsideTextInput,{style:{backgroundColor:backgroundColor},themeState:state,testID:"input-label-asterisk"},"*"),/*#__PURE__*/React__default__namespace.default.createElement(Typography.Body,{testID:"input-label-text".concat(nativeInputTestIDSuffix),numberOfLines:1},label))),/*#__PURE__*/React__default__namespace.default.createElement(StyledTextInputAndLabelContainer,null,renderInput$1({variant:variant,nativeInputProps:nativeInputProps,renderInputValue:renderInputValue,ref:function ref(rnTextInputRef){innerTextInput.current=rnTextInputRef;},theme:theme})),renderSuffix$1({state:state,loading:loading,suffix:suffix})),/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorAndHelpTextContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorAndMaxLengthContainer,null,renderErrorOrHelpText({error:error,helpText:helpText}),renderMaxLengthMessage({state:state,currentLength:displayText.length,maxLength:maxLength,hideCharacterCount:hideCharacterCount}))));});var AndroidDatePickerDialog=function AndroidDatePickerDialog(_ref){var open=_ref.open,onClose=_ref.onClose,value=_ref.value,minDate=_ref.minDate,maxDate=_ref.maxDate,_onChange=_ref.onChange,testID=_ref.testID,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'default':_ref$variant;var theme=useTheme();if(!open)return null;var pickerInitValue=value||new Date();return/*#__PURE__*/React__default__namespace.default.createElement(Box,{testID:testID},open&&variant==='month-year'?/*#__PURE__*/React__default__namespace.default.createElement(Box,{testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(reactNativeMonthYearPicker.MonthYearPickerDialogueAndroid,{themeVariant:theme.themeMode==='dark'?'dark':'light',value:value,minimumDate:minDate,maximumDate:maxDate,onChange:function onChange(action,date){onClose();if(action==='dateSetAction'&&!!date){_onChange(date);}}})):null,open&&variant==='default'?/*#__PURE__*/React__default__namespace.default.createElement(DateTimePicker__default.default,{testID:"datePickerAndroid",mode:"date",value:pickerInitValue,minimumDate:minDate,maximumDate:maxDate,display:"default",onChange:function onChange(_,date){onClose();if(date){_onChange(date);}}}):null);};var getDateValue=function getDateValue(value,minDate,maxDate){if(minDate&&value<minDate){return minDate;}if(maxDate&&value>maxDate){return maxDate;}return value;};var useCalculateDate=function useCalculateDate(_ref){var maxDate=_ref.maxDate,minDate=_ref.minDate,onChange=_ref.onChange,value=_ref.value;React__default.useEffect(function(){var newDate=getDateValue(value||new Date(),minDate,maxDate);if(value&&newDate.toDateString()!==value.toDateString()){onChange(newDate);}},[maxDate,minDate,value]);};var locale$3={lang:'en-AU',dateTimeFormats:{fullDate:'dd/MM/yyyy'}};var LocaleContext=/*#__PURE__*/React__default.createContext(locale$3);var useLocale=function useLocale(){var context=React__default.useContext(LocaleContext);if(!context)return locale$3;return context;};var useDateTimeFormat=function useDateTimeFormat(){var _useLocale=useLocale(),dateTimeFormats=_useLocale.dateTimeFormats;var localizeDateTime=React__default.useCallback(function(key){return dateTimeFormats===null||dateTimeFormats===void 0?void 0:dateTimeFormats[key];},[dateTimeFormats]);return {localizeDateTime:localizeDateTime};};var locale$2={lang:'en-CA',dateTimeFormats:{fullDate:'MMM dd, yyyy'}};var locales={'en-AU':locale$3,'en-CA':locale$2};// Function to get the date format based on the displayFormat and locale,
|
|
1688
1688
|
// if no displayFormat or locale is provided, use the default fullDate format
|
|
1689
1689
|
var getDateFormat=function getDateFormat(_ref){var displayFormat=_ref.displayFormat,locale=_ref.locale,localizeDateTime=_ref.localizeDateTime;// Prioritise displayFormat
|
|
1690
1690
|
if(displayFormat){return displayFormat;}// If locale is provided, find the corresponding locale in the locales object
|
|
@@ -1707,7 +1707,7 @@ React__default.useEffect(function(){var backHandler=reactNative.BackHandler.addE
|
|
|
1707
1707
|
* @param {ErrorProps}
|
|
1708
1708
|
* @return {*} {ReactElement}
|
|
1709
1709
|
*/var ErrorComponent=function ErrorComponent(_ref3){var _ref3$visible=_ref3.visible,visible=_ref3$visible===void 0?true:_ref3$visible,_ref3$variant=_ref3.variant,variant=_ref3$variant===void 0?'in-page':_ref3$variant,title=_ref3.title,description=_ref3.description,image=_ref3.image,testID=_ref3.testID,ctaText=_ref3.ctaText,onCtaPress=_ref3.onCtaPress,secondaryCtaText=_ref3.secondaryCtaText,onSecondaryCtaPress=_ref3.onSecondaryCtaPress,nativeProps=_objectWithoutProperties(_ref3,_excluded2$1);useDeprecation("Visible prop is deprecated. Use conditional rendering instead",visible);var _useState=React__default.useState(visible),_useState2=_slicedToArray(_useState,2),isVisible=_useState2[0],setIsVisible=_useState2[1];var _useState3=React__default.useState(null),_useState4=_slicedToArray(_useState3,2),ctaPressed=_useState4[0],setCtaPressed=_useState4[1];var onCloseModal=React__default.useCallback(function(){if(ctaPressed==='cta'&&onCtaPress){onCtaPress();}if(ctaPressed==='secondaryCta'&&onSecondaryCtaPress){onSecondaryCtaPress();}setCtaPressed(null);},[ctaPressed,onCtaPress,onSecondaryCtaPress]);React__default.useEffect(function(){setIsVisible(visible);},[visible]);// These useEffect lines prevents race condition error when callback contains navigation logic
|
|
1710
|
-
React__default.useEffect(function(){if(ctaPressed){setIsVisible(false);}},[ctaPressed]);React__default.useEffect(function(){if(!isVisible){onCloseModal();}},[isVisible,onCloseModal]);if(variant==='full-screen'){return/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorModal,{visible:isVisible,onRequestClose:function onRequestClose(){return setIsVisible(false);},onDismiss:function onDismiss(){return setIsVisible(false);},animationType:"slide"},/*#__PURE__*/React__default__namespace.default.createElement(ErrorPage,_extends$1({variant:variant,title:title,description:description,image:image,testID:testID,ctaText:ctaText,onCtaPress:onCtaPress&&function(){setCtaPressed('cta');},secondaryCtaText:secondaryCtaText,onSecondaryCtaPress:onSecondaryCtaPress&&function(){setCtaPressed('secondaryCta');}},nativeProps)));}return/*#__PURE__*/React__default__namespace.default.createElement(ErrorPage,_extends$1({variant:variant,title:title,description:description,image:image,testID:testID,ctaText:ctaText,onCtaPress:onCtaPress,secondaryCtaText:secondaryCtaText,onSecondaryCtaPress:onSecondaryCtaPress},nativeProps));};var StyledActionItem=index$b(reactNative.TouchableOpacity)(function(_ref){var theme=_ref.theme;return {padding:theme.__hd__.fab.space.actionItemPadding,margin:theme.__hd__.fab.space.actionItemMargin,marginRight:theme.__hd__.fab.space.actionItemMarginRight,backgroundColor:theme.__hd__.fab.colors.actionItemBackground,borderRadius:theme.__hd__.fab.radii.actionItem,flexDirection:'row',alignItems:'center',alignSelf:'flex-end',overflow:'hidden'};});var StyledActionItemText=index$b(Typography.Body)(function(_ref2){var theme=_ref2.theme;return {color:theme.__hd__.fab.colors.actionItemText};});var StyledIcon$3=index$b(Icon)(function(_ref3){var theme=_ref3.theme;return {color:theme.__hd__.fab.colors.actionItemText};});var AnimatedTouchableHighlight=reactNative.Animated.createAnimatedComponent(reactNative.TouchableOpacity);var StyledFAB$2=index$b(AnimatedTouchableHighlight)(function(_ref){var theme=_ref.theme,themeActive=_ref.themeActive;return _objectSpread2({backgroundColor:themeActive?theme.__hd__.fab.colors.buttonActiveBackground:theme.__hd__.fab.colors.buttonBackground,borderRadius:theme.radii.rounded,alignItems:'center',justifyContent:'center',alignSelf:'flex-start',padding:theme.__hd__.fab.space.containerPadding,flexDirection:'row',height:theme.__hd__.fab.sizes.height},theme.__hd__.fab.shadows["default"]);});var StyledFABIcon=index$b(Icon)(function(_ref2){var theme=_ref2.theme;return {color:theme.__hd__.fab.colors.icon,lineHeight:theme.__hd__.fab.lineHeights.icon,textAlignVertical:'center',textAlign:'center'};});var StyledFABText=index$b(Typography.Body)(function(_ref3){var theme=_ref3.theme;return {color:theme.__hd__.fab.colors.titleText,textAlignVertical:'center',textAlign:'center',marginHorizontal:theme.__hd__.fab.space.titleMarginHorizontal};});var StyledIconContainer=index$b(Box)(function(_ref4){var theme=_ref4.theme;return {width:theme.__hd__.fab.sizes.iconContainerWidth,height:theme.__hd__.fab.sizes.iconContainerHeight,justifyContent:'center',alignItems:'center'};});var ActionItem=function ActionItem(_ref){var icon=_ref.icon,title=_ref.title,onPress=_ref.onPress,style=_ref.style,testID=_ref.testID,index=_ref.index,_ref$active=_ref.active,active=_ref$active===void 0?false:_ref$active;var animatedValue=React__default__namespace.default.useRef(new reactNative.Animated.Value(0));var translateY=animatedValue.current.interpolate({inputRange:[0,1],outputRange:[50,0]});React__default__namespace.default.useEffect(function(){reactNative.Animated.spring(animatedValue.current,{toValue:active?1:0,useNativeDriver:reactNative.Platform.OS!=='web',delay:index*30,speed:10,bounciness:10}).start();},[active,index]);return/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:{transform:[{translateY:translateY}]}},/*#__PURE__*/React__default__namespace.default.createElement(StyledActionItem,{activeOpacity:0.8,style:style,onPress:onPress,testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(React__default__namespace.default.Fragment,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIcon$3,{size:"xsmall",icon:icon})),/*#__PURE__*/React__default__namespace.default.createElement(StyledActionItemText,null,title))));};var _excluded$n=["active"];var AnimatedIcons=reactNative.Animated.createAnimatedComponent(StyledFABIcon);var AnimatedFABIcon=function AnimatedFABIcon(_ref){var active=_ref.active,iconProps=_objectWithoutProperties(_ref,_excluded$n);var rotateAnimation=React__default.useRef(new reactNative.Animated.Value(active?1:0));React__default.useEffect(function(){var animation=reactNative.Animated.spring(rotateAnimation.current,{toValue:active?1:0,useNativeDriver:reactNative.Platform.OS==='ios'||reactNative.Platform.OS==='android'});animation.start();return function(){animation.stop();};},[active]);var interpolatedRotateAnimation=rotateAnimation.current.interpolate({inputRange:[0,1],outputRange:['0deg','-45deg']});return/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:reactNative.StyleSheet.flatten([{transform:[{rotate:interpolatedRotateAnimation}]}])},/*#__PURE__*/React__default__namespace.default.createElement(AnimatedIcons,_extends$1({size:"xsmall"},iconProps)));};if(reactNative.Platform.OS==='android'){if(reactNative.UIManager.setLayoutAnimationEnabledExperimental){reactNative.UIManager.setLayoutAnimationEnabledExperimental(true);}}var IconOnlyContent=function IconOnlyContent(_ref){var icon=_ref.icon,animated=_ref.animated,active=_ref.active;if(animated){return/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(AnimatedFABIcon,{active:active,icon:icon,testID:"animated-fab-icon",size:"xsmall"}));}return/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFABIcon,{size:"xsmall",icon:icon,testID:"styled-fab-icon"}));};var IconWithTextContent=function IconWithTextContent(_ref2){var icon=_ref2.icon,title=_ref2.title;return/*#__PURE__*/React__default__namespace.default.createElement(React__default__namespace.default.Fragment,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFABIcon,{size:"xsmall",icon:icon,testID:"styled-fab-icon"})),/*#__PURE__*/React__default__namespace.default.createElement(StyledFABText,null,title));};var animateWidth=function animateWidth(){reactNative.LayoutAnimation.configureNext({duration:reactNative.Platform.OS==='ios'?200:400,update:{type:'spring',springDamping:reactNative.Platform.OS==='ios'?1:1.5}});};var FAB$1=/*#__PURE__*/React__default.forwardRef(function(_ref3,ref){var _StyleSheet$flatten,_StyleSheet$flatten2;var onPress=_ref3.onPress,title=_ref3.title,icon=_ref3.icon,animated=_ref3.animated,testID=_ref3.testID,active=_ref3.active,style=_ref3.style;var theme=useTheme();var _React$useState=React__default__namespace.default.useState({hideTitle:false,hideButton:false}),_React$useState2=_slicedToArray(_React$useState,2),displayState=_React$useState2[0],setDisplayState=_React$useState2[1];var isIconOnly=displayState.hideTitle||active||!title;var animatedValues={opacity:React__default__namespace.default.useRef(new reactNative.Animated.Value(1)).current,width:React__default__namespace.default.useRef(new reactNative.Animated.Value(1)).current,translateY:React__default__namespace.default.useRef(new reactNative.Animated.Value(0)).current};var marginBottom=Number((_StyleSheet$flatten=reactNative.StyleSheet.flatten(style))===null||_StyleSheet$flatten===void 0?void 0:_StyleSheet$flatten.marginBottom)||0;var _React$useState3=React__default__namespace.default.useState(0),_React$useState4=_slicedToArray(_React$useState3,2),buttonWidth=_React$useState4[0],setButtonWidth=_React$useState4[1];var hasSetButtonWidth=buttonWidth>0;React__default__namespace.default.useImperativeHandle(ref,function(){return {show:function show(){reactNative.Animated.spring(animatedValues.translateY,{toValue:0,useNativeDriver:true}).start();setDisplayState({hideButton:false,hideTitle:false});animateWidth();reactNative.Animated.spring(animatedValues.opacity,{toValue:1,useNativeDriver:true}).start();},collapse:function collapse(){reactNative.Animated.parallel([reactNative.Animated.spring(animatedValues.opacity,{toValue:1,useNativeDriver:true}),reactNative.Animated.spring(animatedValues.translateY,{toValue:0,useNativeDriver:true})]).start();animateWidth();setDisplayState({hideButton:false,hideTitle:true});},hide:function hide(){reactNative.Animated.stagger(20,[reactNative.Animated.spring(animatedValues.opacity,{toValue:0,useNativeDriver:true}),reactNative.Animated.spring(animatedValues.translateY,{toValue:1,useNativeDriver:true})]).start(function(){animateWidth();setDisplayState(function(previousState){return _objectSpread2(_objectSpread2({},previousState),{},{hideButton:true});});});}};},[]);return/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$2,{onLayout:function onLayout(event){return !hasSetButtonWidth&&!active&&setButtonWidth(event.nativeEvent.layout.width);},activeOpacity:0.8,onPress:onPress,style:[style,{bottom:displayState.hideButton?-(marginBottom+theme.__hd__.fab.sizes.height*2):(_StyleSheet$flatten2=reactNative.StyleSheet.flatten(style))===null||_StyleSheet$flatten2===void 0?void 0:_StyleSheet$flatten2.bottom,transform:[{translateY:animatedValues.translateY.interpolate({inputRange:[0,1],outputRange:[0,marginBottom+theme.__hd__.fab.sizes.height*2]})}]}],testID:testID,themeActive:active},/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:{flexDirection:'row',opacity:animatedValues.opacity.interpolate({inputRange:[0,1],outputRange:[0,1]})}},isIconOnly?/*#__PURE__*/React__default__namespace.default.createElement(IconOnlyContent,{animated:animated,active:active,icon:active?'add':icon}):/*#__PURE__*/React__default__namespace.default.createElement(IconWithTextContent,{icon:icon,title:title})));});FAB$1.displayName='FAB';var StyledContainer$4=index$b(reactNative.View)({position:'absolute',left:0,right:0,top:0,bottom:0,alignItems:'flex-end',justifyContent:'flex-end'});var StyledContainerInModal=index$b(reactNative.View)({position:'absolute',left:0,right:0,top:0,bottom:0,alignItems:'flex-end',justifyContent:'flex-end'});var StyledActionGroupContainer=index$b(reactNative.Animated.View)({alignItems:'flex-end',justifyContent:'flex-end',width:'70%'});var StyledFAB$1=index$b(FAB$1)(function(_ref){var theme=_ref.theme;return {marginRight:theme.__hd__.fab.space.buttonMarginRight,marginTop:theme.__hd__.fab.space.buttonMarginTop,alignSelf:'flex-end'};});var StyledBackdropPressable=index$b(reactNative.Pressable)(function(){return {position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'transparent'};});var StyledBackdrop=index$b(Box)(function(_ref2){var theme=_ref2.theme;return {position:'absolute',left:0,right:0,top:0,bottom:0,opacity:0.4,backgroundColor:theme.__hd__.fab.colors.backdropBackground};});var ActionGroup=/*#__PURE__*/React__default.forwardRef(function(_ref,ref){var headerTitle=_ref.headerTitle,onPress=_ref.onPress,active=_ref.active,style=_ref.style,items=_ref.items,testID=_ref.testID,fabTitle=_ref.fabTitle,onBackdropPress=_ref.onBackdropPress,_ref$fabIcon=_ref.fabIcon,fabIcon=_ref$fabIcon===void 0?'add':_ref$fabIcon,_ref$supportedOrienta=_ref.supportedOrientations,supportedOrientations=_ref$supportedOrienta===void 0?['portrait']:_ref$supportedOrienta;useDeprecation("FAB.ActionGroup's headerTitle prop will be removed in the next major release. Please remove it.",headerTitle!==undefined);var theme=useTheme();var fabRef=React__default.useRef(null);var animatedValue=React__default.useRef(new reactNative.Animated.Value(active?1:0));React__default__namespace.default.useImperativeHandle(ref,function(){return {showFAB:function showFAB(){var _fabRef$current;return (_fabRef$current=fabRef.current)===null||_fabRef$current===void 0?void 0:_fabRef$current.show();},collapseFAB:function collapseFAB(){var _fabRef$current2;return (_fabRef$current2=fabRef.current)===null||_fabRef$current2===void 0?void 0:_fabRef$current2.collapse();},hideFAB:function hideFAB(){var _fabRef$current3;return (_fabRef$current3=fabRef.current)===null||_fabRef$current3===void 0?void 0:_fabRef$current3.hide();}};},[fabRef]);React__default__namespace.default.useEffect(function(){reactNative.Animated.spring(animatedValue.current,{toValue:active?1:0,delay:100,useNativeDriver:reactNative.Platform.OS!=='web'}).start();if(active){var _fabRef$current4;(_fabRef$current4=fabRef.current)===null||_fabRef$current4===void 0||_fabRef$current4.collapse();}else {var _fabRef$current5;(_fabRef$current5=fabRef.current)===null||_fabRef$current5===void 0||_fabRef$current5.show();}},[active]);var actionGroupOpacity=animatedValue.current.interpolate({inputRange:[0,1],outputRange:[0,1]});return/*#__PURE__*/React__default__namespace.default.createElement(StyledContainer$4,{testID:testID,pointerEvents:"box-none",style:style},/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$1,{key:"fab",testID:"fab",icon:fabIcon,onPress:onPress,animated:true,active:active,title:fabTitle,ref:fabRef})),/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Modal,{visible:active,animationType:"fade",transparent:true,statusBarTranslucent:true,supportedOrientations:supportedOrientations},/*#__PURE__*/React__default__namespace.default.createElement(StyledContainerInModal,{testID:testID,style:[style]},/*#__PURE__*/React__default__namespace.default.createElement(StyledBackdropPressable,{testID:"back-drop",onPress:onBackdropPress},active&&/*#__PURE__*/React__default__namespace.default.createElement(Portal$1,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledBackdrop,null))),/*#__PURE__*/React__default__namespace.default.createElement(StyledActionGroupContainer,{testID:"action-group",pointerEvents:"box-none",style:{opacity:actionGroupOpacity}},/*#__PURE__*/React__default__namespace.default.createElement(Box,{style:{paddingBottom:0}},items===null||items===void 0?void 0:items.map(function(itemProp,index){return/*#__PURE__*/React__default__namespace.default.createElement(ActionItem,_extends$1({key:itemProp.key||"".concat(itemProp.icon,"_").concat(itemProp.title)},itemProp,{index:active?index:items.length-index,active:active}));}))),active&&/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$1// This FAB is moved up a bit compared to the original FAB,
|
|
1710
|
+
React__default.useEffect(function(){if(ctaPressed){setIsVisible(false);}},[ctaPressed]);React__default.useEffect(function(){if(!isVisible){onCloseModal();}},[isVisible,onCloseModal]);if(variant==='full-screen'){return/*#__PURE__*/React__default__namespace.default.createElement(StyledErrorModal,{visible:isVisible,onRequestClose:function onRequestClose(){return setIsVisible(false);},onDismiss:function onDismiss(){return setIsVisible(false);},animationType:"slide"},/*#__PURE__*/React__default__namespace.default.createElement(ErrorPage,_extends$1({variant:variant,title:title,description:description,image:image,testID:testID,ctaText:ctaText,onCtaPress:onCtaPress&&function(){setCtaPressed('cta');},secondaryCtaText:secondaryCtaText,onSecondaryCtaPress:onSecondaryCtaPress&&function(){setCtaPressed('secondaryCta');}},nativeProps)));}return/*#__PURE__*/React__default__namespace.default.createElement(ErrorPage,_extends$1({variant:variant,title:title,description:description,image:image,testID:testID,ctaText:ctaText,onCtaPress:onCtaPress,secondaryCtaText:secondaryCtaText,onSecondaryCtaPress:onSecondaryCtaPress},nativeProps));};var StyledActionItem=index$b(reactNative.TouchableOpacity)(function(_ref){var theme=_ref.theme;return {padding:theme.__hd__.fab.space.actionItemPadding,margin:theme.__hd__.fab.space.actionItemMargin,marginRight:theme.__hd__.fab.space.actionItemMarginRight,backgroundColor:theme.__hd__.fab.colors.actionItemBackground,borderRadius:theme.__hd__.fab.radii.actionItem,flexDirection:'row',alignItems:'center',alignSelf:'flex-end',overflow:'hidden'};});var StyledActionItemText=index$b(Typography.Body)(function(_ref2){var theme=_ref2.theme;return {color:theme.__hd__.fab.colors.actionItemText};});var StyledIcon$3=index$b(Icon)(function(_ref3){var theme=_ref3.theme;return {color:theme.__hd__.fab.colors.actionItemText};});var AnimatedTouchableHighlight=reactNative.Animated.createAnimatedComponent(reactNative.TouchableOpacity);var StyledFAB$2=index$b(AnimatedTouchableHighlight)(function(_ref){var theme=_ref.theme,themeActive=_ref.themeActive;return _objectSpread2({backgroundColor:themeActive?theme.__hd__.fab.colors.buttonActiveBackground:theme.__hd__.fab.colors.buttonBackground,borderRadius:theme.radii.rounded,alignItems:'center',justifyContent:'center',alignSelf:'flex-start',padding:theme.__hd__.fab.space.containerPadding,flexDirection:'row',height:theme.__hd__.fab.sizes.height},theme.__hd__.fab.shadows["default"]);});var StyledFABIcon=index$b(Icon)(function(_ref2){var theme=_ref2.theme;return {color:theme.__hd__.fab.colors.icon,lineHeight:theme.__hd__.fab.lineHeights.icon,textAlignVertical:'center',textAlign:'center'};});var StyledFABText=index$b(Typography.Body)(function(_ref3){var theme=_ref3.theme;return {color:theme.__hd__.fab.colors.titleText,textAlignVertical:'center',textAlign:'center',marginHorizontal:theme.__hd__.fab.space.titleMarginHorizontal};});var StyledIconContainer=index$b(Box)(function(_ref4){var theme=_ref4.theme;return {width:theme.__hd__.fab.sizes.iconContainerWidth,height:theme.__hd__.fab.sizes.iconContainerHeight,justifyContent:'center',alignItems:'center'};});var ActionItem=function ActionItem(_ref){var icon=_ref.icon,title=_ref.title,onPress=_ref.onPress,style=_ref.style,testID=_ref.testID,index=_ref.index,_ref$active=_ref.active,active=_ref$active===void 0?false:_ref$active;var animatedValue=React__default__namespace.default.useRef(new reactNative.Animated.Value(0));var translateY=animatedValue.current.interpolate({inputRange:[0,1],outputRange:[50,0]});React__default__namespace.default.useEffect(function(){reactNative.Animated.spring(animatedValue.current,{toValue:active?1:0,useNativeDriver:reactNative.Platform.OS!=='web',delay:index*30,speed:10,bounciness:10}).start();},[active,index]);return/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:{transform:[{translateY:translateY}]}},/*#__PURE__*/React__default__namespace.default.createElement(StyledActionItem,{activeOpacity:0.8,style:style,onPress:onPress,testID:testID},/*#__PURE__*/React__default__namespace.default.createElement(React__default__namespace.default.Fragment,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIcon$3,{size:"xsmall",icon:icon})),/*#__PURE__*/React__default__namespace.default.createElement(StyledActionItemText,null,title))));};var _excluded$n=["active"];var AnimatedIcons=reactNative.Animated.createAnimatedComponent(/*#__PURE__*/React__default__namespace.default.forwardRef(function(props,_){return/*#__PURE__*/React__default__namespace.default.createElement(StyledFABIcon,props);}));var AnimatedFABIcon=function AnimatedFABIcon(_ref){var active=_ref.active,iconProps=_objectWithoutProperties(_ref,_excluded$n);var rotateAnimation=React__default.useRef(new reactNative.Animated.Value(active?1:0));React__default.useEffect(function(){var animation=reactNative.Animated.spring(rotateAnimation.current,{toValue:active?1:0,useNativeDriver:reactNative.Platform.OS==='ios'||reactNative.Platform.OS==='android'});animation.start();return function(){animation.stop();};},[active]);var interpolatedRotateAnimation=rotateAnimation.current.interpolate({inputRange:[0,1],outputRange:['0deg','-45deg']});return/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:reactNative.StyleSheet.flatten([{transform:[{rotate:interpolatedRotateAnimation}]}])},/*#__PURE__*/React__default__namespace.default.createElement(AnimatedIcons,_extends$1({size:"xsmall"},iconProps)));};if(reactNative.Platform.OS==='android'){if(reactNative.UIManager.setLayoutAnimationEnabledExperimental){reactNative.UIManager.setLayoutAnimationEnabledExperimental(true);}}var IconOnlyContent=function IconOnlyContent(_ref){var icon=_ref.icon,animated=_ref.animated,active=_ref.active;if(animated){return/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(AnimatedFABIcon,{active:active,icon:icon,testID:"animated-fab-icon",size:"xsmall"}));}return/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFABIcon,{size:"xsmall",icon:icon,testID:"styled-fab-icon"}));};var IconWithTextContent=function IconWithTextContent(_ref2){var icon=_ref2.icon,title=_ref2.title;return/*#__PURE__*/React__default__namespace.default.createElement(React__default__namespace.default.Fragment,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledIconContainer,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFABIcon,{size:"xsmall",icon:icon,testID:"styled-fab-icon"})),/*#__PURE__*/React__default__namespace.default.createElement(StyledFABText,null,title));};var animateWidth=function animateWidth(){reactNative.LayoutAnimation.configureNext({duration:reactNative.Platform.OS==='ios'?200:400,update:{type:'spring',springDamping:reactNative.Platform.OS==='ios'?1:1.5}});};var FAB$1=/*#__PURE__*/React__default.forwardRef(function(_ref3,ref){var _StyleSheet$flatten,_StyleSheet$flatten2;var onPress=_ref3.onPress,title=_ref3.title,icon=_ref3.icon,animated=_ref3.animated,testID=_ref3.testID,active=_ref3.active,style=_ref3.style;var theme=useTheme();var _React$useState=React__default__namespace.default.useState({hideTitle:false,hideButton:false}),_React$useState2=_slicedToArray(_React$useState,2),displayState=_React$useState2[0],setDisplayState=_React$useState2[1];var isIconOnly=displayState.hideTitle||active||!title;var animatedValues={opacity:React__default__namespace.default.useRef(new reactNative.Animated.Value(1)).current,width:React__default__namespace.default.useRef(new reactNative.Animated.Value(1)).current,translateY:React__default__namespace.default.useRef(new reactNative.Animated.Value(0)).current};var marginBottom=Number((_StyleSheet$flatten=reactNative.StyleSheet.flatten(style))===null||_StyleSheet$flatten===void 0?void 0:_StyleSheet$flatten.marginBottom)||0;var _React$useState3=React__default__namespace.default.useState(0),_React$useState4=_slicedToArray(_React$useState3,2),buttonWidth=_React$useState4[0],setButtonWidth=_React$useState4[1];var hasSetButtonWidth=buttonWidth>0;React__default__namespace.default.useImperativeHandle(ref,function(){return {show:function show(){reactNative.Animated.spring(animatedValues.translateY,{toValue:0,useNativeDriver:true}).start();setDisplayState({hideButton:false,hideTitle:false});animateWidth();reactNative.Animated.spring(animatedValues.opacity,{toValue:1,useNativeDriver:true}).start();},collapse:function collapse(){reactNative.Animated.parallel([reactNative.Animated.spring(animatedValues.opacity,{toValue:1,useNativeDriver:true}),reactNative.Animated.spring(animatedValues.translateY,{toValue:0,useNativeDriver:true})]).start();animateWidth();setDisplayState({hideButton:false,hideTitle:true});},hide:function hide(){reactNative.Animated.stagger(20,[reactNative.Animated.spring(animatedValues.opacity,{toValue:0,useNativeDriver:true}),reactNative.Animated.spring(animatedValues.translateY,{toValue:1,useNativeDriver:true})]).start(function(){animateWidth();setDisplayState(function(previousState){return _objectSpread2(_objectSpread2({},previousState),{},{hideButton:true});});});}};},[]);return/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$2,{onLayout:function onLayout(event){return !hasSetButtonWidth&&!active&&setButtonWidth(event.nativeEvent.layout.width);},activeOpacity:0.8,onPress:onPress,style:[style,{bottom:displayState.hideButton?-(marginBottom+theme.__hd__.fab.sizes.height*2):(_StyleSheet$flatten2=reactNative.StyleSheet.flatten(style))===null||_StyleSheet$flatten2===void 0?void 0:_StyleSheet$flatten2.bottom,transform:[{translateY:animatedValues.translateY.interpolate({inputRange:[0,1],outputRange:[0,marginBottom+theme.__hd__.fab.sizes.height*2]})}]}],testID:testID,themeActive:active},/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,{style:{flexDirection:'row',opacity:animatedValues.opacity.interpolate({inputRange:[0,1],outputRange:[0,1]})}},isIconOnly?/*#__PURE__*/React__default__namespace.default.createElement(IconOnlyContent,{animated:animated,active:active,icon:active?'add':icon}):/*#__PURE__*/React__default__namespace.default.createElement(IconWithTextContent,{icon:icon,title:title})));});FAB$1.displayName='FAB';var StyledContainer$4=index$b(reactNative.View)({position:'absolute',left:0,right:0,top:0,bottom:0,alignItems:'flex-end',justifyContent:'flex-end'});var StyledContainerInModal=index$b(reactNative.View)({position:'absolute',left:0,right:0,top:0,bottom:0,alignItems:'flex-end',justifyContent:'flex-end'});var StyledActionGroupContainer=index$b(reactNative.Animated.View)({alignItems:'flex-end',justifyContent:'flex-end',width:'70%'});var StyledFAB$1=index$b(FAB$1)(function(_ref){var theme=_ref.theme;return {marginRight:theme.__hd__.fab.space.buttonMarginRight,marginTop:theme.__hd__.fab.space.buttonMarginTop,alignSelf:'flex-end'};});var StyledBackdropPressable=index$b(reactNative.Pressable)(function(){return {position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'transparent'};});var StyledBackdrop=index$b(Box)(function(_ref2){var theme=_ref2.theme;return {position:'absolute',left:0,right:0,top:0,bottom:0,opacity:0.4,backgroundColor:theme.__hd__.fab.colors.backdropBackground};});var ActionGroup=/*#__PURE__*/React__default.forwardRef(function(_ref,ref){var headerTitle=_ref.headerTitle,onPress=_ref.onPress,active=_ref.active,style=_ref.style,items=_ref.items,testID=_ref.testID,fabTitle=_ref.fabTitle,onBackdropPress=_ref.onBackdropPress,_ref$fabIcon=_ref.fabIcon,fabIcon=_ref$fabIcon===void 0?'add':_ref$fabIcon,_ref$supportedOrienta=_ref.supportedOrientations,supportedOrientations=_ref$supportedOrienta===void 0?['portrait']:_ref$supportedOrienta;useDeprecation("FAB.ActionGroup's headerTitle prop will be removed in the next major release. Please remove it.",headerTitle!==undefined);var theme=useTheme();var fabRef=React__default.useRef(null);var animatedValue=React__default.useRef(new reactNative.Animated.Value(active?1:0));React__default__namespace.default.useImperativeHandle(ref,function(){return {showFAB:function showFAB(){var _fabRef$current;return (_fabRef$current=fabRef.current)===null||_fabRef$current===void 0?void 0:_fabRef$current.show();},collapseFAB:function collapseFAB(){var _fabRef$current2;return (_fabRef$current2=fabRef.current)===null||_fabRef$current2===void 0?void 0:_fabRef$current2.collapse();},hideFAB:function hideFAB(){var _fabRef$current3;return (_fabRef$current3=fabRef.current)===null||_fabRef$current3===void 0?void 0:_fabRef$current3.hide();}};},[fabRef]);React__default__namespace.default.useEffect(function(){reactNative.Animated.spring(animatedValue.current,{toValue:active?1:0,delay:100,useNativeDriver:reactNative.Platform.OS!=='web'}).start();if(active){var _fabRef$current4;(_fabRef$current4=fabRef.current)===null||_fabRef$current4===void 0||_fabRef$current4.collapse();}else {var _fabRef$current5;(_fabRef$current5=fabRef.current)===null||_fabRef$current5===void 0||_fabRef$current5.show();}},[active]);var actionGroupOpacity=animatedValue.current.interpolate({inputRange:[0,1],outputRange:[0,1]});return/*#__PURE__*/React__default__namespace.default.createElement(StyledContainer$4,{testID:testID,pointerEvents:"box-none",style:style},/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$1,{key:"fab",testID:"fab",icon:fabIcon,onPress:onPress,animated:true,active:active,title:fabTitle,ref:fabRef})),/*#__PURE__*/React__default__namespace.default.createElement(reactNative.Modal,{visible:active,animationType:"fade",transparent:true,statusBarTranslucent:true,supportedOrientations:supportedOrientations},/*#__PURE__*/React__default__namespace.default.createElement(StyledContainerInModal,{testID:testID,style:[style]},/*#__PURE__*/React__default__namespace.default.createElement(StyledBackdropPressable,{testID:"back-drop",onPress:onBackdropPress},active&&/*#__PURE__*/React__default__namespace.default.createElement(Portal$1,null,/*#__PURE__*/React__default__namespace.default.createElement(StyledBackdrop,null))),/*#__PURE__*/React__default__namespace.default.createElement(StyledActionGroupContainer,{testID:"action-group",pointerEvents:"box-none",style:{opacity:actionGroupOpacity}},/*#__PURE__*/React__default__namespace.default.createElement(Box,{style:{paddingBottom:0}},items===null||items===void 0?void 0:items.map(function(itemProp,index){return/*#__PURE__*/React__default__namespace.default.createElement(ActionItem,_extends$1({key:itemProp.key||"".concat(itemProp.icon,"_").concat(itemProp.title)},itemProp,{index:active?index:items.length-index,active:active}));}))),active&&/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB$1// This FAB is moved up a bit compared to the original FAB,
|
|
1711
1711
|
// set marginBottom to negative value to compensate for it
|
|
1712
1712
|
,{style:{marginBottom:-theme.space.xxsmall},key:"fab-in-portal",testID:"fab-in-portal",icon:fabIcon,onPress:onPress,animated:true,active:active,title:fabTitle}))));});ActionGroup.displayName='FAB.ActionGroup';var StyledFABPairWrapper=index$b(Box)({flexDirection:'row',justifyContent:'center',alignItems:'center'});var StyledFAB=index$b(FAB$1)(function(_ref){var theme=_ref.theme,_ref$iconOnly=_ref.iconOnly,iconOnly=_ref$iconOnly===void 0?false:_ref$iconOnly,_ref$isLast=_ref.isLast,isLast=_ref$isLast===void 0?false:_ref$isLast;return {height:theme.__hd__.fab.sizes.fabPairHeight,width:iconOnly?theme.__hd__.fab.sizes.fabPairIconOnlyWidth:undefined,marginRight:isLast?undefined:theme.__hd__.fab.space.fabPairMarginRight};});var _excluded$m=["fabConfig","onCancel"];var Pair=function Pair(_ref){var fabConfig=_ref.fabConfig,onCancel=_ref.onCancel,props=_objectWithoutProperties(_ref,_excluded$m);var icon=fabConfig.icon,title=fabConfig.title,onPress=fabConfig.onPress,testID=fabConfig.testID;return/*#__PURE__*/React__default__namespace.default.createElement(StyledFABPairWrapper,props,/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB,{icon:"cancel",onPress:onCancel,testID:"fab-pair-cancel",iconOnly:true}),/*#__PURE__*/React__default__namespace.default.createElement(StyledFAB,{icon:icon,title:title,onPress:onPress,testID:testID,iconOnly:!title,isLast:true}));};var FAB=Object.assign(FAB$1,{ActionGroup:ActionGroup,Pair:Pair});var ToastContainerWrapper=index$b(reactNative.View)(function(_ref){var theme=_ref.theme,position=_ref.position;return _objectSpread2(_objectSpread2({},reactNative.StyleSheet.absoluteFillObject),{},{paddingHorizontal:theme.__hd__.toast.space.wrapperVerticalPadding,paddingVertical:theme.__hd__.toast.space.wrapperHorizontalPadding,flexDirection:position==='bottom'?'column-reverse':'column',elevation:9999});});var Container=index$b(reactNative.Animated.View)(function(_ref2){var theme=_ref2.theme,themeVariant=_ref2.themeVariant,themeIntent=_ref2.themeIntent;return _objectSpread2({borderRadius:themeVariant==='round'?theme.__hd__.toast.radii["default"]:0,backgroundColor:theme.__hd__.toast.colors.backgrounds[themeIntent],minHeight:theme.__hd__.toast.sizes.height,flexDirection:'row'},theme.__hd__.toast.shadows.wrapper);});var IconContainer=index$b(reactNative.View)(function(_ref3){var theme=_ref3.theme;return {alignItems:'center',paddingLeft:theme.__hd__.toast.space.iconLeftPadding};});var TextContainer=index$b(reactNative.View)(function(_ref4){var theme=_ref4.theme;return {paddingHorizontal:theme.__hd__.toast.space.textHorizontalPadding,flex:1};});var ContentContainer=index$b(reactNative.View)(function(_ref5){var theme=_ref5.theme,showDivider=_ref5.showDivider;return {paddingVertical:theme.__hd__.toast.space.contentVerticalPadding,flex:1,borderRightWidth:showDivider?theme.__hd__.toast.borderWidths.base:0,borderColor:theme.__hd__.toast.colors.divider,flexDirection:'row'};});var CTAWrapper=index$b(reactNative.TouchableOpacity)(function(_ref6){var theme=_ref6.theme;return {paddingHorizontal:theme.__hd__.toast.space.ctaPadding,justifyContent:'center'};});var StyledBody=index$b(Typography.Body)(function(_ref7){var theme=_ref7.theme,themeIntent=_ref7.themeIntent;return {color:theme.__hd__.toast.colors.texts[themeIntent]};});var StyledIcon$2=index$b(Icon)(function(_ref8){var theme=_ref8.theme,themeIntent=_ref8.themeIntent;return {color:theme.__hd__.toast.colors.texts[themeIntent]};});var fallbackToastControlContext={show:function show(_){return '';},hide:function hide(_){// Fallback empty function
|
|
1713
1713
|
},clearAll:function clearAll(){// Fallback empty function
|
|
@@ -2254,7 +2254,8 @@ var FloatingLabel = function FloatingLabel(_ref) {
|
|
|
2254
2254
|
isFocused = _ref.isFocused,
|
|
2255
2255
|
required = _ref.required,
|
|
2256
2256
|
accessibilityLabelledBy = _ref.accessibilityLabelledBy,
|
|
2257
|
-
isEmptyValue = _ref.isEmptyValue
|
|
2257
|
+
isEmptyValue = _ref.isEmptyValue,
|
|
2258
|
+
testID = _ref.testID;
|
|
2258
2259
|
var theme = useWorkTheme();
|
|
2259
2260
|
var shouldFloat = isFocused || !isEmptyValue;
|
|
2260
2261
|
var focusAnimation = React__default.useRef(new reactNative.Animated.Value(shouldFloat ? 1 : 0)).current;
|
|
@@ -2266,6 +2267,7 @@ var FloatingLabel = function FloatingLabel(_ref) {
|
|
|
2266
2267
|
useNativeDriver: true
|
|
2267
2268
|
}).start();
|
|
2268
2269
|
}, [shouldFloat, focusAnimation]);
|
|
2270
|
+
var testIDSuffix = testID ? "-".concat(testID) : '';
|
|
2269
2271
|
return /*#__PURE__*/React__default__namespace.default.createElement(StyledFloatingLabelContainer, {
|
|
2270
2272
|
themeVariant: variant,
|
|
2271
2273
|
style: [{
|
|
@@ -2282,14 +2284,15 @@ var FloatingLabel = function FloatingLabel(_ref) {
|
|
|
2282
2284
|
outputRange: [1.333, 1]
|
|
2283
2285
|
})
|
|
2284
2286
|
}]
|
|
2285
|
-
}]
|
|
2287
|
+
}],
|
|
2288
|
+
testID: "input-label".concat(testIDSuffix)
|
|
2286
2289
|
}, /*#__PURE__*/React__default__namespace.default.createElement(reactNative.Animated.View, {
|
|
2287
2290
|
style: {
|
|
2288
2291
|
flexDirection: 'row'
|
|
2289
2292
|
}
|
|
2290
2293
|
}, /*#__PURE__*/React__default__namespace.default.createElement(StyledLabel, {
|
|
2291
2294
|
nativeID: accessibilityLabelledBy,
|
|
2292
|
-
testID: "input-label",
|
|
2295
|
+
testID: "input-label-text".concat(testIDSuffix),
|
|
2293
2296
|
themeState: state,
|
|
2294
2297
|
numberOfLines: 1,
|
|
2295
2298
|
style: {
|
|
@@ -2811,7 +2814,8 @@ var InternalTextInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
2811
2814
|
isFocused: isFocused,
|
|
2812
2815
|
required: required,
|
|
2813
2816
|
accessibilityLabelledBy: accessibilityLabelledBy,
|
|
2814
|
-
isEmptyValue: isEmptyValue
|
|
2817
|
+
isEmptyValue: isEmptyValue,
|
|
2818
|
+
testID: testID
|
|
2815
2819
|
}), /*#__PURE__*/React__default__namespace.default.createElement(InputRow, {
|
|
2816
2820
|
ref: innerTextInput,
|
|
2817
2821
|
state: state,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn-work-uikit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@emotion/native": "^11.9.3",
|
|
24
24
|
"@emotion/primitives-core": "11.0.0",
|
|
25
25
|
"@emotion/react": "^11.9.3",
|
|
26
|
-
"@hero-design/rn": "^8.
|
|
26
|
+
"@hero-design/rn": "^8.103.2-alpha.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@hero-design/react-native-month-year-picker": "^8.43.1",
|
|
@@ -21,6 +21,8 @@ export interface FloatingLabelProps {
|
|
|
21
21
|
accessibilityLabelledBy?: string;
|
|
22
22
|
/** Whether the input value is empty */
|
|
23
23
|
isEmptyValue: boolean;
|
|
24
|
+
/** Testing id of the input component. */
|
|
25
|
+
testID?: string;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -53,6 +55,7 @@ const FloatingLabel: React.FC<FloatingLabelProps> = ({
|
|
|
53
55
|
required,
|
|
54
56
|
accessibilityLabelledBy,
|
|
55
57
|
isEmptyValue,
|
|
58
|
+
testID,
|
|
56
59
|
}) => {
|
|
57
60
|
const theme = useTheme();
|
|
58
61
|
const shouldFloat = isFocused || !isEmptyValue;
|
|
@@ -69,6 +72,8 @@ const FloatingLabel: React.FC<FloatingLabelProps> = ({
|
|
|
69
72
|
}).start();
|
|
70
73
|
}, [shouldFloat, focusAnimation]);
|
|
71
74
|
|
|
75
|
+
const testIDSuffix = testID ? `-${testID}` : '';
|
|
76
|
+
|
|
72
77
|
return (
|
|
73
78
|
<StyledFloatingLabelContainer
|
|
74
79
|
themeVariant={variant}
|
|
@@ -96,6 +101,7 @@ const FloatingLabel: React.FC<FloatingLabelProps> = ({
|
|
|
96
101
|
],
|
|
97
102
|
},
|
|
98
103
|
]}
|
|
104
|
+
testID={`input-label${testIDSuffix}`}
|
|
99
105
|
>
|
|
100
106
|
<Animated.View
|
|
101
107
|
style={{
|
|
@@ -104,7 +110,7 @@ const FloatingLabel: React.FC<FloatingLabelProps> = ({
|
|
|
104
110
|
>
|
|
105
111
|
<StyledLabel
|
|
106
112
|
nativeID={accessibilityLabelledBy}
|
|
107
|
-
testID=
|
|
113
|
+
testID={`input-label-text${testIDSuffix}`}
|
|
108
114
|
themeState={state}
|
|
109
115
|
numberOfLines={1}
|
|
110
116
|
style={{
|
|
@@ -120,6 +120,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
120
120
|
],
|
|
121
121
|
]
|
|
122
122
|
}
|
|
123
|
+
testID="input-label"
|
|
123
124
|
themeVariant="text"
|
|
124
125
|
>
|
|
125
126
|
<AnimatedView
|
|
@@ -155,7 +156,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
155
156
|
],
|
|
156
157
|
]
|
|
157
158
|
}
|
|
158
|
-
testID="input-label"
|
|
159
|
+
testID="input-label-text"
|
|
159
160
|
themeFontWeight="regular"
|
|
160
161
|
themeIntent="body"
|
|
161
162
|
themeState="filled"
|
|
@@ -373,6 +374,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
373
374
|
],
|
|
374
375
|
]
|
|
375
376
|
}
|
|
377
|
+
testID="input-label-text-input-2"
|
|
376
378
|
themeVariant="text"
|
|
377
379
|
>
|
|
378
380
|
<AnimatedView
|
|
@@ -408,7 +410,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
408
410
|
],
|
|
409
411
|
]
|
|
410
412
|
}
|
|
411
|
-
testID="input-label"
|
|
413
|
+
testID="input-label-text-text-input-2"
|
|
412
414
|
themeFontWeight="regular"
|
|
413
415
|
themeIntent="body"
|
|
414
416
|
themeState="error"
|
|
@@ -735,6 +737,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
735
737
|
],
|
|
736
738
|
]
|
|
737
739
|
}
|
|
740
|
+
testID="input-label"
|
|
738
741
|
themeVariant="text"
|
|
739
742
|
>
|
|
740
743
|
<AnimatedView
|
|
@@ -770,7 +773,7 @@ exports[`TextInputGroup should render: xxx 1`] = `
|
|
|
770
773
|
],
|
|
771
774
|
]
|
|
772
775
|
}
|
|
773
|
-
testID="input-label"
|
|
776
|
+
testID="input-label-text"
|
|
774
777
|
themeFontWeight="regular"
|
|
775
778
|
themeIntent="body"
|
|
776
779
|
themeState="filled"
|
|
@@ -74,7 +74,7 @@ Here's what to look for in your unit tests:
|
|
|
74
74
|
it('should display an asterisk for required fields', () => {
|
|
75
75
|
const { getByText } = render(<TextInput label="My Field" required />);
|
|
76
76
|
// This will now fail
|
|
77
|
-
expect(getByText('*')).toBeTruthy();
|
|
77
|
+
expect(getByText('*')).toBeTruthy();
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
// New test for optional field
|
|
@@ -82,7 +82,7 @@ Here's what to look for in your unit tests:
|
|
|
82
82
|
const { queryByText } = render(<TextInput label="My Field" required={false} />);
|
|
83
83
|
expect(queryByText(/\(Optional\)/)).toBeTruthy();
|
|
84
84
|
});
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
// New test for required field
|
|
87
87
|
it('should not display (Optional) for required fields', () => {
|
|
88
88
|
const { queryByText } = render(<TextInput label="My Field" required={true} />);
|
|
@@ -96,38 +96,3 @@ Here's what to look for in your unit tests:
|
|
|
96
96
|
|
|
97
97
|
* **Interaction Tests:**
|
|
98
98
|
* If you have tests that simulate user input, the floating label will animate. This shouldn't affect most tests, but if you have complex tests that check for element positions, they might need adjustment.
|
|
99
|
-
|
|
100
|
-
### 4.3. Breaking Change: `testID` Handling
|
|
101
|
-
|
|
102
|
-
The way `testID` is applied to the underlying native `TextInput` component has changed, which will break existing tests that query for the input field.
|
|
103
|
-
|
|
104
|
-
* **Old Behavior (`@hero-design/rn`):** The `testID` for the native input was dynamically created by appending `-text-input` to the `testID` prop (e.g., `my-test-id-text-input`).
|
|
105
|
-
* **New Behavior (`@hero-design/rn-work-uikit`):** The `testID` for the native input is now **hardcoded to `'text-input'`.**
|
|
106
|
-
|
|
107
|
-
Your tests must be updated to reflect this change.
|
|
108
|
-
|
|
109
|
-
**Example Test Update:**
|
|
110
|
-
|
|
111
|
-
```javascript
|
|
112
|
-
// Old test query
|
|
113
|
-
const input = getByTestId('my-form-field-text-input');
|
|
114
|
-
|
|
115
|
-
// New test query
|
|
116
|
-
const input = getByTestId('text-input');
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Because the native input `testID` is now static, if you have multiple `TextInput` components on one screen, you must first scope your query to the correct component container.
|
|
120
|
-
|
|
121
|
-
**Example with multiple `TextInput`s:**
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
import { render, within } from '@testing-library/react-native';
|
|
125
|
-
|
|
126
|
-
// Get the container for a specific TextInput using its unique testID
|
|
127
|
-
const textInputContainer = getByTestId('my-unique-test-id');
|
|
128
|
-
|
|
129
|
-
// Find the native input within that container
|
|
130
|
-
const nativeInput = within(textInputContainer).getByTestId('text-input');
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
This plan should provide a good starting point for the migration. The key is to be aware of the visual changes and to thoroughly test all instances of the `TextInput` component.
|
|
@@ -133,7 +133,7 @@ describe('FloatingLabel', () => {
|
|
|
133
133
|
);
|
|
134
134
|
|
|
135
135
|
// User should have proper accessibility support
|
|
136
|
-
const label = getByTestId('input-label');
|
|
136
|
+
const label = getByTestId('input-label-text');
|
|
137
137
|
expect(label).toHaveProp('nativeID', accessibilityId);
|
|
138
138
|
});
|
|
139
139
|
});
|
|
@@ -163,7 +163,7 @@ describe('FloatingLabel', () => {
|
|
|
163
163
|
/>
|
|
164
164
|
);
|
|
165
165
|
|
|
166
|
-
const label = getByTestId('input-label');
|
|
166
|
+
const label = getByTestId('input-label-text');
|
|
167
167
|
expect(label).toHaveProp('themeState', state);
|
|
168
168
|
}
|
|
169
169
|
);
|
|
@@ -183,7 +183,7 @@ describe('FloatingLabel', () => {
|
|
|
183
183
|
);
|
|
184
184
|
|
|
185
185
|
// User should see a fully rendered floating label
|
|
186
|
-
const label = getByTestId('input-label');
|
|
186
|
+
const label = getByTestId('input-label-text');
|
|
187
187
|
expect(label).toBeTruthy();
|
|
188
188
|
expect(label).toHaveProp('nativeID', 'fullname-label');
|
|
189
189
|
expect(label).toHaveTextContent('Full Name');
|
|
@@ -104,6 +104,7 @@ exports[`TextInput when user applies custom styling should respect user-provided
|
|
|
104
104
|
],
|
|
105
105
|
]
|
|
106
106
|
}
|
|
107
|
+
testID="input-label"
|
|
107
108
|
themeVariant="text"
|
|
108
109
|
>
|
|
109
110
|
<AnimatedView
|
|
@@ -139,7 +140,7 @@ exports[`TextInput when user applies custom styling should respect user-provided
|
|
|
139
140
|
],
|
|
140
141
|
]
|
|
141
142
|
}
|
|
142
|
-
testID="input-label"
|
|
143
|
+
testID="input-label-text"
|
|
143
144
|
themeFontWeight="regular"
|
|
144
145
|
themeIntent="body"
|
|
145
146
|
themeState="filled"
|
|
@@ -451,6 +452,7 @@ exports[`TextInput when user chooses textarea variant should provide multiline t
|
|
|
451
452
|
],
|
|
452
453
|
]
|
|
453
454
|
}
|
|
455
|
+
testID="input-label"
|
|
454
456
|
themeVariant="textarea"
|
|
455
457
|
>
|
|
456
458
|
<AnimatedView
|
|
@@ -486,7 +488,7 @@ exports[`TextInput when user chooses textarea variant should provide multiline t
|
|
|
486
488
|
],
|
|
487
489
|
]
|
|
488
490
|
}
|
|
489
|
-
testID="input-label"
|
|
491
|
+
testID="input-label-text"
|
|
490
492
|
themeFontWeight="regular"
|
|
491
493
|
themeIntent="body"
|
|
492
494
|
themeState="filled"
|
|
@@ -731,6 +733,7 @@ exports[`TextInput when user encounters a disabled field should display content
|
|
|
731
733
|
],
|
|
732
734
|
]
|
|
733
735
|
}
|
|
736
|
+
testID="input-label"
|
|
734
737
|
themeVariant="text"
|
|
735
738
|
>
|
|
736
739
|
<AnimatedView
|
|
@@ -766,7 +769,7 @@ exports[`TextInput when user encounters a disabled field should display content
|
|
|
766
769
|
],
|
|
767
770
|
]
|
|
768
771
|
}
|
|
769
|
-
testID="input-label"
|
|
772
|
+
testID="input-label-text"
|
|
770
773
|
themeFontWeight="regular"
|
|
771
774
|
themeIntent="body"
|
|
772
775
|
themeState="disabled"
|
|
@@ -1010,6 +1013,7 @@ exports[`TextInput when user encounters a read-only field should display content
|
|
|
1010
1013
|
],
|
|
1011
1014
|
]
|
|
1012
1015
|
}
|
|
1016
|
+
testID="input-label"
|
|
1013
1017
|
themeVariant="text"
|
|
1014
1018
|
>
|
|
1015
1019
|
<AnimatedView
|
|
@@ -1045,7 +1049,7 @@ exports[`TextInput when user encounters a read-only field should display content
|
|
|
1045
1049
|
],
|
|
1046
1050
|
]
|
|
1047
1051
|
}
|
|
1048
|
-
testID="input-label"
|
|
1052
|
+
testID="input-label-text"
|
|
1049
1053
|
themeFontWeight="regular"
|
|
1050
1054
|
themeIntent="body"
|
|
1051
1055
|
themeState="readonly"
|
|
@@ -1363,6 +1367,7 @@ exports[`TextInput when user has entered text should show the input content and
|
|
|
1363
1367
|
],
|
|
1364
1368
|
]
|
|
1365
1369
|
}
|
|
1370
|
+
testID="input-label"
|
|
1366
1371
|
themeVariant="text"
|
|
1367
1372
|
>
|
|
1368
1373
|
<AnimatedView
|
|
@@ -1398,7 +1403,7 @@ exports[`TextInput when user has entered text should show the input content and
|
|
|
1398
1403
|
],
|
|
1399
1404
|
]
|
|
1400
1405
|
}
|
|
1401
|
-
testID="input-label"
|
|
1406
|
+
testID="input-label-text"
|
|
1402
1407
|
themeFontWeight="regular"
|
|
1403
1408
|
themeIntent="body"
|
|
1404
1409
|
themeState="filled"
|
|
@@ -1716,6 +1721,7 @@ exports[`TextInput when user interacts with placeholder text starting from empty
|
|
|
1716
1721
|
],
|
|
1717
1722
|
]
|
|
1718
1723
|
}
|
|
1724
|
+
testID="input-label"
|
|
1719
1725
|
themeVariant="text"
|
|
1720
1726
|
>
|
|
1721
1727
|
<AnimatedView
|
|
@@ -1751,7 +1757,7 @@ exports[`TextInput when user interacts with placeholder text starting from empty
|
|
|
1751
1757
|
],
|
|
1752
1758
|
]
|
|
1753
1759
|
}
|
|
1754
|
-
testID="input-label"
|
|
1760
|
+
testID="input-label-text"
|
|
1755
1761
|
themeFontWeight="regular"
|
|
1756
1762
|
themeIntent="body"
|
|
1757
1763
|
themeState="default"
|
|
@@ -2026,6 +2032,7 @@ exports[`TextInput when user needs programmatic control should provide ref metho
|
|
|
2026
2032
|
],
|
|
2027
2033
|
]
|
|
2028
2034
|
}
|
|
2035
|
+
testID="input-label"
|
|
2029
2036
|
themeVariant="text"
|
|
2030
2037
|
>
|
|
2031
2038
|
<AnimatedView
|
|
@@ -2061,7 +2068,7 @@ exports[`TextInput when user needs programmatic control should provide ref metho
|
|
|
2061
2068
|
],
|
|
2062
2069
|
]
|
|
2063
2070
|
}
|
|
2064
|
-
testID="input-label"
|
|
2071
|
+
testID="input-label-text"
|
|
2065
2072
|
themeFontWeight="regular"
|
|
2066
2073
|
themeIntent="body"
|
|
2067
2074
|
themeState="filled"
|
|
@@ -2305,6 +2312,7 @@ exports[`TextInput when user provides default values starting with pre-filled co
|
|
|
2305
2312
|
],
|
|
2306
2313
|
]
|
|
2307
2314
|
}
|
|
2315
|
+
testID="input-label"
|
|
2308
2316
|
themeVariant="text"
|
|
2309
2317
|
>
|
|
2310
2318
|
<AnimatedView
|
|
@@ -2340,7 +2348,7 @@ exports[`TextInput when user provides default values starting with pre-filled co
|
|
|
2340
2348
|
],
|
|
2341
2349
|
]
|
|
2342
2350
|
}
|
|
2343
|
-
testID="input-label"
|
|
2351
|
+
testID="input-label-text"
|
|
2344
2352
|
themeFontWeight="regular"
|
|
2345
2353
|
themeIntent="body"
|
|
2346
2354
|
themeState="filled"
|
|
@@ -2651,6 +2659,7 @@ exports[`TextInput when user provides default values when both default and contr
|
|
|
2651
2659
|
],
|
|
2652
2660
|
]
|
|
2653
2661
|
}
|
|
2662
|
+
testID="input-label"
|
|
2654
2663
|
themeVariant="text"
|
|
2655
2664
|
>
|
|
2656
2665
|
<AnimatedView
|
|
@@ -2686,7 +2695,7 @@ exports[`TextInput when user provides default values when both default and contr
|
|
|
2686
2695
|
],
|
|
2687
2696
|
]
|
|
2688
2697
|
}
|
|
2689
|
-
testID="input-label"
|
|
2698
|
+
testID="input-label-text"
|
|
2690
2699
|
themeFontWeight="regular"
|
|
2691
2700
|
themeIntent="body"
|
|
2692
2701
|
themeState="filled"
|
|
@@ -2998,6 +3007,7 @@ exports[`TextInput when user sees a loading state should show loading indicator
|
|
|
2998
3007
|
],
|
|
2999
3008
|
]
|
|
3000
3009
|
}
|
|
3010
|
+
testID="input-label"
|
|
3001
3011
|
themeVariant="text"
|
|
3002
3012
|
>
|
|
3003
3013
|
<AnimatedView
|
|
@@ -3033,7 +3043,7 @@ exports[`TextInput when user sees a loading state should show loading indicator
|
|
|
3033
3043
|
],
|
|
3034
3044
|
]
|
|
3035
3045
|
}
|
|
3036
|
-
testID="input-label"
|
|
3046
|
+
testID="input-label-text"
|
|
3037
3047
|
themeFontWeight="regular"
|
|
3038
3048
|
themeIntent="body"
|
|
3039
3049
|
themeState="readonly"
|
|
@@ -3370,6 +3380,7 @@ exports[`TextInput when user sees a required field should indicate the field is
|
|
|
3370
3380
|
],
|
|
3371
3381
|
]
|
|
3372
3382
|
}
|
|
3383
|
+
testID="input-label"
|
|
3373
3384
|
themeVariant="text"
|
|
3374
3385
|
>
|
|
3375
3386
|
<AnimatedView
|
|
@@ -3405,7 +3416,7 @@ exports[`TextInput when user sees a required field should indicate the field is
|
|
|
3405
3416
|
],
|
|
3406
3417
|
]
|
|
3407
3418
|
}
|
|
3408
|
-
testID="input-label"
|
|
3419
|
+
testID="input-label-text"
|
|
3409
3420
|
themeFontWeight="regular"
|
|
3410
3421
|
themeIntent="body"
|
|
3411
3422
|
themeState="default"
|
|
@@ -3693,6 +3704,7 @@ exports[`TextInput when user sees a textarea with character count should display
|
|
|
3693
3704
|
],
|
|
3694
3705
|
]
|
|
3695
3706
|
}
|
|
3707
|
+
testID="input-label"
|
|
3696
3708
|
themeVariant="textarea"
|
|
3697
3709
|
>
|
|
3698
3710
|
<AnimatedView
|
|
@@ -3728,7 +3740,7 @@ exports[`TextInput when user sees a textarea with character count should display
|
|
|
3728
3740
|
],
|
|
3729
3741
|
]
|
|
3730
3742
|
}
|
|
3731
|
-
testID="input-label"
|
|
3743
|
+
testID="input-label-text"
|
|
3732
3744
|
themeFontWeight="regular"
|
|
3733
3745
|
themeIntent="body"
|
|
3734
3746
|
themeState="filled"
|
|
@@ -4083,6 +4095,7 @@ exports[`TextInput when user sees a textarea with character count should hide ch
|
|
|
4083
4095
|
],
|
|
4084
4096
|
]
|
|
4085
4097
|
}
|
|
4098
|
+
testID="input-label"
|
|
4086
4099
|
themeVariant="textarea"
|
|
4087
4100
|
>
|
|
4088
4101
|
<AnimatedView
|
|
@@ -4118,7 +4131,7 @@ exports[`TextInput when user sees a textarea with character count should hide ch
|
|
|
4118
4131
|
],
|
|
4119
4132
|
]
|
|
4120
4133
|
}
|
|
4121
|
-
testID="input-label"
|
|
4134
|
+
testID="input-label-text"
|
|
4122
4135
|
themeFontWeight="regular"
|
|
4123
4136
|
themeIntent="body"
|
|
4124
4137
|
themeState="filled"
|
|
@@ -4440,6 +4453,7 @@ exports[`TextInput when user sees an empty input field should display label and
|
|
|
4440
4453
|
],
|
|
4441
4454
|
]
|
|
4442
4455
|
}
|
|
4456
|
+
testID="input-label"
|
|
4443
4457
|
themeVariant="text"
|
|
4444
4458
|
>
|
|
4445
4459
|
<AnimatedView
|
|
@@ -4475,7 +4489,7 @@ exports[`TextInput when user sees an empty input field should display label and
|
|
|
4475
4489
|
],
|
|
4476
4490
|
]
|
|
4477
4491
|
}
|
|
4478
|
-
testID="input-label"
|
|
4492
|
+
testID="input-label-text"
|
|
4479
4493
|
themeFontWeight="regular"
|
|
4480
4494
|
themeIntent="body"
|
|
4481
4495
|
themeState="default"
|
|
@@ -4792,6 +4806,7 @@ exports[`TextInput when user sees an error state should display error message to
|
|
|
4792
4806
|
],
|
|
4793
4807
|
]
|
|
4794
4808
|
}
|
|
4809
|
+
testID="input-label"
|
|
4795
4810
|
themeVariant="text"
|
|
4796
4811
|
>
|
|
4797
4812
|
<AnimatedView
|
|
@@ -4827,7 +4842,7 @@ exports[`TextInput when user sees an error state should display error message to
|
|
|
4827
4842
|
],
|
|
4828
4843
|
]
|
|
4829
4844
|
}
|
|
4830
|
-
testID="input-label"
|
|
4845
|
+
testID="input-label-text"
|
|
4831
4846
|
themeFontWeight="regular"
|
|
4832
4847
|
themeIntent="body"
|
|
4833
4848
|
themeState="error"
|
|
@@ -5160,6 +5175,7 @@ exports[`TextInput when user sees helper text should display guidance text to as
|
|
|
5160
5175
|
],
|
|
5161
5176
|
]
|
|
5162
5177
|
}
|
|
5178
|
+
testID="input-label"
|
|
5163
5179
|
themeVariant="text"
|
|
5164
5180
|
>
|
|
5165
5181
|
<AnimatedView
|
|
@@ -5195,7 +5211,7 @@ exports[`TextInput when user sees helper text should display guidance text to as
|
|
|
5195
5211
|
],
|
|
5196
5212
|
]
|
|
5197
5213
|
}
|
|
5198
|
-
testID="input-label"
|
|
5214
|
+
testID="input-label-text"
|
|
5199
5215
|
themeFontWeight="regular"
|
|
5200
5216
|
themeIntent="body"
|
|
5201
5217
|
themeState="default"
|
|
@@ -5470,6 +5486,7 @@ exports[`TextInput when user sees input with custom prefix and suffix elements s
|
|
|
5470
5486
|
],
|
|
5471
5487
|
]
|
|
5472
5488
|
}
|
|
5489
|
+
testID="input-label"
|
|
5473
5490
|
themeVariant="text"
|
|
5474
5491
|
>
|
|
5475
5492
|
<AnimatedView
|
|
@@ -5505,7 +5522,7 @@ exports[`TextInput when user sees input with custom prefix and suffix elements s
|
|
|
5505
5522
|
],
|
|
5506
5523
|
]
|
|
5507
5524
|
}
|
|
5508
|
-
testID="input-label"
|
|
5525
|
+
testID="input-label-text"
|
|
5509
5526
|
themeFontWeight="regular"
|
|
5510
5527
|
themeIntent="body"
|
|
5511
5528
|
themeState="default"
|