|
4 | 4 | // trick to keep reference to Array build-in type |
5 | 5 | declare class BuiltInArray<T> extends Array<T> {} |
6 | 6 |
|
7 | | -// trick to have nice attribute list for CSS |
8 | | -declare type CSSStyleName = Exclude< |
9 | | - keyof CSSStyleDeclaration, |
10 | | - 'parentRule' | 'length' |
11 | | -> |
12 | | - |
13 | 7 | // camelCase to kebab-case |
14 | | -type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` |
15 | | - ? U extends Uncapitalize<U> |
16 | | - ? `${Lowercase<T>}${CamelToKebab<U>}` |
17 | | - : `${Lowercase<T>}-${CamelToKebab<U>}` |
18 | | - : S; |
19 | | - |
20 | | -type ConvertKeysToKebab<T> = { |
21 | | - [K in keyof T as CamelToKebab<K & string>]: T[K]; |
| 8 | +declare type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` |
| 9 | + ? U extends Uncapitalize<U> |
| 10 | + ? `${Lowercase<T>}${CamelToKebab<U>}` |
| 11 | + : `${Lowercase<T>}-${CamelToKebab<U>}` |
| 12 | + : S; |
| 13 | + |
| 14 | +declare type ConvertKeysToKebab<T> = { |
| 15 | + [K in keyof T as CamelToKebab<K & string>]: T[K]; |
22 | 16 | }; |
23 | 17 |
|
| 18 | +declare type KebabCSSStyleDeclaration = ConvertKeysToKebab<CSSStyleDeclaration> |
| 19 | + |
| 20 | +// trick to have nice attribute list for CSS |
| 21 | +declare type CSSStyleName = Exclude< |
| 22 | + keyof KebabCSSStyleDeclaration, |
| 23 | + 'parent-rule' | 'length' |
| 24 | +> |
24 | 25 |
|
25 | 26 | // create our own style declaration that includes css vars |
26 | | -interface CSSStyleDeclarationWithVars extends ConvertKeysToKebab<CSSStyleDeclaration> { |
| 27 | +interface CSSStyleDeclarationWithVars extends KebabCSSStyleDeclaration { |
27 | 28 | [key: `--${string}`]: string |
28 | 29 | } |
29 | 30 |
|
|
0 commit comments