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

Function PropTable

packages/dev/s2-docs/src/PropTable.tsx:135–205  ·  view source on GitHub ↗
({
  component,
  links,
  showDescription,
  hideRenderProps,
  showOptionalRenderProps,
  hideSelector,
  cssVariables
}: PropTableProps)

Source from the content-addressed store, hash-verified

133}
134
135export function PropTable({
136 component,
137 links,
138 showDescription,
139 hideRenderProps,
140 showOptionalRenderProps,
141 hideSelector,
142 cssVariables
143}: PropTableProps) {
144 let properties = component?.props?.type === 'interface' ? component.props.properties : null;
145 if (!properties) {
146 return null;
147 }
148
149 let hasProps =
150 Object.values(properties).filter(
151 prop => prop.type === 'property' && prop.access !== 'private' && prop.access !== 'protected'
152 ).length > 0;
153
154 let defaultClassName = properties.className?.default?.slice(1, -1);
155 let renderProps: TType | null = null;
156 let renderPropProperty = properties.className || properties.children;
157 if (!hideRenderProps && renderPropProperty?.type === 'property') {
158 if (renderPropProperty.value.type === 'union') {
159 let func = renderPropProperty.value.elements.find(e => e.type === 'function');
160 if (func) {
161 renderProps = func.parameters[0]?.value;
162 }
163 } else if (renderPropProperty.value.type === 'application') {
164 let application = renderPropProperty.value;
165 if (
166 application.base.type === 'link' &&
167 /ClassNameOrFunction|ChildrenOrFunction/.test(links[application.base.id]?.name)
168 ) {
169 renderProps = application.typeParameters[0];
170 }
171 }
172
173 if (renderProps?.type === 'link') {
174 renderProps = links[renderProps.id];
175 }
176 }
177
178 return (
179 <>
180 {component.description && showDescription && (
181 <div className={style({font: 'body', marginBottom: 16})}>
182 {renderHTMLfromMarkdown(component.description, {forceInline: false, forceBlock: true})}
183 </div>
184 )}
185 {hasProps && (
186 <GroupedPropTable
187 properties={properties}
188 links={links}
189 propGroups={GROUPS}
190 defaultExpanded={DEFAULT_EXPANDED}
191 />
192 )}

Callers

nothing calls this directly

Calls 3

renderHTMLfromMarkdownFunction · 0.90
sliceMethod · 0.80
filterMethod · 0.65

Tested by

no test coverage detected