@webstudio-is/css-data 0.90.0 → 0.266.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +17534 -15
- package/lib/types/__generated__/animatable-properties.d.ts +1 -0
- package/lib/types/__generated__/html.d.ts +2 -0
- package/lib/types/__generated__/keyword-values.d.ts +4 -358
- package/lib/types/__generated__/properties.d.ts +10 -3674
- package/lib/types/__generated__/property-value-descriptions.d.ts +7 -5446
- package/lib/types/__generated__/pseudo-classes.d.ts +1 -0
- package/lib/types/__generated__/pseudo-elements.d.ts +1 -0
- package/lib/types/__generated__/pseudo-selector-descriptions.d.ts +2 -0
- package/lib/types/__generated__/shorthand-properties.d.ts +1 -0
- package/lib/types/css-tree.d.ts +772 -0
- package/lib/types/index.d.ts +18 -3680
- package/lib/types/media-condition-simulator.d.ts +7 -0
- package/lib/types/parse-css-value.d.ts +8 -3
- package/lib/types/parse-css.d.ts +75 -6
- package/lib/types/property-parsers/conic-gradient.d.ts +3 -0
- package/lib/types/property-parsers/gradient-utils.d.ts +20 -0
- package/lib/types/property-parsers/grid-template-areas.d.ts +21 -0
- package/lib/types/property-parsers/grid-template-tracks.d.ts +128 -0
- package/lib/types/property-parsers/index.d.ts +6 -2
- package/lib/types/property-parsers/linear-gradient.d.ts +4 -0
- package/lib/types/property-parsers/radial-gradient.d.ts +3 -0
- package/lib/types/property-parsers/types.d.ts +28 -0
- package/lib/types/selector-validation.d.ts +13 -0
- package/lib/types/shorthands.d.ts +2 -0
- package/package.json +29 -33
- package/lib/__generated__/keyword-values.js +0 -5255
- package/lib/__generated__/properties.js +0 -3697
- package/lib/__generated__/property-value-descriptions.js +0 -2740
- package/lib/__generated__/units.js +0 -65
- package/lib/cjs/__generated__/keyword-values.js +0 -5275
- package/lib/cjs/__generated__/properties.js +0 -3717
- package/lib/cjs/__generated__/property-value-descriptions.js +0 -2760
- package/lib/cjs/__generated__/units.js +0 -85
- package/lib/cjs/custom-data.js +0 -64
- package/lib/cjs/html-check.js +0 -25
- package/lib/cjs/html.js +0 -581
- package/lib/cjs/index.js +0 -48
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/parse-css-value.js +0 -152
- package/lib/cjs/parse-css.js +0 -136
- package/lib/cjs/popularity-index.js +0 -4633
- package/lib/cjs/property-parsers/background.js +0 -119
- package/lib/cjs/property-parsers/box-shadow.js +0 -129
- package/lib/cjs/property-parsers/index.js +0 -19
- package/lib/cjs/property-parsers/parsers.js +0 -26
- package/lib/cjs/property-parsers/to-longhand.js +0 -24
- package/lib/cjs/schema.js +0 -135
- package/lib/custom-data.js +0 -44
- package/lib/html-check.js +0 -2
- package/lib/html.js +0 -561
- package/lib/parse-css-value.js +0 -122
- package/lib/parse-css.js +0 -106
- package/lib/popularity-index.js +0 -4613
- package/lib/property-parsers/background.js +0 -89
- package/lib/property-parsers/box-shadow.js +0 -99
- package/lib/property-parsers/index.js +0 -2
- package/lib/property-parsers/parsers.js +0 -6
- package/lib/property-parsers/to-longhand.js +0 -4
- package/lib/schema.js +0 -115
- package/lib/types/custom-data.d.ts +0 -15
- package/lib/types/html-check.d.ts +0 -1
- package/lib/types/html.d.ts +0 -62
- package/lib/types/parse-css-value.test.d.ts +0 -1
- package/lib/types/parse-css.test.d.ts +0 -1
- package/lib/types/popularity-index.d.ts +0 -6
- package/lib/types/property-parsers/background.d.ts +0 -11
- package/lib/types/property-parsers/background.test.d.ts +0 -1
- package/lib/types/property-parsers/box-shadow.d.ts +0 -3
- package/lib/types/property-parsers/box-shadow.test.d.ts +0 -1
- package/lib/types/property-parsers/parsers.d.ts +0 -2
- package/lib/types/property-parsers/to-longhand.d.ts +0 -1
- package/lib/types/schema.d.ts +0 -3243
- package/src/__generated__/keyword-values.ts +0 -5253
- package/src/__generated__/properties.ts +0 -3696
- package/src/__generated__/property-value-descriptions.ts +0 -4008
- package/src/__generated__/units.ts +0 -63
- package/src/custom-data.ts +0 -57
- package/src/html-check.ts +0 -8
- package/src/html.ts +0 -617
- package/src/index.ts +0 -25
- package/src/parse-css-value.test.ts +0 -136
- package/src/parse-css-value.ts +0 -157
- package/src/parse-css.test.ts +0 -101
- package/src/parse-css.ts +0 -137
- package/src/popularity-index.ts +0 -4611
- package/src/property-parsers/README.md +0 -11
- package/src/property-parsers/background.test.ts +0 -184
- package/src/property-parsers/background.ts +0 -147
- package/src/property-parsers/box-shadow.test.ts +0 -294
- package/src/property-parsers/box-shadow.ts +0 -130
- package/src/property-parsers/index.ts +0 -2
- package/src/property-parsers/parsers.ts +0 -5
- package/src/property-parsers/to-longhand.ts +0 -4
- package/src/schema.ts +0 -193
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import { type CssNode, type FunctionNode } from "css-tree";
|
|
2
|
+
import { type ColorValue, type StyleValue, type VarValue, type CssProperty } from "@webstudio-is/css-engine";
|
|
3
|
+
export declare const cssTryParseValue: (input: string) => undefined | CssNode;
|
|
4
|
+
export declare const isValidDeclaration: (property: CssProperty, value: string) => boolean;
|
|
5
|
+
export declare const parseColor: (colorString: string) => undefined | ColorValue;
|
|
6
|
+
export declare const parseCssVar: (node: FunctionNode) => undefined | VarValue;
|
|
7
|
+
export declare const parseCssValue: (property: CssProperty, // Handles only long-hand values.
|
|
8
|
+
input: string, topLevel?: boolean) => StyleValue;
|
package/lib/types/parse-css.d.ts
CHANGED
|
@@ -1,9 +1,78 @@
|
|
|
1
|
-
import { StyleValue,
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { StyleValue, CssProperty, StyleProperty } from "@webstudio-is/css-engine";
|
|
2
|
+
export type ParsedStyleDecl = {
|
|
3
|
+
breakpoint?: string;
|
|
4
|
+
selector: string;
|
|
5
|
+
state?: string;
|
|
6
|
+
property: CssProperty;
|
|
5
7
|
value: StyleValue;
|
|
6
8
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Store prefixed properties without change
|
|
11
|
+
* and convert to camel case only unprefixed properties
|
|
12
|
+
* @todo stop converting to camel case and use hyphenated format
|
|
13
|
+
*/
|
|
14
|
+
export declare const camelCaseProperty: (property: CssProperty | StyleProperty) => StyleProperty;
|
|
15
|
+
export type ParseCssResult = {
|
|
16
|
+
styles: ParsedStyleDecl[];
|
|
17
|
+
errors: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Extract all CSS custom property (--*) declarations from a CSS string,
|
|
21
|
+
* regardless of which selector rule they appear in.
|
|
22
|
+
* Useful when CSS from multiple rules (e.g. Tailwind utility classes) needs
|
|
23
|
+
* to be resolved together as if they apply to the same element.
|
|
24
|
+
*/
|
|
25
|
+
export declare const extractCssCustomProperties: (css: string) => Map<string, string>;
|
|
26
|
+
export declare const parseCss: (css: string, cssVars: Map<string, string>) => ParseCssResult;
|
|
27
|
+
export type ParsedClassSelector = {
|
|
28
|
+
/** Token name: "card" for .card, "card__title" for .card .title */
|
|
29
|
+
tokenName: string;
|
|
30
|
+
/** Target class names (the last segment): ["card"] or ["title"] */
|
|
31
|
+
classNames: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Non-class selector suffixes on the target: attribute selectors, pseudo-classes, pseudo-elements.
|
|
34
|
+
* e.g. ["[disabled]"] for .btn[disabled], [":hover"] for .card:hover
|
|
35
|
+
*/
|
|
36
|
+
states?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Ancestor constraints for nested selectors (e.g., .card .title).
|
|
39
|
+
* Ordered from outermost to innermost ancestor.
|
|
40
|
+
* Each entry's combinator describes the relationship to the next segment.
|
|
41
|
+
*/
|
|
42
|
+
ancestors?: Array<{
|
|
43
|
+
classNames: string[];
|
|
44
|
+
combinator: "descendant" | "child";
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Parse a selector string and determine if it's a class-based selector
|
|
49
|
+
* suitable for token extraction. Uses css-tree to handle the full CSS
|
|
50
|
+
* selector spec.
|
|
51
|
+
*
|
|
52
|
+
* Supports simple selectors, compound selectors, and nested selectors
|
|
53
|
+
* using descendant (" ") and child (">") combinators where ALL segments
|
|
54
|
+
* are class-based.
|
|
55
|
+
*
|
|
56
|
+
* Supported patterns:
|
|
57
|
+
* .card → { tokenName: "card", classNames: ["card"] }
|
|
58
|
+
* .card.active → { tokenName: "card.active", classNames: ["card", "active"] }
|
|
59
|
+
* .btn[disabled] → { tokenName: "btn", ..., states: ["[disabled]"] }
|
|
60
|
+
* .card:hover → { tokenName: "card", ..., states: [":hover"] }
|
|
61
|
+
* .card .title → { tokenName: "card__title", ..., ancestors: [{classNames:["card"], combinator:"descendant"}] }
|
|
62
|
+
* .card > .title → { tokenName: "card__title", ..., ancestors: [{classNames:["card"], combinator:"child"}] }
|
|
63
|
+
* .a .b .c → { tokenName: "a__b__c", ..., ancestors: [{..,"descendant"},{..,"descendant"}] }
|
|
64
|
+
* .card > .title:hover → { tokenName: "card__title", ..., states: [":hover"], ancestors: [...] }
|
|
65
|
+
*
|
|
66
|
+
* Returns undefined for:
|
|
67
|
+
* - Selectors with sibling combinators (+, ~)
|
|
68
|
+
* - Selectors with non-class nodes in ancestor segments (e.g., .card h1, h1 .card)
|
|
69
|
+
* - Pure element/id selectors
|
|
70
|
+
*/
|
|
71
|
+
export declare const parseClassBasedSelector: (selector: string) => ParsedClassSelector | undefined;
|
|
72
|
+
type ParsedBreakpoint = {
|
|
73
|
+
minWidth?: number;
|
|
74
|
+
maxWidth?: number;
|
|
75
|
+
condition?: string;
|
|
76
|
+
};
|
|
77
|
+
export declare const parseMediaQuery: (mediaQuery: string) => undefined | ParsedBreakpoint;
|
|
9
78
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as csstree from "css-tree";
|
|
2
|
+
import { type UnitValue, type VarValue } from "@webstudio-is/css-engine";
|
|
3
|
+
import type { GradientColorValue, GradientStop } from "./types";
|
|
4
|
+
export declare const angleUnitIdentifiers: readonly ["deg", "grad", "rad", "turn"];
|
|
5
|
+
export declare const isAngleUnit: (unit: string) => boolean;
|
|
6
|
+
export declare const isAngleDimension: (node: csstree.CssNode) => node is csstree.Dimension;
|
|
7
|
+
export declare const isAngleLikeFallback: (fallback: VarValue["fallback"]) => boolean;
|
|
8
|
+
export declare const isVarAngle: (value: VarValue) => boolean;
|
|
9
|
+
export declare const mapLengthPercentageOrVar: (node?: csstree.CssNode) => UnitValue | VarValue | undefined;
|
|
10
|
+
export declare const getColor: (node: csstree.CssNode) => GradientColorValue | undefined;
|
|
11
|
+
export declare const isColorStop: (node: csstree.CssNode) => boolean;
|
|
12
|
+
export declare const withoutWhitespaceNodes: (nodes: csstree.CssNode[]) => csstree.CssNode[];
|
|
13
|
+
export declare const parseGradientStopFromParts: (nodes: csstree.CssNode[]) => GradientStop | undefined;
|
|
14
|
+
export declare const parseGradientHintFromParts: (nodes: csstree.CssNode[]) => GradientStop["hint"] | undefined;
|
|
15
|
+
export declare const formatGradientStops: (stops: GradientStop[]) => string;
|
|
16
|
+
export declare const normalizeRepeatingGradient: (gradient: string, repeatingName: string, baseName: string) => {
|
|
17
|
+
normalized: string;
|
|
18
|
+
isRepeating: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const forEachGradientParts: (ast: csstree.CssNode, functionName: string, callback: (parts: csstree.CssNode[]) => void) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type AreaInfo = {
|
|
2
|
+
name: string;
|
|
3
|
+
columnStart: number;
|
|
4
|
+
columnEnd: number;
|
|
5
|
+
rowStart: number;
|
|
6
|
+
rowEnd: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Parse grid-template-areas CSS string into structured area information.
|
|
10
|
+
* Uses css-tree to parse the value into String AST nodes,
|
|
11
|
+
* then extracts cell names from each row string.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* parseGridAreas('"header header" "sidebar main"')
|
|
15
|
+
* // Returns: [
|
|
16
|
+
* // { name: 'header', columnStart: 1, columnEnd: 3, rowStart: 1, rowEnd: 2 },
|
|
17
|
+
* // { name: 'sidebar', columnStart: 1, columnEnd: 2, rowStart: 2, rowEnd: 3 },
|
|
18
|
+
* // { name: 'main', columnStart: 2, columnEnd: 3, rowStart: 2, rowEnd: 3 }
|
|
19
|
+
* // ]
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseGridAreas: (value: string) => AreaInfo[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single grid track.
|
|
3
|
+
* Can be a simple value like "1fr", "100px", "auto"
|
|
4
|
+
* or a complex value like "minmax(100px, 1fr)"
|
|
5
|
+
*/
|
|
6
|
+
export type GridTrack = {
|
|
7
|
+
/** The raw CSS value of the track */
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Parse a grid-template-columns or grid-template-rows value into an array of tracks.
|
|
12
|
+
*
|
|
13
|
+
* Handles:
|
|
14
|
+
* - Simple values: "1fr", "100px", "auto", "min-content", "max-content"
|
|
15
|
+
* - Functions: "minmax(100px, 1fr)", "fit-content(200px)"
|
|
16
|
+
* - Repeat: "repeat(3, 1fr)" -> expands to ["1fr", "1fr", "1fr"]
|
|
17
|
+
* - Line names: "[header] 1fr [content] 2fr" -> ignores line names, returns ["1fr", "2fr"]
|
|
18
|
+
*
|
|
19
|
+
* @param value - The CSS value string for grid-template-columns/rows
|
|
20
|
+
* @returns Array of track values, or empty array if value is "none" or invalid
|
|
21
|
+
*/
|
|
22
|
+
export declare const parseGridTemplateTrackList: (value: string) => GridTrack[];
|
|
23
|
+
/**
|
|
24
|
+
* Serialize an array of tracks back to a CSS value string.
|
|
25
|
+
*
|
|
26
|
+
* @param tracks - Array of track values
|
|
27
|
+
* @returns CSS string like "1fr 100px auto" or "none" if empty
|
|
28
|
+
*/
|
|
29
|
+
export declare const serializeGridTemplateTrackList: (tracks: GridTrack[]) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Represents a minmax() function with min and max values.
|
|
32
|
+
*/
|
|
33
|
+
export type Minmax = {
|
|
34
|
+
min: string;
|
|
35
|
+
max: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Parse a minmax() function value into its min and max parts.
|
|
39
|
+
* Returns undefined if the value is not a valid minmax() function.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* parseMinmax("minmax(100px, 1fr)") // { min: "100px", max: "1fr" }
|
|
43
|
+
* parseMinmax("1fr") // undefined
|
|
44
|
+
*/
|
|
45
|
+
export declare const parseMinmax: (value: string) => Minmax | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Create a minmax() CSS value from min and max parts.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* serializeMinmax({ min: "100px", max: "1fr" }) // "minmax(100px,1fr)"
|
|
51
|
+
*/
|
|
52
|
+
export declare const serializeMinmax: (minmax: Minmax) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Result of checking if a grid template value is supported by the visual editor.
|
|
55
|
+
*/
|
|
56
|
+
export type GridTemplateSupport = {
|
|
57
|
+
supported: true;
|
|
58
|
+
} | {
|
|
59
|
+
supported: false;
|
|
60
|
+
reason: string;
|
|
61
|
+
type: "subgrid" | "masonry" | "line-names" | "auto-fill" | "auto-fit";
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Check if a grid-template-columns or grid-template-rows value can be
|
|
65
|
+
* represented and edited by the visual grid UI.
|
|
66
|
+
*
|
|
67
|
+
* Unsupported values:
|
|
68
|
+
* - `subgrid` - requires dedicated UI
|
|
69
|
+
* - `masonry` - experimental, not a track definition
|
|
70
|
+
* - `repeat(auto-fill, ...)` / `repeat(auto-fit, ...)` - dynamic track count
|
|
71
|
+
* - Line names like `[header]` - would be silently discarded on edit
|
|
72
|
+
*
|
|
73
|
+
* Note: CSS variables are supported - use computedValue which resolves them.
|
|
74
|
+
*
|
|
75
|
+
* @param value - The CSS value string for grid-template-columns/rows
|
|
76
|
+
* @returns Object indicating if supported, with reason and type if not
|
|
77
|
+
*/
|
|
78
|
+
export declare const checkGridTemplateSupport: (value: string) => GridTemplateSupport;
|
|
79
|
+
/**
|
|
80
|
+
* Describes the mode of a grid axis (columns or rows).
|
|
81
|
+
*
|
|
82
|
+
* - "explicit": Regular explicit tracks (e.g., "1fr 2fr 100px")
|
|
83
|
+
* - "auto-fill": Dynamic tracks via repeat(auto-fill, ...)
|
|
84
|
+
* - "auto-fit": Dynamic tracks via repeat(auto-fit, ...)
|
|
85
|
+
* - "auto": Single "auto" keyword - implicit tracks based on children
|
|
86
|
+
* - "none": No explicit tracks defined
|
|
87
|
+
* - "subgrid": Subgrid inherits tracks from parent
|
|
88
|
+
* - "masonry": Experimental masonry layout
|
|
89
|
+
* - "line-names": Has named grid lines like [header]
|
|
90
|
+
*/
|
|
91
|
+
export type GridAxisMode = "explicit" | "auto-fill" | "auto-fit" | "auto" | "none" | "subgrid" | "masonry" | "line-names";
|
|
92
|
+
/**
|
|
93
|
+
* Analyze a grid template value to determine its mode.
|
|
94
|
+
*
|
|
95
|
+
* @param value - The CSS value string for grid-template-columns/rows
|
|
96
|
+
* @returns The axis mode describing the type of grid track definition
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* getGridAxisMode("1fr 2fr 100px") // "explicit"
|
|
100
|
+
* getGridAxisMode("repeat(auto-fill, minmax(200px, 1fr))") // "auto-fill"
|
|
101
|
+
* getGridAxisMode("none") // "none"
|
|
102
|
+
* getGridAxisMode("auto") // "auto"
|
|
103
|
+
* getGridAxisMode("subgrid") // "subgrid"
|
|
104
|
+
*/
|
|
105
|
+
export declare const getGridAxisMode: (value: string) => GridAxisMode;
|
|
106
|
+
/**
|
|
107
|
+
* Check if a grid axis mode represents a dynamic/implicit grid that
|
|
108
|
+
* requires DOM probing to determine actual track count.
|
|
109
|
+
*
|
|
110
|
+
* @param mode - The grid axis mode
|
|
111
|
+
* @returns true if the mode requires DOM-based track counting
|
|
112
|
+
*/
|
|
113
|
+
export declare const isImplicitGridMode: (mode: GridAxisMode) => boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Check if a grid axis mode is editable in the visual grid UI.
|
|
116
|
+
*
|
|
117
|
+
* @param mode - The grid axis mode
|
|
118
|
+
* @returns true if the mode can be edited visually
|
|
119
|
+
*/
|
|
120
|
+
export declare const isEditableGridMode: (mode: GridAxisMode) => boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Get a display label for a grid axis mode (for the grid generator).
|
|
123
|
+
*
|
|
124
|
+
* @param mode - The grid axis mode
|
|
125
|
+
* @param trackCount - The actual track count (for explicit modes)
|
|
126
|
+
* @returns Display string like "3", "auto-fit", "none"
|
|
127
|
+
*/
|
|
128
|
+
export declare const getGridAxisLabel: (mode: GridAxisMode, trackCount: number) => string;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./linear-gradient";
|
|
2
|
+
export * from "./conic-gradient";
|
|
3
|
+
export * from "./radial-gradient";
|
|
4
|
+
export * from "./grid-template-tracks";
|
|
5
|
+
export * from "./grid-template-areas";
|
|
6
|
+
export * from "./types";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { GradientColorValue, GradientStop, ParsedGradient, ParsedLinearGradient, ParsedConicGradient, } from "./types";
|
|
2
|
+
import type { ParsedLinearGradient } from "./types";
|
|
3
|
+
export declare const parseLinearGradient: (gradient: string) => ParsedLinearGradient | undefined;
|
|
4
|
+
export declare const formatLinearGradient: (parsed: ParsedLinearGradient) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ColorValue, type KeywordValue, type RgbValue, type UnitValue, type VarValue } from "@webstudio-is/css-engine";
|
|
2
|
+
export type GradientColorValue = ColorValue | RgbValue | KeywordValue | VarValue;
|
|
3
|
+
export type GradientStop = {
|
|
4
|
+
color?: GradientColorValue;
|
|
5
|
+
position?: UnitValue | VarValue;
|
|
6
|
+
hint?: UnitValue | VarValue;
|
|
7
|
+
};
|
|
8
|
+
export type ParsedGradientBase = {
|
|
9
|
+
stops: GradientStop[];
|
|
10
|
+
repeating?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ParsedLinearGradient = ParsedGradientBase & {
|
|
13
|
+
type: "linear";
|
|
14
|
+
angle?: UnitValue | VarValue;
|
|
15
|
+
sideOrCorner?: KeywordValue;
|
|
16
|
+
};
|
|
17
|
+
export type ParsedConicGradient = ParsedGradientBase & {
|
|
18
|
+
type: "conic";
|
|
19
|
+
angle?: UnitValue | VarValue;
|
|
20
|
+
position?: string;
|
|
21
|
+
};
|
|
22
|
+
export type ParsedRadialGradient = ParsedGradientBase & {
|
|
23
|
+
type: "radial";
|
|
24
|
+
shape?: KeywordValue;
|
|
25
|
+
size?: string;
|
|
26
|
+
position?: string;
|
|
27
|
+
};
|
|
28
|
+
export type ParsedGradient = ParsedLinearGradient | ParsedConicGradient | ParsedRadialGradient;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SelectorValidationResult = {
|
|
2
|
+
success: false;
|
|
3
|
+
error: string;
|
|
4
|
+
} | {
|
|
5
|
+
success: true;
|
|
6
|
+
type: "pseudo-class" | "pseudo-element" | "attribute";
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Validates a CSS pseudo-class, pseudo-element, or attribute selector
|
|
10
|
+
* @param selector - The selector to validate (e.g., ":hover", "::before", "[data-state=open]")
|
|
11
|
+
* @returns SelectorValidationResult with success status and type or error message
|
|
12
|
+
*/
|
|
13
|
+
export declare const validateSelector: (selector: string) => SelectorValidationResult;
|
package/package.json
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.266.0",
|
|
4
4
|
"description": "CSS Data",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"@webstudio-is/jest-config": "^1.0.7",
|
|
19
|
-
"@webstudio-is/scripts": "^0.0.0",
|
|
20
|
-
"@webstudio-is/tsconfig": "^1.0.7"
|
|
9
|
+
"esbuild": "^0.25.3",
|
|
10
|
+
"html-tags": "^4.0.0",
|
|
11
|
+
"mdn-data": "2.28.0",
|
|
12
|
+
"openai": "^3.2.1",
|
|
13
|
+
"p-retry": "^6.2.1",
|
|
14
|
+
"typescript": "5.8.2",
|
|
15
|
+
"vitest": "^3.1.2",
|
|
16
|
+
"zod": "^3.24.2",
|
|
17
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
21
18
|
},
|
|
22
19
|
"peerDependencies": {
|
|
23
20
|
"zod": "^3.19.1"
|
|
24
21
|
},
|
|
25
22
|
"exports": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
".": {
|
|
24
|
+
"webstudio": "./src/index.ts",
|
|
25
|
+
"types": "./lib/types/index.d.ts",
|
|
26
|
+
"import": "./lib/index.js"
|
|
27
|
+
}
|
|
30
28
|
},
|
|
31
29
|
"files": [
|
|
32
30
|
"lib/*",
|
|
33
|
-
"
|
|
34
|
-
"!*.test.*"
|
|
31
|
+
"!*.{test,stories}.*"
|
|
35
32
|
],
|
|
36
33
|
"license": "AGPL-3.0-or-later",
|
|
37
|
-
"private": false,
|
|
38
34
|
"sideEffects": false,
|
|
39
35
|
"dependencies": {
|
|
40
|
-
"
|
|
41
|
-
"css-tree": "^
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"warn-once": "^0.1.1"
|
|
36
|
+
"change-case": "^5.4.4",
|
|
37
|
+
"css-tree": "^3.1.0",
|
|
38
|
+
"warn-once": "^0.1.1",
|
|
39
|
+
"@webstudio-is/css-engine": "0.266.0"
|
|
45
40
|
},
|
|
46
41
|
"scripts": {
|
|
47
|
-
"typecheck": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"build": "
|
|
51
|
-
"build:mdn-data": "tsx ./bin/mdn-data.ts ./src/__generated__ && prettier --write \"./src/__generated__
|
|
52
|
-
"build:descriptions": "tsx ./bin/property-value-descriptions.ts",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
42
|
+
"typecheck": "tsgo --noEmit",
|
|
43
|
+
"build": "rm -rf lib && esbuild src/index.ts --outdir=lib --bundle --format=esm --packages=external",
|
|
44
|
+
"dts": "tsc --project tsconfig.dts.json && node ./scripts/prepare-dts.mjs",
|
|
45
|
+
"build:html.css": "tsx ./bin/html.css.ts && prettier --write ./src/__generated__/html.ts",
|
|
46
|
+
"build:mdn-data": "tsx ./bin/mdn-data.ts ./src/__generated__ && prettier --write \"./src/__generated__/\" \"../css-engine/src/__generated__/\"",
|
|
47
|
+
"build:descriptions": "tsx ./bin/property-value-descriptions.ts && prettier --write ./src/__generated__/property-value-descriptions.ts",
|
|
48
|
+
"build:property-var-fixtures": "tsx ./bin/property-var-test-fixtures.ts && prettier --write ./src/__generated__/property-var-test-fixtures.ts",
|
|
49
|
+
"build:all": "pnpm build:html.css && pnpm build:mdn-data && pnpm build:descriptions && pnpm build:property-var-fixtures",
|
|
50
|
+
"test": "vitest run"
|
|
55
51
|
}
|
|
56
52
|
}
|