Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 20x 20x 12x 12x 2x 11x 11x 2x 9x 20x 20x 12x 12x 20x 20x | import React from 'react'; import PropTypes from 'prop-types'; import { removeSomeProps } from 'src/utils/componentHelpers'; import { control, spaceProps, typography } from 'src/utils/styledHelpers'; const isArrayOptionsValue = value => !!value && Array.isArray(value); const getDisplayValue = props => { const { value } = props; if (isArrayOptionsValue(value)) { return value.map(e => e.label).join(', '); } Iif (!!value && !!value.label) { return value.label; } if (typeof value === 'string') { return value; } return ''; }; const propsToTrim = [ 'labelText', ...Object.keys(control.propTypes), ...Object.keys(spaceProps.propTypes), ...Object.keys(typography.propTypes), 'value', ]; export const PlainTextComponent = props => { const displayString = getDisplayValue(props); return ( <div {...removeSomeProps(props, propsToTrim)}> <div>{displayString}</div> </div> ); }; PlainTextComponent.propTypes = { ...control.propTypes, ...typography.propTypes, value: PropTypes.any, }; PlainTextComponent.defaultProps = { value: null, }; |