@fluixi-css/core 0.1.0-next.0 → 1.0.0-next.2

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.
Files changed (67) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/reset.css +178 -147
  3. package/dist/src/css-parser.cjs +6 -1
  4. package/dist/src/css-parser.cjs.map +1 -1
  5. package/dist/src/css-parser.js +6 -2
  6. package/dist/src/css-parser.js.map +1 -1
  7. package/dist/src/css-parser.mjs +6 -1
  8. package/dist/src/css-parser.mjs.map +1 -1
  9. package/dist/src/engine/apply.d.ts +2 -0
  10. package/dist/src/engine/apply.js +75 -0
  11. package/dist/src/engine/apply.js.map +1 -0
  12. package/dist/src/engine/ast.js +25 -2
  13. package/dist/src/engine/ast.js.map +1 -1
  14. package/dist/src/engine/atom.js +6 -1
  15. package/dist/src/engine/atom.js.map +1 -1
  16. package/dist/src/engine/compile.js +48 -10
  17. package/dist/src/engine/compile.js.map +1 -1
  18. package/dist/src/engine/directives.js +89 -20
  19. package/dist/src/engine/directives.js.map +1 -1
  20. package/dist/src/engine/index.d.ts +4 -0
  21. package/dist/src/engine/index.js +10 -0
  22. package/dist/src/engine/index.js.map +1 -1
  23. package/dist/src/engine/log.d.ts +6 -0
  24. package/dist/src/engine/log.js +42 -0
  25. package/dist/src/engine/log.js.map +1 -0
  26. package/dist/src/engine/registry.d.ts +5 -4
  27. package/dist/src/engine/registry.js +2 -2
  28. package/dist/src/engine/registry.js.map +1 -1
  29. package/dist/src/engine/scanner.js +34 -6
  30. package/dist/src/engine/scanner.js.map +1 -1
  31. package/dist/src/engine/transform.d.ts +22 -0
  32. package/dist/src/engine/transform.js +36 -9
  33. package/dist/src/engine/transform.js.map +1 -1
  34. package/dist/src/engine/utilities/backgrounds.js +11 -0
  35. package/dist/src/engine/utilities/backgrounds.js.map +1 -1
  36. package/dist/src/engine/utilities/borders.js +60 -1
  37. package/dist/src/engine/utilities/borders.js.map +1 -1
  38. package/dist/src/engine/utilities/filters.d.ts +2 -0
  39. package/dist/src/engine/utilities/filters.js +86 -0
  40. package/dist/src/engine/utilities/filters.js.map +1 -0
  41. package/dist/src/engine/utilities/gradients.d.ts +2 -0
  42. package/dist/src/engine/utilities/gradients.js +40 -0
  43. package/dist/src/engine/utilities/gradients.js.map +1 -0
  44. package/dist/src/engine/utilities/index.js +8 -0
  45. package/dist/src/engine/utilities/index.js.map +1 -1
  46. package/dist/src/engine/utilities/layout.js +25 -0
  47. package/dist/src/engine/utilities/layout.js.map +1 -1
  48. package/dist/src/engine/utilities/spacing.js +25 -1
  49. package/dist/src/engine/utilities/spacing.js.map +1 -1
  50. package/dist/src/engine/utilities/transforms.d.ts +2 -0
  51. package/dist/src/engine/utilities/transforms.js +63 -0
  52. package/dist/src/engine/utilities/transforms.js.map +1 -0
  53. package/dist/src/engine/utilities/transitions.d.ts +2 -0
  54. package/dist/src/engine/utilities/transitions.js +61 -0
  55. package/dist/src/engine/utilities/transitions.js.map +1 -0
  56. package/dist/src/engine/utilities/typography.js +7 -0
  57. package/dist/src/engine/utilities/typography.js.map +1 -1
  58. package/dist/src/engine/variants.d.ts +1 -0
  59. package/dist/src/engine/variants.js +37 -11
  60. package/dist/src/engine/variants.js.map +1 -1
  61. package/dist/src/index.cjs +1038 -199
  62. package/dist/src/index.cjs.map +1 -1
  63. package/dist/src/index.mjs +1036 -200
  64. package/dist/src/index.mjs.map +1 -1
  65. package/dist/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +1 -1
  67. package/reset.css +178 -147
@@ -275,6 +275,34 @@ var Writer = /*#__PURE__*/function () {
275
275
  });
276
276
  }
277
277
  }
278
+
279
+ // Emit verbatim text (a passed-through author slice or the reset) mapping each
280
+ // of its lines to consecutive source lines — so multi-line blocks are covered,
281
+ // not just their first line.
282
+ }, {
283
+ key: "emitMapped",
284
+ value: function emitMapped(text, loc) {
285
+ if (!this.map) {
286
+ this.emit(text);
287
+ return;
288
+ }
289
+ var lines = text.split('\n');
290
+ for (var i = 0; i < lines.length; i++) {
291
+ this.map.addMapping({
292
+ source: loc.source,
293
+ original: {
294
+ line: loc.line + i,
295
+ column: i === 0 ? loc.column : 0
296
+ },
297
+ generated: {
298
+ line: this.line,
299
+ column: this.column
300
+ }
301
+ });
302
+ this.emit(lines[i]);
303
+ if (i < lines.length - 1) this.emit('\n');
304
+ }
305
+ }
278
306
  }]);
279
307
  }();
280
308
  function stringify(nodes) {
@@ -330,8 +358,8 @@ function write(node, depth, opts, w) {
330
358
  }
331
359
  if (node.kind === 'raw') {
332
360
  w.emit(pad);
333
- w.mark(node.loc);
334
- w.emit("".concat(node.text).concat(nl));
361
+ if (node.loc) w.emitMapped(node.text, node.loc);else w.emit(node.text);
362
+ w.emit(nl);
335
363
  return;
336
364
  }
337
365
  var header = node.kind === 'rule' ? node.selector : "@".concat(node.name).concat(node.params ? ' ' + node.params : '');
@@ -421,7 +449,11 @@ function splitModifier(base) {
421
449
 
422
450
  // In arbitrary values `_` stands in for a space; `\_` is a literal underscore.
423
451
  function decodeUnderscores(value) {
424
- return value.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
452
+ // `_` → space, `\_` → literal `_`. But a URL may legitimately contain underscores,
453
+ // so leave the inside of `url(...)` verbatim (the split keeps url() at odd indices).
454
+ return value.split(/(url\([^)]*\))/g).map(function (part, i) {
455
+ return i % 2 === 1 ? part : part.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
456
+ }).join('');
425
457
  }
426
458
 
427
459
  // An arbitrary value may lead with a `type:` hint, e.g. `[length:12px]`.
@@ -669,6 +701,298 @@ function splitRootValue(base, ctx) {
669
701
  };
670
702
  }
671
703
 
704
+ // Turns a parsed atom into CSS. Returns null when the utility or any of its
705
+ // variants aren't registered, so an unknown class simply produces nothing.
706
+ function compileAtom(atom, reg) {
707
+ var produced = producedFor(atom, reg);
708
+ if (!produced || produced.length === 0) return null;
709
+ var flat = [];
710
+ var nested = [];
711
+ var _iterator = _createForOfIteratorHelper(produced),
712
+ _step;
713
+ try {
714
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
715
+ var node = _step.value;
716
+ if (node.kind === 'declaration') flat.push(node);else nested.push(node);
717
+ }
718
+ } catch (err) {
719
+ _iterator.e(err);
720
+ } finally {
721
+ _iterator.f();
722
+ }
723
+ if (atom.important) {
724
+ var _iterator2 = _createForOfIteratorHelper(flat),
725
+ _step2;
726
+ try {
727
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
728
+ var d = _step2.value;
729
+ d.important = true;
730
+ }
731
+ } catch (err) {
732
+ _iterator2.e(err);
733
+ } finally {
734
+ _iterator2.f();
735
+ }
736
+ var _iterator3 = _createForOfIteratorHelper(nested),
737
+ _step3;
738
+ try {
739
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
740
+ var n = _step3.value;
741
+ markImportant$1(n.nodes);
742
+ }
743
+ } catch (err) {
744
+ _iterator3.e(err);
745
+ } finally {
746
+ _iterator3.f();
747
+ }
748
+ }
749
+ var selector = '.' + escapeClass(atom.raw);
750
+ var atRules = [];
751
+ var _iterator4 = _createForOfIteratorHelper(atom.variants),
752
+ _step4;
753
+ try {
754
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
755
+ var variant = _step4.value;
756
+ var wrap = resolveVariant(variant, reg);
757
+ if (!wrap) return null;
758
+ if (wrap.selector) selector = substitute(wrap.selector, selector);
759
+ if (wrap.atRule) atRules.push(wrap.atRule);
760
+ }
761
+
762
+ // Flat declarations sit on the utility's own selector; nested rules weave that
763
+ // selector into their `&` (`space-x-4` → `.space-x-4 > :not([hidden]) ~ …`).
764
+ } catch (err) {
765
+ _iterator4.e(err);
766
+ } finally {
767
+ _iterator4.f();
768
+ }
769
+ var nodes = [];
770
+ if (flat.length) nodes.push(rule(selector, flat));
771
+ for (var _i = 0, _nested = nested; _i < _nested.length; _i++) {
772
+ var _n = _nested[_i];
773
+ nodes.push(rule(substitute(_n.selector, selector), _n.nodes));
774
+ }
775
+ for (var _i2 = 0, _atRules = atRules; _i2 < _atRules.length; _i2++) {
776
+ var ar = _atRules[_i2];
777
+ nodes = [atRule(ar.name, ar.params, nodes)];
778
+ }
779
+ return nodes;
780
+ }
781
+ function markImportant$1(nodes) {
782
+ var _iterator5 = _createForOfIteratorHelper(nodes),
783
+ _step5;
784
+ try {
785
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
786
+ var n = _step5.value;
787
+ if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant$1(n.nodes);
788
+ }
789
+ } catch (err) {
790
+ _iterator5.e(err);
791
+ } finally {
792
+ _iterator5.f();
793
+ }
794
+ }
795
+ function producedFor(atom, reg) {
796
+ if (atom.kind === 'arbitrary-property') {
797
+ return [decl(atom.property, atom.value)];
798
+ }
799
+ if (atom.kind === 'static') {
800
+ // Clone: static templates are shared, and `!important` / `&`-weaving mutate.
801
+ var products = reg.getRule(atom.root);
802
+ return products ? products.map(cloneProduct) : null;
803
+ }
804
+ var handler = reg.getDynamicRule(atom.root);
805
+ if (!handler) return null;
806
+ return handler({
807
+ value: atom.value,
808
+ modifier: atom.modifier,
809
+ negative: atom.negative,
810
+ theme: reg.theme
811
+ });
812
+ }
813
+ function cloneProduct(n) {
814
+ return n.kind === 'declaration' ? _objectSpread2({}, n) : cloneNode(n);
815
+ }
816
+ function cloneNode(n) {
817
+ if (n.kind === 'declaration') return _objectSpread2({}, n);
818
+ if (n.kind === 'rule') return rule(n.selector, n.nodes.map(cloneNode));
819
+ if (n.kind === 'at-rule') return atRule(n.name, n.params, n.nodes.map(cloneNode));
820
+ return _objectSpread2({}, n);
821
+ }
822
+ function resolveVariant(variant, reg) {
823
+ if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
824
+ if (variant.kind === 'static') return reg.getVariant(variant.root);
825
+ // functional: a null value means it's really a static variant (hover, md, …).
826
+ if (variant.value === null) return reg.getVariant(variant.root);
827
+ var handler = reg.getDynamicVariant(variant.root);
828
+ return handler ? handler(variant.value, variant.modifier) : null;
829
+ }
830
+
831
+ // `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
832
+ // A bare selector with no `&` is attached to the element.
833
+ function arbitraryVariant(source) {
834
+ if (source[0] === '@') {
835
+ var cut = source.search(/[\s(]/);
836
+ var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
837
+ var params = cut === -1 ? '' : source.slice(cut).trim();
838
+ return {
839
+ atRule: {
840
+ name: name,
841
+ params: params
842
+ }
843
+ };
844
+ }
845
+ var sel = spacesFromUnderscores(source);
846
+ return {
847
+ selector: sel.includes('&') ? sel : "&".concat(sel)
848
+ };
849
+ }
850
+ function spacesFromUnderscores(s) {
851
+ return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
852
+ }
853
+ function substitute(template, current) {
854
+ return template.replace(/&/g, current);
855
+ }
856
+
857
+ // Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
858
+ // class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
859
+ function escapeClass(name) {
860
+ return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
861
+ return '\\' + c;
862
+ });
863
+ }
864
+
865
+ // `@apply a b c;` — inline the declarations those utilities produce into the
866
+ // surrounding rule. Operates on author-CSS text (which `transform` passes through
867
+ // verbatim), replacing each `@apply` at-rule in place. Flat utilities inline as
868
+ // declarations; utilities that need their own selector (variants like `hover:` /
869
+ // `group-hover:`, child-combinators like `space-x`, at-rule variants like `md:`)
870
+ // emit a nested rule with `&` bound to the applying selector.
871
+ var APPLY_RE = /@apply\s+([^;{}]+);/g;
872
+ function expandApply(css, reg) {
873
+ if (!css.includes('@apply')) return css;
874
+ return css.replace(APPLY_RE, function (_match, listRaw) {
875
+ var list = listRaw.trim();
876
+ // A trailing `!important` marks every inlined declaration (Tailwind semantics).
877
+ var important = false;
878
+ var bang = list.match(/!important\s*$/);
879
+ if (bang) {
880
+ important = true;
881
+ list = list.slice(0, bang.index).trim();
882
+ }
883
+ var decls = [];
884
+ var rules = [];
885
+ var _iterator = _createForOfIteratorHelper(list.split(/\s+/)),
886
+ _step;
887
+ try {
888
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
889
+ var token = _step.value;
890
+ if (!token) continue;
891
+ var out = compileForApply(token, reg, important);
892
+ if (!out) continue;
893
+ if (out.decls) decls.push.apply(decls, _toConsumableArray(out.decls));
894
+ if (out.rule) rules.push(out.rule);
895
+ }
896
+ // Flat declarations first, then nested rules — same order as authored.
897
+ } catch (err) {
898
+ _iterator.e(err);
899
+ } finally {
900
+ _iterator.f();
901
+ }
902
+ return [].concat(decls, rules).join(' ');
903
+ });
904
+ }
905
+ function compileForApply(cls, reg, important) {
906
+ var atom = parseAtom(cls, reg);
907
+ if (!atom) return null;
908
+ var compiled = compileAtom(atom, reg);
909
+ if (!compiled || compiled.length === 0) return null;
910
+ var classSelector = '.' + escapeClass(atom.raw);
911
+
912
+ // A plain utility — one rule on the class itself with only declarations — inlines
913
+ // straight into the applying rule.
914
+ if (compiled.length === 1 && compiled[0].kind === 'rule' && compiled[0].selector === classSelector) {
915
+ var flat = compiled[0].nodes;
916
+ if (flat.every(function (n) {
917
+ return n.kind === 'declaration';
918
+ })) {
919
+ return {
920
+ decls: flat.map(function (n) {
921
+ return declText(n, important);
922
+ })
923
+ };
924
+ }
925
+ }
926
+
927
+ // Everything else keeps its structure but nests: swap the class's own selector
928
+ // for `&`, so `hover:` → `&:hover`, `group-hover:` → `.group:hover &`, `md:` →
929
+ // `@media(...) { & { … } }`.
930
+ if (important) markImportant(compiled);
931
+ var text = stringify(compiled, {
932
+ minify: false
933
+ }).split(classSelector).join('&');
934
+ return {
935
+ rule: text
936
+ };
937
+ }
938
+ function declText(d, important) {
939
+ return "".concat(d.property, ": ").concat(d.value).concat(important || d.important ? ' !important' : '', ";");
940
+ }
941
+ function markImportant(nodes) {
942
+ var _iterator2 = _createForOfIteratorHelper(nodes),
943
+ _step2;
944
+ try {
945
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
946
+ var n = _step2.value;
947
+ if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant(n.nodes);
948
+ }
949
+ } catch (err) {
950
+ _iterator2.e(err);
951
+ } finally {
952
+ _iterator2.f();
953
+ }
954
+ }
955
+
956
+ // Renders a `transform()` result as a compact, colourised build line for the
957
+ // Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays
958
+ // side-effect free — the plugins own the actual `console.log`.
959
+
960
+ var ANSI = {
961
+ reset: '\x1b[0m',
962
+ dim: '\x1b[2m',
963
+ bold: '\x1b[1m',
964
+ cyan: '\x1b[36m',
965
+ green: '\x1b[32m',
966
+ yellow: '\x1b[33m',
967
+ red: '\x1b[31m'
968
+ };
969
+ function paint(code, s, color) {
970
+ return color ? code + s + ANSI.reset : s;
971
+ }
972
+ function humanBytes(n) {
973
+ return n < 1024 ? "".concat(n, " B") : "".concat((n / 1024).toFixed(1), " kB");
974
+ }
975
+ function humanMs(ms) {
976
+ return ms < 1 ? "".concat(ms * 1000 | 0, " \xB5s") : ms < 1000 ? "".concat(ms.toFixed(1), " ms") : "".concat((ms / 1000).toFixed(2), " s");
977
+ }
978
+
979
+ // Green under 10 ms, yellow under 50 ms, red beyond — a quick "is it fast?" cue.
980
+ function timeColor(ms) {
981
+ return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;
982
+ }
983
+ function formatBuildLog(label, stats) {
984
+ var _options$color;
985
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
986
+ var color = (_options$color = options.color) !== null && _options$color !== void 0 ? _options$color : true;
987
+ var head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);
988
+ var name = paint(ANSI.bold, label, color);
989
+ var time = paint(timeColor(stats.ms), humanMs(stats.ms), color);
990
+ var parts = ["".concat(stats.utilities, " ").concat(stats.utilities === 1 ? 'utility' : 'utilities'), "".concat(stats.scanned, " scanned"), humanBytes(stats.bytes)];
991
+ if (stats.sources) parts.push("".concat(stats.sources, " ").concat(stats.sources === 1 ? 'source' : 'sources'));
992
+ var detail = paint(ANSI.dim, parts.join(' · '), color);
993
+ return "".concat(head, " ").concat(name, " ").concat(time, "\n ").concat(detail);
994
+ }
995
+
672
996
  // The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
673
997
  // `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
674
998
  // `var()` references, so the tokens stay live and themeable at runtime.
@@ -1072,8 +1396,13 @@ var CssParser = /*#__PURE__*/function () {
1072
1396
  case 'counter-style':
1073
1397
  case 'viewport':
1074
1398
  case 'theme':
1075
- case 'utility':
1076
1399
  return 'declarations';
1400
+ // `@utility` bodies mix flat declarations with nested rules
1401
+ // (`&:hover`, `&::-webkit-scrollbar`); `rule` mode does the
1402
+ // declaration-vs-nesting lookahead. (`mixed` would read every line
1403
+ // as a selector and corrupt the block.)
1404
+ case 'utility':
1405
+ return 'rule';
1077
1406
  case 'media':
1078
1407
  case 'supports':
1079
1408
  case 'container':
@@ -2240,53 +2569,84 @@ function registerUtility(atRule, reg) {
2240
2569
  var _atRule$preludeText;
2241
2570
  var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
2242
2571
  if (!name || !atRule.block) return;
2243
- var decls = atRule.block.children.filter(function (c) {
2244
- return c.type === 'declaration';
2245
- }).map(function (d) {
2246
- var _d$rawValue;
2247
- return decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true);
2248
- });
2249
- if (decls.length === 0) return;
2572
+
2573
+ // Flat declarations plus any nested rules (`&:hover`, `&::-webkit-scrollbar`);
2574
+ // the nested `&` is later woven with the utility's own selector by the compiler.
2575
+ var products = toProducts(atRule.block.children);
2576
+ if (products.length === 0) return;
2250
2577
 
2251
2578
  // A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
2252
2579
  if (name.endsWith('-*')) {
2253
2580
  var root = name.slice(0, -2);
2254
2581
  if (root) reg.dynamicRule(root, function (ctx) {
2255
- return resolveDeclarations(decls, ctx);
2582
+ return resolveProducts(products, ctx);
2256
2583
  });
2257
2584
  return;
2258
2585
  }
2259
- reg.rule(name, decls);
2586
+ reg.rule(name, products);
2260
2587
  }
2261
-
2262
- // Applies a functional utility's declaration templates to one atom. `--value()`
2263
- // is required — if it can't resolve, the whole utility is dropped (returns null).
2264
- // `--modifier()` is optional — a declaration using it is skipped when there's no
2265
- // matching modifier, so `text-lg` and `text-lg/7` share one definition.
2266
- function resolveDeclarations(templates, ctx) {
2588
+ function toProducts(children) {
2267
2589
  var out = [];
2268
- var _iterator2 = _createForOfIteratorHelper(templates),
2590
+ var _iterator2 = _createForOfIteratorHelper(children),
2269
2591
  _step2;
2270
2592
  try {
2271
2593
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2272
- var t = _step2.value;
2273
- var withValue = replaceFn(t.value, '--value', function (args) {
2274
- return resolveValue(args, ctx);
2275
- });
2276
- if (withValue === null) return null;
2277
- var withModifier = replaceFn(withValue, '--modifier', function (args) {
2278
- return resolveModifier(args, ctx);
2279
- });
2280
- if (withModifier === null) continue;
2281
- out.push(_objectSpread2(_objectSpread2({}, t), {}, {
2282
- value: withModifier
2283
- }));
2594
+ var c = _step2.value;
2595
+ if (c.type === 'declaration') {
2596
+ var _d$rawValue;
2597
+ var d = c;
2598
+ out.push(decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true));
2599
+ } else if (c.type === 'rule') {
2600
+ var _r$declarations, _r$children, _r$rawSelector;
2601
+ var r = c;
2602
+ // The parser splits a rule's own declarations from its nested rules; a
2603
+ // utility body wants both, declarations first.
2604
+ var kids = [].concat(_toConsumableArray((_r$declarations = r.declarations) !== null && _r$declarations !== void 0 ? _r$declarations : []), _toConsumableArray((_r$children = r.children) !== null && _r$children !== void 0 ? _r$children : []));
2605
+ out.push(rule(((_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : '').trim(), toProducts(kids)));
2606
+ }
2284
2607
  }
2285
2608
  } catch (err) {
2286
2609
  _iterator2.e(err);
2287
2610
  } finally {
2288
2611
  _iterator2.f();
2289
2612
  }
2613
+ return out;
2614
+ }
2615
+
2616
+ // Applies a functional utility's templates to one atom, walking nested rules too.
2617
+ // `--value()` is required — if it can't resolve, the whole utility is dropped
2618
+ // (returns null). `--modifier()` is optional — a declaration using it is skipped
2619
+ // when there's no matching modifier, so `text-lg` and `text-lg/7` share one def.
2620
+ function resolveProducts(templates, ctx) {
2621
+ var out = [];
2622
+ var _iterator3 = _createForOfIteratorHelper(templates),
2623
+ _step3;
2624
+ try {
2625
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2626
+ var t = _step3.value;
2627
+ if (t.kind === 'declaration') {
2628
+ var withValue = replaceFn(t.value, '--value', function (args) {
2629
+ return resolveValue(args, ctx);
2630
+ });
2631
+ if (withValue === null) return null;
2632
+ var withModifier = replaceFn(withValue, '--modifier', function (args) {
2633
+ return resolveModifier(args, ctx);
2634
+ });
2635
+ if (withModifier === null) continue;
2636
+ out.push(_objectSpread2(_objectSpread2({}, t), {}, {
2637
+ value: withModifier
2638
+ }));
2639
+ } else {
2640
+ var inner = resolveProducts(t.nodes, ctx);
2641
+ if (inner === null) return null;
2642
+ out.push(rule(t.selector, inner));
2643
+ }
2644
+ }
2645
+ } catch (err) {
2646
+ _iterator3.e(err);
2647
+ } finally {
2648
+ _iterator3.f();
2649
+ }
2290
2650
  return out.length ? out : null;
2291
2651
  }
2292
2652
  function resolveValue(args, ctx) {
@@ -2394,7 +2754,15 @@ function registerVariant(atRule, reg) {
2394
2754
  var prelude = ((_atRule$preludeText2 = atRule.preludeText) !== null && _atRule$preludeText2 !== void 0 ? _atRule$preludeText2 : '').trim();
2395
2755
  if (!prelude) return;
2396
2756
 
2397
- // `name (condition)` shorthand — the block form isn't supported yet.
2757
+ // Block form: `@custom-variant name { &:hover { @slot } }` — the prelude is just
2758
+ // the name and the block describes the wrapping, marked by `@slot`.
2759
+ if (atRule.block) {
2760
+ var wrap = blockToWrap(atRule.block.children);
2761
+ if (prelude && wrap) reg.variant(prelude, wrap);
2762
+ return;
2763
+ }
2764
+
2765
+ // Shorthand: `@custom-variant name (condition)`.
2398
2766
  var paren = prelude.indexOf('(');
2399
2767
  if (paren === -1 || !prelude.endsWith(')')) return;
2400
2768
  var name = prelude.slice(0, paren).trim();
@@ -2402,6 +2770,43 @@ function registerVariant(atRule, reg) {
2402
2770
  if (!name || !condition) return;
2403
2771
  reg.variant(name, wrapFor(condition));
2404
2772
  }
2773
+
2774
+ // Walk the single path down to `@slot`, collecting the selector (nested rules,
2775
+ // combined by `&` substitution) and/or the wrapping at-rule (`@media`, `@supports`).
2776
+ // Supports one selector level, one at-rule level, or both nested.
2777
+ function blockToWrap(children) {
2778
+ var selector;
2779
+ var at;
2780
+ var node = firstBlockChild(children);
2781
+ while (node) {
2782
+ if (node.type === 'rule') {
2783
+ var _rawSelector, _children;
2784
+ var sel = ((_rawSelector = node.rawSelector) !== null && _rawSelector !== void 0 ? _rawSelector : '').trim();
2785
+ selector = selector ? sel.replace(/&/g, selector) : sel;
2786
+ node = firstBlockChild((_children = node.children) !== null && _children !== void 0 ? _children : []);
2787
+ } else if (node.type === 'atrule') {
2788
+ var _ar$preludeText;
2789
+ var ar = node;
2790
+ if (ar.name === 'slot') break;
2791
+ at = {
2792
+ name: ar.name,
2793
+ params: ((_ar$preludeText = ar.preludeText) !== null && _ar$preludeText !== void 0 ? _ar$preludeText : '').trim()
2794
+ };
2795
+ node = ar.block ? firstBlockChild(ar.block.children) : undefined;
2796
+ } else {
2797
+ node = undefined;
2798
+ }
2799
+ }
2800
+ var wrap = {};
2801
+ if (selector) wrap.selector = selector.includes('&') ? selector : "&".concat(selector);
2802
+ if (at) wrap.atRule = at;
2803
+ return wrap.selector || wrap.atRule ? wrap : null;
2804
+ }
2805
+ function firstBlockChild(children) {
2806
+ return children.find(function (c) {
2807
+ return c.type === 'rule' || c.type === 'atrule';
2808
+ });
2809
+ }
2405
2810
  function wrapFor(condition) {
2406
2811
  if (condition[0] === '@') {
2407
2812
  var cut = condition.search(/[\s(]/);
@@ -2419,6 +2824,10 @@ function wrapFor(condition) {
2419
2824
  };
2420
2825
  }
2421
2826
 
2827
+ // A utility produces declarations on its own selector, and/or nested rules whose
2828
+ // `&` is woven with that selector — the latter is how child-combinator utilities
2829
+ // like `space-x`/`divide-y` reach `& > * + *`.
2830
+
2422
2831
  // A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
2423
2832
  // the rule in an at-rule (`@media`, `@supports`). It may do both.
2424
2833
 
@@ -2449,8 +2858,8 @@ var Registry = /*#__PURE__*/function () {
2449
2858
  }
2450
2859
  return _createClass(Registry, [{
2451
2860
  key: "rule",
2452
- value: function rule(name, declarations) {
2453
- this.rules.set(name, declarations);
2861
+ value: function rule(name, products) {
2862
+ this.rules.set(name, products);
2454
2863
  return this;
2455
2864
  }
2456
2865
  }, {
@@ -2498,111 +2907,6 @@ var Registry = /*#__PURE__*/function () {
2498
2907
  }]);
2499
2908
  }();
2500
2909
 
2501
- // Turns a parsed atom into CSS. Returns null when the utility or any of its
2502
- // variants aren't registered, so an unknown class simply produces nothing.
2503
- function compileAtom(atom, reg) {
2504
- var declarations = declarationsFor(atom, reg);
2505
- if (!declarations || declarations.length === 0) return null;
2506
- if (atom.important) {
2507
- var _iterator = _createForOfIteratorHelper(declarations),
2508
- _step;
2509
- try {
2510
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2511
- var d = _step.value;
2512
- d.important = true;
2513
- }
2514
- } catch (err) {
2515
- _iterator.e(err);
2516
- } finally {
2517
- _iterator.f();
2518
- }
2519
- }
2520
- var selector = '.' + escapeClass(atom.raw);
2521
- var atRules = [];
2522
- var _iterator2 = _createForOfIteratorHelper(atom.variants),
2523
- _step2;
2524
- try {
2525
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2526
- var variant = _step2.value;
2527
- var wrap = resolveVariant(variant, reg);
2528
- if (!wrap) return null;
2529
- if (wrap.selector) selector = substitute(wrap.selector, selector);
2530
- if (wrap.atRule) atRules.push(wrap.atRule);
2531
- }
2532
- } catch (err) {
2533
- _iterator2.e(err);
2534
- } finally {
2535
- _iterator2.f();
2536
- }
2537
- var node = rule(selector, declarations);
2538
- for (var _i = 0, _atRules = atRules; _i < _atRules.length; _i++) {
2539
- var ar = _atRules[_i];
2540
- node = atRule(ar.name, ar.params, [node]);
2541
- }
2542
- return [node];
2543
- }
2544
- function declarationsFor(atom, reg) {
2545
- if (atom.kind === 'arbitrary-property') {
2546
- return [decl(atom.property, atom.value)];
2547
- }
2548
- if (atom.kind === 'static') {
2549
- var decls = reg.getRule(atom.root);
2550
- return decls ? decls.map(function (d) {
2551
- return _objectSpread2({}, d);
2552
- }) : null;
2553
- }
2554
- var handler = reg.getDynamicRule(atom.root);
2555
- if (!handler) return null;
2556
- return handler({
2557
- value: atom.value,
2558
- modifier: atom.modifier,
2559
- negative: atom.negative,
2560
- theme: reg.theme
2561
- });
2562
- }
2563
- function resolveVariant(variant, reg) {
2564
- if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
2565
- if (variant.kind === 'static') return reg.getVariant(variant.root);
2566
- // functional: a null value means it's really a static variant (hover, md, …).
2567
- if (variant.value === null) return reg.getVariant(variant.root);
2568
- var handler = reg.getDynamicVariant(variant.root);
2569
- return handler ? handler(variant.value, variant.modifier) : null;
2570
- }
2571
-
2572
- // `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
2573
- // A bare selector with no `&` is attached to the element.
2574
- function arbitraryVariant(source) {
2575
- if (source[0] === '@') {
2576
- var cut = source.search(/[\s(]/);
2577
- var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
2578
- var params = cut === -1 ? '' : source.slice(cut).trim();
2579
- return {
2580
- atRule: {
2581
- name: name,
2582
- params: params
2583
- }
2584
- };
2585
- }
2586
- var sel = spacesFromUnderscores(source);
2587
- return {
2588
- selector: sel.includes('&') ? sel : "&".concat(sel)
2589
- };
2590
- }
2591
- function spacesFromUnderscores(s) {
2592
- return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
2593
- }
2594
- function substitute(template, current) {
2595
- return template.replace(/&/g, current);
2596
- }
2597
-
2598
- // Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
2599
- // class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
2600
- function escapeClass(name) {
2601
- return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
2602
- return '\\' + c;
2603
- });
2604
- }
2605
-
2606
2910
  var Palettes = {
2607
2911
  "slate": {
2608
2912
  "50": "#f8fafc",
@@ -3077,6 +3381,23 @@ function registerBackgrounds(reg) {
3077
3381
  props(reg, 'background-image', {
3078
3382
  'bg-none': 'none'
3079
3383
  });
3384
+
3385
+ // Form-control colours.
3386
+ reg.dynamicRule('accent', function (_ref2) {
3387
+ var value = _ref2.value,
3388
+ modifier = _ref2.modifier,
3389
+ theme = _ref2.theme;
3390
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];
3391
+ var c = colorValue(value, modifier, theme);
3392
+ return c ? [decl('accent-color', c)] : null;
3393
+ });
3394
+ reg.dynamicRule('caret', function (_ref3) {
3395
+ var value = _ref3.value,
3396
+ modifier = _ref3.modifier,
3397
+ theme = _ref3.theme;
3398
+ var c = colorValue(value, modifier, theme);
3399
+ return c ? [decl('caret-color', c)] : null;
3400
+ });
3080
3401
  }
3081
3402
 
3082
3403
  function registerBorders(reg) {
@@ -3097,6 +3418,8 @@ function registerBorders(reg) {
3097
3418
  hidden: 'hidden',
3098
3419
  none: 'none'
3099
3420
  });
3421
+ divide(reg);
3422
+ ring(reg);
3100
3423
  rounded(reg, 'rounded', ['']);
3101
3424
  rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
3102
3425
  rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
@@ -3176,14 +3499,67 @@ function outline(reg) {
3176
3499
  });
3177
3500
  }
3178
3501
 
3502
+ // Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
3503
+ // set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
3504
+ // edge via a `--flx-divide-*-reverse` toggle.
3505
+ var BETWEEN$1 = '& > :not([hidden]) ~ :not([hidden])';
3506
+ function divide(reg) {
3507
+ divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
3508
+ divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
3509
+ reg.dynamicRule('divide', function (_ref4) {
3510
+ var value = _ref4.value,
3511
+ modifier = _ref4.modifier,
3512
+ theme = _ref4.theme;
3513
+ if (value === null) return null;
3514
+ var style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
3515
+ if (style) return [rule(BETWEEN$1, [decl('border-style', style)])];
3516
+ var color = colorFor(value, modifier, theme);
3517
+ return color ? [rule(BETWEEN$1, [decl('border-color', color)])] : null;
3518
+ });
3519
+ }
3520
+ var DIVIDE_STYLES = {
3521
+ solid: 'solid',
3522
+ dashed: 'dashed',
3523
+ dotted: 'dotted',
3524
+ "double": 'double',
3525
+ none: 'none'
3526
+ };
3527
+ function divideWidth(reg, axis, reverseProp, mainProp) {
3528
+ var flag = "--flx-divide-".concat(axis, "-reverse");
3529
+ reg.dynamicRule("divide-".concat(axis), function (_ref5) {
3530
+ var value = _ref5.value;
3531
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') return [rule(BETWEEN$1, [decl(flag, '1')])];
3532
+ var w = widthValue(value, '1px');
3533
+ if (w === null) return null;
3534
+ return [rule(BETWEEN$1, [decl(flag, '0'), decl(reverseProp, "calc(".concat(w, " * var(").concat(flag, "))")), decl(mainProp, "calc(".concat(w, " * calc(1 - var(").concat(flag, ")))"))])];
3535
+ });
3536
+ }
3537
+
3538
+ // A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
3539
+ // (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
3540
+ function ring(reg) {
3541
+ reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
3542
+ reg.dynamicRule('ring', function (_ref6) {
3543
+ var value = _ref6.value,
3544
+ modifier = _ref6.modifier,
3545
+ theme = _ref6.theme;
3546
+ var w = value === null ? '3px' : widthValue(value, null);
3547
+ if (w !== null) {
3548
+ return [decl('--flx-ring-shadow', "var(--flx-ring-inset) 0 0 0 calc(".concat(w, " + var(--flx-ring-offset-width)) var(--flx-ring-color)")), decl('box-shadow', 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)')];
3549
+ }
3550
+ var color = colorFor(value, modifier, theme);
3551
+ return color ? [decl('--flx-ring-color', color)] : null;
3552
+ });
3553
+ }
3554
+
3179
3555
  function registerEffects(reg) {
3180
3556
  reg.dynamicRule('shadow', function (_ref) {
3181
3557
  var value = _ref.value,
3182
3558
  theme = _ref.theme;
3183
- if (value === null) return wrap(theme.resolve('shadow', 'DEFAULT'));
3559
+ if (value === null) return wrap$1(theme.resolve('shadow', 'DEFAULT'));
3184
3560
  if (value.kind === 'arbitrary') return [decl('box-shadow', value.value)];
3185
3561
  if (value.value === 'none') return [decl('box-shadow', 'none')];
3186
- return wrap(theme.resolve('shadow', value.value));
3562
+ return wrap$1(theme.resolve('shadow', value.value));
3187
3563
  });
3188
3564
  reg.dynamicRule('opacity', function (_ref2) {
3189
3565
  var value = _ref2.value;
@@ -3227,7 +3603,7 @@ function registerEffects(reg) {
3227
3603
  auto: 'auto'
3228
3604
  });
3229
3605
  }
3230
- function wrap(shadow) {
3606
+ function wrap$1(shadow) {
3231
3607
  return shadow ? [decl('box-shadow', shadow)] : null;
3232
3608
  }
3233
3609
  var BLEND = {
@@ -3249,6 +3625,131 @@ var BLEND = {
3249
3625
  luminosity: 'luminosity'
3250
3626
  };
3251
3627
 
3628
+ // Same composition trick as transforms: each utility sets a `--flx-*` var and
3629
+ // re-declares the composed `filter`, with identity defaults so any one is valid
3630
+ // alone and several compose (`blur-sm grayscale`).
3631
+ var FILTER = 'blur(var(--flx-blur,0)) brightness(var(--flx-brightness,1)) contrast(var(--flx-contrast,1)) ' + 'grayscale(var(--flx-grayscale,0)) hue-rotate(var(--flx-hue-rotate,0)) invert(var(--flx-invert,0)) ' + 'saturate(var(--flx-saturate,1)) sepia(var(--flx-sepia,0)) drop-shadow(var(--flx-drop-shadow,0 0 #0000))';
3632
+ var BACKDROP = 'blur(var(--flx-backdrop-blur,0)) brightness(var(--flx-backdrop-brightness,1)) ' + 'contrast(var(--flx-backdrop-contrast,1)) grayscale(var(--flx-backdrop-grayscale,0)) ' + 'opacity(var(--flx-backdrop-opacity,1)) saturate(var(--flx-backdrop-saturate,1))';
3633
+ var compose$1 = function compose(prop, val) {
3634
+ return [decl(prop, val), decl('filter', FILTER)];
3635
+ };
3636
+ var backdrop = function backdrop(prop, val) {
3637
+ return [decl(prop, val), decl('backdrop-filter', BACKDROP)];
3638
+ };
3639
+ function registerFilters(reg) {
3640
+ reg.rule('filter-none', [decl('filter', 'none')]);
3641
+ reg.rule('backdrop-filter-none', [decl('backdrop-filter', 'none')]);
3642
+ reg.dynamicRule('blur', function (_ref) {
3643
+ var value = _ref.value;
3644
+ return v(compose$1, '--flx-blur', named$1(value, BLUR));
3645
+ });
3646
+ reg.dynamicRule('brightness', function (_ref2) {
3647
+ var value = _ref2.value;
3648
+ return v(compose$1, '--flx-brightness', ratio(value));
3649
+ });
3650
+ reg.dynamicRule('contrast', function (_ref3) {
3651
+ var value = _ref3.value;
3652
+ return v(compose$1, '--flx-contrast', ratio(value));
3653
+ });
3654
+ reg.dynamicRule('saturate', function (_ref4) {
3655
+ var value = _ref4.value;
3656
+ return v(compose$1, '--flx-saturate', ratio(value));
3657
+ });
3658
+ reg.dynamicRule('grayscale', function (_ref5) {
3659
+ var value = _ref5.value;
3660
+ return v(compose$1, '--flx-grayscale', pct(value));
3661
+ });
3662
+ reg.dynamicRule('invert', function (_ref6) {
3663
+ var value = _ref6.value;
3664
+ return v(compose$1, '--flx-invert', pct(value));
3665
+ });
3666
+ reg.dynamicRule('sepia', function (_ref7) {
3667
+ var value = _ref7.value;
3668
+ return v(compose$1, '--flx-sepia', pct(value));
3669
+ });
3670
+ reg.dynamicRule('hue-rotate', function (_ref8) {
3671
+ var value = _ref8.value,
3672
+ negative = _ref8.negative;
3673
+ return v(compose$1, '--flx-hue-rotate', deg(value, negative));
3674
+ });
3675
+ reg.dynamicRule('drop-shadow', function (_ref9) {
3676
+ var value = _ref9.value;
3677
+ return v(compose$1, '--flx-drop-shadow', named$1(value, DROP_SHADOW));
3678
+ });
3679
+ reg.dynamicRule('backdrop-blur', function (_ref0) {
3680
+ var value = _ref0.value;
3681
+ return v(backdrop, '--flx-backdrop-blur', named$1(value, BLUR));
3682
+ });
3683
+ reg.dynamicRule('backdrop-brightness', function (_ref1) {
3684
+ var value = _ref1.value;
3685
+ return v(backdrop, '--flx-backdrop-brightness', ratio(value));
3686
+ });
3687
+ reg.dynamicRule('backdrop-contrast', function (_ref10) {
3688
+ var value = _ref10.value;
3689
+ return v(backdrop, '--flx-backdrop-contrast', ratio(value));
3690
+ });
3691
+ reg.dynamicRule('backdrop-saturate', function (_ref11) {
3692
+ var value = _ref11.value;
3693
+ return v(backdrop, '--flx-backdrop-saturate', ratio(value));
3694
+ });
3695
+ reg.dynamicRule('backdrop-grayscale', function (_ref12) {
3696
+ var value = _ref12.value;
3697
+ return v(backdrop, '--flx-backdrop-grayscale', pct(value));
3698
+ });
3699
+ reg.dynamicRule('backdrop-opacity', function (_ref13) {
3700
+ var value = _ref13.value;
3701
+ return v(backdrop, '--flx-backdrop-opacity', ratio(value));
3702
+ });
3703
+ }
3704
+ function v(build, prop, val) {
3705
+ return val === null ? null : build(prop, val);
3706
+ }
3707
+
3708
+ /** number → decimal ratio (brightness-50 → 0.5); arbitrary passes through. */
3709
+ function ratio(value) {
3710
+ if (!value) return null;
3711
+ if (value.kind === 'arbitrary') return value.value;
3712
+ return /^\d+$/.test(value.value) ? "".concat(+value.value / 100) : null;
3713
+ }
3714
+
3715
+ /** bare → 100%, `0` → 0%, number → number% (grayscale/invert/sepia). */
3716
+ function pct(value) {
3717
+ if (!value) return '100%';
3718
+ if (value.kind === 'arbitrary') return value.value;
3719
+ return /^\d+$/.test(value.value) ? "".concat(value.value, "%") : null;
3720
+ }
3721
+ function deg(value, negative) {
3722
+ if (!value) return null;
3723
+ if (value.kind === 'arbitrary') return negative ? "calc(".concat(value.value, " * -1)") : value.value;
3724
+ return /^\d+$/.test(value.value) ? "".concat(negative ? '-' : '').concat(value.value, "deg") : null;
3725
+ }
3726
+ function named$1(value, map) {
3727
+ var _map$, _map$value$value;
3728
+ if (!value) return (_map$ = map['']) !== null && _map$ !== void 0 ? _map$ : null;
3729
+ if (value.kind === 'arbitrary') return value.value;
3730
+ return (_map$value$value = map[value.value]) !== null && _map$value$value !== void 0 ? _map$value$value : null;
3731
+ }
3732
+ var BLUR = {
3733
+ '': '8px',
3734
+ none: '0',
3735
+ xs: '2px',
3736
+ sm: '4px',
3737
+ md: '12px',
3738
+ lg: '16px',
3739
+ xl: '24px',
3740
+ '2xl': '40px',
3741
+ '3xl': '64px'
3742
+ };
3743
+ var DROP_SHADOW = {
3744
+ '': '0 1px 2px rgb(0 0 0 / 0.1)',
3745
+ none: '0 0 #0000',
3746
+ sm: '0 1px 1px rgb(0 0 0 / 0.05)',
3747
+ md: '0 4px 3px rgb(0 0 0 / 0.07)',
3748
+ lg: '0 10px 8px rgb(0 0 0 / 0.04)',
3749
+ xl: '0 20px 13px rgb(0 0 0 / 0.03)',
3750
+ '2xl': '0 25px 25px rgb(0 0 0 / 0.15)'
3751
+ };
3752
+
3252
3753
  function registerFlexGrid(reg) {
3253
3754
  props(reg, 'flex-direction', {
3254
3755
  'flex-row': 'row',
@@ -3411,6 +3912,44 @@ function line(reg, root, property) {
3411
3912
  });
3412
3913
  }
3413
3914
 
3915
+ function registerGradients(reg) {
3916
+ keywords(reg, 'bg-gradient-to', 'background-image', {
3917
+ t: 'linear-gradient(to top, var(--flx-gradient-stops))',
3918
+ tr: 'linear-gradient(to top right, var(--flx-gradient-stops))',
3919
+ r: 'linear-gradient(to right, var(--flx-gradient-stops))',
3920
+ br: 'linear-gradient(to bottom right, var(--flx-gradient-stops))',
3921
+ b: 'linear-gradient(to bottom, var(--flx-gradient-stops))',
3922
+ bl: 'linear-gradient(to bottom left, var(--flx-gradient-stops))',
3923
+ l: 'linear-gradient(to left, var(--flx-gradient-stops))',
3924
+ tl: 'linear-gradient(to top left, var(--flx-gradient-stops))'
3925
+ });
3926
+
3927
+ // Color stops build up `--flx-gradient-stops`. `from` seeds a two-stop list that
3928
+ // `to` fills in; `via` promotes it to three stops. A bare `to` with no `from`
3929
+ // still works because the from stop defaults to transparent.
3930
+ reg.dynamicRule('from', function (_ref) {
3931
+ var value = _ref.value,
3932
+ modifier = _ref.modifier,
3933
+ theme = _ref.theme;
3934
+ var color = colorValue(value, modifier, theme);
3935
+ return color ? [decl('--flx-gradient-from', color), decl('--flx-gradient-stops', 'var(--flx-gradient-from), var(--flx-gradient-to, transparent)')] : null;
3936
+ });
3937
+ reg.dynamicRule('via', function (_ref2) {
3938
+ var value = _ref2.value,
3939
+ modifier = _ref2.modifier,
3940
+ theme = _ref2.theme;
3941
+ var color = colorValue(value, modifier, theme);
3942
+ return color ? [decl('--flx-gradient-via', color), decl('--flx-gradient-stops', 'var(--flx-gradient-from, transparent), var(--flx-gradient-via), var(--flx-gradient-to, transparent)')] : null;
3943
+ });
3944
+ reg.dynamicRule('to', function (_ref3) {
3945
+ var value = _ref3.value,
3946
+ modifier = _ref3.modifier,
3947
+ theme = _ref3.theme;
3948
+ var color = colorValue(value, modifier, theme);
3949
+ return color ? [decl('--flx-gradient-to', color)] : null;
3950
+ });
3951
+ }
3952
+
3414
3953
  function registerLayout(reg) {
3415
3954
  props(reg, 'display', {
3416
3955
  block: 'block',
@@ -3497,6 +4036,36 @@ function registerLayout(reg) {
3497
4036
  if (value.value === 'auto') return [decl('z-index', 'auto')];
3498
4037
  return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
3499
4038
  });
4039
+ reg.dynamicRule('columns', function (_ref2) {
4040
+ var value = _ref2.value;
4041
+ if (!value) return null;
4042
+ if (value.kind === 'arbitrary') return [decl('columns', value.value)];
4043
+ if (value.value === 'auto' || /^\d+$/.test(value.value)) return [decl('columns', value.value)];
4044
+ return null;
4045
+ });
4046
+
4047
+ // Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
4048
+ // (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
4049
+ props(reg, 'scroll-snap-type', {
4050
+ 'snap-none': 'none',
4051
+ 'snap-x': 'x var(--flx-scroll-snap-strictness)',
4052
+ 'snap-y': 'y var(--flx-scroll-snap-strictness)',
4053
+ 'snap-both': 'both var(--flx-scroll-snap-strictness)'
4054
+ });
4055
+ props(reg, '--flx-scroll-snap-strictness', {
4056
+ 'snap-mandatory': 'mandatory',
4057
+ 'snap-proximity': 'proximity'
4058
+ });
4059
+ props(reg, 'scroll-snap-align', {
4060
+ 'snap-start': 'start',
4061
+ 'snap-end': 'end',
4062
+ 'snap-center': 'center',
4063
+ 'snap-align-none': 'none'
4064
+ });
4065
+ props(reg, 'scroll-snap-stop', {
4066
+ 'snap-normal': 'normal',
4067
+ 'snap-always': 'always'
4068
+ });
3500
4069
  }
3501
4070
  var OVERFLOW = {
3502
4071
  auto: 'auto',
@@ -3506,11 +4075,11 @@ var OVERFLOW = {
3506
4075
  scroll: 'scroll'
3507
4076
  };
3508
4077
  function inset(reg, root, props) {
3509
- reg.dynamicRule(root, function (_ref2) {
3510
- var value = _ref2.value,
3511
- negative = _ref2.negative,
3512
- modifier = _ref2.modifier,
3513
- theme = _ref2.theme;
4078
+ reg.dynamicRule(root, function (_ref3) {
4079
+ var value = _ref3.value,
4080
+ negative = _ref3.negative,
4081
+ modifier = _ref3.modifier,
4082
+ theme = _ref3.theme;
3514
4083
  if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3515
4084
  return decl(p, 'auto');
3516
4085
  });
@@ -3560,6 +4129,29 @@ function registerSpacing(reg) {
3560
4129
  props = _Object$entries$_i[1];
3561
4130
  spacing(reg, root, props, root[0] === 'm');
3562
4131
  }
4132
+ spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
4133
+ spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
4134
+ }
4135
+
4136
+ // Only the space *between* siblings, applied to every child after the first via
4137
+ // the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
4138
+ // margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
4139
+ var BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
4140
+ function spaceBetween(reg, axis, startProp, endProp) {
4141
+ var flag = "--flx-space-".concat(axis, "-reverse");
4142
+ reg.dynamicRule("space-".concat(axis), function (_ref) {
4143
+ var value = _ref.value,
4144
+ negative = _ref.negative,
4145
+ theme = _ref.theme;
4146
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
4147
+ return [rule(BETWEEN, [decl(flag, '1')])];
4148
+ }
4149
+ var v = sizeValue(value, theme, {
4150
+ negative: negative
4151
+ });
4152
+ if (!v) return null;
4153
+ return [rule(BETWEEN, [decl(flag, '0'), decl(startProp, "calc(".concat(v, " * calc(1 - var(").concat(flag, ")))")), decl(endProp, "calc(".concat(v, " * var(").concat(flag, "))"))])];
4154
+ });
3563
4155
  }
3564
4156
 
3565
4157
  // `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
@@ -3587,10 +4179,10 @@ var SPACING = {
3587
4179
  'scroll-p': ['scroll-padding']
3588
4180
  };
3589
4181
  function spacing(reg, root, props, allowAuto) {
3590
- reg.dynamicRule(root, function (_ref) {
3591
- var value = _ref.value,
3592
- negative = _ref.negative,
3593
- theme = _ref.theme;
4182
+ reg.dynamicRule(root, function (_ref2) {
4183
+ var value = _ref2.value,
4184
+ negative = _ref2.negative,
4185
+ theme = _ref2.theme;
3594
4186
  if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3595
4187
  return decl(p, 'auto');
3596
4188
  });
@@ -3603,6 +4195,154 @@ function spacing(reg, root, props, allowAuto) {
3603
4195
  });
3604
4196
  }
3605
4197
 
4198
+ // Each transform utility sets its own `--flx-*` var and re-declares the composed
4199
+ // `transform`. The vars carry identity defaults (0 / 1) as fallbacks, so any single
4200
+ // utility is valid on its own and several compose (`rotate-45 scale-90`) without an
4201
+ // ordering dependency or a shared base rule.
4202
+ var REST = 'rotate(var(--flx-rotate,0)) skewX(var(--flx-skew-x,0)) skewY(var(--flx-skew-y,0)) ' + 'scaleX(var(--flx-scale-x,1)) scaleY(var(--flx-scale-y,1))';
4203
+ var TRANSFORM = "translate(var(--flx-translate-x,0),var(--flx-translate-y,0)) ".concat(REST);
4204
+ var TRANSFORM_GPU = "translate3d(var(--flx-translate-x,0),var(--flx-translate-y,0),0) ".concat(REST);
4205
+ var compose = function compose(prop, val) {
4206
+ return [decl(prop, val), decl('transform', TRANSFORM)];
4207
+ };
4208
+ function registerTransforms(reg) {
4209
+ var rotate = function rotate(v, neg) {
4210
+ return angle(v, neg);
4211
+ };
4212
+ reg.dynamicRule('rotate', function (_ref) {
4213
+ var value = _ref.value,
4214
+ negative = _ref.negative;
4215
+ var v = rotate(value, negative);
4216
+ return v ? compose('--flx-rotate', v) : null;
4217
+ });
4218
+ reg.dynamicRule('skew-x', function (_ref2) {
4219
+ var value = _ref2.value,
4220
+ negative = _ref2.negative;
4221
+ return wrap('--flx-skew-x', angle(value, negative));
4222
+ });
4223
+ reg.dynamicRule('skew-y', function (_ref3) {
4224
+ var value = _ref3.value,
4225
+ negative = _ref3.negative;
4226
+ return wrap('--flx-skew-y', angle(value, negative));
4227
+ });
4228
+ reg.dynamicRule('scale', function (_ref4) {
4229
+ var value = _ref4.value,
4230
+ negative = _ref4.negative;
4231
+ var v = scaleVal(value, negative);
4232
+ return v ? [decl('--flx-scale-x', v), decl('--flx-scale-y', v), decl('transform', TRANSFORM)] : null;
4233
+ });
4234
+ reg.dynamicRule('scale-x', function (_ref5) {
4235
+ var value = _ref5.value,
4236
+ negative = _ref5.negative;
4237
+ return wrap('--flx-scale-x', scaleVal(value, negative));
4238
+ });
4239
+ reg.dynamicRule('scale-y', function (_ref6) {
4240
+ var value = _ref6.value,
4241
+ negative = _ref6.negative;
4242
+ return wrap('--flx-scale-y', scaleVal(value, negative));
4243
+ });
4244
+ reg.dynamicRule('translate-x', function (_ref7) {
4245
+ var value = _ref7.value,
4246
+ negative = _ref7.negative,
4247
+ theme = _ref7.theme;
4248
+ return wrap('--flx-translate-x', sizeValue(value, theme, {
4249
+ negative: negative
4250
+ }));
4251
+ });
4252
+ reg.dynamicRule('translate-y', function (_ref8) {
4253
+ var value = _ref8.value,
4254
+ negative = _ref8.negative,
4255
+ theme = _ref8.theme;
4256
+ return wrap('--flx-translate-y', sizeValue(value, theme, {
4257
+ negative: negative
4258
+ }));
4259
+ });
4260
+ reg.rule('transform-none', [decl('transform', 'none')]);
4261
+ reg.rule('transform-gpu', [decl('transform', TRANSFORM_GPU)]);
4262
+ reg.rule('transform-cpu', [decl('transform', TRANSFORM)]);
4263
+ keywords(reg, 'origin', 'transform-origin', {
4264
+ center: 'center',
4265
+ top: 'top',
4266
+ 'top-right': 'top right',
4267
+ right: 'right',
4268
+ 'bottom-right': 'bottom right',
4269
+ bottom: 'bottom',
4270
+ 'bottom-left': 'bottom left',
4271
+ left: 'left',
4272
+ 'top-left': 'top left'
4273
+ });
4274
+ }
4275
+ function wrap(prop, val) {
4276
+ return val ? compose(prop, val) : null;
4277
+ }
4278
+ function angle(value, negative) {
4279
+ if (!value) return null;
4280
+ if (value.kind === 'arbitrary') return negative ? "calc(".concat(value.value, " * -1)") : value.value;
4281
+ return "".concat(negative ? '-' : '').concat(value.value, "deg");
4282
+ }
4283
+ function scaleVal(value, negative) {
4284
+ if (!value) return null;
4285
+ if (value.kind === 'arbitrary') return negative ? "calc(".concat(value.value, " * -1)") : value.value;
4286
+ if (!/^\d+$/.test(value.value)) return null;
4287
+ var n = (negative ? -1 : 1) * (+value.value / 100);
4288
+ return "".concat(n);
4289
+ }
4290
+
4291
+ var DEFAULT_EASE = 'cubic-bezier(0.4, 0, 0.2, 1)';
4292
+ function registerTransitions(reg) {
4293
+ // `transition` (+ named property groups) also seeds a sensible default duration
4294
+ // and timing function, matching what a bare `transition` is expected to animate.
4295
+ reg.dynamicRule('transition', function (_ref) {
4296
+ var _PROPERTY_GROUPS$valu;
4297
+ var value = _ref.value;
4298
+ var property = value === null ? 'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter' : (_PROPERTY_GROUPS$valu = PROPERTY_GROUPS[value.value]) !== null && _PROPERTY_GROUPS$valu !== void 0 ? _PROPERTY_GROUPS$valu : value.kind === 'arbitrary' ? value.value : null;
4299
+ if (property === null) return null;
4300
+ if (property === 'none') return [decl('transition-property', 'none')];
4301
+ return [decl('transition-property', property), decl('transition-timing-function', DEFAULT_EASE), decl('transition-duration', '150ms')];
4302
+ });
4303
+ reg.dynamicRule('duration', function (_ref2) {
4304
+ var value = _ref2.value;
4305
+ return time('transition-duration', value);
4306
+ });
4307
+ reg.dynamicRule('delay', function (_ref3) {
4308
+ var value = _ref3.value;
4309
+ return time('transition-delay', value);
4310
+ });
4311
+ keywords(reg, 'ease', 'transition-timing-function', {
4312
+ linear: 'linear',
4313
+ "in": 'cubic-bezier(0.4, 0, 1, 1)',
4314
+ out: 'cubic-bezier(0, 0, 0.2, 1)',
4315
+ 'in-out': DEFAULT_EASE
4316
+ });
4317
+ keywords(reg, 'animate', 'animation', {
4318
+ none: 'none',
4319
+ spin: 'spin 1s linear infinite',
4320
+ ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
4321
+ pulse: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
4322
+ bounce: 'bounce 1s infinite'
4323
+ });
4324
+ keywords(reg, 'will-change', 'will-change', {
4325
+ auto: 'auto',
4326
+ scroll: 'scroll-position',
4327
+ contents: 'contents',
4328
+ transform: 'transform'
4329
+ });
4330
+ }
4331
+ var PROPERTY_GROUPS = {
4332
+ none: 'none',
4333
+ all: 'all',
4334
+ colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
4335
+ opacity: 'opacity',
4336
+ shadow: 'box-shadow',
4337
+ transform: 'transform'
4338
+ };
4339
+ function time(prop, value) {
4340
+ if (!value) return null;
4341
+ if (value.kind === 'arbitrary') return [decl(prop, value.value)];
4342
+ if (/^\d+$/.test(value.value)) return [decl(prop, "".concat(value.value, "ms"))];
4343
+ return null;
4344
+ }
4345
+
3606
4346
  function registerTypography(reg) {
3607
4347
  // `text-` is overloaded: a colour token, a font-size token, or an arbitrary of
3608
4348
  // either kind. Alignment/overflow keywords (`text-center`, `text-ellipsis`) are
@@ -3696,6 +4436,12 @@ function registerTypography(reg) {
3696
4436
  var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
3697
4437
  return t ? [decl('letter-spacing', t)] : null;
3698
4438
  });
4439
+ reg.dynamicRule('content', function (_ref4) {
4440
+ var value = _ref4.value;
4441
+ if (!value) return null;
4442
+ if (value.kind === 'arbitrary') return [decl('content', value.value)];
4443
+ return value.value === 'none' ? [decl('content', 'none')] : null;
4444
+ });
3699
4445
  }
3700
4446
  var WEIGHTS = {
3701
4447
  thin: '100',
@@ -3744,6 +4490,10 @@ function registerUtilities(reg) {
3744
4490
  registerBackgrounds(reg);
3745
4491
  registerBorders(reg);
3746
4492
  registerEffects(reg);
4493
+ registerTransforms(reg);
4494
+ registerTransitions(reg);
4495
+ registerFilters(reg);
4496
+ registerGradients(reg);
3747
4497
  }
3748
4498
 
3749
4499
  function registerVariants(reg) {
@@ -3780,16 +4530,19 @@ function registerVariants(reg) {
3780
4530
  reg.variant('ltr', {
3781
4531
  selector: '&:where([dir="ltr"], [dir="ltr"] *)'
3782
4532
  });
3783
- for (var _i4 = 0, _arr = ['sm', 'md', 'lg', 'xl', '2xl']; _i4 < _arr.length; _i4++) {
3784
- var bp = _arr[_i4];
3785
- var min = reg.theme.get("--breakpoint-".concat(bp));
3786
- if (min) reg.variant(bp, {
3787
- atRule: {
3788
- name: 'media',
3789
- params: "(min-width: ".concat(min, ")")
3790
- }
3791
- });
3792
- }
4533
+ reg.variant('*', {
4534
+ selector: '& > *'
4535
+ }); // direct children
4536
+ reg.variant('**', {
4537
+ selector: '& *'
4538
+ }); // all descendants
4539
+ reg.variant('open', {
4540
+ selector: '&:is([open], :open)'
4541
+ });
4542
+ reg.variant('inert', {
4543
+ selector: '&:is([inert], [inert] *)'
4544
+ });
4545
+ registerBreakpointVariants(reg);
3793
4546
 
3794
4547
  // `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
3795
4548
  // takes the width verbatim. `max-*` overrides the `max-w`/`max-h` utilities here
@@ -3806,11 +4559,11 @@ function registerVariants(reg) {
3806
4559
  reg.dynamicVariant('max', function (v) {
3807
4560
  return mediaWidth('max-width', width(v));
3808
4561
  });
3809
- reg.dynamicVariant('group', function (v) {
3810
- return relational(v, '.group', ' &');
4562
+ reg.dynamicVariant('group', function (v, m) {
4563
+ return relational(v, m, '.group', ' &');
3811
4564
  });
3812
- reg.dynamicVariant('peer', function (v) {
3813
- return relational(v, '.peer', ' ~ &');
4565
+ reg.dynamicVariant('peer', function (v, m) {
4566
+ return relational(v, m, '.peer', ' ~ &');
3814
4567
  });
3815
4568
  reg.dynamicVariant('data', function (v) {
3816
4569
  return named(v) ? {
@@ -3828,9 +4581,7 @@ function registerVariants(reg) {
3828
4581
  } : null;
3829
4582
  });
3830
4583
  reg.dynamicVariant('not', function (v) {
3831
- return named(v) ? {
3832
- selector: "&:not(".concat(named(v), ")")
3833
- } : null;
4584
+ return notVariant(reg, v);
3834
4585
  });
3835
4586
  reg.dynamicVariant('supports', function (v) {
3836
4587
  return named(v) ? {
@@ -3841,6 +4592,23 @@ function registerVariants(reg) {
3841
4592
  } : null;
3842
4593
  });
3843
4594
  }
4595
+
4596
+ // The named breakpoints (`sm:`/`md:`/…) are static variants, so their media params
4597
+ // bake the theme value at registration. A `@theme { --breakpoint-md: … }` override
4598
+ // loaded later wouldn't reach them — so compile() re-runs this after loadTheme to
4599
+ // pick up overrides. (The dynamic `min-*`/`max-*` already resolve at apply time.)
4600
+ function registerBreakpointVariants(reg) {
4601
+ for (var _i4 = 0, _arr = ['sm', 'md', 'lg', 'xl', '2xl']; _i4 < _arr.length; _i4++) {
4602
+ var bp = _arr[_i4];
4603
+ var min = reg.theme.get("--breakpoint-".concat(bp));
4604
+ if (min) reg.variant(bp, {
4605
+ atRule: {
4606
+ name: 'media',
4607
+ params: "(min-width: ".concat(min, ")")
4608
+ }
4609
+ });
4610
+ }
4611
+ }
3844
4612
  function mediaWidth(feature, value) {
3845
4613
  return value ? {
3846
4614
  atRule: {
@@ -3903,16 +4671,34 @@ function named(v) {
3903
4671
  }
3904
4672
 
3905
4673
  // `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
3906
- // is a pseudo-class, an arbitrary one is a raw selector fragment.
3907
- function relational(v, base, tail) {
4674
+ // is a pseudo-class, an arbitrary one is a raw selector fragment. A `/name`
4675
+ // modifier scopes to a named group/peer (`group-hover/item` → `.group\/item:hover`).
4676
+ function relational(v, m, base, tail) {
3908
4677
  var value = named(v);
3909
4678
  if (!value) return null;
3910
4679
  var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
4680
+ var scope = m ? "".concat(base, "\\/").concat(m.value) : base;
3911
4681
  return {
3912
- selector: "".concat(base).concat(cond).concat(tail)
4682
+ selector: "".concat(scope).concat(cond).concat(tail)
3913
4683
  };
3914
4684
  }
3915
4685
 
4686
+ // `not-hover` → `&:not(:hover)`, `not-first` → `&:not(:first-child)`: resolve the
4687
+ // inner variant's pseudo, so the selector is valid (not the literal name). Only
4688
+ // simple pseudo variants compose; `not-[…]` takes an arbitrary selector.
4689
+ function notVariant(reg, v) {
4690
+ var _reg$getVariant;
4691
+ var value = named(v);
4692
+ if (!value) return null;
4693
+ if (v.kind === 'arbitrary') return {
4694
+ selector: "&:not(".concat(value, ")")
4695
+ };
4696
+ var frag = (_reg$getVariant = reg.getVariant(value)) === null || _reg$getVariant === void 0 || (_reg$getVariant = _reg$getVariant.selector) === null || _reg$getVariant === void 0 ? void 0 : _reg$getVariant.replace(/^&/, '').trim();
4697
+ return frag && frag.startsWith(':') ? {
4698
+ selector: "&:not(".concat(frag, ")")
4699
+ } : null;
4700
+ }
4701
+
3916
4702
  // The batteries-included registry: the default token theme plus the utility
3917
4703
  // families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
3918
4704
  // build a bare `new Registry(theme)` and register their own.
@@ -3940,13 +4726,26 @@ function scanAtoms(source) {
3940
4726
  continue;
3941
4727
  }
3942
4728
  var j = i;
3943
- var depth = 0;
4729
+ var bracket = 0;
4730
+ var paren = 0;
3944
4731
  while (j < n) {
3945
4732
  var c = source[j];
3946
- if (c === '[') depth++;else if (c === ']') {
3947
- if (depth === 0) break;
3948
- depth--;
3949
- } else if (depth === 0 && BOUNDARY.has(c)) break;
4733
+ if (c === '[') {
4734
+ bracket++;
4735
+ } else if (c === ']') {
4736
+ if (bracket === 0) break;
4737
+ bracket--;
4738
+ } else if (bracket > 0) ; else if (c === '(') {
4739
+ // Keep a shorthand paren whole (`bg-(--brand)`, `text-(length:--x)`), but
4740
+ // treat a plain function call (`clsx(…)`) as a boundary so its args scan.
4741
+ if (paren === 0 && !isShorthandParen(source, j)) break;
4742
+ paren++;
4743
+ } else if (c === ')') {
4744
+ if (paren === 0) break;
4745
+ paren--;
4746
+ } else if (paren === 0 && BOUNDARY.has(c)) {
4747
+ break;
4748
+ }
3950
4749
  j++;
3951
4750
  }
3952
4751
  add(found, source.slice(i, j));
@@ -3954,6 +4753,15 @@ function scanAtoms(source) {
3954
4753
  }
3955
4754
  return _toConsumableArray(found);
3956
4755
  }
4756
+
4757
+ // A `(` opens a class shorthand when it holds a CSS var (`(--brand)`) or a typed
4758
+ // value (`(length:--x)`) — otherwise it's a function call and ends the token.
4759
+ function isShorthandParen(s, open) {
4760
+ if (s[open + 1] === '-' && s[open + 2] === '-') return true;
4761
+ var k = open + 1;
4762
+ while (k < s.length && /[a-zA-Z-]/.test(s[k])) k++;
4763
+ return k > open + 1 && s[k] === ':';
4764
+ }
3957
4765
  function add(found, token) {
3958
4766
  // Trailing sentence/markup punctuation is never part of a class.
3959
4767
  var cleaned = token.replace(/[.,;:]+$/, '');
@@ -4206,10 +5014,14 @@ var MARKER = 'fluixi';
4206
5014
  // directives are consumed, and an `@fluixi;` marker is replaced by the generated
4207
5015
  // token `:root` + utilities. With no marker the generated block is appended.
4208
5016
  function transform(input) {
4209
- var _options$registry, _options$classes, _options$from, _options$sources;
5017
+ var _options$registry, _options$classes, _options$from, _options$resetFrom, _options$sources;
4210
5018
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5019
+ var started = performance.now();
4211
5020
  var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
4212
- loadTheme(input, reg.theme);
5021
+ if (options.theme) loadTheme(options.theme, reg.theme);
5022
+ loadTheme(input, reg.theme); // the input's own @theme overrides the base
5023
+ registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides
5024
+ if (options.theme) loadDirectives(options.theme, reg);
4213
5025
  loadDirectives(input, reg);
4214
5026
  var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4215
5027
  var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
@@ -4311,7 +5123,8 @@ function transform(input) {
4311
5123
  var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
4312
5124
  var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
4313
5125
  if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
4314
- nodes.push(raw(input.slice(start.offset, end.offset), {
5126
+ var text = expandApply(input.slice(start.offset, end.offset), reg);
5127
+ nodes.push(raw(text, {
4315
5128
  source: from,
4316
5129
  line: start.line,
4317
5130
  column: Math.max(0, start.column - 1)
@@ -4324,30 +5137,48 @@ function transform(input) {
4324
5137
  _iterator5.f();
4325
5138
  }
4326
5139
  if (!injected) nodes.push.apply(nodes, generated);
4327
- if (options.reset) nodes.unshift(raw(options.reset));
5140
+ var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
5141
+ if (options.reset) nodes.unshift(raw(options.reset, {
5142
+ source: resetFrom,
5143
+ line: 1,
5144
+ column: 0
5145
+ }));
5146
+ var css;
5147
+ var map;
4328
5148
  if (options.sourceMap) {
4329
- var _stringifyWithMap = stringifyWithMap(nodes, {
4330
- minify: options.minify
4331
- }),
4332
- css = _stringifyWithMap.css,
4333
- map = _stringifyWithMap.map;
4334
- map.setSourceContent(from, input);
4335
- var json = map.toJSON();
5149
+ var out = stringifyWithMap(nodes, {
5150
+ minify: options.minify
5151
+ });
5152
+ css = out.css;
5153
+ out.map.setSourceContent(from, input);
5154
+ if (options.reset) out.map.setSourceContent(resetFrom, options.reset);
5155
+ var json = out.map.toJSON();
4336
5156
  json.file = from;
4337
- return {
4338
- css: css,
4339
- map: json,
4340
- classes: _toConsumableArray(classes),
4341
- sources: sources,
4342
- registry: reg
4343
- };
4344
- }
4345
- return {
4346
- css: stringify(nodes, {
5157
+ map = json;
5158
+ } else {
5159
+ css = stringify(nodes, {
4347
5160
  minify: options.minify
4348
- }),
5161
+ });
5162
+ }
5163
+ var stats = {
5164
+ ms: performance.now() - started,
5165
+ scanned: classes.size,
5166
+ utilities: rules.length,
5167
+ bytes: css.length,
5168
+ sources: sources.length
5169
+ };
5170
+ return map ? {
5171
+ css: css,
5172
+ map: map,
5173
+ classes: _toConsumableArray(classes),
5174
+ sources: sources,
5175
+ stats: stats,
5176
+ registry: reg
5177
+ } : {
5178
+ css: css,
4349
5179
  classes: _toConsumableArray(classes),
4350
5180
  sources: sources,
5181
+ stats: stats,
4351
5182
  registry: reg
4352
5183
  };
4353
5184
  }
@@ -4379,7 +5210,12 @@ function compile(input) {
4379
5210
  var _options$registry, _options$classes, _options$sources;
4380
5211
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4381
5212
  var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
5213
+ if (options.theme) loadTheme(options.theme, reg.theme);
4382
5214
  loadTheme(input, reg.theme);
5215
+ // Re-seed the named breakpoint variants so a `@theme` breakpoint override reaches
5216
+ // `sm:`/`md:`/… (they baked the default value at registry-creation time).
5217
+ registerBreakpointVariants(reg);
5218
+ if (options.theme) loadDirectives(options.theme, reg);
4383
5219
  loadDirectives(input, reg);
4384
5220
  var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4385
5221
  var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
@@ -4494,6 +5330,8 @@ exports.defaultTheme = defaultTheme;
4494
5330
  exports.emitTheme = emitTheme;
4495
5331
  exports.emitUiTheme = emitUiTheme;
4496
5332
  exports.escapeClass = escapeClass;
5333
+ exports.expandApply = expandApply;
5334
+ exports.formatBuildLog = formatBuildLog;
4497
5335
  exports.keywords = keywords;
4498
5336
  exports.loadDirectives = loadDirectives;
4499
5337
  exports.loadTheme = loadTheme;
@@ -4502,6 +5340,7 @@ exports.parseSources = parseSources;
4502
5340
  exports.parseVariant = parseVariant;
4503
5341
  exports.props = props;
4504
5342
  exports.raw = raw;
5343
+ exports.registerBreakpointVariants = registerBreakpointVariants;
4505
5344
  exports.registerUtilities = registerUtilities;
4506
5345
  exports.registerVariants = registerVariants;
4507
5346
  exports.resolveSourceFiles = resolveSourceFiles;