tailwindcss 4.0.0-alpha.20 → 4.0.0-alpha.21

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/dist/lib.d.mts CHANGED
@@ -1,3 +1,162 @@
1
+ type Rule = {
2
+ kind: 'rule';
3
+ selector: string;
4
+ nodes: AstNode[];
5
+ };
6
+ type Declaration = {
7
+ kind: 'declaration';
8
+ property: string;
9
+ value: string | undefined;
10
+ important: boolean;
11
+ };
12
+ type Comment = {
13
+ kind: 'comment';
14
+ value: string;
15
+ };
16
+ type AstNode = Rule | Declaration | Comment;
17
+
18
+ declare class Theme {
19
+ #private;
20
+ private values;
21
+ constructor(values?: Map<string, {
22
+ value: string;
23
+ isReference: boolean;
24
+ isInline: boolean;
25
+ }>);
26
+ add(key: string, value: string, { isReference, isInline }?: {
27
+ isReference?: boolean | undefined;
28
+ isInline?: boolean | undefined;
29
+ }): void;
30
+ keysInNamespaces(themeKeys: ThemeKey[]): string[];
31
+ get(themeKeys: (ThemeKey | `${ThemeKey}-${string}`)[]): string | null;
32
+ entries(): IterableIterator<[string, {
33
+ value: string;
34
+ isReference: boolean;
35
+ isInline: boolean;
36
+ }]>;
37
+ resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
38
+ resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
39
+ resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
40
+ namespace(namespace: string): Map<string | null, string>;
41
+ }
42
+ type ThemeKey = '--accent-color' | '--animate' | '--aspect-ratio' | '--backdrop-blur' | '--backdrop-brightness' | '--backdrop-contrast' | '--backdrop-grayscale' | '--backdrop-hue-rotate' | '--backdrop-invert' | '--backdrop-opacity' | '--backdrop-saturate' | '--backdrop-sepia' | '--background-color' | '--background-image' | '--blur' | '--border-color' | '--border-spacing' | '--border-width' | '--box-shadow-color' | '--breakpoint' | '--brightness' | '--caret-color' | '--color' | '--columns' | '--contrast' | '--cursor' | '--default-border-width' | '--default-ring-color' | '--default-ring-width' | '--default-transition-timing-function' | '--default-transition-duration' | '--divide-width' | '--divide-color' | '--drop-shadow' | '--fill' | '--flex-basis' | '--font-family' | '--font-size' | '--font-weight' | '--gap' | '--gradient-color-stop-positions' | '--grayscale' | '--grid-auto-columns' | '--grid-auto-rows' | '--grid-column' | '--grid-column-end' | '--grid-column-start' | '--grid-row' | '--grid-row-end' | '--grid-row-start' | '--grid-template-columns' | '--grid-template-rows' | '--height' | '--hue-rotate' | '--inset' | '--inset-shadow' | '--invert' | '--letter-spacing' | '--line-height' | '--line-clamp' | '--list-style-image' | '--list-style-type' | '--margin' | '--max-height' | '--max-width' | '--min-height' | '--min-width' | '--object-position' | '--opacity' | '--order' | '--outline-color' | '--outline-width' | '--outline-offset' | '--padding' | '--placeholder-color' | '--perspective' | '--perspective-origin' | '--radius' | '--ring-color' | '--ring-offset-color' | '--ring-offset-width' | '--ring-width' | '--rotate' | '--saturate' | '--scale' | '--scroll-margin' | '--scroll-padding' | '--sepia' | '--shadow' | '--size' | '--skew' | '--space' | '--spacing' | '--stroke' | '--stroke-width' | '--text-color' | '--text-decoration-color' | '--text-decoration-thickness' | '--text-indent' | '--text-underline-offset' | '--transform-origin' | '--transition-delay' | '--transition-duration' | '--transition-property' | '--transition-timing-function' | '--translate' | '--width' | '--z-index' | `--default-${string}`;
43
+
44
+ type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
45
+ kind: T;
46
+ }>) => null | void;
47
+ type CompareFn = (a: Variant, z: Variant) => number;
48
+ declare class Variants {
49
+ private compareFns;
50
+ private variants;
51
+ private completions;
52
+ /**
53
+ * Registering a group of variants should result in the same sort number for
54
+ * all the variants. This is to ensure that the variants are applied in the
55
+ * correct order.
56
+ */
57
+ private groupOrder;
58
+ /**
59
+ * Keep track of the last sort order instead of using the size of the map to
60
+ * avoid unnecessarily skipping order numbers.
61
+ */
62
+ private lastOrder;
63
+ static(name: string, applyFn: VariantFn<'static'>, { compounds }?: {
64
+ compounds?: boolean;
65
+ }): void;
66
+ fromAst(name: string, ast: AstNode[]): void;
67
+ functional(name: string, applyFn: VariantFn<'functional'>, { compounds }?: {
68
+ compounds?: boolean;
69
+ }): void;
70
+ compound(name: string, applyFn: VariantFn<'compound'>, { compounds }?: {
71
+ compounds?: boolean;
72
+ }): void;
73
+ group(fn: () => void, compareFn?: CompareFn): void;
74
+ has(name: string): boolean;
75
+ get(name: string): {
76
+ kind: Variant["kind"];
77
+ order: number;
78
+ applyFn: VariantFn<any>;
79
+ compounds: boolean;
80
+ } | undefined;
81
+ kind(name: string): "static" | "arbitrary" | "functional" | "compound";
82
+ compounds(name: string): boolean;
83
+ suggest(name: string, suggestions: () => string[]): void;
84
+ getCompletions(name: string): string[];
85
+ compare(a: Variant | null, z: Variant | null): number;
86
+ keys(): IterableIterator<string>;
87
+ entries(): IterableIterator<[string, {
88
+ kind: Variant["kind"];
89
+ order: number;
90
+ applyFn: VariantFn<any>;
91
+ compounds: boolean;
92
+ }]>;
93
+ private set;
94
+ private nextOrder;
95
+ }
96
+
97
+ declare function compileAstNodes(candidate: Candidate, designSystem: DesignSystem): {
98
+ node: AstNode;
99
+ propertySort: number[];
100
+ }[];
101
+
102
+ interface ClassMetadata {
103
+ modifiers: string[];
104
+ }
105
+ type ClassEntry = [string, ClassMetadata];
106
+ interface SelectorOptions {
107
+ modifier?: string;
108
+ value?: string;
109
+ }
110
+ interface VariantEntry {
111
+ name: string;
112
+ isArbitrary: boolean;
113
+ values: string[];
114
+ hasDash: boolean;
115
+ selectors: (options: SelectorOptions) => string[];
116
+ }
117
+
118
+ type CompileFn<T extends Candidate['kind']> = (value: Extract<Candidate, {
119
+ kind: T;
120
+ }>) => AstNode[] | undefined | null;
121
+ interface SuggestionGroup {
122
+ supportsNegative?: boolean;
123
+ values: (string | null)[];
124
+ modifiers: string[];
125
+ }
126
+ type UtilityOptions = {
127
+ types: string[];
128
+ };
129
+ type Utility = {
130
+ kind: 'static' | 'functional';
131
+ compileFn: CompileFn<any>;
132
+ options?: UtilityOptions;
133
+ };
134
+ declare class Utilities {
135
+ private utilities;
136
+ private completions;
137
+ static(name: string, compileFn: CompileFn<'static'>): void;
138
+ functional(name: string, compileFn: CompileFn<'functional'>, options?: UtilityOptions): void;
139
+ has(name: string, kind: 'static' | 'functional'): boolean;
140
+ get(name: string): Utility[];
141
+ getCompletions(name: string): SuggestionGroup[];
142
+ suggest(name: string, groups: () => SuggestionGroup[]): void;
143
+ keys(kind: 'static' | 'functional'): string[];
144
+ }
145
+
146
+ type DesignSystem = {
147
+ theme: Theme;
148
+ utilities: Utilities;
149
+ variants: Variants;
150
+ candidatesToCss(classes: string[]): (string | null)[];
151
+ getClassOrder(classes: string[]): [string, bigint | null][];
152
+ getClassList(): ClassEntry[];
153
+ getVariants(): VariantEntry[];
154
+ parseCandidate(candidate: string): Candidate[];
155
+ parseVariant(variant: string): ReturnType<typeof parseVariant>;
156
+ compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
157
+ getUsedVariants(): ReturnType<typeof parseVariant>[];
158
+ };
159
+
1
160
  type ArbitraryUtilityValue = {
2
161
  kind: 'arbitrary';
3
162
  /**
@@ -178,178 +337,10 @@ type Candidate =
178
337
  };
179
338
  declare function parseVariant(variant: string, designSystem: DesignSystem): Variant | null;
180
339
 
181
- type Rule = {
182
- kind: 'rule';
183
- selector: string;
184
- nodes: AstNode[];
185
- };
186
- type Declaration = {
187
- kind: 'declaration';
188
- property: string;
189
- value: string | undefined;
190
- important: boolean;
191
- };
192
- type Comment = {
193
- kind: 'comment';
194
- value: string;
195
- };
196
- type AstNode = Rule | Declaration | Comment;
197
-
198
- declare class Theme {
199
- #private;
200
- private values;
201
- constructor(values?: Map<string, {
202
- value: string;
203
- isReference: boolean;
204
- isInline: boolean;
205
- }>);
206
- add(key: string, value: string, { isReference, isInline }?: {
207
- isReference?: boolean | undefined;
208
- isInline?: boolean | undefined;
209
- }): void;
210
- keysInNamespaces(themeKeys: ThemeKey[]): string[];
211
- get(themeKeys: (ThemeKey | `${ThemeKey}-${string}`)[]): string | null;
212
- entries(): IterableIterator<[string, {
213
- value: string;
214
- isReference: boolean;
215
- isInline: boolean;
216
- }]>;
217
- resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
218
- resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
219
- resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
220
- namespace(namespace: string): Map<string | null, string>;
221
- }
222
- type ThemeKey = '--accent-color' | '--animate' | '--aspect-ratio' | '--backdrop-blur' | '--backdrop-brightness' | '--backdrop-contrast' | '--backdrop-grayscale' | '--backdrop-hue-rotate' | '--backdrop-invert' | '--backdrop-opacity' | '--backdrop-saturate' | '--backdrop-sepia' | '--background-color' | '--background-image' | '--blur' | '--border-color' | '--border-spacing' | '--border-width' | '--box-shadow-color' | '--breakpoint' | '--brightness' | '--caret-color' | '--color' | '--columns' | '--contrast' | '--cursor' | '--default-border-width' | '--default-ring-color' | '--default-ring-width' | '--default-transition-timing-function' | '--default-transition-duration' | '--divide-width' | '--divide-color' | '--drop-shadow' | '--fill' | '--flex-basis' | '--font-family' | '--font-size' | '--font-weight' | '--gap' | '--gradient-color-stop-positions' | '--grayscale' | '--grid-auto-columns' | '--grid-auto-rows' | '--grid-column' | '--grid-column-end' | '--grid-column-start' | '--grid-row' | '--grid-row-end' | '--grid-row-start' | '--grid-template-columns' | '--grid-template-rows' | '--height' | '--hue-rotate' | '--inset' | '--inset-shadow' | '--invert' | '--letter-spacing' | '--line-height' | '--line-clamp' | '--list-style-image' | '--list-style-type' | '--margin' | '--max-height' | '--max-width' | '--min-height' | '--min-width' | '--object-position' | '--opacity' | '--order' | '--outline-color' | '--outline-width' | '--outline-offset' | '--padding' | '--placeholder-color' | '--perspective' | '--perspective-origin' | '--radius' | '--ring-color' | '--ring-offset-color' | '--ring-offset-width' | '--ring-width' | '--rotate' | '--saturate' | '--scale' | '--scroll-margin' | '--scroll-padding' | '--sepia' | '--shadow' | '--size' | '--skew' | '--space' | '--spacing' | '--stroke' | '--stroke-width' | '--text-color' | '--text-decoration-color' | '--text-decoration-thickness' | '--text-indent' | '--text-underline-offset' | '--transform-origin' | '--transition-delay' | '--transition-duration' | '--transition-property' | '--transition-timing-function' | '--translate' | '--width' | '--z-index' | `--default-${string}`;
223
-
224
- type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
225
- kind: T;
226
- }>) => null | void;
227
- type CompareFn = (a: Variant, z: Variant) => number;
228
- declare class Variants {
229
- private compareFns;
230
- private variants;
231
- private completions;
232
- /**
233
- * Registering a group of variants should result in the same sort number for
234
- * all the variants. This is to ensure that the variants are applied in the
235
- * correct order.
236
- */
237
- private groupOrder;
238
- /**
239
- * Keep track of the last sort order instead of using the size of the map to
240
- * avoid unnecessarily skipping order numbers.
241
- */
242
- private lastOrder;
243
- static(name: string, applyFn: VariantFn<'static'>, { compounds }?: {
244
- compounds?: boolean;
245
- }): void;
246
- fromAst(name: string, ast: AstNode[]): void;
247
- functional(name: string, applyFn: VariantFn<'functional'>, { compounds }?: {
248
- compounds?: boolean;
249
- }): void;
250
- compound(name: string, applyFn: VariantFn<'compound'>, { compounds }?: {
251
- compounds?: boolean;
252
- }): void;
253
- group(fn: () => void, compareFn?: CompareFn): void;
254
- has(name: string): boolean;
255
- get(name: string): {
256
- kind: Variant["kind"];
257
- order: number;
258
- applyFn: VariantFn<any>;
259
- compounds: boolean;
260
- } | undefined;
261
- kind(name: string): "static" | "arbitrary" | "functional" | "compound";
262
- compounds(name: string): boolean;
263
- suggest(name: string, suggestions: () => string[]): void;
264
- getCompletions(name: string): string[];
265
- compare(a: Variant | null, z: Variant | null): number;
266
- keys(): IterableIterator<string>;
267
- entries(): IterableIterator<[string, {
268
- kind: Variant["kind"];
269
- order: number;
270
- applyFn: VariantFn<any>;
271
- compounds: boolean;
272
- }]>;
273
- private set;
274
- private nextOrder;
275
- }
276
-
277
- declare function compileAstNodes(candidate: Candidate, designSystem: DesignSystem): {
278
- node: AstNode;
279
- propertySort: number[];
280
- }[];
281
-
282
- interface ClassMetadata {
283
- modifiers: string[];
284
- }
285
- type ClassEntry = [string, ClassMetadata];
286
- interface SelectorOptions {
287
- modifier?: string;
288
- value?: string;
289
- }
290
- interface VariantEntry {
291
- name: string;
292
- isArbitrary: boolean;
293
- values: string[];
294
- hasDash: boolean;
295
- selectors: (options: SelectorOptions) => string[];
296
- }
297
-
298
- type CompileFn<T extends Candidate['kind']> = (value: Extract<Candidate, {
299
- kind: T;
300
- }>) => AstNode[] | undefined | null;
301
- interface SuggestionGroup {
302
- supportsNegative?: boolean;
303
- values: (string | null)[];
304
- modifiers: string[];
305
- }
306
- type UtilityOptions = {
307
- types: string[];
308
- };
309
- type Utility = {
310
- kind: 'static' | 'functional';
311
- compileFn: CompileFn<any>;
312
- options?: UtilityOptions;
313
- };
314
- declare class Utilities {
315
- private utilities;
316
- private completions;
317
- static(name: string, compileFn: CompileFn<'static'>): void;
318
- functional(name: string, compileFn: CompileFn<'functional'>, options?: UtilityOptions): void;
319
- has(name: string, kind: 'static' | 'functional'): boolean;
320
- get(name: string): Utility[];
321
- getCompletions(name: string): SuggestionGroup[];
322
- suggest(name: string, groups: () => SuggestionGroup[]): void;
323
- keys(kind: 'static' | 'functional'): string[];
324
- }
325
-
326
- type DesignSystem = {
327
- theme: Theme;
328
- utilities: Utilities;
329
- variants: Variants;
330
- candidatesToCss(classes: string[]): (string | null)[];
331
- getClassOrder(classes: string[]): [string, bigint | null][];
332
- getClassList(): ClassEntry[];
333
- getVariants(): VariantEntry[];
334
- parseCandidate(candidate: string): Candidate[];
335
- parseVariant(variant: string): ReturnType<typeof parseVariant>;
336
- compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
337
- getUsedVariants(): ReturnType<typeof parseVariant>[];
338
- };
339
-
340
340
  interface PluginUtils {
341
341
  theme(keypath: string, defaultValue?: any): any;
342
342
  }
343
343
 
344
- type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
345
- interface UserConfig {
346
- theme?: ThemeConfig;
347
- }
348
- type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
349
- type ThemeConfig = Record<string, ThemeValue> & {
350
- extend?: Record<string, ThemeValue>;
351
- };
352
-
353
344
  type PluginFn = (api: PluginAPI) => void;
354
345
  type PluginWithConfig = {
355
346
  handler: PluginFn;
@@ -386,14 +377,40 @@ type PluginAPI = {
386
377
  modifiers: 'any' | Record<string, string>;
387
378
  }>): void;
388
379
  theme(path: string, defaultValue?: any): any;
380
+ config(path: string, defaultValue?: any): any;
389
381
  prefix(className: string): string;
390
382
  };
391
383
  type CssInJs = {
392
- [key: string]: string | CssInJs | CssInJs[];
384
+ [key: string]: string | string[] | CssInJs | CssInJs[];
393
385
  };
394
386
 
387
+ type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
388
+ type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
389
+ type ThemeConfig = Record<string, ThemeValue> & {
390
+ extend?: Record<string, ThemeValue>;
391
+ };
392
+ type ContentFile = string | {
393
+ raw: string;
394
+ extension?: string;
395
+ };
396
+ type DarkModeStrategy = false | 'media' | 'class' | ['class', string] | 'selector' | ['selector', string] | ['variant', string | string[]];
397
+ interface UserConfig {
398
+ presets?: UserConfig[];
399
+ theme?: ThemeConfig;
400
+ plugins?: Plugin[];
401
+ }
402
+ interface UserConfig {
403
+ content?: ContentFile[] | {
404
+ files: ContentFile[];
405
+ };
406
+ }
407
+ interface UserConfig {
408
+ darkMode?: DarkModeStrategy;
409
+ }
410
+
395
411
  type CompileOptions = {
396
412
  loadPlugin?: (path: string) => Promise<Plugin>;
413
+ loadConfig?: (path: string) => Promise<UserConfig>;
397
414
  };
398
415
  declare function compile(css: string, opts?: CompileOptions): Promise<{
399
416
  globs: string[];