MCPcopy Create free account
hub / github.com/adobe/react-spectrum / StateTable

Function StateTable

packages/dev/s2-docs/src/StateTable.tsx:18–90  ·  view source on GitHub ↗
({
  properties,
  links,
  showOptional,
  hideSelector,
  cssVariables,
  style: styleProp
}: StateTableProps)

Source from the content-addressed store, hash-verified

16}
17
18export function StateTable({
19 properties,
20 links,
21 showOptional,
22 hideSelector,
23 cssVariables,
24 style: styleProp
25}: StateTableProps) {
26 if (links) {
27 setLinks(links);
28 }
29
30 let props = Object.values(properties);
31 if (!showOptional) {
32 props = props.filter(prop => !prop.optional);
33 }
34 let showSelector = !hideSelector && props.some(prop => prop.type === 'property' && prop.selector);
35
36 let table = (
37 <Table style={styleProp}>
38 <TableHeader>
39 <TableRow>
40 <TableColumn role="columnheader">Render Prop</TableColumn>
41 {showSelector && <TableColumn role="columnheader">CSS Selector</TableColumn>}
42 </TableRow>
43 </TableHeader>
44 <TableBody>
45 {props.map((prop, index) => (
46 <Fragment key={index}>
47 <TableRow>
48 <TableCell role="rowheader" hideBorder>
49 <code className={codeStyle}>
50 <span className={codeStyles.property}>{prop.name}</span>
51 </code>
52 </TableCell>
53 {showSelector && (
54 <TableCell hideBorder>
55 <strong
56 className={style({font: 'ui', fontWeight: 'bold', display: {sm: 'none'}})}>
57 CSS Selector:{' '}
58 </strong>
59 {prop.type === 'property' && prop.selector ? (
60 <span className={codeStyle}>
61 <Code lang="css">{prop.selector}</Code>
62 </span>
63 ) : (
64 <code className={codeStyle}>—</code>
65 )}
66 </TableCell>
67 )}
68 </TableRow>
69 <TableRow>
70 <TableCell colSpan={2}>
71 {prop.description && renderHTMLfromMarkdown(prop.description, {forceInline: true})}
72 </TableCell>
73 </TableRow>
74 </Fragment>
75 ))}

Callers

nothing calls this directly

Calls 3

setLinksFunction · 0.90
renderHTMLfromMarkdownFunction · 0.90
filterMethod · 0.65

Tested by

no test coverage detected