@@ -7,28 +7,18 @@ import properties from "mdn-data/css/properties.json";
7
7
import syntaxes from "mdn-data/css/syntaxes.json" ;
8
8
import selectors from "mdn-data/css/selectors.json" ;
9
9
import data from "css-tree/dist/data" ;
10
- import { camelCase } from "change-case" ;
11
- import type {
12
- KeywordValue ,
13
- StyleValue ,
14
- Unit ,
15
- UnitValue ,
16
- UnparsedValue ,
17
- FontFamilyValue ,
10
+ import {
11
+ type KeywordValue ,
12
+ type StyleValue ,
13
+ type Unit ,
14
+ type UnitValue ,
15
+ type UnparsedValue ,
16
+ type FontFamilyValue ,
17
+ hyphenateProperty ,
18
+ type CssProperty ,
18
19
} from "@webstudio-is/css-engine" ;
19
20
import * as customData from "../src/custom-data" ;
20
-
21
- /**
22
- * Store prefixed properties without change
23
- * and convert to camel case only unprefixed properties
24
- * @todo stop converting to camel case and use hyphenated format
25
- */
26
- const normalizePropertyName = ( property : string ) => {
27
- if ( property . startsWith ( "-" ) ) {
28
- return property ;
29
- }
30
- return camelCase ( property ) ;
31
- } ;
21
+ import { camelCaseProperty } from "../src/parse-css" ;
32
22
33
23
const units : Record < string , Array < string > > = {
34
24
number : [ ] ,
@@ -233,7 +223,7 @@ const walkSyntax = (
233
223
walk ( parsed ) ;
234
224
} ;
235
225
236
- type FilteredProperties = { [ property in Property ] : Value } ;
226
+ type FilteredProperties = { [ property : string ] : Value } ;
237
227
238
228
const experimentalProperties = [
239
229
"appearance" ,
@@ -299,7 +289,7 @@ const propertiesData = {
299
289
...customData . propertiesData ,
300
290
} ;
301
291
302
- let property : Property ;
292
+ let property : string ;
303
293
for ( property in filteredProperties ) {
304
294
const config = filteredProperties [ property ] ;
305
295
const unitGroups = new Set < string > ( ) ;
@@ -326,7 +316,7 @@ for (property in filteredProperties) {
326
316
) ;
327
317
}
328
318
329
- propertiesData [ normalizePropertyName ( property ) ] = {
319
+ propertiesData [ camelCaseProperty ( property as CssProperty ) ] = {
330
320
unitGroups : Array . from ( unitGroups ) ,
331
321
inherited : config . inherited ,
332
322
initial : parseInitialValue ( property , config . initial , unitGroups ) ,
@@ -367,7 +357,7 @@ const keywordValues = (() => {
367
357
const result = { ...customData . keywordValues } ;
368
358
369
359
for ( const property in filteredProperties ) {
370
- const key = normalizePropertyName ( property ) ;
360
+ const key = camelCaseProperty ( property as CssProperty ) ;
371
361
// prevent merging with custom keywords
372
362
if ( result [ key ] ) {
373
363
continue ;
@@ -416,10 +406,14 @@ writeToFile("pseudo-elements.ts", "pseudoElements", pseudoElements);
416
406
417
407
let types = "" ;
418
408
419
- const propertyLiterals = Object . keys ( propertiesData ) . map ( ( property ) =>
409
+ const camelCasedProperties = Object . keys ( propertiesData ) . map ( ( property ) =>
420
410
JSON . stringify ( property )
421
411
) ;
422
- types += `export type Property = ${ propertyLiterals . join ( " | " ) } ;\n\n` ;
412
+ types += `export type CamelCasedProperty = ${ camelCasedProperties . join ( " | " ) } ;\n\n` ;
413
+ const hyphenatedProperties = Object . keys ( propertiesData ) . map ( ( property ) =>
414
+ JSON . stringify ( hyphenateProperty ( property ) )
415
+ ) ;
416
+ types += `export type HyphenatedProperty = ${ hyphenatedProperties . join ( " | " ) } ;\n\n` ;
423
417
424
418
const unitLiterals = Object . values ( units )
425
419
. flat ( )
0 commit comments