(props: Record<string, string | null | undefined>, options: FormatPropsOptions = {})
| 16 | } |
| 17 | |
| 18 | export const formatProps = (props: Record<string, string | null | undefined>, options: FormatPropsOptions = {}) => { |
| 19 | const { keyValueSeparator = ': ', propSeparator = ', ', quoteStyle = 'single' } = options |
| 20 | const quote = quoteStyle === 'single' ? "'" : quoteStyle === 'double' ? '"' : '' |
| 21 | return Object.entries(props) |
| 22 | .filter(([_, value]) => value != null) |
| 23 | .map(([key, value]) => `${key}${keyValueSeparator}${quote}${value}${quote}`) |
| 24 | .join(propSeparator) |
| 25 | } |
| 26 | |
| 27 | export const formatJsxComponent = (component: string, props: Record<string, string | null | undefined>) => { |
| 28 | const formattedProps = formatProps(props, { keyValueSeparator: '=', propSeparator: ' ', quoteStyle: 'double' }) |
no test coverage detected