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

Function CodeProps

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

Source from the content-addressed store, hash-verified

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