| 3 | export type NormalizedStyle = Record<string, string | number> |
| 4 | |
| 5 | export function normalizeStyle( |
| 6 | value: unknown, |
| 7 | ): NormalizedStyle | string | undefined { |
| 8 | if (isArray(value)) { |
| 9 | const res: NormalizedStyle = {} |
| 10 | for (let i = 0; i < value.length; i++) { |
| 11 | const item = value[i] |
| 12 | const normalized = isString(item) |
| 13 | ? parseStringStyle(item) |
| 14 | : (normalizeStyle(item) as NormalizedStyle) |
| 15 | if (normalized) { |
| 16 | for (const key in normalized) { |
| 17 | res[key] = normalized[key] |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | return res |
| 22 | } else if (isString(value) || isObject(value)) { |
| 23 | return value |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | const listDelimiterRE = /;(?![^(]*\))/g |
| 28 | const propertyDelimiterRE = /:([^]+)/ |