({indent = ''})
| 301 | } |
| 302 | |
| 303 | export 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 | |
| 333 | function renderElement(name: string, props: Props, controls?: Controls, indent = '') { |
| 334 | let start = ( |
nothing calls this directly
no test coverage detected