1 | import type { CSSNumericSumValue, UnitMap } from './CSSNumericSumValue';
|
2 | import { CSSStyleValue, CSSStyleValueType } from './CSSStyleValue';
|
3 | import { Nested, ParenLess, UnitType } from './types';
|
4 | export declare type CSSNumberish = number | CSSNumericValue;
|
5 | declare type CSSNumericBaseType = 'length' | 'angle' | 'time' | 'frequency' | 'resolution' | 'flex' | 'percent';
|
6 | interface CSSNumericType {
|
7 | length: number;
|
8 | angle: number;
|
9 | time: number;
|
10 | frequency: number;
|
11 | resolution: number;
|
12 | flex: number;
|
13 | percent: number;
|
14 | percentHint: CSSNumericBaseType;
|
15 | }
|
16 | export declare enum BaseType {
|
17 | kLength = 0,
|
18 | kAngle = 1,
|
19 | kTime = 2,
|
20 | kFrequency = 3,
|
21 | kResolution = 4,
|
22 | kFlex = 5,
|
23 | kPercent = 6,
|
24 | kNumBaseTypes = 7
|
25 | }
|
26 | export declare function unitTypeToBaseType(unit: UnitType): BaseType.kLength | BaseType.kAngle | BaseType.kTime | BaseType.kFrequency | BaseType.kResolution | BaseType.kFlex | BaseType.kPercent;
|
27 | export declare function baseTypeToString(baseType: BaseType): "" | "percent" | "length" | "angle" | "time" | "frequency" | "resolution" | "flex";
|
28 | export declare class CSSNumericValueType {
|
29 | private exponents;
|
30 | private numNonZeroEntries;
|
31 | percentHint: BaseType;
|
32 | hasPercentHint: boolean;
|
33 | constructor(unit?: UnitType, exponent?: number);
|
34 | applyPercentHint(hint: BaseType): void;
|
35 | hasNonZeroEntries(): boolean;
|
36 | isOnlyNonZeroEntry(baseType: BaseType, value: number): boolean;
|
37 | exponent(type: BaseType): number;
|
38 | setExponent(type: BaseType, newValue: number): void;
|
39 | static negateExponents(type: CSSNumericValueType): CSSNumericValueType;
|
40 | matchesBaseType(baseType: BaseType): boolean;
|
41 | matchesPercentage(): boolean;
|
42 | matchesBaseTypePercentage(baseType: BaseType): boolean;
|
43 | matchesNumber(): boolean;
|
44 | matchesNumberPercentage(): boolean;
|
45 | static add(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
46 | static multiply(type1: CSSNumericValueType, type2: CSSNumericValueType, error: boolean): CSSNumericValueType;
|
47 | }
|
48 | /**
|
49 | * CSSNumericValue is the base class for numeric and length typed CSS Values.
|
50 | * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
|
51 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
|
52 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
|
53 | */
|
54 | export declare abstract class CSSNumericValue extends CSSStyleValue {
|
55 | type_: CSSNumericValueType;
|
56 | |
57 |
|
58 |
|
59 | static fromNumberish(value: CSSNumberish): CSSNumericValue;
|
60 | static fromPercentish(value: CSSNumberish): CSSNumericValue;
|
61 | constructor(type_: CSSNumericValueType);
|
62 | getType(): CSSStyleValueType;
|
63 | /**
|
64 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/equals
|
65 | */
|
66 | equals(...numberishes: CSSNumberish[]): any;
|
67 | /**
|
68 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#439
|
69 | */
|
70 | add(...numberishes: CSSNumberish[]): CSSNumericValue;
|
71 | /**
|
72 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#452
|
73 | */
|
74 | sub(...numberishes: CSSNumberish[]): CSSNumericValue;
|
75 | /**
|
76 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/mul
|
77 | */
|
78 | mul(...numberishes: CSSNumberish[]): CSSNumericValue;
|
79 | /**
|
80 | * eg. calc(24px / 4%)
|
81 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/div
|
82 | */
|
83 | div(...numberishes: CSSNumberish[]): CSSNumericValue;
|
84 | min(...numberishes: CSSNumberish[]): CSSNumericValue;
|
85 | max(...numberishes: CSSNumberish[]): CSSNumericValue;
|
86 | /**
|
87 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/to
|
88 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#331
|
89 | */
|
90 | to(unitOrName: UnitType | string): CSSUnitValue;
|
91 | /**
|
92 | * converts the object's value to a CSSMathSum object to values of the specified unit.
|
93 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/toSum
|
94 | */
|
95 | toSum(...unit_strings: string[]): CSSMathSum;
|
96 | /**
|
97 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/type
|
98 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#414
|
99 | */
|
100 | type(): CSSNumericType;
|
101 | static isValidUnit(unit: UnitType): boolean;
|
102 | abstract sumValue(): CSSNumericSumValue;
|
103 | negate(): CSSNumericValue;
|
104 | invert(): CSSNumericValue;
|
105 | }
|
106 | /**
|
107 | * Represents numeric values that can be expressed as a single number plus a
|
108 | * unit (or a naked number or percentage).
|
109 | * @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
110 | */
|
111 | export declare class CSSUnitValue extends CSSNumericValue {
|
112 | static toCanonicalUnit(unit: UnitType): UnitType.kUnknown | UnitType.kNumber | UnitType.kPixels | UnitType.kDegrees | UnitType.kSeconds | UnitType.kHertz | UnitType.kDotsPerPixel;
|
113 | static toCanonicalUnitIfPossible(unit: UnitType): UnitType;
|
114 | static formatInfinityOrNaN(number: number, suffix?: string): string;
|
115 | static formatNumber(number: number, suffix?: string): string;
|
116 | unit: UnitType;
|
117 | value: number;
|
118 | constructor(value: number, unitOrName?: UnitType | string);
|
119 | clone(): CSSUnitValue;
|
120 | convertTo(target_unit: UnitType): CSSUnitValue;
|
121 | equals(other: CSSNumericValue): boolean;
|
122 | getType(): CSSStyleValueType;
|
123 | sumValue(): CSSNumericSumValue;
|
124 | negate(): CSSUnitValue;
|
125 | invert(): CSSUnitValue | CSSMathInvert;
|
126 | buildCSSText(n: Nested, p: ParenLess, result: string): string;
|
127 | }
|
128 | /**
|
129 | * The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
130 | *
|
131 | * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
132 | * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
133 | */
|
134 | export declare abstract class CSSMathValue extends CSSNumericValue {
|
135 | abstract operator: string;
|
136 | isUnitValue(): boolean;
|
137 | }
|
138 | export declare class CSSMathInvert extends CSSMathValue {
|
139 | private value;
|
140 | static create(value: CSSNumericValue): CSSMathInvert;
|
141 | constructor(value: CSSNumericValue, type: CSSNumericValueType);
|
142 | operator: string;
|
143 | clone(): CSSMathInvert;
|
144 | getType(): CSSStyleValueType;
|
145 | equals(other: CSSNumericValue): any;
|
146 | sumValue(): CSSNumericSumValue;
|
147 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
148 | }
|
149 | export declare class CSSMathNegate extends CSSMathValue {
|
150 | value: CSSNumericValue;
|
151 | static create(value: CSSNumericValue): CSSMathNegate;
|
152 | constructor(value: CSSNumericValue, type: CSSNumericValueType);
|
153 | operator: string;
|
154 | clone(): CSSMathNegate;
|
155 | getType(): CSSStyleValueType;
|
156 | equals(other: CSSNumericValue): any;
|
157 | sumValue(): CSSNumericSumValue;
|
158 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
159 | }
|
160 | export declare function typeCheck(values: CSSNumericValue[], op: Function, error: boolean): CSSNumericValueType;
|
161 | export declare abstract class CSSMathVariadic extends CSSMathValue {
|
162 | values: CSSNumericValue[];
|
163 | constructor(values: CSSNumericValue[], type: CSSNumericValueType);
|
164 | numericValues(): CSSNumericValue[];
|
165 | equals(other: CSSNumericValue): any;
|
166 | }
|
167 | export declare class CSSMathMin extends CSSMathVariadic {
|
168 | static create(values: CSSNumericValue[]): CSSMathMin;
|
169 | operator: string;
|
170 | clone(): CSSMathMin;
|
171 | getType(): CSSStyleValueType;
|
172 | sumValue(): CSSNumericSumValue;
|
173 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
174 | }
|
175 | export declare class CSSMathMax extends CSSMathVariadic {
|
176 | static create(values: CSSNumericValue[]): CSSMathMax;
|
177 | operator: string;
|
178 | clone(): CSSMathMax;
|
179 | getType(): CSSStyleValueType;
|
180 | sumValue(): CSSNumericSumValue;
|
181 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | export declare class CSSMathSum extends CSSMathVariadic {
|
188 | static create(values: CSSNumericValue[]): CSSMathSum;
|
189 | static numericTypeFromUnitMap(units: UnitMap): CSSNumericValueType;
|
190 | static canCreateNumericTypeFromSumValue(sum: CSSNumericSumValue): boolean;
|
191 | operator: string;
|
192 | clone(): CSSMathSum;
|
193 | getType(): CSSStyleValueType;
|
194 | sumValue(): CSSNumericSumValue;
|
195 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
196 | }
|
197 |
|
198 |
|
199 |
|
200 |
|
201 | export declare class CSSMathProduct extends CSSMathVariadic {
|
202 | static create(values: CSSNumericValue[]): CSSMathProduct;
|
203 | static multiplyUnitMaps(a: UnitMap, b: UnitMap): UnitMap;
|
204 | operator: string;
|
205 | clone(): CSSMathProduct;
|
206 | getType(): CSSStyleValueType;
|
207 | sumValue(): CSSNumericSumValue;
|
208 | buildCSSText(nested: Nested, paren_less: ParenLess, result: string): string;
|
209 | }
|
210 | export declare const Opx: CSSUnitValue;
|
211 | export declare const Odeg: CSSUnitValue;
|
212 | export {};
|