tailwindcss 4.0.0-alpha.22 → 4.0.0-alpha.24

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/plugin.d.mts CHANGED
@@ -1,72 +1,5 @@
1
- import { P as PluginUtils, N as NamedUtilityValue } from './resolve-config-C9L_YGHi.mjs';
2
-
3
- type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
4
- type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
5
- type ThemeConfig = Record<string, ThemeValue> & {
6
- extend?: Record<string, ThemeValue>;
7
- };
8
- type ContentFile = string | {
9
- raw: string;
10
- extension?: string;
11
- };
12
- type DarkModeStrategy = false | 'media' | 'class' | ['class', string] | 'selector' | ['selector', string] | ['variant', string | string[]];
13
- interface UserConfig {
14
- presets?: UserConfig[];
15
- theme?: ThemeConfig;
16
- plugins?: Plugin[];
17
- }
18
- interface UserConfig {
19
- content?: ContentFile[] | {
20
- files: ContentFile[];
21
- };
22
- }
23
- interface UserConfig {
24
- darkMode?: DarkModeStrategy;
25
- }
26
-
27
- type Config = UserConfig;
28
- type PluginFn = (api: PluginAPI) => void;
29
- type PluginWithConfig = {
30
- handler: PluginFn;
31
- config?: UserConfig;
32
- };
33
- type PluginWithOptions<T> = {
34
- (options?: T): PluginWithConfig;
35
- __isOptionsFunction: true;
36
- };
37
- type Plugin = PluginFn | PluginWithConfig | PluginWithOptions<any>;
38
- type PluginAPI = {
39
- addBase(base: CssInJs): void;
40
- addVariant(name: string, variant: string | string[] | CssInJs): void;
41
- addUtilities(utilities: Record<string, CssInJs | CssInJs[]> | Record<string, CssInJs | CssInJs[]>[], options?: {}): void;
42
- matchUtilities(utilities: Record<string, (value: string, extra: {
43
- modifier: string | null;
44
- }) => CssInJs | CssInJs[]>, options?: Partial<{
45
- type: string | string[];
46
- supportsNegativeValues: boolean;
47
- values: Record<string, string> & {
48
- __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
49
- };
50
- modifiers: 'any' | Record<string, string>;
51
- }>): void;
52
- addComponents(utilities: Record<string, CssInJs> | Record<string, CssInJs>[], options?: {}): void;
53
- matchComponents(utilities: Record<string, (value: string, extra: {
54
- modifier: string | null;
55
- }) => CssInJs>, options?: Partial<{
56
- type: string | string[];
57
- supportsNegativeValues: boolean;
58
- values: Record<string, string> & {
59
- __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
60
- };
61
- modifiers: 'any' | Record<string, string>;
62
- }>): void;
63
- theme(path: string, defaultValue?: any): any;
64
- config(path: string, defaultValue?: any): any;
65
- prefix(className: string): string;
66
- };
67
- type CssInJs = {
68
- [key: string]: string | string[] | CssInJs | CssInJs[];
69
- };
1
+ import { a as PluginFn, C as Config, b as PluginWithConfig, c as PluginWithOptions } from './types-D9a5isOA.mjs';
2
+ import './resolve-config-4MvviLnr.mjs';
70
3
 
71
4
  declare function createPlugin(handler: PluginFn, config?: Partial<Config>): PluginWithConfig;
72
5
  declare namespace createPlugin {
package/dist/plugin.d.ts CHANGED
@@ -38,6 +38,18 @@ type Plugin = PluginFn | PluginWithConfig | PluginWithOptions<any>;
38
38
  type PluginAPI = {
39
39
  addBase(base: CssInJs): void;
40
40
  addVariant(name: string, variant: string | string[] | CssInJs): void;
41
+ matchVariant<T = string>(name: string, cb: (value: T | string, extra: {
42
+ modifier: string | null;
43
+ }) => string | string[], options?: {
44
+ values?: Record<string, T>;
45
+ sort?(a: {
46
+ value: T | string;
47
+ modifier: string | null;
48
+ }, b: {
49
+ value: T | string;
50
+ modifier: string | null;
51
+ }): number;
52
+ }): void;
41
53
  addUtilities(utilities: Record<string, CssInJs | CssInJs[]> | Record<string, CssInJs | CssInJs[]>[], options?: {}): void;
42
54
  matchUtilities(utilities: Record<string, (value: string, extra: {
43
55
  modifier: string | null;
@@ -0,0 +1,348 @@
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 const enum ThemeOptions {
19
+ NONE = 0,
20
+ INLINE = 1,
21
+ REFERENCE = 2,
22
+ DEFAULT = 4
23
+ }
24
+ declare class Theme {
25
+ #private;
26
+ private values;
27
+ constructor(values?: Map<string, {
28
+ value: string;
29
+ options: number;
30
+ }>);
31
+ add(key: string, value: string, options?: ThemeOptions): void;
32
+ keysInNamespaces(themeKeys: ThemeKey[]): string[];
33
+ get(themeKeys: ThemeKey[]): string | null;
34
+ hasDefault(key: string): boolean;
35
+ getOptions(key: string): number;
36
+ entries(): IterableIterator<[string, {
37
+ value: string;
38
+ options: number;
39
+ }]>;
40
+ resolve(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
41
+ resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
42
+ resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
43
+ namespace(namespace: string): Map<string | null, string>;
44
+ }
45
+ type ThemeKey = `--${string}`;
46
+
47
+ type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
48
+ kind: T;
49
+ }>) => null | void;
50
+ type CompareFn = (a: Variant, z: Variant) => number;
51
+ declare class Variants {
52
+ private compareFns;
53
+ private variants;
54
+ private completions;
55
+ /**
56
+ * Registering a group of variants should result in the same sort number for
57
+ * all the variants. This is to ensure that the variants are applied in the
58
+ * correct order.
59
+ */
60
+ private groupOrder;
61
+ /**
62
+ * Keep track of the last sort order instead of using the size of the map to
63
+ * avoid unnecessarily skipping order numbers.
64
+ */
65
+ private lastOrder;
66
+ static(name: string, applyFn: VariantFn<'static'>, { compounds }?: {
67
+ compounds?: boolean;
68
+ }): void;
69
+ fromAst(name: string, ast: AstNode[]): void;
70
+ functional(name: string, applyFn: VariantFn<'functional'>, { compounds }?: {
71
+ compounds?: boolean;
72
+ }): void;
73
+ compound(name: string, applyFn: VariantFn<'compound'>, { compounds }?: {
74
+ compounds?: boolean;
75
+ }): void;
76
+ group(fn: () => void, compareFn?: CompareFn): void;
77
+ has(name: string): boolean;
78
+ get(name: string): {
79
+ kind: Variant["kind"];
80
+ order: number;
81
+ applyFn: VariantFn<any>;
82
+ compounds: boolean;
83
+ } | undefined;
84
+ kind(name: string): "static" | "functional" | "arbitrary" | "compound";
85
+ compounds(name: string): boolean;
86
+ suggest(name: string, suggestions: () => string[]): void;
87
+ getCompletions(name: string): string[];
88
+ compare(a: Variant | null, z: Variant | null): number;
89
+ keys(): IterableIterator<string>;
90
+ entries(): IterableIterator<[string, {
91
+ kind: Variant["kind"];
92
+ order: number;
93
+ applyFn: VariantFn<any>;
94
+ compounds: boolean;
95
+ }]>;
96
+ private set;
97
+ private nextOrder;
98
+ }
99
+
100
+ declare function compileAstNodes(candidate: Candidate, designSystem: DesignSystem): {
101
+ node: AstNode;
102
+ propertySort: number[];
103
+ }[];
104
+
105
+ interface ClassMetadata {
106
+ modifiers: string[];
107
+ }
108
+ type ClassEntry = [string, ClassMetadata];
109
+ interface SelectorOptions {
110
+ modifier?: string;
111
+ value?: string;
112
+ }
113
+ interface VariantEntry {
114
+ name: string;
115
+ isArbitrary: boolean;
116
+ values: string[];
117
+ hasDash: boolean;
118
+ selectors: (options: SelectorOptions) => string[];
119
+ }
120
+
121
+ type CompileFn<T extends Candidate['kind']> = (value: Extract<Candidate, {
122
+ kind: T;
123
+ }>) => AstNode[] | undefined | null;
124
+ interface SuggestionGroup {
125
+ supportsNegative?: boolean;
126
+ values: (string | null)[];
127
+ modifiers: string[];
128
+ }
129
+ type UtilityOptions = {
130
+ types: string[];
131
+ };
132
+ type Utility = {
133
+ kind: 'static' | 'functional';
134
+ compileFn: CompileFn<any>;
135
+ options?: UtilityOptions;
136
+ };
137
+ declare class Utilities {
138
+ private utilities;
139
+ private completions;
140
+ static(name: string, compileFn: CompileFn<'static'>): void;
141
+ functional(name: string, compileFn: CompileFn<'functional'>, options?: UtilityOptions): void;
142
+ has(name: string, kind: 'static' | 'functional'): boolean;
143
+ get(name: string): Utility[];
144
+ getCompletions(name: string): SuggestionGroup[];
145
+ suggest(name: string, groups: () => SuggestionGroup[]): void;
146
+ keys(kind: 'static' | 'functional'): string[];
147
+ }
148
+
149
+ type DesignSystem = {
150
+ theme: Theme;
151
+ utilities: Utilities;
152
+ variants: Variants;
153
+ candidatesToCss(classes: string[]): (string | null)[];
154
+ getClassOrder(classes: string[]): [string, bigint | null][];
155
+ getClassList(): ClassEntry[];
156
+ getVariants(): VariantEntry[];
157
+ parseCandidate(candidate: string): Candidate[];
158
+ parseVariant(variant: string): ReturnType<typeof parseVariant>;
159
+ compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
160
+ getUsedVariants(): ReturnType<typeof parseVariant>[];
161
+ resolveThemeValue(path: string): string | undefined;
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
+ export type { DesignSystem as D, NamedUtilityValue as N, PluginUtils as P };
@@ -0,0 +1,83 @@
1
+ import { N as NamedUtilityValue, P as PluginUtils } from './resolve-config-4MvviLnr.mjs';
2
+
3
+ type Config = UserConfig;
4
+ type PluginFn = (api: PluginAPI) => void;
5
+ type PluginWithConfig = {
6
+ handler: PluginFn;
7
+ config?: UserConfig;
8
+ };
9
+ type PluginWithOptions<T> = {
10
+ (options?: T): PluginWithConfig;
11
+ __isOptionsFunction: true;
12
+ };
13
+ type Plugin = PluginFn | PluginWithConfig | PluginWithOptions<any>;
14
+ type PluginAPI = {
15
+ addBase(base: CssInJs): void;
16
+ addVariant(name: string, variant: string | string[] | CssInJs): void;
17
+ matchVariant<T = string>(name: string, cb: (value: T | string, extra: {
18
+ modifier: string | null;
19
+ }) => string | string[], options?: {
20
+ values?: Record<string, T>;
21
+ sort?(a: {
22
+ value: T | string;
23
+ modifier: string | null;
24
+ }, b: {
25
+ value: T | string;
26
+ modifier: string | null;
27
+ }): number;
28
+ }): void;
29
+ addUtilities(utilities: Record<string, CssInJs | CssInJs[]> | Record<string, CssInJs | CssInJs[]>[], options?: {}): void;
30
+ matchUtilities(utilities: Record<string, (value: string, extra: {
31
+ modifier: string | null;
32
+ }) => CssInJs | CssInJs[]>, options?: Partial<{
33
+ type: string | string[];
34
+ supportsNegativeValues: boolean;
35
+ values: Record<string, string> & {
36
+ __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
37
+ };
38
+ modifiers: 'any' | Record<string, string>;
39
+ }>): void;
40
+ addComponents(utilities: Record<string, CssInJs> | Record<string, CssInJs>[], options?: {}): void;
41
+ matchComponents(utilities: Record<string, (value: string, extra: {
42
+ modifier: string | null;
43
+ }) => CssInJs>, options?: Partial<{
44
+ type: string | string[];
45
+ supportsNegativeValues: boolean;
46
+ values: Record<string, string> & {
47
+ __BARE_VALUE__?: (value: NamedUtilityValue) => string | undefined;
48
+ };
49
+ modifiers: 'any' | Record<string, string>;
50
+ }>): void;
51
+ theme(path: string, defaultValue?: any): any;
52
+ config(path: string, defaultValue?: any): any;
53
+ prefix(className: string): string;
54
+ };
55
+ type CssInJs = {
56
+ [key: string]: string | string[] | CssInJs | CssInJs[];
57
+ };
58
+
59
+ type ResolvableTo<T> = T | ((utils: PluginUtils) => T);
60
+ type ThemeValue = ResolvableTo<Record<string, unknown>> | null | undefined;
61
+ type ThemeConfig = Record<string, ThemeValue> & {
62
+ extend?: Record<string, ThemeValue>;
63
+ };
64
+ type ContentFile = string | {
65
+ raw: string;
66
+ extension?: string;
67
+ };
68
+ type DarkModeStrategy = false | 'media' | 'class' | ['class', string] | 'selector' | ['selector', string] | ['variant', string | string[]];
69
+ interface UserConfig {
70
+ presets?: UserConfig[];
71
+ theme?: ThemeConfig;
72
+ plugins?: Plugin[];
73
+ }
74
+ interface UserConfig {
75
+ content?: ContentFile[] | {
76
+ files: ContentFile[];
77
+ };
78
+ }
79
+ interface UserConfig {
80
+ darkMode?: DarkModeStrategy;
81
+ }
82
+
83
+ export type { Config as C, Plugin as P, UserConfig as U, PluginFn as a, PluginWithConfig as b, PluginWithOptions as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "4.0.0-alpha.22",
3
+ "version": "4.0.0-alpha.24",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.14.8",
56
56
  "lightningcss": "^1.26.0",
57
- "@tailwindcss/oxide": "4.0.0-alpha.22"
57
+ "@tailwindcss/oxide": "4.0.0-alpha.24"
58
58
  },
59
59
  "scripts": {
60
60
  "lint": "tsc --noEmit",
@@ -1,22 +0,0 @@
1
- type NamedUtilityValue = {
2
- kind: 'named';
3
- /**
4
- * bg-red-500
5
- * ^^^^^^^
6
- *
7
- * w-1/2
8
- * ^
9
- */
10
- value: string;
11
- /**
12
- * w-1/2
13
- * ^^^
14
- */
15
- fraction: string | null;
16
- };
17
-
18
- interface PluginUtils {
19
- theme(keypath: string, defaultValue?: any): any;
20
- }
21
-
22
- export type { NamedUtilityValue as N, PluginUtils as P };