tailwindcss 0.0.0-oxide.1 → 0.0.0-oxide.3
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/{chunk-J6HTTNZH.mjs → chunk-YL27VW7G.mjs} +2587 -1738
- package/dist/cli.d.mts +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2239 -1396
- package/dist/cli.mjs +5 -11
- package/dist/lib.d.mts +102 -22
- package/dist/lib.d.ts +102 -22
- package/dist/lib.js +2174 -1257
- package/dist/lib.mjs +1 -1
- package/package.json +2 -3
- package/preflight.css +1 -3
- package/theme.css +0 -3
package/dist/lib.js
CHANGED
|
@@ -5,7 +5,7 @@ var lightningcss = require('lightningcss');
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.0.0-oxide.
|
|
8
|
+
var version = "0.0.0-oxide.3";
|
|
9
9
|
|
|
10
10
|
// src/ast.ts
|
|
11
11
|
function rule(selector, nodes) {
|
|
@@ -45,183 +45,33 @@ function walk(ast, visit) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let current = "";
|
|
57
|
-
let closingBracketStack = "";
|
|
58
|
-
for (let i = 0; i < input.length; i++) {
|
|
59
|
-
let char = input[i];
|
|
60
|
-
if (char === "\\") {
|
|
61
|
-
current += input.slice(i, i + 2);
|
|
62
|
-
i += 1;
|
|
63
|
-
} else if (char === "/" && input[i + 1] === "*") {
|
|
64
|
-
let start = i;
|
|
65
|
-
for (let j = i + 2; j < input.length; j++) {
|
|
66
|
-
if (input[j] === "\\") {
|
|
67
|
-
j += 1;
|
|
68
|
-
} else if (input[j] === "*" && input[j + 1] === "/") {
|
|
69
|
-
i = j + 1;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
let commentString = input.slice(start, i + 1);
|
|
74
|
-
if (commentString[2] === "!") {
|
|
75
|
-
licenseComments.push(comment(commentString.slice(2, -2)));
|
|
76
|
-
}
|
|
77
|
-
} else if (char === '"' || char === "'") {
|
|
78
|
-
let start = i;
|
|
79
|
-
for (let j = i + 1; j < input.length; j++) {
|
|
80
|
-
if (input[j] === "\\") {
|
|
81
|
-
j += 1;
|
|
82
|
-
} else if (input[j] === char) {
|
|
83
|
-
i = j;
|
|
84
|
-
break;
|
|
85
|
-
} else if (input[j] === ";" && input[j + 1] === "\n") {
|
|
86
|
-
throw new Error(`Unterminated string: ${input.slice(start, j + 1) + char}`);
|
|
87
|
-
} else if (input[j] === "\n") {
|
|
88
|
-
throw new Error(`Unterminated string: ${input.slice(start, j) + char}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
current += input.slice(start, i + 1);
|
|
92
|
-
} else if ((char === " " || char === "\n" || char === " ") && (input[i + 1] === " " || input[i + 1] === "\n" || input[i + 1] === " ")) {
|
|
93
|
-
continue;
|
|
94
|
-
} else if (char === "-" && input[i + 1] === "-" && current.length === 0) {
|
|
95
|
-
let closingBracketStack2 = "";
|
|
96
|
-
let start = i;
|
|
97
|
-
let colonIdx = -1;
|
|
98
|
-
for (let j = i + 2; j < input.length; j++) {
|
|
99
|
-
if (input[j] === "\\") {
|
|
100
|
-
j += 1;
|
|
101
|
-
} else if (input[j] === "/" && input[j + 1] === "*") {
|
|
102
|
-
for (let k = j + 2; k < input.length; k++) {
|
|
103
|
-
if (input[k] === "\\") {
|
|
104
|
-
k += 1;
|
|
105
|
-
} else if (input[k] === "*" && input[k + 1] === "/") {
|
|
106
|
-
j = k + 1;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else if (colonIdx === -1 && input[j] === ":") {
|
|
111
|
-
colonIdx = current.length + j - start;
|
|
112
|
-
} else if (input[j] === ";" && closingBracketStack2.length === 0) {
|
|
113
|
-
current += input.slice(start, j);
|
|
114
|
-
i = j;
|
|
115
|
-
break;
|
|
116
|
-
} else if (input[j] === "(") {
|
|
117
|
-
closingBracketStack2 += ")";
|
|
118
|
-
} else if (input[j] === "[") {
|
|
119
|
-
closingBracketStack2 += "]";
|
|
120
|
-
} else if (input[j] === "{") {
|
|
121
|
-
closingBracketStack2 += "}";
|
|
122
|
-
} else if ((input[j] === "}" || input.length - 1 === j) && closingBracketStack2.length === 0) {
|
|
123
|
-
i = j - 1;
|
|
124
|
-
current += input.slice(start, j);
|
|
125
|
-
break;
|
|
126
|
-
} else if (input[j] === ")" || input[j] === "]" || input[j] === "}") {
|
|
127
|
-
if (closingBracketStack2.length > 0 && input[j] === closingBracketStack2[closingBracketStack2.length - 1]) {
|
|
128
|
-
closingBracketStack2 = closingBracketStack2.slice(0, -1);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
let declaration = parseDeclaration(current, colonIdx);
|
|
133
|
-
if (parent) {
|
|
134
|
-
parent.nodes.push(declaration);
|
|
135
|
-
} else {
|
|
136
|
-
ast.push(declaration);
|
|
137
|
-
}
|
|
138
|
-
current = "";
|
|
139
|
-
} else if (char === ";" && current[0] === "@") {
|
|
140
|
-
node = rule(current, []);
|
|
141
|
-
if (parent) {
|
|
142
|
-
parent.nodes.push(node);
|
|
143
|
-
} else {
|
|
144
|
-
ast.push(node);
|
|
145
|
-
}
|
|
146
|
-
current = "";
|
|
147
|
-
node = null;
|
|
148
|
-
} else if (char === ";") {
|
|
149
|
-
let declaration = parseDeclaration(current);
|
|
150
|
-
if (parent) {
|
|
151
|
-
parent.nodes.push(declaration);
|
|
152
|
-
} else {
|
|
153
|
-
ast.push(declaration);
|
|
154
|
-
}
|
|
155
|
-
current = "";
|
|
156
|
-
} else if (char === "{") {
|
|
157
|
-
closingBracketStack += "}";
|
|
158
|
-
node = rule(current.trim(), []);
|
|
159
|
-
if (parent) {
|
|
160
|
-
parent.nodes.push(node);
|
|
161
|
-
}
|
|
162
|
-
stack.push(parent);
|
|
163
|
-
parent = node;
|
|
164
|
-
current = "";
|
|
165
|
-
node = null;
|
|
166
|
-
} else if (char === "}") {
|
|
167
|
-
if (closingBracketStack === "") {
|
|
168
|
-
throw new Error(`Missing opening {`);
|
|
169
|
-
} else {
|
|
170
|
-
closingBracketStack = closingBracketStack.slice(0, -1);
|
|
171
|
-
}
|
|
172
|
-
if (current.length > 0) {
|
|
173
|
-
if (current[0] === "@") {
|
|
174
|
-
node = rule(current.trim(), []);
|
|
175
|
-
if (parent) {
|
|
176
|
-
parent.nodes.push(node);
|
|
177
|
-
} else {
|
|
178
|
-
ast.push(node);
|
|
179
|
-
}
|
|
180
|
-
current = "";
|
|
181
|
-
node = null;
|
|
182
|
-
} else {
|
|
183
|
-
let colonIdx = current.indexOf(":");
|
|
184
|
-
if (parent) {
|
|
185
|
-
let importantIdx = current.indexOf("!important", colonIdx + 1);
|
|
186
|
-
parent.nodes.push({
|
|
187
|
-
kind: "declaration",
|
|
188
|
-
property: current.slice(0, colonIdx).trim(),
|
|
189
|
-
value: current.slice(colonIdx + 1, importantIdx === -1 ? current.length : importantIdx).trim(),
|
|
190
|
-
important: importantIdx !== -1
|
|
191
|
-
});
|
|
192
|
-
}
|
|
48
|
+
function toCss(ast) {
|
|
49
|
+
let atRoots = [];
|
|
50
|
+
return ast.map(function stringify(node) {
|
|
51
|
+
let css = "";
|
|
52
|
+
if (node.kind === "rule") {
|
|
53
|
+
if (node.selector === "@at-root") {
|
|
54
|
+
for (let child of node.nodes) {
|
|
55
|
+
atRoots.push(stringify(child));
|
|
193
56
|
}
|
|
57
|
+
return css;
|
|
194
58
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
ast.push(parent);
|
|
59
|
+
if (node.selector[0] === "@" && node.nodes.length === 0) {
|
|
60
|
+
return `${node.selector};`;
|
|
198
61
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
} else {
|
|
203
|
-
if (current.length === 0 && (char === " " || char === "\n" || char === " ")) {
|
|
204
|
-
continue;
|
|
62
|
+
css += `${node.selector}{`;
|
|
63
|
+
for (let child of node.nodes) {
|
|
64
|
+
css += stringify(child);
|
|
205
65
|
}
|
|
206
|
-
|
|
66
|
+
css += "}";
|
|
67
|
+
} else if (node.kind === "comment") {
|
|
68
|
+
css += `/*${node.value}*/
|
|
69
|
+
`;
|
|
70
|
+
} else if (node.property !== "--tw-sort" && node.value !== void 0 && node.value !== null) {
|
|
71
|
+
css += `${node.property}:${node.value}${node.important ? "!important" : ""};`;
|
|
207
72
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
throw new Error(`Missing closing } at ${parent.selector}`);
|
|
211
|
-
}
|
|
212
|
-
if (licenseComments.length > 0) {
|
|
213
|
-
return licenseComments.concat(ast);
|
|
214
|
-
}
|
|
215
|
-
return ast;
|
|
216
|
-
}
|
|
217
|
-
function parseDeclaration(current, colonIdx = current.indexOf(":")) {
|
|
218
|
-
let importantIdx = current.indexOf("!important", colonIdx + 1);
|
|
219
|
-
return {
|
|
220
|
-
kind: "declaration",
|
|
221
|
-
property: current.slice(0, colonIdx).trim(),
|
|
222
|
-
value: current.slice(colonIdx + 1, importantIdx === -1 ? current.length : importantIdx).trim(),
|
|
223
|
-
important: importantIdx !== -1
|
|
224
|
-
};
|
|
73
|
+
return css;
|
|
74
|
+
}).concat(atRoots).join("\n");
|
|
225
75
|
}
|
|
226
76
|
|
|
227
77
|
// src/utils/math-operators.ts
|
|
@@ -380,152 +230,57 @@ function segment(input, separator) {
|
|
|
380
230
|
}
|
|
381
231
|
|
|
382
232
|
// src/candidate.ts
|
|
383
|
-
function
|
|
384
|
-
let
|
|
385
|
-
let
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
233
|
+
function parseCandidate(input, utilities, parsedVariants) {
|
|
234
|
+
let rawVariants = segment(input, ":");
|
|
235
|
+
let base = rawVariants.pop();
|
|
236
|
+
let parsedCandidateVariants = [];
|
|
237
|
+
for (let variant of rawVariants) {
|
|
238
|
+
let parsedVariant = parsedVariants.get(variant);
|
|
239
|
+
if (parsedVariant === null)
|
|
240
|
+
return null;
|
|
241
|
+
switch (variant) {
|
|
242
|
+
case "after":
|
|
243
|
+
case "backdrop":
|
|
244
|
+
case "before":
|
|
245
|
+
case "first-letter":
|
|
246
|
+
case "first-line":
|
|
247
|
+
case "marker":
|
|
248
|
+
case "placeholder":
|
|
249
|
+
case "selection":
|
|
250
|
+
parsedCandidateVariants.unshift(parsedVariant);
|
|
251
|
+
break;
|
|
252
|
+
default:
|
|
253
|
+
parsedCandidateVariants.push(parsedVariant);
|
|
403
254
|
}
|
|
404
255
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
256
|
+
let state = {
|
|
257
|
+
important: false,
|
|
258
|
+
negative: false
|
|
259
|
+
};
|
|
260
|
+
if (base[base.length - 1] === "!") {
|
|
261
|
+
state.important = true;
|
|
262
|
+
base = base.slice(0, -1);
|
|
263
|
+
}
|
|
264
|
+
if (base[0] === "[") {
|
|
265
|
+
let [baseWithoutModifier, modifierSegment2 = null] = segment(base, "/");
|
|
266
|
+
if (baseWithoutModifier[baseWithoutModifier.length - 1] !== "]")
|
|
410
267
|
return null;
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
268
|
+
let charCode = baseWithoutModifier.charCodeAt(1);
|
|
269
|
+
if (charCode !== 45 && !(charCode >= 97 && charCode <= 122))
|
|
270
|
+
return null;
|
|
271
|
+
baseWithoutModifier = baseWithoutModifier.slice(1, -1);
|
|
272
|
+
let idx = baseWithoutModifier.indexOf(":");
|
|
273
|
+
if (idx === -1 || idx === 0 || idx === baseWithoutModifier.length - 1)
|
|
274
|
+
return null;
|
|
275
|
+
let property2 = baseWithoutModifier.slice(0, idx);
|
|
276
|
+
let value2 = decodeArbitraryValue(baseWithoutModifier.slice(idx + 1));
|
|
417
277
|
return {
|
|
418
278
|
kind: "arbitrary",
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
let [variantWithoutModifier, modifier = null, additionalModifier] = segment(variant, "/");
|
|
425
|
-
if (additionalModifier)
|
|
426
|
-
return null;
|
|
427
|
-
let [root, value] = findRoot(variantWithoutModifier, variants);
|
|
428
|
-
if (root === null)
|
|
429
|
-
return null;
|
|
430
|
-
switch (variants.kind(root)) {
|
|
431
|
-
case "static": {
|
|
432
|
-
if (value !== null)
|
|
433
|
-
return null;
|
|
434
|
-
return {
|
|
435
|
-
kind: "static",
|
|
436
|
-
root,
|
|
437
|
-
compounds: variants.compounds(root)
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
case "functional": {
|
|
441
|
-
if (value === null)
|
|
442
|
-
return null;
|
|
443
|
-
if (value[0] === "[" && value[value.length - 1] === "]") {
|
|
444
|
-
return {
|
|
445
|
-
kind: "functional",
|
|
446
|
-
root,
|
|
447
|
-
value: {
|
|
448
|
-
kind: "arbitrary",
|
|
449
|
-
value: decodeArbitraryValue(value.slice(1, -1))
|
|
450
|
-
},
|
|
451
|
-
compounds: variants.compounds(root)
|
|
452
|
-
};
|
|
453
|
-
} else {
|
|
454
|
-
return {
|
|
455
|
-
kind: "functional",
|
|
456
|
-
root,
|
|
457
|
-
value: { kind: "named", value },
|
|
458
|
-
compounds: variants.compounds(root)
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
case "compound": {
|
|
463
|
-
if (value === null)
|
|
464
|
-
return null;
|
|
465
|
-
let subVariant = parsedVariants.get(value);
|
|
466
|
-
if (subVariant === null)
|
|
467
|
-
return null;
|
|
468
|
-
if (subVariant.compounds === false)
|
|
469
|
-
return null;
|
|
470
|
-
return {
|
|
471
|
-
kind: "compound",
|
|
472
|
-
root,
|
|
473
|
-
modifier: modifier === null ? null : { kind: "named", value: modifier },
|
|
474
|
-
variant: subVariant,
|
|
475
|
-
compounds: variants.compounds(root)
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
function parseCandidate(input, utilities, parsedVariants) {
|
|
483
|
-
let rawVariants = segment(input, ":");
|
|
484
|
-
let base = rawVariants.pop();
|
|
485
|
-
let parsedCandidateVariants = [];
|
|
486
|
-
for (let variant of rawVariants) {
|
|
487
|
-
let parsedVariant = parsedVariants.get(variant);
|
|
488
|
-
if (parsedVariant === null)
|
|
489
|
-
return null;
|
|
490
|
-
switch (variant) {
|
|
491
|
-
case "after":
|
|
492
|
-
case "backdrop":
|
|
493
|
-
case "before":
|
|
494
|
-
case "first-letter":
|
|
495
|
-
case "first-line":
|
|
496
|
-
case "marker":
|
|
497
|
-
case "placeholder":
|
|
498
|
-
case "selection":
|
|
499
|
-
parsedCandidateVariants.unshift(parsedVariant);
|
|
500
|
-
break;
|
|
501
|
-
default:
|
|
502
|
-
parsedCandidateVariants.push(parsedVariant);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
let state = {
|
|
506
|
-
important: false,
|
|
507
|
-
negative: false
|
|
508
|
-
};
|
|
509
|
-
if (base[base.length - 1] === "!") {
|
|
510
|
-
state.important = true;
|
|
511
|
-
base = base.slice(0, -1);
|
|
512
|
-
}
|
|
513
|
-
if (base[0] === "[" && base[base.length - 1] === "]") {
|
|
514
|
-
let charCode = base.charCodeAt(1);
|
|
515
|
-
if (charCode !== 45 && !(charCode >= 97 && charCode <= 122))
|
|
516
|
-
return null;
|
|
517
|
-
base = base.slice(1, -1);
|
|
518
|
-
let idx = base.indexOf(":");
|
|
519
|
-
if (idx === -1 || idx === 0 || idx === base.length - 1)
|
|
520
|
-
return null;
|
|
521
|
-
let property2 = base.slice(0, idx);
|
|
522
|
-
let value2 = decodeArbitraryValue(base.slice(idx + 1));
|
|
523
|
-
return {
|
|
524
|
-
kind: "arbitrary",
|
|
525
|
-
property: property2,
|
|
526
|
-
value: value2,
|
|
527
|
-
variants: parsedCandidateVariants,
|
|
528
|
-
important: state.important
|
|
279
|
+
property: property2,
|
|
280
|
+
value: value2,
|
|
281
|
+
modifier: modifierSegment2 === null ? null : parseModifier(modifierSegment2),
|
|
282
|
+
variants: parsedCandidateVariants,
|
|
283
|
+
important: state.important
|
|
529
284
|
};
|
|
530
285
|
}
|
|
531
286
|
if (base[0] === "-") {
|
|
@@ -533,6 +288,12 @@ function parseCandidate(input, utilities, parsedVariants) {
|
|
|
533
288
|
base = base.slice(1);
|
|
534
289
|
}
|
|
535
290
|
let [root, value] = findRoot(base, utilities);
|
|
291
|
+
let modifierSegment = null;
|
|
292
|
+
if (root === null && base.includes("/")) {
|
|
293
|
+
let [rootWithoutModifier, rootModifierSegment = null] = segment(base, "/");
|
|
294
|
+
modifierSegment = rootModifierSegment;
|
|
295
|
+
[root, value] = findRoot(rootWithoutModifier, utilities);
|
|
296
|
+
}
|
|
536
297
|
if (root === null)
|
|
537
298
|
return null;
|
|
538
299
|
let kind = utilities.kind(root);
|
|
@@ -550,22 +311,36 @@ function parseCandidate(input, utilities, parsedVariants) {
|
|
|
550
311
|
let candidate = {
|
|
551
312
|
kind: "functional",
|
|
552
313
|
root,
|
|
553
|
-
modifier: null,
|
|
314
|
+
modifier: modifierSegment === null ? null : parseModifier(modifierSegment),
|
|
554
315
|
value: null,
|
|
555
316
|
variants: parsedCandidateVariants,
|
|
556
317
|
negative: state.negative,
|
|
557
318
|
important: state.important
|
|
558
319
|
};
|
|
559
|
-
if (value === null)
|
|
320
|
+
if (value === null)
|
|
560
321
|
return candidate;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
322
|
+
{
|
|
323
|
+
let [valueWithoutModifier, modifierSegment2 = null] = segment(value, "/");
|
|
324
|
+
if (modifierSegment2 !== null) {
|
|
325
|
+
candidate.modifier = parseModifier(modifierSegment2);
|
|
326
|
+
}
|
|
327
|
+
let startArbitraryIdx = valueWithoutModifier.indexOf("[");
|
|
328
|
+
let valueIsArbitrary = startArbitraryIdx !== -1;
|
|
329
|
+
if (valueIsArbitrary) {
|
|
330
|
+
let arbitraryValue = valueWithoutModifier.slice(startArbitraryIdx + 1, -1);
|
|
331
|
+
let typehint = "";
|
|
332
|
+
for (let i = 0; i < arbitraryValue.length; i++) {
|
|
333
|
+
let code = arbitraryValue.charCodeAt(i);
|
|
334
|
+
if (code === 58) {
|
|
335
|
+
typehint = arbitraryValue.slice(0, i);
|
|
336
|
+
arbitraryValue = arbitraryValue.slice(i + 1);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
if (code === 45 || code >= 97 && code <= 122) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
569
344
|
let dashedIdent = null;
|
|
570
345
|
if (arbitraryValue[0] === "-" && arbitraryValue[1] === "-") {
|
|
571
346
|
dashedIdent = arbitraryValue;
|
|
@@ -573,33 +348,26 @@ function parseCandidate(input, utilities, parsedVariants) {
|
|
|
573
348
|
} else {
|
|
574
349
|
arbitraryValue = decodeArbitraryValue(arbitraryValue);
|
|
575
350
|
}
|
|
576
|
-
candidate.
|
|
351
|
+
candidate.value = {
|
|
577
352
|
kind: "arbitrary",
|
|
353
|
+
dataType: typehint || null,
|
|
578
354
|
value: arbitraryValue,
|
|
579
355
|
dashedIdent
|
|
580
356
|
};
|
|
581
357
|
} else {
|
|
582
|
-
candidate.modifier
|
|
358
|
+
let fraction = modifierSegment2 === null || candidate.modifier?.kind === "arbitrary" ? null : value.slice(valueWithoutModifier.lastIndexOf("-") + 1);
|
|
359
|
+
candidate.value = {
|
|
583
360
|
kind: "named",
|
|
584
|
-
value:
|
|
361
|
+
value: valueWithoutModifier,
|
|
362
|
+
fraction
|
|
585
363
|
};
|
|
586
364
|
}
|
|
587
365
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (code === 58) {
|
|
594
|
-
typehint = arbitraryValue.slice(0, i);
|
|
595
|
-
arbitraryValue = arbitraryValue.slice(i + 1);
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
if (code === 45 || code >= 97 && code <= 122) {
|
|
599
|
-
continue;
|
|
600
|
-
}
|
|
601
|
-
break;
|
|
602
|
-
}
|
|
366
|
+
return candidate;
|
|
367
|
+
}
|
|
368
|
+
function parseModifier(modifier) {
|
|
369
|
+
if (modifier[0] === "[" && modifier[modifier.length - 1] === "]") {
|
|
370
|
+
let arbitraryValue = modifier.slice(1, -1);
|
|
603
371
|
let dashedIdent = null;
|
|
604
372
|
if (arbitraryValue[0] === "-" && arbitraryValue[1] === "-") {
|
|
605
373
|
dashedIdent = arbitraryValue;
|
|
@@ -607,314 +375,113 @@ function parseCandidate(input, utilities, parsedVariants) {
|
|
|
607
375
|
} else {
|
|
608
376
|
arbitraryValue = decodeArbitraryValue(arbitraryValue);
|
|
609
377
|
}
|
|
610
|
-
|
|
378
|
+
return {
|
|
611
379
|
kind: "arbitrary",
|
|
612
|
-
dataType: typehint || null,
|
|
613
380
|
value: arbitraryValue,
|
|
614
381
|
dashedIdent
|
|
615
382
|
};
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
kind: "named",
|
|
386
|
+
value: modifier
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function parseVariant(variant, variants, parsedVariants) {
|
|
390
|
+
if (variant[0] === "[" && variant[variant.length - 1] === "]") {
|
|
391
|
+
if (variant[1] === "@" && variant.includes("&"))
|
|
392
|
+
return null;
|
|
393
|
+
let selector = decodeArbitraryValue(variant.slice(1, -1));
|
|
394
|
+
if (selector[0] !== "@") {
|
|
395
|
+
if (!selector.includes("&")) {
|
|
396
|
+
selector = `&:is(${selector})`;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
kind: "arbitrary",
|
|
401
|
+
selector,
|
|
402
|
+
compounds: true
|
|
622
403
|
};
|
|
623
404
|
}
|
|
624
|
-
|
|
405
|
+
{
|
|
406
|
+
let [variantWithoutModifier, modifier = null, additionalModifier] = segment(variant, "/");
|
|
407
|
+
if (additionalModifier)
|
|
408
|
+
return null;
|
|
409
|
+
let [root, value] = findRoot(variantWithoutModifier, variants);
|
|
410
|
+
if (root === null)
|
|
411
|
+
return null;
|
|
412
|
+
switch (variants.kind(root)) {
|
|
413
|
+
case "static": {
|
|
414
|
+
if (value !== null)
|
|
415
|
+
return null;
|
|
416
|
+
return {
|
|
417
|
+
kind: "static",
|
|
418
|
+
root,
|
|
419
|
+
compounds: variants.compounds(root)
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
case "functional": {
|
|
423
|
+
if (value === null)
|
|
424
|
+
return null;
|
|
425
|
+
if (value[0] === "[" && value[value.length - 1] === "]") {
|
|
426
|
+
return {
|
|
427
|
+
kind: "functional",
|
|
428
|
+
root,
|
|
429
|
+
modifier: modifier === null ? null : parseModifier(modifier),
|
|
430
|
+
value: {
|
|
431
|
+
kind: "arbitrary",
|
|
432
|
+
value: decodeArbitraryValue(value.slice(1, -1))
|
|
433
|
+
},
|
|
434
|
+
compounds: variants.compounds(root)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
kind: "functional",
|
|
439
|
+
root,
|
|
440
|
+
modifier: modifier === null ? null : parseModifier(modifier),
|
|
441
|
+
value: { kind: "named", value },
|
|
442
|
+
compounds: variants.compounds(root)
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
case "compound": {
|
|
446
|
+
if (value === null)
|
|
447
|
+
return null;
|
|
448
|
+
let subVariant = parsedVariants.get(value);
|
|
449
|
+
if (subVariant === null)
|
|
450
|
+
return null;
|
|
451
|
+
if (subVariant.compounds === false)
|
|
452
|
+
return null;
|
|
453
|
+
return {
|
|
454
|
+
kind: "compound",
|
|
455
|
+
root,
|
|
456
|
+
modifier: modifier === null ? null : { kind: "named", value: modifier },
|
|
457
|
+
variant: subVariant,
|
|
458
|
+
compounds: variants.compounds(root)
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
function findRoot(input, lookup) {
|
|
466
|
+
if (lookup.has(input))
|
|
467
|
+
return [input, null];
|
|
468
|
+
let idx = input.lastIndexOf("-");
|
|
469
|
+
if (idx === -1) {
|
|
470
|
+
if (input[0] === "@" && lookup.has("@")) {
|
|
471
|
+
return ["@", input.slice(1)];
|
|
472
|
+
}
|
|
473
|
+
return [null, null];
|
|
474
|
+
}
|
|
475
|
+
do {
|
|
476
|
+
let maybeRoot = input.slice(0, idx);
|
|
477
|
+
if (lookup.has(maybeRoot)) {
|
|
478
|
+
return [maybeRoot, input.slice(idx + 1)];
|
|
479
|
+
}
|
|
480
|
+
idx = input.lastIndexOf("-", idx - 1);
|
|
481
|
+
} while (idx > 0);
|
|
482
|
+
return [null, null];
|
|
625
483
|
}
|
|
626
484
|
|
|
627
|
-
// src/property-order.ts
|
|
628
|
-
var property_order_default = [
|
|
629
|
-
"pointer-events",
|
|
630
|
-
"visibility",
|
|
631
|
-
"position",
|
|
632
|
-
// How do we make `inset-x-0` come before `top-0`?
|
|
633
|
-
"inset",
|
|
634
|
-
"inset-inline",
|
|
635
|
-
"inset-block",
|
|
636
|
-
"inset-inline-start",
|
|
637
|
-
"inset-inline-end",
|
|
638
|
-
"top",
|
|
639
|
-
"right",
|
|
640
|
-
"bottom",
|
|
641
|
-
"left",
|
|
642
|
-
"isolation",
|
|
643
|
-
"z-index",
|
|
644
|
-
"order",
|
|
645
|
-
"grid-column",
|
|
646
|
-
"grid-column-start",
|
|
647
|
-
"grid-column-end",
|
|
648
|
-
"grid-row",
|
|
649
|
-
"grid-row-start",
|
|
650
|
-
"grid-row-end",
|
|
651
|
-
"float",
|
|
652
|
-
"clear",
|
|
653
|
-
// How do we make `mx-0` come before `mt-0`?
|
|
654
|
-
// Idea: `margin-x` property that we compile away with a Visitor plugin?
|
|
655
|
-
"margin",
|
|
656
|
-
"margin-inline",
|
|
657
|
-
"margin-block",
|
|
658
|
-
"margin-inline-start",
|
|
659
|
-
"margin-inline-end",
|
|
660
|
-
"margin-top",
|
|
661
|
-
"margin-right",
|
|
662
|
-
"margin-bottom",
|
|
663
|
-
"margin-left",
|
|
664
|
-
"box-sizing",
|
|
665
|
-
"display",
|
|
666
|
-
"aspect-ratio",
|
|
667
|
-
"height",
|
|
668
|
-
"max-height",
|
|
669
|
-
"min-height",
|
|
670
|
-
"width",
|
|
671
|
-
"max-width",
|
|
672
|
-
"min-width",
|
|
673
|
-
"flex",
|
|
674
|
-
"flex-shrink",
|
|
675
|
-
"flex-grow",
|
|
676
|
-
"flex-basis",
|
|
677
|
-
"table-layout",
|
|
678
|
-
"caption-side",
|
|
679
|
-
"border-collapse",
|
|
680
|
-
// There's no `border-spacing-x` property, we use variables, how to sort?
|
|
681
|
-
"border-spacing",
|
|
682
|
-
// '--tw-border-spacing-x',
|
|
683
|
-
// '--tw-border-spacing-y',
|
|
684
|
-
"transform-origin",
|
|
685
|
-
// '--tw-translate-x',
|
|
686
|
-
// '--tw-translate-y',
|
|
687
|
-
"translate",
|
|
688
|
-
"rotate",
|
|
689
|
-
// '--tw-rotate',
|
|
690
|
-
"--tw-skew-x",
|
|
691
|
-
"--tw-skew-y",
|
|
692
|
-
"scale",
|
|
693
|
-
// '--tw-scale-x',
|
|
694
|
-
// '--tw-scale-y',
|
|
695
|
-
"transform",
|
|
696
|
-
"animation",
|
|
697
|
-
"cursor",
|
|
698
|
-
"touch-action",
|
|
699
|
-
"--tw-pan-x",
|
|
700
|
-
"--tw-pan-y",
|
|
701
|
-
"--tw-pinch-zoom",
|
|
702
|
-
"resize",
|
|
703
|
-
"scroll-snap-type",
|
|
704
|
-
"--tw-scroll-snap-strictness",
|
|
705
|
-
"scroll-snap-align",
|
|
706
|
-
"scroll-snap-stop",
|
|
707
|
-
"scroll-margin",
|
|
708
|
-
"scroll-margin-inline-start",
|
|
709
|
-
"scroll-margin-inline-end",
|
|
710
|
-
"scroll-margin-top",
|
|
711
|
-
"scroll-margin-right",
|
|
712
|
-
"scroll-margin-bottom",
|
|
713
|
-
"scroll-margin-left",
|
|
714
|
-
"scroll-padding",
|
|
715
|
-
"scroll-padding-inline-start",
|
|
716
|
-
"scroll-padding-inline-end",
|
|
717
|
-
"scroll-padding-top",
|
|
718
|
-
"scroll-padding-right",
|
|
719
|
-
"scroll-padding-bottom",
|
|
720
|
-
"scroll-padding-left",
|
|
721
|
-
"list-style-position",
|
|
722
|
-
"list-style-type",
|
|
723
|
-
"list-style-image",
|
|
724
|
-
"appearance",
|
|
725
|
-
"columns",
|
|
726
|
-
"break-before",
|
|
727
|
-
"break-inside",
|
|
728
|
-
"break-after",
|
|
729
|
-
"grid-auto-columns",
|
|
730
|
-
"grid-auto-flow",
|
|
731
|
-
"grid-auto-rows",
|
|
732
|
-
"grid-template-columns",
|
|
733
|
-
"grid-template-rows",
|
|
734
|
-
"flex-direction",
|
|
735
|
-
"flex-wrap",
|
|
736
|
-
"place-content",
|
|
737
|
-
"place-items",
|
|
738
|
-
"align-content",
|
|
739
|
-
"align-items",
|
|
740
|
-
"justify-content",
|
|
741
|
-
"justify-items",
|
|
742
|
-
"gap",
|
|
743
|
-
"column-gap",
|
|
744
|
-
"row-gap",
|
|
745
|
-
"--tw-space-x-reverse",
|
|
746
|
-
"--tw-space-y-reverse",
|
|
747
|
-
// Is there a more "real" property we could use for this?
|
|
748
|
-
"divide-x-width",
|
|
749
|
-
"divide-y-width",
|
|
750
|
-
"--tw-divide-y-reverse",
|
|
751
|
-
"divide-style",
|
|
752
|
-
"divide-color",
|
|
753
|
-
"--tw-divide-opacity",
|
|
754
|
-
"place-self",
|
|
755
|
-
"align-self",
|
|
756
|
-
"justify-self",
|
|
757
|
-
"overflow",
|
|
758
|
-
"overflow-x",
|
|
759
|
-
"overflow-y",
|
|
760
|
-
"overscroll-behavior",
|
|
761
|
-
"overscroll-behavior-x",
|
|
762
|
-
"overscroll-behavior-y",
|
|
763
|
-
"scroll-behavior",
|
|
764
|
-
"text-overflow",
|
|
765
|
-
"hyphens",
|
|
766
|
-
"white-space",
|
|
767
|
-
"text-wrap",
|
|
768
|
-
"overflow-wrap",
|
|
769
|
-
"work-break",
|
|
770
|
-
"border-radius",
|
|
771
|
-
"border-start-radius",
|
|
772
|
-
// Not real
|
|
773
|
-
"border-end-radius",
|
|
774
|
-
// Not real
|
|
775
|
-
"border-top-radius",
|
|
776
|
-
// Not real
|
|
777
|
-
"border-right-radius",
|
|
778
|
-
// Not real
|
|
779
|
-
"border-bottom-radius",
|
|
780
|
-
// Not real
|
|
781
|
-
"border-left-radius",
|
|
782
|
-
// Not real
|
|
783
|
-
"border-start-start-radius",
|
|
784
|
-
"border-start-end-radius",
|
|
785
|
-
"border-end-end-radius",
|
|
786
|
-
"border-end-start-radius",
|
|
787
|
-
"border-top-left-radius",
|
|
788
|
-
"border-top-right-radius",
|
|
789
|
-
"border-bottom-right-radius",
|
|
790
|
-
"border-bottom-left-radius",
|
|
791
|
-
"border-width",
|
|
792
|
-
"border-inline-width",
|
|
793
|
-
// Not real
|
|
794
|
-
"border-inline-start-width",
|
|
795
|
-
"border-inline-end-width",
|
|
796
|
-
"border-top-width",
|
|
797
|
-
"border-right-width",
|
|
798
|
-
"border-bottom-width",
|
|
799
|
-
"border-left-width",
|
|
800
|
-
"border-style",
|
|
801
|
-
"border-color",
|
|
802
|
-
"border-x-color",
|
|
803
|
-
// Not real
|
|
804
|
-
"border-y-color",
|
|
805
|
-
// Not real
|
|
806
|
-
"border-inline-start-color",
|
|
807
|
-
"border-inline-end-color",
|
|
808
|
-
"border-top-color",
|
|
809
|
-
"border-right-color",
|
|
810
|
-
"border-bottom-color",
|
|
811
|
-
"border-left-color",
|
|
812
|
-
"--tw-border-opacity",
|
|
813
|
-
"background-color",
|
|
814
|
-
"--tw-bg-opacity",
|
|
815
|
-
"background-image",
|
|
816
|
-
"--tw-gradient-stops",
|
|
817
|
-
"--tw-gradient-via-stops",
|
|
818
|
-
"--tw-gradient-from",
|
|
819
|
-
"--tw-gradient-from-position",
|
|
820
|
-
"--tw-gradient-via",
|
|
821
|
-
"--tw-gradient-via-position",
|
|
822
|
-
"--tw-gradient-to",
|
|
823
|
-
"--tw-gradient-to-position",
|
|
824
|
-
"box-decoration-break",
|
|
825
|
-
"background-size",
|
|
826
|
-
"background-attachment",
|
|
827
|
-
"background-clip",
|
|
828
|
-
"background-position",
|
|
829
|
-
"background-repeat",
|
|
830
|
-
"background-origin",
|
|
831
|
-
"fill",
|
|
832
|
-
"stroke",
|
|
833
|
-
"stroke-width",
|
|
834
|
-
"object-fit",
|
|
835
|
-
"object-position",
|
|
836
|
-
"padding",
|
|
837
|
-
"padding-inline",
|
|
838
|
-
"padding-block",
|
|
839
|
-
"padding-inline-start",
|
|
840
|
-
"padding-inline-end",
|
|
841
|
-
"padding-top",
|
|
842
|
-
"padding-right",
|
|
843
|
-
"padding-bottom",
|
|
844
|
-
"padding-left",
|
|
845
|
-
"text-align",
|
|
846
|
-
"text-indent",
|
|
847
|
-
"vertical-align",
|
|
848
|
-
"font-family",
|
|
849
|
-
"font-size",
|
|
850
|
-
"font-weight",
|
|
851
|
-
"text-transform",
|
|
852
|
-
"font-style",
|
|
853
|
-
"font-variant-numeric",
|
|
854
|
-
"line-height",
|
|
855
|
-
"letter-spacing",
|
|
856
|
-
"color",
|
|
857
|
-
"--tw-text-opacity",
|
|
858
|
-
"text-decoration-line",
|
|
859
|
-
"text-decoration-color",
|
|
860
|
-
"text-decoration-style",
|
|
861
|
-
"text-decoration-thickness",
|
|
862
|
-
"text-underline-offset",
|
|
863
|
-
"-webkit-font-smoothing",
|
|
864
|
-
"placeholder-color",
|
|
865
|
-
// Not real
|
|
866
|
-
"--tw-placeholder-opacity",
|
|
867
|
-
"caret-color",
|
|
868
|
-
"accent-color",
|
|
869
|
-
"opacity",
|
|
870
|
-
"background-blend-mode",
|
|
871
|
-
"mix-blend-mode",
|
|
872
|
-
"box-shadow",
|
|
873
|
-
"--tw-shadow",
|
|
874
|
-
"--tw-shadow-color",
|
|
875
|
-
"--tw-ring-shadow",
|
|
876
|
-
"--tw-ring-color",
|
|
877
|
-
"--tw-inset-shadow",
|
|
878
|
-
"--tw-inset-shadow-color",
|
|
879
|
-
"--tw-inset-ring-shadow",
|
|
880
|
-
"--tw-inset-ring-color",
|
|
881
|
-
"--tw-ring-opacity",
|
|
882
|
-
"--tw-ring-offset-width",
|
|
883
|
-
"--tw-ring-offset-color",
|
|
884
|
-
"outline",
|
|
885
|
-
"outline-width",
|
|
886
|
-
"outline-offset",
|
|
887
|
-
"outline-color",
|
|
888
|
-
"--tw-blur",
|
|
889
|
-
"--tw-brightness",
|
|
890
|
-
"--tw-contast",
|
|
891
|
-
"--tw-drop-shadow",
|
|
892
|
-
"--tw-grayscale",
|
|
893
|
-
"--tw-hue-rotate",
|
|
894
|
-
"--tw-invert",
|
|
895
|
-
"--tw-saturate",
|
|
896
|
-
"--tw-sepia",
|
|
897
|
-
"filter",
|
|
898
|
-
"--tw-backdrop-blur",
|
|
899
|
-
"--tw-backdrop-brightness",
|
|
900
|
-
"--tw-backdrop-contast",
|
|
901
|
-
"--tw-backdrop-grayscale",
|
|
902
|
-
"--tw-backdrop-hue-rotate",
|
|
903
|
-
"--tw-backdrop-invert",
|
|
904
|
-
"--tw-backdrop-opacity",
|
|
905
|
-
"--tw-backdrop-saturate",
|
|
906
|
-
"--tw-backdrop-sepia",
|
|
907
|
-
"backdrop-filter",
|
|
908
|
-
"transition-property",
|
|
909
|
-
"transition-delay",
|
|
910
|
-
"transition-duration",
|
|
911
|
-
"transition-timing-function",
|
|
912
|
-
"will-change",
|
|
913
|
-
"contain",
|
|
914
|
-
"content",
|
|
915
|
-
"forced-color-adjust"
|
|
916
|
-
];
|
|
917
|
-
|
|
918
485
|
// src/utils/default-map.ts
|
|
919
486
|
var DefaultMap = class extends Map {
|
|
920
487
|
constructor(factory) {
|
|
@@ -931,205 +498,100 @@ var DefaultMap = class extends Map {
|
|
|
931
498
|
}
|
|
932
499
|
};
|
|
933
500
|
|
|
934
|
-
// src/
|
|
935
|
-
function
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
var string = String(value);
|
|
940
|
-
var length = string.length;
|
|
941
|
-
var index = -1;
|
|
942
|
-
var codeUnit;
|
|
943
|
-
var result = "";
|
|
944
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
945
|
-
if (
|
|
946
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
947
|
-
// there is no second character, […]
|
|
948
|
-
length == 1 && firstCodeUnit == 45
|
|
949
|
-
) {
|
|
950
|
-
return "\\" + string;
|
|
951
|
-
}
|
|
952
|
-
while (++index < length) {
|
|
953
|
-
codeUnit = string.charCodeAt(index);
|
|
954
|
-
if (codeUnit == 0) {
|
|
955
|
-
result += "\uFFFD";
|
|
501
|
+
// src/intellisense.ts
|
|
502
|
+
function getClassList(design) {
|
|
503
|
+
let list = [];
|
|
504
|
+
for (let [utility, fn] of design.utilities.entries()) {
|
|
505
|
+
if (typeof utility !== "string") {
|
|
956
506
|
continue;
|
|
957
507
|
}
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
-
// U+007F, […]
|
|
961
|
-
codeUnit >= 1 && codeUnit <= 31 || codeUnit == 127 || // If the character is the first character and is in the range [0-9]
|
|
962
|
-
// (U+0030 to U+0039), […]
|
|
963
|
-
index == 0 && codeUnit >= 48 && codeUnit <= 57 || // If the character is the second character and is in the range [0-9]
|
|
964
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
965
|
-
index == 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit == 45
|
|
966
|
-
) {
|
|
967
|
-
result += "\\" + codeUnit.toString(16) + " ";
|
|
508
|
+
if (fn.kind === "static") {
|
|
509
|
+
list.push([utility, { modifiers: [] }]);
|
|
968
510
|
continue;
|
|
969
511
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
// src/parse.ts
|
|
980
|
-
function applyImportant(ast) {
|
|
981
|
-
for (let node of ast) {
|
|
982
|
-
if (node.kind === "rule" && node.selector === "@at-root") {
|
|
983
|
-
continue;
|
|
984
|
-
}
|
|
985
|
-
if (node.kind === "declaration") {
|
|
986
|
-
node.important = true;
|
|
987
|
-
} else if (node.kind === "rule") {
|
|
988
|
-
applyImportant(node.nodes);
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
function applyVariant(node, variant, variants) {
|
|
993
|
-
if (variant.kind === "arbitrary") {
|
|
994
|
-
node.nodes = [rule(variant.selector, node.nodes)];
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
let applyVariantFn = variants.get(variant.root);
|
|
998
|
-
if (variant.kind === "compound") {
|
|
999
|
-
let result2 = applyVariant(node, variant.variant, variants);
|
|
1000
|
-
if (result2 === null)
|
|
1001
|
-
return null;
|
|
1002
|
-
for (let child of node.nodes) {
|
|
1003
|
-
let result3 = applyVariantFn(child, variant);
|
|
1004
|
-
if (result3 === null)
|
|
1005
|
-
return null;
|
|
512
|
+
let completions = design.utilities.getCompletions(utility);
|
|
513
|
+
for (let group of completions) {
|
|
514
|
+
for (let value of group.values) {
|
|
515
|
+
let name = value === null ? utility : `${utility}-${value}`;
|
|
516
|
+
list.push([name, { modifiers: group.modifiers }]);
|
|
517
|
+
if (group.supportsNegative) {
|
|
518
|
+
list.push([`-${name}`, { modifiers: group.modifiers }]);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
1006
521
|
}
|
|
1007
|
-
return;
|
|
1008
522
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
return null;
|
|
523
|
+
list.sort((a, b) => a[0].localeCompare(b[0]));
|
|
524
|
+
return list;
|
|
1012
525
|
}
|
|
1013
|
-
function
|
|
1014
|
-
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
526
|
+
function getVariants(design) {
|
|
527
|
+
let list = [];
|
|
528
|
+
let parsedVariants = new DefaultMap(
|
|
529
|
+
(variant, map) => parseVariant(variant, design.variants, map)
|
|
530
|
+
);
|
|
531
|
+
for (let [root, variant] of design.variants.entries()) {
|
|
532
|
+
let selectors2 = function({ value, modifier } = {}) {
|
|
533
|
+
let name = root;
|
|
534
|
+
if (value)
|
|
535
|
+
name += `-${value}`;
|
|
536
|
+
if (modifier)
|
|
537
|
+
name += `/${modifier}`;
|
|
538
|
+
let variant2 = parsedVariants.get(name);
|
|
539
|
+
if (!variant2)
|
|
540
|
+
return [];
|
|
541
|
+
let node = rule(".__placeholder__", [decl("color", "red")]);
|
|
542
|
+
if (applyVariant(node, variant2, design.variants) === null) {
|
|
543
|
+
return [];
|
|
1030
544
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
});
|
|
1036
|
-
next:
|
|
1037
|
-
for (let [candidate, rawCandidate] of candidates) {
|
|
1038
|
-
let ruleNodes = [];
|
|
1039
|
-
if (candidate.kind === "arbitrary") {
|
|
1040
|
-
ruleNodes = [decl(candidate.property, candidate.value)];
|
|
1041
|
-
} else if (candidate.kind === "static" || candidate.kind === "functional") {
|
|
1042
|
-
let { matchFn } = designSystem.utilities.get(candidate.root);
|
|
1043
|
-
let matchNodes = matchFn(candidate);
|
|
1044
|
-
if (matchNodes === void 0) {
|
|
1045
|
-
if (throwOnInvalidCandidate) {
|
|
1046
|
-
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
1047
|
-
} else {
|
|
1048
|
-
continue next;
|
|
1049
|
-
}
|
|
545
|
+
let selectors3 = [];
|
|
546
|
+
for (let child of node.nodes) {
|
|
547
|
+
if (child.kind === "rule") {
|
|
548
|
+
selectors3.push(child.selector);
|
|
1050
549
|
}
|
|
1051
|
-
ruleNodes = matchNodes;
|
|
1052
550
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
551
|
+
return selectors3;
|
|
552
|
+
};
|
|
553
|
+
if (variant.kind === "arbitrary")
|
|
554
|
+
continue;
|
|
555
|
+
let values = design.variants.getCompletions(root);
|
|
556
|
+
switch (variant.kind) {
|
|
557
|
+
case "static": {
|
|
558
|
+
list.push({
|
|
559
|
+
name: root,
|
|
560
|
+
values,
|
|
561
|
+
isArbitrary: false,
|
|
562
|
+
hasDash: true,
|
|
563
|
+
selectors: selectors2
|
|
564
|
+
});
|
|
565
|
+
break;
|
|
1056
566
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
if (throwOnInvalidCandidate) {
|
|
1067
|
-
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
1068
|
-
} else {
|
|
1069
|
-
continue next;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
variantOrder |= 1n << BigInt(variants.indexOf(variant));
|
|
567
|
+
case "functional": {
|
|
568
|
+
list.push({
|
|
569
|
+
name: root,
|
|
570
|
+
values,
|
|
571
|
+
isArbitrary: true,
|
|
572
|
+
hasDash: true,
|
|
573
|
+
selectors: selectors2
|
|
574
|
+
});
|
|
575
|
+
break;
|
|
1073
576
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
let zSorting = nodeSorting.get(z);
|
|
1084
|
-
if (aSorting.variants - zSorting.variants !== 0n) {
|
|
1085
|
-
return Number(aSorting.variants - zSorting.variants);
|
|
1086
|
-
}
|
|
1087
|
-
let offset = 0;
|
|
1088
|
-
while (aSorting.properties.length < offset && zSorting.properties.length < offset && aSorting.properties[offset] === zSorting.properties[offset]) {
|
|
1089
|
-
offset += 1;
|
|
1090
|
-
}
|
|
1091
|
-
return (
|
|
1092
|
-
// Sort by lowest property index first
|
|
1093
|
-
(aSorting.properties[offset] ?? Infinity) - (zSorting.properties[offset] ?? Infinity) || // Sort by most properties first, then by least properties
|
|
1094
|
-
zSorting.properties.length - aSorting.properties.length
|
|
1095
|
-
);
|
|
1096
|
-
});
|
|
1097
|
-
return {
|
|
1098
|
-
astNodes,
|
|
1099
|
-
nodeSorting
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
function getPropertySort(nodes) {
|
|
1103
|
-
let propertySort = /* @__PURE__ */ new Set();
|
|
1104
|
-
let q = nodes.slice();
|
|
1105
|
-
next:
|
|
1106
|
-
while (q.length > 0) {
|
|
1107
|
-
let node = q.shift();
|
|
1108
|
-
if (node.kind === "declaration") {
|
|
1109
|
-
if (node.property === "--tw-sort") {
|
|
1110
|
-
let idx2 = property_order_default.indexOf(node.value);
|
|
1111
|
-
if (idx2 !== -1) {
|
|
1112
|
-
propertySort.add(idx2);
|
|
1113
|
-
break next;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
let idx = property_order_default.indexOf(node.property);
|
|
1117
|
-
if (idx !== -1)
|
|
1118
|
-
propertySort.add(idx);
|
|
1119
|
-
} else if (node.kind === "rule") {
|
|
1120
|
-
if (node.selector === "@at-root")
|
|
1121
|
-
continue;
|
|
1122
|
-
for (let child of node.nodes) {
|
|
1123
|
-
q.push(child);
|
|
1124
|
-
}
|
|
577
|
+
case "compound": {
|
|
578
|
+
list.push({
|
|
579
|
+
name: root,
|
|
580
|
+
values,
|
|
581
|
+
isArbitrary: true,
|
|
582
|
+
hasDash: true,
|
|
583
|
+
selectors: selectors2
|
|
584
|
+
});
|
|
585
|
+
break;
|
|
1125
586
|
}
|
|
1126
587
|
}
|
|
1127
|
-
|
|
588
|
+
}
|
|
589
|
+
return list;
|
|
1128
590
|
}
|
|
1129
591
|
|
|
1130
592
|
// src/sort.ts
|
|
1131
593
|
function getClassOrder(design, classes) {
|
|
1132
|
-
let { astNodes, nodeSorting } =
|
|
594
|
+
let { astNodes, nodeSorting } = compileCandidates(Array.from(classes), design, {
|
|
1133
595
|
throwOnInvalidCandidate: false
|
|
1134
596
|
});
|
|
1135
597
|
let sorted = new Map(classes.map((className) => [className, null]));
|
|
@@ -1534,13 +996,18 @@ function replaceShadowColors(input, replacement) {
|
|
|
1534
996
|
}
|
|
1535
997
|
|
|
1536
998
|
// src/utilities.ts
|
|
999
|
+
var ARBITRARY_VARIANT = Symbol("ARBITRARY_VARIANT");
|
|
1537
1000
|
var Utilities = class {
|
|
1538
1001
|
utilities = /* @__PURE__ */ new Map();
|
|
1539
|
-
|
|
1540
|
-
|
|
1002
|
+
completions = /* @__PURE__ */ new Map();
|
|
1003
|
+
static(name, compileFn) {
|
|
1004
|
+
this.set(name, { kind: "static", compileFn });
|
|
1541
1005
|
}
|
|
1542
|
-
functional(name,
|
|
1543
|
-
this.set(name, { kind: "functional",
|
|
1006
|
+
functional(name, compileFn) {
|
|
1007
|
+
this.set(name, { kind: "functional", compileFn });
|
|
1008
|
+
}
|
|
1009
|
+
arbitrary(compileFn) {
|
|
1010
|
+
this.set(ARBITRARY_VARIANT, { kind: "arbitrary", compileFn });
|
|
1544
1011
|
}
|
|
1545
1012
|
has(name) {
|
|
1546
1013
|
return this.utilities.has(name);
|
|
@@ -1551,13 +1018,25 @@ var Utilities = class {
|
|
|
1551
1018
|
kind(name) {
|
|
1552
1019
|
return this.utilities.get(name).kind;
|
|
1553
1020
|
}
|
|
1021
|
+
getCompletions(name) {
|
|
1022
|
+
return this.completions.get(name)?.() ?? [];
|
|
1023
|
+
}
|
|
1024
|
+
suggest(name, groups) {
|
|
1025
|
+
this.completions.set(name, groups);
|
|
1026
|
+
}
|
|
1554
1027
|
keys() {
|
|
1555
1028
|
return this.utilities.keys();
|
|
1556
1029
|
}
|
|
1557
|
-
|
|
1030
|
+
entries() {
|
|
1031
|
+
return this.utilities.entries();
|
|
1032
|
+
}
|
|
1033
|
+
getArbitrary() {
|
|
1034
|
+
return this.get(ARBITRARY_VARIANT).compileFn;
|
|
1035
|
+
}
|
|
1036
|
+
set(name, { kind, compileFn }) {
|
|
1558
1037
|
this.utilities.set(name, {
|
|
1559
1038
|
kind,
|
|
1560
|
-
|
|
1039
|
+
compileFn
|
|
1561
1040
|
});
|
|
1562
1041
|
}
|
|
1563
1042
|
};
|
|
@@ -1577,19 +1056,17 @@ function property(ident, initialValue, syntax) {
|
|
|
1577
1056
|
]);
|
|
1578
1057
|
}
|
|
1579
1058
|
function withAlpha(value, alpha) {
|
|
1580
|
-
if (alpha === null)
|
|
1059
|
+
if (alpha === null)
|
|
1581
1060
|
return value;
|
|
1582
|
-
}
|
|
1583
1061
|
let alphaAsNumber = Number(alpha);
|
|
1584
|
-
if (!isNaN(alphaAsNumber)) {
|
|
1062
|
+
if (!Number.isNaN(alphaAsNumber)) {
|
|
1585
1063
|
alpha = `${alphaAsNumber * 100}%`;
|
|
1586
1064
|
}
|
|
1587
1065
|
return `color-mix(in srgb, ${value} ${alpha}, transparent)`;
|
|
1588
1066
|
}
|
|
1589
1067
|
function asColor(value, modifier, theme) {
|
|
1590
|
-
if (!modifier)
|
|
1068
|
+
if (!modifier)
|
|
1591
1069
|
return value;
|
|
1592
|
-
}
|
|
1593
1070
|
if (modifier.kind === "arbitrary") {
|
|
1594
1071
|
return withAlpha(value, modifier.value);
|
|
1595
1072
|
}
|
|
@@ -1597,6 +1074,9 @@ function asColor(value, modifier, theme) {
|
|
|
1597
1074
|
if (alpha) {
|
|
1598
1075
|
return withAlpha(value, alpha);
|
|
1599
1076
|
}
|
|
1077
|
+
if (Number.isNaN(Number(modifier.value))) {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1600
1080
|
return withAlpha(value, `${modifier.value}%`);
|
|
1601
1081
|
}
|
|
1602
1082
|
function withNegative(value, candidate) {
|
|
@@ -1622,11 +1102,45 @@ function resolveThemeColor(candidate, theme, themeKeys) {
|
|
|
1622
1102
|
}
|
|
1623
1103
|
function createUtilities(theme) {
|
|
1624
1104
|
let utilities = new Utilities();
|
|
1105
|
+
utilities.arbitrary((candidate) => {
|
|
1106
|
+
let value = candidate.value;
|
|
1107
|
+
if (candidate.modifier) {
|
|
1108
|
+
value = asColor(value, candidate.modifier, theme);
|
|
1109
|
+
}
|
|
1110
|
+
if (value === null)
|
|
1111
|
+
return;
|
|
1112
|
+
return [decl(candidate.property, value)];
|
|
1113
|
+
});
|
|
1114
|
+
function suggest(classRoot, defns) {
|
|
1115
|
+
function* resolve(themeKeys) {
|
|
1116
|
+
for (let value of theme.keysInNamespaces(themeKeys)) {
|
|
1117
|
+
yield value.replaceAll("_", ".");
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
utilities.suggest(classRoot, () => {
|
|
1121
|
+
let groups = [];
|
|
1122
|
+
for (let defn of defns()) {
|
|
1123
|
+
if (typeof defn === "string") {
|
|
1124
|
+
groups.push({ values: [defn], modifiers: [] });
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
let values = [
|
|
1128
|
+
...defn.values ?? [],
|
|
1129
|
+
...resolve(defn.valueThemeKeys ?? [])
|
|
1130
|
+
];
|
|
1131
|
+
let modifiers = [...defn.modifiers ?? [], ...resolve(defn.modifierThemeKeys ?? [])];
|
|
1132
|
+
if (defn.hasDefaultValue) {
|
|
1133
|
+
values.unshift(null);
|
|
1134
|
+
}
|
|
1135
|
+
groups.push({ supportsNegative: defn.supportsNegative, values, modifiers });
|
|
1136
|
+
}
|
|
1137
|
+
return groups;
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1625
1140
|
function staticUtility(className, declarations) {
|
|
1626
1141
|
utilities.static(className, (candidate) => {
|
|
1627
|
-
if (candidate.negative)
|
|
1142
|
+
if (candidate.negative)
|
|
1628
1143
|
return;
|
|
1629
|
-
}
|
|
1630
1144
|
return declarations.map((node) => {
|
|
1631
1145
|
return typeof node === "function" ? node() : decl(node[0], node[1]);
|
|
1632
1146
|
});
|
|
@@ -1643,17 +1157,24 @@ function createUtilities(theme) {
|
|
|
1643
1157
|
value = candidate.value.value;
|
|
1644
1158
|
} else {
|
|
1645
1159
|
value = theme.resolve(candidate.value.fraction ?? candidate.value.value, desc.themeKeys);
|
|
1646
|
-
if (
|
|
1160
|
+
if (value === null && desc.supportsFractions && candidate.value.fraction) {
|
|
1647
1161
|
value = `calc(${candidate.value.fraction} * 100%)`;
|
|
1648
1162
|
}
|
|
1649
|
-
if (
|
|
1163
|
+
if (value === null && desc.handleBareValue) {
|
|
1650
1164
|
value = desc.handleBareValue(candidate.value);
|
|
1651
1165
|
}
|
|
1652
1166
|
}
|
|
1653
|
-
if (
|
|
1167
|
+
if (value === null)
|
|
1654
1168
|
return;
|
|
1655
1169
|
return desc.handle(withNegative(value, candidate));
|
|
1656
1170
|
});
|
|
1171
|
+
suggest(classRoot, () => [
|
|
1172
|
+
{
|
|
1173
|
+
supportsNegative: desc.supportsNegative,
|
|
1174
|
+
valueThemeKeys: desc.themeKeys,
|
|
1175
|
+
hasDefaultValue: desc.defaultValue !== void 0 && desc.defaultValue !== null
|
|
1176
|
+
}
|
|
1177
|
+
]);
|
|
1657
1178
|
}
|
|
1658
1179
|
function colorUtility(classRoot, desc) {
|
|
1659
1180
|
utilities.functional(classRoot, (candidate) => {
|
|
@@ -1667,11 +1188,19 @@ function createUtilities(theme) {
|
|
|
1667
1188
|
value = asColor(value, candidate.modifier, theme);
|
|
1668
1189
|
} else {
|
|
1669
1190
|
value = resolveThemeColor(candidate, theme, desc.themeKeys);
|
|
1670
|
-
if (!value)
|
|
1671
|
-
return;
|
|
1672
1191
|
}
|
|
1192
|
+
if (value === null)
|
|
1193
|
+
return;
|
|
1673
1194
|
return desc.handle(value);
|
|
1674
1195
|
});
|
|
1196
|
+
suggest(classRoot, () => [
|
|
1197
|
+
{
|
|
1198
|
+
values: ["current", "transparent"],
|
|
1199
|
+
valueThemeKeys: desc.themeKeys,
|
|
1200
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
1201
|
+
modifierThemeKeys: ["--opacity"]
|
|
1202
|
+
}
|
|
1203
|
+
]);
|
|
1675
1204
|
}
|
|
1676
1205
|
staticUtility("sr-only", [
|
|
1677
1206
|
["position", "absolute"],
|
|
@@ -1828,6 +1357,13 @@ function createUtilities(theme) {
|
|
|
1828
1357
|
themeKeys: ["--z-index"],
|
|
1829
1358
|
handle: (value) => [decl("z-index", value)]
|
|
1830
1359
|
});
|
|
1360
|
+
suggest("z", () => [
|
|
1361
|
+
{
|
|
1362
|
+
supportsNegative: true,
|
|
1363
|
+
values: ["0", "10", "20", "30", "40", "50"],
|
|
1364
|
+
valueThemeKeys: ["--z-index"]
|
|
1365
|
+
}
|
|
1366
|
+
]);
|
|
1831
1367
|
staticUtility("order-first", [["order", "calc(-infinity)"]]);
|
|
1832
1368
|
staticUtility("order-last", [["order", "calc(infinity)"]]);
|
|
1833
1369
|
staticUtility("order-none", [["order", "0"]]);
|
|
@@ -1837,6 +1373,13 @@ function createUtilities(theme) {
|
|
|
1837
1373
|
themeKeys: ["--order"],
|
|
1838
1374
|
handle: (value) => [decl("order", value)]
|
|
1839
1375
|
});
|
|
1376
|
+
suggest("order", () => [
|
|
1377
|
+
{
|
|
1378
|
+
supportsNegative: true,
|
|
1379
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
1380
|
+
valueThemeKeys: ["--order"]
|
|
1381
|
+
}
|
|
1382
|
+
]);
|
|
1840
1383
|
staticUtility("col-auto", [["grid-column", "auto"]]);
|
|
1841
1384
|
functionalUtility("col", {
|
|
1842
1385
|
themeKeys: ["--grid-column"],
|
|
@@ -1860,6 +1403,24 @@ function createUtilities(theme) {
|
|
|
1860
1403
|
themeKeys: ["--grid-column-end"],
|
|
1861
1404
|
handle: (value) => [decl("grid-column-end", value)]
|
|
1862
1405
|
});
|
|
1406
|
+
suggest("col-span", () => [
|
|
1407
|
+
{
|
|
1408
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
1409
|
+
valueThemeKeys: []
|
|
1410
|
+
}
|
|
1411
|
+
]);
|
|
1412
|
+
suggest("col-start", () => [
|
|
1413
|
+
{
|
|
1414
|
+
values: Array.from({ length: 13 }, (_, i) => `${i + 1}`),
|
|
1415
|
+
valueThemeKeys: ["--grid-column-start"]
|
|
1416
|
+
}
|
|
1417
|
+
]);
|
|
1418
|
+
suggest("col-end", () => [
|
|
1419
|
+
{
|
|
1420
|
+
values: Array.from({ length: 13 }, (_, i) => `${i + 1}`),
|
|
1421
|
+
valueThemeKeys: ["--grid-column-end"]
|
|
1422
|
+
}
|
|
1423
|
+
]);
|
|
1863
1424
|
staticUtility("row-auto", [["grid-row", "auto"]]);
|
|
1864
1425
|
functionalUtility("row", {
|
|
1865
1426
|
themeKeys: ["--grid-row"],
|
|
@@ -1883,6 +1444,24 @@ function createUtilities(theme) {
|
|
|
1883
1444
|
themeKeys: ["--grid-row-end"],
|
|
1884
1445
|
handle: (value) => [decl("grid-row-end", value)]
|
|
1885
1446
|
});
|
|
1447
|
+
suggest("row-span", () => [
|
|
1448
|
+
{
|
|
1449
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
1450
|
+
valueThemeKeys: []
|
|
1451
|
+
}
|
|
1452
|
+
]);
|
|
1453
|
+
suggest("row-start", () => [
|
|
1454
|
+
{
|
|
1455
|
+
values: Array.from({ length: 13 }, (_, i) => `${i + 1}`),
|
|
1456
|
+
valueThemeKeys: ["--grid-row-start"]
|
|
1457
|
+
}
|
|
1458
|
+
]);
|
|
1459
|
+
suggest("row-end", () => [
|
|
1460
|
+
{
|
|
1461
|
+
values: Array.from({ length: 13 }, (_, i) => `${i + 1}`),
|
|
1462
|
+
valueThemeKeys: ["--grid-row-end"]
|
|
1463
|
+
}
|
|
1464
|
+
]);
|
|
1886
1465
|
staticUtility("float-start", [["float", "start"]]);
|
|
1887
1466
|
staticUtility("float-end", [["float", "end"]]);
|
|
1888
1467
|
staticUtility("float-right", [["float", "right"]]);
|
|
@@ -1936,6 +1515,12 @@ function createUtilities(theme) {
|
|
|
1936
1515
|
decl("-webkit-line-clamp", value)
|
|
1937
1516
|
]
|
|
1938
1517
|
});
|
|
1518
|
+
suggest("line-clamp", () => [
|
|
1519
|
+
{
|
|
1520
|
+
values: ["1", "2", "3", "4", "5", "6"],
|
|
1521
|
+
valueThemeKeys: ["--line-clamp"]
|
|
1522
|
+
}
|
|
1523
|
+
]);
|
|
1939
1524
|
staticUtility("block", [["display", "block"]]);
|
|
1940
1525
|
staticUtility("inline-block", [["display", "inline-block"]]);
|
|
1941
1526
|
staticUtility("inline", [["display", "inline"]]);
|
|
@@ -2107,6 +1692,20 @@ function createUtilities(theme) {
|
|
|
2107
1692
|
handleBareValue: ({ value }) => value,
|
|
2108
1693
|
handle: (value) => [decl("flex-grow", value)]
|
|
2109
1694
|
});
|
|
1695
|
+
suggest("shrink", () => [
|
|
1696
|
+
{
|
|
1697
|
+
values: ["0"],
|
|
1698
|
+
valueThemeKeys: [],
|
|
1699
|
+
hasDefaultValue: true
|
|
1700
|
+
}
|
|
1701
|
+
]);
|
|
1702
|
+
suggest("grow", () => [
|
|
1703
|
+
{
|
|
1704
|
+
values: ["0"],
|
|
1705
|
+
valueThemeKeys: [],
|
|
1706
|
+
hasDefaultValue: true
|
|
1707
|
+
}
|
|
1708
|
+
]);
|
|
2110
1709
|
staticUtility("basis-auto", [["flex-basis", "auto"]]);
|
|
2111
1710
|
staticUtility("basis-full", [["flex-basis", "100%"]]);
|
|
2112
1711
|
functionalUtility("basis", {
|
|
@@ -2183,7 +1782,7 @@ function createUtilities(theme) {
|
|
|
2183
1782
|
translateProperties(),
|
|
2184
1783
|
decl("--tw-translate-x", value),
|
|
2185
1784
|
decl("--tw-translate-y", value),
|
|
2186
|
-
decl("translate",
|
|
1785
|
+
decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
|
|
2187
1786
|
]
|
|
2188
1787
|
});
|
|
2189
1788
|
utilities.static("translate-x-full", (candidate) => {
|
|
@@ -2201,7 +1800,7 @@ function createUtilities(theme) {
|
|
|
2201
1800
|
handle: (value) => [
|
|
2202
1801
|
translateProperties(),
|
|
2203
1802
|
decl("--tw-translate-x", value),
|
|
2204
|
-
decl("translate",
|
|
1803
|
+
decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
|
|
2205
1804
|
]
|
|
2206
1805
|
});
|
|
2207
1806
|
utilities.static("translate-y-full", (candidate) => {
|
|
@@ -2219,7 +1818,7 @@ function createUtilities(theme) {
|
|
|
2219
1818
|
handle: (value) => [
|
|
2220
1819
|
translateProperties(),
|
|
2221
1820
|
decl("--tw-translate-y", value),
|
|
2222
|
-
decl("translate",
|
|
1821
|
+
decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
|
|
2223
1822
|
]
|
|
2224
1823
|
});
|
|
2225
1824
|
functionalUtility("rotate", {
|
|
@@ -2228,6 +1827,13 @@ function createUtilities(theme) {
|
|
|
2228
1827
|
handleBareValue: ({ value }) => `${value}deg`,
|
|
2229
1828
|
handle: (value) => [decl("rotate", value)]
|
|
2230
1829
|
});
|
|
1830
|
+
suggest("rotate", () => [
|
|
1831
|
+
{
|
|
1832
|
+
supportsNegative: true,
|
|
1833
|
+
values: ["0", "1", "2", "3", "6", "12", "45", "90", "180"],
|
|
1834
|
+
valueThemeKeys: ["--rotate"]
|
|
1835
|
+
}
|
|
1836
|
+
]);
|
|
2231
1837
|
let skewProperties = () => atRoot([property("--tw-skew-x", "0deg", "<angle>"), property("--tw-skew-y", "0deg", "<angle>")]);
|
|
2232
1838
|
functionalUtility("skew", {
|
|
2233
1839
|
supportsNegative: true,
|
|
@@ -2260,6 +1866,27 @@ function createUtilities(theme) {
|
|
|
2260
1866
|
decl("transform", "skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))")
|
|
2261
1867
|
]
|
|
2262
1868
|
});
|
|
1869
|
+
suggest("skew", () => [
|
|
1870
|
+
{
|
|
1871
|
+
supportsNegative: true,
|
|
1872
|
+
values: ["0", "1", "2", "3", "6", "12"],
|
|
1873
|
+
valueThemeKeys: ["--skew"]
|
|
1874
|
+
}
|
|
1875
|
+
]);
|
|
1876
|
+
suggest("skew-x", () => [
|
|
1877
|
+
{
|
|
1878
|
+
supportsNegative: true,
|
|
1879
|
+
values: ["0", "1", "2", "3", "6", "12"],
|
|
1880
|
+
valueThemeKeys: ["--skew"]
|
|
1881
|
+
}
|
|
1882
|
+
]);
|
|
1883
|
+
suggest("skew-y", () => [
|
|
1884
|
+
{
|
|
1885
|
+
supportsNegative: true,
|
|
1886
|
+
values: ["0", "1", "2", "3", "6", "12"],
|
|
1887
|
+
valueThemeKeys: ["--skew"]
|
|
1888
|
+
}
|
|
1889
|
+
]);
|
|
2263
1890
|
let scaleProperties = () => atRoot([property("--tw-scale-x", "1", "<number>"), property("--tw-scale-y", "1", "<number>")]);
|
|
2264
1891
|
functionalUtility("scale", {
|
|
2265
1892
|
supportsNegative: true,
|
|
@@ -2292,6 +1919,27 @@ function createUtilities(theme) {
|
|
|
2292
1919
|
decl("scale", "var(--tw-scale-x) var(--tw-scale-y)")
|
|
2293
1920
|
]
|
|
2294
1921
|
});
|
|
1922
|
+
suggest("scale", () => [
|
|
1923
|
+
{
|
|
1924
|
+
supportsNegative: true,
|
|
1925
|
+
values: ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"],
|
|
1926
|
+
valueThemeKeys: ["--scale"]
|
|
1927
|
+
}
|
|
1928
|
+
]);
|
|
1929
|
+
suggest("scale-x", () => [
|
|
1930
|
+
{
|
|
1931
|
+
supportsNegative: true,
|
|
1932
|
+
values: ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"],
|
|
1933
|
+
valueThemeKeys: ["--scale"]
|
|
1934
|
+
}
|
|
1935
|
+
]);
|
|
1936
|
+
suggest("scale-y", () => [
|
|
1937
|
+
{
|
|
1938
|
+
supportsNegative: true,
|
|
1939
|
+
values: ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"],
|
|
1940
|
+
valueThemeKeys: ["--scale"]
|
|
1941
|
+
}
|
|
1942
|
+
]);
|
|
2295
1943
|
staticUtility("transform", [
|
|
2296
1944
|
skewProperties,
|
|
2297
1945
|
["transform", "skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))"]
|
|
@@ -2377,11 +2025,11 @@ function createUtilities(theme) {
|
|
|
2377
2025
|
["user-select", value]
|
|
2378
2026
|
]);
|
|
2379
2027
|
}
|
|
2380
|
-
staticUtility(
|
|
2381
|
-
staticUtility(
|
|
2382
|
-
staticUtility(
|
|
2383
|
-
staticUtility(
|
|
2384
|
-
staticUtility(
|
|
2028
|
+
staticUtility("resize-none", [["resize", "none"]]);
|
|
2029
|
+
staticUtility("resize-both", [["resize", "both"]]);
|
|
2030
|
+
staticUtility("resize-x", [["resize", "horizontal"]]);
|
|
2031
|
+
staticUtility("resize-y", [["resize", "vertical"]]);
|
|
2032
|
+
staticUtility("snap-none", [["scroll-snap-type", "none"]]);
|
|
2385
2033
|
let snapProperties = () => atRoot([property("--tw-scroll-snap-strictness", "proximity", "*")]);
|
|
2386
2034
|
for (let value of ["x", "y", "both"]) {
|
|
2387
2035
|
staticUtility(`snap-${value}`, [
|
|
@@ -2389,8 +2037,8 @@ function createUtilities(theme) {
|
|
|
2389
2037
|
["scroll-snap-type", `${value} var(--tw-scroll-snap-strictness)`]
|
|
2390
2038
|
]);
|
|
2391
2039
|
}
|
|
2392
|
-
staticUtility(
|
|
2393
|
-
staticUtility(
|
|
2040
|
+
staticUtility("snap-mandatory", [snapProperties, ["--tw-scroll-snap-strictness", "mandatory"]]);
|
|
2041
|
+
staticUtility("snap-proximity", [snapProperties, ["--tw-scroll-snap-strictness", "proximity"]]);
|
|
2394
2042
|
staticUtility("snap-align-none", [["scroll-snap-align", "none"]]);
|
|
2395
2043
|
staticUtility("snap-start", [["scroll-snap-align", "start"]]);
|
|
2396
2044
|
staticUtility("snap-end", [["scroll-snap-align", "end"]]);
|
|
@@ -2509,6 +2157,12 @@ function createUtilities(theme) {
|
|
|
2509
2157
|
handleBareValue: ({ value }) => value,
|
|
2510
2158
|
handle: (value) => [decl("columns", value)]
|
|
2511
2159
|
});
|
|
2160
|
+
suggest("columns", () => [
|
|
2161
|
+
{
|
|
2162
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
2163
|
+
valueThemeKeys: ["--columns", "--width"]
|
|
2164
|
+
}
|
|
2165
|
+
]);
|
|
2512
2166
|
for (let value of ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"]) {
|
|
2513
2167
|
staticUtility(`break-before-${value}`, [["break-before", value]]);
|
|
2514
2168
|
}
|
|
@@ -2553,6 +2207,18 @@ function createUtilities(theme) {
|
|
|
2553
2207
|
handleBareValue: ({ value }) => `repeat(${value}, minmax(0, 1fr))`,
|
|
2554
2208
|
handle: (value) => [decl("grid-template-rows", value)]
|
|
2555
2209
|
});
|
|
2210
|
+
suggest("grid-cols", () => [
|
|
2211
|
+
{
|
|
2212
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
2213
|
+
valueThemeKeys: ["--grid-template-columns"]
|
|
2214
|
+
}
|
|
2215
|
+
]);
|
|
2216
|
+
suggest("grid-rows", () => [
|
|
2217
|
+
{
|
|
2218
|
+
values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
|
|
2219
|
+
valueThemeKeys: ["--grid-template-rows"]
|
|
2220
|
+
}
|
|
2221
|
+
]);
|
|
2556
2222
|
staticUtility("flex-row", [["flex-direction", "row"]]);
|
|
2557
2223
|
staticUtility("flex-row-reverse", [["flex-direction", "row-reverse"]]);
|
|
2558
2224
|
staticUtility("flex-col", [["flex-direction", "column"]]);
|
|
@@ -2651,48 +2317,6 @@ function createUtilities(theme) {
|
|
|
2651
2317
|
decl("--tw-space-y-reverse", "1")
|
|
2652
2318
|
])
|
|
2653
2319
|
]);
|
|
2654
|
-
functionalUtility("divide-x", {
|
|
2655
|
-
defaultValue: theme.get(["--default-border-width"]) ?? "1px",
|
|
2656
|
-
themeKeys: ["--divide-width", "--border-width"],
|
|
2657
|
-
handleBareValue: ({ value }) => `${value}px`,
|
|
2658
|
-
handle: (value) => [
|
|
2659
|
-
atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
|
|
2660
|
-
rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2661
|
-
decl("--tw-sort", "divide-x-width"),
|
|
2662
|
-
decl("border-inline-end-width", `calc(${value} * var(--tw-divide-x-reverse))`),
|
|
2663
|
-
decl("border-inline-start-width", `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`)
|
|
2664
|
-
])
|
|
2665
|
-
]
|
|
2666
|
-
});
|
|
2667
|
-
functionalUtility("divide-y", {
|
|
2668
|
-
defaultValue: theme.get(["--default-border-width"]) ?? "1px",
|
|
2669
|
-
themeKeys: ["--divide-width", "--border-width"],
|
|
2670
|
-
handleBareValue: ({ value }) => `${value}px`,
|
|
2671
|
-
handle: (value) => [
|
|
2672
|
-
atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
|
|
2673
|
-
rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2674
|
-
decl("--tw-sort", "divide-y-width"),
|
|
2675
|
-
decl("border-bottom-width", `calc(${value} * var(--tw-divide-y-reverse))`),
|
|
2676
|
-
decl("border-top-width", `calc(${value} * calc(1 - var(--tw-divide-y-reverse)))`)
|
|
2677
|
-
])
|
|
2678
|
-
]
|
|
2679
|
-
});
|
|
2680
|
-
staticUtility("divide-x-reverse", [
|
|
2681
|
-
() => atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
|
|
2682
|
-
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-x-reverse", "1")])
|
|
2683
|
-
]);
|
|
2684
|
-
staticUtility("divide-y-reverse", [
|
|
2685
|
-
() => atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
|
|
2686
|
-
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-y-reverse", "1")])
|
|
2687
|
-
]);
|
|
2688
|
-
for (let value of ["solid", "dashed", "dotted", "double", "none"]) {
|
|
2689
|
-
staticUtility(`divide-${value}`, [
|
|
2690
|
-
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2691
|
-
decl("--tw-sort", "divide-style"),
|
|
2692
|
-
decl("border-style", value)
|
|
2693
|
-
])
|
|
2694
|
-
]);
|
|
2695
|
-
}
|
|
2696
2320
|
colorUtility("accent", {
|
|
2697
2321
|
themeKeys: ["--accent-color", "--color"],
|
|
2698
2322
|
handle: (value) => [decl("accent-color", value)]
|
|
@@ -2736,33 +2360,33 @@ function createUtilities(theme) {
|
|
|
2736
2360
|
staticUtility(`overscroll-x-${value}`, [["overscroll-behavior-x", value]]);
|
|
2737
2361
|
staticUtility(`overscroll-y-${value}`, [["overscroll-behavior-y", value]]);
|
|
2738
2362
|
}
|
|
2739
|
-
staticUtility(
|
|
2740
|
-
staticUtility(
|
|
2741
|
-
staticUtility(
|
|
2363
|
+
staticUtility("scroll-auto", [["scroll-behavior", "auto"]]);
|
|
2364
|
+
staticUtility("scroll-smooth", [["scroll-behavior", "smooth"]]);
|
|
2365
|
+
staticUtility("truncate", [
|
|
2742
2366
|
["overflow", "hidden"],
|
|
2743
2367
|
["text-overflow", "ellipsis"],
|
|
2744
2368
|
["white-space", "nowrap"]
|
|
2745
2369
|
]);
|
|
2746
|
-
staticUtility(
|
|
2747
|
-
staticUtility(
|
|
2748
|
-
staticUtility(
|
|
2370
|
+
staticUtility("text-ellipsis", [["text-overflow", "ellipsis"]]);
|
|
2371
|
+
staticUtility("text-clip", [["text-overflow", "clip"]]);
|
|
2372
|
+
staticUtility("hyphens-none", [
|
|
2749
2373
|
["-webkit-hyphens", "none"],
|
|
2750
2374
|
["hyphens", "none"]
|
|
2751
2375
|
]);
|
|
2752
|
-
staticUtility(
|
|
2376
|
+
staticUtility("hyphens-manual", [
|
|
2753
2377
|
["-webkit-hyphens", "manual"],
|
|
2754
2378
|
["hyphens", "manual"]
|
|
2755
2379
|
]);
|
|
2756
|
-
staticUtility(
|
|
2380
|
+
staticUtility("hyphens-auto", [
|
|
2757
2381
|
["-webkit-hyphens", "auto"],
|
|
2758
2382
|
["hyphens", "auto"]
|
|
2759
2383
|
]);
|
|
2760
|
-
staticUtility(
|
|
2761
|
-
staticUtility(
|
|
2762
|
-
staticUtility(
|
|
2763
|
-
staticUtility(
|
|
2764
|
-
staticUtility(
|
|
2765
|
-
staticUtility(
|
|
2384
|
+
staticUtility("whitespace-normal", [["white-space", "normal"]]);
|
|
2385
|
+
staticUtility("whitespace-nowrap", [["white-space", "nowrap"]]);
|
|
2386
|
+
staticUtility("whitespace-pre", [["white-space", "pre"]]);
|
|
2387
|
+
staticUtility("whitespace-pre-line", [["white-space", "pre-line"]]);
|
|
2388
|
+
staticUtility("whitespace-pre-wrap", [["white-space", "pre-wrap"]]);
|
|
2389
|
+
staticUtility("whitespace-break-spaces", [["white-space", "break-spaces"]]);
|
|
2766
2390
|
staticUtility("text-wrap", [["text-wrap", "wrap"]]);
|
|
2767
2391
|
staticUtility("text-nowrap", [["text-wrap", "nowrap"]]);
|
|
2768
2392
|
staticUtility("text-balance", [["text-wrap", "balance"]]);
|
|
@@ -2852,88 +2476,201 @@ function createUtilities(theme) {
|
|
|
2852
2476
|
themeKeys: ["--radius"],
|
|
2853
2477
|
handle: (value) => [decl("border-bottom-left-radius", value)]
|
|
2854
2478
|
});
|
|
2855
|
-
staticUtility("border-solid", [
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
staticUtility("border-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2479
|
+
staticUtility("border-solid", [
|
|
2480
|
+
["--tw-border-style", "solid"],
|
|
2481
|
+
["border-style", "solid"]
|
|
2482
|
+
]);
|
|
2483
|
+
staticUtility("border-dashed", [
|
|
2484
|
+
["--tw-border-style", "dashed"],
|
|
2485
|
+
["border-style", "dashed"]
|
|
2486
|
+
]);
|
|
2487
|
+
staticUtility("border-dotted", [
|
|
2488
|
+
["--tw-border-style", "dotted"],
|
|
2489
|
+
["border-style", "dotted"]
|
|
2490
|
+
]);
|
|
2491
|
+
staticUtility("border-double", [
|
|
2492
|
+
["--tw-border-style", "double"],
|
|
2493
|
+
["border-style", "double"]
|
|
2494
|
+
]);
|
|
2495
|
+
staticUtility("border-hidden", [
|
|
2496
|
+
["--tw-border-style", "hidden"],
|
|
2497
|
+
["border-style", "hidden"]
|
|
2498
|
+
]);
|
|
2499
|
+
staticUtility("border-none", [
|
|
2500
|
+
["--tw-border-style", "none"],
|
|
2501
|
+
["border-style", "none"]
|
|
2502
|
+
]);
|
|
2503
|
+
{
|
|
2504
|
+
let borderSideUtility2 = function(classRoot, desc) {
|
|
2505
|
+
utilities.functional(classRoot, (candidate) => {
|
|
2506
|
+
if (candidate.negative)
|
|
2507
|
+
return;
|
|
2508
|
+
if (!candidate.value) {
|
|
2509
|
+
let value = theme.get(["--default-border-width"]) ?? "1px";
|
|
2510
|
+
let decls = desc.width(value);
|
|
2511
|
+
if (!decls)
|
|
2512
|
+
return;
|
|
2513
|
+
return [borderProperties(), decl("border-style", "var(--tw-border-style)"), ...decls];
|
|
2514
|
+
}
|
|
2515
|
+
if (candidate.value.kind === "arbitrary") {
|
|
2516
|
+
let value = candidate.value.value;
|
|
2517
|
+
let type = candidate.value.dataType ?? inferDataType(value, ["color", "line-width", "length"]);
|
|
2518
|
+
switch (type) {
|
|
2519
|
+
case "line-width":
|
|
2520
|
+
case "length": {
|
|
2521
|
+
let decls = desc.width(value);
|
|
2522
|
+
if (!decls)
|
|
2523
|
+
return;
|
|
2524
|
+
return [borderProperties(), decl("border-style", "var(--tw-border-style)"), ...decls];
|
|
2525
|
+
}
|
|
2526
|
+
default: {
|
|
2527
|
+
value = asColor(value, candidate.modifier, theme);
|
|
2528
|
+
if (value === null)
|
|
2529
|
+
return;
|
|
2530
|
+
return desc.color(value);
|
|
2531
|
+
}
|
|
2877
2532
|
}
|
|
2878
|
-
|
|
2879
|
-
|
|
2533
|
+
}
|
|
2534
|
+
{
|
|
2535
|
+
let value = resolveThemeColor(candidate, theme, ["--border-color", "--color"]);
|
|
2536
|
+
if (value) {
|
|
2880
2537
|
return desc.color(value);
|
|
2881
2538
|
}
|
|
2882
2539
|
}
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2540
|
+
{
|
|
2541
|
+
let value = theme.resolve(candidate.value.value, ["--border-width"]);
|
|
2542
|
+
if (value) {
|
|
2543
|
+
let decls = desc.width(value);
|
|
2544
|
+
if (!decls)
|
|
2545
|
+
return;
|
|
2546
|
+
return [borderProperties(), decl("border-style", "var(--tw-border-style)"), ...decls];
|
|
2547
|
+
}
|
|
2548
|
+
if (!Number.isNaN(Number(candidate.value.value))) {
|
|
2549
|
+
let decls = desc.width(`${candidate.value.value}px`);
|
|
2550
|
+
if (!decls)
|
|
2551
|
+
return;
|
|
2552
|
+
return [borderProperties(), decl("border-style", "var(--tw-border-style)"), ...decls];
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
suggest(classRoot, () => [
|
|
2557
|
+
{
|
|
2558
|
+
values: ["current", "transparent"],
|
|
2559
|
+
valueThemeKeys: ["--border-color", "--color"],
|
|
2560
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
2561
|
+
modifierThemeKeys: ["--opacity"],
|
|
2562
|
+
hasDefaultValue: true
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
values: [],
|
|
2566
|
+
valueThemeKeys: ["--border-width"]
|
|
2888
2567
|
}
|
|
2568
|
+
]);
|
|
2569
|
+
};
|
|
2570
|
+
let borderProperties = () => {
|
|
2571
|
+
return atRoot([property("--tw-border-style", "solid", "<custom-ident>")]);
|
|
2572
|
+
};
|
|
2573
|
+
borderSideUtility2("border", {
|
|
2574
|
+
width: (value) => [decl("border-width", value)],
|
|
2575
|
+
color: (value) => [decl("border-color", value)]
|
|
2576
|
+
});
|
|
2577
|
+
borderSideUtility2("border-x", {
|
|
2578
|
+
width: (value) => [decl("border-left-width", value), decl("border-right-width", value)],
|
|
2579
|
+
color: (value) => [decl("border-left-color", value), decl("border-right-color", value)]
|
|
2580
|
+
});
|
|
2581
|
+
borderSideUtility2("border-y", {
|
|
2582
|
+
width: (value) => [decl("border-top-width", value), decl("border-bottom-width", value)],
|
|
2583
|
+
color: (value) => [decl("border-top-color", value), decl("border-bottom-color", value)]
|
|
2584
|
+
});
|
|
2585
|
+
borderSideUtility2("border-s", {
|
|
2586
|
+
width: (value) => [decl("border-inline-start-width", value)],
|
|
2587
|
+
color: (value) => [decl("border-inline-start-color", value)]
|
|
2588
|
+
});
|
|
2589
|
+
borderSideUtility2("border-e", {
|
|
2590
|
+
width: (value) => [decl("border-inline-end-width", value)],
|
|
2591
|
+
color: (value) => [decl("border-inline-end-color", value)]
|
|
2592
|
+
});
|
|
2593
|
+
borderSideUtility2("border-t", {
|
|
2594
|
+
width: (value) => [decl("border-top-width", value)],
|
|
2595
|
+
color: (value) => [decl("border-top-color", value)]
|
|
2596
|
+
});
|
|
2597
|
+
borderSideUtility2("border-r", {
|
|
2598
|
+
width: (value) => [decl("border-right-width", value)],
|
|
2599
|
+
color: (value) => [decl("border-right-color", value)]
|
|
2600
|
+
});
|
|
2601
|
+
borderSideUtility2("border-b", {
|
|
2602
|
+
width: (value) => [decl("border-bottom-width", value)],
|
|
2603
|
+
color: (value) => [decl("border-bottom-color", value)]
|
|
2604
|
+
});
|
|
2605
|
+
borderSideUtility2("border-l", {
|
|
2606
|
+
width: (value) => [decl("border-left-width", value)],
|
|
2607
|
+
color: (value) => [decl("border-left-color", value)]
|
|
2608
|
+
});
|
|
2609
|
+
functionalUtility("divide-x", {
|
|
2610
|
+
defaultValue: theme.get(["--default-border-width"]) ?? "1px",
|
|
2611
|
+
themeKeys: ["--divide-width", "--border-width"],
|
|
2612
|
+
handleBareValue: ({ value }) => `${value}px`,
|
|
2613
|
+
handle: (value) => [
|
|
2614
|
+
atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
|
|
2615
|
+
rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2616
|
+
decl("--tw-sort", "divide-x-width"),
|
|
2617
|
+
borderProperties(),
|
|
2618
|
+
decl("border-style", "var(--tw-border-style)"),
|
|
2619
|
+
decl("border-inline-end-width", `calc(${value} * var(--tw-divide-x-reverse))`),
|
|
2620
|
+
decl(
|
|
2621
|
+
"border-inline-start-width",
|
|
2622
|
+
`calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`
|
|
2623
|
+
)
|
|
2624
|
+
])
|
|
2625
|
+
]
|
|
2626
|
+
});
|
|
2627
|
+
functionalUtility("divide-y", {
|
|
2628
|
+
defaultValue: theme.get(["--default-border-width"]) ?? "1px",
|
|
2629
|
+
themeKeys: ["--divide-width", "--border-width"],
|
|
2630
|
+
handleBareValue: ({ value }) => `${value}px`,
|
|
2631
|
+
handle: (value) => [
|
|
2632
|
+
atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
|
|
2633
|
+
rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2634
|
+
decl("--tw-sort", "divide-y-width"),
|
|
2635
|
+
borderProperties(),
|
|
2636
|
+
decl("border-style", "var(--tw-border-style)"),
|
|
2637
|
+
decl("border-bottom-width", `calc(${value} * var(--tw-divide-y-reverse))`),
|
|
2638
|
+
decl("border-top-width", `calc(${value} * calc(1 - var(--tw-divide-y-reverse)))`)
|
|
2639
|
+
])
|
|
2640
|
+
]
|
|
2641
|
+
});
|
|
2642
|
+
suggest("divide-x", () => [
|
|
2643
|
+
{
|
|
2644
|
+
values: ["0", "2", "4", "8"],
|
|
2645
|
+
valueThemeKeys: ["--divide-width", "--border-width"],
|
|
2646
|
+
hasDefaultValue: true
|
|
2889
2647
|
}
|
|
2648
|
+
]);
|
|
2649
|
+
suggest("divide-y", () => [
|
|
2890
2650
|
{
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
}
|
|
2895
|
-
if (!isNaN(Number(candidate.value.value))) {
|
|
2896
|
-
return desc.width(`${candidate.value.value}px`);
|
|
2897
|
-
}
|
|
2651
|
+
values: ["0", "2", "4", "8"],
|
|
2652
|
+
valueThemeKeys: ["--divide-width", "--border-width"],
|
|
2653
|
+
hasDefaultValue: true
|
|
2898
2654
|
}
|
|
2899
|
-
|
|
2655
|
+
]);
|
|
2656
|
+
staticUtility("divide-x-reverse", [
|
|
2657
|
+
() => atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
|
|
2658
|
+
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-x-reverse", "1")])
|
|
2659
|
+
]);
|
|
2660
|
+
staticUtility("divide-y-reverse", [
|
|
2661
|
+
() => atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
|
|
2662
|
+
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-y-reverse", "1")])
|
|
2663
|
+
]);
|
|
2664
|
+
for (let value of ["solid", "dashed", "dotted", "double", "none"]) {
|
|
2665
|
+
staticUtility(`divide-${value}`, [
|
|
2666
|
+
() => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
|
|
2667
|
+
decl("--tw-sort", "divide-style"),
|
|
2668
|
+
decl("--tw-border-style", value),
|
|
2669
|
+
decl("border-style", value)
|
|
2670
|
+
])
|
|
2671
|
+
]);
|
|
2672
|
+
}
|
|
2900
2673
|
}
|
|
2901
|
-
borderSideUtility("border", {
|
|
2902
|
-
width: (value) => [decl("border-width", value)],
|
|
2903
|
-
color: (value) => [decl("border-color", value)]
|
|
2904
|
-
});
|
|
2905
|
-
borderSideUtility("border-x", {
|
|
2906
|
-
width: (value) => [decl("border-left-width", value), decl("border-right-width", value)],
|
|
2907
|
-
color: (value) => [decl("border-left-color", value), decl("border-right-color", value)]
|
|
2908
|
-
});
|
|
2909
|
-
borderSideUtility("border-y", {
|
|
2910
|
-
width: (value) => [decl("border-top-width", value), decl("border-bottom-width", value)],
|
|
2911
|
-
color: (value) => [decl("border-top-color", value), decl("border-bottom-color", value)]
|
|
2912
|
-
});
|
|
2913
|
-
borderSideUtility("border-s", {
|
|
2914
|
-
width: (value) => [decl("border-inline-start-width", value)],
|
|
2915
|
-
color: (value) => [decl("border-inline-start-color", value)]
|
|
2916
|
-
});
|
|
2917
|
-
borderSideUtility("border-e", {
|
|
2918
|
-
width: (value) => [decl("border-inline-end-width", value)],
|
|
2919
|
-
color: (value) => [decl("border-inline-end-color", value)]
|
|
2920
|
-
});
|
|
2921
|
-
borderSideUtility("border-t", {
|
|
2922
|
-
width: (value) => [decl("border-top-width", value)],
|
|
2923
|
-
color: (value) => [decl("border-top-color", value)]
|
|
2924
|
-
});
|
|
2925
|
-
borderSideUtility("border-r", {
|
|
2926
|
-
width: (value) => [decl("border-right-width", value)],
|
|
2927
|
-
color: (value) => [decl("border-right-color", value)]
|
|
2928
|
-
});
|
|
2929
|
-
borderSideUtility("border-b", {
|
|
2930
|
-
width: (value) => [decl("border-bottom-width", value)],
|
|
2931
|
-
color: (value) => [decl("border-bottom-color", value)]
|
|
2932
|
-
});
|
|
2933
|
-
borderSideUtility("border-l", {
|
|
2934
|
-
width: (value) => [decl("border-left-width", value)],
|
|
2935
|
-
color: (value) => [decl("border-left-color", value)]
|
|
2936
|
-
});
|
|
2937
2674
|
staticUtility("bg-inherit", [["background-color", "inherit"]]);
|
|
2938
2675
|
staticUtility("bg-transparent", [["background-color", "transparent"]]);
|
|
2939
2676
|
staticUtility("bg-auto", [["background-size", "auto"]]);
|
|
@@ -2973,9 +2710,8 @@ function createUtilities(theme) {
|
|
|
2973
2710
|
]);
|
|
2974
2711
|
}
|
|
2975
2712
|
utilities.functional("bg", (candidate) => {
|
|
2976
|
-
if (candidate.negative || !candidate.value)
|
|
2713
|
+
if (candidate.negative || !candidate.value)
|
|
2977
2714
|
return;
|
|
2978
|
-
}
|
|
2979
2715
|
if (candidate.value.kind === "arbitrary") {
|
|
2980
2716
|
let value = candidate.value.value;
|
|
2981
2717
|
let type = candidate.value.dataType ?? inferDataType(value, [
|
|
@@ -3003,6 +2739,8 @@ function createUtilities(theme) {
|
|
|
3003
2739
|
}
|
|
3004
2740
|
default: {
|
|
3005
2741
|
value = asColor(value, candidate.modifier, theme);
|
|
2742
|
+
if (value === null)
|
|
2743
|
+
return;
|
|
3006
2744
|
return [decl("background-color", value)];
|
|
3007
2745
|
}
|
|
3008
2746
|
}
|
|
@@ -3020,6 +2758,18 @@ function createUtilities(theme) {
|
|
|
3020
2758
|
}
|
|
3021
2759
|
}
|
|
3022
2760
|
});
|
|
2761
|
+
suggest("bg", () => [
|
|
2762
|
+
{
|
|
2763
|
+
values: ["current", "transparent"],
|
|
2764
|
+
valueThemeKeys: ["--background-color", "--color"],
|
|
2765
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
2766
|
+
modifierThemeKeys: ["--opacity"]
|
|
2767
|
+
},
|
|
2768
|
+
{
|
|
2769
|
+
values: [],
|
|
2770
|
+
valueThemeKeys: ["--background-image"]
|
|
2771
|
+
}
|
|
2772
|
+
]);
|
|
3023
2773
|
let gradientStopProperties = () => {
|
|
3024
2774
|
return atRoot([
|
|
3025
2775
|
property("--tw-gradient-from", "#0000", "<color>"),
|
|
@@ -3036,9 +2786,8 @@ function createUtilities(theme) {
|
|
|
3036
2786
|
};
|
|
3037
2787
|
function gradientStopUtility(classRoot, desc) {
|
|
3038
2788
|
utilities.functional(classRoot, (candidate) => {
|
|
3039
|
-
if (candidate.negative || !candidate.value)
|
|
2789
|
+
if (candidate.negative || !candidate.value)
|
|
3040
2790
|
return;
|
|
3041
|
-
}
|
|
3042
2791
|
if (candidate.value.kind === "arbitrary") {
|
|
3043
2792
|
let value = candidate.value.value;
|
|
3044
2793
|
let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage"]);
|
|
@@ -3049,6 +2798,8 @@ function createUtilities(theme) {
|
|
|
3049
2798
|
}
|
|
3050
2799
|
default: {
|
|
3051
2800
|
value = asColor(value, candidate.modifier, theme);
|
|
2801
|
+
if (value === null)
|
|
2802
|
+
return;
|
|
3052
2803
|
return desc.color(value);
|
|
3053
2804
|
}
|
|
3054
2805
|
}
|
|
@@ -3068,6 +2819,18 @@ function createUtilities(theme) {
|
|
|
3068
2819
|
}
|
|
3069
2820
|
}
|
|
3070
2821
|
});
|
|
2822
|
+
suggest(classRoot, () => [
|
|
2823
|
+
{
|
|
2824
|
+
values: ["current", "transparent"],
|
|
2825
|
+
valueThemeKeys: ["--background-color", "--color"],
|
|
2826
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
2827
|
+
modifierThemeKeys: ["--opacity"]
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
values: Array.from({ length: 21 }, (_, index) => `${index * 5}%`),
|
|
2831
|
+
valueThemeKeys: ["--gradient-color-stop-positions"]
|
|
2832
|
+
}
|
|
2833
|
+
]);
|
|
3071
2834
|
}
|
|
3072
2835
|
gradientStopUtility("from", {
|
|
3073
2836
|
color: (value) => [
|
|
@@ -3089,9 +2852,9 @@ function createUtilities(theme) {
|
|
|
3089
2852
|
decl("--tw-gradient-via", value),
|
|
3090
2853
|
decl(
|
|
3091
2854
|
"--tw-gradient-via-stops",
|
|
3092
|
-
|
|
2855
|
+
"var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position)"
|
|
3093
2856
|
),
|
|
3094
|
-
decl("--tw-gradient-stops",
|
|
2857
|
+
decl("--tw-gradient-stops", "var(--tw-gradient-via-stops)")
|
|
3095
2858
|
],
|
|
3096
2859
|
position: (value) => [gradientStopProperties(), decl("--tw-gradient-via-position", value)]
|
|
3097
2860
|
});
|
|
@@ -3151,25 +2914,34 @@ function createUtilities(theme) {
|
|
|
3151
2914
|
staticUtility(`bg-blend-${value}`, [["background-blend-mode", value]]);
|
|
3152
2915
|
staticUtility(`mix-blend-${value}`, [["mix-blend-mode", value]]);
|
|
3153
2916
|
}
|
|
3154
|
-
staticUtility(
|
|
3155
|
-
staticUtility(
|
|
2917
|
+
staticUtility("mix-blend-plus-darker", [["mix-blend-mode", "plus-darker"]]);
|
|
2918
|
+
staticUtility("mix-blend-plus-lighter", [["mix-blend-mode", "plus-lighter"]]);
|
|
3156
2919
|
utilities.functional("fill", (candidate) => {
|
|
3157
|
-
if (candidate.negative || !candidate.value)
|
|
2920
|
+
if (candidate.negative || !candidate.value)
|
|
3158
2921
|
return;
|
|
3159
|
-
}
|
|
3160
2922
|
if (candidate.value.kind === "arbitrary") {
|
|
3161
|
-
|
|
2923
|
+
let value2 = asColor(candidate.value.value, candidate.modifier, theme);
|
|
2924
|
+
if (value2 === null)
|
|
2925
|
+
return;
|
|
2926
|
+
return [decl("fill", value2)];
|
|
3162
2927
|
}
|
|
3163
2928
|
let value = resolveThemeColor(candidate, theme, ["--fill", "--color"]);
|
|
3164
2929
|
if (value) {
|
|
3165
2930
|
return [decl("fill", value)];
|
|
3166
2931
|
}
|
|
3167
2932
|
});
|
|
2933
|
+
suggest("fill", () => [
|
|
2934
|
+
{
|
|
2935
|
+
values: ["current", "transparent"],
|
|
2936
|
+
valueThemeKeys: ["--fill", "--color"],
|
|
2937
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
2938
|
+
modifierThemeKeys: ["--opacity"]
|
|
2939
|
+
}
|
|
2940
|
+
]);
|
|
3168
2941
|
staticUtility("stroke-none", [["stroke", "none"]]);
|
|
3169
2942
|
utilities.functional("stroke", (candidate) => {
|
|
3170
|
-
if (candidate.negative || !candidate.value)
|
|
2943
|
+
if (candidate.negative || !candidate.value)
|
|
3171
2944
|
return;
|
|
3172
|
-
}
|
|
3173
2945
|
if (candidate.value.kind === "arbitrary") {
|
|
3174
2946
|
let value = candidate.value.value;
|
|
3175
2947
|
let type = candidate.value.dataType ?? inferDataType(value, ["color", "number", "length", "percentage"]);
|
|
@@ -3181,6 +2953,8 @@ function createUtilities(theme) {
|
|
|
3181
2953
|
}
|
|
3182
2954
|
default: {
|
|
3183
2955
|
value = asColor(candidate.value.value, candidate.modifier, theme);
|
|
2956
|
+
if (value === null)
|
|
2957
|
+
return;
|
|
3184
2958
|
return [decl("stroke", value)];
|
|
3185
2959
|
}
|
|
3186
2960
|
}
|
|
@@ -3195,11 +2969,23 @@ function createUtilities(theme) {
|
|
|
3195
2969
|
let value = theme.resolve(candidate.value.value, ["--stroke-width"]);
|
|
3196
2970
|
if (value) {
|
|
3197
2971
|
return [decl("stroke-width", value)];
|
|
3198
|
-
} else if (!isNaN(Number(candidate.value.value))) {
|
|
2972
|
+
} else if (!Number.isNaN(Number(candidate.value.value))) {
|
|
3199
2973
|
return [decl("stroke-width", candidate.value.value)];
|
|
3200
2974
|
}
|
|
3201
2975
|
}
|
|
3202
2976
|
});
|
|
2977
|
+
suggest("stroke", () => [
|
|
2978
|
+
{
|
|
2979
|
+
values: ["current", "transparent"],
|
|
2980
|
+
valueThemeKeys: ["--stroke", "--color"],
|
|
2981
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
2982
|
+
modifierThemeKeys: ["--opacity"]
|
|
2983
|
+
},
|
|
2984
|
+
{
|
|
2985
|
+
values: ["0", "1", "2", "3"],
|
|
2986
|
+
valueThemeKeys: ["--stroke-width"]
|
|
2987
|
+
}
|
|
2988
|
+
]);
|
|
3203
2989
|
staticUtility("object-contain", [["object-fit", "contain"]]);
|
|
3204
2990
|
staticUtility("object-cover", [["object-fit", "cover"]]);
|
|
3205
2991
|
staticUtility("object-fill", [["object-fit", "fill"]]);
|
|
@@ -3278,9 +3064,8 @@ function createUtilities(theme) {
|
|
|
3278
3064
|
handle: (value) => [decl("vertical-align", value)]
|
|
3279
3065
|
});
|
|
3280
3066
|
utilities.functional("font", (candidate) => {
|
|
3281
|
-
if (candidate.negative || !candidate.value)
|
|
3067
|
+
if (candidate.negative || !candidate.value)
|
|
3282
3068
|
return;
|
|
3283
|
-
}
|
|
3284
3069
|
if (candidate.value.kind === "arbitrary") {
|
|
3285
3070
|
let value = candidate.value.value;
|
|
3286
3071
|
let type = candidate.value.dataType ?? inferDataType(value, ["number", "generic-name", "family-name"]);
|
|
@@ -3348,6 +3133,26 @@ function createUtilities(theme) {
|
|
|
3348
3133
|
}
|
|
3349
3134
|
}
|
|
3350
3135
|
});
|
|
3136
|
+
suggest("font", () => [
|
|
3137
|
+
{
|
|
3138
|
+
values: [],
|
|
3139
|
+
valueThemeKeys: ["--font-family"]
|
|
3140
|
+
},
|
|
3141
|
+
{
|
|
3142
|
+
values: [
|
|
3143
|
+
"thin",
|
|
3144
|
+
"extralight",
|
|
3145
|
+
"light",
|
|
3146
|
+
"normal",
|
|
3147
|
+
"medium",
|
|
3148
|
+
"semibold",
|
|
3149
|
+
"bold",
|
|
3150
|
+
"extrabold",
|
|
3151
|
+
"black"
|
|
3152
|
+
],
|
|
3153
|
+
valueThemeKeys: ["--font-weight"]
|
|
3154
|
+
}
|
|
3155
|
+
]);
|
|
3351
3156
|
staticUtility("uppercase", [["text-transform", "uppercase"]]);
|
|
3352
3157
|
staticUtility("lowercase", [["text-transform", "lowercase"]]);
|
|
3353
3158
|
staticUtility("capitalize", [["text-transform", "capitalize"]]);
|
|
@@ -3372,9 +3177,8 @@ function createUtilities(theme) {
|
|
|
3372
3177
|
staticUtility("decoration-auto", [["text-decoration-thickness", "auto"]]);
|
|
3373
3178
|
staticUtility("decoration-from-font", [["text-decoration-thickness", "from-font"]]);
|
|
3374
3179
|
utilities.functional("decoration", (candidate) => {
|
|
3375
|
-
if (candidate.negative || !candidate.value)
|
|
3180
|
+
if (candidate.negative || !candidate.value)
|
|
3376
3181
|
return;
|
|
3377
|
-
}
|
|
3378
3182
|
if (candidate.value.kind === "arbitrary") {
|
|
3379
3183
|
let value = candidate.value.value;
|
|
3380
3184
|
let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage"]);
|
|
@@ -3385,6 +3189,8 @@ function createUtilities(theme) {
|
|
|
3385
3189
|
}
|
|
3386
3190
|
default: {
|
|
3387
3191
|
value = asColor(value, candidate.modifier, theme);
|
|
3192
|
+
if (value === null)
|
|
3193
|
+
return;
|
|
3388
3194
|
return [decl("text-decoration-color", value)];
|
|
3389
3195
|
}
|
|
3390
3196
|
}
|
|
@@ -3394,7 +3200,7 @@ function createUtilities(theme) {
|
|
|
3394
3200
|
if (value) {
|
|
3395
3201
|
return [decl("text-decoration-thickness", value)];
|
|
3396
3202
|
}
|
|
3397
|
-
if (!isNaN(Number(candidate.value.value))) {
|
|
3203
|
+
if (!Number.isNaN(Number(candidate.value.value))) {
|
|
3398
3204
|
return [decl("text-decoration-thickness", `${candidate.value.value}px`)];
|
|
3399
3205
|
}
|
|
3400
3206
|
}
|
|
@@ -3405,6 +3211,18 @@ function createUtilities(theme) {
|
|
|
3405
3211
|
}
|
|
3406
3212
|
}
|
|
3407
3213
|
});
|
|
3214
|
+
suggest("decoration", () => [
|
|
3215
|
+
{
|
|
3216
|
+
values: ["current", "transparent"],
|
|
3217
|
+
valueThemeKeys: ["--text-decoration-color", "--color"],
|
|
3218
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
3219
|
+
modifierThemeKeys: ["--opacity"]
|
|
3220
|
+
},
|
|
3221
|
+
{
|
|
3222
|
+
values: ["0", "1", "2"],
|
|
3223
|
+
valueThemeKeys: ["--text-decoration-thickness"]
|
|
3224
|
+
}
|
|
3225
|
+
]);
|
|
3408
3226
|
staticUtility("animate-none", [["animation", "none"]]);
|
|
3409
3227
|
functionalUtility("animate", {
|
|
3410
3228
|
themeKeys: ["--animate"],
|
|
@@ -3460,14 +3278,13 @@ function createUtilities(theme) {
|
|
|
3460
3278
|
]);
|
|
3461
3279
|
};
|
|
3462
3280
|
utilities.functional("filter", (candidate) => {
|
|
3463
|
-
if (candidate.negative)
|
|
3281
|
+
if (candidate.negative)
|
|
3464
3282
|
return;
|
|
3465
|
-
}
|
|
3466
3283
|
if (candidate.value === null) {
|
|
3467
3284
|
return [filterProperties(), decl("filter", cssFilterValue)];
|
|
3468
3285
|
}
|
|
3469
3286
|
if (candidate.value.kind === "arbitrary") {
|
|
3470
|
-
return;
|
|
3287
|
+
return [decl("filter", candidate.value.value)];
|
|
3471
3288
|
}
|
|
3472
3289
|
switch (candidate.value.value) {
|
|
3473
3290
|
case "none":
|
|
@@ -3475,9 +3292,8 @@ function createUtilities(theme) {
|
|
|
3475
3292
|
}
|
|
3476
3293
|
});
|
|
3477
3294
|
utilities.functional("backdrop-filter", (candidate) => {
|
|
3478
|
-
if (candidate.negative)
|
|
3295
|
+
if (candidate.negative)
|
|
3479
3296
|
return;
|
|
3480
|
-
}
|
|
3481
3297
|
if (candidate.value === null) {
|
|
3482
3298
|
return [
|
|
3483
3299
|
backdropFilterProperties(),
|
|
@@ -3486,7 +3302,10 @@ function createUtilities(theme) {
|
|
|
3486
3302
|
];
|
|
3487
3303
|
}
|
|
3488
3304
|
if (candidate.value.kind === "arbitrary") {
|
|
3489
|
-
return
|
|
3305
|
+
return [
|
|
3306
|
+
decl("-webkit-backdrop-filter", candidate.value.value),
|
|
3307
|
+
decl("backdrop-filter", candidate.value.value)
|
|
3308
|
+
];
|
|
3490
3309
|
}
|
|
3491
3310
|
switch (candidate.value.value) {
|
|
3492
3311
|
case "none":
|
|
@@ -3529,6 +3348,18 @@ function createUtilities(theme) {
|
|
|
3529
3348
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3530
3349
|
]
|
|
3531
3350
|
});
|
|
3351
|
+
suggest("brightness", () => [
|
|
3352
|
+
{
|
|
3353
|
+
values: ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"],
|
|
3354
|
+
valueThemeKeys: ["--brightness"]
|
|
3355
|
+
}
|
|
3356
|
+
]);
|
|
3357
|
+
suggest("backdrop-brightness", () => [
|
|
3358
|
+
{
|
|
3359
|
+
values: ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"],
|
|
3360
|
+
valueThemeKeys: ["--backdrop-brightness", "--brightness"]
|
|
3361
|
+
}
|
|
3362
|
+
]);
|
|
3532
3363
|
functionalUtility("contrast", {
|
|
3533
3364
|
themeKeys: ["--contrast"],
|
|
3534
3365
|
handleBareValue: ({ value }) => `${value}%`,
|
|
@@ -3548,6 +3379,18 @@ function createUtilities(theme) {
|
|
|
3548
3379
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3549
3380
|
]
|
|
3550
3381
|
});
|
|
3382
|
+
suggest("contrast", () => [
|
|
3383
|
+
{
|
|
3384
|
+
values: ["0", "50", "75", "100", "125", "150", "200"],
|
|
3385
|
+
valueThemeKeys: ["--contrast"]
|
|
3386
|
+
}
|
|
3387
|
+
]);
|
|
3388
|
+
suggest("backdrop-contrast", () => [
|
|
3389
|
+
{
|
|
3390
|
+
values: ["0", "50", "75", "100", "125", "150", "200"],
|
|
3391
|
+
valueThemeKeys: ["--backdrop-contrast", "--contrast"]
|
|
3392
|
+
}
|
|
3393
|
+
]);
|
|
3551
3394
|
functionalUtility("grayscale", {
|
|
3552
3395
|
themeKeys: ["--grayscale"],
|
|
3553
3396
|
handleBareValue: ({ value }) => `${value}%`,
|
|
@@ -3569,6 +3412,20 @@ function createUtilities(theme) {
|
|
|
3569
3412
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3570
3413
|
]
|
|
3571
3414
|
});
|
|
3415
|
+
suggest("grayscale", () => [
|
|
3416
|
+
{
|
|
3417
|
+
values: ["0", "25", "50", "75", "100"],
|
|
3418
|
+
valueThemeKeys: ["--grayscale"],
|
|
3419
|
+
hasDefaultValue: true
|
|
3420
|
+
}
|
|
3421
|
+
]);
|
|
3422
|
+
suggest("backdrop-grayscale", () => [
|
|
3423
|
+
{
|
|
3424
|
+
values: ["0", "25", "50", "75", "100"],
|
|
3425
|
+
valueThemeKeys: ["--backdrop-grayscale", "--grayscale"],
|
|
3426
|
+
hasDefaultValue: true
|
|
3427
|
+
}
|
|
3428
|
+
]);
|
|
3572
3429
|
functionalUtility("hue-rotate", {
|
|
3573
3430
|
themeKeys: ["--hue-rotate"],
|
|
3574
3431
|
handleBareValue: ({ value }) => `${value}deg`,
|
|
@@ -3588,6 +3445,18 @@ function createUtilities(theme) {
|
|
|
3588
3445
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3589
3446
|
]
|
|
3590
3447
|
});
|
|
3448
|
+
suggest("hue-rotate", () => [
|
|
3449
|
+
{
|
|
3450
|
+
values: ["0", "15", "30", "60", "90", "180"],
|
|
3451
|
+
valueThemeKeys: ["--hue-rotate"]
|
|
3452
|
+
}
|
|
3453
|
+
]);
|
|
3454
|
+
suggest("backdrop-hue-rotate", () => [
|
|
3455
|
+
{
|
|
3456
|
+
values: ["0", "15", "30", "60", "90", "180"],
|
|
3457
|
+
valueThemeKeys: ["--backdrop-hue-rotate", "--hue-rotate"]
|
|
3458
|
+
}
|
|
3459
|
+
]);
|
|
3591
3460
|
functionalUtility("invert", {
|
|
3592
3461
|
themeKeys: ["--invert"],
|
|
3593
3462
|
handleBareValue: ({ value }) => `${value}%`,
|
|
@@ -3609,6 +3478,20 @@ function createUtilities(theme) {
|
|
|
3609
3478
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3610
3479
|
]
|
|
3611
3480
|
});
|
|
3481
|
+
suggest("invert", () => [
|
|
3482
|
+
{
|
|
3483
|
+
values: ["0", "25", "50", "75", "100"],
|
|
3484
|
+
valueThemeKeys: ["--invert"],
|
|
3485
|
+
hasDefaultValue: true
|
|
3486
|
+
}
|
|
3487
|
+
]);
|
|
3488
|
+
suggest("backdrop-invert", () => [
|
|
3489
|
+
{
|
|
3490
|
+
values: ["0", "25", "50", "75", "100"],
|
|
3491
|
+
valueThemeKeys: ["--backdrop-invert", "--invert"],
|
|
3492
|
+
hasDefaultValue: true
|
|
3493
|
+
}
|
|
3494
|
+
]);
|
|
3612
3495
|
functionalUtility("saturate", {
|
|
3613
3496
|
themeKeys: ["--saturate"],
|
|
3614
3497
|
handleBareValue: ({ value }) => `${value}%`,
|
|
@@ -3628,6 +3511,18 @@ function createUtilities(theme) {
|
|
|
3628
3511
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3629
3512
|
]
|
|
3630
3513
|
});
|
|
3514
|
+
suggest("saturate", () => [
|
|
3515
|
+
{
|
|
3516
|
+
values: ["0", "50", "100", "150", "200"],
|
|
3517
|
+
valueThemeKeys: ["--saturate"]
|
|
3518
|
+
}
|
|
3519
|
+
]);
|
|
3520
|
+
suggest("backdrop-saturate", () => [
|
|
3521
|
+
{
|
|
3522
|
+
values: ["0", "50", "100", "150", "200"],
|
|
3523
|
+
valueThemeKeys: ["--backdrop-saturate", "--saturate"]
|
|
3524
|
+
}
|
|
3525
|
+
]);
|
|
3631
3526
|
functionalUtility("sepia", {
|
|
3632
3527
|
themeKeys: ["--sepia"],
|
|
3633
3528
|
handleBareValue: ({ value }) => `${value}%`,
|
|
@@ -3649,6 +3544,20 @@ function createUtilities(theme) {
|
|
|
3649
3544
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3650
3545
|
]
|
|
3651
3546
|
});
|
|
3547
|
+
suggest("sepia", () => [
|
|
3548
|
+
{
|
|
3549
|
+
values: ["0", "50", "100"],
|
|
3550
|
+
valueThemeKeys: ["--sepia"],
|
|
3551
|
+
hasDefaultValue: true
|
|
3552
|
+
}
|
|
3553
|
+
]);
|
|
3554
|
+
suggest("backdrop-sepia", () => [
|
|
3555
|
+
{
|
|
3556
|
+
values: ["0", "50", "100"],
|
|
3557
|
+
valueThemeKeys: ["--backdrop-sepia", "--sepia"],
|
|
3558
|
+
hasDefaultValue: true
|
|
3559
|
+
}
|
|
3560
|
+
]);
|
|
3652
3561
|
functionalUtility("drop-shadow", {
|
|
3653
3562
|
themeKeys: ["--drop-shadow"],
|
|
3654
3563
|
handle: (value) => [
|
|
@@ -3663,7 +3572,6 @@ function createUtilities(theme) {
|
|
|
3663
3572
|
functionalUtility("backdrop-opacity", {
|
|
3664
3573
|
themeKeys: ["--backdrop-opacity", "--opacity"],
|
|
3665
3574
|
handleBareValue: ({ value }) => `${value}%`,
|
|
3666
|
-
defaultValue: "100%",
|
|
3667
3575
|
handle: (value) => [
|
|
3668
3576
|
backdropFilterProperties(),
|
|
3669
3577
|
decl("--tw-backdrop-opacity", `opacity(${value})`),
|
|
@@ -3671,6 +3579,12 @@ function createUtilities(theme) {
|
|
|
3671
3579
|
decl("backdrop-filter", cssBackdropFilterValue)
|
|
3672
3580
|
]
|
|
3673
3581
|
});
|
|
3582
|
+
suggest("backdrop-opacity", () => [
|
|
3583
|
+
{
|
|
3584
|
+
values: Array.from({ length: 21 }, (_, i) => `${i * 5}`),
|
|
3585
|
+
valueThemeKeys: ["--backdrop-opacity", "--opacity"]
|
|
3586
|
+
}
|
|
3587
|
+
]);
|
|
3674
3588
|
}
|
|
3675
3589
|
{
|
|
3676
3590
|
let defaultTimingFunction = "var(--default-transition-timing-function)";
|
|
@@ -3730,14 +3644,26 @@ function createUtilities(theme) {
|
|
|
3730
3644
|
value = theme.resolve(candidate.value.fraction ?? candidate.value.value, [
|
|
3731
3645
|
"--transition-duration"
|
|
3732
3646
|
]);
|
|
3733
|
-
if (
|
|
3647
|
+
if (value === null && !Number.isNaN(Number(candidate.value.value))) {
|
|
3734
3648
|
value = `${candidate.value.value}ms`;
|
|
3735
3649
|
}
|
|
3736
|
-
if (!value)
|
|
3737
|
-
return;
|
|
3738
3650
|
}
|
|
3651
|
+
if (value === null)
|
|
3652
|
+
return;
|
|
3739
3653
|
return [decl("transition-duration", value)];
|
|
3740
3654
|
});
|
|
3655
|
+
suggest("delay", () => [
|
|
3656
|
+
{
|
|
3657
|
+
values: ["75", "100", "150", "200", "300", "500", "700", "1000"],
|
|
3658
|
+
valueThemeKeys: ["--transition-delay"]
|
|
3659
|
+
}
|
|
3660
|
+
]);
|
|
3661
|
+
suggest("duration", () => [
|
|
3662
|
+
{
|
|
3663
|
+
values: ["75", "100", "150", "200", "300", "500", "700", "1000"],
|
|
3664
|
+
valueThemeKeys: ["--transition-duration"]
|
|
3665
|
+
}
|
|
3666
|
+
]);
|
|
3741
3667
|
}
|
|
3742
3668
|
functionalUtility("ease", {
|
|
3743
3669
|
themeKeys: ["--transition-timing-function"],
|
|
@@ -3875,61 +3801,121 @@ function createUtilities(theme) {
|
|
|
3875
3801
|
["font-variant-numeric", cssFontVariantNumericValue]
|
|
3876
3802
|
]);
|
|
3877
3803
|
}
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3804
|
+
{
|
|
3805
|
+
let outlineProperties = () => {
|
|
3806
|
+
return atRoot([property("--tw-outline-style", "solid", "<custom-ident>")]);
|
|
3807
|
+
};
|
|
3808
|
+
staticUtility("outline-none", [
|
|
3809
|
+
["outline", "2px solid transparent"],
|
|
3810
|
+
["outline-offset", "2px"]
|
|
3811
|
+
]);
|
|
3812
|
+
staticUtility("outline-solid", [
|
|
3813
|
+
["--tw-outline-style", "solid"],
|
|
3814
|
+
["outline-style", "solid"]
|
|
3815
|
+
]);
|
|
3816
|
+
staticUtility("outline-dashed", [
|
|
3817
|
+
["--tw-outline-style", "dashed"],
|
|
3818
|
+
["outline-style", "dashed"]
|
|
3819
|
+
]);
|
|
3820
|
+
staticUtility("outline-dotted", [
|
|
3821
|
+
["--tw-outline-style", "dotted"],
|
|
3822
|
+
["outline-style", "dotted"]
|
|
3823
|
+
]);
|
|
3824
|
+
staticUtility("outline-double", [
|
|
3825
|
+
["--tw-outline-style", "double"],
|
|
3826
|
+
["outline-style", "double"]
|
|
3827
|
+
]);
|
|
3828
|
+
utilities.functional("outline", (candidate) => {
|
|
3829
|
+
if (candidate.negative)
|
|
3830
|
+
return;
|
|
3831
|
+
if (candidate.value === null) {
|
|
3832
|
+
return [
|
|
3833
|
+
outlineProperties(),
|
|
3834
|
+
decl("outline-style", "var(--tw-outline-style)"),
|
|
3835
|
+
decl("outline-width", "1px")
|
|
3836
|
+
];
|
|
3837
|
+
}
|
|
3838
|
+
if (candidate.value.kind === "arbitrary") {
|
|
3839
|
+
let value = candidate.value.value;
|
|
3840
|
+
let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "number", "percentage"]);
|
|
3841
|
+
switch (type) {
|
|
3842
|
+
case "length":
|
|
3843
|
+
case "number":
|
|
3844
|
+
case "percentage": {
|
|
3845
|
+
return [
|
|
3846
|
+
outlineProperties(),
|
|
3847
|
+
decl("outline-style", "var(--tw-outline-style)"),
|
|
3848
|
+
decl("outline-width", value)
|
|
3849
|
+
];
|
|
3850
|
+
}
|
|
3851
|
+
default: {
|
|
3852
|
+
value = asColor(value, candidate.modifier, theme);
|
|
3853
|
+
if (value === null)
|
|
3854
|
+
return;
|
|
3855
|
+
return [decl("outline-color", value)];
|
|
3856
|
+
}
|
|
3900
3857
|
}
|
|
3901
|
-
|
|
3902
|
-
|
|
3858
|
+
}
|
|
3859
|
+
{
|
|
3860
|
+
let value = resolveThemeColor(candidate, theme, ["--outline-color", "--color"]);
|
|
3861
|
+
if (value) {
|
|
3903
3862
|
return [decl("outline-color", value)];
|
|
3904
3863
|
}
|
|
3905
3864
|
}
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3865
|
+
{
|
|
3866
|
+
let value = theme.resolve(candidate.value.value, ["--outline-width"]);
|
|
3867
|
+
if (value) {
|
|
3868
|
+
return [
|
|
3869
|
+
outlineProperties(),
|
|
3870
|
+
decl("outline-style", "var(--tw-outline-style)"),
|
|
3871
|
+
decl("outline-width", value)
|
|
3872
|
+
];
|
|
3873
|
+
} else if (!Number.isNaN(Number(candidate.value.value))) {
|
|
3874
|
+
return [
|
|
3875
|
+
outlineProperties(),
|
|
3876
|
+
decl("outline-style", "var(--tw-outline-style)"),
|
|
3877
|
+
decl("outline-width", `${candidate.value.value}px`)
|
|
3878
|
+
];
|
|
3879
|
+
}
|
|
3911
3880
|
}
|
|
3912
|
-
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3881
|
+
});
|
|
3882
|
+
suggest("outline", () => [
|
|
3883
|
+
{
|
|
3884
|
+
values: ["current", "transparent"],
|
|
3885
|
+
valueThemeKeys: ["--outline-color", "--color"],
|
|
3886
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
3887
|
+
modifierThemeKeys: ["--opacity"],
|
|
3888
|
+
hasDefaultValue: true
|
|
3889
|
+
},
|
|
3890
|
+
{
|
|
3891
|
+
values: ["0", "1", "2", "4", "8"],
|
|
3892
|
+
valueThemeKeys: ["--outline-width"]
|
|
3919
3893
|
}
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3894
|
+
]);
|
|
3895
|
+
functionalUtility("outline-offset", {
|
|
3896
|
+
supportsNegative: true,
|
|
3897
|
+
themeKeys: ["--outline-offset"],
|
|
3898
|
+
handleBareValue: ({ value }) => `${value}px`,
|
|
3899
|
+
handle: (value) => [decl("outline-offset", value)]
|
|
3900
|
+
});
|
|
3901
|
+
suggest("outline-offset", () => [
|
|
3902
|
+
{
|
|
3903
|
+
values: ["0", "1", "2", "4", "8"],
|
|
3904
|
+
valueThemeKeys: ["--outline-offset"]
|
|
3905
|
+
}
|
|
3906
|
+
]);
|
|
3907
|
+
}
|
|
3928
3908
|
functionalUtility("opacity", {
|
|
3929
3909
|
themeKeys: ["--opacity"],
|
|
3930
3910
|
handleBareValue: ({ value }) => `${value}%`,
|
|
3931
3911
|
handle: (value) => [decl("opacity", value)]
|
|
3932
3912
|
});
|
|
3913
|
+
suggest("opacity", () => [
|
|
3914
|
+
{
|
|
3915
|
+
values: Array.from({ length: 21 }, (_, i) => `${i * 5}`),
|
|
3916
|
+
valueThemeKeys: ["--opacity"]
|
|
3917
|
+
}
|
|
3918
|
+
]);
|
|
3933
3919
|
staticUtility("underline-offset-auto", [["text-underline-offset", "auto"]]);
|
|
3934
3920
|
functionalUtility("underline-offset", {
|
|
3935
3921
|
supportsNegative: true,
|
|
@@ -3937,10 +3923,16 @@ function createUtilities(theme) {
|
|
|
3937
3923
|
handleBareValue: ({ value }) => `${value}px`,
|
|
3938
3924
|
handle: (value) => [decl("text-underline-offset", value)]
|
|
3939
3925
|
});
|
|
3926
|
+
suggest("underline-offset", () => [
|
|
3927
|
+
{
|
|
3928
|
+
supportsNegative: true,
|
|
3929
|
+
values: ["0", "1", "2", "4", "8"],
|
|
3930
|
+
valueThemeKeys: ["--text-underline-offset"]
|
|
3931
|
+
}
|
|
3932
|
+
]);
|
|
3940
3933
|
utilities.functional("text", (candidate) => {
|
|
3941
|
-
if (candidate.negative || !candidate.value)
|
|
3934
|
+
if (candidate.negative || !candidate.value)
|
|
3942
3935
|
return;
|
|
3943
|
-
}
|
|
3944
3936
|
if (candidate.value.kind === "arbitrary") {
|
|
3945
3937
|
let value = candidate.value.value;
|
|
3946
3938
|
let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage", "absolute-size", "relative-size"]);
|
|
@@ -3960,6 +3952,8 @@ function createUtilities(theme) {
|
|
|
3960
3952
|
}
|
|
3961
3953
|
default: {
|
|
3962
3954
|
value = asColor(value, candidate.modifier, theme);
|
|
3955
|
+
if (value === null)
|
|
3956
|
+
return;
|
|
3963
3957
|
return [decl("color", value)];
|
|
3964
3958
|
}
|
|
3965
3959
|
}
|
|
@@ -3996,18 +3990,32 @@ function createUtilities(theme) {
|
|
|
3996
3990
|
}
|
|
3997
3991
|
}
|
|
3998
3992
|
});
|
|
3993
|
+
suggest("text", () => [
|
|
3994
|
+
{
|
|
3995
|
+
values: ["current", "transparent"],
|
|
3996
|
+
valueThemeKeys: ["--text-color", "--color"],
|
|
3997
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
3998
|
+
modifierThemeKeys: ["--opacity"]
|
|
3999
|
+
},
|
|
4000
|
+
{
|
|
4001
|
+
values: [],
|
|
4002
|
+
valueThemeKeys: ["--font-size"],
|
|
4003
|
+
modifiers: [],
|
|
4004
|
+
modifierThemeKeys: ["--line-height"]
|
|
4005
|
+
}
|
|
4006
|
+
]);
|
|
3999
4007
|
{
|
|
4000
4008
|
let ringShadowValue2 = function(value) {
|
|
4001
|
-
return `var(--tw-ring-inset,) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color,
|
|
4009
|
+
return `var(--tw-ring-inset,) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color, ${defaultRingColor})`;
|
|
4002
4010
|
}, insetRingShadowValue2 = function(value) {
|
|
4003
4011
|
return `inset 0 0 0 ${value} var(--tw-inset-ring-color, currentColor)`;
|
|
4004
4012
|
};
|
|
4005
4013
|
let cssBoxShadowValue = [
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4014
|
+
"var(--tw-inset-shadow)",
|
|
4015
|
+
"var(--tw-inset-ring-shadow)",
|
|
4016
|
+
"var(--tw-ring-offset-shadow)",
|
|
4017
|
+
"var(--tw-ring-shadow)",
|
|
4018
|
+
"var(--tw-shadow)"
|
|
4011
4019
|
].join(", ");
|
|
4012
4020
|
let nullShadow = "0 0 #0000";
|
|
4013
4021
|
let boxShadowProperties = () => {
|
|
@@ -4028,12 +4036,11 @@ function createUtilities(theme) {
|
|
|
4028
4036
|
]);
|
|
4029
4037
|
};
|
|
4030
4038
|
utilities.functional("shadow", (candidate) => {
|
|
4031
|
-
if (candidate.negative)
|
|
4039
|
+
if (candidate.negative)
|
|
4032
4040
|
return;
|
|
4033
|
-
}
|
|
4034
4041
|
if (!candidate.value) {
|
|
4035
4042
|
let value = theme.get(["--shadow"]);
|
|
4036
|
-
if (
|
|
4043
|
+
if (value === null)
|
|
4037
4044
|
return;
|
|
4038
4045
|
return [
|
|
4039
4046
|
boxShadowProperties(),
|
|
@@ -4048,6 +4055,8 @@ function createUtilities(theme) {
|
|
|
4048
4055
|
switch (type) {
|
|
4049
4056
|
case "color": {
|
|
4050
4057
|
value = asColor(value, candidate.modifier, theme);
|
|
4058
|
+
if (value === null)
|
|
4059
|
+
return;
|
|
4051
4060
|
return [
|
|
4052
4061
|
boxShadowProperties(),
|
|
4053
4062
|
decl("--tw-shadow-color", value),
|
|
@@ -4095,13 +4104,25 @@ function createUtilities(theme) {
|
|
|
4095
4104
|
}
|
|
4096
4105
|
}
|
|
4097
4106
|
});
|
|
4107
|
+
suggest("shadow", () => [
|
|
4108
|
+
{
|
|
4109
|
+
values: ["current", "transparent"],
|
|
4110
|
+
valueThemeKeys: ["--box-shadow-color", "--color"],
|
|
4111
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
4112
|
+
modifierThemeKeys: ["--opacity"]
|
|
4113
|
+
},
|
|
4114
|
+
{
|
|
4115
|
+
values: [],
|
|
4116
|
+
valueThemeKeys: ["--shadow"],
|
|
4117
|
+
hasDefaultValue: true
|
|
4118
|
+
}
|
|
4119
|
+
]);
|
|
4098
4120
|
utilities.functional("inset-shadow", (candidate) => {
|
|
4099
|
-
if (candidate.negative)
|
|
4121
|
+
if (candidate.negative)
|
|
4100
4122
|
return;
|
|
4101
|
-
}
|
|
4102
4123
|
if (!candidate.value) {
|
|
4103
4124
|
let value = theme.get(["--inset-shadow"]);
|
|
4104
|
-
if (
|
|
4125
|
+
if (value === null)
|
|
4105
4126
|
return;
|
|
4106
4127
|
return [
|
|
4107
4128
|
boxShadowProperties(),
|
|
@@ -4119,6 +4140,8 @@ function createUtilities(theme) {
|
|
|
4119
4140
|
switch (type) {
|
|
4120
4141
|
case "color": {
|
|
4121
4142
|
value = asColor(value, candidate.modifier, theme);
|
|
4143
|
+
if (value === null)
|
|
4144
|
+
return;
|
|
4122
4145
|
return [
|
|
4123
4146
|
boxShadowProperties(),
|
|
4124
4147
|
decl("--tw-inset-shadow-color", value),
|
|
@@ -4172,14 +4195,29 @@ function createUtilities(theme) {
|
|
|
4172
4195
|
}
|
|
4173
4196
|
}
|
|
4174
4197
|
});
|
|
4198
|
+
suggest("inset-shadow", () => [
|
|
4199
|
+
{
|
|
4200
|
+
values: ["current", "transparent"],
|
|
4201
|
+
valueThemeKeys: ["--box-shadow-color", "--color"],
|
|
4202
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
4203
|
+
modifierThemeKeys: ["--opacity"]
|
|
4204
|
+
},
|
|
4205
|
+
{
|
|
4206
|
+
values: [],
|
|
4207
|
+
valueThemeKeys: ["--shadow"],
|
|
4208
|
+
hasDefaultValue: true
|
|
4209
|
+
}
|
|
4210
|
+
]);
|
|
4175
4211
|
staticUtility("ring-inset", [boxShadowProperties, ["--tw-ring-inset", "inset"]]);
|
|
4212
|
+
let defaultRingColor = theme.get(["--default-ring-color"]) ?? "currentColor";
|
|
4176
4213
|
utilities.functional("ring", (candidate) => {
|
|
4177
4214
|
if (candidate.negative)
|
|
4178
4215
|
return;
|
|
4179
4216
|
if (!candidate.value) {
|
|
4217
|
+
let value = theme.get(["--default-ring-width"]) ?? "1px";
|
|
4180
4218
|
return [
|
|
4181
4219
|
boxShadowProperties(),
|
|
4182
|
-
decl("--tw-ring-shadow", ringShadowValue2(
|
|
4220
|
+
decl("--tw-ring-shadow", ringShadowValue2(value)),
|
|
4183
4221
|
decl("box-shadow", cssBoxShadowValue)
|
|
4184
4222
|
];
|
|
4185
4223
|
}
|
|
@@ -4196,6 +4234,8 @@ function createUtilities(theme) {
|
|
|
4196
4234
|
}
|
|
4197
4235
|
default: {
|
|
4198
4236
|
value = asColor(value, candidate.modifier, theme);
|
|
4237
|
+
if (value === null)
|
|
4238
|
+
return;
|
|
4199
4239
|
return [decl("--tw-ring-color", value)];
|
|
4200
4240
|
}
|
|
4201
4241
|
}
|
|
@@ -4208,7 +4248,7 @@ function createUtilities(theme) {
|
|
|
4208
4248
|
}
|
|
4209
4249
|
{
|
|
4210
4250
|
let value = theme.resolve(candidate.value.value, ["--ring-width"]);
|
|
4211
|
-
if (
|
|
4251
|
+
if (value === null && !Number.isNaN(Number(candidate.value.value))) {
|
|
4212
4252
|
value = `${candidate.value.value}px`;
|
|
4213
4253
|
}
|
|
4214
4254
|
if (value) {
|
|
@@ -4220,6 +4260,19 @@ function createUtilities(theme) {
|
|
|
4220
4260
|
}
|
|
4221
4261
|
}
|
|
4222
4262
|
});
|
|
4263
|
+
suggest("ring", () => [
|
|
4264
|
+
{
|
|
4265
|
+
values: ["current", "transparent"],
|
|
4266
|
+
valueThemeKeys: ["--ring-color", "--color"],
|
|
4267
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
4268
|
+
modifierThemeKeys: ["--opacity"]
|
|
4269
|
+
},
|
|
4270
|
+
{
|
|
4271
|
+
values: ["0", "1", "2", "4", "8"],
|
|
4272
|
+
valueThemeKeys: ["--ring-width"],
|
|
4273
|
+
hasDefaultValue: true
|
|
4274
|
+
}
|
|
4275
|
+
]);
|
|
4223
4276
|
utilities.functional("inset-ring", (candidate) => {
|
|
4224
4277
|
if (candidate.negative)
|
|
4225
4278
|
return;
|
|
@@ -4243,6 +4296,8 @@ function createUtilities(theme) {
|
|
|
4243
4296
|
}
|
|
4244
4297
|
default: {
|
|
4245
4298
|
value = asColor(value, candidate.modifier, theme);
|
|
4299
|
+
if (value === null)
|
|
4300
|
+
return;
|
|
4246
4301
|
return [decl("--tw-inset-ring-color", value)];
|
|
4247
4302
|
}
|
|
4248
4303
|
}
|
|
@@ -4255,7 +4310,7 @@ function createUtilities(theme) {
|
|
|
4255
4310
|
}
|
|
4256
4311
|
{
|
|
4257
4312
|
let value = theme.resolve(candidate.value.value, ["--ring-width"]);
|
|
4258
|
-
if (
|
|
4313
|
+
if (value === null && !Number.isNaN(Number(candidate.value.value))) {
|
|
4259
4314
|
value = `${candidate.value.value}px`;
|
|
4260
4315
|
}
|
|
4261
4316
|
if (value) {
|
|
@@ -4267,11 +4322,23 @@ function createUtilities(theme) {
|
|
|
4267
4322
|
}
|
|
4268
4323
|
}
|
|
4269
4324
|
});
|
|
4325
|
+
suggest("inset-ring", () => [
|
|
4326
|
+
{
|
|
4327
|
+
values: ["current", "transparent"],
|
|
4328
|
+
valueThemeKeys: ["--ring-color", "--color"],
|
|
4329
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
4330
|
+
modifierThemeKeys: ["--opacity"]
|
|
4331
|
+
},
|
|
4332
|
+
{
|
|
4333
|
+
values: ["0", "1", "2", "4", "8"],
|
|
4334
|
+
valueThemeKeys: ["--ring-width"],
|
|
4335
|
+
hasDefaultValue: true
|
|
4336
|
+
}
|
|
4337
|
+
]);
|
|
4270
4338
|
let ringOffsetShadowValue = "var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)";
|
|
4271
4339
|
utilities.functional("ring-offset", (candidate) => {
|
|
4272
|
-
if (candidate.negative || !candidate.value)
|
|
4340
|
+
if (candidate.negative || !candidate.value)
|
|
4273
4341
|
return;
|
|
4274
|
-
}
|
|
4275
4342
|
if (candidate.value.kind === "arbitrary") {
|
|
4276
4343
|
let value = candidate.value.value;
|
|
4277
4344
|
let type = candidate.value.dataType ?? inferDataType(value, ["color", "length"]);
|
|
@@ -4284,6 +4351,8 @@ function createUtilities(theme) {
|
|
|
4284
4351
|
}
|
|
4285
4352
|
default: {
|
|
4286
4353
|
value = asColor(value, candidate.modifier, theme);
|
|
4354
|
+
if (value === null)
|
|
4355
|
+
return;
|
|
4287
4356
|
return [decl("--tw-ring-offset-color", value)];
|
|
4288
4357
|
}
|
|
4289
4358
|
}
|
|
@@ -4295,7 +4364,7 @@ function createUtilities(theme) {
|
|
|
4295
4364
|
decl("--tw-ring-offset-width", value),
|
|
4296
4365
|
decl("--tw-ring-offset-shadow", ringOffsetShadowValue)
|
|
4297
4366
|
];
|
|
4298
|
-
} else if (!isNaN(Number(candidate.value.value))) {
|
|
4367
|
+
} else if (!Number.isNaN(Number(candidate.value.value))) {
|
|
4299
4368
|
return [
|
|
4300
4369
|
decl("--tw-ring-offset-width", `${candidate.value.value}px`),
|
|
4301
4370
|
decl("--tw-ring-offset-shadow", ringOffsetShadowValue)
|
|
@@ -4310,6 +4379,43 @@ function createUtilities(theme) {
|
|
|
4310
4379
|
}
|
|
4311
4380
|
});
|
|
4312
4381
|
}
|
|
4382
|
+
suggest("ring-offset", () => [
|
|
4383
|
+
{
|
|
4384
|
+
values: ["current", "transparent"],
|
|
4385
|
+
valueThemeKeys: ["--ring-offset-color", "--color"],
|
|
4386
|
+
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
|
|
4387
|
+
modifierThemeKeys: ["--opacity"]
|
|
4388
|
+
},
|
|
4389
|
+
{
|
|
4390
|
+
values: ["0", "1", "2", "4", "8"],
|
|
4391
|
+
valueThemeKeys: ["--ring-offset-width"]
|
|
4392
|
+
}
|
|
4393
|
+
]);
|
|
4394
|
+
utilities.functional("@container", (candidate) => {
|
|
4395
|
+
if (candidate.negative)
|
|
4396
|
+
return;
|
|
4397
|
+
let value = null;
|
|
4398
|
+
if (candidate.value === null) {
|
|
4399
|
+
value = "inline-size";
|
|
4400
|
+
} else if (candidate.value.kind === "arbitrary") {
|
|
4401
|
+
value = candidate.value.value;
|
|
4402
|
+
} else if (candidate.value.kind === "named" && candidate.value.value === "normal") {
|
|
4403
|
+
value = "normal";
|
|
4404
|
+
}
|
|
4405
|
+
if (value === null)
|
|
4406
|
+
return;
|
|
4407
|
+
if (candidate.modifier) {
|
|
4408
|
+
return [decl("container-type", value), decl("container-name", candidate.modifier.value)];
|
|
4409
|
+
}
|
|
4410
|
+
return [decl("container-type", value)];
|
|
4411
|
+
});
|
|
4412
|
+
suggest("@container", () => [
|
|
4413
|
+
{
|
|
4414
|
+
values: ["normal"],
|
|
4415
|
+
valueThemeKeys: [],
|
|
4416
|
+
hasDefaultValue: false
|
|
4417
|
+
}
|
|
4418
|
+
]);
|
|
4313
4419
|
return utilities;
|
|
4314
4420
|
}
|
|
4315
4421
|
|
|
@@ -4317,6 +4423,7 @@ function createUtilities(theme) {
|
|
|
4317
4423
|
var Variants = class {
|
|
4318
4424
|
compareFns = /* @__PURE__ */ new Map();
|
|
4319
4425
|
variants = /* @__PURE__ */ new Map();
|
|
4426
|
+
completions = /* @__PURE__ */ new Map();
|
|
4320
4427
|
/**
|
|
4321
4428
|
* Registering a group of variants should result in the same sort number for
|
|
4322
4429
|
* all the variants. This is to ensure that the variants are applied in the
|
|
@@ -4348,7 +4455,7 @@ var Variants = class {
|
|
|
4348
4455
|
return this.variants.has(name);
|
|
4349
4456
|
}
|
|
4350
4457
|
get(name) {
|
|
4351
|
-
return this.variants.get(name)
|
|
4458
|
+
return this.variants.get(name);
|
|
4352
4459
|
}
|
|
4353
4460
|
kind(name) {
|
|
4354
4461
|
return this.variants.get(name)?.kind;
|
|
@@ -4356,6 +4463,12 @@ var Variants = class {
|
|
|
4356
4463
|
compounds(name) {
|
|
4357
4464
|
return this.variants.get(name)?.compounds;
|
|
4358
4465
|
}
|
|
4466
|
+
suggest(name, suggestions) {
|
|
4467
|
+
this.completions.set(name, suggestions);
|
|
4468
|
+
}
|
|
4469
|
+
getCompletions(name) {
|
|
4470
|
+
return this.completions.get(name)?.() ?? [];
|
|
4471
|
+
}
|
|
4359
4472
|
compare(a, z) {
|
|
4360
4473
|
if (a === z)
|
|
4361
4474
|
return 0;
|
|
@@ -4386,6 +4499,9 @@ var Variants = class {
|
|
|
4386
4499
|
keys() {
|
|
4387
4500
|
return this.variants.keys();
|
|
4388
4501
|
}
|
|
4502
|
+
entries() {
|
|
4503
|
+
return this.variants.entries();
|
|
4504
|
+
}
|
|
4389
4505
|
set(name, { kind, applyFn, compounds }) {
|
|
4390
4506
|
this.lastOrder = this.nextOrder();
|
|
4391
4507
|
this.variants.set(name, {
|
|
@@ -4421,11 +4537,21 @@ function createVariants(theme) {
|
|
|
4421
4537
|
ruleNode.selector = ruleNode.selector.replace("&", groupSelector);
|
|
4422
4538
|
ruleNode.selector = `&:is(${ruleNode.selector} *)`;
|
|
4423
4539
|
});
|
|
4540
|
+
variants.suggest("group", () => {
|
|
4541
|
+
return Array.from(variants.keys()).filter((name) => {
|
|
4542
|
+
return variants.get(name)?.compounds ?? false;
|
|
4543
|
+
});
|
|
4544
|
+
});
|
|
4424
4545
|
variants.compound("peer", (ruleNode, variant) => {
|
|
4425
4546
|
let peerSelector = variant.modifier ? `:where(.peer\\/${variant.modifier.value})` : ":where(.peer)";
|
|
4426
4547
|
ruleNode.selector = ruleNode.selector.replace("&", peerSelector);
|
|
4427
4548
|
ruleNode.selector = `&:is(${ruleNode.selector} ~ *)`;
|
|
4428
4549
|
});
|
|
4550
|
+
variants.suggest("peer", () => {
|
|
4551
|
+
return Array.from(variants.keys()).filter((name) => {
|
|
4552
|
+
return variants.get(name)?.compounds ?? false;
|
|
4553
|
+
});
|
|
4554
|
+
});
|
|
4429
4555
|
staticVariant("first-letter", ["&::first-letter"], { compounds: false });
|
|
4430
4556
|
staticVariant("first-line", ["&::first-line"], { compounds: false });
|
|
4431
4557
|
staticVariant("marker", ["& *::marker", "&::marker"], { compounds: false });
|
|
@@ -4522,15 +4648,31 @@ function createVariants(theme) {
|
|
|
4522
4648
|
variants.compound("has", (ruleNode) => {
|
|
4523
4649
|
ruleNode.selector = `&:has(${ruleNode.selector.replace("&", "*")})`;
|
|
4524
4650
|
});
|
|
4651
|
+
variants.suggest("has", () => {
|
|
4652
|
+
return Array.from(variants.keys()).filter((name) => {
|
|
4653
|
+
return variants.get(name)?.compounds ?? false;
|
|
4654
|
+
});
|
|
4655
|
+
});
|
|
4525
4656
|
variants.functional("aria", (ruleNode, variant) => {
|
|
4526
4657
|
if (variant.value === null)
|
|
4527
4658
|
return null;
|
|
4528
|
-
if (variant.value.kind
|
|
4659
|
+
if (variant.value.kind === "arbitrary") {
|
|
4529
4660
|
ruleNode.nodes = [rule(`&[aria-${variant.value.value}]`, ruleNode.nodes)];
|
|
4530
4661
|
} else {
|
|
4531
4662
|
ruleNode.nodes = [rule(`&[aria-${variant.value.value}="true"]`, ruleNode.nodes)];
|
|
4532
4663
|
}
|
|
4533
4664
|
});
|
|
4665
|
+
variants.suggest("aria", () => [
|
|
4666
|
+
"busy",
|
|
4667
|
+
"checked",
|
|
4668
|
+
"disabled",
|
|
4669
|
+
"expanded",
|
|
4670
|
+
"hidden",
|
|
4671
|
+
"pressed",
|
|
4672
|
+
"readonly",
|
|
4673
|
+
"required",
|
|
4674
|
+
"selected"
|
|
4675
|
+
]);
|
|
4534
4676
|
variants.functional("data", (ruleNode, variant) => {
|
|
4535
4677
|
if (variant.value === null)
|
|
4536
4678
|
return null;
|
|
@@ -4549,147 +4691,934 @@ function createVariants(theme) {
|
|
|
4549
4691
|
ruleNode.nodes = [rule(`@supports ${query}`, ruleNode.nodes)];
|
|
4550
4692
|
return;
|
|
4551
4693
|
}
|
|
4552
|
-
if (!value.includes(":")) {
|
|
4553
|
-
value = `${value}: var(--tw)`;
|
|
4694
|
+
if (!value.includes(":")) {
|
|
4695
|
+
value = `${value}: var(--tw)`;
|
|
4696
|
+
}
|
|
4697
|
+
if (value[0] !== "(" || value[value.length - 1] !== ")") {
|
|
4698
|
+
value = `(${value})`;
|
|
4699
|
+
}
|
|
4700
|
+
ruleNode.nodes = [rule(`@supports ${value}`, ruleNode.nodes)];
|
|
4701
|
+
},
|
|
4702
|
+
{ compounds: false }
|
|
4703
|
+
);
|
|
4704
|
+
staticVariant("motion-safe", ["@media (prefers-reduced-motion: no-preference)"], {
|
|
4705
|
+
compounds: false
|
|
4706
|
+
});
|
|
4707
|
+
staticVariant("motion-reduce", ["@media (prefers-reduced-motion: reduce)"], { compounds: false });
|
|
4708
|
+
staticVariant("contrast-more", ["@media (prefers-contrast: more)"], { compounds: false });
|
|
4709
|
+
staticVariant("contrast-less", ["@media (prefers-contrast: less)"], { compounds: false });
|
|
4710
|
+
{
|
|
4711
|
+
let compareBreakpoints2 = function(a, z, direction, lookup) {
|
|
4712
|
+
if (a === z)
|
|
4713
|
+
return 0;
|
|
4714
|
+
let aValue = lookup.get(a);
|
|
4715
|
+
if (aValue === null)
|
|
4716
|
+
return direction === "asc" ? -1 : 1;
|
|
4717
|
+
let zValue = lookup.get(z);
|
|
4718
|
+
if (zValue === null)
|
|
4719
|
+
return direction === "asc" ? 1 : -1;
|
|
4720
|
+
if (aValue === zValue)
|
|
4721
|
+
return 0;
|
|
4722
|
+
let aIsCssFunction = aValue.indexOf("(");
|
|
4723
|
+
let zIsCssFunction = zValue.indexOf("(");
|
|
4724
|
+
let aBucket = aIsCssFunction === -1 ? (
|
|
4725
|
+
// No CSS function found, bucket by unit instead
|
|
4726
|
+
aValue.replace(/[\d.]+/g, "")
|
|
4727
|
+
) : (
|
|
4728
|
+
// CSS function found, bucket by function name
|
|
4729
|
+
aValue.slice(0, aIsCssFunction)
|
|
4730
|
+
);
|
|
4731
|
+
let zBucket = zIsCssFunction === -1 ? (
|
|
4732
|
+
// No CSS function found, bucket by unit
|
|
4733
|
+
zValue.replace(/[\d.]+/g, "")
|
|
4734
|
+
) : (
|
|
4735
|
+
// CSS function found, bucket by function name
|
|
4736
|
+
zValue.slice(0, zIsCssFunction)
|
|
4737
|
+
);
|
|
4738
|
+
let order = (
|
|
4739
|
+
// Compare by bucket name
|
|
4740
|
+
aBucket.localeCompare(zBucket) || // If bucket names are the same, compare by value
|
|
4741
|
+
(direction === "asc" ? parseInt(aValue) - parseInt(zValue) : parseInt(zValue) - parseInt(aValue))
|
|
4742
|
+
);
|
|
4743
|
+
if (Number.isNaN(order)) {
|
|
4744
|
+
return aValue.localeCompare(zValue);
|
|
4745
|
+
}
|
|
4746
|
+
return order;
|
|
4747
|
+
};
|
|
4748
|
+
{
|
|
4749
|
+
let breakpoints = theme.namespace("--breakpoint");
|
|
4750
|
+
let resolvedBreakpoints = new DefaultMap((variant) => {
|
|
4751
|
+
switch (variant.kind) {
|
|
4752
|
+
case "static": {
|
|
4753
|
+
return breakpoints.get(variant.root) ?? null;
|
|
4754
|
+
}
|
|
4755
|
+
case "functional": {
|
|
4756
|
+
if (variant.value === null)
|
|
4757
|
+
return null;
|
|
4758
|
+
let value = null;
|
|
4759
|
+
if (variant.value.kind === "arbitrary") {
|
|
4760
|
+
value = variant.value.value;
|
|
4761
|
+
} else if (variant.value.kind === "named") {
|
|
4762
|
+
value = theme.resolve(variant.value.value, ["--breakpoint"]);
|
|
4763
|
+
}
|
|
4764
|
+
if (!value)
|
|
4765
|
+
return null;
|
|
4766
|
+
if (value.includes("var("))
|
|
4767
|
+
return null;
|
|
4768
|
+
return value;
|
|
4769
|
+
}
|
|
4770
|
+
case "arbitrary":
|
|
4771
|
+
case "compound":
|
|
4772
|
+
return null;
|
|
4773
|
+
}
|
|
4774
|
+
});
|
|
4775
|
+
variants.group(
|
|
4776
|
+
() => {
|
|
4777
|
+
variants.functional(
|
|
4778
|
+
"max",
|
|
4779
|
+
(ruleNode, variant) => {
|
|
4780
|
+
let value = resolvedBreakpoints.get(variant);
|
|
4781
|
+
if (value === null)
|
|
4782
|
+
return null;
|
|
4783
|
+
ruleNode.nodes = [rule(`@media (width < ${value})`, ruleNode.nodes)];
|
|
4784
|
+
},
|
|
4785
|
+
{ compounds: false }
|
|
4786
|
+
);
|
|
4787
|
+
},
|
|
4788
|
+
(a, z) => compareBreakpoints2(a, z, "desc", resolvedBreakpoints)
|
|
4789
|
+
);
|
|
4790
|
+
variants.suggest(
|
|
4791
|
+
"max",
|
|
4792
|
+
() => Array.from(breakpoints.keys()).filter((key) => key !== null)
|
|
4793
|
+
);
|
|
4794
|
+
variants.group(
|
|
4795
|
+
() => {
|
|
4796
|
+
for (let [key, value] of theme.namespace("--breakpoint")) {
|
|
4797
|
+
if (key === null)
|
|
4798
|
+
continue;
|
|
4799
|
+
variants.static(
|
|
4800
|
+
key,
|
|
4801
|
+
(ruleNode) => {
|
|
4802
|
+
ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
|
|
4803
|
+
},
|
|
4804
|
+
{ compounds: false }
|
|
4805
|
+
);
|
|
4806
|
+
}
|
|
4807
|
+
variants.functional(
|
|
4808
|
+
"min",
|
|
4809
|
+
(ruleNode, variant) => {
|
|
4810
|
+
let value = resolvedBreakpoints.get(variant);
|
|
4811
|
+
if (value === null)
|
|
4812
|
+
return null;
|
|
4813
|
+
ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
|
|
4814
|
+
},
|
|
4815
|
+
{ compounds: false }
|
|
4816
|
+
);
|
|
4817
|
+
},
|
|
4818
|
+
(a, z) => compareBreakpoints2(a, z, "asc", resolvedBreakpoints)
|
|
4819
|
+
);
|
|
4820
|
+
variants.suggest(
|
|
4821
|
+
"min",
|
|
4822
|
+
() => Array.from(breakpoints.keys()).filter((key) => key !== null)
|
|
4823
|
+
);
|
|
4824
|
+
}
|
|
4825
|
+
{
|
|
4826
|
+
let widths = theme.namespace("--width");
|
|
4827
|
+
let resolvedWidths = new DefaultMap((variant) => {
|
|
4828
|
+
switch (variant.kind) {
|
|
4829
|
+
case "functional": {
|
|
4830
|
+
if (variant.value === null)
|
|
4831
|
+
return null;
|
|
4832
|
+
let value = null;
|
|
4833
|
+
if (variant.value.kind === "arbitrary") {
|
|
4834
|
+
value = variant.value.value;
|
|
4835
|
+
} else if (variant.value.kind === "named") {
|
|
4836
|
+
value = theme.resolve(variant.value.value, ["--width"]);
|
|
4837
|
+
}
|
|
4838
|
+
if (!value)
|
|
4839
|
+
return null;
|
|
4840
|
+
if (value.includes("var("))
|
|
4841
|
+
return null;
|
|
4842
|
+
return value;
|
|
4843
|
+
}
|
|
4844
|
+
case "static":
|
|
4845
|
+
case "arbitrary":
|
|
4846
|
+
case "compound":
|
|
4847
|
+
return null;
|
|
4848
|
+
}
|
|
4849
|
+
});
|
|
4850
|
+
variants.group(
|
|
4851
|
+
() => {
|
|
4852
|
+
variants.functional(
|
|
4853
|
+
"@max",
|
|
4854
|
+
(ruleNode, variant) => {
|
|
4855
|
+
let value = resolvedWidths.get(variant);
|
|
4856
|
+
if (value === null)
|
|
4857
|
+
return null;
|
|
4858
|
+
ruleNode.nodes = [
|
|
4859
|
+
rule(
|
|
4860
|
+
variant.modifier ? `@container ${variant.modifier.value} (width < ${value})` : `@container (width < ${value})`,
|
|
4861
|
+
ruleNode.nodes
|
|
4862
|
+
)
|
|
4863
|
+
];
|
|
4864
|
+
},
|
|
4865
|
+
{ compounds: false }
|
|
4866
|
+
);
|
|
4867
|
+
},
|
|
4868
|
+
(a, z) => compareBreakpoints2(a, z, "desc", resolvedWidths)
|
|
4869
|
+
);
|
|
4870
|
+
variants.suggest(
|
|
4871
|
+
"@max",
|
|
4872
|
+
() => Array.from(widths.keys()).filter((key) => key !== null)
|
|
4873
|
+
);
|
|
4874
|
+
variants.group(
|
|
4875
|
+
() => {
|
|
4876
|
+
variants.functional(
|
|
4877
|
+
"@",
|
|
4878
|
+
(ruleNode, variant) => {
|
|
4879
|
+
let value = resolvedWidths.get(variant);
|
|
4880
|
+
if (value === null)
|
|
4881
|
+
return null;
|
|
4882
|
+
ruleNode.nodes = [
|
|
4883
|
+
rule(
|
|
4884
|
+
variant.modifier ? `@container ${variant.modifier.value} (width >= ${value})` : `@container (width >= ${value})`,
|
|
4885
|
+
ruleNode.nodes
|
|
4886
|
+
)
|
|
4887
|
+
];
|
|
4888
|
+
},
|
|
4889
|
+
{ compounds: false }
|
|
4890
|
+
);
|
|
4891
|
+
variants.functional(
|
|
4892
|
+
"@min",
|
|
4893
|
+
(ruleNode, variant) => {
|
|
4894
|
+
let value = resolvedWidths.get(variant);
|
|
4895
|
+
if (value === null)
|
|
4896
|
+
return null;
|
|
4897
|
+
ruleNode.nodes = [
|
|
4898
|
+
rule(
|
|
4899
|
+
variant.modifier ? `@container ${variant.modifier.value} (width >= ${value})` : `@container (width >= ${value})`,
|
|
4900
|
+
ruleNode.nodes
|
|
4901
|
+
)
|
|
4902
|
+
];
|
|
4903
|
+
},
|
|
4904
|
+
{ compounds: false }
|
|
4905
|
+
);
|
|
4906
|
+
},
|
|
4907
|
+
(a, z) => compareBreakpoints2(a, z, "asc", resolvedWidths)
|
|
4908
|
+
);
|
|
4909
|
+
variants.suggest(
|
|
4910
|
+
"@min",
|
|
4911
|
+
() => Array.from(widths.keys()).filter((key) => key !== null)
|
|
4912
|
+
);
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
staticVariant("portrait", ["@media (orientation: portrait)"], { compounds: false });
|
|
4916
|
+
staticVariant("landscape", ["@media (orientation: landscape)"], { compounds: false });
|
|
4917
|
+
staticVariant("ltr", ['&:where([dir="ltr"], [dir="ltr"] *)']);
|
|
4918
|
+
staticVariant("rtl", ['&:where([dir="rtl"], [dir="rtl"] *)']);
|
|
4919
|
+
staticVariant("dark", ["@media (prefers-color-scheme: dark)"], { compounds: false });
|
|
4920
|
+
staticVariant("print", ["@media print"], { compounds: false });
|
|
4921
|
+
staticVariant("forced-colors", ["@media (forced-colors: active)"], { compounds: false });
|
|
4922
|
+
return variants;
|
|
4923
|
+
}
|
|
4924
|
+
|
|
4925
|
+
// src/design-system.ts
|
|
4926
|
+
function buildDesignSystem(theme) {
|
|
4927
|
+
return {
|
|
4928
|
+
theme,
|
|
4929
|
+
utilities: createUtilities(theme),
|
|
4930
|
+
variants: createVariants(theme),
|
|
4931
|
+
candidatesToCss(classes) {
|
|
4932
|
+
let result = [];
|
|
4933
|
+
for (let className of classes) {
|
|
4934
|
+
let { astNodes } = compileCandidates([className], this, { throwOnInvalidCandidate: false });
|
|
4935
|
+
if (astNodes.length === 0) {
|
|
4936
|
+
result.push(null);
|
|
4937
|
+
} else {
|
|
4938
|
+
result.push(toCss(astNodes));
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
return result;
|
|
4942
|
+
},
|
|
4943
|
+
getClassOrder(classes) {
|
|
4944
|
+
return getClassOrder(this, classes);
|
|
4945
|
+
},
|
|
4946
|
+
getClassList() {
|
|
4947
|
+
return getClassList(this);
|
|
4948
|
+
},
|
|
4949
|
+
getVariants() {
|
|
4950
|
+
return getVariants(this);
|
|
4951
|
+
}
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
|
|
4955
|
+
// src/property-order.ts
|
|
4956
|
+
var property_order_default = [
|
|
4957
|
+
"container-type",
|
|
4958
|
+
"pointer-events",
|
|
4959
|
+
"visibility",
|
|
4960
|
+
"position",
|
|
4961
|
+
// How do we make `inset-x-0` come before `top-0`?
|
|
4962
|
+
"inset",
|
|
4963
|
+
"inset-inline",
|
|
4964
|
+
"inset-block",
|
|
4965
|
+
"inset-inline-start",
|
|
4966
|
+
"inset-inline-end",
|
|
4967
|
+
"top",
|
|
4968
|
+
"right",
|
|
4969
|
+
"bottom",
|
|
4970
|
+
"left",
|
|
4971
|
+
"isolation",
|
|
4972
|
+
"z-index",
|
|
4973
|
+
"order",
|
|
4974
|
+
"grid-column",
|
|
4975
|
+
"grid-column-start",
|
|
4976
|
+
"grid-column-end",
|
|
4977
|
+
"grid-row",
|
|
4978
|
+
"grid-row-start",
|
|
4979
|
+
"grid-row-end",
|
|
4980
|
+
"float",
|
|
4981
|
+
"clear",
|
|
4982
|
+
// How do we make `mx-0` come before `mt-0`?
|
|
4983
|
+
// Idea: `margin-x` property that we compile away with a Visitor plugin?
|
|
4984
|
+
"margin",
|
|
4985
|
+
"margin-inline",
|
|
4986
|
+
"margin-block",
|
|
4987
|
+
"margin-inline-start",
|
|
4988
|
+
"margin-inline-end",
|
|
4989
|
+
"margin-top",
|
|
4990
|
+
"margin-right",
|
|
4991
|
+
"margin-bottom",
|
|
4992
|
+
"margin-left",
|
|
4993
|
+
"box-sizing",
|
|
4994
|
+
"display",
|
|
4995
|
+
"aspect-ratio",
|
|
4996
|
+
"height",
|
|
4997
|
+
"max-height",
|
|
4998
|
+
"min-height",
|
|
4999
|
+
"width",
|
|
5000
|
+
"max-width",
|
|
5001
|
+
"min-width",
|
|
5002
|
+
"flex",
|
|
5003
|
+
"flex-shrink",
|
|
5004
|
+
"flex-grow",
|
|
5005
|
+
"flex-basis",
|
|
5006
|
+
"table-layout",
|
|
5007
|
+
"caption-side",
|
|
5008
|
+
"border-collapse",
|
|
5009
|
+
// There's no `border-spacing-x` property, we use variables, how to sort?
|
|
5010
|
+
"border-spacing",
|
|
5011
|
+
// '--tw-border-spacing-x',
|
|
5012
|
+
// '--tw-border-spacing-y',
|
|
5013
|
+
"transform-origin",
|
|
5014
|
+
// '--tw-translate-x',
|
|
5015
|
+
// '--tw-translate-y',
|
|
5016
|
+
"translate",
|
|
5017
|
+
"rotate",
|
|
5018
|
+
// '--tw-rotate',
|
|
5019
|
+
"--tw-skew-x",
|
|
5020
|
+
"--tw-skew-y",
|
|
5021
|
+
"scale",
|
|
5022
|
+
// '--tw-scale-x',
|
|
5023
|
+
// '--tw-scale-y',
|
|
5024
|
+
"transform",
|
|
5025
|
+
"animation",
|
|
5026
|
+
"cursor",
|
|
5027
|
+
"touch-action",
|
|
5028
|
+
"--tw-pan-x",
|
|
5029
|
+
"--tw-pan-y",
|
|
5030
|
+
"--tw-pinch-zoom",
|
|
5031
|
+
"resize",
|
|
5032
|
+
"scroll-snap-type",
|
|
5033
|
+
"--tw-scroll-snap-strictness",
|
|
5034
|
+
"scroll-snap-align",
|
|
5035
|
+
"scroll-snap-stop",
|
|
5036
|
+
"scroll-margin",
|
|
5037
|
+
"scroll-margin-inline-start",
|
|
5038
|
+
"scroll-margin-inline-end",
|
|
5039
|
+
"scroll-margin-top",
|
|
5040
|
+
"scroll-margin-right",
|
|
5041
|
+
"scroll-margin-bottom",
|
|
5042
|
+
"scroll-margin-left",
|
|
5043
|
+
"scroll-padding",
|
|
5044
|
+
"scroll-padding-inline-start",
|
|
5045
|
+
"scroll-padding-inline-end",
|
|
5046
|
+
"scroll-padding-top",
|
|
5047
|
+
"scroll-padding-right",
|
|
5048
|
+
"scroll-padding-bottom",
|
|
5049
|
+
"scroll-padding-left",
|
|
5050
|
+
"list-style-position",
|
|
5051
|
+
"list-style-type",
|
|
5052
|
+
"list-style-image",
|
|
5053
|
+
"appearance",
|
|
5054
|
+
"columns",
|
|
5055
|
+
"break-before",
|
|
5056
|
+
"break-inside",
|
|
5057
|
+
"break-after",
|
|
5058
|
+
"grid-auto-columns",
|
|
5059
|
+
"grid-auto-flow",
|
|
5060
|
+
"grid-auto-rows",
|
|
5061
|
+
"grid-template-columns",
|
|
5062
|
+
"grid-template-rows",
|
|
5063
|
+
"flex-direction",
|
|
5064
|
+
"flex-wrap",
|
|
5065
|
+
"place-content",
|
|
5066
|
+
"place-items",
|
|
5067
|
+
"align-content",
|
|
5068
|
+
"align-items",
|
|
5069
|
+
"justify-content",
|
|
5070
|
+
"justify-items",
|
|
5071
|
+
"gap",
|
|
5072
|
+
"column-gap",
|
|
5073
|
+
"row-gap",
|
|
5074
|
+
"--tw-space-x-reverse",
|
|
5075
|
+
"--tw-space-y-reverse",
|
|
5076
|
+
// Is there a more "real" property we could use for this?
|
|
5077
|
+
"divide-x-width",
|
|
5078
|
+
"divide-y-width",
|
|
5079
|
+
"--tw-divide-y-reverse",
|
|
5080
|
+
"divide-style",
|
|
5081
|
+
"divide-color",
|
|
5082
|
+
"--tw-divide-opacity",
|
|
5083
|
+
"place-self",
|
|
5084
|
+
"align-self",
|
|
5085
|
+
"justify-self",
|
|
5086
|
+
"overflow",
|
|
5087
|
+
"overflow-x",
|
|
5088
|
+
"overflow-y",
|
|
5089
|
+
"overscroll-behavior",
|
|
5090
|
+
"overscroll-behavior-x",
|
|
5091
|
+
"overscroll-behavior-y",
|
|
5092
|
+
"scroll-behavior",
|
|
5093
|
+
"text-overflow",
|
|
5094
|
+
"hyphens",
|
|
5095
|
+
"white-space",
|
|
5096
|
+
"text-wrap",
|
|
5097
|
+
"overflow-wrap",
|
|
5098
|
+
"work-break",
|
|
5099
|
+
"border-radius",
|
|
5100
|
+
"border-start-radius",
|
|
5101
|
+
// Not real
|
|
5102
|
+
"border-end-radius",
|
|
5103
|
+
// Not real
|
|
5104
|
+
"border-top-radius",
|
|
5105
|
+
// Not real
|
|
5106
|
+
"border-right-radius",
|
|
5107
|
+
// Not real
|
|
5108
|
+
"border-bottom-radius",
|
|
5109
|
+
// Not real
|
|
5110
|
+
"border-left-radius",
|
|
5111
|
+
// Not real
|
|
5112
|
+
"border-start-start-radius",
|
|
5113
|
+
"border-start-end-radius",
|
|
5114
|
+
"border-end-end-radius",
|
|
5115
|
+
"border-end-start-radius",
|
|
5116
|
+
"border-top-left-radius",
|
|
5117
|
+
"border-top-right-radius",
|
|
5118
|
+
"border-bottom-right-radius",
|
|
5119
|
+
"border-bottom-left-radius",
|
|
5120
|
+
"border-width",
|
|
5121
|
+
"border-inline-width",
|
|
5122
|
+
// Not real
|
|
5123
|
+
"border-inline-start-width",
|
|
5124
|
+
"border-inline-end-width",
|
|
5125
|
+
"border-top-width",
|
|
5126
|
+
"border-right-width",
|
|
5127
|
+
"border-bottom-width",
|
|
5128
|
+
"border-left-width",
|
|
5129
|
+
"border-style",
|
|
5130
|
+
"border-color",
|
|
5131
|
+
"border-x-color",
|
|
5132
|
+
// Not real
|
|
5133
|
+
"border-y-color",
|
|
5134
|
+
// Not real
|
|
5135
|
+
"border-inline-start-color",
|
|
5136
|
+
"border-inline-end-color",
|
|
5137
|
+
"border-top-color",
|
|
5138
|
+
"border-right-color",
|
|
5139
|
+
"border-bottom-color",
|
|
5140
|
+
"border-left-color",
|
|
5141
|
+
"--tw-border-opacity",
|
|
5142
|
+
"background-color",
|
|
5143
|
+
"--tw-bg-opacity",
|
|
5144
|
+
"background-image",
|
|
5145
|
+
"--tw-gradient-stops",
|
|
5146
|
+
"--tw-gradient-via-stops",
|
|
5147
|
+
"--tw-gradient-from",
|
|
5148
|
+
"--tw-gradient-from-position",
|
|
5149
|
+
"--tw-gradient-via",
|
|
5150
|
+
"--tw-gradient-via-position",
|
|
5151
|
+
"--tw-gradient-to",
|
|
5152
|
+
"--tw-gradient-to-position",
|
|
5153
|
+
"box-decoration-break",
|
|
5154
|
+
"background-size",
|
|
5155
|
+
"background-attachment",
|
|
5156
|
+
"background-clip",
|
|
5157
|
+
"background-position",
|
|
5158
|
+
"background-repeat",
|
|
5159
|
+
"background-origin",
|
|
5160
|
+
"fill",
|
|
5161
|
+
"stroke",
|
|
5162
|
+
"stroke-width",
|
|
5163
|
+
"object-fit",
|
|
5164
|
+
"object-position",
|
|
5165
|
+
"padding",
|
|
5166
|
+
"padding-inline",
|
|
5167
|
+
"padding-block",
|
|
5168
|
+
"padding-inline-start",
|
|
5169
|
+
"padding-inline-end",
|
|
5170
|
+
"padding-top",
|
|
5171
|
+
"padding-right",
|
|
5172
|
+
"padding-bottom",
|
|
5173
|
+
"padding-left",
|
|
5174
|
+
"text-align",
|
|
5175
|
+
"text-indent",
|
|
5176
|
+
"vertical-align",
|
|
5177
|
+
"font-family",
|
|
5178
|
+
"font-size",
|
|
5179
|
+
"font-weight",
|
|
5180
|
+
"text-transform",
|
|
5181
|
+
"font-style",
|
|
5182
|
+
"font-variant-numeric",
|
|
5183
|
+
"line-height",
|
|
5184
|
+
"letter-spacing",
|
|
5185
|
+
"color",
|
|
5186
|
+
"--tw-text-opacity",
|
|
5187
|
+
"text-decoration-line",
|
|
5188
|
+
"text-decoration-color",
|
|
5189
|
+
"text-decoration-style",
|
|
5190
|
+
"text-decoration-thickness",
|
|
5191
|
+
"text-underline-offset",
|
|
5192
|
+
"-webkit-font-smoothing",
|
|
5193
|
+
"placeholder-color",
|
|
5194
|
+
// Not real
|
|
5195
|
+
"--tw-placeholder-opacity",
|
|
5196
|
+
"caret-color",
|
|
5197
|
+
"accent-color",
|
|
5198
|
+
"opacity",
|
|
5199
|
+
"background-blend-mode",
|
|
5200
|
+
"mix-blend-mode",
|
|
5201
|
+
"box-shadow",
|
|
5202
|
+
"--tw-shadow",
|
|
5203
|
+
"--tw-shadow-color",
|
|
5204
|
+
"--tw-ring-shadow",
|
|
5205
|
+
"--tw-ring-color",
|
|
5206
|
+
"--tw-inset-shadow",
|
|
5207
|
+
"--tw-inset-shadow-color",
|
|
5208
|
+
"--tw-inset-ring-shadow",
|
|
5209
|
+
"--tw-inset-ring-color",
|
|
5210
|
+
"--tw-ring-opacity",
|
|
5211
|
+
"--tw-ring-offset-width",
|
|
5212
|
+
"--tw-ring-offset-color",
|
|
5213
|
+
"outline",
|
|
5214
|
+
"outline-width",
|
|
5215
|
+
"outline-offset",
|
|
5216
|
+
"outline-color",
|
|
5217
|
+
"--tw-blur",
|
|
5218
|
+
"--tw-brightness",
|
|
5219
|
+
"--tw-contast",
|
|
5220
|
+
"--tw-drop-shadow",
|
|
5221
|
+
"--tw-grayscale",
|
|
5222
|
+
"--tw-hue-rotate",
|
|
5223
|
+
"--tw-invert",
|
|
5224
|
+
"--tw-saturate",
|
|
5225
|
+
"--tw-sepia",
|
|
5226
|
+
"filter",
|
|
5227
|
+
"--tw-backdrop-blur",
|
|
5228
|
+
"--tw-backdrop-brightness",
|
|
5229
|
+
"--tw-backdrop-contast",
|
|
5230
|
+
"--tw-backdrop-grayscale",
|
|
5231
|
+
"--tw-backdrop-hue-rotate",
|
|
5232
|
+
"--tw-backdrop-invert",
|
|
5233
|
+
"--tw-backdrop-opacity",
|
|
5234
|
+
"--tw-backdrop-saturate",
|
|
5235
|
+
"--tw-backdrop-sepia",
|
|
5236
|
+
"backdrop-filter",
|
|
5237
|
+
"transition-property",
|
|
5238
|
+
"transition-delay",
|
|
5239
|
+
"transition-duration",
|
|
5240
|
+
"transition-timing-function",
|
|
5241
|
+
"will-change",
|
|
5242
|
+
"contain",
|
|
5243
|
+
"content",
|
|
5244
|
+
"forced-color-adjust"
|
|
5245
|
+
];
|
|
5246
|
+
|
|
5247
|
+
// src/utils/escape.ts
|
|
5248
|
+
function escape(value) {
|
|
5249
|
+
if (arguments.length == 0) {
|
|
5250
|
+
throw new TypeError("`CSS.escape` requires an argument.");
|
|
5251
|
+
}
|
|
5252
|
+
var string = String(value);
|
|
5253
|
+
var length = string.length;
|
|
5254
|
+
var index = -1;
|
|
5255
|
+
var codeUnit;
|
|
5256
|
+
var result = "";
|
|
5257
|
+
var firstCodeUnit = string.charCodeAt(0);
|
|
5258
|
+
if (
|
|
5259
|
+
// If the character is the first character and is a `-` (U+002D), and
|
|
5260
|
+
// there is no second character, […]
|
|
5261
|
+
length == 1 && firstCodeUnit == 45
|
|
5262
|
+
) {
|
|
5263
|
+
return "\\" + string;
|
|
5264
|
+
}
|
|
5265
|
+
while (++index < length) {
|
|
5266
|
+
codeUnit = string.charCodeAt(index);
|
|
5267
|
+
if (codeUnit == 0) {
|
|
5268
|
+
result += "\uFFFD";
|
|
5269
|
+
continue;
|
|
5270
|
+
}
|
|
5271
|
+
if (
|
|
5272
|
+
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
5273
|
+
// U+007F, […]
|
|
5274
|
+
codeUnit >= 1 && codeUnit <= 31 || codeUnit == 127 || // If the character is the first character and is in the range [0-9]
|
|
5275
|
+
// (U+0030 to U+0039), […]
|
|
5276
|
+
index == 0 && codeUnit >= 48 && codeUnit <= 57 || // If the character is the second character and is in the range [0-9]
|
|
5277
|
+
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
5278
|
+
index == 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit == 45
|
|
5279
|
+
) {
|
|
5280
|
+
result += "\\" + codeUnit.toString(16) + " ";
|
|
5281
|
+
continue;
|
|
5282
|
+
}
|
|
5283
|
+
if (codeUnit >= 128 || codeUnit == 45 || codeUnit == 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) {
|
|
5284
|
+
result += string.charAt(index);
|
|
5285
|
+
continue;
|
|
5286
|
+
}
|
|
5287
|
+
result += "\\" + string.charAt(index);
|
|
5288
|
+
}
|
|
5289
|
+
return result;
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
// src/compile.ts
|
|
5293
|
+
function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidate = false } = {}) {
|
|
5294
|
+
rawCandidates.sort();
|
|
5295
|
+
let nodeSorting = /* @__PURE__ */ new Map();
|
|
5296
|
+
let astNodes = [];
|
|
5297
|
+
let parsedVariants = new DefaultMap((variant, map) => {
|
|
5298
|
+
return parseVariant(variant, designSystem.variants, map);
|
|
5299
|
+
});
|
|
5300
|
+
let candidates = /* @__PURE__ */ new Map();
|
|
5301
|
+
for (let rawCandidate of rawCandidates) {
|
|
5302
|
+
let candidate = parseCandidate(rawCandidate, designSystem.utilities, parsedVariants);
|
|
5303
|
+
if (candidate === null) {
|
|
5304
|
+
if (throwOnInvalidCandidate) {
|
|
5305
|
+
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
5306
|
+
}
|
|
5307
|
+
continue;
|
|
5308
|
+
}
|
|
5309
|
+
candidates.set(candidate, rawCandidate);
|
|
5310
|
+
}
|
|
5311
|
+
let variants = Array.from(parsedVariants.values()).sort((a, z) => {
|
|
5312
|
+
return designSystem.variants.compare(a, z);
|
|
5313
|
+
});
|
|
5314
|
+
next:
|
|
5315
|
+
for (let [candidate, rawCandidate] of candidates) {
|
|
5316
|
+
let nodes = [];
|
|
5317
|
+
if (candidate.kind === "arbitrary") {
|
|
5318
|
+
let compileFn = designSystem.utilities.getArbitrary();
|
|
5319
|
+
let compiledNodes = compileFn(candidate);
|
|
5320
|
+
if (compiledNodes === void 0) {
|
|
5321
|
+
if (throwOnInvalidCandidate) {
|
|
5322
|
+
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
5323
|
+
}
|
|
5324
|
+
continue next;
|
|
5325
|
+
}
|
|
5326
|
+
nodes = compiledNodes;
|
|
5327
|
+
} else if (candidate.kind === "static" || candidate.kind === "functional") {
|
|
5328
|
+
let { compileFn } = designSystem.utilities.get(candidate.root);
|
|
5329
|
+
let compiledNodes = compileFn(candidate);
|
|
5330
|
+
if (compiledNodes === void 0) {
|
|
5331
|
+
if (throwOnInvalidCandidate) {
|
|
5332
|
+
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
5333
|
+
}
|
|
5334
|
+
continue next;
|
|
5335
|
+
}
|
|
5336
|
+
nodes = compiledNodes;
|
|
5337
|
+
}
|
|
5338
|
+
let propertySort = getPropertySort(nodes);
|
|
5339
|
+
if (candidate.important) {
|
|
5340
|
+
applyImportant(nodes);
|
|
5341
|
+
}
|
|
5342
|
+
let node = {
|
|
5343
|
+
kind: "rule",
|
|
5344
|
+
selector: `.${escape(rawCandidate)}`,
|
|
5345
|
+
nodes
|
|
5346
|
+
};
|
|
5347
|
+
let variantOrder = 0n;
|
|
5348
|
+
for (let variant of candidate.variants) {
|
|
5349
|
+
let result = applyVariant(node, variant, designSystem.variants);
|
|
5350
|
+
if (result === null) {
|
|
5351
|
+
if (throwOnInvalidCandidate) {
|
|
5352
|
+
throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
|
|
5353
|
+
}
|
|
5354
|
+
continue next;
|
|
5355
|
+
}
|
|
5356
|
+
variantOrder |= 1n << BigInt(variants.indexOf(variant));
|
|
5357
|
+
}
|
|
5358
|
+
nodeSorting.set(node, {
|
|
5359
|
+
properties: propertySort,
|
|
5360
|
+
variants: variantOrder,
|
|
5361
|
+
candidate: rawCandidate
|
|
5362
|
+
});
|
|
5363
|
+
astNodes.push(node);
|
|
5364
|
+
}
|
|
5365
|
+
astNodes.sort((a, z) => {
|
|
5366
|
+
let aSorting = nodeSorting.get(a);
|
|
5367
|
+
let zSorting = nodeSorting.get(z);
|
|
5368
|
+
if (aSorting.variants - zSorting.variants !== 0n) {
|
|
5369
|
+
return Number(aSorting.variants - zSorting.variants);
|
|
5370
|
+
}
|
|
5371
|
+
let offset = 0;
|
|
5372
|
+
while (aSorting.properties.length < offset && zSorting.properties.length < offset && aSorting.properties[offset] === zSorting.properties[offset]) {
|
|
5373
|
+
offset += 1;
|
|
5374
|
+
}
|
|
5375
|
+
return (
|
|
5376
|
+
// Sort by lowest property index first
|
|
5377
|
+
(aSorting.properties[offset] ?? Infinity) - (zSorting.properties[offset] ?? Infinity) || // Sort by most properties first, then by least properties
|
|
5378
|
+
zSorting.properties.length - aSorting.properties.length
|
|
5379
|
+
);
|
|
5380
|
+
});
|
|
5381
|
+
return {
|
|
5382
|
+
astNodes,
|
|
5383
|
+
nodeSorting
|
|
5384
|
+
};
|
|
5385
|
+
}
|
|
5386
|
+
function applyVariant(node, variant, variants) {
|
|
5387
|
+
if (variant.kind === "arbitrary") {
|
|
5388
|
+
node.nodes = [rule(variant.selector, node.nodes)];
|
|
5389
|
+
return;
|
|
5390
|
+
}
|
|
5391
|
+
let { applyFn } = variants.get(variant.root);
|
|
5392
|
+
if (variant.kind === "compound") {
|
|
5393
|
+
let result2 = applyVariant(node, variant.variant, variants);
|
|
5394
|
+
if (result2 === null)
|
|
5395
|
+
return null;
|
|
5396
|
+
for (let child of node.nodes) {
|
|
5397
|
+
if (child.kind !== "rule")
|
|
5398
|
+
return null;
|
|
5399
|
+
let result3 = applyFn(child, variant);
|
|
5400
|
+
if (result3 === null)
|
|
5401
|
+
return null;
|
|
5402
|
+
}
|
|
5403
|
+
return;
|
|
5404
|
+
}
|
|
5405
|
+
let result = applyFn(node, variant);
|
|
5406
|
+
if (result === null)
|
|
5407
|
+
return null;
|
|
5408
|
+
}
|
|
5409
|
+
function applyImportant(ast) {
|
|
5410
|
+
for (let node of ast) {
|
|
5411
|
+
if (node.kind === "rule" && node.selector === "@at-root") {
|
|
5412
|
+
continue;
|
|
5413
|
+
}
|
|
5414
|
+
if (node.kind === "declaration") {
|
|
5415
|
+
node.important = true;
|
|
5416
|
+
} else if (node.kind === "rule") {
|
|
5417
|
+
applyImportant(node.nodes);
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
function getPropertySort(nodes) {
|
|
5422
|
+
let propertySort = /* @__PURE__ */ new Set();
|
|
5423
|
+
let q = nodes.slice();
|
|
5424
|
+
while (q.length > 0) {
|
|
5425
|
+
let node = q.shift();
|
|
5426
|
+
if (node.kind === "declaration") {
|
|
5427
|
+
if (node.property === "--tw-sort") {
|
|
5428
|
+
let idx2 = property_order_default.indexOf(node.value);
|
|
5429
|
+
if (idx2 !== -1) {
|
|
5430
|
+
propertySort.add(idx2);
|
|
5431
|
+
break;
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
let idx = property_order_default.indexOf(node.property);
|
|
5435
|
+
if (idx !== -1)
|
|
5436
|
+
propertySort.add(idx);
|
|
5437
|
+
} else if (node.kind === "rule") {
|
|
5438
|
+
if (node.selector === "@at-root")
|
|
5439
|
+
continue;
|
|
5440
|
+
for (let child of node.nodes) {
|
|
5441
|
+
q.push(child);
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
return Array.from(propertySort).sort((a, z) => a - z);
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
// src/css-parser.ts
|
|
5449
|
+
function parse(input) {
|
|
5450
|
+
let ast = [];
|
|
5451
|
+
let licenseComments = [];
|
|
5452
|
+
let stack = [];
|
|
5453
|
+
let parent = null;
|
|
5454
|
+
let node = null;
|
|
5455
|
+
let current = "";
|
|
5456
|
+
let closingBracketStack = "";
|
|
5457
|
+
for (let i = 0; i < input.length; i++) {
|
|
5458
|
+
let char = input[i];
|
|
5459
|
+
if (char === "\\") {
|
|
5460
|
+
current += input.slice(i, i + 2);
|
|
5461
|
+
i += 1;
|
|
5462
|
+
} else if (char === "/" && input[i + 1] === "*") {
|
|
5463
|
+
let start = i;
|
|
5464
|
+
for (let j = i + 2; j < input.length; j++) {
|
|
5465
|
+
if (input[j] === "\\") {
|
|
5466
|
+
j += 1;
|
|
5467
|
+
} else if (input[j] === "*" && input[j + 1] === "/") {
|
|
5468
|
+
i = j + 1;
|
|
5469
|
+
break;
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
let commentString = input.slice(start, i + 1);
|
|
5473
|
+
if (commentString[2] === "!") {
|
|
5474
|
+
licenseComments.push(comment(commentString.slice(2, -2)));
|
|
5475
|
+
}
|
|
5476
|
+
} else if (char === '"' || char === "'") {
|
|
5477
|
+
let start = i;
|
|
5478
|
+
for (let j = i + 1; j < input.length; j++) {
|
|
5479
|
+
if (input[j] === "\\") {
|
|
5480
|
+
j += 1;
|
|
5481
|
+
} else if (input[j] === char) {
|
|
5482
|
+
i = j;
|
|
5483
|
+
break;
|
|
5484
|
+
} else if (input[j] === ";" && input[j + 1] === "\n") {
|
|
5485
|
+
throw new Error(`Unterminated string: ${input.slice(start, j + 1) + char}`);
|
|
5486
|
+
} else if (input[j] === "\n") {
|
|
5487
|
+
throw new Error(`Unterminated string: ${input.slice(start, j) + char}`);
|
|
5488
|
+
}
|
|
5489
|
+
}
|
|
5490
|
+
current += input.slice(start, i + 1);
|
|
5491
|
+
} else if ((char === " " || char === "\n" || char === " ") && (input[i + 1] === " " || input[i + 1] === "\n" || input[i + 1] === " ")) {
|
|
5492
|
+
continue;
|
|
5493
|
+
} else if (char === "-" && input[i + 1] === "-" && current.length === 0) {
|
|
5494
|
+
let closingBracketStack2 = "";
|
|
5495
|
+
let start = i;
|
|
5496
|
+
let colonIdx = -1;
|
|
5497
|
+
for (let j = i + 2; j < input.length; j++) {
|
|
5498
|
+
if (input[j] === "\\") {
|
|
5499
|
+
j += 1;
|
|
5500
|
+
} else if (input[j] === "/" && input[j + 1] === "*") {
|
|
5501
|
+
for (let k = j + 2; k < input.length; k++) {
|
|
5502
|
+
if (input[k] === "\\") {
|
|
5503
|
+
k += 1;
|
|
5504
|
+
} else if (input[k] === "*" && input[k + 1] === "/") {
|
|
5505
|
+
j = k + 1;
|
|
5506
|
+
break;
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
} else if (colonIdx === -1 && input[j] === ":") {
|
|
5510
|
+
colonIdx = current.length + j - start;
|
|
5511
|
+
} else if (input[j] === ";" && closingBracketStack2.length === 0) {
|
|
5512
|
+
current += input.slice(start, j);
|
|
5513
|
+
i = j;
|
|
5514
|
+
break;
|
|
5515
|
+
} else if (input[j] === "(") {
|
|
5516
|
+
closingBracketStack2 += ")";
|
|
5517
|
+
} else if (input[j] === "[") {
|
|
5518
|
+
closingBracketStack2 += "]";
|
|
5519
|
+
} else if (input[j] === "{") {
|
|
5520
|
+
closingBracketStack2 += "}";
|
|
5521
|
+
} else if ((input[j] === "}" || input.length - 1 === j) && closingBracketStack2.length === 0) {
|
|
5522
|
+
i = j - 1;
|
|
5523
|
+
current += input.slice(start, j);
|
|
5524
|
+
break;
|
|
5525
|
+
} else if (input[j] === ")" || input[j] === "]" || input[j] === "}") {
|
|
5526
|
+
if (closingBracketStack2.length > 0 && input[j] === closingBracketStack2[closingBracketStack2.length - 1]) {
|
|
5527
|
+
closingBracketStack2 = closingBracketStack2.slice(0, -1);
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
let declaration = parseDeclaration(current, colonIdx);
|
|
5532
|
+
if (parent) {
|
|
5533
|
+
parent.nodes.push(declaration);
|
|
5534
|
+
} else {
|
|
5535
|
+
ast.push(declaration);
|
|
4554
5536
|
}
|
|
4555
|
-
|
|
4556
|
-
|
|
5537
|
+
current = "";
|
|
5538
|
+
} else if (char === ";" && current[0] === "@") {
|
|
5539
|
+
node = rule(current, []);
|
|
5540
|
+
if (parent) {
|
|
5541
|
+
parent.nodes.push(node);
|
|
5542
|
+
} else {
|
|
5543
|
+
ast.push(node);
|
|
4557
5544
|
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
staticVariant("contrast-more", ["@media (prefers-contrast: more)"], { compounds: false });
|
|
4567
|
-
staticVariant("contrast-less", ["@media (prefers-contrast: less)"], { compounds: false });
|
|
4568
|
-
{
|
|
4569
|
-
let compareBreakpoints2 = function(a, z, direction) {
|
|
4570
|
-
if (a === z)
|
|
4571
|
-
return 0;
|
|
4572
|
-
let aValue = resolvedBreakpoints.get(a);
|
|
4573
|
-
if (aValue === null)
|
|
4574
|
-
return direction === "asc" ? -1 : 1;
|
|
4575
|
-
let zValue = resolvedBreakpoints.get(z);
|
|
4576
|
-
if (zValue === null)
|
|
4577
|
-
return direction === "asc" ? 1 : -1;
|
|
4578
|
-
if (aValue === zValue)
|
|
4579
|
-
return 0;
|
|
4580
|
-
let aIsCssFunction = aValue.indexOf("(");
|
|
4581
|
-
let zIsCssFunction = zValue.indexOf("(");
|
|
4582
|
-
let aBucket = aIsCssFunction === -1 ? (
|
|
4583
|
-
// No CSS function found, bucket by unit instead
|
|
4584
|
-
aValue.replace(/[\d.]+/g, "")
|
|
4585
|
-
) : (
|
|
4586
|
-
// CSS function found, bucket by function name
|
|
4587
|
-
aValue.slice(0, aIsCssFunction)
|
|
4588
|
-
);
|
|
4589
|
-
let zBucket = zIsCssFunction === -1 ? (
|
|
4590
|
-
// No CSS function found, bucket by unit
|
|
4591
|
-
zValue.replace(/[\d.]+/g, "")
|
|
4592
|
-
) : (
|
|
4593
|
-
// CSS function found, bucket by function name
|
|
4594
|
-
zValue.slice(0, zIsCssFunction)
|
|
4595
|
-
);
|
|
4596
|
-
let order = (
|
|
4597
|
-
// Compare by bucket name
|
|
4598
|
-
aBucket.localeCompare(zBucket) || // If bucket names are the same, compare by value
|
|
4599
|
-
(direction === "asc" ? parseInt(aValue) - parseInt(zValue) : parseInt(zValue) - parseInt(aValue))
|
|
4600
|
-
);
|
|
4601
|
-
if (isNaN(order)) {
|
|
4602
|
-
return aValue.localeCompare(zValue);
|
|
5545
|
+
current = "";
|
|
5546
|
+
node = null;
|
|
5547
|
+
} else if (char === ";") {
|
|
5548
|
+
let declaration = parseDeclaration(current);
|
|
5549
|
+
if (parent) {
|
|
5550
|
+
parent.nodes.push(declaration);
|
|
5551
|
+
} else {
|
|
5552
|
+
ast.push(declaration);
|
|
4603
5553
|
}
|
|
4604
|
-
|
|
4605
|
-
}
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
5554
|
+
current = "";
|
|
5555
|
+
} else if (char === "{") {
|
|
5556
|
+
closingBracketStack += "}";
|
|
5557
|
+
node = rule(current.trim(), []);
|
|
5558
|
+
if (parent) {
|
|
5559
|
+
parent.nodes.push(node);
|
|
5560
|
+
}
|
|
5561
|
+
stack.push(parent);
|
|
5562
|
+
parent = node;
|
|
5563
|
+
current = "";
|
|
5564
|
+
node = null;
|
|
5565
|
+
} else if (char === "}") {
|
|
5566
|
+
if (closingBracketStack === "") {
|
|
5567
|
+
throw new Error("Missing opening {");
|
|
5568
|
+
}
|
|
5569
|
+
closingBracketStack = closingBracketStack.slice(0, -1);
|
|
5570
|
+
if (current.length > 0) {
|
|
5571
|
+
if (current[0] === "@") {
|
|
5572
|
+
node = rule(current.trim(), []);
|
|
5573
|
+
if (parent) {
|
|
5574
|
+
parent.nodes.push(node);
|
|
5575
|
+
} else {
|
|
5576
|
+
ast.push(node);
|
|
4621
5577
|
}
|
|
4622
|
-
|
|
4623
|
-
|
|
5578
|
+
current = "";
|
|
5579
|
+
node = null;
|
|
5580
|
+
} else {
|
|
5581
|
+
let colonIdx = current.indexOf(":");
|
|
5582
|
+
if (parent) {
|
|
5583
|
+
let importantIdx = current.indexOf("!important", colonIdx + 1);
|
|
5584
|
+
parent.nodes.push({
|
|
5585
|
+
kind: "declaration",
|
|
5586
|
+
property: current.slice(0, colonIdx).trim(),
|
|
5587
|
+
value: current.slice(colonIdx + 1, importantIdx === -1 ? current.length : importantIdx).trim(),
|
|
5588
|
+
important: importantIdx !== -1
|
|
5589
|
+
});
|
|
4624
5590
|
}
|
|
4625
|
-
return value;
|
|
4626
5591
|
}
|
|
4627
|
-
case "arbitrary":
|
|
4628
|
-
case "compound":
|
|
4629
|
-
return null;
|
|
4630
5592
|
}
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
},
|
|
4645
|
-
(a, z) => compareBreakpoints2(a, z, "desc")
|
|
4646
|
-
);
|
|
4647
|
-
variants.group(
|
|
4648
|
-
() => {
|
|
4649
|
-
for (let [key, value] of theme.namespace("--breakpoint")) {
|
|
4650
|
-
if (key === null)
|
|
4651
|
-
continue;
|
|
4652
|
-
variants.static(
|
|
4653
|
-
key,
|
|
4654
|
-
(ruleNode) => {
|
|
4655
|
-
ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
|
|
4656
|
-
},
|
|
4657
|
-
{ compounds: false }
|
|
4658
|
-
);
|
|
4659
|
-
}
|
|
4660
|
-
variants.functional(
|
|
4661
|
-
"min",
|
|
4662
|
-
(ruleNode, variant) => {
|
|
4663
|
-
let value = resolvedBreakpoints.get(variant);
|
|
4664
|
-
if (value === null)
|
|
4665
|
-
return null;
|
|
4666
|
-
ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
|
|
4667
|
-
},
|
|
4668
|
-
{ compounds: false }
|
|
4669
|
-
);
|
|
4670
|
-
},
|
|
4671
|
-
(a, z) => compareBreakpoints2(a, z, "asc")
|
|
4672
|
-
);
|
|
5593
|
+
let grandParent = stack.pop() ?? null;
|
|
5594
|
+
if (grandParent === null && parent) {
|
|
5595
|
+
ast.push(parent);
|
|
5596
|
+
}
|
|
5597
|
+
parent = grandParent;
|
|
5598
|
+
current = "";
|
|
5599
|
+
node = null;
|
|
5600
|
+
} else {
|
|
5601
|
+
if (current.length === 0 && (char === " " || char === "\n" || char === " ")) {
|
|
5602
|
+
continue;
|
|
5603
|
+
}
|
|
5604
|
+
current += char;
|
|
5605
|
+
}
|
|
4673
5606
|
}
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
return variants;
|
|
5607
|
+
if (closingBracketStack.length > 0 && parent) {
|
|
5608
|
+
throw new Error(`Missing closing } at ${parent.selector}`);
|
|
5609
|
+
}
|
|
5610
|
+
if (licenseComments.length > 0) {
|
|
5611
|
+
return licenseComments.concat(ast);
|
|
5612
|
+
}
|
|
5613
|
+
return ast;
|
|
4682
5614
|
}
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
function buildDesignSystem(theme) {
|
|
5615
|
+
function parseDeclaration(current, colonIdx = current.indexOf(":")) {
|
|
5616
|
+
let importantIdx = current.indexOf("!important", colonIdx + 1);
|
|
4686
5617
|
return {
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
return getClassOrder(this, classes);
|
|
4692
|
-
}
|
|
5618
|
+
kind: "declaration",
|
|
5619
|
+
property: current.slice(0, colonIdx).trim(),
|
|
5620
|
+
value: current.slice(colonIdx + 1, importantIdx === -1 ? current.length : importantIdx).trim(),
|
|
5621
|
+
important: importantIdx !== -1
|
|
4693
5622
|
};
|
|
4694
5623
|
}
|
|
4695
5624
|
|
|
@@ -4715,6 +5644,21 @@ var Theme = class {
|
|
|
4715
5644
|
this.values.set(key, value);
|
|
4716
5645
|
}
|
|
4717
5646
|
}
|
|
5647
|
+
keysInNamespaces(themeKeys) {
|
|
5648
|
+
let keys = [];
|
|
5649
|
+
for (let prefix of themeKeys) {
|
|
5650
|
+
let namespace = `${prefix}-`;
|
|
5651
|
+
for (let key of this.values.keys()) {
|
|
5652
|
+
if (key.startsWith(namespace)) {
|
|
5653
|
+
if (key.indexOf("--", 2) !== -1) {
|
|
5654
|
+
continue;
|
|
5655
|
+
}
|
|
5656
|
+
keys.push(key.slice(namespace.length));
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5660
|
+
return keys;
|
|
5661
|
+
}
|
|
4718
5662
|
get(themeKeys) {
|
|
4719
5663
|
for (let key of themeKeys) {
|
|
4720
5664
|
let value = this.values.get(key);
|
|
@@ -4777,53 +5721,6 @@ var Theme = class {
|
|
|
4777
5721
|
};
|
|
4778
5722
|
|
|
4779
5723
|
// src/index.ts
|
|
4780
|
-
function toCss(ast) {
|
|
4781
|
-
let atRoots = [];
|
|
4782
|
-
return ast.map(function stringify(node) {
|
|
4783
|
-
let css = "";
|
|
4784
|
-
if (node.kind === "rule") {
|
|
4785
|
-
if (node.selector === "@at-root") {
|
|
4786
|
-
for (let child of node.nodes) {
|
|
4787
|
-
atRoots.push(stringify(child));
|
|
4788
|
-
}
|
|
4789
|
-
return css;
|
|
4790
|
-
}
|
|
4791
|
-
if (node.selector[0] === "@" && node.nodes.length === 0) {
|
|
4792
|
-
return `${node.selector};`;
|
|
4793
|
-
}
|
|
4794
|
-
css += `${node.selector}{`;
|
|
4795
|
-
for (let child of node.nodes) {
|
|
4796
|
-
css += stringify(child);
|
|
4797
|
-
}
|
|
4798
|
-
css += "}";
|
|
4799
|
-
} else if (node.kind === "comment") {
|
|
4800
|
-
css += `/*${node.value}*/
|
|
4801
|
-
`;
|
|
4802
|
-
} else if (node.property !== "--tw-sort" && node.value !== void 0 && node.value !== null) {
|
|
4803
|
-
css += `${node.property}:${node.value}${node.important ? "!important" : ""};`;
|
|
4804
|
-
}
|
|
4805
|
-
return css;
|
|
4806
|
-
}).concat(atRoots).join("\n");
|
|
4807
|
-
}
|
|
4808
|
-
function optimizeCss(input, { file = "input.css", minify = false } = {}) {
|
|
4809
|
-
return lightningcss.transform({
|
|
4810
|
-
filename: file,
|
|
4811
|
-
code: Buffer.from(input),
|
|
4812
|
-
minify,
|
|
4813
|
-
sourceMap: false,
|
|
4814
|
-
drafts: {
|
|
4815
|
-
customMedia: true
|
|
4816
|
-
},
|
|
4817
|
-
nonStandard: {
|
|
4818
|
-
deepSelectorCombinator: true
|
|
4819
|
-
},
|
|
4820
|
-
include: lightningcss.Features.Nesting,
|
|
4821
|
-
exclude: lightningcss.Features.LogicalProperties,
|
|
4822
|
-
targets: {
|
|
4823
|
-
safari: 16 << 16 | 4 << 8
|
|
4824
|
-
}
|
|
4825
|
-
}).code.toString();
|
|
4826
|
-
}
|
|
4827
5724
|
function compile(css, rawCandidates) {
|
|
4828
5725
|
let ast = parse(css);
|
|
4829
5726
|
{
|
|
@@ -4884,7 +5781,7 @@ function compile(css, rawCandidates) {
|
|
|
4884
5781
|
let designSystem = buildDesignSystem(theme);
|
|
4885
5782
|
walk(ast, (node, { replaceWith }) => {
|
|
4886
5783
|
if (node.kind === "rule" && node.selector === "@tailwind utilities") {
|
|
4887
|
-
replaceWith(
|
|
5784
|
+
replaceWith(compileCandidates(rawCandidates, designSystem).astNodes);
|
|
4888
5785
|
return false;
|
|
4889
5786
|
}
|
|
4890
5787
|
});
|
|
@@ -4896,7 +5793,7 @@ function compile(css, rawCandidates) {
|
|
|
4896
5793
|
/* Ignore `@apply ` when parsing the selector */
|
|
4897
5794
|
).split(/\s+/g);
|
|
4898
5795
|
{
|
|
4899
|
-
let candidateAst =
|
|
5796
|
+
let candidateAst = compileCandidates(candidates, designSystem, {
|
|
4900
5797
|
throwOnInvalidCandidate: true
|
|
4901
5798
|
}).astNodes;
|
|
4902
5799
|
let newNodes = [];
|
|
@@ -4923,7 +5820,27 @@ function compile(css, rawCandidates) {
|
|
|
4923
5820
|
}
|
|
4924
5821
|
return toCss(ast);
|
|
4925
5822
|
}
|
|
4926
|
-
function
|
|
5823
|
+
function optimizeCss(input, { file = "input.css", minify = false } = {}) {
|
|
5824
|
+
return lightningcss.transform({
|
|
5825
|
+
filename: file,
|
|
5826
|
+
code: Buffer.from(input),
|
|
5827
|
+
minify,
|
|
5828
|
+
sourceMap: false,
|
|
5829
|
+
drafts: {
|
|
5830
|
+
customMedia: true
|
|
5831
|
+
},
|
|
5832
|
+
nonStandard: {
|
|
5833
|
+
deepSelectorCombinator: true
|
|
5834
|
+
},
|
|
5835
|
+
include: lightningcss.Features.Nesting,
|
|
5836
|
+
exclude: lightningcss.Features.LogicalProperties,
|
|
5837
|
+
targets: {
|
|
5838
|
+
safari: 16 << 16 | 4 << 8
|
|
5839
|
+
},
|
|
5840
|
+
errorRecovery: true
|
|
5841
|
+
}).code.toString();
|
|
5842
|
+
}
|
|
5843
|
+
function __unstable__loadDesignSystem(css) {
|
|
4927
5844
|
let theme = new Theme();
|
|
4928
5845
|
let ast = parse(css);
|
|
4929
5846
|
walk(ast, (node) => {
|
|
@@ -4942,6 +5859,6 @@ function loadDesignSystem(css) {
|
|
|
4942
5859
|
return buildDesignSystem(theme);
|
|
4943
5860
|
}
|
|
4944
5861
|
|
|
5862
|
+
exports.__unstable__loadDesignSystem = __unstable__loadDesignSystem;
|
|
4945
5863
|
exports.compile = compile;
|
|
4946
|
-
exports.loadDesignSystem = loadDesignSystem;
|
|
4947
5864
|
exports.optimizeCss = optimizeCss;
|