UNPKG

@prosperitainova/dumbo-react-native

Version:
79 lines (77 loc) 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InlineLink = void 0; var _react = _interopRequireDefault(require("react")); var _reactNative = require("react-native"); var _helpers = require("../../helpers"); var _colors = require("../../styles/colors"); var _Text = require("../Text"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** Props for InlineLink component */ /** * InlineLink component * Link for using in inline with other text. * * To use import React Native Text wrapper `import { Text as ReactText } from 'react-native';` * Use `Text` from the Carbon package. * Then use something like: * ```javascript * <ReactText> * <Text text="Regular text before link. You can click on " /> * <InlineLink text="this link" onPress={() => openLink('https://carbondesignsystem.com')} /> * <Text text=" which will open the link." /> * </ReactText> * ``` * * {@link https://github.com/carbon-design-system/carbon-react-native/blob/main/example/src/Views/Link.tsx | Example code} */ class InlineLink extends _react.default.Component { get styles() { const { forceDarkMode } = this.props; return _reactNative.StyleSheet.create({ wrapper: { flexDirection: 'row', alignItems: 'center', color: (0, _colors.getColor)('linkPrimary', forceDarkMode ? 'dark' : undefined) } }); } onPress = event => { const { dismissKeyboardOnPress, onPress } = this.props; if (dismissKeyboardOnPress && typeof _reactNative.Keyboard?.dismiss === 'function') { _reactNative.Keyboard.dismiss(); } if (typeof onPress === 'function') { onPress(event); } }; render() { const { text, onLongPress, textType, style } = this.props; return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, { type: textType, text: text, style: (0, _helpers.styleReferenceBreaker)(this.styles.wrapper, style), componentProps: { accessibilityLabel: text, accessibilityRole: 'link', onPress: this.onPress, onLongPress: onLongPress } }); } } exports.InlineLink = InlineLink; //# sourceMappingURL=index.js.map