"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const components_1 = require("@bluebase/components");
const TextField_1 = tslib_1.__importDefault(require("@material-ui/core/TextField"));
const component_mapper_1 = require("@bluebase/component-mapper");
exports.TextInput = component_mapper_1.componentMapper(TextField_1.default, {
    autoCorrect: ({ autoCorrect }) => (autoCorrect ? 'on' : 'off'),
    spellCheck: ({ spellCheck, autoCorrect }) => spellCheck !== undefined ? spellCheck : autoCorrect,
    disabled: ({ disabled, editable }) => disabled !== undefined ? disabled : !editable,
    onChange: ({ onChange, onChangeText }) => (event) => {
        if (onChange) {
            onChange(event);
        }
        if (onChangeText && event && event.target) {
            onChangeText(event.target.value);
        }
    },
    type: ({ keyboardType, secureTextEntry, type }) => {
        if (type) {
            return type;
        }
        if (secureTextEntry) {
            return 'password';
        }
        switch (keyboardType) {
            case 'email-address':
                return 'email';
            case 'number-pad':
            case 'numeric':
                return 'number';
            case 'phone-pad':
                return 'tel';
            case 'search':
            case 'web-search':
                return 'search';
            case 'url':
                return 'url';
            default:
                return 'text';
        }
    },
    rows: 'numberOfLines',
}, {
    defaultProps: components_1.TextInputDefaultProps,
    rest: true,
    ignore: [
        'autoCorrect',
        'editable',
        'keyboardType',
        // 'multiline',
        'numberOfLines',
        'secureTextEntry',
        'style',
        'blurOnSubmit',
        'clearTextOnFocus',
        'onChangeText',
        'onLayout',
        'onSelectionChange',
        'onSubmitEditing',
        'selection',
        'selectTextOnFocus',
        'spellCheck',
        'accessibilityViewIsModal',
        'allowFontScaling',
        'caretHidden',
        'clearButtonMode',
        'dataDetectorTypes',
        'disableFullscreenUI',
        'enablesReturnKeyAutomatically',
        'hitSlop',
        'inlineImageLeft',
        'inlineImagePadding',
        'inputAccessoryViewID',
        'keyboardAppearance',
        'needsOffscreenAlphaCompositing',
        'onAccessibilityTap',
        'onContentSizeChange',
        'onEndEditing',
        'onMagicTap',
        'onScroll',
        'removeClippedSubviews',
        'renderToHardwareTextureAndroid',
        'returnKeyLabel',
        'returnKeyType',
        'scrollEnabled',
        'selectionColor',
        'selectionState',
        'shouldRasterizeIOS',
        'textBreakStrategy',
        'textContentType',
        'underlineColorAndroid',
    ],
});
