(style: NestedStyleMap)
| 1202 | } |
| 1203 | |
| 1204 | export function nestedCssToClassNames(style: NestedStyleMap): string[] { |
| 1205 | const base: Record<string, string> = {} |
| 1206 | const nestedEntries: Array<{ selector: string; style: Record<string, string> }> = [] |
| 1207 | |
| 1208 | for (const [key, value] of Object.entries(style)) { |
| 1209 | if (typeof value === 'string') { |
| 1210 | base[key] = value |
| 1211 | continue |
| 1212 | } |
| 1213 | if (!value || typeof value !== 'object' || Array.isArray(value)) continue |
| 1214 | nestedEntries.push({ selector: key, style: value }) |
| 1215 | } |
| 1216 | |
| 1217 | const classNames = cssToClassNamesWithArbitraryProperties(base) |
| 1218 | |
| 1219 | for (const entry of nestedEntries) { |
| 1220 | const variant = nestedSelectorToVariant(entry.selector) |
| 1221 | if (!variant) continue |
| 1222 | const nestedClassNames = cssToClassNamesWithArbitraryProperties(entry.style) |
| 1223 | classNames.push(...nestedClassNames.map((className) => `${variant}:${className}`)) |
| 1224 | } |
| 1225 | |
| 1226 | return Array.from(new Set(classNames)) |
| 1227 | } |
| 1228 | |
| 1229 | export function joinClassNames(classNames: string[]): string { |
| 1230 | return classNames.filter(Boolean).join(' ') |
no test coverage detected