Skip to content

Commit eb32e76

Browse files
committed
feat: add KebabCaseStandardPropertiesMap type
1 parent 9203fc0 commit eb32e76

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/types/property.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type * as CSS from 'csstype'
2+
import type { KebabCase, LiteralUnion } from '../utils'
23

34
export type CSSPropertiesMap = keyof CSS.Properties
45

56
export type StandardPropertiesMap = keyof CSS.StandardProperties
7+
8+
export type KebabCaseStandardPropertiesMap = LiteralUnion<KebabCase<StandardPropertiesMap>>

src/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ export type LiteralUnion<Union extends Base, Base = string> =
2323
| (Base & { zz_IGNORE_ME?: never })
2424

2525
export type RegExpLike = RegExp | `/${string}/`
26+
27+
export type KebabCase<S extends string, B extends boolean = true> =
28+
S extends `${infer F}${infer O}`
29+
? F extends Uncapitalize<F>
30+
? `${F}${KebabCase<O, false>}`
31+
: B extends true
32+
? `${Uncapitalize<F>}${KebabCase<O, false>}`
33+
: `-${Uncapitalize<F>}${KebabCase<O, false>}`
34+
: S

0 commit comments

Comments
 (0)