@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.
108 lines (107 loc) • 4.29 kB
JavaScript
"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 _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 && {}.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 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