UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

91 lines (88 loc) • 3.83 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var index_android_exports = {}; __export(index_android_exports, { TextInput: () => TextInput }); module.exports = __toCommonJS(index_android_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_react = require("react"); var import_compose = require("../../compose.android.js"); var import_syncNativeState = require("../../syncNativeState.native.js"); var import_textInputShared = require("./textInputShared.native.js"); function TextInput(param) { var { ref, value, onChangeText, placeholder, autoFocus, editable: editableProp, readOnly, multiline, keyboardType: keyboardTypeProp, autoCapitalize, autoCorrect, returnKeyType: returnKeyTypeProp, inputMode, enterKeyHint, onSubmitEditing, onFocus, onBlur, defaultValue, testID, style, secureTextEntry, maxLength, textAlign } = param; var editable = (0, import_textInputShared.resolveEditable)(editableProp, readOnly); var keyboardType = keyboardTypeProp !== null && keyboardTypeProp !== void 0 ? keyboardTypeProp : (0, import_textInputShared.inputModeToKeyboardType)(inputMode); var returnKeyType = returnKeyTypeProp !== null && returnKeyTypeProp !== void 0 ? returnKeyTypeProp : (0, import_textInputShared.enterKeyHintToReturnKeyType)(enterKeyHint); var initialFallbackRef = (0, import_react.useRef)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""); var fallback = (0, import_syncNativeState.useNativeState)(initialFallbackRef.current); var state = value !== null && value !== void 0 ? value : fallback; var { focused, focusRevision, focus, blur, isFocused, handleFocusChange } = (0, import_textInputShared.useTextInputFocus)({ autoFocus, editable, onFocus, onBlur }); (0, import_react.useImperativeHandle)(ref, function() { return { focus, blur, clear: function clear() { state.set(""); }, isFocused, setSelection: function setSelection(start, end) { void start; void end; console.warn("TextInput.setSelection() is not supported on Android yet: it needs a TextFieldValue-backed field. This call was ignored."); return Promise.resolve(); } }; }, [state]); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_compose.Compose.TextField, { text: state, onTextChange: function onTextChange(text) { return onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text); }, placeholder, disabled: !editable, secureText: secureTextEntry, focused, focusRevision, onFocusChange: handleFocusChange, keyboardType: keyboardType ? (0, import_textInputShared.androidKeyboardType)(keyboardType) : void 0, imeAction: returnKeyType ? (0, import_textInputShared.androidImeAction)(returnKeyType) : void 0, onSubmit: onSubmitEditing ? function() { return onSubmitEditing(state.value); } : void 0, maxLength, multiline, capitalization: autoCapitalize, autoCorrect, textAlign: textAlign === "auto" ? void 0 : textAlign, testID, style: [{ width: "100%", minHeight: 56 }, style] }); } //# sourceMappingURL=index.android.js.map