({
componentLink,
prop,
}: {
componentLink: string;
prop: string;
})
| 25 | }; |
| 26 | |
| 27 | export default function PropTable({ |
| 28 | componentLink, |
| 29 | prop, |
| 30 | }: { |
| 31 | componentLink: string; |
| 32 | prop: string; |
| 33 | }) { |
| 34 | const doc = useDoc(componentLink); |
| 35 | |
| 36 | if (!doc?.data?.props) { |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | const props = doc.data.props; |
| 41 | |
| 42 | return ( |
| 43 | <div> |
| 44 | {Object.keys(props).map((key) => { |
| 45 | if (key !== prop) { |
| 46 | return null; |
| 47 | } |
| 48 | let descriptionByLines = props[key].description.split('\n'); |
| 49 | |
| 50 | // Slice leading badge - it's handled in `generatePageMDX` |
| 51 | if (descriptionByLines[0].includes('@')) { |
| 52 | descriptionByLines = descriptionByLines.slice(1); |
| 53 | } |
| 54 | descriptionByLines = descriptionByLines.map((line: string) => { |
| 55 | // Replace annotations with styled badges. |
| 56 | if (line.includes('@')) { |
| 57 | const annotIndex = line.indexOf('@'); |
| 58 | // eslint-disable-next-line prettier/prettier |
| 59 | return `${line.substr(0, annotIndex)} ${renderBadge(line.substr(annotIndex))}`; |
| 60 | } else { |
| 61 | return line; |
| 62 | } |
| 63 | }); |
| 64 | |
| 65 | const description = descriptionByLines.join('\n'); |
| 66 | const tsType = props[key].tsType?.raw ?? props[key].tsType?.name; |
| 67 | // @ts-ignore |
| 68 | const tsTypeLink = typeDefinitions[tsType]; |
| 69 | |
| 70 | return ( |
| 71 | <div key={key}> |
| 72 | <p> |
| 73 | Type:{' '} |
| 74 | {tsTypeLink ? ( |
| 75 | <a |
| 76 | href={tsTypeLink} |
| 77 | target={ |
| 78 | tsTypeLink.startsWith( |
| 79 | 'https://callstack.github.io/react-native-paper' |
| 80 | ) |
| 81 | ? '_self' |
| 82 | : '_blank' |
| 83 | } |
| 84 | rel="noreferrer" |
nothing calls this directly
no test coverage detected
searching dependent graphs…