1 | import {List, ValueObject} from 'immutable';
|
2 |
|
3 | import {SassBoolean} from './boolean';
|
4 | import {SassCalculation} from './calculation';
|
5 | import {SassColor} from './color';
|
6 | import {SassFunction} from './function';
|
7 | import {ListSeparator} from './list';
|
8 | import {SassMap} from './map';
|
9 | import {SassMixin} from './mixin';
|
10 | import {SassNumber} from './number';
|
11 | import {SassString} from './string';
|
12 |
|
13 | export {SassArgumentList} from './argument_list';
|
14 | export {SassBoolean, sassTrue, sassFalse} from './boolean';
|
15 | export {
|
16 | SassCalculation,
|
17 | CalculationValue,
|
18 | CalculationOperator,
|
19 | CalculationOperation,
|
20 | CalculationInterpolation,
|
21 | } from './calculation';
|
22 | export {
|
23 | SassColor,
|
24 | ColorSpaceHsl,
|
25 | ChannelNameHsl,
|
26 | ColorSpaceHwb,
|
27 | ChannelNameHwb,
|
28 | ColorSpaceLab,
|
29 | ChannelNameLab,
|
30 | ColorSpaceLch,
|
31 | ChannelNameLch,
|
32 | ColorSpaceRgb,
|
33 | ChannelNameRgb,
|
34 | ColorSpaceXyz,
|
35 | ChannelNameXyz,
|
36 | ChannelName,
|
37 | GamutMapMethod,
|
38 | KnownColorSpace,
|
39 | PolarColorSpace,
|
40 | RectangularColorSpace,
|
41 | HueInterpolationMethod,
|
42 | } from './color';
|
43 | export {SassFunction} from './function';
|
44 | export {SassList, ListSeparator} from './list';
|
45 | export {SassMap} from './map';
|
46 | export {SassMixin} from './mixin';
|
47 | export {SassNumber} from './number';
|
48 | export {SassString} from './string';
|
49 |
|
50 | /**
|
51 | * Sass's [`null` value](https://sass-lang.com/documentation/values/null).
|
52 | *
|
53 | * @category Custom Function
|
54 | */
|
55 | export const sassNull: Value;
|
56 |
|
57 | /**
|
58 | * The abstract base class of Sass's value types.
|
59 | *
|
60 | * This is passed to and returned by {@link CustomFunction}s, which are passed
|
61 | * into the Sass implementation using {@link Options.functions}.
|
62 | *
|
63 | * @category Custom Function
|
64 | */
|
65 | export abstract class Value implements ValueObject {
|
66 | protected constructor();
|
67 |
|
68 | /**
|
69 | * This value as a list.
|
70 | *
|
71 | * All SassScript values can be used as lists. Maps count as lists of pairs,
|
72 | * and all other values count as single-value lists.
|
73 | *
|
74 | * @returns An immutable {from the [`immutable`
List} |
75 | * package](https://immutable-js.com/).
|
76 | */
|
77 | get asList(): List<Value>;
|
78 |
|
79 | /**
|
80 | * Whether this value as a list has brackets.
|
81 | *
|
82 | * All SassScript values can be used as lists. Maps count as lists of pairs,
|
83 | * and all other values count as single-value lists.
|
84 | */
|
85 | get hasBrackets(): boolean;
|
86 |
|
87 | /**
|
88 | * Whether the value counts as `true` in an `@if` statement and other
|
89 | * contexts.
|
90 | */
|
91 | get isTruthy(): boolean;
|
92 |
|
93 | /**
|
94 | * Returns JavaScript's `null` value if this is {@link sassNull}, and returns
|
95 | * `this` otherwise.
|
96 | */
|
97 | get realNull(): null | Value;
|
98 |
|
99 | /**
|
100 | * The separator for this value as a list.
|
101 | *
|
102 | * All SassScript values can be used as lists. Maps count as lists of pairs,
|
103 | * and all other values count as single-value lists.
|
104 | */
|
105 | get separator(): ListSeparator;
|
106 |
|
107 | /**
|
108 | * Converts `sassIndex` into a JavaScript-style index into the list returned
|
109 | * by {@link asList}.
|
110 | *
|
111 | * Sass indexes are one-based, while JavaScript indexes are zero-based. Sass
|
112 | * indexes may also be negative in order to index from the end of the list.
|
113 | *
|
114 | * @param sassIndex - The Sass-style index into this as a list.
|
115 | * @param name - The name of the function argument `sassIndex` came from
|
116 | * (without the `$`) if it came from an argument. Used for error reporting.
|
117 | * @throws `Error` If `sassIndex` isn't a number, if that number isn't an
|
118 | * integer, or if that integer isn't a valid index for {@link asList}.
|
119 | */
|
120 | sassIndexToListIndex(sassIndex: Value, name?: string): number;
|
121 |
|
122 | /**
|
123 | * Returns the value at index `index` in this value as a list, or `undefined`
|
124 | * if `index` isn't valid for this list.
|
125 | *
|
126 | * All SassScript values can be used as lists. Maps count as lists of pairs,
|
127 | * and all other values count as single-value lists.
|
128 | *
|
129 | * This is a shorthand for `this.asList.get(index)`, although it may be more
|
130 | * efficient in some cases.
|
131 | *
|
132 | * **Heads up!** This method uses the same indexing conventions as the
|
133 | * `immutable` package: unlike Sass the index of the first element is 0, but
|
134 | * like Sass negative numbers index from the end of the list.
|
135 | */
|
136 | get(index: number): Value | undefined;
|
137 |
|
138 | /**
|
139 | * Throws if `this` isn't a {@link SassBoolean}.
|
140 | *
|
141 | * **Heads up!** Functions should generally use {@link isTruthy} rather than
|
142 | * requiring a literal boolean.
|
143 | *
|
144 | * @param name - The name of the function argument `this` came from (without
|
145 | * the `$`) if it came from an argument. Used for error reporting.
|
146 | */
|
147 | assertBoolean(name?: string): SassBoolean;
|
148 |
|
149 | /**
|
150 | * Throws if `this` isn't a {@link SassCalculation}.
|
151 | *
|
152 | * @param name - The name of the function argument `this` came from (without
|
153 | * the `$`) if it came from an argument. Used for error reporting.
|
154 | */
|
155 | assertCalculation(name?: string): SassCalculation;
|
156 |
|
157 | /**
|
158 | * Throws if `this` isn't a {@link SassColor}.
|
159 | *
|
160 | * @param name - The name of the function argument `this` came from (without
|
161 | * the `$`) if it came from an argument. Used for error reporting.
|
162 | */
|
163 | assertColor(name?: string): SassColor;
|
164 |
|
165 | /**
|
166 | * Throws if `this` isn't a {@link SassFunction}.
|
167 | *
|
168 | * @param name - The name of the function argument `this` came from (without
|
169 | * the `$`) if it came from an argument. Used for error reporting.
|
170 | */
|
171 | assertFunction(name?: string): SassFunction;
|
172 |
|
173 | /**
|
174 | * Throws if `this` isn't a {@link SassMap}.
|
175 | *
|
176 | * @param name - The name of the function argument `this` came from (without
|
177 | * the `$`) if it came from an argument. Used for error reporting.
|
178 | */
|
179 | assertMap(name?: string): SassMap;
|
180 |
|
181 | /**
|
182 | * Throws if `this` isn't a {@link SassMixin}.
|
183 | *
|
184 | * @param name - The name of the function argument `this` came from (without
|
185 | * the `$`) if it came from an argument. Used for error reporting.
|
186 | */
|
187 | assertMixin(name?: string): SassMixin;
|
188 |
|
189 | /**
|
190 | * Throws if `this` isn't a {@link SassNumber}.
|
191 | *
|
192 | * @param name - The name of the function argument `this` came from (without
|
193 | * the `$`) if it came from an argument. Used for error reporting.
|
194 | */
|
195 | assertNumber(name?: string): SassNumber;
|
196 |
|
197 | /**
|
198 | * Throws if `this` isn't a {@link SassString}.
|
199 | *
|
200 | * @param name - The name of the function argument `this` came from (without
|
201 | * the `$`) if it came from an argument. Used for error reporting.
|
202 | */
|
203 | assertString(name?: string): SassString;
|
204 |
|
205 | /**
|
206 | * Returns `this` as a map if it counts as one (empty lists count as empty
|
207 | * maps) or `null` if it doesn't.
|
208 | */
|
209 | tryMap(): SassMap | null;
|
210 |
|
211 | /** Returns whether `this` represents the same value as `other`. */
|
212 | equals(other: Value): boolean;
|
213 |
|
214 | /** Returns a hash code that can be used to store `this` in a hash map. */
|
215 | hashCode(): number;
|
216 |
|
217 | /** @hidden */
|
218 | toString(): string;
|
219 | }
|