tailwindcss 0.0.0-oxide.2 → 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/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.2";
8
+ var version = "0.0.0-oxide.3";
9
9
 
10
10
  // src/ast.ts
11
11
  function rule(selector, nodes) {
@@ -45,6 +45,34 @@ function walk(ast, visit) {
45
45
  }
46
46
  }
47
47
  }
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));
56
+ }
57
+ return css;
58
+ }
59
+ if (node.selector[0] === "@" && node.nodes.length === 0) {
60
+ return `${node.selector};`;
61
+ }
62
+ css += `${node.selector}{`;
63
+ for (let child of node.nodes) {
64
+ css += stringify(child);
65
+ }
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" : ""};`;
72
+ }
73
+ return css;
74
+ }).concat(atRoots).join("\n");
75
+ }
48
76
 
49
77
  // src/utils/math-operators.ts
50
78
  var mathFunctions = [
@@ -202,105 +230,6 @@ function segment(input, separator) {
202
230
  }
203
231
 
204
232
  // src/candidate.ts
205
- function findRoot(input, lookup) {
206
- let root = null;
207
- let value = null;
208
- {
209
- if (lookup.has(input)) {
210
- root = input;
211
- value = null;
212
- } else {
213
- let idx = input.lastIndexOf("-");
214
- if (idx === -1)
215
- return [null, null];
216
- do {
217
- let maybeRoot = input.slice(0, idx);
218
- if (lookup.has(maybeRoot)) {
219
- root = maybeRoot;
220
- value = input.slice(idx + 1);
221
- break;
222
- }
223
- idx = input.lastIndexOf("-", idx - 1);
224
- } while (idx > 0);
225
- }
226
- }
227
- return [root, value];
228
- }
229
- function parseVariant(variant, variants, parsedVariants) {
230
- if (variant[0] === "[" && variant[variant.length - 1] === "]") {
231
- if (variant[1] === "@" && variant.includes("&"))
232
- return null;
233
- let selector = decodeArbitraryValue(variant.slice(1, -1));
234
- if (selector[0] !== "@") {
235
- if (!selector.includes("&")) {
236
- selector = `&:is(${selector})`;
237
- }
238
- }
239
- return {
240
- kind: "arbitrary",
241
- selector,
242
- compounds: true
243
- };
244
- }
245
- {
246
- let [variantWithoutModifier, modifier = null, additionalModifier] = segment(variant, "/");
247
- if (additionalModifier)
248
- return null;
249
- let [root, value] = findRoot(variantWithoutModifier, variants);
250
- if (root === null)
251
- return null;
252
- switch (variants.kind(root)) {
253
- case "static": {
254
- if (value !== null)
255
- return null;
256
- return {
257
- kind: "static",
258
- root,
259
- compounds: variants.compounds(root)
260
- };
261
- }
262
- case "functional": {
263
- if (value === null)
264
- return null;
265
- if (value[0] === "[" && value[value.length - 1] === "]") {
266
- return {
267
- kind: "functional",
268
- root,
269
- value: {
270
- kind: "arbitrary",
271
- value: decodeArbitraryValue(value.slice(1, -1))
272
- },
273
- compounds: variants.compounds(root)
274
- };
275
- } else {
276
- return {
277
- kind: "functional",
278
- root,
279
- value: { kind: "named", value },
280
- compounds: variants.compounds(root)
281
- };
282
- }
283
- }
284
- case "compound": {
285
- if (value === null)
286
- return null;
287
- let subVariant = parsedVariants.get(value);
288
- if (subVariant === null)
289
- return null;
290
- if (subVariant.compounds === false)
291
- return null;
292
- return {
293
- kind: "compound",
294
- root,
295
- modifier: modifier === null ? null : { kind: "named", value: modifier },
296
- variant: subVariant,
297
- compounds: variants.compounds(root)
298
- };
299
- }
300
- }
301
- }
302
- return null;
303
- }
304
233
  function parseCandidate(input, utilities, parsedVariants) {
305
234
  let rawVariants = segment(input, ":");
306
235
  let base = rawVariants.pop();
@@ -332,20 +261,24 @@ function parseCandidate(input, utilities, parsedVariants) {
332
261
  state.important = true;
333
262
  base = base.slice(0, -1);
334
263
  }
335
- if (base[0] === "[" && base[base.length - 1] === "]") {
336
- let charCode = base.charCodeAt(1);
264
+ if (base[0] === "[") {
265
+ let [baseWithoutModifier, modifierSegment2 = null] = segment(base, "/");
266
+ if (baseWithoutModifier[baseWithoutModifier.length - 1] !== "]")
267
+ return null;
268
+ let charCode = baseWithoutModifier.charCodeAt(1);
337
269
  if (charCode !== 45 && !(charCode >= 97 && charCode <= 122))
338
270
  return null;
339
- base = base.slice(1, -1);
340
- let idx = base.indexOf(":");
341
- if (idx === -1 || idx === 0 || idx === base.length - 1)
271
+ baseWithoutModifier = baseWithoutModifier.slice(1, -1);
272
+ let idx = baseWithoutModifier.indexOf(":");
273
+ if (idx === -1 || idx === 0 || idx === baseWithoutModifier.length - 1)
342
274
  return null;
343
- let property2 = base.slice(0, idx);
344
- let value2 = decodeArbitraryValue(base.slice(idx + 1));
275
+ let property2 = baseWithoutModifier.slice(0, idx);
276
+ let value2 = decodeArbitraryValue(baseWithoutModifier.slice(idx + 1));
345
277
  return {
346
278
  kind: "arbitrary",
347
279
  property: property2,
348
280
  value: value2,
281
+ modifier: modifierSegment2 === null ? null : parseModifier(modifierSegment2),
349
282
  variants: parsedCandidateVariants,
350
283
  important: state.important
351
284
  };
@@ -355,6 +288,12 @@ function parseCandidate(input, utilities, parsedVariants) {
355
288
  base = base.slice(1);
356
289
  }
357
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
+ }
358
297
  if (root === null)
359
298
  return null;
360
299
  let kind = utilities.kind(root);
@@ -372,22 +311,36 @@ function parseCandidate(input, utilities, parsedVariants) {
372
311
  let candidate = {
373
312
  kind: "functional",
374
313
  root,
375
- modifier: null,
314
+ modifier: modifierSegment === null ? null : parseModifier(modifierSegment),
376
315
  value: null,
377
316
  variants: parsedCandidateVariants,
378
317
  negative: state.negative,
379
318
  important: state.important
380
319
  };
381
- if (value === null) {
320
+ if (value === null)
382
321
  return candidate;
383
- }
384
- let [valueWithoutModifier, modifierSegment = null] = segment(value, "/");
385
- let startArbitraryIdx = valueWithoutModifier.indexOf("[");
386
- let valueIsArbitrary = startArbitraryIdx !== -1;
387
- let modifierIsArbitrary = modifierSegment && modifierSegment[0] === "[" && modifierSegment[modifierSegment.length - 1] === "]";
388
- if (modifierSegment) {
389
- if (modifierIsArbitrary) {
390
- let arbitraryValue = modifierSegment.slice(1, -1);
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
+ }
391
344
  let dashedIdent = null;
392
345
  if (arbitraryValue[0] === "-" && arbitraryValue[1] === "-") {
393
346
  dashedIdent = arbitraryValue;
@@ -395,33 +348,26 @@ function parseCandidate(input, utilities, parsedVariants) {
395
348
  } else {
396
349
  arbitraryValue = decodeArbitraryValue(arbitraryValue);
397
350
  }
398
- candidate.modifier = {
351
+ candidate.value = {
399
352
  kind: "arbitrary",
353
+ dataType: typehint || null,
400
354
  value: arbitraryValue,
401
355
  dashedIdent
402
356
  };
403
357
  } else {
404
- candidate.modifier = {
358
+ let fraction = modifierSegment2 === null || candidate.modifier?.kind === "arbitrary" ? null : value.slice(valueWithoutModifier.lastIndexOf("-") + 1);
359
+ candidate.value = {
405
360
  kind: "named",
406
- value: modifierSegment
361
+ value: valueWithoutModifier,
362
+ fraction
407
363
  };
408
364
  }
409
365
  }
410
- if (valueIsArbitrary) {
411
- let arbitraryValue = valueWithoutModifier.slice(startArbitraryIdx + 1, -1);
412
- let typehint = "";
413
- for (let i = 0; i < arbitraryValue.length; i++) {
414
- let code = arbitraryValue.charCodeAt(i);
415
- if (code === 58) {
416
- typehint = arbitraryValue.slice(0, i);
417
- arbitraryValue = arbitraryValue.slice(i + 1);
418
- break;
419
- }
420
- if (code === 45 || code >= 97 && code <= 122) {
421
- continue;
422
- }
423
- break;
424
- }
366
+ return candidate;
367
+ }
368
+ function parseModifier(modifier) {
369
+ if (modifier[0] === "[" && modifier[modifier.length - 1] === "]") {
370
+ let arbitraryValue = modifier.slice(1, -1);
425
371
  let dashedIdent = null;
426
372
  if (arbitraryValue[0] === "-" && arbitraryValue[1] === "-") {
427
373
  dashedIdent = arbitraryValue;
@@ -429,21 +375,218 @@ function parseCandidate(input, utilities, parsedVariants) {
429
375
  } else {
430
376
  arbitraryValue = decodeArbitraryValue(arbitraryValue);
431
377
  }
432
- candidate.value = {
378
+ return {
433
379
  kind: "arbitrary",
434
- dataType: typehint || null,
435
380
  value: arbitraryValue,
436
381
  dashedIdent
437
382
  };
438
- } else {
439
- let fraction = modifierSegment === null || modifierIsArbitrary ? null : value.slice(valueWithoutModifier.lastIndexOf("-") + 1);
440
- candidate.value = {
441
- kind: "named",
442
- value: valueWithoutModifier,
443
- fraction
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
444
403
  };
445
404
  }
446
- return candidate;
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];
483
+ }
484
+
485
+ // src/utils/default-map.ts
486
+ var DefaultMap = class extends Map {
487
+ constructor(factory) {
488
+ super();
489
+ this.factory = factory;
490
+ }
491
+ get(key) {
492
+ let value = super.get(key);
493
+ if (value === void 0) {
494
+ value = this.factory(key, this);
495
+ this.set(key, value);
496
+ }
497
+ return value;
498
+ }
499
+ };
500
+
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") {
506
+ continue;
507
+ }
508
+ if (fn.kind === "static") {
509
+ list.push([utility, { modifiers: [] }]);
510
+ continue;
511
+ }
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
+ }
521
+ }
522
+ }
523
+ list.sort((a, b) => a[0].localeCompare(b[0]));
524
+ return list;
525
+ }
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 [];
544
+ }
545
+ let selectors3 = [];
546
+ for (let child of node.nodes) {
547
+ if (child.kind === "rule") {
548
+ selectors3.push(child.selector);
549
+ }
550
+ }
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;
566
+ }
567
+ case "functional": {
568
+ list.push({
569
+ name: root,
570
+ values,
571
+ isArbitrary: true,
572
+ hasDash: true,
573
+ selectors: selectors2
574
+ });
575
+ break;
576
+ }
577
+ case "compound": {
578
+ list.push({
579
+ name: root,
580
+ values,
581
+ isArbitrary: true,
582
+ hasDash: true,
583
+ selectors: selectors2
584
+ });
585
+ break;
586
+ }
587
+ }
588
+ }
589
+ return list;
447
590
  }
448
591
 
449
592
  // src/sort.ts
@@ -853,14 +996,19 @@ function replaceShadowColors(input, replacement) {
853
996
  }
854
997
 
855
998
  // src/utilities.ts
999
+ var ARBITRARY_VARIANT = Symbol("ARBITRARY_VARIANT");
856
1000
  var Utilities = class {
857
1001
  utilities = /* @__PURE__ */ new Map();
1002
+ completions = /* @__PURE__ */ new Map();
858
1003
  static(name, compileFn) {
859
1004
  this.set(name, { kind: "static", compileFn });
860
1005
  }
861
1006
  functional(name, compileFn) {
862
1007
  this.set(name, { kind: "functional", compileFn });
863
1008
  }
1009
+ arbitrary(compileFn) {
1010
+ this.set(ARBITRARY_VARIANT, { kind: "arbitrary", compileFn });
1011
+ }
864
1012
  has(name) {
865
1013
  return this.utilities.has(name);
866
1014
  }
@@ -870,9 +1018,21 @@ var Utilities = class {
870
1018
  kind(name) {
871
1019
  return this.utilities.get(name).kind;
872
1020
  }
1021
+ getCompletions(name) {
1022
+ return this.completions.get(name)?.() ?? [];
1023
+ }
1024
+ suggest(name, groups) {
1025
+ this.completions.set(name, groups);
1026
+ }
873
1027
  keys() {
874
1028
  return this.utilities.keys();
875
1029
  }
1030
+ entries() {
1031
+ return this.utilities.entries();
1032
+ }
1033
+ getArbitrary() {
1034
+ return this.get(ARBITRARY_VARIANT).compileFn;
1035
+ }
876
1036
  set(name, { kind, compileFn }) {
877
1037
  this.utilities.set(name, {
878
1038
  kind,
@@ -896,19 +1056,17 @@ function property(ident, initialValue, syntax) {
896
1056
  ]);
897
1057
  }
898
1058
  function withAlpha(value, alpha) {
899
- if (alpha === null) {
1059
+ if (alpha === null)
900
1060
  return value;
901
- }
902
1061
  let alphaAsNumber = Number(alpha);
903
- if (!isNaN(alphaAsNumber)) {
1062
+ if (!Number.isNaN(alphaAsNumber)) {
904
1063
  alpha = `${alphaAsNumber * 100}%`;
905
1064
  }
906
1065
  return `color-mix(in srgb, ${value} ${alpha}, transparent)`;
907
1066
  }
908
1067
  function asColor(value, modifier, theme) {
909
- if (!modifier) {
1068
+ if (!modifier)
910
1069
  return value;
911
- }
912
1070
  if (modifier.kind === "arbitrary") {
913
1071
  return withAlpha(value, modifier.value);
914
1072
  }
@@ -916,6 +1074,9 @@ function asColor(value, modifier, theme) {
916
1074
  if (alpha) {
917
1075
  return withAlpha(value, alpha);
918
1076
  }
1077
+ if (Number.isNaN(Number(modifier.value))) {
1078
+ return null;
1079
+ }
919
1080
  return withAlpha(value, `${modifier.value}%`);
920
1081
  }
921
1082
  function withNegative(value, candidate) {
@@ -941,11 +1102,45 @@ function resolveThemeColor(candidate, theme, themeKeys) {
941
1102
  }
942
1103
  function createUtilities(theme) {
943
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
+ }
944
1140
  function staticUtility(className, declarations) {
945
1141
  utilities.static(className, (candidate) => {
946
- if (candidate.negative) {
1142
+ if (candidate.negative)
947
1143
  return;
948
- }
949
1144
  return declarations.map((node) => {
950
1145
  return typeof node === "function" ? node() : decl(node[0], node[1]);
951
1146
  });
@@ -962,17 +1157,24 @@ function createUtilities(theme) {
962
1157
  value = candidate.value.value;
963
1158
  } else {
964
1159
  value = theme.resolve(candidate.value.fraction ?? candidate.value.value, desc.themeKeys);
965
- if (!value && desc.supportsFractions && candidate.value.fraction) {
1160
+ if (value === null && desc.supportsFractions && candidate.value.fraction) {
966
1161
  value = `calc(${candidate.value.fraction} * 100%)`;
967
1162
  }
968
- if (!value && desc.handleBareValue) {
1163
+ if (value === null && desc.handleBareValue) {
969
1164
  value = desc.handleBareValue(candidate.value);
970
1165
  }
971
1166
  }
972
- if (!value)
1167
+ if (value === null)
973
1168
  return;
974
1169
  return desc.handle(withNegative(value, candidate));
975
1170
  });
1171
+ suggest(classRoot, () => [
1172
+ {
1173
+ supportsNegative: desc.supportsNegative,
1174
+ valueThemeKeys: desc.themeKeys,
1175
+ hasDefaultValue: desc.defaultValue !== void 0 && desc.defaultValue !== null
1176
+ }
1177
+ ]);
976
1178
  }
977
1179
  function colorUtility(classRoot, desc) {
978
1180
  utilities.functional(classRoot, (candidate) => {
@@ -986,11 +1188,19 @@ function createUtilities(theme) {
986
1188
  value = asColor(value, candidate.modifier, theme);
987
1189
  } else {
988
1190
  value = resolveThemeColor(candidate, theme, desc.themeKeys);
989
- if (!value)
990
- return;
991
1191
  }
1192
+ if (value === null)
1193
+ return;
992
1194
  return desc.handle(value);
993
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
+ ]);
994
1204
  }
995
1205
  staticUtility("sr-only", [
996
1206
  ["position", "absolute"],
@@ -1147,6 +1357,13 @@ function createUtilities(theme) {
1147
1357
  themeKeys: ["--z-index"],
1148
1358
  handle: (value) => [decl("z-index", value)]
1149
1359
  });
1360
+ suggest("z", () => [
1361
+ {
1362
+ supportsNegative: true,
1363
+ values: ["0", "10", "20", "30", "40", "50"],
1364
+ valueThemeKeys: ["--z-index"]
1365
+ }
1366
+ ]);
1150
1367
  staticUtility("order-first", [["order", "calc(-infinity)"]]);
1151
1368
  staticUtility("order-last", [["order", "calc(infinity)"]]);
1152
1369
  staticUtility("order-none", [["order", "0"]]);
@@ -1156,6 +1373,13 @@ function createUtilities(theme) {
1156
1373
  themeKeys: ["--order"],
1157
1374
  handle: (value) => [decl("order", value)]
1158
1375
  });
1376
+ suggest("order", () => [
1377
+ {
1378
+ supportsNegative: true,
1379
+ values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
1380
+ valueThemeKeys: ["--order"]
1381
+ }
1382
+ ]);
1159
1383
  staticUtility("col-auto", [["grid-column", "auto"]]);
1160
1384
  functionalUtility("col", {
1161
1385
  themeKeys: ["--grid-column"],
@@ -1179,6 +1403,24 @@ function createUtilities(theme) {
1179
1403
  themeKeys: ["--grid-column-end"],
1180
1404
  handle: (value) => [decl("grid-column-end", value)]
1181
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
+ ]);
1182
1424
  staticUtility("row-auto", [["grid-row", "auto"]]);
1183
1425
  functionalUtility("row", {
1184
1426
  themeKeys: ["--grid-row"],
@@ -1202,6 +1444,24 @@ function createUtilities(theme) {
1202
1444
  themeKeys: ["--grid-row-end"],
1203
1445
  handle: (value) => [decl("grid-row-end", value)]
1204
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
+ ]);
1205
1465
  staticUtility("float-start", [["float", "start"]]);
1206
1466
  staticUtility("float-end", [["float", "end"]]);
1207
1467
  staticUtility("float-right", [["float", "right"]]);
@@ -1255,6 +1515,12 @@ function createUtilities(theme) {
1255
1515
  decl("-webkit-line-clamp", value)
1256
1516
  ]
1257
1517
  });
1518
+ suggest("line-clamp", () => [
1519
+ {
1520
+ values: ["1", "2", "3", "4", "5", "6"],
1521
+ valueThemeKeys: ["--line-clamp"]
1522
+ }
1523
+ ]);
1258
1524
  staticUtility("block", [["display", "block"]]);
1259
1525
  staticUtility("inline-block", [["display", "inline-block"]]);
1260
1526
  staticUtility("inline", [["display", "inline"]]);
@@ -1426,6 +1692,20 @@ function createUtilities(theme) {
1426
1692
  handleBareValue: ({ value }) => value,
1427
1693
  handle: (value) => [decl("flex-grow", value)]
1428
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
+ ]);
1429
1709
  staticUtility("basis-auto", [["flex-basis", "auto"]]);
1430
1710
  staticUtility("basis-full", [["flex-basis", "100%"]]);
1431
1711
  functionalUtility("basis", {
@@ -1502,7 +1782,7 @@ function createUtilities(theme) {
1502
1782
  translateProperties(),
1503
1783
  decl("--tw-translate-x", value),
1504
1784
  decl("--tw-translate-y", value),
1505
- decl("translate", `var(--tw-translate-x) var(--tw-translate-y)`)
1785
+ decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
1506
1786
  ]
1507
1787
  });
1508
1788
  utilities.static("translate-x-full", (candidate) => {
@@ -1520,7 +1800,7 @@ function createUtilities(theme) {
1520
1800
  handle: (value) => [
1521
1801
  translateProperties(),
1522
1802
  decl("--tw-translate-x", value),
1523
- decl("translate", `var(--tw-translate-x) var(--tw-translate-y)`)
1803
+ decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
1524
1804
  ]
1525
1805
  });
1526
1806
  utilities.static("translate-y-full", (candidate) => {
@@ -1538,7 +1818,7 @@ function createUtilities(theme) {
1538
1818
  handle: (value) => [
1539
1819
  translateProperties(),
1540
1820
  decl("--tw-translate-y", value),
1541
- decl("translate", `var(--tw-translate-x) var(--tw-translate-y)`)
1821
+ decl("translate", "var(--tw-translate-x) var(--tw-translate-y)")
1542
1822
  ]
1543
1823
  });
1544
1824
  functionalUtility("rotate", {
@@ -1547,6 +1827,13 @@ function createUtilities(theme) {
1547
1827
  handleBareValue: ({ value }) => `${value}deg`,
1548
1828
  handle: (value) => [decl("rotate", value)]
1549
1829
  });
1830
+ suggest("rotate", () => [
1831
+ {
1832
+ supportsNegative: true,
1833
+ values: ["0", "1", "2", "3", "6", "12", "45", "90", "180"],
1834
+ valueThemeKeys: ["--rotate"]
1835
+ }
1836
+ ]);
1550
1837
  let skewProperties = () => atRoot([property("--tw-skew-x", "0deg", "<angle>"), property("--tw-skew-y", "0deg", "<angle>")]);
1551
1838
  functionalUtility("skew", {
1552
1839
  supportsNegative: true,
@@ -1579,6 +1866,27 @@ function createUtilities(theme) {
1579
1866
  decl("transform", "skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))")
1580
1867
  ]
1581
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
+ ]);
1582
1890
  let scaleProperties = () => atRoot([property("--tw-scale-x", "1", "<number>"), property("--tw-scale-y", "1", "<number>")]);
1583
1891
  functionalUtility("scale", {
1584
1892
  supportsNegative: true,
@@ -1611,6 +1919,27 @@ function createUtilities(theme) {
1611
1919
  decl("scale", "var(--tw-scale-x) var(--tw-scale-y)")
1612
1920
  ]
1613
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
+ ]);
1614
1943
  staticUtility("transform", [
1615
1944
  skewProperties,
1616
1945
  ["transform", "skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))"]
@@ -1696,11 +2025,11 @@ function createUtilities(theme) {
1696
2025
  ["user-select", value]
1697
2026
  ]);
1698
2027
  }
1699
- staticUtility(`resize-none`, [["resize", "none"]]);
1700
- staticUtility(`resize-both`, [["resize", "both"]]);
1701
- staticUtility(`resize-x`, [["resize", "horizontal"]]);
1702
- staticUtility(`resize-y`, [["resize", "vertical"]]);
1703
- staticUtility(`snap-none`, [["scroll-snap-type", "none"]]);
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"]]);
1704
2033
  let snapProperties = () => atRoot([property("--tw-scroll-snap-strictness", "proximity", "*")]);
1705
2034
  for (let value of ["x", "y", "both"]) {
1706
2035
  staticUtility(`snap-${value}`, [
@@ -1708,8 +2037,8 @@ function createUtilities(theme) {
1708
2037
  ["scroll-snap-type", `${value} var(--tw-scroll-snap-strictness)`]
1709
2038
  ]);
1710
2039
  }
1711
- staticUtility(`snap-mandatory`, [snapProperties, ["--tw-scroll-snap-strictness", "mandatory"]]);
1712
- staticUtility(`snap-proximity`, [snapProperties, ["--tw-scroll-snap-strictness", "proximity"]]);
2040
+ staticUtility("snap-mandatory", [snapProperties, ["--tw-scroll-snap-strictness", "mandatory"]]);
2041
+ staticUtility("snap-proximity", [snapProperties, ["--tw-scroll-snap-strictness", "proximity"]]);
1713
2042
  staticUtility("snap-align-none", [["scroll-snap-align", "none"]]);
1714
2043
  staticUtility("snap-start", [["scroll-snap-align", "start"]]);
1715
2044
  staticUtility("snap-end", [["scroll-snap-align", "end"]]);
@@ -1828,6 +2157,12 @@ function createUtilities(theme) {
1828
2157
  handleBareValue: ({ value }) => value,
1829
2158
  handle: (value) => [decl("columns", value)]
1830
2159
  });
2160
+ suggest("columns", () => [
2161
+ {
2162
+ values: Array.from({ length: 12 }, (_, i) => `${i + 1}`),
2163
+ valueThemeKeys: ["--columns", "--width"]
2164
+ }
2165
+ ]);
1831
2166
  for (let value of ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"]) {
1832
2167
  staticUtility(`break-before-${value}`, [["break-before", value]]);
1833
2168
  }
@@ -1872,6 +2207,18 @@ function createUtilities(theme) {
1872
2207
  handleBareValue: ({ value }) => `repeat(${value}, minmax(0, 1fr))`,
1873
2208
  handle: (value) => [decl("grid-template-rows", value)]
1874
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
+ ]);
1875
2222
  staticUtility("flex-row", [["flex-direction", "row"]]);
1876
2223
  staticUtility("flex-row-reverse", [["flex-direction", "row-reverse"]]);
1877
2224
  staticUtility("flex-col", [["flex-direction", "column"]]);
@@ -1970,48 +2317,6 @@ function createUtilities(theme) {
1970
2317
  decl("--tw-space-y-reverse", "1")
1971
2318
  ])
1972
2319
  ]);
1973
- functionalUtility("divide-x", {
1974
- defaultValue: theme.get(["--default-border-width"]) ?? "1px",
1975
- themeKeys: ["--divide-width", "--border-width"],
1976
- handleBareValue: ({ value }) => `${value}px`,
1977
- handle: (value) => [
1978
- atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
1979
- rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
1980
- decl("--tw-sort", "divide-x-width"),
1981
- decl("border-inline-end-width", `calc(${value} * var(--tw-divide-x-reverse))`),
1982
- decl("border-inline-start-width", `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`)
1983
- ])
1984
- ]
1985
- });
1986
- functionalUtility("divide-y", {
1987
- defaultValue: theme.get(["--default-border-width"]) ?? "1px",
1988
- themeKeys: ["--divide-width", "--border-width"],
1989
- handleBareValue: ({ value }) => `${value}px`,
1990
- handle: (value) => [
1991
- atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
1992
- rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
1993
- decl("--tw-sort", "divide-y-width"),
1994
- decl("border-bottom-width", `calc(${value} * var(--tw-divide-y-reverse))`),
1995
- decl("border-top-width", `calc(${value} * calc(1 - var(--tw-divide-y-reverse)))`)
1996
- ])
1997
- ]
1998
- });
1999
- staticUtility("divide-x-reverse", [
2000
- () => atRoot([property("--tw-divide-x-reverse", "0", "<number>")]),
2001
- () => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-x-reverse", "1")])
2002
- ]);
2003
- staticUtility("divide-y-reverse", [
2004
- () => atRoot([property("--tw-divide-y-reverse", "0", "<number>")]),
2005
- () => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [decl("--tw-divide-y-reverse", "1")])
2006
- ]);
2007
- for (let value of ["solid", "dashed", "dotted", "double", "none"]) {
2008
- staticUtility(`divide-${value}`, [
2009
- () => rule(":where(& > :not([hidden]) ~ :not([hidden]))", [
2010
- decl("--tw-sort", "divide-style"),
2011
- decl("border-style", value)
2012
- ])
2013
- ]);
2014
- }
2015
2320
  colorUtility("accent", {
2016
2321
  themeKeys: ["--accent-color", "--color"],
2017
2322
  handle: (value) => [decl("accent-color", value)]
@@ -2055,33 +2360,33 @@ function createUtilities(theme) {
2055
2360
  staticUtility(`overscroll-x-${value}`, [["overscroll-behavior-x", value]]);
2056
2361
  staticUtility(`overscroll-y-${value}`, [["overscroll-behavior-y", value]]);
2057
2362
  }
2058
- staticUtility(`scroll-auto`, [["scroll-behavior", "auto"]]);
2059
- staticUtility(`scroll-smooth`, [["scroll-behavior", "smooth"]]);
2060
- staticUtility(`truncate`, [
2363
+ staticUtility("scroll-auto", [["scroll-behavior", "auto"]]);
2364
+ staticUtility("scroll-smooth", [["scroll-behavior", "smooth"]]);
2365
+ staticUtility("truncate", [
2061
2366
  ["overflow", "hidden"],
2062
2367
  ["text-overflow", "ellipsis"],
2063
2368
  ["white-space", "nowrap"]
2064
2369
  ]);
2065
- staticUtility(`text-ellipsis`, [["text-overflow", "ellipsis"]]);
2066
- staticUtility(`text-clip`, [["text-overflow", "clip"]]);
2067
- staticUtility(`hyphens-none`, [
2370
+ staticUtility("text-ellipsis", [["text-overflow", "ellipsis"]]);
2371
+ staticUtility("text-clip", [["text-overflow", "clip"]]);
2372
+ staticUtility("hyphens-none", [
2068
2373
  ["-webkit-hyphens", "none"],
2069
2374
  ["hyphens", "none"]
2070
2375
  ]);
2071
- staticUtility(`hyphens-manual`, [
2376
+ staticUtility("hyphens-manual", [
2072
2377
  ["-webkit-hyphens", "manual"],
2073
2378
  ["hyphens", "manual"]
2074
2379
  ]);
2075
- staticUtility(`hyphens-auto`, [
2380
+ staticUtility("hyphens-auto", [
2076
2381
  ["-webkit-hyphens", "auto"],
2077
2382
  ["hyphens", "auto"]
2078
2383
  ]);
2079
- staticUtility(`whitespace-normal`, [["white-space", "normal"]]);
2080
- staticUtility(`whitespace-nowrap`, [["white-space", "nowrap"]]);
2081
- staticUtility(`whitespace-pre`, [["white-space", "pre"]]);
2082
- staticUtility(`whitespace-pre-line`, [["white-space", "pre-line"]]);
2083
- staticUtility(`whitespace-pre-wrap`, [["white-space", "pre-wrap"]]);
2084
- staticUtility(`whitespace-break-spaces`, [["white-space", "break-spaces"]]);
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"]]);
2085
2390
  staticUtility("text-wrap", [["text-wrap", "wrap"]]);
2086
2391
  staticUtility("text-nowrap", [["text-wrap", "nowrap"]]);
2087
2392
  staticUtility("text-balance", [["text-wrap", "balance"]]);
@@ -2171,88 +2476,201 @@ function createUtilities(theme) {
2171
2476
  themeKeys: ["--radius"],
2172
2477
  handle: (value) => [decl("border-bottom-left-radius", value)]
2173
2478
  });
2174
- staticUtility("border-solid", [["border-style", "solid"]]);
2175
- staticUtility("border-dashed", [["border-style", "dashed"]]);
2176
- staticUtility("border-dotted", [["border-style", "dotted"]]);
2177
- staticUtility("border-double", [["border-style", "double"]]);
2178
- staticUtility("border-hidden", [["border-style", "hidden"]]);
2179
- staticUtility("border-none", [["border-style", "none"]]);
2180
- function borderSideUtility(classRoot, desc) {
2181
- utilities.functional(classRoot, (candidate) => {
2182
- if (candidate.negative) {
2183
- return;
2184
- }
2185
- if (!candidate.value) {
2186
- let value = theme.get(["--default-border-width"]) ?? "1px";
2187
- return desc.width(value);
2188
- }
2189
- if (candidate.value.kind === "arbitrary") {
2190
- let value = candidate.value.value;
2191
- let type = candidate.value.dataType ?? inferDataType(value, ["color", "line-width", "length"]);
2192
- switch (type) {
2193
- case "line-width":
2194
- case "length": {
2195
- return desc.width(value);
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
+ }
2196
2532
  }
2197
- default: {
2198
- value = asColor(value, candidate.modifier, theme);
2533
+ }
2534
+ {
2535
+ let value = resolveThemeColor(candidate, theme, ["--border-color", "--color"]);
2536
+ if (value) {
2199
2537
  return desc.color(value);
2200
2538
  }
2201
2539
  }
2202
- }
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"]
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", () => [
2203
2643
  {
2204
- let value = resolveThemeColor(candidate, theme, ["--border-color", "--color"]);
2205
- if (value) {
2206
- return desc.color(value);
2207
- }
2644
+ values: ["0", "2", "4", "8"],
2645
+ valueThemeKeys: ["--divide-width", "--border-width"],
2646
+ hasDefaultValue: true
2208
2647
  }
2648
+ ]);
2649
+ suggest("divide-y", () => [
2209
2650
  {
2210
- let value = theme.resolve(candidate.value.value, ["--border-width"]);
2211
- if (value) {
2212
- return desc.width(value);
2213
- }
2214
- if (!isNaN(Number(candidate.value.value))) {
2215
- return desc.width(`${candidate.value.value}px`);
2216
- }
2651
+ values: ["0", "2", "4", "8"],
2652
+ valueThemeKeys: ["--divide-width", "--border-width"],
2653
+ hasDefaultValue: true
2217
2654
  }
2218
- });
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
+ }
2219
2673
  }
2220
- borderSideUtility("border", {
2221
- width: (value) => [decl("border-width", value)],
2222
- color: (value) => [decl("border-color", value)]
2223
- });
2224
- borderSideUtility("border-x", {
2225
- width: (value) => [decl("border-left-width", value), decl("border-right-width", value)],
2226
- color: (value) => [decl("border-left-color", value), decl("border-right-color", value)]
2227
- });
2228
- borderSideUtility("border-y", {
2229
- width: (value) => [decl("border-top-width", value), decl("border-bottom-width", value)],
2230
- color: (value) => [decl("border-top-color", value), decl("border-bottom-color", value)]
2231
- });
2232
- borderSideUtility("border-s", {
2233
- width: (value) => [decl("border-inline-start-width", value)],
2234
- color: (value) => [decl("border-inline-start-color", value)]
2235
- });
2236
- borderSideUtility("border-e", {
2237
- width: (value) => [decl("border-inline-end-width", value)],
2238
- color: (value) => [decl("border-inline-end-color", value)]
2239
- });
2240
- borderSideUtility("border-t", {
2241
- width: (value) => [decl("border-top-width", value)],
2242
- color: (value) => [decl("border-top-color", value)]
2243
- });
2244
- borderSideUtility("border-r", {
2245
- width: (value) => [decl("border-right-width", value)],
2246
- color: (value) => [decl("border-right-color", value)]
2247
- });
2248
- borderSideUtility("border-b", {
2249
- width: (value) => [decl("border-bottom-width", value)],
2250
- color: (value) => [decl("border-bottom-color", value)]
2251
- });
2252
- borderSideUtility("border-l", {
2253
- width: (value) => [decl("border-left-width", value)],
2254
- color: (value) => [decl("border-left-color", value)]
2255
- });
2256
2674
  staticUtility("bg-inherit", [["background-color", "inherit"]]);
2257
2675
  staticUtility("bg-transparent", [["background-color", "transparent"]]);
2258
2676
  staticUtility("bg-auto", [["background-size", "auto"]]);
@@ -2292,9 +2710,8 @@ function createUtilities(theme) {
2292
2710
  ]);
2293
2711
  }
2294
2712
  utilities.functional("bg", (candidate) => {
2295
- if (candidate.negative || !candidate.value) {
2713
+ if (candidate.negative || !candidate.value)
2296
2714
  return;
2297
- }
2298
2715
  if (candidate.value.kind === "arbitrary") {
2299
2716
  let value = candidate.value.value;
2300
2717
  let type = candidate.value.dataType ?? inferDataType(value, [
@@ -2322,6 +2739,8 @@ function createUtilities(theme) {
2322
2739
  }
2323
2740
  default: {
2324
2741
  value = asColor(value, candidate.modifier, theme);
2742
+ if (value === null)
2743
+ return;
2325
2744
  return [decl("background-color", value)];
2326
2745
  }
2327
2746
  }
@@ -2339,6 +2758,18 @@ function createUtilities(theme) {
2339
2758
  }
2340
2759
  }
2341
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
+ ]);
2342
2773
  let gradientStopProperties = () => {
2343
2774
  return atRoot([
2344
2775
  property("--tw-gradient-from", "#0000", "<color>"),
@@ -2355,9 +2786,8 @@ function createUtilities(theme) {
2355
2786
  };
2356
2787
  function gradientStopUtility(classRoot, desc) {
2357
2788
  utilities.functional(classRoot, (candidate) => {
2358
- if (candidate.negative || !candidate.value) {
2789
+ if (candidate.negative || !candidate.value)
2359
2790
  return;
2360
- }
2361
2791
  if (candidate.value.kind === "arbitrary") {
2362
2792
  let value = candidate.value.value;
2363
2793
  let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage"]);
@@ -2368,6 +2798,8 @@ function createUtilities(theme) {
2368
2798
  }
2369
2799
  default: {
2370
2800
  value = asColor(value, candidate.modifier, theme);
2801
+ if (value === null)
2802
+ return;
2371
2803
  return desc.color(value);
2372
2804
  }
2373
2805
  }
@@ -2387,6 +2819,18 @@ function createUtilities(theme) {
2387
2819
  }
2388
2820
  }
2389
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
+ ]);
2390
2834
  }
2391
2835
  gradientStopUtility("from", {
2392
2836
  color: (value) => [
@@ -2408,9 +2852,9 @@ function createUtilities(theme) {
2408
2852
  decl("--tw-gradient-via", value),
2409
2853
  decl(
2410
2854
  "--tw-gradient-via-stops",
2411
- `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)`
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)"
2412
2856
  ),
2413
- decl("--tw-gradient-stops", `var(--tw-gradient-via-stops)`)
2857
+ decl("--tw-gradient-stops", "var(--tw-gradient-via-stops)")
2414
2858
  ],
2415
2859
  position: (value) => [gradientStopProperties(), decl("--tw-gradient-via-position", value)]
2416
2860
  });
@@ -2470,25 +2914,34 @@ function createUtilities(theme) {
2470
2914
  staticUtility(`bg-blend-${value}`, [["background-blend-mode", value]]);
2471
2915
  staticUtility(`mix-blend-${value}`, [["mix-blend-mode", value]]);
2472
2916
  }
2473
- staticUtility(`mix-blend-plus-darker`, [["mix-blend-mode", "plus-darker"]]);
2474
- staticUtility(`mix-blend-plus-lighter`, [["mix-blend-mode", "plus-lighter"]]);
2917
+ staticUtility("mix-blend-plus-darker", [["mix-blend-mode", "plus-darker"]]);
2918
+ staticUtility("mix-blend-plus-lighter", [["mix-blend-mode", "plus-lighter"]]);
2475
2919
  utilities.functional("fill", (candidate) => {
2476
- if (candidate.negative || !candidate.value) {
2920
+ if (candidate.negative || !candidate.value)
2477
2921
  return;
2478
- }
2479
2922
  if (candidate.value.kind === "arbitrary") {
2480
- return [decl("fill", asColor(candidate.value.value, candidate.modifier, theme))];
2923
+ let value2 = asColor(candidate.value.value, candidate.modifier, theme);
2924
+ if (value2 === null)
2925
+ return;
2926
+ return [decl("fill", value2)];
2481
2927
  }
2482
2928
  let value = resolveThemeColor(candidate, theme, ["--fill", "--color"]);
2483
2929
  if (value) {
2484
2930
  return [decl("fill", value)];
2485
2931
  }
2486
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
+ ]);
2487
2941
  staticUtility("stroke-none", [["stroke", "none"]]);
2488
2942
  utilities.functional("stroke", (candidate) => {
2489
- if (candidate.negative || !candidate.value) {
2943
+ if (candidate.negative || !candidate.value)
2490
2944
  return;
2491
- }
2492
2945
  if (candidate.value.kind === "arbitrary") {
2493
2946
  let value = candidate.value.value;
2494
2947
  let type = candidate.value.dataType ?? inferDataType(value, ["color", "number", "length", "percentage"]);
@@ -2500,6 +2953,8 @@ function createUtilities(theme) {
2500
2953
  }
2501
2954
  default: {
2502
2955
  value = asColor(candidate.value.value, candidate.modifier, theme);
2956
+ if (value === null)
2957
+ return;
2503
2958
  return [decl("stroke", value)];
2504
2959
  }
2505
2960
  }
@@ -2514,11 +2969,23 @@ function createUtilities(theme) {
2514
2969
  let value = theme.resolve(candidate.value.value, ["--stroke-width"]);
2515
2970
  if (value) {
2516
2971
  return [decl("stroke-width", value)];
2517
- } else if (!isNaN(Number(candidate.value.value))) {
2972
+ } else if (!Number.isNaN(Number(candidate.value.value))) {
2518
2973
  return [decl("stroke-width", candidate.value.value)];
2519
2974
  }
2520
2975
  }
2521
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
+ ]);
2522
2989
  staticUtility("object-contain", [["object-fit", "contain"]]);
2523
2990
  staticUtility("object-cover", [["object-fit", "cover"]]);
2524
2991
  staticUtility("object-fill", [["object-fit", "fill"]]);
@@ -2597,9 +3064,8 @@ function createUtilities(theme) {
2597
3064
  handle: (value) => [decl("vertical-align", value)]
2598
3065
  });
2599
3066
  utilities.functional("font", (candidate) => {
2600
- if (candidate.negative || !candidate.value) {
3067
+ if (candidate.negative || !candidate.value)
2601
3068
  return;
2602
- }
2603
3069
  if (candidate.value.kind === "arbitrary") {
2604
3070
  let value = candidate.value.value;
2605
3071
  let type = candidate.value.dataType ?? inferDataType(value, ["number", "generic-name", "family-name"]);
@@ -2667,6 +3133,26 @@ function createUtilities(theme) {
2667
3133
  }
2668
3134
  }
2669
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
+ ]);
2670
3156
  staticUtility("uppercase", [["text-transform", "uppercase"]]);
2671
3157
  staticUtility("lowercase", [["text-transform", "lowercase"]]);
2672
3158
  staticUtility("capitalize", [["text-transform", "capitalize"]]);
@@ -2691,9 +3177,8 @@ function createUtilities(theme) {
2691
3177
  staticUtility("decoration-auto", [["text-decoration-thickness", "auto"]]);
2692
3178
  staticUtility("decoration-from-font", [["text-decoration-thickness", "from-font"]]);
2693
3179
  utilities.functional("decoration", (candidate) => {
2694
- if (candidate.negative || !candidate.value) {
3180
+ if (candidate.negative || !candidate.value)
2695
3181
  return;
2696
- }
2697
3182
  if (candidate.value.kind === "arbitrary") {
2698
3183
  let value = candidate.value.value;
2699
3184
  let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage"]);
@@ -2704,6 +3189,8 @@ function createUtilities(theme) {
2704
3189
  }
2705
3190
  default: {
2706
3191
  value = asColor(value, candidate.modifier, theme);
3192
+ if (value === null)
3193
+ return;
2707
3194
  return [decl("text-decoration-color", value)];
2708
3195
  }
2709
3196
  }
@@ -2713,7 +3200,7 @@ function createUtilities(theme) {
2713
3200
  if (value) {
2714
3201
  return [decl("text-decoration-thickness", value)];
2715
3202
  }
2716
- if (!isNaN(Number(candidate.value.value))) {
3203
+ if (!Number.isNaN(Number(candidate.value.value))) {
2717
3204
  return [decl("text-decoration-thickness", `${candidate.value.value}px`)];
2718
3205
  }
2719
3206
  }
@@ -2724,6 +3211,18 @@ function createUtilities(theme) {
2724
3211
  }
2725
3212
  }
2726
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
+ ]);
2727
3226
  staticUtility("animate-none", [["animation", "none"]]);
2728
3227
  functionalUtility("animate", {
2729
3228
  themeKeys: ["--animate"],
@@ -2779,14 +3278,13 @@ function createUtilities(theme) {
2779
3278
  ]);
2780
3279
  };
2781
3280
  utilities.functional("filter", (candidate) => {
2782
- if (candidate.negative) {
3281
+ if (candidate.negative)
2783
3282
  return;
2784
- }
2785
3283
  if (candidate.value === null) {
2786
3284
  return [filterProperties(), decl("filter", cssFilterValue)];
2787
3285
  }
2788
3286
  if (candidate.value.kind === "arbitrary") {
2789
- return;
3287
+ return [decl("filter", candidate.value.value)];
2790
3288
  }
2791
3289
  switch (candidate.value.value) {
2792
3290
  case "none":
@@ -2794,9 +3292,8 @@ function createUtilities(theme) {
2794
3292
  }
2795
3293
  });
2796
3294
  utilities.functional("backdrop-filter", (candidate) => {
2797
- if (candidate.negative) {
3295
+ if (candidate.negative)
2798
3296
  return;
2799
- }
2800
3297
  if (candidate.value === null) {
2801
3298
  return [
2802
3299
  backdropFilterProperties(),
@@ -2805,7 +3302,10 @@ function createUtilities(theme) {
2805
3302
  ];
2806
3303
  }
2807
3304
  if (candidate.value.kind === "arbitrary") {
2808
- return;
3305
+ return [
3306
+ decl("-webkit-backdrop-filter", candidate.value.value),
3307
+ decl("backdrop-filter", candidate.value.value)
3308
+ ];
2809
3309
  }
2810
3310
  switch (candidate.value.value) {
2811
3311
  case "none":
@@ -2848,6 +3348,18 @@ function createUtilities(theme) {
2848
3348
  decl("backdrop-filter", cssBackdropFilterValue)
2849
3349
  ]
2850
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
+ ]);
2851
3363
  functionalUtility("contrast", {
2852
3364
  themeKeys: ["--contrast"],
2853
3365
  handleBareValue: ({ value }) => `${value}%`,
@@ -2867,6 +3379,18 @@ function createUtilities(theme) {
2867
3379
  decl("backdrop-filter", cssBackdropFilterValue)
2868
3380
  ]
2869
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
+ ]);
2870
3394
  functionalUtility("grayscale", {
2871
3395
  themeKeys: ["--grayscale"],
2872
3396
  handleBareValue: ({ value }) => `${value}%`,
@@ -2888,6 +3412,20 @@ function createUtilities(theme) {
2888
3412
  decl("backdrop-filter", cssBackdropFilterValue)
2889
3413
  ]
2890
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
+ ]);
2891
3429
  functionalUtility("hue-rotate", {
2892
3430
  themeKeys: ["--hue-rotate"],
2893
3431
  handleBareValue: ({ value }) => `${value}deg`,
@@ -2907,6 +3445,18 @@ function createUtilities(theme) {
2907
3445
  decl("backdrop-filter", cssBackdropFilterValue)
2908
3446
  ]
2909
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
+ ]);
2910
3460
  functionalUtility("invert", {
2911
3461
  themeKeys: ["--invert"],
2912
3462
  handleBareValue: ({ value }) => `${value}%`,
@@ -2928,6 +3478,20 @@ function createUtilities(theme) {
2928
3478
  decl("backdrop-filter", cssBackdropFilterValue)
2929
3479
  ]
2930
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
+ ]);
2931
3495
  functionalUtility("saturate", {
2932
3496
  themeKeys: ["--saturate"],
2933
3497
  handleBareValue: ({ value }) => `${value}%`,
@@ -2947,6 +3511,18 @@ function createUtilities(theme) {
2947
3511
  decl("backdrop-filter", cssBackdropFilterValue)
2948
3512
  ]
2949
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
+ ]);
2950
3526
  functionalUtility("sepia", {
2951
3527
  themeKeys: ["--sepia"],
2952
3528
  handleBareValue: ({ value }) => `${value}%`,
@@ -2968,6 +3544,20 @@ function createUtilities(theme) {
2968
3544
  decl("backdrop-filter", cssBackdropFilterValue)
2969
3545
  ]
2970
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
+ ]);
2971
3561
  functionalUtility("drop-shadow", {
2972
3562
  themeKeys: ["--drop-shadow"],
2973
3563
  handle: (value) => [
@@ -2982,7 +3572,6 @@ function createUtilities(theme) {
2982
3572
  functionalUtility("backdrop-opacity", {
2983
3573
  themeKeys: ["--backdrop-opacity", "--opacity"],
2984
3574
  handleBareValue: ({ value }) => `${value}%`,
2985
- defaultValue: "100%",
2986
3575
  handle: (value) => [
2987
3576
  backdropFilterProperties(),
2988
3577
  decl("--tw-backdrop-opacity", `opacity(${value})`),
@@ -2990,6 +3579,12 @@ function createUtilities(theme) {
2990
3579
  decl("backdrop-filter", cssBackdropFilterValue)
2991
3580
  ]
2992
3581
  });
3582
+ suggest("backdrop-opacity", () => [
3583
+ {
3584
+ values: Array.from({ length: 21 }, (_, i) => `${i * 5}`),
3585
+ valueThemeKeys: ["--backdrop-opacity", "--opacity"]
3586
+ }
3587
+ ]);
2993
3588
  }
2994
3589
  {
2995
3590
  let defaultTimingFunction = "var(--default-transition-timing-function)";
@@ -3049,14 +3644,26 @@ function createUtilities(theme) {
3049
3644
  value = theme.resolve(candidate.value.fraction ?? candidate.value.value, [
3050
3645
  "--transition-duration"
3051
3646
  ]);
3052
- if (!value && !isNaN(Number(candidate.value.value))) {
3647
+ if (value === null && !Number.isNaN(Number(candidate.value.value))) {
3053
3648
  value = `${candidate.value.value}ms`;
3054
3649
  }
3055
- if (!value)
3056
- return;
3057
3650
  }
3651
+ if (value === null)
3652
+ return;
3058
3653
  return [decl("transition-duration", value)];
3059
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
+ ]);
3060
3667
  }
3061
3668
  functionalUtility("ease", {
3062
3669
  themeKeys: ["--transition-timing-function"],
@@ -3194,61 +3801,121 @@ function createUtilities(theme) {
3194
3801
  ["font-variant-numeric", cssFontVariantNumericValue]
3195
3802
  ]);
3196
3803
  }
3197
- staticUtility("outline-none", [
3198
- ["outline", "2px solid transparent"],
3199
- ["outline-offset", "2px"]
3200
- ]);
3201
- staticUtility("outline-dashed", [["outline-style", "dashed"]]);
3202
- staticUtility("outline-dotted", [["outline-style", "dotted"]]);
3203
- staticUtility("outline-double", [["outline-style", "double"]]);
3204
- utilities.functional("outline", (candidate) => {
3205
- if (candidate.negative) {
3206
- return;
3207
- }
3208
- if (candidate.value === null) {
3209
- return [decl("outline-style", "solid")];
3210
- }
3211
- if (candidate.value.kind === "arbitrary") {
3212
- let value = candidate.value.value;
3213
- let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "number", "percentage"]);
3214
- switch (type) {
3215
- case "length":
3216
- case "number":
3217
- case "percentage": {
3218
- return [decl("outline-width", value)];
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
+ }
3219
3857
  }
3220
- default: {
3221
- value = asColor(value, candidate.modifier, theme);
3858
+ }
3859
+ {
3860
+ let value = resolveThemeColor(candidate, theme, ["--outline-color", "--color"]);
3861
+ if (value) {
3222
3862
  return [decl("outline-color", value)];
3223
3863
  }
3224
3864
  }
3225
- }
3226
- {
3227
- let value = resolveThemeColor(candidate, theme, ["--outline-color", "--color"]);
3228
- if (value) {
3229
- return [decl("outline-color", value)];
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
+ }
3230
3880
  }
3231
- }
3232
- {
3233
- let value = theme.resolve(candidate.value.value, ["--outline-width"]);
3234
- if (value) {
3235
- return [decl("outline-width", value)];
3236
- } else if (!isNaN(Number(candidate.value.value))) {
3237
- return [decl("outline-width", `${candidate.value.value}px`)];
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"]
3238
3893
  }
3239
- }
3240
- });
3241
- functionalUtility("outline-offset", {
3242
- supportsNegative: true,
3243
- themeKeys: ["--outline-offset"],
3244
- handleBareValue: ({ value }) => `${value}px`,
3245
- handle: (value) => [decl("outline-offset", value)]
3246
- });
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
+ }
3247
3908
  functionalUtility("opacity", {
3248
3909
  themeKeys: ["--opacity"],
3249
3910
  handleBareValue: ({ value }) => `${value}%`,
3250
3911
  handle: (value) => [decl("opacity", value)]
3251
3912
  });
3913
+ suggest("opacity", () => [
3914
+ {
3915
+ values: Array.from({ length: 21 }, (_, i) => `${i * 5}`),
3916
+ valueThemeKeys: ["--opacity"]
3917
+ }
3918
+ ]);
3252
3919
  staticUtility("underline-offset-auto", [["text-underline-offset", "auto"]]);
3253
3920
  functionalUtility("underline-offset", {
3254
3921
  supportsNegative: true,
@@ -3256,10 +3923,16 @@ function createUtilities(theme) {
3256
3923
  handleBareValue: ({ value }) => `${value}px`,
3257
3924
  handle: (value) => [decl("text-underline-offset", value)]
3258
3925
  });
3926
+ suggest("underline-offset", () => [
3927
+ {
3928
+ supportsNegative: true,
3929
+ values: ["0", "1", "2", "4", "8"],
3930
+ valueThemeKeys: ["--text-underline-offset"]
3931
+ }
3932
+ ]);
3259
3933
  utilities.functional("text", (candidate) => {
3260
- if (candidate.negative || !candidate.value) {
3934
+ if (candidate.negative || !candidate.value)
3261
3935
  return;
3262
- }
3263
3936
  if (candidate.value.kind === "arbitrary") {
3264
3937
  let value = candidate.value.value;
3265
3938
  let type = candidate.value.dataType ?? inferDataType(value, ["color", "length", "percentage", "absolute-size", "relative-size"]);
@@ -3279,6 +3952,8 @@ function createUtilities(theme) {
3279
3952
  }
3280
3953
  default: {
3281
3954
  value = asColor(value, candidate.modifier, theme);
3955
+ if (value === null)
3956
+ return;
3282
3957
  return [decl("color", value)];
3283
3958
  }
3284
3959
  }
@@ -3315,18 +3990,32 @@ function createUtilities(theme) {
3315
3990
  }
3316
3991
  }
3317
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
+ ]);
3318
4007
  {
3319
4008
  let ringShadowValue2 = function(value) {
3320
- return `var(--tw-ring-inset,) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color, var(--default-ring-color))`;
4009
+ return `var(--tw-ring-inset,) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color, ${defaultRingColor})`;
3321
4010
  }, insetRingShadowValue2 = function(value) {
3322
4011
  return `inset 0 0 0 ${value} var(--tw-inset-ring-color, currentColor)`;
3323
4012
  };
3324
4013
  let cssBoxShadowValue = [
3325
- `var(--tw-inset-shadow)`,
3326
- `var(--tw-inset-ring-shadow)`,
3327
- `var(--tw-ring-offset-shadow)`,
3328
- `var(--tw-ring-shadow)`,
3329
- `var(--tw-shadow)`
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)"
3330
4019
  ].join(", ");
3331
4020
  let nullShadow = "0 0 #0000";
3332
4021
  let boxShadowProperties = () => {
@@ -3347,12 +4036,11 @@ function createUtilities(theme) {
3347
4036
  ]);
3348
4037
  };
3349
4038
  utilities.functional("shadow", (candidate) => {
3350
- if (candidate.negative) {
4039
+ if (candidate.negative)
3351
4040
  return;
3352
- }
3353
4041
  if (!candidate.value) {
3354
4042
  let value = theme.get(["--shadow"]);
3355
- if (!value)
4043
+ if (value === null)
3356
4044
  return;
3357
4045
  return [
3358
4046
  boxShadowProperties(),
@@ -3367,6 +4055,8 @@ function createUtilities(theme) {
3367
4055
  switch (type) {
3368
4056
  case "color": {
3369
4057
  value = asColor(value, candidate.modifier, theme);
4058
+ if (value === null)
4059
+ return;
3370
4060
  return [
3371
4061
  boxShadowProperties(),
3372
4062
  decl("--tw-shadow-color", value),
@@ -3414,13 +4104,25 @@ function createUtilities(theme) {
3414
4104
  }
3415
4105
  }
3416
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
+ ]);
3417
4120
  utilities.functional("inset-shadow", (candidate) => {
3418
- if (candidate.negative) {
4121
+ if (candidate.negative)
3419
4122
  return;
3420
- }
3421
4123
  if (!candidate.value) {
3422
4124
  let value = theme.get(["--inset-shadow"]);
3423
- if (!value)
4125
+ if (value === null)
3424
4126
  return;
3425
4127
  return [
3426
4128
  boxShadowProperties(),
@@ -3438,6 +4140,8 @@ function createUtilities(theme) {
3438
4140
  switch (type) {
3439
4141
  case "color": {
3440
4142
  value = asColor(value, candidate.modifier, theme);
4143
+ if (value === null)
4144
+ return;
3441
4145
  return [
3442
4146
  boxShadowProperties(),
3443
4147
  decl("--tw-inset-shadow-color", value),
@@ -3491,14 +4195,29 @@ function createUtilities(theme) {
3491
4195
  }
3492
4196
  }
3493
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
+ ]);
3494
4211
  staticUtility("ring-inset", [boxShadowProperties, ["--tw-ring-inset", "inset"]]);
4212
+ let defaultRingColor = theme.get(["--default-ring-color"]) ?? "currentColor";
3495
4213
  utilities.functional("ring", (candidate) => {
3496
4214
  if (candidate.negative)
3497
4215
  return;
3498
4216
  if (!candidate.value) {
4217
+ let value = theme.get(["--default-ring-width"]) ?? "1px";
3499
4218
  return [
3500
4219
  boxShadowProperties(),
3501
- decl("--tw-ring-shadow", ringShadowValue2("var(--default-ring-width)")),
4220
+ decl("--tw-ring-shadow", ringShadowValue2(value)),
3502
4221
  decl("box-shadow", cssBoxShadowValue)
3503
4222
  ];
3504
4223
  }
@@ -3515,6 +4234,8 @@ function createUtilities(theme) {
3515
4234
  }
3516
4235
  default: {
3517
4236
  value = asColor(value, candidate.modifier, theme);
4237
+ if (value === null)
4238
+ return;
3518
4239
  return [decl("--tw-ring-color", value)];
3519
4240
  }
3520
4241
  }
@@ -3527,7 +4248,7 @@ function createUtilities(theme) {
3527
4248
  }
3528
4249
  {
3529
4250
  let value = theme.resolve(candidate.value.value, ["--ring-width"]);
3530
- if (!value && !isNaN(Number(candidate.value.value))) {
4251
+ if (value === null && !Number.isNaN(Number(candidate.value.value))) {
3531
4252
  value = `${candidate.value.value}px`;
3532
4253
  }
3533
4254
  if (value) {
@@ -3539,6 +4260,19 @@ function createUtilities(theme) {
3539
4260
  }
3540
4261
  }
3541
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
+ ]);
3542
4276
  utilities.functional("inset-ring", (candidate) => {
3543
4277
  if (candidate.negative)
3544
4278
  return;
@@ -3562,6 +4296,8 @@ function createUtilities(theme) {
3562
4296
  }
3563
4297
  default: {
3564
4298
  value = asColor(value, candidate.modifier, theme);
4299
+ if (value === null)
4300
+ return;
3565
4301
  return [decl("--tw-inset-ring-color", value)];
3566
4302
  }
3567
4303
  }
@@ -3574,7 +4310,7 @@ function createUtilities(theme) {
3574
4310
  }
3575
4311
  {
3576
4312
  let value = theme.resolve(candidate.value.value, ["--ring-width"]);
3577
- if (!value && !isNaN(Number(candidate.value.value))) {
4313
+ if (value === null && !Number.isNaN(Number(candidate.value.value))) {
3578
4314
  value = `${candidate.value.value}px`;
3579
4315
  }
3580
4316
  if (value) {
@@ -3586,11 +4322,23 @@ function createUtilities(theme) {
3586
4322
  }
3587
4323
  }
3588
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
+ ]);
3589
4338
  let ringOffsetShadowValue = "var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)";
3590
4339
  utilities.functional("ring-offset", (candidate) => {
3591
- if (candidate.negative || !candidate.value) {
4340
+ if (candidate.negative || !candidate.value)
3592
4341
  return;
3593
- }
3594
4342
  if (candidate.value.kind === "arbitrary") {
3595
4343
  let value = candidate.value.value;
3596
4344
  let type = candidate.value.dataType ?? inferDataType(value, ["color", "length"]);
@@ -3603,6 +4351,8 @@ function createUtilities(theme) {
3603
4351
  }
3604
4352
  default: {
3605
4353
  value = asColor(value, candidate.modifier, theme);
4354
+ if (value === null)
4355
+ return;
3606
4356
  return [decl("--tw-ring-offset-color", value)];
3607
4357
  }
3608
4358
  }
@@ -3614,7 +4364,7 @@ function createUtilities(theme) {
3614
4364
  decl("--tw-ring-offset-width", value),
3615
4365
  decl("--tw-ring-offset-shadow", ringOffsetShadowValue)
3616
4366
  ];
3617
- } else if (!isNaN(Number(candidate.value.value))) {
4367
+ } else if (!Number.isNaN(Number(candidate.value.value))) {
3618
4368
  return [
3619
4369
  decl("--tw-ring-offset-width", `${candidate.value.value}px`),
3620
4370
  decl("--tw-ring-offset-shadow", ringOffsetShadowValue)
@@ -3629,29 +4379,51 @@ function createUtilities(theme) {
3629
4379
  }
3630
4380
  });
3631
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
+ ]);
3632
4419
  return utilities;
3633
4420
  }
3634
4421
 
3635
- // src/utils/default-map.ts
3636
- var DefaultMap = class extends Map {
3637
- constructor(factory) {
3638
- super();
3639
- this.factory = factory;
3640
- }
3641
- get(key) {
3642
- let value = super.get(key);
3643
- if (value === void 0) {
3644
- value = this.factory(key, this);
3645
- this.set(key, value);
3646
- }
3647
- return value;
3648
- }
3649
- };
3650
-
3651
4422
  // src/variants.ts
3652
4423
  var Variants = class {
3653
4424
  compareFns = /* @__PURE__ */ new Map();
3654
4425
  variants = /* @__PURE__ */ new Map();
4426
+ completions = /* @__PURE__ */ new Map();
3655
4427
  /**
3656
4428
  * Registering a group of variants should result in the same sort number for
3657
4429
  * all the variants. This is to ensure that the variants are applied in the
@@ -3683,7 +4455,7 @@ var Variants = class {
3683
4455
  return this.variants.has(name);
3684
4456
  }
3685
4457
  get(name) {
3686
- return this.variants.get(name)?.applyFn;
4458
+ return this.variants.get(name);
3687
4459
  }
3688
4460
  kind(name) {
3689
4461
  return this.variants.get(name)?.kind;
@@ -3691,6 +4463,12 @@ var Variants = class {
3691
4463
  compounds(name) {
3692
4464
  return this.variants.get(name)?.compounds;
3693
4465
  }
4466
+ suggest(name, suggestions) {
4467
+ this.completions.set(name, suggestions);
4468
+ }
4469
+ getCompletions(name) {
4470
+ return this.completions.get(name)?.() ?? [];
4471
+ }
3694
4472
  compare(a, z) {
3695
4473
  if (a === z)
3696
4474
  return 0;
@@ -3721,6 +4499,9 @@ var Variants = class {
3721
4499
  keys() {
3722
4500
  return this.variants.keys();
3723
4501
  }
4502
+ entries() {
4503
+ return this.variants.entries();
4504
+ }
3724
4505
  set(name, { kind, applyFn, compounds }) {
3725
4506
  this.lastOrder = this.nextOrder();
3726
4507
  this.variants.set(name, {
@@ -3756,11 +4537,21 @@ function createVariants(theme) {
3756
4537
  ruleNode.selector = ruleNode.selector.replace("&", groupSelector);
3757
4538
  ruleNode.selector = `&:is(${ruleNode.selector} *)`;
3758
4539
  });
4540
+ variants.suggest("group", () => {
4541
+ return Array.from(variants.keys()).filter((name) => {
4542
+ return variants.get(name)?.compounds ?? false;
4543
+ });
4544
+ });
3759
4545
  variants.compound("peer", (ruleNode, variant) => {
3760
4546
  let peerSelector = variant.modifier ? `:where(.peer\\/${variant.modifier.value})` : ":where(.peer)";
3761
4547
  ruleNode.selector = ruleNode.selector.replace("&", peerSelector);
3762
4548
  ruleNode.selector = `&:is(${ruleNode.selector} ~ *)`;
3763
4549
  });
4550
+ variants.suggest("peer", () => {
4551
+ return Array.from(variants.keys()).filter((name) => {
4552
+ return variants.get(name)?.compounds ?? false;
4553
+ });
4554
+ });
3764
4555
  staticVariant("first-letter", ["&::first-letter"], { compounds: false });
3765
4556
  staticVariant("first-line", ["&::first-line"], { compounds: false });
3766
4557
  staticVariant("marker", ["& *::marker", "&::marker"], { compounds: false });
@@ -3857,15 +4648,31 @@ function createVariants(theme) {
3857
4648
  variants.compound("has", (ruleNode) => {
3858
4649
  ruleNode.selector = `&:has(${ruleNode.selector.replace("&", "*")})`;
3859
4650
  });
4651
+ variants.suggest("has", () => {
4652
+ return Array.from(variants.keys()).filter((name) => {
4653
+ return variants.get(name)?.compounds ?? false;
4654
+ });
4655
+ });
3860
4656
  variants.functional("aria", (ruleNode, variant) => {
3861
4657
  if (variant.value === null)
3862
4658
  return null;
3863
- if (variant.value.kind == "arbitrary") {
4659
+ if (variant.value.kind === "arbitrary") {
3864
4660
  ruleNode.nodes = [rule(`&[aria-${variant.value.value}]`, ruleNode.nodes)];
3865
4661
  } else {
3866
4662
  ruleNode.nodes = [rule(`&[aria-${variant.value.value}="true"]`, ruleNode.nodes)];
3867
4663
  }
3868
4664
  });
4665
+ variants.suggest("aria", () => [
4666
+ "busy",
4667
+ "checked",
4668
+ "disabled",
4669
+ "expanded",
4670
+ "hidden",
4671
+ "pressed",
4672
+ "readonly",
4673
+ "required",
4674
+ "selected"
4675
+ ]);
3869
4676
  variants.functional("data", (ruleNode, variant) => {
3870
4677
  if (variant.value === null)
3871
4678
  return null;
@@ -3901,13 +4708,13 @@ function createVariants(theme) {
3901
4708
  staticVariant("contrast-more", ["@media (prefers-contrast: more)"], { compounds: false });
3902
4709
  staticVariant("contrast-less", ["@media (prefers-contrast: less)"], { compounds: false });
3903
4710
  {
3904
- let compareBreakpoints2 = function(a, z, direction) {
4711
+ let compareBreakpoints2 = function(a, z, direction, lookup) {
3905
4712
  if (a === z)
3906
4713
  return 0;
3907
- let aValue = resolvedBreakpoints.get(a);
4714
+ let aValue = lookup.get(a);
3908
4715
  if (aValue === null)
3909
4716
  return direction === "asc" ? -1 : 1;
3910
- let zValue = resolvedBreakpoints.get(z);
4717
+ let zValue = lookup.get(z);
3911
4718
  if (zValue === null)
3912
4719
  return direction === "asc" ? 1 : -1;
3913
4720
  if (aValue === zValue)
@@ -3933,78 +4740,177 @@ function createVariants(theme) {
3933
4740
  aBucket.localeCompare(zBucket) || // If bucket names are the same, compare by value
3934
4741
  (direction === "asc" ? parseInt(aValue) - parseInt(zValue) : parseInt(zValue) - parseInt(aValue))
3935
4742
  );
3936
- if (isNaN(order)) {
4743
+ if (Number.isNaN(order)) {
3937
4744
  return aValue.localeCompare(zValue);
3938
4745
  }
3939
4746
  return order;
3940
4747
  };
3941
- let breakpoints = theme.namespace("--breakpoint");
3942
- let resolvedBreakpoints = new DefaultMap((variant) => {
3943
- switch (variant.kind) {
3944
- case "static": {
3945
- return breakpoints.get(variant.root) ?? null;
3946
- }
3947
- case "functional": {
3948
- let value = null;
3949
- if (variant.value.kind === "arbitrary") {
3950
- value = variant.value.value;
3951
- } else if (variant.value.kind === "named") {
3952
- value = theme.resolve(variant.value.value, ["--breakpoint"]);
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;
3953
4754
  }
3954
- if (!value) {
3955
- return null;
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;
3956
4769
  }
3957
- if (value.includes("var(")) {
4770
+ case "arbitrary":
4771
+ case "compound":
3958
4772
  return null;
3959
- }
3960
- return value;
3961
4773
  }
3962
- case "arbitrary":
3963
- case "compound":
3964
- return null;
3965
- }
3966
- });
3967
- variants.group(
3968
- () => {
3969
- variants.functional(
3970
- "max",
3971
- (ruleNode, variant) => {
3972
- let value = resolvedBreakpoints.get(variant);
3973
- if (value === null)
3974
- return null;
3975
- ruleNode.nodes = [rule(`@media (width < ${value})`, ruleNode.nodes)];
3976
- },
3977
- { compounds: false }
3978
- );
3979
- },
3980
- (a, z) => compareBreakpoints2(a, z, "desc")
3981
- );
3982
- variants.group(
3983
- () => {
3984
- for (let [key, value] of theme.namespace("--breakpoint")) {
3985
- if (key === null)
3986
- continue;
3987
- variants.static(
3988
- key,
3989
- (ruleNode) => {
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;
3990
4813
  ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
3991
4814
  },
3992
4815
  { compounds: false }
3993
4816
  );
3994
- }
3995
- variants.functional(
3996
- "min",
3997
- (ruleNode, variant) => {
3998
- let value = resolvedBreakpoints.get(variant);
3999
- if (value === null)
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)
4000
4831
  return null;
4001
- ruleNode.nodes = [rule(`@media (width >= ${value})`, ruleNode.nodes)];
4002
- },
4003
- { compounds: false }
4004
- );
4005
- },
4006
- (a, z) => compareBreakpoints2(a, z, "asc")
4007
- );
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
+ }
4008
4914
  }
4009
4915
  staticVariant("portrait", ["@media (orientation: portrait)"], { compounds: false });
4010
4916
  staticVariant("landscape", ["@media (orientation: landscape)"], { compounds: false });
@@ -4022,14 +4928,33 @@ function buildDesignSystem(theme) {
4022
4928
  theme,
4023
4929
  utilities: createUtilities(theme),
4024
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
+ },
4025
4943
  getClassOrder(classes) {
4026
4944
  return getClassOrder(this, classes);
4945
+ },
4946
+ getClassList() {
4947
+ return getClassList(this);
4948
+ },
4949
+ getVariants() {
4950
+ return getVariants(this);
4027
4951
  }
4028
4952
  };
4029
4953
  }
4030
4954
 
4031
4955
  // src/property-order.ts
4032
4956
  var property_order_default = [
4957
+ "container-type",
4033
4958
  "pointer-events",
4034
4959
  "visibility",
4035
4960
  "position",
@@ -4365,39 +5290,6 @@ function escape(value) {
4365
5290
  }
4366
5291
 
4367
5292
  // src/compile.ts
4368
- function applyImportant(ast) {
4369
- for (let node of ast) {
4370
- if (node.kind === "rule" && node.selector === "@at-root") {
4371
- continue;
4372
- }
4373
- if (node.kind === "declaration") {
4374
- node.important = true;
4375
- } else if (node.kind === "rule") {
4376
- applyImportant(node.nodes);
4377
- }
4378
- }
4379
- }
4380
- function applyVariant(node, variant, variants) {
4381
- if (variant.kind === "arbitrary") {
4382
- node.nodes = [rule(variant.selector, node.nodes)];
4383
- return;
4384
- }
4385
- let applyVariantFn = variants.get(variant.root);
4386
- if (variant.kind === "compound") {
4387
- let result2 = applyVariant(node, variant.variant, variants);
4388
- if (result2 === null)
4389
- return null;
4390
- for (let child of node.nodes) {
4391
- let result3 = applyVariantFn(child, variant);
4392
- if (result3 === null)
4393
- return null;
4394
- }
4395
- return;
4396
- }
4397
- let result = applyVariantFn(node, variant);
4398
- if (result === null)
4399
- return null;
4400
- }
4401
5293
  function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidate = false } = {}) {
4402
5294
  rawCandidates.sort();
4403
5295
  let nodeSorting = /* @__PURE__ */ new Map();
@@ -4406,18 +5298,16 @@ function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidat
4406
5298
  return parseVariant(variant, designSystem.variants, map);
4407
5299
  });
4408
5300
  let candidates = /* @__PURE__ */ new Map();
4409
- next:
4410
- for (let rawCandidate of rawCandidates) {
4411
- let candidate = parseCandidate(rawCandidate, designSystem.utilities, parsedVariants);
4412
- if (candidate === null) {
4413
- if (throwOnInvalidCandidate) {
4414
- throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
4415
- } else {
4416
- continue next;
4417
- }
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}`);
4418
5306
  }
4419
- candidates.set(candidate, rawCandidate);
5307
+ continue;
4420
5308
  }
5309
+ candidates.set(candidate, rawCandidate);
5310
+ }
4421
5311
  let variants = Array.from(parsedVariants.values()).sort((a, z) => {
4422
5312
  return designSystem.variants.compare(a, z);
4423
5313
  });
@@ -4425,16 +5315,23 @@ function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidat
4425
5315
  for (let [candidate, rawCandidate] of candidates) {
4426
5316
  let nodes = [];
4427
5317
  if (candidate.kind === "arbitrary") {
4428
- nodes = [decl(candidate.property, candidate.value)];
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;
4429
5327
  } else if (candidate.kind === "static" || candidate.kind === "functional") {
4430
5328
  let { compileFn } = designSystem.utilities.get(candidate.root);
4431
5329
  let compiledNodes = compileFn(candidate);
4432
5330
  if (compiledNodes === void 0) {
4433
5331
  if (throwOnInvalidCandidate) {
4434
5332
  throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
4435
- } else {
4436
- continue next;
4437
5333
  }
5334
+ continue next;
4438
5335
  }
4439
5336
  nodes = compiledNodes;
4440
5337
  }
@@ -4453,9 +5350,8 @@ function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidat
4453
5350
  if (result === null) {
4454
5351
  if (throwOnInvalidCandidate) {
4455
5352
  throw new Error(`Cannot apply unknown utility class: ${rawCandidate}`);
4456
- } else {
4457
- continue next;
4458
5353
  }
5354
+ continue next;
4459
5355
  }
4460
5356
  variantOrder |= 1n << BigInt(variants.indexOf(variant));
4461
5357
  }
@@ -4487,31 +5383,65 @@ function compileCandidates(rawCandidates, designSystem, { throwOnInvalidCandidat
4487
5383
  nodeSorting
4488
5384
  };
4489
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
+ }
4490
5421
  function getPropertySort(nodes) {
4491
5422
  let propertySort = /* @__PURE__ */ new Set();
4492
5423
  let q = nodes.slice();
4493
- next:
4494
- while (q.length > 0) {
4495
- let node = q.shift();
4496
- if (node.kind === "declaration") {
4497
- if (node.property === "--tw-sort") {
4498
- let idx2 = property_order_default.indexOf(node.value);
4499
- if (idx2 !== -1) {
4500
- propertySort.add(idx2);
4501
- break next;
4502
- }
4503
- }
4504
- let idx = property_order_default.indexOf(node.property);
4505
- if (idx !== -1)
4506
- propertySort.add(idx);
4507
- } else if (node.kind === "rule") {
4508
- if (node.selector === "@at-root")
4509
- continue;
4510
- for (let child of node.nodes) {
4511
- q.push(child);
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;
4512
5432
  }
4513
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
+ }
4514
5443
  }
5444
+ }
4515
5445
  return Array.from(propertySort).sort((a, z) => a - z);
4516
5446
  }
4517
5447
 
@@ -4634,10 +5564,9 @@ function parse(input) {
4634
5564
  node = null;
4635
5565
  } else if (char === "}") {
4636
5566
  if (closingBracketStack === "") {
4637
- throw new Error(`Missing opening {`);
4638
- } else {
4639
- closingBracketStack = closingBracketStack.slice(0, -1);
5567
+ throw new Error("Missing opening {");
4640
5568
  }
5569
+ closingBracketStack = closingBracketStack.slice(0, -1);
4641
5570
  if (current.length > 0) {
4642
5571
  if (current[0] === "@") {
4643
5572
  node = rule(current.trim(), []);
@@ -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
  {
@@ -4923,7 +5820,27 @@ function compile(css, rawCandidates) {
4923
5820
  }
4924
5821
  return toCss(ast);
4925
5822
  }
4926
- function loadDesignSystem(css) {
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;