diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 9e4f29c94c9c..14d13fcb7a8d 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -208,6 +208,8 @@ export type TextContentType = | 'newPassword' | 'oneTimeCode'; +type PasswordRules = string; + type IOSProps = $ReadOnly<{| spellCheck?: ?boolean, keyboardAppearance?: ?('default' | 'light' | 'dark'), @@ -220,6 +222,7 @@ type IOSProps = $ReadOnly<{| | $ReadOnlyArray, inputAccessoryViewID?: ?string, textContentType?: ?TextContentType, + PasswordRules?: ?PasswordRules, scrollEnabled?: ?boolean, |}>; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index ff8bd3140d2a..c82c7b8142e7 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -260,6 +260,16 @@ - (void)setTextContentType:(NSString *)type #endif } + +- (void)setPasswordRules:(NSString *)descriptor +{ + #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0 + if (@available(iOS 12.0, *)) { + self.backedTextInputView.passwordRules = [UITextInputPasswordRules passwordRulesWithDescriptor:descriptor]; + } + #endif +} + - (UIKeyboardType)keyboardType { return self.backedTextInputView.keyboardType; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index d226782be62f..a1a3671be8ca 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -57,6 +57,7 @@ @implementation RCTBaseTextInputViewManager RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection) RCT_EXPORT_VIEW_PROPERTY(inputAccessoryViewID, NSString) RCT_EXPORT_VIEW_PROPERTY(textContentType, NSString) +RCT_EXPORT_VIEW_PROPERTY(passwordRules, NSString) RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)