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