(children, indent = '')
| 377 | } |
| 378 | |
| 379 | function renderChildren(children, indent = '') { |
| 380 | if (children?.icon || children?.avatar || children?.badge) { |
| 381 | let result: ReactNode = null; |
| 382 | if (children.avatar) { |
| 383 | result = renderElement('Avatar', {src: 'https://i.imgur.com/xIe7Wlb.png'}, undefined, indent); |
| 384 | } else if (children.icon) { |
| 385 | result = renderElement(children.icon.replace(/^(\d)/, '_$1'), {}, undefined, indent); |
| 386 | } |
| 387 | |
| 388 | if (children.text) { |
| 389 | let text = renderElement('Text', {children: children.text}, undefined, indent); |
| 390 | result = ( |
| 391 | <> |
| 392 | {result} |
| 393 | {result ? '\n ' + indent : null} |
| 394 | {text} |
| 395 | </> |
| 396 | ); |
| 397 | } |
| 398 | |
| 399 | if (children.badge) { |
| 400 | let badge = renderElement('NotificationBadge', {value: 12}, undefined, indent); |
| 401 | result = ( |
| 402 | <> |
| 403 | {result} |
| 404 | {result ? '\n ' + indent : null} |
| 405 | {badge} |
| 406 | </> |
| 407 | ); |
| 408 | } |
| 409 | |
| 410 | return result; |
| 411 | } else if (children?.text != null) { |
| 412 | return children.text; |
| 413 | } else if (Array.isArray(children)) { |
| 414 | return children.map((c, i) => ( |
| 415 | <React.Fragment key={i}> |
| 416 | {i > 0 ? '\n ' + indent : null} |
| 417 | {c} |
| 418 | </React.Fragment> |
| 419 | )); |
| 420 | } |
| 421 | |
| 422 | return children; |
| 423 | } |
| 424 | |
| 425 | function countChars(element: ReactNode) { |
| 426 | if (typeof element === 'string') { |
no test coverage detected