UNPKG

we-insights-react-native

Version:

[we-insights] is a powerful utility library designed to streamline data collection processes for WeApp employees. It simplifies the process of gathering, storing, and managing data within WeApp projects, making it an invaluable tool for enhancing efficien

75 lines (74 loc) 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Input = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } const Input = ({ multiline = false, numberOfLines = 1, placeholder = '', onChangeText, value, style = {} }) => { const [isFocused, setIsFocused] = (0, _react.useState)(false); const inputStyle = { backgroundColor: style.backgroundColor, color: style.textColor, borderColor: style.borderColor, fontFamily: style.fontFamily, ...styles.input, ...(multiline && styles.textArea), fontSize: 16 }; return /*#__PURE__*/_react.default.createElement(_reactNative.View, { style: styles.inputContainer }, /*#__PURE__*/_react.default.createElement(_reactNative.View, { style: styles.placeholderContainer }, (value || isFocused) && /*#__PURE__*/_react.default.createElement(_reactNative.Text, { style: [styles.placeholder, { color: style.textColor }] }, placeholder), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, { multiline: multiline, numberOfLines: numberOfLines, placeholder: isFocused ? '' : placeholder, onChangeText: onChangeText, value: value, style: inputStyle, placeholderTextColor: style.textColor, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false) }))); }; exports.Input = Input; const styles = _reactNative.StyleSheet.create({ inputContainer: { position: 'relative' }, input: { borderWidth: 1, padding: 10, marginBottom: 10, borderRadius: 4 }, textArea: { height: 100 }, placeholderContainer: { position: 'relative' }, placeholder: { position: 'absolute', top: 4, left: 10, color: '#ffffff', fontSize: 10, zIndex: 999 } }); //# sourceMappingURL=Input.js.map