connect-transfer-react-native-sdk
Version:
Connect Transfer React Native SDK for Mastercard Open Banking Connect
69 lines (68 loc) • 2.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _reactI18next = require("react-i18next");
var _jsxRuntime = require("react/jsx-runtime");
const MAAttributedText = ({
text,
styledTexts,
textStyle,
component = null
}) => {
const {
t
} = (0, _reactI18next.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__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.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__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: textStyle,
children: part
}, key);
}
const styledText = styledObj.onPress ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
onPress: styledObj.onPress,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styledObj.style,
children: part
})
}, key) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styledObj.style,
children: part
}, key);
if (styledObj.text === t('PrivacyNoticeText') && component) {
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
onPress: styledObj.onPress,
style: {
flexDirection: 'row',
transform: [{
translateY: _reactNative.Platform.OS === 'ios' ? 1 : 4
}]
},
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styledObj.style],
children: part
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: {
textDecorationLine: 'none'
},
children: " "
}), component]
}, key);
}
return styledText;
})
})
});
};
var _default = exports.default = MAAttributedText;
//# sourceMappingURL=MAAttributedText.js.map