Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iOS): add support for missing text content types #42788

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ export interface TextInputIOSProps {
* - `'birthdateDay'` (iOS 17+)
* - `'birthdateMonth'` (iOS 17+)
* - `'birthdateYear'` (iOS 17+)
* - `'dateTime'` (iOS 15+)
* - `'flightNumber'` (iOS 15+)
* - `'shipmentTrackingNumber'` (iOS 15+)
*
*/
textContentType?:
Expand Down Expand Up @@ -299,6 +302,9 @@ export interface TextInputIOSProps {
| 'birthdateDay'
| 'birthdateMonth'
| 'birthdateYear'
| 'dateTime'
| 'flightNumber'
| 'shipmentTrackingNumber'
| undefined;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ export type TextContentType =
| 'birthdate'
| 'birthdateDay'
| 'birthdateMonth'
| 'birthdateYear';
| 'birthdateYear'
| 'dateTime'
| 'flightNumber'
| 'shipmentTrackingNumber';

export type enterKeyHintType =
| 'enter'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export type TextContentType =
| 'birthdate'
| 'birthdateDay'
| 'birthdateMonth'
| 'birthdateYear';
| 'birthdateYear'
| 'dateTime'
| 'flightNumber'
| 'shipmentTrackingNumber';

export type enterKeyHintType =
// Cross Platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ - (void)setTextContentType:(NSString *)type
@"oneTimeCode" : UITextContentTypeOneTimeCode,
}];

if (@available(iOS 15.0, *)) {
[mutableContentTypeMap addEntriesFromDictionary:@{
@"dateTime" : UITextContentTypeDateTime,
@"flightNumber" : UITextContentTypeFlightNumber,
@"shipmentTrackingNumber" : UITextContentTypeShipmentTrackingNumber,
}];
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */
if (@available(iOS 17.0, *)) {
[mutableContentTypeMap addEntriesFromDictionary:@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,10 @@ export type TextContentType =
| \\"birthdate\\"
| \\"birthdateDay\\"
| \\"birthdateMonth\\"
| \\"birthdateYear\\";
| \\"birthdateYear\\"
| \\"dateTime\\"
| \\"flightNumber\\"
| \\"shipmentTrackingNumber\\";
export type enterKeyHintType =
| \\"enter\\"
| \\"done\\"
Expand Down Expand Up @@ -3307,7 +3310,10 @@ export type TextContentType =
| \\"birthdate\\"
| \\"birthdateDay\\"
| \\"birthdateMonth\\"
| \\"birthdateYear\\";
| \\"birthdateYear\\"
| \\"dateTime\\"
| \\"flightNumber\\"
| \\"shipmentTrackingNumber\\";
export type enterKeyHintType =
| \\"done\\"
| \\"go\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ UITextContentType RCTUITextContentTypeFromString(const std::string &contentType)
@"oneTimeCode" : UITextContentTypeOneTimeCode,
}];

if (@available(iOS 15.0, *)) {
[mutableContentTypeMap addEntriesFromDictionary:@{
@"dateTime" : UITextContentTypeDateTime,
@"flightNumber" : UITextContentTypeFlightNumber,
@"shipmentTrackingNumber" : UITextContentTypeShipmentTrackingNumber,
}];
}

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 /* __IPHONE_17_0 */
if (@available(iOS 17.0, *)) {
[mutableContentTypeMap addEntriesFromDictionary:@{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,15 @@ const textInputExamples: Array<RNTesterModuleExample> = [
<WithLabel label="birthdate">
<ExampleTextInput textContentType="birthdate" />
</WithLabel>
<WithLabel label="dateTime">
<ExampleTextInput textContentType="dateTime" />
</WithLabel>
<WithLabel label="flightNumber">
<ExampleTextInput textContentType="flightNumber" />
</WithLabel>
<WithLabel label="shipmentTrackingNumber">
<ExampleTextInput textContentType="shipmentTrackingNumber" />
</WithLabel>
</View>
);
},
Expand Down
Loading