@onekeyfe/react-native-text-input 0.3.0 → 3.0.91
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/OneKeyTextInput.podspec +18 -0
- package/README.md +10 -28
- package/android/build.gradle +3 -3
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/textinput/TextInputViewManager.kt +2 -2
- package/ios/OneKeyTextInputPasteObserver.h +11 -0
- package/ios/OneKeyTextInputPasteObserver.mm +204 -0
- package/lib/module/AndroidTextInputNativeComponent.js +111 -0
- package/lib/{commonjs → module}/Input.js +127 -107
- package/lib/module/enum.js +7 -0
- package/lib/module/index.js +11 -0
- package/lib/module/package.json +1 -0
- package/lib/module/type.js +4 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +4 -4
- package/lib/typescript/src/type.d.ts +2 -2
- package/package.json +32 -117
- package/react-native.config.js +12 -0
- package/src/AndroidTextInputNativeComponent.js +77 -88
- package/src/Input.js +242 -1027
- package/src/enum.ts +1 -1
- package/src/index.tsx +5 -5
- package/src/type.ts +2 -2
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerDelegate.java +0 -26
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/OneKeyTextInputManagerInterface.java +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -36
- package/android/generated/android/app/build/generated/source/codegen/jni/RNTextInputViewSpec-generated.cpp +0 -22
- package/android/generated/android/app/build/generated/source/codegen/jni/RNTextInputViewSpec.h +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.cpp +0 -22
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.h +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/EventEmitters.cpp +0 -24
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/EventEmitters.h +0 -25
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/Props.cpp +0 -25
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/Props.h +0 -27
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/RNTextInputViewSpecJSI-generated.cpp +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/RNTextInputViewSpecJSI.h +0 -19
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ShadowNodes.cpp +0 -17
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/ShadowNodes.h +0 -32
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/States.cpp +0 -16
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNTextInputViewSpec/States.h +0 -29
- package/android/src/newarch/TextInputViewManagerSpec.kt +0 -21
- package/android/src/oldarch/TextInputViewManagerSpec.kt +0 -9
- package/ios/TextInputViewManager.mm +0 -23
- package/ios/Utils.h +0 -8
- package/ios/Utils.m +0 -26
- package/ios/generated/build/generated/ios/RNTextInputViewSpec/RNTextInputViewSpec-generated.mm +0 -16
- package/ios/generated/build/generated/ios/RNTextInputViewSpec/RNTextInputViewSpec.h +0 -38
- package/ios/generated/build/generated/ios/RNTextInputViewSpecJSI-generated.cpp +0 -17
- package/ios/generated/build/generated/ios/RNTextInputViewSpecJSI.h +0 -19
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.cpp +0 -22
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ComponentDescriptors.h +0 -24
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/EventEmitters.cpp +0 -24
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/EventEmitters.h +0 -25
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/Props.cpp +0 -25
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/Props.h +0 -27
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/RCTComponentViewHelpers.h +0 -20
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ShadowNodes.cpp +0 -17
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/ShadowNodes.h +0 -32
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/States.cpp +0 -16
- package/ios/generated/build/generated/ios/react/renderer/components/RNTextInputViewSpec/States.h +0 -29
- package/lib/commonjs/AndroidTextInputNativeComponent.js +0 -152
- package/lib/commonjs/AndroidTextInputNativeComponent.js.map +0 -1
- package/lib/commonjs/Input.js.map +0 -1
- package/lib/commonjs/TextInputViewNativeComponent.ts +0 -9
- package/lib/commonjs/enum.js +0 -11
- package/lib/commonjs/enum.js.map +0 -1
- package/lib/commonjs/index.js +0 -28
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/type.js +0 -6
- package/lib/commonjs/type.js.map +0 -1
- package/lib/typescript/src/TextInputViewNativeComponent.d.ts +0 -8
- package/lib/typescript/src/TextInputViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/enum.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/type.d.ts.map +0 -1
- package/src/TextInputViewNativeComponent.ts +0 -9
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var React = _react;
|
|
19
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
3
|
+
import usePressability from 'react-native/Libraries/Pressability/usePressability';
|
|
4
|
+
import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
|
|
5
|
+
import StyleSheet from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
6
|
+
import Text from 'react-native/Libraries/Text/Text';
|
|
7
|
+
import TextAncestorContext from 'react-native/Libraries/Text/TextAncestorContext';
|
|
8
|
+
import Platform from 'react-native/Libraries/Utilities/Platform';
|
|
9
|
+
import useMergeRefs from 'react-native/Libraries/Utilities/useMergeRefs';
|
|
10
|
+
import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState';
|
|
11
|
+
import invariant from 'invariant';
|
|
12
|
+
import nullthrows from 'nullthrows';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import { findNodeHandle, NativeEventEmitter, NativeModules } from 'react-native';
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
const iosPasteEmitter = Platform.OS === 'ios' && NativeModules.OneKeyTextInputPasteObserver != null ? new NativeEventEmitter(NativeModules.OneKeyTextInputPasteObserver) : null;
|
|
23
18
|
let AndroidTextInput;
|
|
24
19
|
let AndroidTextInputCommands;
|
|
25
20
|
let RCTSinglelineTextInputView;
|
|
26
21
|
let RCTSinglelineTextInputNativeCommands;
|
|
27
22
|
let RCTMultilineTextInputView;
|
|
28
23
|
let RCTMultilineTextInputNativeCommands;
|
|
29
|
-
if (
|
|
24
|
+
if (Platform.OS === 'android') {
|
|
30
25
|
AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
|
|
31
26
|
AndroidTextInputCommands = require('./AndroidTextInputNativeComponent').Commands;
|
|
32
|
-
} else if (
|
|
27
|
+
} else if (Platform.OS === 'ios') {
|
|
33
28
|
RCTSinglelineTextInputView = require('react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent').default;
|
|
34
29
|
RCTSinglelineTextInputNativeCommands = require('react-native/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent').Commands;
|
|
35
30
|
RCTMultilineTextInputView = require('react-native/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent').default;
|
|
@@ -44,16 +39,16 @@ function useTextInputStateSynchronization({
|
|
|
44
39
|
text,
|
|
45
40
|
viewCommands
|
|
46
41
|
}) {
|
|
47
|
-
const [lastNativeText, setLastNativeText] =
|
|
48
|
-
const [lastNativeSelectionState, setLastNativeSelection] =
|
|
42
|
+
const [lastNativeText, setLastNativeText] = useState(props.value);
|
|
43
|
+
const [lastNativeSelectionState, setLastNativeSelection] = useState({
|
|
44
|
+
mostRecentEventCount,
|
|
49
45
|
selection: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
mostRecentEventCount: mostRecentEventCount
|
|
46
|
+
end: -1,
|
|
47
|
+
start: -1
|
|
48
|
+
}
|
|
54
49
|
});
|
|
55
50
|
const lastNativeSelection = lastNativeSelectionState.selection;
|
|
56
|
-
|
|
51
|
+
useLayoutEffect(() => {
|
|
57
52
|
const nativeUpdate = {};
|
|
58
53
|
if (lastNativeText !== props.value && typeof props.value === 'string') {
|
|
59
54
|
nativeUpdate.text = props.value;
|
|
@@ -62,8 +57,8 @@ function useTextInputStateSynchronization({
|
|
|
62
57
|
if (selection && lastNativeSelection && (lastNativeSelection.start !== selection.start || lastNativeSelection.end !== selection.end)) {
|
|
63
58
|
nativeUpdate.selection = selection;
|
|
64
59
|
setLastNativeSelection({
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
mostRecentEventCount,
|
|
61
|
+
selection
|
|
67
62
|
});
|
|
68
63
|
}
|
|
69
64
|
if (Object.keys(nativeUpdate).length === 0) {
|
|
@@ -74,8 +69,8 @@ function useTextInputStateSynchronization({
|
|
|
74
69
|
}
|
|
75
70
|
}, [mostRecentEventCount, inputRef, props.value, props.defaultValue, lastNativeText, selection, lastNativeSelection, text, viewCommands]);
|
|
76
71
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
setLastNativeSelection,
|
|
73
|
+
setLastNativeText
|
|
79
74
|
};
|
|
80
75
|
}
|
|
81
76
|
function InternalTextInput(props) {
|
|
@@ -92,54 +87,73 @@ function InternalTextInput(props) {
|
|
|
92
87
|
selectionColor,
|
|
93
88
|
selectionHandleColor,
|
|
94
89
|
cursorColor,
|
|
90
|
+
onPaste,
|
|
95
91
|
...otherProps
|
|
96
92
|
} = props;
|
|
97
|
-
const inputRef =
|
|
93
|
+
const inputRef = useRef(null);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (Platform.OS !== 'ios' || iosPasteEmitter == null || onPaste == null) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const subscription = iosPasteEmitter.addListener('OneKeyTextInputPaste', event => {
|
|
99
|
+
const target = findNodeHandle(inputRef.current);
|
|
100
|
+
if (target != null && target === event.target) {
|
|
101
|
+
onPaste({
|
|
102
|
+
nativeEvent: {
|
|
103
|
+
items: event.items
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return () => subscription.remove();
|
|
109
|
+
}, [onPaste]);
|
|
98
110
|
const selection = propsSelection == null ? null : {
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
end: propsSelection.end ?? propsSelection.start,
|
|
112
|
+
start: propsSelection.start
|
|
101
113
|
};
|
|
102
114
|
const text = typeof props.value === 'string' ? props.value : typeof props.defaultValue === 'string' ? props.defaultValue : undefined;
|
|
103
115
|
const viewCommands = AndroidTextInputCommands || (props.multiline === true ? RCTMultilineTextInputNativeCommands : RCTSinglelineTextInputNativeCommands);
|
|
104
|
-
const [mostRecentEventCount, setMostRecentEventCount] =
|
|
116
|
+
const [mostRecentEventCount, setMostRecentEventCount] = useState(0);
|
|
105
117
|
const {
|
|
106
118
|
setLastNativeText,
|
|
107
119
|
setLastNativeSelection
|
|
108
120
|
} = useTextInputStateSynchronization({
|
|
109
|
-
props,
|
|
110
121
|
inputRef,
|
|
111
122
|
mostRecentEventCount,
|
|
123
|
+
props,
|
|
112
124
|
selection,
|
|
113
125
|
text,
|
|
114
126
|
viewCommands
|
|
115
127
|
});
|
|
116
|
-
|
|
128
|
+
useLayoutEffect(() => {
|
|
117
129
|
const inputRefValue = inputRef.current;
|
|
118
130
|
if (inputRefValue != null) {
|
|
119
|
-
|
|
131
|
+
TextInputState.registerInput(inputRefValue);
|
|
120
132
|
return () => {
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
(
|
|
133
|
+
TextInputState.unregisterInput(inputRefValue);
|
|
134
|
+
if (TextInputState.currentlyFocusedInput() === inputRefValue) {
|
|
135
|
+
nullthrows(inputRefValue).blur();
|
|
124
136
|
}
|
|
125
137
|
};
|
|
126
138
|
}
|
|
127
139
|
}, []);
|
|
128
|
-
const setLocalRef =
|
|
140
|
+
const setLocalRef = useCallback(instance => {
|
|
129
141
|
inputRef.current = instance;
|
|
130
142
|
if (instance != null) {
|
|
143
|
+
TextInputState.registerInput(instance);
|
|
131
144
|
Object.assign(instance, {
|
|
132
145
|
clear() {
|
|
133
146
|
if (inputRef.current != null) {
|
|
134
147
|
viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, '', 0, 0);
|
|
135
148
|
}
|
|
136
149
|
},
|
|
137
|
-
isFocused() {
|
|
138
|
-
return _TextInputState.default.currentlyFocusedInput() === inputRef.current;
|
|
139
|
-
},
|
|
140
150
|
getNativeRef() {
|
|
141
151
|
return inputRef.current;
|
|
142
152
|
},
|
|
153
|
+
isFocused() {
|
|
154
|
+
const currentlyFocusedInput = TextInputState.currentlyFocusedInput();
|
|
155
|
+
return currentlyFocusedInput != null && currentlyFocusedInput === inputRef.current;
|
|
156
|
+
},
|
|
143
157
|
setSelection(start, end) {
|
|
144
158
|
if (inputRef.current != null) {
|
|
145
159
|
viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, null, start, end);
|
|
@@ -148,7 +162,7 @@ function InternalTextInput(props) {
|
|
|
148
162
|
});
|
|
149
163
|
}
|
|
150
164
|
}, [mostRecentEventCount, viewCommands]);
|
|
151
|
-
const ref = (
|
|
165
|
+
const ref = useMergeRefs(setLocalRef, props.forwardedRef);
|
|
152
166
|
const _onChange = event => {
|
|
153
167
|
const currentText = event.nativeEvent.text;
|
|
154
168
|
props.onChange && props.onChange(event);
|
|
@@ -165,18 +179,18 @@ function InternalTextInput(props) {
|
|
|
165
179
|
return;
|
|
166
180
|
}
|
|
167
181
|
setLastNativeSelection({
|
|
168
|
-
|
|
169
|
-
|
|
182
|
+
mostRecentEventCount,
|
|
183
|
+
selection: event.nativeEvent.selection
|
|
170
184
|
});
|
|
171
185
|
};
|
|
172
186
|
const _onFocus = event => {
|
|
173
|
-
|
|
187
|
+
TextInputState.focusInput(inputRef.current);
|
|
174
188
|
if (props.onFocus) {
|
|
175
189
|
props.onFocus(event);
|
|
176
190
|
}
|
|
177
191
|
};
|
|
178
192
|
const _onBlur = event => {
|
|
179
|
-
|
|
193
|
+
TextInputState.blurInput(inputRef.current);
|
|
180
194
|
if (props.onBlur) {
|
|
181
195
|
props.onBlur(event);
|
|
182
196
|
}
|
|
@@ -216,7 +230,8 @@ function InternalTextInput(props) {
|
|
|
216
230
|
onPressOut,
|
|
217
231
|
rejectResponderTermination
|
|
218
232
|
} = props;
|
|
219
|
-
const config =
|
|
233
|
+
const config = useMemo(() => ({
|
|
234
|
+
cancelable: Platform.OS === 'ios' ? !rejectResponderTermination : null,
|
|
220
235
|
hitSlop,
|
|
221
236
|
onPress: event => {
|
|
222
237
|
onPress?.(event);
|
|
@@ -226,19 +241,19 @@ function InternalTextInput(props) {
|
|
|
226
241
|
}
|
|
227
242
|
}
|
|
228
243
|
},
|
|
229
|
-
onPressIn
|
|
230
|
-
onPressOut
|
|
231
|
-
cancelable: _Platform.default.OS === 'ios' ? !rejectResponderTermination : null
|
|
244
|
+
onPressIn,
|
|
245
|
+
onPressOut
|
|
232
246
|
}), [editable, hitSlop, onPress, onPressIn, onPressOut, rejectResponderTermination]);
|
|
233
247
|
let caretHidden = props.caretHidden;
|
|
234
|
-
if (
|
|
248
|
+
if (Platform.isTesting) {
|
|
235
249
|
caretHidden = true;
|
|
236
250
|
}
|
|
237
251
|
const {
|
|
238
252
|
onBlur,
|
|
239
253
|
onFocus,
|
|
240
254
|
...eventHandlers
|
|
241
|
-
} = (
|
|
255
|
+
} = usePressability(config);
|
|
256
|
+
const _accessibilityLabel = props?.['aria-label'] ?? props?.accessibilityLabel;
|
|
242
257
|
let _accessibilityState;
|
|
243
258
|
if (accessibilityState != null || ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {
|
|
244
259
|
_accessibilityState = {
|
|
@@ -250,7 +265,7 @@ function InternalTextInput(props) {
|
|
|
250
265
|
};
|
|
251
266
|
}
|
|
252
267
|
let _style = props.style;
|
|
253
|
-
const flattenedStyle = (
|
|
268
|
+
const flattenedStyle = flattenStyle(props.style);
|
|
254
269
|
if (flattenedStyle != null) {
|
|
255
270
|
let overrides = null;
|
|
256
271
|
if (typeof flattenedStyle?.fontWeight === 'number') {
|
|
@@ -266,14 +281,18 @@ function InternalTextInput(props) {
|
|
|
266
281
|
_style = [_style, overrides];
|
|
267
282
|
}
|
|
268
283
|
}
|
|
269
|
-
if (
|
|
284
|
+
if (Platform.OS === 'ios') {
|
|
270
285
|
const RCTTextInputView = props.multiline === true ? RCTMultilineTextInputView : RCTSinglelineTextInputView;
|
|
271
286
|
const useMultilineDefaultStyle = props.multiline === true && (flattenedStyle == null || flattenedStyle.padding == null && flattenedStyle.paddingVertical == null && flattenedStyle.paddingTop == null);
|
|
272
|
-
|
|
287
|
+
const _accessibilityElementsHidden = props['aria-hidden'] ?? props.accessibilityElementsHidden;
|
|
288
|
+
textInput = /*#__PURE__*/_jsx(RCTTextInputView, {
|
|
273
289
|
ref: ref,
|
|
274
290
|
...otherProps,
|
|
275
291
|
...eventHandlers,
|
|
292
|
+
acceptDragAndDropTypes: props.experimental_acceptDragAndDropTypes,
|
|
293
|
+
accessibilityLabel: _accessibilityLabel,
|
|
276
294
|
accessibilityState: _accessibilityState,
|
|
295
|
+
accessibilityElementsHidden: _accessibilityElementsHidden,
|
|
277
296
|
accessible: accessible,
|
|
278
297
|
submitBehavior: submitBehavior,
|
|
279
298
|
caretHidden: caretHidden,
|
|
@@ -291,51 +310,51 @@ function InternalTextInput(props) {
|
|
|
291
310
|
onSelectionChangeShouldSetResponder: emptyFunctionThatReturnsTrue,
|
|
292
311
|
selection: selection,
|
|
293
312
|
selectionColor: selectionColor,
|
|
294
|
-
style:
|
|
313
|
+
style: StyleSheet.compose(useMultilineDefaultStyle ? styles.multilineDefault : null, _style),
|
|
295
314
|
text: text
|
|
296
315
|
});
|
|
297
|
-
} else if (
|
|
316
|
+
} else if (Platform.OS === 'android') {
|
|
298
317
|
const autoCapitalize = props.autoCapitalize || 'sentences';
|
|
299
318
|
const _accessibilityLabelledBy = props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy;
|
|
319
|
+
const _importantForAccessibility = props['aria-hidden'] === true ? 'no-hide-descendants' : undefined;
|
|
300
320
|
const placeholder = props.placeholder ?? '';
|
|
301
321
|
let children = props.children;
|
|
302
322
|
const childCount = React.Children.count(children);
|
|
303
|
-
(
|
|
323
|
+
invariant(!(props.value != null && childCount), 'Cannot specify both value and children.');
|
|
304
324
|
if (childCount > 1) {
|
|
305
|
-
children = /*#__PURE__*/(
|
|
325
|
+
children = /*#__PURE__*/_jsx(Text, {
|
|
306
326
|
children: children
|
|
307
327
|
});
|
|
308
328
|
}
|
|
309
329
|
const colorProps = {
|
|
330
|
+
cursorColor: cursorColor === undefined ? selectionColor : cursorColor,
|
|
310
331
|
selectionColor,
|
|
311
|
-
selectionHandleColor: selectionHandleColor === undefined ? selectionColor : selectionHandleColor
|
|
312
|
-
cursorColor: cursorColor === undefined ? selectionColor : cursorColor
|
|
332
|
+
selectionHandleColor: selectionHandleColor === undefined ? selectionColor : selectionHandleColor
|
|
313
333
|
};
|
|
314
|
-
|
|
315
|
-
onPaste,
|
|
316
|
-
...rest
|
|
317
|
-
} = otherProps;
|
|
318
|
-
textInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(AndroidTextInput, {
|
|
334
|
+
textInput = /*#__PURE__*/_jsx(AndroidTextInput, {
|
|
319
335
|
ref: ref,
|
|
320
|
-
...
|
|
336
|
+
...otherProps,
|
|
321
337
|
...colorProps,
|
|
322
338
|
...eventHandlers,
|
|
323
|
-
|
|
324
|
-
accessibilityState: _accessibilityState,
|
|
339
|
+
accessibilityLabel: _accessibilityLabel,
|
|
325
340
|
accessibilityLabelledBy: _accessibilityLabelledBy,
|
|
341
|
+
accessibilityState: _accessibilityState,
|
|
326
342
|
accessible: accessible,
|
|
343
|
+
acceptDragAndDropTypes: props.experimental_acceptDragAndDropTypes,
|
|
327
344
|
autoCapitalize: autoCapitalize,
|
|
328
345
|
submitBehavior: submitBehavior,
|
|
329
346
|
caretHidden: caretHidden,
|
|
330
347
|
children: children,
|
|
331
348
|
disableFullscreenUI: props.disableFullscreenUI,
|
|
332
349
|
focusable: tabIndex !== undefined ? !tabIndex : focusable,
|
|
350
|
+
importantForAccessibility: _importantForAccessibility,
|
|
333
351
|
mostRecentEventCount: mostRecentEventCount,
|
|
334
352
|
nativeID: id ?? props.nativeID,
|
|
335
353
|
numberOfLines: props.rows ?? props.numberOfLines,
|
|
336
354
|
onBlur: _onBlur,
|
|
337
355
|
onChange: _onChange,
|
|
338
356
|
onFocus: _onFocus,
|
|
357
|
+
onPaste: onPaste,
|
|
339
358
|
onScroll: _onScroll,
|
|
340
359
|
onSelectionChange: _onSelectionChange,
|
|
341
360
|
placeholder: placeholder,
|
|
@@ -344,14 +363,14 @@ function InternalTextInput(props) {
|
|
|
344
363
|
textBreakStrategy: props.textBreakStrategy
|
|
345
364
|
});
|
|
346
365
|
}
|
|
347
|
-
return /*#__PURE__*/(
|
|
366
|
+
return /*#__PURE__*/_jsx(TextAncestorContext, {
|
|
348
367
|
value: true,
|
|
349
368
|
children: textInput
|
|
350
369
|
});
|
|
351
370
|
}
|
|
352
371
|
const enterKeyHintToReturnTypeMap = {
|
|
353
|
-
enter: 'default',
|
|
354
372
|
done: 'done',
|
|
373
|
+
enter: 'default',
|
|
355
374
|
go: 'go',
|
|
356
375
|
next: 'next',
|
|
357
376
|
previous: 'previous',
|
|
@@ -359,16 +378,17 @@ const enterKeyHintToReturnTypeMap = {
|
|
|
359
378
|
send: 'send'
|
|
360
379
|
};
|
|
361
380
|
const inputModeToKeyboardTypeMap = {
|
|
362
|
-
none: 'default',
|
|
363
|
-
text: 'default',
|
|
364
381
|
decimal: 'decimal-pad',
|
|
382
|
+
email: 'email-address',
|
|
383
|
+
none: 'default',
|
|
365
384
|
numeric: 'number-pad',
|
|
385
|
+
search: Platform.OS === 'ios' ? 'web-search' : 'default',
|
|
366
386
|
tel: 'phone-pad',
|
|
367
|
-
|
|
368
|
-
email: 'email-address',
|
|
387
|
+
text: 'default',
|
|
369
388
|
url: 'url'
|
|
370
389
|
};
|
|
371
390
|
const autoCompleteWebToAutoCompleteAndroidMap = {
|
|
391
|
+
'additional-name': 'name-middle',
|
|
372
392
|
'address-line1': 'postal-address-region',
|
|
373
393
|
'address-line2': 'postal-address-locality',
|
|
374
394
|
bday: 'birthdate-full',
|
|
@@ -383,12 +403,11 @@ const autoCompleteWebToAutoCompleteAndroidMap = {
|
|
|
383
403
|
country: 'postal-address-country',
|
|
384
404
|
'current-password': 'password',
|
|
385
405
|
email: 'email',
|
|
406
|
+
'family-name': 'name-family',
|
|
407
|
+
'given-name': 'name-given',
|
|
386
408
|
'honorific-prefix': 'name-prefix',
|
|
387
409
|
'honorific-suffix': 'name-suffix',
|
|
388
410
|
name: 'name',
|
|
389
|
-
'additional-name': 'name-middle',
|
|
390
|
-
'family-name': 'name-family',
|
|
391
|
-
'given-name': 'name-given',
|
|
392
411
|
'new-password': 'password-new',
|
|
393
412
|
off: 'off',
|
|
394
413
|
'one-time-code': 'sms-otp',
|
|
@@ -401,33 +420,33 @@ const autoCompleteWebToAutoCompleteAndroidMap = {
|
|
|
401
420
|
username: 'username'
|
|
402
421
|
};
|
|
403
422
|
const autoCompleteWebToTextContentTypeMap = {
|
|
423
|
+
'additional-name': 'middleName',
|
|
404
424
|
'address-line1': 'streetAddressLine1',
|
|
405
425
|
'address-line2': 'streetAddressLine2',
|
|
406
426
|
bday: 'birthdate',
|
|
407
427
|
'bday-day': 'birthdateDay',
|
|
408
428
|
'bday-month': 'birthdateMonth',
|
|
409
429
|
'bday-year': 'birthdateYear',
|
|
430
|
+
'cc-additional-name': 'creditCardMiddleName',
|
|
410
431
|
'cc-csc': 'creditCardSecurityCode',
|
|
432
|
+
'cc-exp': 'creditCardExpiration',
|
|
411
433
|
'cc-exp-month': 'creditCardExpirationMonth',
|
|
412
434
|
'cc-exp-year': 'creditCardExpirationYear',
|
|
413
|
-
'cc-exp': 'creditCardExpiration',
|
|
414
|
-
'cc-given-name': 'creditCardGivenName',
|
|
415
|
-
'cc-additional-name': 'creditCardMiddleName',
|
|
416
435
|
'cc-family-name': 'creditCardFamilyName',
|
|
436
|
+
'cc-given-name': 'creditCardGivenName',
|
|
417
437
|
'cc-name': 'creditCardName',
|
|
418
438
|
'cc-number': 'creditCardNumber',
|
|
419
439
|
'cc-type': 'creditCardType',
|
|
420
|
-
'current-password': 'password',
|
|
421
440
|
country: 'countryName',
|
|
441
|
+
'current-password': 'password',
|
|
422
442
|
email: 'emailAddress',
|
|
423
|
-
name: 'name',
|
|
424
|
-
'additional-name': 'middleName',
|
|
425
443
|
'family-name': 'familyName',
|
|
426
444
|
'given-name': 'givenName',
|
|
427
|
-
nickname: 'nickname',
|
|
428
445
|
'honorific-prefix': 'namePrefix',
|
|
429
446
|
'honorific-suffix': 'nameSuffix',
|
|
447
|
+
name: 'name',
|
|
430
448
|
'new-password': 'newPassword',
|
|
449
|
+
nickname: 'nickname',
|
|
431
450
|
off: 'none',
|
|
432
451
|
'one-time-code': 'oneTimeCode',
|
|
433
452
|
organization: 'organizationName',
|
|
@@ -438,7 +457,8 @@ const autoCompleteWebToTextContentTypeMap = {
|
|
|
438
457
|
url: 'URL',
|
|
439
458
|
username: 'username'
|
|
440
459
|
};
|
|
441
|
-
const
|
|
460
|
+
const TextInput = function TextInput({
|
|
461
|
+
ref: forwardedRef,
|
|
442
462
|
allowFontScaling = true,
|
|
443
463
|
rejectResponderTermination = true,
|
|
444
464
|
underlineColorAndroid = 'transparent',
|
|
@@ -452,8 +472,8 @@ const ExportedForwardRef = /*#__PURE__*/React.forwardRef(function TextInput({
|
|
|
452
472
|
showSoftInputOnFocus,
|
|
453
473
|
keyboardType,
|
|
454
474
|
...restProps
|
|
455
|
-
}
|
|
456
|
-
return /*#__PURE__*/(
|
|
475
|
+
}) {
|
|
476
|
+
return /*#__PURE__*/_jsx(InternalTextInput, {
|
|
457
477
|
allowFontScaling: allowFontScaling,
|
|
458
478
|
rejectResponderTermination: rejectResponderTermination,
|
|
459
479
|
underlineColorAndroid: underlineColorAndroid,
|
|
@@ -461,29 +481,29 @@ const ExportedForwardRef = /*#__PURE__*/React.forwardRef(function TextInput({
|
|
|
461
481
|
returnKeyType: enterKeyHint ? enterKeyHintToReturnTypeMap[enterKeyHint] : returnKeyType,
|
|
462
482
|
keyboardType: inputMode ? inputModeToKeyboardTypeMap[inputMode] : keyboardType,
|
|
463
483
|
showSoftInputOnFocus: inputMode == null ? showSoftInputOnFocus : inputMode !== 'none',
|
|
464
|
-
autoComplete:
|
|
465
|
-
textContentType: textContentType != null ? textContentType :
|
|
484
|
+
autoComplete: Platform.OS === 'android' ? autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ?? autoComplete : undefined,
|
|
485
|
+
textContentType: textContentType != null ? textContentType : Platform.OS === 'ios' && autoComplete && autoComplete in autoCompleteWebToTextContentTypeMap ? autoCompleteWebToTextContentTypeMap[autoComplete] : textContentType,
|
|
466
486
|
...restProps,
|
|
467
487
|
forwardedRef: forwardedRef
|
|
468
488
|
});
|
|
469
|
-
});
|
|
470
|
-
ExportedForwardRef.displayName = 'TextInput';
|
|
471
|
-
ExportedForwardRef.State = {
|
|
472
|
-
currentlyFocusedInput: _TextInputState.default.currentlyFocusedInput,
|
|
473
|
-
currentlyFocusedField: _TextInputState.default.currentlyFocusedField,
|
|
474
|
-
focusTextInput: _TextInputState.default.focusTextInput,
|
|
475
|
-
blurTextInput: _TextInputState.default.blurTextInput
|
|
476
489
|
};
|
|
477
|
-
|
|
490
|
+
TextInput.displayName = 'TextInput';
|
|
491
|
+
TextInput.State = {
|
|
492
|
+
blurTextInput: TextInputState.blurTextInput,
|
|
493
|
+
currentlyFocusedField: TextInputState.currentlyFocusedField,
|
|
494
|
+
currentlyFocusedInput: TextInputState.currentlyFocusedInput,
|
|
495
|
+
focusTextInput: TextInputState.focusTextInput
|
|
496
|
+
};
|
|
497
|
+
const styles = StyleSheet.create({
|
|
478
498
|
multilineDefault: {
|
|
479
499
|
paddingTop: 5
|
|
480
500
|
}
|
|
481
501
|
});
|
|
482
502
|
const verticalAlignToTextAlignVerticalMap = {
|
|
483
503
|
auto: 'auto',
|
|
484
|
-
top: 'top',
|
|
485
504
|
bottom: 'bottom',
|
|
486
|
-
middle: 'center'
|
|
505
|
+
middle: 'center',
|
|
506
|
+
top: 'top'
|
|
487
507
|
};
|
|
488
|
-
|
|
508
|
+
export default TextInput;
|
|
489
509
|
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
import TextInputView from "./Input.js";
|
|
5
|
+
|
|
6
|
+
// export * from './TextInputViewNativeComponent';
|
|
7
|
+
|
|
8
|
+
export * from "./enum.js";
|
|
9
|
+
const TextInput = TextInputView;
|
|
10
|
+
export default TextInput;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ComponentType } from
|
|
2
|
-
import type { ITextInputProps } from
|
|
3
|
-
export type { IPasteEventPayloadItem, IPasteEventPayload, IPasteEventParams, ITextInputProps, } from
|
|
4
|
-
export * from
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { ITextInputProps } from "./type";
|
|
3
|
+
export type { IPasteEventPayloadItem, IPasteEventPayload, IPasteEventParams, ITextInputProps, } from "./type";
|
|
4
|
+
export * from "./enum";
|
|
5
5
|
declare const TextInput: ComponentType<ITextInputProps>;
|
|
6
6
|
export default TextInput;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TextInputProps } from
|
|
2
|
-
import type { EPasteEventPayloadItemType } from
|
|
1
|
+
import type { TextInputProps } from "react-native";
|
|
2
|
+
import type { EPasteEventPayloadItemType } from "./enum";
|
|
3
3
|
export type IPasteEventPayloadItem = {
|
|
4
4
|
data?: string;
|
|
5
5
|
type?: EPasteEventPayloadItemType;
|