UNPKG

@sendbird/uikit-react-native

Version:

Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.

107 lines (106 loc) 4.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _uikitReactNativeFoundation = require("@sendbird/uikit-react-native-foundation"); var _useContext = require("../../../hooks/useContext"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const MessageSearchHeader = ({ keyword, onChangeKeyword, onPressHeaderLeft, onPressHeaderRight }) => { const { HeaderComponent } = (0, _uikitReactNativeFoundation.useHeaderStyle)(); const { colors } = (0, _uikitReactNativeFoundation.useUIKitTheme)(); const { STRINGS } = (0, _useContext.useLocalization)(); const inputRef = (0, _react.useRef)(null); const inputColor = colors.ui.input.default.active; const searchEnabled = keyword.length > 0; (0, _react.useEffect)(() => { setTimeout(() => { var _inputRef$current; (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus(); }, _reactNative.Platform.select({ ios: 500, default: 0 })); }, []); return /*#__PURE__*/_react.default.createElement(HeaderComponent, { clearTitleMargin: true, title: /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Box, { flex: 1, height: 36, alignItems: 'center', backgroundColor: inputColor.background, borderRadius: 24, paddingHorizontal: 10, flexDirection: 'row' }, /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Icon, { size: 24, icon: 'search', color: colors.onBackground03, containerStyle: styles.searchIcon }), /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.TextInput, { disableFullscreenUI: true, enablesReturnKeyAutomatically: true, ref: inputRef, returnKeyType: 'search', onSubmitEditing: () => onPressHeaderRight(), selectionColor: colors.primary, placeholder: STRINGS.MESSAGE_SEARCH.HEADER_INPUT_PLACEHOLDER, placeholderTextColor: inputColor.placeholder, style: [styles.input, { color: inputColor.text }], value: keyword, onChangeText: onChangeKeyword, supportRTLAlign: true, originalText: keyword }), searchEnabled && /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.PressBox, { onPress: () => onChangeKeyword('') }, /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Icon, { size: 18, icon: 'remove', color: colors.onBackground03, containerStyle: styles.clearIcon }))), left: /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Icon, { icon: 'arrow-left' }), onPressLeft: onPressHeaderLeft, right: /*#__PURE__*/_react.default.createElement(_uikitReactNativeFoundation.Text, { button: true, color: searchEnabled ? colors.primary : colors.onBackground04 }, STRINGS.MESSAGE_SEARCH.HEADER_RIGHT), onPressRight: searchEnabled ? onPressHeaderRight : undefined }); }; const styles = (0, _uikitReactNativeFoundation.createStyleSheet)({ searchIcon: { marginEnd: 8 }, clearIcon: { marginStart: 8 }, input: { flex: 1, height: '100%', fontSize: 14, paddingStart: 0, paddingTop: 0, paddingBottom: 0, paddingEnd: 0 } }); var _default = exports.default = MessageSearchHeader; //# sourceMappingURL=MessageSearchHeader.js.map