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

Function CodeProps

packages/dev/s2-docs/src/VisualExampleClient.tsx:303–331  ·  view source on GitHub ↗
({indent = ''})

Source from the content-addressed store, hash-verified

301}
302
303export function CodeProps({indent = ''}) {
304 let {props, controls, propsObject} = useContext(Context);
305 if (propsObject) {
306 props = {[propsObject]: props};
307 }
308
309 let renderedProps: ReactNode[] = Object.keys(props)
310 .filter(prop => prop !== 'children')
311 .map(prop => renderProp(prop, props[prop], controls[prop], indent))
312 .filter(Boolean);
313 let newlines = indent.length > 0 || countChars(renderedProps) > 40;
314 let separator = newlines ? indent || ' ' : ' ';
315 renderedProps = renderedProps.map((p, i) => {
316 let sep = separator;
317 if (newlines) {
318 sep = (indent && i === 0 ? '' : '\n') + separator;
319 }
320 return (
321 <Fragment key={i}>
322 {sep}
323 {p}
324 </Fragment>
325 );
326 });
327 if (newlines && indent && renderedProps.length) {
328 renderedProps.push('\n');
329 }
330 return renderedProps;
331}
332
333function renderElement(name: string, props: Props, controls?: Controls, indent = '') {
334 let start = (

Callers

nothing calls this directly

Calls 4

renderPropFunction · 0.85
countCharsFunction · 0.85
pushMethod · 0.80
filterMethod · 0.65

Tested by

no test coverage detected