(children: ReactElement<unknown>[])
| 20 | } |
| 21 | |
| 22 | function encodeChildren(children: ReactElement<unknown>[]): EncodedElement[] { |
| 23 | const elements: EncodedElement[] = []; |
| 24 | |
| 25 | children.forEach((current) => { |
| 26 | if (!current) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | switch (current.type) { |
| 31 | case List: { |
| 32 | elements.push( |
| 33 | encodeList(current as ReactElement<ListProps<RowComponentData>>) |
| 34 | ); |
| 35 | break; |
| 36 | } |
| 37 | case RowComponent: { |
| 38 | elements.push( |
| 39 | encodeRowComponent( |
| 40 | current as ReactElement<RowComponentProps<RowComponentData>> |
| 41 | ) |
| 42 | ); |
| 43 | break; |
| 44 | } |
| 45 | default: { |
| 46 | if (typeof current === "object") { |
| 47 | const { children } = current.props as TextProps; |
| 48 | if (typeof children === "string") { |
| 49 | elements.push(encodeTextChild(current as ReactElement<TextProps>)); |
| 50 | } else { |
| 51 | console.warn("Could not encode type:", current); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | }); |
| 57 | |
| 58 | return elements; |
| 59 | } |
| 60 | |
| 61 | function encodeList( |
| 62 | element: ReactElement<ListProps<RowComponentData>> |
no test coverage detected