import type { CSSNumericSumValue, UnitMap } from './CSSNumericSumValue'; import { CSSStyleValue, CSSStyleValueType } from './CSSStyleValue'; import { Nested, ParenLess, UnitType } from './types'; export declare type CSSNumberish = number | CSSNumericValue; declare type CSSNumericBaseType = 'length' | 'angle' | 'time' | 'frequency' | 'resolution' | 'flex' | 'percent'; interface CSSNumericType { length: number; angle: number; time: number; frequency: number; resolution: number; flex: number; percent: number; percentHint: CSSNumericBaseType; } export declare enum BaseType { kLength = 0, kAngle = 1, kTime = 2, kFrequency = 3, kResolution = 4, kFlex = 5, kPercent = 6, kNumBaseTypes = 7 } export declare function unitTypeToBaseType(unit: UnitType): BaseType.kLength | BaseType.kAngle | BaseType.kTime | BaseType.kFrequency | BaseType.kResolution | BaseType.kFlex | BaseType.kPercent; export declare function baseTypeToString(baseType: BaseType): "" | "percent" | "length" | "angle" | "time" | "frequency" | "resolution" | "flex"; export declare class CSSNumericValueType { private exponents; private numNonZeroEntries; percentHint: BaseType; hasPercentHint: boolean; constructor(unit?: UnitType, exponent?: number); applyPercentHint(hint: BaseType): void; hasNonZeroEntries(): boolean; isOnlyNonZeroEntry(baseType: BaseType, value: number): boolean; exponent(type: BaseType): number; setExponent(type: BaseType, newValue: number): void; static negateExponents(type: CSSNumericValueType): CSSNumericValueType; matchesBaseType(baseType: BaseType): boolean; matchesPercentage(): boolean; matchesBaseTypePercentage(baseType: BaseType): boolean; matchesNumber(): boolean; matchesNumberPercentage(): boolean; static add(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType; static multiply(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType; } /** * CSSNumericValue is the base class for numeric and length typed CSS Values. * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl */ export declare abstract class CSSNumericValue extends CSSStyleValue { type_: CSSNumericValueType; /** * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#296 */ static fromNumberish(value: CSSNumberish): CSSNumericValue; static fromPercentish(value: CSSNumberish): CSSNumericValue; constructor(type_: CSSNumericValueType); getType(): CSSStyleValueType; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/equals */ equals(...numberishes: CSSNumberish[]): any; /** * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#439 */ add(...numberishes: CSSNumberish[]): CSSNumericValue; /** * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#452 */ sub(...numberishes: CSSNumberish[]): CSSNumericValue; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/mul */ mul(...numberishes: CSSNumberish[]): CSSNumericValue; /** * eg. calc(24px / 4%) * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/div */ div(...numberishes: CSSNumberish[]): CSSNumericValue; min(...numberishes: CSSNumberish[]): CSSNumericValue; max(...numberishes: CSSNumberish[]): CSSNumericValue; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/to * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#331 */ to(unitOrName: UnitType | string): CSSUnitValue; /** * converts the object's value to a CSSMathSum object to values of the specified unit. * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/toSum */ toSum(...unit_strings: string[]): CSSMathSum; /** * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/type * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#414 */ type(): CSSNumericType; static isValidUnit(unit: UnitType): boolean; abstract sumValue(): CSSNumericSumValue; negate(): CSSNumericValue; invert(): CSSNumericValue; } /** * Represents numeric values that can be expressed as a single number plus a * unit (or a naked number or percentage). * @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue */ export declare class CSSUnitValue extends CSSNumericValue { static toCanonicalUnit(unit: UnitType): UnitType.kUnknown | UnitType.kNumber | UnitType.kPixels | UnitType.kDegrees | UnitType.kSeconds | UnitType.kHertz | UnitType.kDotsPerPixel; static toCanonicalUnitIfPossible(unit: UnitType): UnitType; static formatInfinityOrNaN(number: number, suffix?: string): string; static formatNumber(number: number, suffix?: string): string; unit: UnitType; value: number; constructor(value: number, unitOrName?: UnitType | string); clone(): CSSUnitValue; convertTo(target_unit: UnitType): CSSUnitValue; equals(other: CSSNumericValue): boolean; getType(): CSSStyleValueType; sumValue(): CSSNumericSumValue; negate(): CSSUnitValue; invert(): CSSUnitValue | CSSMathInvert; buildCSSText(n: Nested, p: ParenLess, result: string): string; } /** * The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values. * * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl */ export declare abstract class CSSMathValue extends CSSNumericValue { abstract operator: string; isUnitValue(): boolean; } export declare class CSSMathInvert extends CSSMathValue { private value; static create(value: CSSNumericValue): CSSMathInvert; constructor(value: CSSNumericValue, type: CSSNumericValueType); operator: string; clone(): CSSMathInvert; getType(): CSSStyleValueType; equals(other: CSSNumericValue): any; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } export declare class CSSMathNegate extends CSSMathValue { value: CSSNumericValue; static create(value: CSSNumericValue): CSSMathNegate; constructor(value: CSSNumericValue, type: CSSNumericValueType); operator: string; clone(): CSSMathNegate; getType(): CSSStyleValueType; equals(other: CSSNumericValue): any; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } export declare function typeCheck(values: CSSNumericValue[], op: Function, error: boolean): CSSNumericValueType; export declare abstract class CSSMathVariadic extends CSSMathValue { values: CSSNumericValue[]; constructor(values: CSSNumericValue[], type: CSSNumericValueType); numericValues(): CSSNumericValue[]; equals(other: CSSNumericValue): any; } export declare class CSSMathMin extends CSSMathVariadic { static create(values: CSSNumericValue[]): CSSMathMin; operator: string; clone(): CSSMathMin; getType(): CSSStyleValueType; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } export declare class CSSMathMax extends CSSMathVariadic { static create(values: CSSNumericValue[]): CSSMathMax; operator: string; clone(): CSSMathMax; getType(): CSSStyleValueType; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } /** * Represents the sum of one or more CSSNumericValues. * @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum */ export declare class CSSMathSum extends CSSMathVariadic { static create(values: CSSNumericValue[]): CSSMathSum; static numericTypeFromUnitMap(units: UnitMap): CSSNumericValueType; static canCreateNumericTypeFromSumValue(sum: CSSNumericSumValue): boolean; operator: string; clone(): CSSMathSum; getType(): CSSStyleValueType; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } /** * Represents the product of one or more CSSNumericValues. * @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct */ export declare class CSSMathProduct extends CSSMathVariadic { static create(values: CSSNumericValue[]): CSSMathProduct; static multiplyUnitMaps(a: UnitMap, b: UnitMap): UnitMap; operator: string; clone(): CSSMathProduct; getType(): CSSStyleValueType; sumValue(): CSSNumericSumValue; buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string; } export declare const Opx: CSSUnitValue; export declare const Odeg: CSSUnitValue; export {};