tailwindcss 4.0.0-alpha.23 → 4.0.0-alpha.25

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,6 @@
1
+ import { U as UserConfig, P as Plugin } from './types-D_qOw1fc.mjs';
2
+ import { V as Variant, C as Candidate } from './resolve-config-CaMNEFdQ.mjs';
3
+
1
4
  type Rule = {
2
5
  kind: 'rule';
3
6
  selector: string;
@@ -13,45 +16,54 @@ type Comment = {
13
16
  kind: 'comment';
14
17
  value: string;
15
18
  };
16
- type AstNode = Rule | Declaration | Comment;
19
+ type Context = {
20
+ kind: 'context';
21
+ context: Record<string, string>;
22
+ nodes: AstNode[];
23
+ };
24
+ type AstNode = Rule | Declaration | Comment | Context;
17
25
 
26
+ declare const enum ThemeOptions {
27
+ NONE = 0,
28
+ INLINE = 1,
29
+ REFERENCE = 2,
30
+ DEFAULT = 4
31
+ }
18
32
  declare class Theme {
19
33
  #private;
20
34
  private values;
21
35
  constructor(values?: Map<string, {
22
36
  value: string;
23
- isReference: boolean;
24
- isInline: boolean;
25
- isDefault: boolean;
37
+ options: number;
26
38
  }>);
27
- add(key: string, value: string, { isReference, isInline, isDefault }?: {
28
- isReference?: boolean | undefined;
29
- isInline?: boolean | undefined;
30
- isDefault?: boolean | undefined;
31
- }): void;
39
+ add(key: string, value: string, options?: ThemeOptions): void;
32
40
  keysInNamespaces(themeKeys: ThemeKey[]): string[];
33
- get(themeKeys: (ThemeKey | `${ThemeKey}-${string}`)[]): string | null;
41
+ get(themeKeys: ThemeKey[]): string | null;
34
42
  hasDefault(key: string): boolean;
43
+ getOptions(key: string): number;
35
44
  entries(): IterableIterator<[string, {
36
45
  value: string;
37
- isReference: boolean;
38
- isInline: boolean;
39
- isDefault: boolean;
46
+ options: number;
40
47
  }]>;
41
48
  resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
42
49
  resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
43
50
  resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
44
51
  namespace(namespace: string): Map<string | null, string>;
45
52
  }
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}`;
53
+ type ThemeKey = `--${string}`;
47
54
 
48
55
  type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
49
56
  kind: T;
50
57
  }>) => null | void;
51
58
  type CompareFn = (a: Variant, z: Variant) => number;
52
59
  declare class Variants {
53
- private compareFns;
54
- private variants;
60
+ compareFns: Map<number, CompareFn>;
61
+ variants: Map<string, {
62
+ kind: Variant["kind"];
63
+ order: number;
64
+ applyFn: VariantFn<any>;
65
+ compounds: boolean;
66
+ }>;
55
67
  private completions;
56
68
  /**
57
69
  * Registering a group of variants should result in the same sort number for
@@ -64,15 +76,18 @@ declare class Variants {
64
76
  * avoid unnecessarily skipping order numbers.
65
77
  */
66
78
  private lastOrder;
67
- static(name: string, applyFn: VariantFn<'static'>, { compounds }?: {
79
+ static(name: string, applyFn: VariantFn<'static'>, { compounds, order }?: {
68
80
  compounds?: boolean;
81
+ order?: number;
69
82
  }): void;
70
83
  fromAst(name: string, ast: AstNode[]): void;
71
- functional(name: string, applyFn: VariantFn<'functional'>, { compounds }?: {
84
+ functional(name: string, applyFn: VariantFn<'functional'>, { compounds, order }?: {
72
85
  compounds?: boolean;
86
+ order?: number;
73
87
  }): void;
74
- compound(name: string, applyFn: VariantFn<'compound'>, { compounds }?: {
88
+ compound(name: string, applyFn: VariantFn<'compound'>, { compounds, order }?: {
75
89
  compounds?: boolean;
90
+ order?: number;
76
91
  }): void;
77
92
  group(fn: () => void, compareFn?: CompareFn): void;
78
93
  has(name: string): boolean;
@@ -151,278 +166,37 @@ type DesignSystem = {
151
166
  theme: Theme;
152
167
  utilities: Utilities;
153
168
  variants: Variants;
154
- candidatesToCss(classes: string[]): (string | null)[];
155
169
  getClassOrder(classes: string[]): [string, bigint | null][];
156
170
  getClassList(): ClassEntry[];
157
171
  getVariants(): VariantEntry[];
158
172
  parseCandidate(candidate: string): Candidate[];
159
- parseVariant(variant: string): ReturnType<typeof parseVariant>;
173
+ parseVariant(variant: string): Variant | null;
160
174
  compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
161
- getUsedVariants(): ReturnType<typeof parseVariant>[];
162
- };
163
-
164
- type ArbitraryUtilityValue = {
165
- kind: 'arbitrary';
166
- /**
167
- * bg-[color:--my-color]
168
- * ^^^^^
169
- */
170
- dataType: string | null;
171
- /**
172
- * bg-[#0088cc]
173
- * ^^^^^^^
174
- * bg-[--my_variable]
175
- * var(^^^^^^^^^^^^^)
176
- */
177
- value: string;
178
- /**
179
- * bg-[--my_variable]
180
- * ^^^^^^^^^^^^^
181
- */
182
- dashedIdent: string | null;
183
- };
184
- type NamedUtilityValue = {
185
- kind: 'named';
186
- /**
187
- * bg-red-500
188
- * ^^^^^^^
189
- *
190
- * w-1/2
191
- * ^
192
- */
193
- value: string;
194
- /**
195
- * w-1/2
196
- * ^^^
197
- */
198
- fraction: string | null;
199
- };
200
- type ArbitraryModifier = {
201
- kind: 'arbitrary';
202
- /**
203
- * bg-red-500/[50%]
204
- * ^^^
205
- */
206
- value: string;
207
- /**
208
- * bg-red-500/[--my_variable]
209
- * ^^^^^^^^^^^^^
210
- */
211
- dashedIdent: string | null;
212
- };
213
- type NamedModifier = {
214
- kind: 'named';
215
- /**
216
- * bg-red-500/50
217
- * ^^
218
- */
219
- value: string;
220
- };
221
- type ArbitraryVariantValue = {
222
- kind: 'arbitrary';
223
- value: string;
224
- };
225
- type NamedVariantValue = {
226
- kind: 'named';
227
- value: string;
228
- };
229
- type Variant =
230
- /**
231
- * Arbitrary variants are variants that take a selector and generate a variant
232
- * on the fly.
233
- *
234
- * E.g.: `[&_p]`
235
- */
236
- {
237
- kind: 'arbitrary';
238
- selector: string;
239
- compounds: boolean;
240
- relative: boolean;
241
- }
242
- /**
243
- * Static variants are variants that don't take any arguments.
244
- *
245
- * E.g.: `hover`
246
- */
247
- | {
248
- kind: 'static';
249
- root: string;
250
- compounds: boolean;
251
- }
252
- /**
253
- * Functional variants are variants that can take an argument. The argument is
254
- * either a named variant value or an arbitrary variant value.
255
- *
256
- * E.g.:
257
- *
258
- * - `aria-disabled`
259
- * - `aria-[disabled]`
260
- * - `@container-size` -> @container, with named value `size`
261
- * - `@container-[inline-size]` -> @container, with arbitrary variant value `inline-size`
262
- * - `@container` -> @container, with no value
263
- */
264
- | {
265
- kind: 'functional';
266
- root: string;
267
- value: ArbitraryVariantValue | NamedVariantValue | null;
268
- modifier: ArbitraryModifier | NamedModifier | null;
269
- compounds: boolean;
270
- }
271
- /**
272
- * Compound variants are variants that take another variant as an argument.
273
- *
274
- * E.g.:
275
- *
276
- * - `has-[&_p]`
277
- * - `group-*`
278
- * - `peer-*`
279
- */
280
- | {
281
- kind: 'compound';
282
- root: string;
283
- modifier: ArbitraryModifier | NamedModifier | null;
284
- variant: Variant;
285
- compounds: boolean;
286
- };
287
- type Candidate =
288
- /**
289
- * Arbitrary candidates are candidates that register utilities on the fly with
290
- * a property and a value.
291
- *
292
- * E.g.:
293
- *
294
- * - `[color:red]`
295
- * - `[color:red]/50`
296
- * - `[color:red]/50!`
297
- */
298
- {
299
- kind: 'arbitrary';
300
- property: string;
301
- value: string;
302
- modifier: ArbitraryModifier | NamedModifier | null;
303
- variants: Variant[];
304
- important: boolean;
305
- raw: string;
306
- }
307
- /**
308
- * Static candidates are candidates that don't take any arguments.
309
- *
310
- * E.g.:
311
- *
312
- * - `underline`
313
- * - `flex`
314
- */
315
- | {
316
- kind: 'static';
317
- root: string;
318
- variants: Variant[];
319
- negative: boolean;
320
- important: boolean;
321
- raw: string;
322
- }
323
- /**
324
- * Functional candidates are candidates that can take an argument.
325
- *
326
- * E.g.:
327
- *
328
- * - `bg-red-500`
329
- * - `bg-[#0088cc]`
330
- * - `w-1/2`
331
- */
332
- | {
333
- kind: 'functional';
334
- root: string;
335
- value: ArbitraryUtilityValue | NamedUtilityValue | null;
336
- modifier: ArbitraryModifier | NamedModifier | null;
337
- variants: Variant[];
338
- negative: boolean;
339
- important: boolean;
340
- raw: string;
341
- };
342
- declare function parseVariant(variant: string, designSystem: DesignSystem): Variant | null;
343
-
344
- interface PluginUtils {
345
- theme(keypath: string, defaultValue?: any): any;
346
- }
347
-
348
- type PluginFn = (api: PluginAPI) => void;
349
- type PluginWithConfig = {
350
- handler: PluginFn;
351
- config?: UserConfig;
352
- };
353
- type PluginWithOptions<T> = {
354
- (options?: T): PluginWithConfig;
355
- __isOptionsFunction: true;
356
- };
357
- type Plugin = PluginFn | PluginWithConfig | PluginWithOptions<any>;
358
- type PluginAPI = {
359
- addBase(base: CssInJs): void;
360
- addVariant(name: string, variant: string | string[] | CssInJs): void;
361
- addUtilities(utilities: Record<string, CssInJs | CssInJs[]> | Record<string, CssInJs | CssInJs[]>[], options?: {}): void;
362
- matchUtilities(utilities: Record<string, (value: string, extra: {
363
- modifier: string | null;
364
- }) => CssInJs | CssInJs[]>, options?: Partial<{
365
- type: string | string[];
366
- supportsNegativeValues: boolean;
367
- values: Record<string, string> & {
368
- __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
369
- };
370
- modifiers: 'any' | Record<string, string>;
371
- }>): void;
372
- addComponents(utilities: Record<string, CssInJs> | Record<string, CssInJs>[], options?: {}): void;
373
- matchComponents(utilities: Record<string, (value: string, extra: {
374
- modifier: string | null;
375
- }) => CssInJs>, options?: Partial<{
376
- type: string | string[];
377
- supportsNegativeValues: boolean;
378
- values: Record<string, string> & {
379
- __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
380
- };
381
- modifiers: 'any' | Record<string, string>;
382
- }>): void;
383
- theme(path: string, defaultValue?: any): any;
384
- config(path: string, defaultValue?: any): any;
385
- prefix(className: string): string;
386
- };
387
- type CssInJs = {
388
- [key: string]: string | string[] | CssInJs | CssInJs[];
389
- };
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;
175
+ getVariantOrder(): Map<Variant, number>;
176
+ resolveThemeValue(path: string): string | undefined;
177
+ candidatesToCss(classes: string[]): (string | null)[];
399
178
  };
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
179
 
180
+ type Config = UserConfig;
415
181
  type CompileOptions = {
416
- loadPlugin?: (path: string) => Promise<Plugin>;
417
- loadConfig?: (path: string) => Promise<UserConfig>;
182
+ base?: string;
183
+ loadModule?: (id: string, base: string, resourceHint: 'plugin' | 'config') => Promise<{
184
+ module: Plugin | Config;
185
+ base: string;
186
+ }>;
187
+ loadStylesheet?: (id: string, base: string) => Promise<{
188
+ content: string;
189
+ base: string;
190
+ }>;
418
191
  };
419
192
  declare function compile(css: string, opts?: CompileOptions): Promise<{
420
193
  globs: {
421
- origin?: string;
194
+ base: string;
422
195
  pattern: string;
423
196
  }[];
424
197
  build(candidates: string[]): string;
425
198
  }>;
426
199
  declare function __unstable__loadDesignSystem(css: string, opts?: CompileOptions): Promise<DesignSystem>;
200
+ declare function postcssPluginWarning(): void;
427
201
 
428
- export { __unstable__loadDesignSystem, compile };
202
+ export { type Config, __unstable__loadDesignSystem, compile, postcssPluginWarning as default };