react-native-platform-components 1.3.0 → 1.4.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/README.md +24 -30
- package/android/src/main/java/com/platformcomponents/PCButtonGroupView.kt +498 -0
- package/android/src/main/java/com/platformcomponents/PCButtonGroupViewManager.kt +191 -0
- package/android/src/main/java/com/platformcomponents/PCButtonSupport.kt +127 -0
- package/android/src/main/java/com/platformcomponents/PCButtonView.kt +345 -0
- package/android/src/main/java/com/platformcomponents/PCButtonViewManager.kt +126 -0
- package/android/src/main/java/com/platformcomponents/PCExpressive.kt +107 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarView.kt +115 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarViewManager.kt +65 -0
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlView.kt +11 -3
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlViewManager.kt +6 -1
- package/android/src/main/java/com/platformcomponents/PCTextFieldView.kt +1018 -0
- package/android/src/main/java/com/platformcomponents/PCTextFieldViewManager.kt +248 -0
- package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +4 -0
- package/android/src/main/res/values/attrs.xml +13 -0
- package/android/src/main/res/values/styles.xml +183 -0
- package/ios/PCButton.h +10 -0
- package/ios/PCButton.mm +196 -0
- package/ios/PCButtonGroup.h +10 -0
- package/ios/PCButtonGroup.mm +256 -0
- package/ios/PCButtonGroupView.swift +254 -0
- package/ios/PCButtonSupport.swift +141 -0
- package/ios/PCButtonView.swift +155 -0
- package/ios/PCFloatingToolbar.h +10 -0
- package/ios/PCFloatingToolbar.mm +76 -0
- package/ios/PCFloatingToolbarView.swift +95 -0
- package/ios/PCTextField.h +10 -0
- package/ios/PCTextField.mm +391 -0
- package/ios/PCTextFieldView.swift +1012 -0
- package/lib/commonjs/Button.js +77 -0
- package/lib/commonjs/Button.js.map +1 -0
- package/lib/commonjs/ButtonGroup.js +99 -0
- package/lib/commonjs/ButtonGroup.js.map +1 -0
- package/lib/commonjs/ButtonGroupNativeComponent.ts +121 -0
- package/lib/commonjs/ButtonNativeComponent.ts +76 -0
- package/lib/commonjs/FloatingToolbar.js +69 -0
- package/lib/commonjs/FloatingToolbar.js.map +1 -0
- package/lib/commonjs/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/commonjs/SegmentedControl.js +11 -85
- package/lib/commonjs/SegmentedControl.js.map +1 -1
- package/lib/commonjs/SegmentedControlNativeComponent.ts +3 -0
- package/lib/commonjs/TextField.js +195 -0
- package/lib/commonjs/TextField.js.map +1 -0
- package/lib/commonjs/TextFieldNativeComponent.ts +218 -0
- package/lib/commonjs/focusRegistry.js +78 -0
- package/lib/commonjs/focusRegistry.js.map +1 -0
- package/lib/commonjs/icons.js +92 -0
- package/lib/commonjs/icons.js.map +1 -0
- package/lib/commonjs/index.js +66 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +32 -2
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/labelStyle.js +27 -0
- package/lib/commonjs/labelStyle.js.map +1 -0
- package/lib/commonjs/reactNativeInternals.d.js +2 -0
- package/lib/commonjs/reactNativeInternals.d.js.map +1 -0
- package/lib/module/Button.js +70 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/ButtonGroup.js +92 -0
- package/lib/module/ButtonGroup.js.map +1 -0
- package/lib/module/ButtonGroupNativeComponent.ts +121 -0
- package/lib/module/ButtonNativeComponent.ts +76 -0
- package/lib/module/FloatingToolbar.js +62 -0
- package/lib/module/FloatingToolbar.js.map +1 -0
- package/lib/module/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/module/SegmentedControl.js +12 -87
- package/lib/module/SegmentedControl.js.map +1 -1
- package/lib/module/SegmentedControlNativeComponent.ts +3 -0
- package/lib/module/TextField.js +189 -0
- package/lib/module/TextField.js.map +1 -0
- package/lib/module/TextFieldNativeComponent.ts +218 -0
- package/lib/module/focusRegistry.js +74 -0
- package/lib/module/focusRegistry.js.map +1 -0
- package/lib/module/icons.js +87 -0
- package/lib/module/icons.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +28 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/labelStyle.js +23 -0
- package/lib/module/labelStyle.js.map +1 -0
- package/lib/module/reactNativeInternals.d.js +2 -0
- package/lib/module/reactNativeInternals.d.js.map +1 -0
- package/lib/typescript/commonjs/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Button.d.ts +76 -0
- package/lib/typescript/commonjs/src/Button.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts +102 -0
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts +93 -0
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts +57 -0
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts +45 -0
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts +24 -0
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts +17 -46
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +2 -0
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/TextField.d.ts +174 -0
- package/lib/typescript/commonjs/src/TextField.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts +162 -0
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/focusRegistry.d.ts +13 -0
- package/lib/typescript/commonjs/src/focusRegistry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/icons.d.ts +52 -0
- package/lib/typescript/commonjs/src/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.web.d.ts +121 -0
- package/lib/typescript/commonjs/src/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/labelStyle.d.ts +20 -0
- package/lib/typescript/commonjs/src/labelStyle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/sharedTypes.d.ts +6 -1
- package/lib/typescript/commonjs/src/sharedTypes.d.ts.map +1 -1
- package/lib/typescript/module/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/module/src/Button.d.ts +76 -0
- package/lib/typescript/module/src/Button.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonGroup.d.ts +102 -0
- package/lib/typescript/module/src/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts +93 -0
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts +57 -0
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/FloatingToolbar.d.ts +45 -0
- package/lib/typescript/module/src/FloatingToolbar.d.ts.map +1 -0
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts +24 -0
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/SegmentedControl.d.ts +17 -46
- package/lib/typescript/module/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +2 -0
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/TextField.d.ts +174 -0
- package/lib/typescript/module/src/TextField.d.ts.map +1 -0
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts +162 -0
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/focusRegistry.d.ts +13 -0
- package/lib/typescript/module/src/focusRegistry.d.ts.map +1 -0
- package/lib/typescript/module/src/icons.d.ts +52 -0
- package/lib/typescript/module/src/icons.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +6 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.web.d.ts +121 -0
- package/lib/typescript/module/src/index.web.d.ts.map +1 -1
- package/lib/typescript/module/src/labelStyle.d.ts +20 -0
- package/lib/typescript/module/src/labelStyle.d.ts.map +1 -0
- package/lib/typescript/module/src/sharedTypes.d.ts +6 -1
- package/lib/typescript/module/src/sharedTypes.d.ts.map +1 -1
- package/package.json +25 -4
- package/react-native.config.js +3 -0
- package/shared/PCButtonComponentDescriptors-custom.h +22 -0
- package/shared/PCButtonGroupComponentDescriptors-custom.h +22 -0
- package/shared/PCButtonGroupShadowNode-custom.cpp +48 -0
- package/shared/PCButtonGroupShadowNode-custom.h +55 -0
- package/shared/PCButtonGroupState-custom.h +61 -0
- package/shared/PCButtonShadowNode-custom.cpp +48 -0
- package/shared/PCButtonShadowNode-custom.h +55 -0
- package/shared/PCButtonState-custom.h +61 -0
- package/shared/PCTextFieldComponentDescriptors-custom.h +22 -0
- package/shared/PCTextFieldShadowNode-custom.cpp +47 -0
- package/shared/PCTextFieldShadowNode-custom.h +55 -0
- package/shared/PCTextFieldState-custom.h +61 -0
- package/shared/react/renderer/components/PlatformComponentsViewSpec/ComponentDescriptors.h +3 -0
- package/src/Button.tsx +144 -0
- package/src/ButtonGroup.tsx +233 -0
- package/src/ButtonGroupNativeComponent.ts +121 -0
- package/src/ButtonNativeComponent.ts +76 -0
- package/src/FloatingToolbar.tsx +113 -0
- package/src/FloatingToolbarNativeComponent.ts +31 -0
- package/src/SegmentedControl.tsx +26 -118
- package/src/SegmentedControlNativeComponent.ts +3 -0
- package/src/TextField.tsx +494 -0
- package/src/TextFieldNativeComponent.ts +218 -0
- package/src/focusRegistry.ts +89 -0
- package/src/icons.ts +116 -0
- package/src/index.tsx +6 -0
- package/src/index.web.tsx +194 -0
- package/src/labelStyle.ts +36 -0
- package/src/reactNativeInternals.d.ts +22 -0
- package/src/sharedTypes.ts +7 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// FloatingToolbarNativeComponent.ts
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* iOS-specific configuration.
|
|
7
|
+
*/
|
|
8
|
+
export type FloatingToolbarIOSProps = Readonly<{
|
|
9
|
+
/** Glass effect style on iOS 26: 'regular' | 'clear' */
|
|
10
|
+
effect?: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Android-specific configuration.
|
|
15
|
+
*/
|
|
16
|
+
export type FloatingToolbarAndroidProps = Readonly<{
|
|
17
|
+
/** Material color variant: 'standard' | 'vibrant' */
|
|
18
|
+
variant?: string;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
export interface FloatingToolbarNativeProps extends ViewProps {
|
|
22
|
+
/** Container color. Default: the platform's toolbar material. */
|
|
23
|
+
color?: ColorValue;
|
|
24
|
+
|
|
25
|
+
ios?: FloatingToolbarIOSProps;
|
|
26
|
+
android?: FloatingToolbarAndroidProps;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default codegenNativeComponent<FloatingToolbarNativeProps>(
|
|
30
|
+
'PCFloatingToolbar'
|
|
31
|
+
) as HostComponent<FloatingToolbarNativeProps>;
|
|
@@ -2,31 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// SegmentedControl.tsx
|
|
4
4
|
import React, { useCallback, useMemo } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
6
6
|
import NativeSegmentedControl from './SegmentedControlNativeComponent';
|
|
7
|
-
|
|
7
|
+
import { resolveIcon } from "./icons.js";
|
|
8
|
+
import { normalizeLabelStyle } from "./labelStyle.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
10
|
// Android: Minimum height to ensure visibility.
|
|
9
11
|
// Fabric's shadow node measurement isn't being called on initial render,
|
|
10
12
|
// so we apply a minHeight that matches Material design touch target guidelines.
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const ANDROID_MIN_HEIGHT = 48;
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
* A single icon source.
|
|
16
|
-
*
|
|
17
|
-
* - `string`: shorthand for an SF Symbol name on iOS and a drawable resource
|
|
18
|
-
* name on Android (the original API).
|
|
19
|
-
* - `{ type: 'sfSymbol' }`: an SF Symbol. iOS only; ignored on Android.
|
|
20
|
-
* - `{ type: 'drawable' }`: a drawable from the app's `res/drawable`.
|
|
21
|
-
* Android only; ignored on iOS.
|
|
22
|
-
* - `{ type: 'image' }`: an image asset (`require('./icon.png')`) or a
|
|
23
|
-
* `{ uri }` source. Works on both platforms. Images are drawn as tinted
|
|
24
|
-
* templates unless `tinted` is `false`.
|
|
25
|
-
*/
|
|
15
|
+
/** A single icon source. Alias of {@link PlatformIconSource}. */
|
|
26
16
|
|
|
27
17
|
/**
|
|
28
18
|
* An icon for a segment: a single source used on both platforms, or a
|
|
29
|
-
* per-platform pair
|
|
19
|
+
* per-platform pair. Alias of {@link PlatformIcon}.
|
|
30
20
|
*/
|
|
31
21
|
|
|
32
22
|
/**
|
|
@@ -39,72 +29,14 @@ const ANDROID_MIN_HEIGHT = 48;
|
|
|
39
29
|
* their label. Screen readers still announce the label on both platforms.
|
|
40
30
|
*/
|
|
41
31
|
|
|
42
|
-
/**
|
|
43
|
-
* Font for segment labels. Each field falls back to the platform default.
|
|
44
|
-
*/
|
|
32
|
+
/** Font for segment labels. Alias of {@link LabelStyle}. */
|
|
45
33
|
|
|
46
34
|
/**
|
|
47
35
|
* Badge colors. Both default to the platform look (red with white text).
|
|
48
36
|
*/
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
iconName: '',
|
|
53
|
-
iconUri: '',
|
|
54
|
-
iconScale: 1,
|
|
55
|
-
iconTinted: 'true'
|
|
56
|
-
};
|
|
57
|
-
function pickIconSource(icon) {
|
|
58
|
-
if (icon === undefined || typeof icon === 'string' || 'type' in icon) {
|
|
59
|
-
return icon;
|
|
60
|
-
}
|
|
61
|
-
return Platform.OS === 'ios' ? icon.ios : icon.android;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Flattens the public icon shape into the strings native expects, dropping
|
|
66
|
-
* sources that don't apply to the current platform.
|
|
67
|
-
*/
|
|
68
|
-
export function resolveSegmentIcon(icon) {
|
|
69
|
-
const source = pickIconSource(icon);
|
|
70
|
-
if (source === undefined) return NO_ICON;
|
|
71
|
-
if (typeof source === 'string') {
|
|
72
|
-
if (source.length === 0) return NO_ICON;
|
|
73
|
-
return {
|
|
74
|
-
...NO_ICON,
|
|
75
|
-
iconType: Platform.OS === 'ios' ? 'sfSymbol' : 'drawable',
|
|
76
|
-
iconName: source
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
switch (source.type) {
|
|
80
|
-
case 'sfSymbol':
|
|
81
|
-
return Platform.OS === 'ios' ? {
|
|
82
|
-
...NO_ICON,
|
|
83
|
-
iconType: 'sfSymbol',
|
|
84
|
-
iconName: source.name
|
|
85
|
-
} : NO_ICON;
|
|
86
|
-
case 'drawable':
|
|
87
|
-
return Platform.OS === 'android' ? {
|
|
88
|
-
...NO_ICON,
|
|
89
|
-
iconType: 'drawable',
|
|
90
|
-
iconName: source.name
|
|
91
|
-
} : NO_ICON;
|
|
92
|
-
case 'image':
|
|
93
|
-
{
|
|
94
|
-
const resolved = Image.resolveAssetSource(source.source);
|
|
95
|
-
if (!resolved?.uri) return NO_ICON;
|
|
96
|
-
return {
|
|
97
|
-
iconType: 'image',
|
|
98
|
-
iconName: '',
|
|
99
|
-
iconUri: resolved.uri,
|
|
100
|
-
iconScale: resolved.scale > 0 ? resolved.scale : 1,
|
|
101
|
-
iconTinted: source.tinted === false ? 'false' : 'true'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
default:
|
|
105
|
-
return NO_ICON;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
38
|
+
/** Flattens a segment icon for native. Alias of {@link resolveIcon}. */
|
|
39
|
+
export const resolveSegmentIcon = resolveIcon;
|
|
108
40
|
function normalizeSelectedValue(selected) {
|
|
109
41
|
return selected ?? '';
|
|
110
42
|
}
|
|
@@ -165,21 +97,14 @@ export function SegmentedControl(props) {
|
|
|
165
97
|
const nativeSelectedSegmentColor = selectedSegmentColor ?? (Platform.OS === 'ios' ? ios?.selectedSegmentTintColor : undefined);
|
|
166
98
|
|
|
167
99
|
// Normalize the label font; empty / 0 means platform default
|
|
168
|
-
const nativeLabelStyle = useMemo(() =>
|
|
169
|
-
if (!labelStyle) return undefined;
|
|
170
|
-
return {
|
|
171
|
-
fontFamily: labelStyle.fontFamily ?? '',
|
|
172
|
-
fontSize: labelStyle.fontSize ?? 0,
|
|
173
|
-
fontWeight: labelStyle.fontWeight === undefined ? '' : String(labelStyle.fontWeight),
|
|
174
|
-
fontStyle: labelStyle.fontStyle ?? ''
|
|
175
|
-
};
|
|
176
|
-
}, [labelStyle]);
|
|
100
|
+
const nativeLabelStyle = useMemo(() => normalizeLabelStyle(labelStyle), [labelStyle]);
|
|
177
101
|
|
|
178
102
|
// Normalize Android props
|
|
179
103
|
const nativeAndroid = useMemo(() => {
|
|
180
104
|
if (!android) return undefined;
|
|
181
105
|
return {
|
|
182
|
-
selectionRequired: android.selectionRequired === false ? 'false' : 'true'
|
|
106
|
+
selectionRequired: android.selectionRequired === false ? 'false' : 'true',
|
|
107
|
+
material: android.material ?? 'expressive'
|
|
183
108
|
};
|
|
184
109
|
}, [android]);
|
|
185
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMemo","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","Platform","StyleSheet","NativeSegmentedControl","resolveIcon","normalizeLabelStyle","jsx","_jsx","ANDROID_MIN_HEIGHT","resolveSegmentIcon","normalizeSelectedValue","selected","SegmentedControl","props","style","segments","selectedValue","disabled","labelVisibility","selectedSegmentColor","activeTintColor","inactiveTintColor","labelStyle","badgeStyle","onSelect","onDeselect","ios","android","viewProps","nativeSegments","map","seg","label","value","badge","undefined","String","accessibilityLabel","icon","selectedData","handleSelect","e","index","nativeEvent","nativeIos","momentary","apportionsSegmentWidthsByContent","nativeSelectedSegmentColor","OS","selectedSegmentTintColor","nativeLabelStyle","nativeAndroid","selectionRequired","material","mergedStyle","styles","androidDefault","interactivity","androidRippleColor","rippleColor","androidStrokeColor","strokeColor","badgeBackgroundColor","backgroundColor","badgeTextColor","color","create","minHeight"],"sourceRoot":"../../src","sources":["SegmentedControl.tsx"],"mappings":";;AAAA;AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SACEC,QAAQ,EACRC,UAAU,QAKL,cAAc;AAErB,OAAOC,sBAAsB,MAGtB,mCAAmC;AAC1C,SACEC,WAAW,QAGN,YAAS;AAChB,SAASC,mBAAmB,QAAyB,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGpE;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,EAAE;;AAE7B;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAGA;AACA;AACA;;AAsIA;AACA,OAAO,MAAMC,kBAAkB,GAAGL,WAAW;AAE7C,SAASM,sBAAsBA,CAACC,QAAuB,EAAU;EAC/D,OAAOA,QAAQ,IAAI,E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,aAAa,EAAExC,QAAQ,GAAG,UAAU,GAAG,SAAU;IACjDC,eAAe,EAAEA,eAAe,IAAI,MAAO;IAC3CC,oBAAoB,EAAE4B,0BAA2B;IACjD3B,eAAe,EAAEA,eAAgB;IACjCC,iBAAiB,EAAEA,iBAAkB;IACrCqC,kBAAkB,EAAE/B,OAAO,EAAEgC,WAAY;IACzCC,kBAAkB,EAAEjC,OAAO,EAAEkC,WAAY;IACzCvC,UAAU,EAAE4B,gBAAiB;IAC7BY,oBAAoB,EAAEvC,UAAU,EAAEwC,eAAgB;IAClDC,cAAc,EAAEzC,UAAU,EAAE0C,KAAM;IAClCzC,QAAQ,EAAEA,QAAQ,IAAIC,UAAU,GAAGe,YAAY,GAAGL,SAAU;IAC5DT,GAAG,EAAEkB,SAAU;IACfjB,OAAO,EAAEwB,aAAc;IAAA,GACnBvB;EAAS,CACd,CAAC;AAEN;AAEA,MAAM2B,MAAM,GAAGrD,UAAU,CAACgE,MAAM,CAAC;EAC/BV,cAAc,EAAE;IACdW,SAAS,EAAE3D;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -72,6 +72,9 @@ export type IOSProps = Readonly<{
|
|
|
72
72
|
export type AndroidProps = Readonly<{
|
|
73
73
|
/** Whether one segment must always be selected */
|
|
74
74
|
selectionRequired?: string; // 'true' | 'false'
|
|
75
|
+
|
|
76
|
+
/** Material style: 'm3' | 'expressive' */
|
|
77
|
+
material?: string;
|
|
75
78
|
}>;
|
|
76
79
|
|
|
77
80
|
export interface SegmentedControlProps extends ViewProps {
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// TextField.tsx
|
|
4
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import NativeTextField, { Commands } from './TextFieldNativeComponent';
|
|
6
|
+
import { resolveIcon } from "./icons.js";
|
|
7
|
+
import { normalizeLabelStyle } from "./labelStyle.js";
|
|
8
|
+
import { focusRegistry } from "./focusRegistry.js";
|
|
9
|
+
|
|
10
|
+
/** Keyboard to show; the React Native `TextInput` values. */
|
|
11
|
+
|
|
12
|
+
/** Return key label; the React Native `TextInput` values. */
|
|
13
|
+
|
|
14
|
+
/** Autofill hint; a cross-platform subset of the React Native `TextInput` values. */
|
|
15
|
+
|
|
16
|
+
/** An iOS text trait: the system default, on, or off. */
|
|
17
|
+
|
|
18
|
+
/** Focus, blur and submit events carry the text at that moment. */
|
|
19
|
+
|
|
20
|
+
/** Change events carry the text and the native edit counter. */
|
|
21
|
+
|
|
22
|
+
/** Methods available through the `ref`. */
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
export const TextField = /*#__PURE__*/forwardRef(function TextFieldComponent(props, ref) {
|
|
25
|
+
const {
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
onChangeText,
|
|
29
|
+
onChange,
|
|
30
|
+
onFocus,
|
|
31
|
+
onBlur,
|
|
32
|
+
onSubmitEditing,
|
|
33
|
+
label,
|
|
34
|
+
placeholder,
|
|
35
|
+
supportingText,
|
|
36
|
+
error,
|
|
37
|
+
prefix,
|
|
38
|
+
suffix,
|
|
39
|
+
leadingIcon,
|
|
40
|
+
trailingIcon,
|
|
41
|
+
onTrailingIconPress,
|
|
42
|
+
clearButtonMode,
|
|
43
|
+
passwordToggle,
|
|
44
|
+
showCharacterCount,
|
|
45
|
+
maxLength,
|
|
46
|
+
keyboardType,
|
|
47
|
+
returnKeyType,
|
|
48
|
+
autoCapitalize,
|
|
49
|
+
autoCorrect,
|
|
50
|
+
secureTextEntry,
|
|
51
|
+
multiline,
|
|
52
|
+
editable,
|
|
53
|
+
autoFocus,
|
|
54
|
+
selectTextOnFocus,
|
|
55
|
+
autoComplete,
|
|
56
|
+
keyboardAppearance,
|
|
57
|
+
textStyle,
|
|
58
|
+
accessibilityLabel,
|
|
59
|
+
ios,
|
|
60
|
+
android,
|
|
61
|
+
...viewProps
|
|
62
|
+
} = props;
|
|
63
|
+
const nativeRef = useRef(null);
|
|
64
|
+
const focused = useRef(false);
|
|
65
|
+
|
|
66
|
+
// The same synchronization as React Native's TextInput: every native edit
|
|
67
|
+
// reports an event count, and a controlled value is pushed with the last
|
|
68
|
+
// count JS has seen. Native drops the update when the user has typed
|
|
69
|
+
// since, and the edit that follows brings JS back in line.
|
|
70
|
+
const [mostRecentEventCount, setMostRecentEventCount] = useState(0);
|
|
71
|
+
const [lastNativeText, setLastNativeText] = useState(value ?? defaultValue);
|
|
72
|
+
|
|
73
|
+
// Registered like a TextInput, so Keyboard.dismiss() and the ScrollView
|
|
74
|
+
// keyboard props treat the field as one (see focusRegistry.ts)
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const node = nativeRef.current;
|
|
77
|
+
if (node == null) return undefined;
|
|
78
|
+
focusRegistry.register(node);
|
|
79
|
+
return () => focusRegistry.unregister(node);
|
|
80
|
+
}, []);
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
if (typeof value !== 'string' || value === lastNativeText) return;
|
|
83
|
+
setLastNativeText(value);
|
|
84
|
+
const node = nativeRef.current;
|
|
85
|
+
if (node != null) {
|
|
86
|
+
Commands.setText(node, mostRecentEventCount, value);
|
|
87
|
+
}
|
|
88
|
+
}, [value, lastNativeText, mostRecentEventCount]);
|
|
89
|
+
useImperativeHandle(ref, () => ({
|
|
90
|
+
focus: () => {
|
|
91
|
+
const node = nativeRef.current;
|
|
92
|
+
if (node != null) Commands.focus(node);
|
|
93
|
+
},
|
|
94
|
+
blur: () => {
|
|
95
|
+
const node = nativeRef.current;
|
|
96
|
+
if (node != null) Commands.blur(node);
|
|
97
|
+
},
|
|
98
|
+
clear: () => {
|
|
99
|
+
const node = nativeRef.current;
|
|
100
|
+
if (node != null) Commands.clear(node);
|
|
101
|
+
},
|
|
102
|
+
isFocused: () => focused.current
|
|
103
|
+
}), []);
|
|
104
|
+
const handleChange = useCallback(event => {
|
|
105
|
+
const {
|
|
106
|
+
text,
|
|
107
|
+
eventCount
|
|
108
|
+
} = event.nativeEvent;
|
|
109
|
+
setMostRecentEventCount(eventCount);
|
|
110
|
+
setLastNativeText(text);
|
|
111
|
+
onChange?.(event);
|
|
112
|
+
onChangeText?.(text);
|
|
113
|
+
}, [onChange, onChangeText]);
|
|
114
|
+
const handleFocus = useCallback(event => {
|
|
115
|
+
focused.current = true;
|
|
116
|
+
focusRegistry.focused(nativeRef.current);
|
|
117
|
+
onFocus?.(event);
|
|
118
|
+
}, [onFocus]);
|
|
119
|
+
const handleBlur = useCallback(event => {
|
|
120
|
+
focused.current = false;
|
|
121
|
+
focusRegistry.blurred(nativeRef.current);
|
|
122
|
+
onBlur?.(event);
|
|
123
|
+
}, [onBlur]);
|
|
124
|
+
const handleSubmit = useCallback(event => {
|
|
125
|
+
onSubmitEditing?.(event);
|
|
126
|
+
}, [onSubmitEditing]);
|
|
127
|
+
const handleTrailingIconPress = useCallback(() => {
|
|
128
|
+
onTrailingIconPress?.();
|
|
129
|
+
}, [onTrailingIconPress]);
|
|
130
|
+
const nativeLeadingIcon = useMemo(() => resolveIcon(leadingIcon), [leadingIcon]);
|
|
131
|
+
const nativeTrailingIcon = useMemo(() => resolveIcon(trailingIcon), [trailingIcon]);
|
|
132
|
+
const nativeTextStyle = useMemo(() => normalizeLabelStyle(textStyle), [textStyle]);
|
|
133
|
+
const nativeIOS = useMemo(() => ({
|
|
134
|
+
writingTools: ios?.writingTools ?? '',
|
|
135
|
+
inlinePrediction: ios?.inlinePrediction ?? '',
|
|
136
|
+
smartQuotes: ios?.smartQuotes ?? '',
|
|
137
|
+
smartDashes: ios?.smartDashes ?? '',
|
|
138
|
+
smartInsertDelete: ios?.smartInsertDelete ?? '',
|
|
139
|
+
mathExpressionCompletion: ios?.mathExpressionCompletion ?? '',
|
|
140
|
+
borderStyle: ios?.borderStyle ?? '',
|
|
141
|
+
labelPlacement: ios?.labelPlacement ?? '',
|
|
142
|
+
labelWidth: ios?.labelWidth ?? 0
|
|
143
|
+
}), [ios]);
|
|
144
|
+
const nativeAndroid = useMemo(() => ({
|
|
145
|
+
material: android?.material ?? 'm3',
|
|
146
|
+
variant: android?.variant ?? 'outlined',
|
|
147
|
+
density: android?.dense ? 'dense' : 'standard'
|
|
148
|
+
}), [android]);
|
|
149
|
+
return /*#__PURE__*/_jsx(NativeTextField, {
|
|
150
|
+
ref: nativeRef,
|
|
151
|
+
initialText: value ?? defaultValue ?? '',
|
|
152
|
+
label: label ?? '',
|
|
153
|
+
placeholder: placeholder ?? '',
|
|
154
|
+
supportingText: supportingText ?? '',
|
|
155
|
+
errorState: error ? 'error' : 'none',
|
|
156
|
+
errorText: typeof error === 'string' ? error : '',
|
|
157
|
+
prefix: prefix ?? '',
|
|
158
|
+
suffix: suffix ?? '',
|
|
159
|
+
leadingIcon: nativeLeadingIcon,
|
|
160
|
+
trailingIcon: nativeTrailingIcon,
|
|
161
|
+
clearButtonMode: clearButtonMode ?? 'never',
|
|
162
|
+
passwordToggle: passwordToggle ? 'shown' : 'hidden',
|
|
163
|
+
characterCount: showCharacterCount ? 'shown' : 'hidden',
|
|
164
|
+
maxLength: maxLength ?? 0,
|
|
165
|
+
keyboardType: keyboardType ?? 'default',
|
|
166
|
+
returnKeyType: returnKeyType ?? 'default',
|
|
167
|
+
autoCapitalize: autoCapitalize ?? 'sentences',
|
|
168
|
+
autoCorrect: autoCorrect === false ? 'disabled' : 'enabled',
|
|
169
|
+
secureTextEntry: secureTextEntry ? 'secure' : 'plain',
|
|
170
|
+
lines: multiline ? 'multiline' : 'single',
|
|
171
|
+
interactivity: editable === false ? 'disabled' : 'enabled',
|
|
172
|
+
autoFocus: autoFocus ? 'focus' : 'none',
|
|
173
|
+
selectTextOnFocus: selectTextOnFocus ? 'select' : 'keep',
|
|
174
|
+
autoComplete: autoComplete ?? '',
|
|
175
|
+
keyboardAppearance: keyboardAppearance ?? 'default',
|
|
176
|
+
textStyle: nativeTextStyle,
|
|
177
|
+
spokenLabel: accessibilityLabel ?? '',
|
|
178
|
+
ios: nativeIOS,
|
|
179
|
+
android: nativeAndroid,
|
|
180
|
+
onFieldChange: handleChange,
|
|
181
|
+
onFieldFocus: handleFocus,
|
|
182
|
+
onFieldBlur: handleBlur,
|
|
183
|
+
onFieldSubmit: onSubmitEditing ? handleSubmit : undefined,
|
|
184
|
+
onTrailingIconPress: onTrailingIconPress ? handleTrailingIconPress : undefined,
|
|
185
|
+
...viewProps
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
TextField.displayName = 'TextField';
|
|
189
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","NativeTextField","Commands","resolveIcon","normalizeLabelStyle","focusRegistry","jsx","_jsx","TextField","TextFieldComponent","props","ref","value","defaultValue","onChangeText","onChange","onFocus","onBlur","onSubmitEditing","label","placeholder","supportingText","error","prefix","suffix","leadingIcon","trailingIcon","onTrailingIconPress","clearButtonMode","passwordToggle","showCharacterCount","maxLength","keyboardType","returnKeyType","autoCapitalize","autoCorrect","secureTextEntry","multiline","editable","autoFocus","selectTextOnFocus","autoComplete","keyboardAppearance","textStyle","accessibilityLabel","ios","android","viewProps","nativeRef","focused","mostRecentEventCount","setMostRecentEventCount","lastNativeText","setLastNativeText","node","current","undefined","register","unregister","setText","focus","blur","clear","isFocused","handleChange","event","text","eventCount","nativeEvent","handleFocus","handleBlur","blurred","handleSubmit","handleTrailingIconPress","nativeLeadingIcon","nativeTrailingIcon","nativeTextStyle","nativeIOS","writingTools","inlinePrediction","smartQuotes","smartDashes","smartInsertDelete","mathExpressionCompletion","borderStyle","labelPlacement","labelWidth","nativeAndroid","material","variant","density","dense","initialText","errorState","errorText","characterCount","lines","interactivity","spokenLabel","onFieldChange","onFieldFocus","onFieldBlur","onFieldSubmit","displayName"],"sourceRoot":"../../src","sources":["TextField.tsx"],"mappings":";;AAA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UAAW;IACxBgC,aAAa,EAAEpF,eAAe,GAAGsD,YAAY,GAAGhB,SAAU;IAC1D7B,mBAAmB,EACjBA,mBAAmB,GAAG8C,uBAAuB,GAAGjB,SACjD;IAAA,GACGT;EAAS,CACd,CAAC;AAEN,CACF,CAAC;AAEDvC,SAAS,CAAC+F,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// TextFieldNativeComponent.ts
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
4
|
+
import { codegenNativeCommands, codegenNativeComponent } from 'react-native';
|
|
5
|
+
import type { BubblingEventHandler, Double, Int32 } from './codegenTypes';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Icon fields, pre-resolved on the JS side (see icons.ts).
|
|
9
|
+
*/
|
|
10
|
+
export type TextFieldIconProps = Readonly<{
|
|
11
|
+
iconType: string; // '' | 'sfSymbol' | 'drawable' | 'image'
|
|
12
|
+
iconName: string; // SF Symbol (iOS) or drawable resource name (Android)
|
|
13
|
+
iconUri: string; // Resolved image URI when iconType === 'image'
|
|
14
|
+
iconScale: Double; // Resolved image scale when iconType === 'image'
|
|
15
|
+
iconTinted: string; // 'true' | 'false' — draw the image as a tinted template
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Text font. Empty strings / 0 mean "platform default".
|
|
20
|
+
*/
|
|
21
|
+
export type TextFieldTextStyleProps = Readonly<{
|
|
22
|
+
fontFamily?: string;
|
|
23
|
+
fontSize?: Double;
|
|
24
|
+
fontWeight?: string; // 'normal' | 'bold' | '100'..'900'
|
|
25
|
+
fontStyle?: string; // 'normal' | 'italic'
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Fired on every edit. `eventCount` is the native edit counter that JS hands
|
|
30
|
+
* back with `setText`, so a stale controlled value can't overwrite what the
|
|
31
|
+
* user typed since.
|
|
32
|
+
*/
|
|
33
|
+
export type TextFieldChangeEvent = Readonly<{
|
|
34
|
+
text: string;
|
|
35
|
+
eventCount: Int32;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
/** Focus, blur and submit carry the text at that moment. */
|
|
39
|
+
export type TextFieldTextEvent = Readonly<{
|
|
40
|
+
text: string;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* iOS-specific configuration. Every field is '' for the platform default.
|
|
45
|
+
*/
|
|
46
|
+
export type TextFieldIOSProps = Readonly<{
|
|
47
|
+
/** 'default' | 'complete' | 'limited' | 'none' (iOS 18) */
|
|
48
|
+
writingTools?: string;
|
|
49
|
+
/** 'default' | 'yes' | 'no' (iOS 17) */
|
|
50
|
+
inlinePrediction?: string;
|
|
51
|
+
/** 'default' | 'yes' | 'no' */
|
|
52
|
+
smartQuotes?: string;
|
|
53
|
+
/** 'default' | 'yes' | 'no' */
|
|
54
|
+
smartDashes?: string;
|
|
55
|
+
/** 'default' | 'yes' | 'no' */
|
|
56
|
+
smartInsertDelete?: string;
|
|
57
|
+
/** 'default' | 'yes' | 'no' (iOS 18) */
|
|
58
|
+
mathExpressionCompletion?: string;
|
|
59
|
+
/** 'roundedRect' | 'none' | 'line' | 'bezel' */
|
|
60
|
+
borderStyle?: string;
|
|
61
|
+
/** 'above' | 'leading': where the label sits */
|
|
62
|
+
labelPlacement?: string;
|
|
63
|
+
/** Width of a leading label column in points; 0 = default */
|
|
64
|
+
labelWidth?: Double;
|
|
65
|
+
}>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Android-specific configuration.
|
|
69
|
+
*/
|
|
70
|
+
export type TextFieldAndroidProps = Readonly<{
|
|
71
|
+
/** 'm3' | 'system' (AndroidMaterialMode) */
|
|
72
|
+
material?: string;
|
|
73
|
+
/** 'outlined' | 'filled' */
|
|
74
|
+
variant?: string;
|
|
75
|
+
/** 'standard' | 'dense' */
|
|
76
|
+
density?: string;
|
|
77
|
+
}>;
|
|
78
|
+
|
|
79
|
+
export interface TextFieldNativeProps extends ViewProps {
|
|
80
|
+
/**
|
|
81
|
+
* Text applied when the native view is created. Later updates go through
|
|
82
|
+
* the `setText` command so they can be checked against `eventCount`.
|
|
83
|
+
*/
|
|
84
|
+
initialText?: string;
|
|
85
|
+
|
|
86
|
+
/** Floating label (Android) / caption above the field (iOS). */
|
|
87
|
+
label?: string;
|
|
88
|
+
|
|
89
|
+
/** Placeholder shown while the field is empty. */
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
|
|
92
|
+
/** Helper text below the field. */
|
|
93
|
+
supportingText?: string;
|
|
94
|
+
|
|
95
|
+
/** 'none' | 'error' */
|
|
96
|
+
errorState?: string;
|
|
97
|
+
|
|
98
|
+
/** Error message shown instead of the supporting text. */
|
|
99
|
+
errorText?: string;
|
|
100
|
+
|
|
101
|
+
/** Text shown before the input, inside the field. */
|
|
102
|
+
prefix?: string;
|
|
103
|
+
|
|
104
|
+
/** Text shown after the input, inside the field. */
|
|
105
|
+
suffix?: string;
|
|
106
|
+
|
|
107
|
+
/** Icon at the start of the field. */
|
|
108
|
+
leadingIcon?: TextFieldIconProps;
|
|
109
|
+
|
|
110
|
+
/** Icon at the end of the field; pressing it fires onTrailingIconPress. */
|
|
111
|
+
trailingIcon?: TextFieldIconProps;
|
|
112
|
+
|
|
113
|
+
/** 'never' | 'while-editing' | 'unless-editing' | 'always' */
|
|
114
|
+
clearButtonMode?: string;
|
|
115
|
+
|
|
116
|
+
/** 'shown' | 'hidden': a button that toggles secure text entry. */
|
|
117
|
+
passwordToggle?: string;
|
|
118
|
+
|
|
119
|
+
/** 'shown' | 'hidden': the character counter. */
|
|
120
|
+
characterCount?: string;
|
|
121
|
+
|
|
122
|
+
/** Maximum number of UTF-16 characters; 0 = unlimited. */
|
|
123
|
+
maxLength?: Int32;
|
|
124
|
+
|
|
125
|
+
/** React Native keyboardType value. */
|
|
126
|
+
keyboardType?: string;
|
|
127
|
+
|
|
128
|
+
/** React Native returnKeyType value. */
|
|
129
|
+
returnKeyType?: string;
|
|
130
|
+
|
|
131
|
+
/** 'none' | 'sentences' | 'words' | 'characters' */
|
|
132
|
+
autoCapitalize?: string;
|
|
133
|
+
|
|
134
|
+
/** 'enabled' | 'disabled' */
|
|
135
|
+
autoCorrect?: string;
|
|
136
|
+
|
|
137
|
+
/** 'secure' | 'plain' */
|
|
138
|
+
secureTextEntry?: string;
|
|
139
|
+
|
|
140
|
+
/** 'single' | 'multiline' */
|
|
141
|
+
lines?: string;
|
|
142
|
+
|
|
143
|
+
/** 'enabled' | 'disabled' */
|
|
144
|
+
interactivity?: string;
|
|
145
|
+
|
|
146
|
+
/** 'focus' | 'none': focus the field when it mounts. */
|
|
147
|
+
autoFocus?: string;
|
|
148
|
+
|
|
149
|
+
/** 'select' | 'keep': select all text on focus. */
|
|
150
|
+
selectTextOnFocus?: string;
|
|
151
|
+
|
|
152
|
+
/** React Native autoComplete value; '' = platform default. */
|
|
153
|
+
autoComplete?: string;
|
|
154
|
+
|
|
155
|
+
/** 'default' | 'light' | 'dark' (iOS keyboard appearance) */
|
|
156
|
+
keyboardAppearance?: string;
|
|
157
|
+
|
|
158
|
+
/** Font of the input text. */
|
|
159
|
+
textStyle?: TextFieldTextStyleProps;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Screen-reader label, applied to the native field rather than the host
|
|
163
|
+
* view. Empty means "use the label".
|
|
164
|
+
*/
|
|
165
|
+
spokenLabel?: string;
|
|
166
|
+
|
|
167
|
+
ios?: TextFieldIOSProps;
|
|
168
|
+
android?: TextFieldAndroidProps;
|
|
169
|
+
|
|
170
|
+
/** Fired on every user edit. */
|
|
171
|
+
onFieldChange?: BubblingEventHandler<TextFieldChangeEvent>;
|
|
172
|
+
|
|
173
|
+
/** Fired when the field gains focus. */
|
|
174
|
+
onFieldFocus?: BubblingEventHandler<TextFieldTextEvent>;
|
|
175
|
+
|
|
176
|
+
/** Fired when the field loses focus. */
|
|
177
|
+
onFieldBlur?: BubblingEventHandler<TextFieldTextEvent>;
|
|
178
|
+
|
|
179
|
+
/** Fired when the keyboard's return key is pressed (single-line). */
|
|
180
|
+
onFieldSubmit?: BubblingEventHandler<TextFieldTextEvent>;
|
|
181
|
+
|
|
182
|
+
/** Fired when the trailing icon is pressed. */
|
|
183
|
+
onTrailingIconPress?: BubblingEventHandler<Readonly<{}>>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
type NativeTextFieldComponent = HostComponent<TextFieldNativeProps>;
|
|
187
|
+
|
|
188
|
+
// `React.ElementRef` rather than `React.ComponentRef`: the codegen shipped with
|
|
189
|
+
// React Native 0.81 (and the 0.76 Android floor) only accepts the former.
|
|
190
|
+
interface NativeCommands {
|
|
191
|
+
/** Focuses the field and shows the keyboard. */
|
|
192
|
+
focus: (viewRef: React.ElementRef<NativeTextFieldComponent>) => void;
|
|
193
|
+
|
|
194
|
+
/** Removes focus and hides the keyboard. */
|
|
195
|
+
blur: (viewRef: React.ElementRef<NativeTextFieldComponent>) => void;
|
|
196
|
+
|
|
197
|
+
/** Clears the text; fires onFieldChange like a user edit. */
|
|
198
|
+
clear: (viewRef: React.ElementRef<NativeTextFieldComponent>) => void;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Replaces the text, unless the user has edited since `eventCount` was
|
|
202
|
+
* reported, in which case the update is dropped and the next edit event
|
|
203
|
+
* brings JS back in sync.
|
|
204
|
+
*/
|
|
205
|
+
setText: (
|
|
206
|
+
viewRef: React.ElementRef<NativeTextFieldComponent>,
|
|
207
|
+
eventCount: Int32,
|
|
208
|
+
text: string
|
|
209
|
+
) => void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
213
|
+
supportedCommands: ['focus', 'blur', 'clear', 'setText'],
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export default codegenNativeComponent<TextFieldNativeProps>(
|
|
217
|
+
'PCTextField'
|
|
218
|
+
) as NativeTextFieldComponent;
|