tailwindcss 4.0.0-alpha.20 → 4.0.0-alpha.22

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,166 @@
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
+ isDefault: boolean;
26
+ }>);
27
+ add(key: string, value: string, { isReference, isInline, isDefault }?: {
28
+ isReference?: boolean | undefined;
29
+ isInline?: boolean | undefined;
30
+ isDefault?: boolean | undefined;
31
+ }): void;
32
+ keysInNamespaces(themeKeys: ThemeKey[]): string[];
33
+ get(themeKeys: (ThemeKey | `${ThemeKey}-${string}`)[]): string | null;
34
+ hasDefault(key: string): boolean;
35
+ entries(): IterableIterator<[string, {
36
+ value: string;
37
+ isReference: boolean;
38
+ isInline: boolean;
39
+ isDefault: boolean;
40
+ }]>;
41
+ resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
42
+ resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
43
+ resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
44
+ namespace(namespace: string): Map<string | null, string>;
45
+ }
46
+ 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}`;
47
+
48
+ type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
49
+ kind: T;
50
+ }>) => null | void;
51
+ type CompareFn = (a: Variant, z: Variant) => number;
52
+ declare class Variants {
53
+ private compareFns;
54
+ private variants;
55
+ private completions;
56
+ /**
57
+ * Registering a group of variants should result in the same sort number for
58
+ * all the variants. This is to ensure that the variants are applied in the
59
+ * correct order.
60
+ */
61
+ private groupOrder;
62
+ /**
63
+ * Keep track of the last sort order instead of using the size of the map to
64
+ * avoid unnecessarily skipping order numbers.
65
+ */
66
+ private lastOrder;
67
+ static(name: string, applyFn: VariantFn<'static'>, { compounds }?: {
68
+ compounds?: boolean;
69
+ }): void;
70
+ fromAst(name: string, ast: AstNode[]): void;
71
+ functional(name: string, applyFn: VariantFn<'functional'>, { compounds }?: {
72
+ compounds?: boolean;
73
+ }): void;
74
+ compound(name: string, applyFn: VariantFn<'compound'>, { compounds }?: {
75
+ compounds?: boolean;
76
+ }): void;
77
+ group(fn: () => void, compareFn?: CompareFn): void;
78
+ has(name: string): boolean;
79
+ get(name: string): {
80
+ kind: Variant["kind"];
81
+ order: number;
82
+ applyFn: VariantFn<any>;
83
+ compounds: boolean;
84
+ } | undefined;
85
+ kind(name: string): "static" | "arbitrary" | "functional" | "compound";
86
+ compounds(name: string): boolean;
87
+ suggest(name: string, suggestions: () => string[]): void;
88
+ getCompletions(name: string): string[];
89
+ compare(a: Variant | null, z: Variant | null): number;
90
+ keys(): IterableIterator<string>;
91
+ entries(): IterableIterator<[string, {
92
+ kind: Variant["kind"];
93
+ order: number;
94
+ applyFn: VariantFn<any>;
95
+ compounds: boolean;
96
+ }]>;
97
+ private set;
98
+ private nextOrder;
99
+ }
100
+
101
+ declare function compileAstNodes(candidate: Candidate, designSystem: DesignSystem): {
102
+ node: AstNode;
103
+ propertySort: number[];
104
+ }[];
105
+
106
+ interface ClassMetadata {
107
+ modifiers: string[];
108
+ }
109
+ type ClassEntry = [string, ClassMetadata];
110
+ interface SelectorOptions {
111
+ modifier?: string;
112
+ value?: string;
113
+ }
114
+ interface VariantEntry {
115
+ name: string;
116
+ isArbitrary: boolean;
117
+ values: string[];
118
+ hasDash: boolean;
119
+ selectors: (options: SelectorOptions) => string[];
120
+ }
121
+
122
+ type CompileFn<T extends Candidate['kind']> = (value: Extract<Candidate, {
123
+ kind: T;
124
+ }>) => AstNode[] | undefined | null;
125
+ interface SuggestionGroup {
126
+ supportsNegative?: boolean;
127
+ values: (string | null)[];
128
+ modifiers: string[];
129
+ }
130
+ type UtilityOptions = {
131
+ types: string[];
132
+ };
133
+ type Utility = {
134
+ kind: 'static' | 'functional';
135
+ compileFn: CompileFn<any>;
136
+ options?: UtilityOptions;
137
+ };
138
+ declare class Utilities {
139
+ private utilities;
140
+ private completions;
141
+ static(name: string, compileFn: CompileFn<'static'>): void;
142
+ functional(name: string, compileFn: CompileFn<'functional'>, options?: UtilityOptions): void;
143
+ has(name: string, kind: 'static' | 'functional'): boolean;
144
+ get(name: string): Utility[];
145
+ getCompletions(name: string): SuggestionGroup[];
146
+ suggest(name: string, groups: () => SuggestionGroup[]): void;
147
+ keys(kind: 'static' | 'functional'): string[];
148
+ }
149
+
150
+ type DesignSystem = {
151
+ theme: Theme;
152
+ utilities: Utilities;
153
+ variants: Variants;
154
+ candidatesToCss(classes: string[]): (string | null)[];
155
+ getClassOrder(classes: string[]): [string, bigint | null][];
156
+ getClassList(): ClassEntry[];
157
+ getVariants(): VariantEntry[];
158
+ parseCandidate(candidate: string): Candidate[];
159
+ parseVariant(variant: string): ReturnType<typeof parseVariant>;
160
+ compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
161
+ getUsedVariants(): ReturnType<typeof parseVariant>[];
162
+ };
163
+
1
164
  type ArbitraryUtilityValue = {
2
165
  kind: 'arbitrary';
3
166
  /**
@@ -178,178 +341,10 @@ type Candidate =
178
341
  };
179
342
  declare function parseVariant(variant: string, designSystem: DesignSystem): Variant | null;
180
343
 
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
344
  interface PluginUtils {
341
345
  theme(keypath: string, defaultValue?: any): any;
342
346
  }
343
347
 
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
348
  type PluginFn = (api: PluginAPI) => void;
354
349
  type PluginWithConfig = {
355
350
  handler: PluginFn;
@@ -386,17 +381,46 @@ type PluginAPI = {
386
381
  modifiers: 'any' | Record<string, string>;
387
382
  }>): void;
388
383
  theme(path: string, defaultValue?: any): any;
384
+ config(path: string, defaultValue?: any): any;
389
385
  prefix(className: string): string;
390
386
  };
391
387
  type CssInJs = {
392
- [key: string]: string | CssInJs | CssInJs[];
388
+ [key: string]: string | string[] | CssInJs | CssInJs[];
393
389
  };
394
390
 
391
+ type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
392
+ type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
393
+ type ThemeConfig = Record<string, ThemeValue> & {
394
+ extend?: Record<string, ThemeValue>;
395
+ };
396
+ type ContentFile = string | {
397
+ raw: string;
398
+ extension?: string;
399
+ };
400
+ type DarkModeStrategy = false | 'media' | 'class' | ['class', string] | 'selector' | ['selector', string] | ['variant', string | string[]];
401
+ interface UserConfig {
402
+ presets?: UserConfig[];
403
+ theme?: ThemeConfig;
404
+ plugins?: Plugin[];
405
+ }
406
+ interface UserConfig {
407
+ content?: ContentFile[] | {
408
+ files: ContentFile[];
409
+ };
410
+ }
411
+ interface UserConfig {
412
+ darkMode?: DarkModeStrategy;
413
+ }
414
+
395
415
  type CompileOptions = {
396
416
  loadPlugin?: (path: string) => Promise<Plugin>;
417
+ loadConfig?: (path: string) => Promise<UserConfig>;
397
418
  };
398
419
  declare function compile(css: string, opts?: CompileOptions): Promise<{
399
- globs: string[];
420
+ globs: {
421
+ origin?: string;
422
+ pattern: string;
423
+ }[];
400
424
  build(candidates: string[]): string;
401
425
  }>;
402
426
  declare function __unstable__loadDesignSystem(css: string, opts?: CompileOptions): Promise<DesignSystem>;