({indent = ''})
| 297 | } |
| 298 | |
| 299 | export 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 | |
| 329 | function renderElement(name: string, props: Props, controls?: Controls, indent = '') { |
| 330 | let start = ( |
nothing calls this directly
no test coverage detected