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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_SegmentedControlNativeComponent","_interopRequireDefault","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ANDROID_MIN_HEIGHT","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_SegmentedControlNativeComponent","_interopRequireDefault","_icons","_labelStyle","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ANDROID_MIN_HEIGHT","resolveSegmentIcon","exports","resolveIcon","normalizeSelectedValue","selected","SegmentedControl","props","style","segments","selectedValue","disabled","labelVisibility","selectedSegmentColor","activeTintColor","inactiveTintColor","labelStyle","badgeStyle","onSelect","onDeselect","ios","android","viewProps","nativeSegments","useMemo","map","seg","label","value","badge","undefined","String","accessibilityLabel","icon","selectedData","handleSelect","useCallback","index","nativeEvent","nativeIos","momentary","apportionsSegmentWidthsByContent","nativeSelectedSegmentColor","Platform","OS","selectedSegmentTintColor","nativeLabelStyle","normalizeLabelStyle","nativeAndroid","selectionRequired","material","mergedStyle","styles","androidDefault","jsx","interactivity","androidRippleColor","rippleColor","androidStrokeColor","strokeColor","badgeBackgroundColor","backgroundColor","badgeTextColor","color","StyleSheet","create","minHeight"],"sourceRoot":"../../src","sources":["SegmentedControl.tsx"],"mappings":";;;;;;;AACA,IAAAA,MAAA,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AAC,CAAC;;EAEb;EACA,MAAM8B,WAAW,GAAG,IAAA3B,cAAO,EAAC,MAA4B;IACtD,IAAImB,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAO,CAACQ,MAAM,CAACC,cAAc,EAAE7C,KAAK,CAAC;IACvC;IACA,OAAOA,KAAK;EACd,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBACE,IAAA5B,WAAA,CAAA0E,GAAA,EAAC9E,gCAAA,CAAAO,OAAsB;IACrByB,KAAK,EAAE2C,WAAY;IACnB1C,QAAQ,EAAEc,cAAe;IACzBb,aAAa,EAAEwB,YAAa;IAC5BqB,aAAa,EAAE5C,QAAQ,GAAG,UAAU,GAAG,SAAU;IACjDC,eAAe,EAAEA,eAAe,IAAI,MAAO;IAC3CC,oBAAoB,EAAE6B,0BAA2B;IACjD5B,eAAe,EAAEA,eAAgB;IACjCC,iBAAiB,EAAEA,iBAAkB;IACrCyC,kBAAkB,EAAEnC,OAAO,EAAEoC,WAAY;IACzCC,kBAAkB,EAAErC,OAAO,EAAEsC,WAAY;IACzC3C,UAAU,EAAE8B,gBAAiB;IAC7Bc,oBAAoB,EAAE3C,UAAU,EAAE4C,eAAgB;IAClDC,cAAc,EAAE7C,UAAU,EAAE8C,KAAM;IAClC7C,QAAQ,EAAEA,QAAQ,IAAIC,UAAU,GAAGgB,YAAY,GAAGL,SAAU;IAC5DV,GAAG,EAAEmB,SAAU;IACflB,OAAO,EAAE2B,aAAc;IAAA,GACnB1B;EAAS,CACd,CAAC;AAEN;AAEA,MAAM8B,MAAM,GAAGY,uBAAU,CAACC,MAAM,CAAC;EAC/BZ,cAAc,EAAE;IACda,SAAS,EAAElE;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,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TextField = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _TextFieldNativeComponent = _interopRequireWildcard(require("./TextFieldNativeComponent"));
|
|
9
|
+
var _icons = require("./icons");
|
|
10
|
+
var _labelStyle = require("./labelStyle");
|
|
11
|
+
var _focusRegistry = require("./focusRegistry");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
// TextField.tsx
|
|
15
|
+
|
|
16
|
+
/** Keyboard to show; the React Native `TextInput` values. */
|
|
17
|
+
|
|
18
|
+
/** Return key label; the React Native `TextInput` values. */
|
|
19
|
+
|
|
20
|
+
/** Autofill hint; a cross-platform subset of the React Native `TextInput` values. */
|
|
21
|
+
|
|
22
|
+
/** An iOS text trait: the system default, on, or off. */
|
|
23
|
+
|
|
24
|
+
/** Focus, blur and submit events carry the text at that moment. */
|
|
25
|
+
|
|
26
|
+
/** Change events carry the text and the native edit counter. */
|
|
27
|
+
|
|
28
|
+
/** Methods available through the `ref`. */
|
|
29
|
+
|
|
30
|
+
const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)(function TextFieldComponent(props, ref) {
|
|
31
|
+
const {
|
|
32
|
+
value,
|
|
33
|
+
defaultValue,
|
|
34
|
+
onChangeText,
|
|
35
|
+
onChange,
|
|
36
|
+
onFocus,
|
|
37
|
+
onBlur,
|
|
38
|
+
onSubmitEditing,
|
|
39
|
+
label,
|
|
40
|
+
placeholder,
|
|
41
|
+
supportingText,
|
|
42
|
+
error,
|
|
43
|
+
prefix,
|
|
44
|
+
suffix,
|
|
45
|
+
leadingIcon,
|
|
46
|
+
trailingIcon,
|
|
47
|
+
onTrailingIconPress,
|
|
48
|
+
clearButtonMode,
|
|
49
|
+
passwordToggle,
|
|
50
|
+
showCharacterCount,
|
|
51
|
+
maxLength,
|
|
52
|
+
keyboardType,
|
|
53
|
+
returnKeyType,
|
|
54
|
+
autoCapitalize,
|
|
55
|
+
autoCorrect,
|
|
56
|
+
secureTextEntry,
|
|
57
|
+
multiline,
|
|
58
|
+
editable,
|
|
59
|
+
autoFocus,
|
|
60
|
+
selectTextOnFocus,
|
|
61
|
+
autoComplete,
|
|
62
|
+
keyboardAppearance,
|
|
63
|
+
textStyle,
|
|
64
|
+
accessibilityLabel,
|
|
65
|
+
ios,
|
|
66
|
+
android,
|
|
67
|
+
...viewProps
|
|
68
|
+
} = props;
|
|
69
|
+
const nativeRef = (0, _react.useRef)(null);
|
|
70
|
+
const focused = (0, _react.useRef)(false);
|
|
71
|
+
|
|
72
|
+
// The same synchronization as React Native's TextInput: every native edit
|
|
73
|
+
// reports an event count, and a controlled value is pushed with the last
|
|
74
|
+
// count JS has seen. Native drops the update when the user has typed
|
|
75
|
+
// since, and the edit that follows brings JS back in line.
|
|
76
|
+
const [mostRecentEventCount, setMostRecentEventCount] = (0, _react.useState)(0);
|
|
77
|
+
const [lastNativeText, setLastNativeText] = (0, _react.useState)(value ?? defaultValue);
|
|
78
|
+
|
|
79
|
+
// Registered like a TextInput, so Keyboard.dismiss() and the ScrollView
|
|
80
|
+
// keyboard props treat the field as one (see focusRegistry.ts)
|
|
81
|
+
(0, _react.useLayoutEffect)(() => {
|
|
82
|
+
const node = nativeRef.current;
|
|
83
|
+
if (node == null) return undefined;
|
|
84
|
+
_focusRegistry.focusRegistry.register(node);
|
|
85
|
+
return () => _focusRegistry.focusRegistry.unregister(node);
|
|
86
|
+
}, []);
|
|
87
|
+
(0, _react.useLayoutEffect)(() => {
|
|
88
|
+
if (typeof value !== 'string' || value === lastNativeText) return;
|
|
89
|
+
setLastNativeText(value);
|
|
90
|
+
const node = nativeRef.current;
|
|
91
|
+
if (node != null) {
|
|
92
|
+
_TextFieldNativeComponent.Commands.setText(node, mostRecentEventCount, value);
|
|
93
|
+
}
|
|
94
|
+
}, [value, lastNativeText, mostRecentEventCount]);
|
|
95
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
96
|
+
focus: () => {
|
|
97
|
+
const node = nativeRef.current;
|
|
98
|
+
if (node != null) _TextFieldNativeComponent.Commands.focus(node);
|
|
99
|
+
},
|
|
100
|
+
blur: () => {
|
|
101
|
+
const node = nativeRef.current;
|
|
102
|
+
if (node != null) _TextFieldNativeComponent.Commands.blur(node);
|
|
103
|
+
},
|
|
104
|
+
clear: () => {
|
|
105
|
+
const node = nativeRef.current;
|
|
106
|
+
if (node != null) _TextFieldNativeComponent.Commands.clear(node);
|
|
107
|
+
},
|
|
108
|
+
isFocused: () => focused.current
|
|
109
|
+
}), []);
|
|
110
|
+
const handleChange = (0, _react.useCallback)(event => {
|
|
111
|
+
const {
|
|
112
|
+
text,
|
|
113
|
+
eventCount
|
|
114
|
+
} = event.nativeEvent;
|
|
115
|
+
setMostRecentEventCount(eventCount);
|
|
116
|
+
setLastNativeText(text);
|
|
117
|
+
onChange?.(event);
|
|
118
|
+
onChangeText?.(text);
|
|
119
|
+
}, [onChange, onChangeText]);
|
|
120
|
+
const handleFocus = (0, _react.useCallback)(event => {
|
|
121
|
+
focused.current = true;
|
|
122
|
+
_focusRegistry.focusRegistry.focused(nativeRef.current);
|
|
123
|
+
onFocus?.(event);
|
|
124
|
+
}, [onFocus]);
|
|
125
|
+
const handleBlur = (0, _react.useCallback)(event => {
|
|
126
|
+
focused.current = false;
|
|
127
|
+
_focusRegistry.focusRegistry.blurred(nativeRef.current);
|
|
128
|
+
onBlur?.(event);
|
|
129
|
+
}, [onBlur]);
|
|
130
|
+
const handleSubmit = (0, _react.useCallback)(event => {
|
|
131
|
+
onSubmitEditing?.(event);
|
|
132
|
+
}, [onSubmitEditing]);
|
|
133
|
+
const handleTrailingIconPress = (0, _react.useCallback)(() => {
|
|
134
|
+
onTrailingIconPress?.();
|
|
135
|
+
}, [onTrailingIconPress]);
|
|
136
|
+
const nativeLeadingIcon = (0, _react.useMemo)(() => (0, _icons.resolveIcon)(leadingIcon), [leadingIcon]);
|
|
137
|
+
const nativeTrailingIcon = (0, _react.useMemo)(() => (0, _icons.resolveIcon)(trailingIcon), [trailingIcon]);
|
|
138
|
+
const nativeTextStyle = (0, _react.useMemo)(() => (0, _labelStyle.normalizeLabelStyle)(textStyle), [textStyle]);
|
|
139
|
+
const nativeIOS = (0, _react.useMemo)(() => ({
|
|
140
|
+
writingTools: ios?.writingTools ?? '',
|
|
141
|
+
inlinePrediction: ios?.inlinePrediction ?? '',
|
|
142
|
+
smartQuotes: ios?.smartQuotes ?? '',
|
|
143
|
+
smartDashes: ios?.smartDashes ?? '',
|
|
144
|
+
smartInsertDelete: ios?.smartInsertDelete ?? '',
|
|
145
|
+
mathExpressionCompletion: ios?.mathExpressionCompletion ?? '',
|
|
146
|
+
borderStyle: ios?.borderStyle ?? '',
|
|
147
|
+
labelPlacement: ios?.labelPlacement ?? '',
|
|
148
|
+
labelWidth: ios?.labelWidth ?? 0
|
|
149
|
+
}), [ios]);
|
|
150
|
+
const nativeAndroid = (0, _react.useMemo)(() => ({
|
|
151
|
+
material: android?.material ?? 'm3',
|
|
152
|
+
variant: android?.variant ?? 'outlined',
|
|
153
|
+
density: android?.dense ? 'dense' : 'standard'
|
|
154
|
+
}), [android]);
|
|
155
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextFieldNativeComponent.default, {
|
|
156
|
+
ref: nativeRef,
|
|
157
|
+
initialText: value ?? defaultValue ?? '',
|
|
158
|
+
label: label ?? '',
|
|
159
|
+
placeholder: placeholder ?? '',
|
|
160
|
+
supportingText: supportingText ?? '',
|
|
161
|
+
errorState: error ? 'error' : 'none',
|
|
162
|
+
errorText: typeof error === 'string' ? error : '',
|
|
163
|
+
prefix: prefix ?? '',
|
|
164
|
+
suffix: suffix ?? '',
|
|
165
|
+
leadingIcon: nativeLeadingIcon,
|
|
166
|
+
trailingIcon: nativeTrailingIcon,
|
|
167
|
+
clearButtonMode: clearButtonMode ?? 'never',
|
|
168
|
+
passwordToggle: passwordToggle ? 'shown' : 'hidden',
|
|
169
|
+
characterCount: showCharacterCount ? 'shown' : 'hidden',
|
|
170
|
+
maxLength: maxLength ?? 0,
|
|
171
|
+
keyboardType: keyboardType ?? 'default',
|
|
172
|
+
returnKeyType: returnKeyType ?? 'default',
|
|
173
|
+
autoCapitalize: autoCapitalize ?? 'sentences',
|
|
174
|
+
autoCorrect: autoCorrect === false ? 'disabled' : 'enabled',
|
|
175
|
+
secureTextEntry: secureTextEntry ? 'secure' : 'plain',
|
|
176
|
+
lines: multiline ? 'multiline' : 'single',
|
|
177
|
+
interactivity: editable === false ? 'disabled' : 'enabled',
|
|
178
|
+
autoFocus: autoFocus ? 'focus' : 'none',
|
|
179
|
+
selectTextOnFocus: selectTextOnFocus ? 'select' : 'keep',
|
|
180
|
+
autoComplete: autoComplete ?? '',
|
|
181
|
+
keyboardAppearance: keyboardAppearance ?? 'default',
|
|
182
|
+
textStyle: nativeTextStyle,
|
|
183
|
+
spokenLabel: accessibilityLabel ?? '',
|
|
184
|
+
ios: nativeIOS,
|
|
185
|
+
android: nativeAndroid,
|
|
186
|
+
onFieldChange: handleChange,
|
|
187
|
+
onFieldFocus: handleFocus,
|
|
188
|
+
onFieldBlur: handleBlur,
|
|
189
|
+
onFieldSubmit: onSubmitEditing ? handleSubmit : undefined,
|
|
190
|
+
onTrailingIconPress: onTrailingIconPress ? handleTrailingIconPress : undefined,
|
|
191
|
+
...viewProps
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
TextField.displayName = 'TextField';
|
|
195
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_TextFieldNativeComponent","_icons","_labelStyle","_focusRegistry","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextField","exports","forwardRef","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","useRef","focused","mostRecentEventCount","setMostRecentEventCount","useState","lastNativeText","setLastNativeText","useLayoutEffect","node","current","undefined","focusRegistry","register","unregister","Commands","setText","useImperativeHandle","focus","blur","clear","isFocused","handleChange","useCallback","event","text","eventCount","nativeEvent","handleFocus","handleBlur","blurred","handleSubmit","handleTrailingIconPress","nativeLeadingIcon","useMemo","resolveIcon","nativeTrailingIcon","nativeTextStyle","normalizeLabelStyle","nativeIOS","writingTools","inlinePrediction","smartQuotes","smartDashes","smartInsertDelete","mathExpressionCompletion","borderStyle","labelPlacement","labelWidth","nativeAndroid","material","variant","density","dense","jsx","initialText","errorState","errorText","characterCount","lines","interactivity","spokenLabel","onFieldChange","onFieldFocus","onFieldBlur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SACjD;IAAA,GACGZ;EAAS,CACd,CAAC;AAEN,CACF,CAAC;AAEDzC,SAAS,CAAC4G,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;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.focusRegistry = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } // focusRegistry.ts
|
|
9
|
+
//
|
|
10
|
+
// TextField's link to React Native's focused-input bookkeeping. The core
|
|
11
|
+
// TextInput registers its host node with `TextInputState`, and that registry is
|
|
12
|
+
// what `Keyboard.dismiss()`, a ScrollView's `keyboardShouldPersistTaps` and
|
|
13
|
+
// `keyboardDismissMode`, and `KeyboardAvoidingView` act on. Registering the
|
|
14
|
+
// same way makes a TextField behave like a TextInput for all of them.
|
|
15
|
+
//
|
|
16
|
+
// `TextInputState` is a stable internal (it has kept this shape since 0.63),
|
|
17
|
+
// but React Native's Babel preset adds a dev-time warning to every static
|
|
18
|
+
// `import` or `require` of a deep path. A dynamic `import()` is resolved by
|
|
19
|
+
// Metro the same way and carries no warning; it settles in a microtask at
|
|
20
|
+
// startup, so a node registered before then is kept and registered once the
|
|
21
|
+
// module arrives. If a future release drops the path, the registry is simply
|
|
22
|
+
// absent and the field falls back to the public `TextInput.State` calls for
|
|
23
|
+
// focus and blur, keeping `Keyboard.dismiss()` working.
|
|
24
|
+
let registry;
|
|
25
|
+
const pendingRegistrations = new Set();
|
|
26
|
+
|
|
27
|
+
// A stable internal without a public counterpart; see reactNativeInternals.d.ts.
|
|
28
|
+
|
|
29
|
+
Promise.resolve().then(() => _interopRequireWildcard(require('react-native/Libraries/Components/TextInput/TextInputState'))).then(module => {
|
|
30
|
+
registry = module.default;
|
|
31
|
+
pendingRegistrations.forEach(node => registry?.registerInput(node));
|
|
32
|
+
pendingRegistrations.clear();
|
|
33
|
+
}).catch(() => {
|
|
34
|
+
// Not available: focus and blur still go through TextInput.State below.
|
|
35
|
+
});
|
|
36
|
+
const focusRegistry = exports.focusRegistry = {
|
|
37
|
+
/** Called when the field mounts. */
|
|
38
|
+
register(node) {
|
|
39
|
+
if (registry) {
|
|
40
|
+
registry.registerInput(node);
|
|
41
|
+
} else {
|
|
42
|
+
pendingRegistrations.add(node);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
/** Called when the field unmounts; drops the focus if the field held it. */
|
|
46
|
+
unregister(node) {
|
|
47
|
+
pendingRegistrations.delete(node);
|
|
48
|
+
if (registry) {
|
|
49
|
+
registry.unregisterInput(node);
|
|
50
|
+
if (registry.currentlyFocusedInput() === node) {
|
|
51
|
+
registry.blurInput(node);
|
|
52
|
+
}
|
|
53
|
+
} else if (_reactNative.TextInput.State.currentlyFocusedInput() === node) {
|
|
54
|
+
_reactNative.TextInput.State.blurTextInput(node);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
/** The field gained focus natively. */
|
|
58
|
+
focused(node) {
|
|
59
|
+
if (node == null) return;
|
|
60
|
+
if (registry) {
|
|
61
|
+
registry.focusInput(node);
|
|
62
|
+
} else {
|
|
63
|
+
// Also re-sends the focus command, which the focused field ignores
|
|
64
|
+
_reactNative.TextInput.State.focusTextInput(node);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
/** The field lost focus natively. */
|
|
68
|
+
blurred(node) {
|
|
69
|
+
if (node == null) return;
|
|
70
|
+
if (registry) {
|
|
71
|
+
registry.blurInput(node);
|
|
72
|
+
} else {
|
|
73
|
+
// Also re-sends the blur command, which the unfocused field ignores
|
|
74
|
+
_reactNative.TextInput.State.blurTextInput(node);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=focusRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","registry","pendingRegistrations","Set","Promise","resolve","then","module","forEach","node","registerInput","clear","catch","focusRegistry","exports","register","add","unregister","delete","unregisterInput","currentlyFocusedInput","blurInput","TextInput","State","blurTextInput","focused","focusInput","focusTextInput","blurred"],"sourceRoot":"../../src","sources":["focusRegistry.ts"],"mappings":";;;;;;AAgBA,IAAAA,YAAA,GAAAC,OAAA;AAAyC,SAAAC,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAA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,CAACH,qBAAqB,CAAC,CAAC,KAAKX,IAAI,EAAE;MAC3Da,sBAAS,CAACC,KAAK,CAACC,aAAa,CAACf,IAAa,CAAC;IAC9C;EACF,CAAC;EAED;EACAgB,OAAOA,CAAChB,IAAqB,EAAQ;IACnC,IAAIA,IAAI,IAAI,IAAI,EAAE;IAClB,IAAIR,QAAQ,EAAE;MACZA,QAAQ,CAACyB,UAAU,CAACjB,IAAI,CAAC;IAC3B,CAAC,MAAM;MACL;MACAa,sBAAS,CAACC,KAAK,CAACI,cAAc,CAAClB,IAAa,CAAC;IAC/C;EACF,CAAC;EAED;EACAmB,OAAOA,CAACnB,IAAqB,EAAQ;IACnC,IAAIA,IAAI,IAAI,IAAI,EAAE;IAClB,IAAIR,QAAQ,EAAE;MACZA,QAAQ,CAACoB,SAAS,CAACZ,IAAI,CAAC;IAC1B,CAAC,MAAM;MACL;MACAa,sBAAS,CAACC,KAAK,CAACC,aAAa,CAACf,IAAa,CAAC;IAC9C;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NO_ICON = void 0;
|
|
7
|
+
exports.resolveIcon = resolveIcon;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
// icons.ts
|
|
10
|
+
//
|
|
11
|
+
// Icon props shared by SegmentedControl, Button and ButtonGroup. Icons are
|
|
12
|
+
// resolved on the JS side so native only deals with flat strings.
|
|
13
|
+
|
|
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.
|
|
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
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An icon: a single source used on both platforms, or a per-platform pair so
|
|
29
|
+
* callers don't need to branch on `Platform.OS`.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** The flat icon fields the native specs expect. */
|
|
33
|
+
|
|
34
|
+
const NO_ICON = exports.NO_ICON = {
|
|
35
|
+
iconType: '',
|
|
36
|
+
iconName: '',
|
|
37
|
+
iconUri: '',
|
|
38
|
+
iconScale: 1,
|
|
39
|
+
iconTinted: 'true'
|
|
40
|
+
};
|
|
41
|
+
function pickIconSource(icon) {
|
|
42
|
+
if (icon === undefined || typeof icon === 'string' || 'type' in icon) {
|
|
43
|
+
return icon;
|
|
44
|
+
}
|
|
45
|
+
return _reactNative.Platform.OS === 'ios' ? icon.ios : icon.android;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Flattens the public icon shape into the strings native expects, dropping
|
|
50
|
+
* sources that don't apply to the current platform.
|
|
51
|
+
*/
|
|
52
|
+
function resolveIcon(icon) {
|
|
53
|
+
const source = pickIconSource(icon);
|
|
54
|
+
if (source === undefined) return NO_ICON;
|
|
55
|
+
if (typeof source === 'string') {
|
|
56
|
+
if (source.length === 0) return NO_ICON;
|
|
57
|
+
return {
|
|
58
|
+
...NO_ICON,
|
|
59
|
+
iconType: _reactNative.Platform.OS === 'ios' ? 'sfSymbol' : 'drawable',
|
|
60
|
+
iconName: source
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
switch (source.type) {
|
|
64
|
+
case 'sfSymbol':
|
|
65
|
+
return _reactNative.Platform.OS === 'ios' ? {
|
|
66
|
+
...NO_ICON,
|
|
67
|
+
iconType: 'sfSymbol',
|
|
68
|
+
iconName: source.name
|
|
69
|
+
} : NO_ICON;
|
|
70
|
+
case 'drawable':
|
|
71
|
+
return _reactNative.Platform.OS === 'android' ? {
|
|
72
|
+
...NO_ICON,
|
|
73
|
+
iconType: 'drawable',
|
|
74
|
+
iconName: source.name
|
|
75
|
+
} : NO_ICON;
|
|
76
|
+
case 'image':
|
|
77
|
+
{
|
|
78
|
+
const resolved = _reactNative.Image.resolveAssetSource(source.source);
|
|
79
|
+
if (!resolved?.uri) return NO_ICON;
|
|
80
|
+
return {
|
|
81
|
+
iconType: 'image',
|
|
82
|
+
iconName: '',
|
|
83
|
+
iconUri: resolved.uri,
|
|
84
|
+
iconScale: resolved.scale > 0 ? resolved.scale : 1,
|
|
85
|
+
iconTinted: source.tinted === false ? 'false' : 'true'
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
return NO_ICON;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=icons.js.map
|