UNPKG

swiftui-react-native

Version:

A React Native component library inspired by SwiftUI

63 lines 3.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextEditor = exports.SecureField = exports.TextField = void 0; const expo_modules_core_1 = require("expo-modules-core"); const react_1 = __importDefault(require("react")); const binding_1 = require("../../utils/binding"); const modifiers_1 = require("../../utils/modifiers"); const onBaseEvent_1 = require("../../utils/onBaseEvent"); const NativeTextField = (0, expo_modules_core_1.requireNativeViewManager)('TextField'); function TextField({ text, style, onChange, placeholder, ...modifiers }) { return (react_1.default.createElement(NativeTextField, { text: (0, binding_1.getValueOrBinding)(text), type: "textfield", modifiers: (0, modifiers_1.mapToNativeModifiers)(modifiers), onEvent: (e) => { (0, onBaseEvent_1.onBaseEvent)(e, modifiers, { onValueChange(e) { if (typeof text === 'object' && 'value' in text) { text.setValue(e.nativeEvent.onValueChange); } onChange?.(e.nativeEvent.onValueChange); }, }); }, style: { width: 100, height: 30, ...style, } })); } exports.TextField = TextField; function SecureField({ text, style, onChange, placeholder, ...modifiers }) { return (react_1.default.createElement(NativeTextField, { text: (0, binding_1.getValueOrBinding)(text), type: "securefield", modifiers: (0, modifiers_1.mapToNativeModifiers)(modifiers), onEvent: (e) => { (0, onBaseEvent_1.onBaseEvent)(e, modifiers, { onValueChange: (e) => { if (typeof text === 'object' && 'value' in text) { text.setValue(e.nativeEvent.onValueChange); } onChange?.(e.nativeEvent.onValueChange); }, }); }, style: { width: 100, height: 30, ...style, } })); } exports.SecureField = SecureField; function TextEditor({ text, style, onChange, placeholder, ...modifiers }) { return (react_1.default.createElement(NativeTextField, { text: (0, binding_1.getValueOrBinding)(text), type: "texteditor", modifiers: (0, modifiers_1.mapToNativeModifiers)(modifiers), onEvent: (e) => { (0, onBaseEvent_1.onBaseEvent)(e, modifiers, { onValueChange: (e) => { if (typeof text === 'object' && 'value' in text) { text.setValue(e.nativeEvent.onValueChange); } onChange?.(e.nativeEvent.onValueChange); }, }); }, style: { ...(0, modifiers_1.getSizeFromModifiers)(modifiers, { width: 100, height: 30 }), ...style, } })); } exports.TextEditor = TextEditor; //# sourceMappingURL=TextField.ios.js.map