UNPKG

connect-transfer-react-native-sdk

Version:

Connect Transfer React Native SDK for Mastercard Open Banking Connect

65 lines (64 loc) 2.11 kB
"use strict"; import { Text, Pressable, Platform } from 'react-native'; import { useTranslation } from 'react-i18next'; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; const MAAttributedText = ({ text, styledTexts, textStyle, component = null }) => { const { t } = useTranslation(); const pattern = styledTexts?.length > 0 ? new RegExp(`(${styledTexts.map(item => item.text).join('|')})`, 'gi') : null; const parts = pattern ? text?.split(pattern) : [text]; return /*#__PURE__*/_jsx(_Fragment, { children: /*#__PURE__*/_jsx(Text, { style: textStyle, children: parts.map((part, index) => { const styledObj = styledTexts?.find(item => item.text?.toLowerCase() === part.toLowerCase()); const key = `${part}-${index}`; if (!styledObj) { return /*#__PURE__*/_jsx(Text, { style: textStyle, children: part }, key); } const styledText = styledObj.onPress ? /*#__PURE__*/_jsx(Pressable, { onPress: styledObj.onPress, children: /*#__PURE__*/_jsx(Text, { style: styledObj.style, children: part }) }, key) : /*#__PURE__*/_jsx(Text, { style: styledObj.style, children: part }, key); if (styledObj.text === t('PrivacyNoticeText') && component) { return /*#__PURE__*/_jsxs(Pressable, { onPress: styledObj.onPress, style: { flexDirection: 'row', transform: [{ translateY: Platform.OS === 'ios' ? 1 : 4 }] }, children: [/*#__PURE__*/_jsx(Text, { style: [styledObj.style], children: part }), /*#__PURE__*/_jsx(Text, { style: { textDecorationLine: 'none' }, children: " " }), component] }, key); } return styledText; }) }) }); }; export default MAAttributedText; //# sourceMappingURL=MAAttributedText.js.map