UNPKG

@audira/carbon-react-native

Version:

Build React Native apps with component and shared patterns using Carbon

211 lines (206 loc) 6.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextInput = void 0; var _react = require("react"); var _reactNative = require("react-native"); var _carbonReactNativeElements = require("@audira/carbon-react-native-elements"); var _index = require("../form-helper-text/index.js"); var _index2 = require("../form-label/index.js"); var _index3 = require("../text-input-field/index.js"); var _jsxRuntime = require("react/jsx-runtime"); const TextInput = exports.TextInput = /*#__PURE__*/(0, _react.forwardRef)(function TextInput({ label, helperText, // hoist the `TextInputFieldProps` size = 'medium', interactiveState = 'normal', textInputStyle, // ----- // hoist TextInputProps of React Native allowFontScaling, autoCapitalize, autoComplete, autoCorrect, autoFocus, blurOnSubmit, submitBehavior, caretHidden, contextMenuHidden, defaultValue, value, editable, keyboardType, inputMode, maxLength, multiline, onBlur, onChange, onChangeText, onContentSizeChange, onEndEditing, onPress, onPressIn, onPressOut, onFocus, onSelectionChange, onSubmitEditing, onScroll, onKeyPress, placeholder, placeholderTextColor, readOnly, returnKeyType, enterKeyHint, secureTextEntry, selectTextOnFocus, selection, selectionColor, textAlign, inputAccessoryViewID, inputAccessoryViewButtonLabel, maxFontSizeMultiplier, // ----- // hoist TextInputAndroidProps cursorColor, selectionHandleColor, importantForAutofill, disableFullscreenUI, inlineImageLeft, inlineImagePadding, numberOfLines, returnKeyLabel, textBreakStrategy, underlineColorAndroid, textAlignVertical, showSoftInputOnFocus, verticalAlign, // ----- // hoist TextInputIOSProps disableKeyboardShortcuts, clearButtonMode, clearTextOnFocus, dataDetectorTypes, enablesReturnKeyAutomatically, keyboardAppearance, passwordRules, rejectResponderTermination, selectionState, spellCheck, textContentType, scrollEnabled, lineBreakStrategyIOS, lineBreakModeIOS, smartInsertDelete, // ----- style: viewStyleProp, ...viewProps }, ref) { const viewRef = (0, _react.useRef)(null), textInputFieldRef = (0, _react.useRef)(null); (0, _react.useImperativeHandle)(ref, () => { return Object.assign(viewRef.current ?? {}, { get textInputField() { return textInputFieldRef.current ?? undefined; } }); }, []); return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { ...viewProps, ref: viewRef, style: viewStyleProp, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.FormLabel, { label: label, style: styleSheet.label }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index3.TextInputField, { ref: textInputFieldRef, size: size, interactiveState: interactiveState, textInputStyle: textInputStyle, allowFontScaling: allowFontScaling, autoCapitalize: autoCapitalize, autoComplete: autoComplete, autoCorrect: autoCorrect, autoFocus: autoFocus, blurOnSubmit: blurOnSubmit, submitBehavior: submitBehavior, caretHidden: caretHidden, contextMenuHidden: contextMenuHidden, defaultValue: defaultValue, value: value, editable: editable, keyboardType: keyboardType, inputMode: inputMode, maxLength: maxLength, multiline: multiline, onBlur: onBlur, onChange: onChange, onChangeText: onChangeText, onContentSizeChange: onContentSizeChange, onEndEditing: onEndEditing, onPress: onPress, onPressIn: onPressIn, onPressOut: onPressOut, onFocus: onFocus, onSelectionChange: onSelectionChange, onSubmitEditing: onSubmitEditing, onScroll: onScroll, onKeyPress: onKeyPress, placeholder: placeholder, placeholderTextColor: placeholderTextColor, readOnly: readOnly, returnKeyType: returnKeyType, enterKeyHint: enterKeyHint, secureTextEntry: secureTextEntry, selectTextOnFocus: selectTextOnFocus, selection: selection, selectionColor: selectionColor, textAlign: textAlign, inputAccessoryViewID: inputAccessoryViewID, inputAccessoryViewButtonLabel: inputAccessoryViewButtonLabel, maxFontSizeMultiplier: maxFontSizeMultiplier, cursorColor: cursorColor, selectionHandleColor: selectionHandleColor, importantForAutofill: importantForAutofill, disableFullscreenUI: disableFullscreenUI, inlineImageLeft: inlineImageLeft, inlineImagePadding: inlineImagePadding, numberOfLines: numberOfLines, returnKeyLabel: returnKeyLabel, textBreakStrategy: textBreakStrategy, underlineColorAndroid: underlineColorAndroid, textAlignVertical: textAlignVertical, showSoftInputOnFocus: showSoftInputOnFocus, verticalAlign: verticalAlign, disableKeyboardShortcuts: disableKeyboardShortcuts, clearButtonMode: clearButtonMode, clearTextOnFocus: clearTextOnFocus, dataDetectorTypes: dataDetectorTypes, enablesReturnKeyAutomatically: enablesReturnKeyAutomatically, keyboardAppearance: keyboardAppearance, passwordRules: passwordRules, rejectResponderTermination: rejectResponderTermination, selectionState: selectionState, spellCheck: spellCheck, textContentType: textContentType, scrollEnabled: scrollEnabled, lineBreakStrategyIOS: lineBreakStrategyIOS, lineBreakModeIOS: lineBreakModeIOS, smartInsertDelete: smartInsertDelete }), !!helperText?.length && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.FormHelperText, { text: helperText, error: interactiveState === 'invalid', style: styleSheet.helperText })] }); }); const styleSheet = _reactNative.StyleSheet.create({ label: { marginBottom: _carbonReactNativeElements.Spacing.spacing_03 }, helperText: { marginTop: _carbonReactNativeElements.Spacing.spacing_02 } }); //# sourceMappingURL=TextInput.js.map