UNPKG

2.41 kBTypeScriptView Raw
1import { Nested, ParenLess, UnitType, UnitCategory } from './types';
2export declare enum CSSStyleValueType {
3 kUnknownType = 0,
4 kUnparsedType = 1,
5 kKeywordType = 2,
6 kUnitType = 3,
7 kSumType = 4,
8 kProductType = 5,
9 kNegateType = 6,
10 kInvertType = 7,
11 kMinType = 8,
12 kMaxType = 9,
13 kClampType = 10,
14 kTransformType = 11,
15 kPositionType = 12,
16 kURLImageType = 13,
17 kColorType = 14,
18 kUnsupportedColorType = 15
19}
20/**
21 * CSSStyleValue is the base class for all CSS values accessible from Typed OM.
22 * Values that are not yet supported as specific types are also returned as base CSSStyleValues.
23 *
24 * Spec @see https://drafts.css-houdini.org/css-typed-om/#stylevalue-objects
25 * Docs @see https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleValue
26 */
27export declare abstract class CSSStyleValue {
28 static parse(propertyName: string, value: string): CSSStyleValue;
29 static parseAll(propertyName: string, value: string): CSSStyleValue[];
30 static unitFromName(name: string): UnitType;
31 static unitTypeToUnitCategory(type: UnitType): UnitCategory;
32 static unitTypeToString(type: UnitType): "" | "em" | "px" | "deg" | "rad" | "grad" | "ms" | "s" | "rem" | "turn" | "%";
33 static stringToUnitType(name: string): UnitType;
34 static canonicalUnitTypeForCategory(category: UnitCategory): UnitType.kUnknown | UnitType.kNumber | UnitType.kPixels | UnitType.kDegrees | UnitType.kSeconds | UnitType.kHertz | UnitType.kDotsPerPixel;
35 /**
36 * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/css_primitive_value.cc#353
37 */
38 static conversionToCanonicalUnitsScaleFactor(unit_type: UnitType): number;
39 static isAngle(unit: UnitType): boolean;
40 static isViewportPercentageLength(type: UnitType): boolean;
41 static isContainerPercentageLength(type: UnitType): boolean;
42 static isLength(type: UnitType): boolean;
43 static isRelativeUnit(type: UnitType): boolean;
44 static isTime(unit: UnitType): boolean;
45 static isFrequency(unit: UnitType): boolean;
46 static isResolution(type: UnitType): boolean;
47 static isFlex(unit: UnitType): boolean;
48 protected abstract getType(): CSSStyleValueType;
49 abstract buildCSSText(n: Nested, p: ParenLess, result: string): string;
50 abstract clone(): CSSStyleValue;
51 toString(): string;
52 isNumericValue(): boolean;
53}