@fluixi-css/core 1.0.0-next.1 → 1.0.0-next.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/package.json +1 -1
- package/dist/reset.css +174 -152
- package/dist/src/css-parser.cjs +6 -1
- package/dist/src/css-parser.cjs.map +1 -1
- package/dist/src/css-parser.js +6 -2
- package/dist/src/css-parser.js.map +1 -1
- package/dist/src/css-parser.mjs +6 -1
- package/dist/src/css-parser.mjs.map +1 -1
- package/dist/src/engine/apply.d.ts +2 -0
- package/dist/src/engine/apply.js +75 -0
- package/dist/src/engine/apply.js.map +1 -0
- package/dist/src/engine/ast.js +25 -2
- package/dist/src/engine/ast.js.map +1 -1
- package/dist/src/engine/atom.js +8 -1
- package/dist/src/engine/atom.js.map +1 -1
- package/dist/src/engine/compile.js +48 -10
- package/dist/src/engine/compile.js.map +1 -1
- package/dist/src/engine/directives.js +45 -19
- package/dist/src/engine/directives.js.map +1 -1
- package/dist/src/engine/index.d.ts +4 -0
- package/dist/src/engine/index.js +11 -5
- package/dist/src/engine/index.js.map +1 -1
- package/dist/src/engine/log.d.ts +6 -0
- package/dist/src/engine/log.js +42 -0
- package/dist/src/engine/log.js.map +1 -0
- package/dist/src/engine/registry.d.ts +5 -4
- package/dist/src/engine/registry.js +2 -2
- package/dist/src/engine/registry.js.map +1 -1
- package/dist/src/engine/transform.d.ts +22 -0
- package/dist/src/engine/transform.js +60 -30
- package/dist/src/engine/transform.js.map +1 -1
- package/dist/src/engine/ui-preset.d.ts +20 -1
- package/dist/src/engine/ui-preset.js +87 -9
- package/dist/src/engine/ui-preset.js.map +1 -1
- package/dist/src/engine/utilities/backgrounds.js +11 -0
- package/dist/src/engine/utilities/backgrounds.js.map +1 -1
- package/dist/src/engine/utilities/borders.js +60 -1
- package/dist/src/engine/utilities/borders.js.map +1 -1
- package/dist/src/engine/utilities/layout.js +25 -0
- package/dist/src/engine/utilities/layout.js.map +1 -1
- package/dist/src/engine/utilities/spacing.js +25 -1
- package/dist/src/engine/utilities/spacing.js.map +1 -1
- package/dist/src/engine/utilities/typography.js +7 -0
- package/dist/src/engine/utilities/typography.js.map +1 -1
- package/dist/src/engine/variants.js +25 -6
- package/dist/src/engine/variants.js.map +1 -1
- package/dist/src/index.cjs +748 -209
- package/dist/src/index.cjs.map +1 -1
- package/dist/src/index.mjs +746 -210
- package/dist/src/index.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/reset.css +174 -152
package/dist/src/index.mjs
CHANGED
|
@@ -273,6 +273,34 @@ var Writer = /*#__PURE__*/function () {
|
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
+
|
|
277
|
+
// Emit verbatim text (a passed-through author slice or the reset) mapping each
|
|
278
|
+
// of its lines to consecutive source lines — so multi-line blocks are covered,
|
|
279
|
+
// not just their first line.
|
|
280
|
+
}, {
|
|
281
|
+
key: "emitMapped",
|
|
282
|
+
value: function emitMapped(text, loc) {
|
|
283
|
+
if (!this.map) {
|
|
284
|
+
this.emit(text);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
var lines = text.split('\n');
|
|
288
|
+
for (var i = 0; i < lines.length; i++) {
|
|
289
|
+
this.map.addMapping({
|
|
290
|
+
source: loc.source,
|
|
291
|
+
original: {
|
|
292
|
+
line: loc.line + i,
|
|
293
|
+
column: i === 0 ? loc.column : 0
|
|
294
|
+
},
|
|
295
|
+
generated: {
|
|
296
|
+
line: this.line,
|
|
297
|
+
column: this.column
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
this.emit(lines[i]);
|
|
301
|
+
if (i < lines.length - 1) this.emit('\n');
|
|
302
|
+
}
|
|
303
|
+
}
|
|
276
304
|
}]);
|
|
277
305
|
}();
|
|
278
306
|
function stringify(nodes) {
|
|
@@ -328,8 +356,8 @@ function write(node, depth, opts, w) {
|
|
|
328
356
|
}
|
|
329
357
|
if (node.kind === 'raw') {
|
|
330
358
|
w.emit(pad);
|
|
331
|
-
w.
|
|
332
|
-
w.emit(
|
|
359
|
+
if (node.loc) w.emitMapped(node.text, node.loc);else w.emit(node.text);
|
|
360
|
+
w.emit(nl);
|
|
333
361
|
return;
|
|
334
362
|
}
|
|
335
363
|
var header = node.kind === 'rule' ? node.selector : "@".concat(node.name).concat(node.params ? ' ' + node.params : '');
|
|
@@ -563,9 +591,15 @@ function parseAtom(raw) {
|
|
|
563
591
|
if (arbProp !== null && arbProp.includes(':')) {
|
|
564
592
|
var colon = arbProp.indexOf(':');
|
|
565
593
|
if (colon <= 0) return null;
|
|
594
|
+
// The head must be a real CSS property or custom property. Scanners pull
|
|
595
|
+
// `[...]` runs out of JS/TS too (array/object literals like
|
|
596
|
+
// `[...prev, { value } as T]`); rejecting a non-property head keeps those
|
|
597
|
+
// from emitting broken rules that later crash the CSS parser.
|
|
598
|
+
var property = arbProp.slice(0, colon);
|
|
599
|
+
if (!/^-{0,2}[a-zA-Z][a-zA-Z0-9-]*$/.test(property)) return null;
|
|
566
600
|
return {
|
|
567
601
|
kind: 'arbitrary-property',
|
|
568
|
-
property:
|
|
602
|
+
property: property,
|
|
569
603
|
value: decodeUnderscores(arbProp.slice(colon + 1)),
|
|
570
604
|
modifier: modifier,
|
|
571
605
|
important: important,
|
|
@@ -671,6 +705,298 @@ function splitRootValue(base, ctx) {
|
|
|
671
705
|
};
|
|
672
706
|
}
|
|
673
707
|
|
|
708
|
+
// Turns a parsed atom into CSS. Returns null when the utility or any of its
|
|
709
|
+
// variants aren't registered, so an unknown class simply produces nothing.
|
|
710
|
+
function compileAtom(atom, reg) {
|
|
711
|
+
var produced = producedFor(atom, reg);
|
|
712
|
+
if (!produced || produced.length === 0) return null;
|
|
713
|
+
var flat = [];
|
|
714
|
+
var nested = [];
|
|
715
|
+
var _iterator = _createForOfIteratorHelper(produced),
|
|
716
|
+
_step;
|
|
717
|
+
try {
|
|
718
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
719
|
+
var node = _step.value;
|
|
720
|
+
if (node.kind === 'declaration') flat.push(node);else nested.push(node);
|
|
721
|
+
}
|
|
722
|
+
} catch (err) {
|
|
723
|
+
_iterator.e(err);
|
|
724
|
+
} finally {
|
|
725
|
+
_iterator.f();
|
|
726
|
+
}
|
|
727
|
+
if (atom.important) {
|
|
728
|
+
var _iterator2 = _createForOfIteratorHelper(flat),
|
|
729
|
+
_step2;
|
|
730
|
+
try {
|
|
731
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
732
|
+
var d = _step2.value;
|
|
733
|
+
d.important = true;
|
|
734
|
+
}
|
|
735
|
+
} catch (err) {
|
|
736
|
+
_iterator2.e(err);
|
|
737
|
+
} finally {
|
|
738
|
+
_iterator2.f();
|
|
739
|
+
}
|
|
740
|
+
var _iterator3 = _createForOfIteratorHelper(nested),
|
|
741
|
+
_step3;
|
|
742
|
+
try {
|
|
743
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
744
|
+
var n = _step3.value;
|
|
745
|
+
markImportant$1(n.nodes);
|
|
746
|
+
}
|
|
747
|
+
} catch (err) {
|
|
748
|
+
_iterator3.e(err);
|
|
749
|
+
} finally {
|
|
750
|
+
_iterator3.f();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
var selector = '.' + escapeClass(atom.raw);
|
|
754
|
+
var atRules = [];
|
|
755
|
+
var _iterator4 = _createForOfIteratorHelper(atom.variants),
|
|
756
|
+
_step4;
|
|
757
|
+
try {
|
|
758
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
759
|
+
var variant = _step4.value;
|
|
760
|
+
var wrap = resolveVariant(variant, reg);
|
|
761
|
+
if (!wrap) return null;
|
|
762
|
+
if (wrap.selector) selector = substitute(wrap.selector, selector);
|
|
763
|
+
if (wrap.atRule) atRules.push(wrap.atRule);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Flat declarations sit on the utility's own selector; nested rules weave that
|
|
767
|
+
// selector into their `&` (`space-x-4` → `.space-x-4 > :not([hidden]) ~ …`).
|
|
768
|
+
} catch (err) {
|
|
769
|
+
_iterator4.e(err);
|
|
770
|
+
} finally {
|
|
771
|
+
_iterator4.f();
|
|
772
|
+
}
|
|
773
|
+
var nodes = [];
|
|
774
|
+
if (flat.length) nodes.push(rule(selector, flat));
|
|
775
|
+
for (var _i = 0, _nested = nested; _i < _nested.length; _i++) {
|
|
776
|
+
var _n = _nested[_i];
|
|
777
|
+
nodes.push(rule(substitute(_n.selector, selector), _n.nodes));
|
|
778
|
+
}
|
|
779
|
+
for (var _i2 = 0, _atRules = atRules; _i2 < _atRules.length; _i2++) {
|
|
780
|
+
var ar = _atRules[_i2];
|
|
781
|
+
nodes = [atRule(ar.name, ar.params, nodes)];
|
|
782
|
+
}
|
|
783
|
+
return nodes;
|
|
784
|
+
}
|
|
785
|
+
function markImportant$1(nodes) {
|
|
786
|
+
var _iterator5 = _createForOfIteratorHelper(nodes),
|
|
787
|
+
_step5;
|
|
788
|
+
try {
|
|
789
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
790
|
+
var n = _step5.value;
|
|
791
|
+
if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant$1(n.nodes);
|
|
792
|
+
}
|
|
793
|
+
} catch (err) {
|
|
794
|
+
_iterator5.e(err);
|
|
795
|
+
} finally {
|
|
796
|
+
_iterator5.f();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function producedFor(atom, reg) {
|
|
800
|
+
if (atom.kind === 'arbitrary-property') {
|
|
801
|
+
return [decl(atom.property, atom.value)];
|
|
802
|
+
}
|
|
803
|
+
if (atom.kind === 'static') {
|
|
804
|
+
// Clone: static templates are shared, and `!important` / `&`-weaving mutate.
|
|
805
|
+
var products = reg.getRule(atom.root);
|
|
806
|
+
return products ? products.map(cloneProduct) : null;
|
|
807
|
+
}
|
|
808
|
+
var handler = reg.getDynamicRule(atom.root);
|
|
809
|
+
if (!handler) return null;
|
|
810
|
+
return handler({
|
|
811
|
+
value: atom.value,
|
|
812
|
+
modifier: atom.modifier,
|
|
813
|
+
negative: atom.negative,
|
|
814
|
+
theme: reg.theme
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function cloneProduct(n) {
|
|
818
|
+
return n.kind === 'declaration' ? _objectSpread2({}, n) : cloneNode(n);
|
|
819
|
+
}
|
|
820
|
+
function cloneNode(n) {
|
|
821
|
+
if (n.kind === 'declaration') return _objectSpread2({}, n);
|
|
822
|
+
if (n.kind === 'rule') return rule(n.selector, n.nodes.map(cloneNode));
|
|
823
|
+
if (n.kind === 'at-rule') return atRule(n.name, n.params, n.nodes.map(cloneNode));
|
|
824
|
+
return _objectSpread2({}, n);
|
|
825
|
+
}
|
|
826
|
+
function resolveVariant(variant, reg) {
|
|
827
|
+
if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
|
|
828
|
+
if (variant.kind === 'static') return reg.getVariant(variant.root);
|
|
829
|
+
// functional: a null value means it's really a static variant (hover, md, …).
|
|
830
|
+
if (variant.value === null) return reg.getVariant(variant.root);
|
|
831
|
+
var handler = reg.getDynamicVariant(variant.root);
|
|
832
|
+
return handler ? handler(variant.value, variant.modifier) : null;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
|
|
836
|
+
// A bare selector with no `&` is attached to the element.
|
|
837
|
+
function arbitraryVariant(source) {
|
|
838
|
+
if (source[0] === '@') {
|
|
839
|
+
var cut = source.search(/[\s(]/);
|
|
840
|
+
var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
|
|
841
|
+
var params = cut === -1 ? '' : source.slice(cut).trim();
|
|
842
|
+
return {
|
|
843
|
+
atRule: {
|
|
844
|
+
name: name,
|
|
845
|
+
params: params
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
var sel = spacesFromUnderscores(source);
|
|
850
|
+
return {
|
|
851
|
+
selector: sel.includes('&') ? sel : "&".concat(sel)
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function spacesFromUnderscores(s) {
|
|
855
|
+
return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
|
|
856
|
+
}
|
|
857
|
+
function substitute(template, current) {
|
|
858
|
+
return template.replace(/&/g, current);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
|
|
862
|
+
// class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
|
|
863
|
+
function escapeClass(name) {
|
|
864
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
|
|
865
|
+
return '\\' + c;
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// `@apply a b c;` — inline the declarations those utilities produce into the
|
|
870
|
+
// surrounding rule. Operates on author-CSS text (which `transform` passes through
|
|
871
|
+
// verbatim), replacing each `@apply` at-rule in place. Flat utilities inline as
|
|
872
|
+
// declarations; utilities that need their own selector (variants like `hover:` /
|
|
873
|
+
// `group-hover:`, child-combinators like `space-x`, at-rule variants like `md:`)
|
|
874
|
+
// emit a nested rule with `&` bound to the applying selector.
|
|
875
|
+
var APPLY_RE = /@apply\s+([^;{}]+);/g;
|
|
876
|
+
function expandApply(css, reg) {
|
|
877
|
+
if (!css.includes('@apply')) return css;
|
|
878
|
+
return css.replace(APPLY_RE, function (_match, listRaw) {
|
|
879
|
+
var list = listRaw.trim();
|
|
880
|
+
// A trailing `!important` marks every inlined declaration (Tailwind semantics).
|
|
881
|
+
var important = false;
|
|
882
|
+
var bang = list.match(/!important\s*$/);
|
|
883
|
+
if (bang) {
|
|
884
|
+
important = true;
|
|
885
|
+
list = list.slice(0, bang.index).trim();
|
|
886
|
+
}
|
|
887
|
+
var decls = [];
|
|
888
|
+
var rules = [];
|
|
889
|
+
var _iterator = _createForOfIteratorHelper(list.split(/\s+/)),
|
|
890
|
+
_step;
|
|
891
|
+
try {
|
|
892
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
893
|
+
var token = _step.value;
|
|
894
|
+
if (!token) continue;
|
|
895
|
+
var out = compileForApply(token, reg, important);
|
|
896
|
+
if (!out) continue;
|
|
897
|
+
if (out.decls) decls.push.apply(decls, _toConsumableArray(out.decls));
|
|
898
|
+
if (out.rule) rules.push(out.rule);
|
|
899
|
+
}
|
|
900
|
+
// Flat declarations first, then nested rules — same order as authored.
|
|
901
|
+
} catch (err) {
|
|
902
|
+
_iterator.e(err);
|
|
903
|
+
} finally {
|
|
904
|
+
_iterator.f();
|
|
905
|
+
}
|
|
906
|
+
return [].concat(decls, rules).join(' ');
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function compileForApply(cls, reg, important) {
|
|
910
|
+
var atom = parseAtom(cls, reg);
|
|
911
|
+
if (!atom) return null;
|
|
912
|
+
var compiled = compileAtom(atom, reg);
|
|
913
|
+
if (!compiled || compiled.length === 0) return null;
|
|
914
|
+
var classSelector = '.' + escapeClass(atom.raw);
|
|
915
|
+
|
|
916
|
+
// A plain utility — one rule on the class itself with only declarations — inlines
|
|
917
|
+
// straight into the applying rule.
|
|
918
|
+
if (compiled.length === 1 && compiled[0].kind === 'rule' && compiled[0].selector === classSelector) {
|
|
919
|
+
var flat = compiled[0].nodes;
|
|
920
|
+
if (flat.every(function (n) {
|
|
921
|
+
return n.kind === 'declaration';
|
|
922
|
+
})) {
|
|
923
|
+
return {
|
|
924
|
+
decls: flat.map(function (n) {
|
|
925
|
+
return declText(n, important);
|
|
926
|
+
})
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
// Everything else keeps its structure but nests: swap the class's own selector
|
|
932
|
+
// for `&`, so `hover:` → `&:hover`, `group-hover:` → `.group:hover &`, `md:` →
|
|
933
|
+
// `@media(...) { & { … } }`.
|
|
934
|
+
if (important) markImportant(compiled);
|
|
935
|
+
var text = stringify(compiled, {
|
|
936
|
+
minify: false
|
|
937
|
+
}).split(classSelector).join('&');
|
|
938
|
+
return {
|
|
939
|
+
rule: text
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function declText(d, important) {
|
|
943
|
+
return "".concat(d.property, ": ").concat(d.value).concat(important || d.important ? ' !important' : '', ";");
|
|
944
|
+
}
|
|
945
|
+
function markImportant(nodes) {
|
|
946
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
947
|
+
_step2;
|
|
948
|
+
try {
|
|
949
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
950
|
+
var n = _step2.value;
|
|
951
|
+
if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant(n.nodes);
|
|
952
|
+
}
|
|
953
|
+
} catch (err) {
|
|
954
|
+
_iterator2.e(err);
|
|
955
|
+
} finally {
|
|
956
|
+
_iterator2.f();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// Renders a `transform()` result as a compact, colourised build line for the
|
|
961
|
+
// Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays
|
|
962
|
+
// side-effect free — the plugins own the actual `console.log`.
|
|
963
|
+
|
|
964
|
+
var ANSI = {
|
|
965
|
+
reset: '\x1b[0m',
|
|
966
|
+
dim: '\x1b[2m',
|
|
967
|
+
bold: '\x1b[1m',
|
|
968
|
+
cyan: '\x1b[36m',
|
|
969
|
+
green: '\x1b[32m',
|
|
970
|
+
yellow: '\x1b[33m',
|
|
971
|
+
red: '\x1b[31m'
|
|
972
|
+
};
|
|
973
|
+
function paint(code, s, color) {
|
|
974
|
+
return color ? code + s + ANSI.reset : s;
|
|
975
|
+
}
|
|
976
|
+
function humanBytes(n) {
|
|
977
|
+
return n < 1024 ? "".concat(n, " B") : "".concat((n / 1024).toFixed(1), " kB");
|
|
978
|
+
}
|
|
979
|
+
function humanMs(ms) {
|
|
980
|
+
return ms < 1 ? "".concat(ms * 1000 | 0, " \xB5s") : ms < 1000 ? "".concat(ms.toFixed(1), " ms") : "".concat((ms / 1000).toFixed(2), " s");
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Green under 10 ms, yellow under 50 ms, red beyond — a quick "is it fast?" cue.
|
|
984
|
+
function timeColor(ms) {
|
|
985
|
+
return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;
|
|
986
|
+
}
|
|
987
|
+
function formatBuildLog(label, stats) {
|
|
988
|
+
var _options$color;
|
|
989
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
990
|
+
var color = (_options$color = options.color) !== null && _options$color !== void 0 ? _options$color : true;
|
|
991
|
+
var head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);
|
|
992
|
+
var name = paint(ANSI.bold, label, color);
|
|
993
|
+
var time = paint(timeColor(stats.ms), humanMs(stats.ms), color);
|
|
994
|
+
var parts = ["".concat(stats.utilities, " ").concat(stats.utilities === 1 ? 'utility' : 'utilities'), "".concat(stats.scanned, " scanned"), humanBytes(stats.bytes)];
|
|
995
|
+
if (stats.sources) parts.push("".concat(stats.sources, " ").concat(stats.sources === 1 ? 'source' : 'sources'));
|
|
996
|
+
var detail = paint(ANSI.dim, parts.join(' · '), color);
|
|
997
|
+
return "".concat(head, " ").concat(name, " ").concat(time, "\n ").concat(detail);
|
|
998
|
+
}
|
|
999
|
+
|
|
674
1000
|
// The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
|
|
675
1001
|
// `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
|
|
676
1002
|
// `var()` references, so the tokens stay live and themeable at runtime.
|
|
@@ -1074,8 +1400,13 @@ var CssParser = /*#__PURE__*/function () {
|
|
|
1074
1400
|
case 'counter-style':
|
|
1075
1401
|
case 'viewport':
|
|
1076
1402
|
case 'theme':
|
|
1077
|
-
case 'utility':
|
|
1078
1403
|
return 'declarations';
|
|
1404
|
+
// `@utility` bodies mix flat declarations with nested rules
|
|
1405
|
+
// (`&:hover`, `&::-webkit-scrollbar`); `rule` mode does the
|
|
1406
|
+
// declaration-vs-nesting lookahead. (`mixed` would read every line
|
|
1407
|
+
// as a selector and corrupt the block.)
|
|
1408
|
+
case 'utility':
|
|
1409
|
+
return 'rule';
|
|
1079
1410
|
case 'media':
|
|
1080
1411
|
case 'supports':
|
|
1081
1412
|
case 'container':
|
|
@@ -2242,53 +2573,84 @@ function registerUtility(atRule, reg) {
|
|
|
2242
2573
|
var _atRule$preludeText;
|
|
2243
2574
|
var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
|
|
2244
2575
|
if (!name || !atRule.block) return;
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
});
|
|
2251
|
-
if (decls.length === 0) return;
|
|
2576
|
+
|
|
2577
|
+
// Flat declarations plus any nested rules (`&:hover`, `&::-webkit-scrollbar`);
|
|
2578
|
+
// the nested `&` is later woven with the utility's own selector by the compiler.
|
|
2579
|
+
var products = toProducts(atRule.block.children);
|
|
2580
|
+
if (products.length === 0) return;
|
|
2252
2581
|
|
|
2253
2582
|
// A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
|
|
2254
2583
|
if (name.endsWith('-*')) {
|
|
2255
2584
|
var root = name.slice(0, -2);
|
|
2256
2585
|
if (root) reg.dynamicRule(root, function (ctx) {
|
|
2257
|
-
return
|
|
2586
|
+
return resolveProducts(products, ctx);
|
|
2258
2587
|
});
|
|
2259
2588
|
return;
|
|
2260
2589
|
}
|
|
2261
|
-
reg.rule(name,
|
|
2590
|
+
reg.rule(name, products);
|
|
2262
2591
|
}
|
|
2263
|
-
|
|
2264
|
-
// Applies a functional utility's declaration templates to one atom. `--value()`
|
|
2265
|
-
// is required — if it can't resolve, the whole utility is dropped (returns null).
|
|
2266
|
-
// `--modifier()` is optional — a declaration using it is skipped when there's no
|
|
2267
|
-
// matching modifier, so `text-lg` and `text-lg/7` share one definition.
|
|
2268
|
-
function resolveDeclarations(templates, ctx) {
|
|
2592
|
+
function toProducts(children) {
|
|
2269
2593
|
var out = [];
|
|
2270
|
-
var _iterator2 = _createForOfIteratorHelper(
|
|
2594
|
+
var _iterator2 = _createForOfIteratorHelper(children),
|
|
2271
2595
|
_step2;
|
|
2272
2596
|
try {
|
|
2273
2597
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2274
|
-
var
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2598
|
+
var c = _step2.value;
|
|
2599
|
+
if (c.type === 'declaration') {
|
|
2600
|
+
var _d$rawValue;
|
|
2601
|
+
var d = c;
|
|
2602
|
+
out.push(decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true));
|
|
2603
|
+
} else if (c.type === 'rule') {
|
|
2604
|
+
var _r$declarations, _r$children, _r$rawSelector;
|
|
2605
|
+
var r = c;
|
|
2606
|
+
// The parser splits a rule's own declarations from its nested rules; a
|
|
2607
|
+
// utility body wants both, declarations first.
|
|
2608
|
+
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 : []));
|
|
2609
|
+
out.push(rule(((_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : '').trim(), toProducts(kids)));
|
|
2610
|
+
}
|
|
2286
2611
|
}
|
|
2287
2612
|
} catch (err) {
|
|
2288
2613
|
_iterator2.e(err);
|
|
2289
2614
|
} finally {
|
|
2290
2615
|
_iterator2.f();
|
|
2291
2616
|
}
|
|
2617
|
+
return out;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
// Applies a functional utility's templates to one atom, walking nested rules too.
|
|
2621
|
+
// `--value()` is required — if it can't resolve, the whole utility is dropped
|
|
2622
|
+
// (returns null). `--modifier()` is optional — a declaration using it is skipped
|
|
2623
|
+
// when there's no matching modifier, so `text-lg` and `text-lg/7` share one def.
|
|
2624
|
+
function resolveProducts(templates, ctx) {
|
|
2625
|
+
var out = [];
|
|
2626
|
+
var _iterator3 = _createForOfIteratorHelper(templates),
|
|
2627
|
+
_step3;
|
|
2628
|
+
try {
|
|
2629
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2630
|
+
var t = _step3.value;
|
|
2631
|
+
if (t.kind === 'declaration') {
|
|
2632
|
+
var withValue = replaceFn(t.value, '--value', function (args) {
|
|
2633
|
+
return resolveValue(args, ctx);
|
|
2634
|
+
});
|
|
2635
|
+
if (withValue === null) return null;
|
|
2636
|
+
var withModifier = replaceFn(withValue, '--modifier', function (args) {
|
|
2637
|
+
return resolveModifier(args, ctx);
|
|
2638
|
+
});
|
|
2639
|
+
if (withModifier === null) continue;
|
|
2640
|
+
out.push(_objectSpread2(_objectSpread2({}, t), {}, {
|
|
2641
|
+
value: withModifier
|
|
2642
|
+
}));
|
|
2643
|
+
} else {
|
|
2644
|
+
var inner = resolveProducts(t.nodes, ctx);
|
|
2645
|
+
if (inner === null) return null;
|
|
2646
|
+
out.push(rule(t.selector, inner));
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
} catch (err) {
|
|
2650
|
+
_iterator3.e(err);
|
|
2651
|
+
} finally {
|
|
2652
|
+
_iterator3.f();
|
|
2653
|
+
}
|
|
2292
2654
|
return out.length ? out : null;
|
|
2293
2655
|
}
|
|
2294
2656
|
function resolveValue(args, ctx) {
|
|
@@ -2466,6 +2828,10 @@ function wrapFor(condition) {
|
|
|
2466
2828
|
};
|
|
2467
2829
|
}
|
|
2468
2830
|
|
|
2831
|
+
// A utility produces declarations on its own selector, and/or nested rules whose
|
|
2832
|
+
// `&` is woven with that selector — the latter is how child-combinator utilities
|
|
2833
|
+
// like `space-x`/`divide-y` reach `& > * + *`.
|
|
2834
|
+
|
|
2469
2835
|
// A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
|
|
2470
2836
|
// the rule in an at-rule (`@media`, `@supports`). It may do both.
|
|
2471
2837
|
|
|
@@ -2496,8 +2862,8 @@ var Registry = /*#__PURE__*/function () {
|
|
|
2496
2862
|
}
|
|
2497
2863
|
return _createClass(Registry, [{
|
|
2498
2864
|
key: "rule",
|
|
2499
|
-
value: function rule(name,
|
|
2500
|
-
this.rules.set(name,
|
|
2865
|
+
value: function rule(name, products) {
|
|
2866
|
+
this.rules.set(name, products);
|
|
2501
2867
|
return this;
|
|
2502
2868
|
}
|
|
2503
2869
|
}, {
|
|
@@ -2545,111 +2911,6 @@ var Registry = /*#__PURE__*/function () {
|
|
|
2545
2911
|
}]);
|
|
2546
2912
|
}();
|
|
2547
2913
|
|
|
2548
|
-
// Turns a parsed atom into CSS. Returns null when the utility or any of its
|
|
2549
|
-
// variants aren't registered, so an unknown class simply produces nothing.
|
|
2550
|
-
function compileAtom(atom, reg) {
|
|
2551
|
-
var declarations = declarationsFor(atom, reg);
|
|
2552
|
-
if (!declarations || declarations.length === 0) return null;
|
|
2553
|
-
if (atom.important) {
|
|
2554
|
-
var _iterator = _createForOfIteratorHelper(declarations),
|
|
2555
|
-
_step;
|
|
2556
|
-
try {
|
|
2557
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2558
|
-
var d = _step.value;
|
|
2559
|
-
d.important = true;
|
|
2560
|
-
}
|
|
2561
|
-
} catch (err) {
|
|
2562
|
-
_iterator.e(err);
|
|
2563
|
-
} finally {
|
|
2564
|
-
_iterator.f();
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
var selector = '.' + escapeClass(atom.raw);
|
|
2568
|
-
var atRules = [];
|
|
2569
|
-
var _iterator2 = _createForOfIteratorHelper(atom.variants),
|
|
2570
|
-
_step2;
|
|
2571
|
-
try {
|
|
2572
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2573
|
-
var variant = _step2.value;
|
|
2574
|
-
var wrap = resolveVariant(variant, reg);
|
|
2575
|
-
if (!wrap) return null;
|
|
2576
|
-
if (wrap.selector) selector = substitute(wrap.selector, selector);
|
|
2577
|
-
if (wrap.atRule) atRules.push(wrap.atRule);
|
|
2578
|
-
}
|
|
2579
|
-
} catch (err) {
|
|
2580
|
-
_iterator2.e(err);
|
|
2581
|
-
} finally {
|
|
2582
|
-
_iterator2.f();
|
|
2583
|
-
}
|
|
2584
|
-
var node = rule(selector, declarations);
|
|
2585
|
-
for (var _i = 0, _atRules = atRules; _i < _atRules.length; _i++) {
|
|
2586
|
-
var ar = _atRules[_i];
|
|
2587
|
-
node = atRule(ar.name, ar.params, [node]);
|
|
2588
|
-
}
|
|
2589
|
-
return [node];
|
|
2590
|
-
}
|
|
2591
|
-
function declarationsFor(atom, reg) {
|
|
2592
|
-
if (atom.kind === 'arbitrary-property') {
|
|
2593
|
-
return [decl(atom.property, atom.value)];
|
|
2594
|
-
}
|
|
2595
|
-
if (atom.kind === 'static') {
|
|
2596
|
-
var decls = reg.getRule(atom.root);
|
|
2597
|
-
return decls ? decls.map(function (d) {
|
|
2598
|
-
return _objectSpread2({}, d);
|
|
2599
|
-
}) : null;
|
|
2600
|
-
}
|
|
2601
|
-
var handler = reg.getDynamicRule(atom.root);
|
|
2602
|
-
if (!handler) return null;
|
|
2603
|
-
return handler({
|
|
2604
|
-
value: atom.value,
|
|
2605
|
-
modifier: atom.modifier,
|
|
2606
|
-
negative: atom.negative,
|
|
2607
|
-
theme: reg.theme
|
|
2608
|
-
});
|
|
2609
|
-
}
|
|
2610
|
-
function resolveVariant(variant, reg) {
|
|
2611
|
-
if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
|
|
2612
|
-
if (variant.kind === 'static') return reg.getVariant(variant.root);
|
|
2613
|
-
// functional: a null value means it's really a static variant (hover, md, …).
|
|
2614
|
-
if (variant.value === null) return reg.getVariant(variant.root);
|
|
2615
|
-
var handler = reg.getDynamicVariant(variant.root);
|
|
2616
|
-
return handler ? handler(variant.value, variant.modifier) : null;
|
|
2617
|
-
}
|
|
2618
|
-
|
|
2619
|
-
// `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
|
|
2620
|
-
// A bare selector with no `&` is attached to the element.
|
|
2621
|
-
function arbitraryVariant(source) {
|
|
2622
|
-
if (source[0] === '@') {
|
|
2623
|
-
var cut = source.search(/[\s(]/);
|
|
2624
|
-
var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
|
|
2625
|
-
var params = cut === -1 ? '' : source.slice(cut).trim();
|
|
2626
|
-
return {
|
|
2627
|
-
atRule: {
|
|
2628
|
-
name: name,
|
|
2629
|
-
params: params
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
var sel = spacesFromUnderscores(source);
|
|
2634
|
-
return {
|
|
2635
|
-
selector: sel.includes('&') ? sel : "&".concat(sel)
|
|
2636
|
-
};
|
|
2637
|
-
}
|
|
2638
|
-
function spacesFromUnderscores(s) {
|
|
2639
|
-
return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
|
|
2640
|
-
}
|
|
2641
|
-
function substitute(template, current) {
|
|
2642
|
-
return template.replace(/&/g, current);
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
// Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
|
|
2646
|
-
// class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
|
|
2647
|
-
function escapeClass(name) {
|
|
2648
|
-
return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
|
|
2649
|
-
return '\\' + c;
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
2914
|
var Palettes = {
|
|
2654
2915
|
"slate": {
|
|
2655
2916
|
"50": "#f8fafc",
|
|
@@ -3124,6 +3385,23 @@ function registerBackgrounds(reg) {
|
|
|
3124
3385
|
props(reg, 'background-image', {
|
|
3125
3386
|
'bg-none': 'none'
|
|
3126
3387
|
});
|
|
3388
|
+
|
|
3389
|
+
// Form-control colours.
|
|
3390
|
+
reg.dynamicRule('accent', function (_ref2) {
|
|
3391
|
+
var value = _ref2.value,
|
|
3392
|
+
modifier = _ref2.modifier,
|
|
3393
|
+
theme = _ref2.theme;
|
|
3394
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];
|
|
3395
|
+
var c = colorValue(value, modifier, theme);
|
|
3396
|
+
return c ? [decl('accent-color', c)] : null;
|
|
3397
|
+
});
|
|
3398
|
+
reg.dynamicRule('caret', function (_ref3) {
|
|
3399
|
+
var value = _ref3.value,
|
|
3400
|
+
modifier = _ref3.modifier,
|
|
3401
|
+
theme = _ref3.theme;
|
|
3402
|
+
var c = colorValue(value, modifier, theme);
|
|
3403
|
+
return c ? [decl('caret-color', c)] : null;
|
|
3404
|
+
});
|
|
3127
3405
|
}
|
|
3128
3406
|
|
|
3129
3407
|
function registerBorders(reg) {
|
|
@@ -3144,6 +3422,8 @@ function registerBorders(reg) {
|
|
|
3144
3422
|
hidden: 'hidden',
|
|
3145
3423
|
none: 'none'
|
|
3146
3424
|
});
|
|
3425
|
+
divide(reg);
|
|
3426
|
+
ring(reg);
|
|
3147
3427
|
rounded(reg, 'rounded', ['']);
|
|
3148
3428
|
rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
|
|
3149
3429
|
rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
|
|
@@ -3223,6 +3503,59 @@ function outline(reg) {
|
|
|
3223
3503
|
});
|
|
3224
3504
|
}
|
|
3225
3505
|
|
|
3506
|
+
// Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
|
|
3507
|
+
// set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
|
|
3508
|
+
// edge via a `--flx-divide-*-reverse` toggle.
|
|
3509
|
+
var BETWEEN$1 = '& > :not([hidden]) ~ :not([hidden])';
|
|
3510
|
+
function divide(reg) {
|
|
3511
|
+
divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
|
|
3512
|
+
divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
|
|
3513
|
+
reg.dynamicRule('divide', function (_ref4) {
|
|
3514
|
+
var value = _ref4.value,
|
|
3515
|
+
modifier = _ref4.modifier,
|
|
3516
|
+
theme = _ref4.theme;
|
|
3517
|
+
if (value === null) return null;
|
|
3518
|
+
var style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
|
|
3519
|
+
if (style) return [rule(BETWEEN$1, [decl('border-style', style)])];
|
|
3520
|
+
var color = colorFor(value, modifier, theme);
|
|
3521
|
+
return color ? [rule(BETWEEN$1, [decl('border-color', color)])] : null;
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
var DIVIDE_STYLES = {
|
|
3525
|
+
solid: 'solid',
|
|
3526
|
+
dashed: 'dashed',
|
|
3527
|
+
dotted: 'dotted',
|
|
3528
|
+
"double": 'double',
|
|
3529
|
+
none: 'none'
|
|
3530
|
+
};
|
|
3531
|
+
function divideWidth(reg, axis, reverseProp, mainProp) {
|
|
3532
|
+
var flag = "--flx-divide-".concat(axis, "-reverse");
|
|
3533
|
+
reg.dynamicRule("divide-".concat(axis), function (_ref5) {
|
|
3534
|
+
var value = _ref5.value;
|
|
3535
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') return [rule(BETWEEN$1, [decl(flag, '1')])];
|
|
3536
|
+
var w = widthValue(value, '1px');
|
|
3537
|
+
if (w === null) return null;
|
|
3538
|
+
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, ")))"))])];
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
// A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
|
|
3543
|
+
// (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
|
|
3544
|
+
function ring(reg) {
|
|
3545
|
+
reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
|
|
3546
|
+
reg.dynamicRule('ring', function (_ref6) {
|
|
3547
|
+
var value = _ref6.value,
|
|
3548
|
+
modifier = _ref6.modifier,
|
|
3549
|
+
theme = _ref6.theme;
|
|
3550
|
+
var w = value === null ? '3px' : widthValue(value, null);
|
|
3551
|
+
if (w !== null) {
|
|
3552
|
+
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)')];
|
|
3553
|
+
}
|
|
3554
|
+
var color = colorFor(value, modifier, theme);
|
|
3555
|
+
return color ? [decl('--flx-ring-color', color)] : null;
|
|
3556
|
+
});
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3226
3559
|
function registerEffects(reg) {
|
|
3227
3560
|
reg.dynamicRule('shadow', function (_ref) {
|
|
3228
3561
|
var value = _ref.value,
|
|
@@ -3707,6 +4040,36 @@ function registerLayout(reg) {
|
|
|
3707
4040
|
if (value.value === 'auto') return [decl('z-index', 'auto')];
|
|
3708
4041
|
return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
|
|
3709
4042
|
});
|
|
4043
|
+
reg.dynamicRule('columns', function (_ref2) {
|
|
4044
|
+
var value = _ref2.value;
|
|
4045
|
+
if (!value) return null;
|
|
4046
|
+
if (value.kind === 'arbitrary') return [decl('columns', value.value)];
|
|
4047
|
+
if (value.value === 'auto' || /^\d+$/.test(value.value)) return [decl('columns', value.value)];
|
|
4048
|
+
return null;
|
|
4049
|
+
});
|
|
4050
|
+
|
|
4051
|
+
// Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
|
|
4052
|
+
// (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
|
|
4053
|
+
props(reg, 'scroll-snap-type', {
|
|
4054
|
+
'snap-none': 'none',
|
|
4055
|
+
'snap-x': 'x var(--flx-scroll-snap-strictness)',
|
|
4056
|
+
'snap-y': 'y var(--flx-scroll-snap-strictness)',
|
|
4057
|
+
'snap-both': 'both var(--flx-scroll-snap-strictness)'
|
|
4058
|
+
});
|
|
4059
|
+
props(reg, '--flx-scroll-snap-strictness', {
|
|
4060
|
+
'snap-mandatory': 'mandatory',
|
|
4061
|
+
'snap-proximity': 'proximity'
|
|
4062
|
+
});
|
|
4063
|
+
props(reg, 'scroll-snap-align', {
|
|
4064
|
+
'snap-start': 'start',
|
|
4065
|
+
'snap-end': 'end',
|
|
4066
|
+
'snap-center': 'center',
|
|
4067
|
+
'snap-align-none': 'none'
|
|
4068
|
+
});
|
|
4069
|
+
props(reg, 'scroll-snap-stop', {
|
|
4070
|
+
'snap-normal': 'normal',
|
|
4071
|
+
'snap-always': 'always'
|
|
4072
|
+
});
|
|
3710
4073
|
}
|
|
3711
4074
|
var OVERFLOW = {
|
|
3712
4075
|
auto: 'auto',
|
|
@@ -3716,11 +4079,11 @@ var OVERFLOW = {
|
|
|
3716
4079
|
scroll: 'scroll'
|
|
3717
4080
|
};
|
|
3718
4081
|
function inset(reg, root, props) {
|
|
3719
|
-
reg.dynamicRule(root, function (
|
|
3720
|
-
var value =
|
|
3721
|
-
negative =
|
|
3722
|
-
modifier =
|
|
3723
|
-
theme =
|
|
4082
|
+
reg.dynamicRule(root, function (_ref3) {
|
|
4083
|
+
var value = _ref3.value,
|
|
4084
|
+
negative = _ref3.negative,
|
|
4085
|
+
modifier = _ref3.modifier,
|
|
4086
|
+
theme = _ref3.theme;
|
|
3724
4087
|
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3725
4088
|
return decl(p, 'auto');
|
|
3726
4089
|
});
|
|
@@ -3770,6 +4133,29 @@ function registerSpacing(reg) {
|
|
|
3770
4133
|
props = _Object$entries$_i[1];
|
|
3771
4134
|
spacing(reg, root, props, root[0] === 'm');
|
|
3772
4135
|
}
|
|
4136
|
+
spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
|
|
4137
|
+
spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
// Only the space *between* siblings, applied to every child after the first via
|
|
4141
|
+
// the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
|
|
4142
|
+
// margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
|
|
4143
|
+
var BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
|
|
4144
|
+
function spaceBetween(reg, axis, startProp, endProp) {
|
|
4145
|
+
var flag = "--flx-space-".concat(axis, "-reverse");
|
|
4146
|
+
reg.dynamicRule("space-".concat(axis), function (_ref) {
|
|
4147
|
+
var value = _ref.value,
|
|
4148
|
+
negative = _ref.negative,
|
|
4149
|
+
theme = _ref.theme;
|
|
4150
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
|
|
4151
|
+
return [rule(BETWEEN, [decl(flag, '1')])];
|
|
4152
|
+
}
|
|
4153
|
+
var v = sizeValue(value, theme, {
|
|
4154
|
+
negative: negative
|
|
4155
|
+
});
|
|
4156
|
+
if (!v) return null;
|
|
4157
|
+
return [rule(BETWEEN, [decl(flag, '0'), decl(startProp, "calc(".concat(v, " * calc(1 - var(").concat(flag, ")))")), decl(endProp, "calc(".concat(v, " * var(").concat(flag, "))"))])];
|
|
4158
|
+
});
|
|
3773
4159
|
}
|
|
3774
4160
|
|
|
3775
4161
|
// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
|
|
@@ -3797,10 +4183,10 @@ var SPACING = {
|
|
|
3797
4183
|
'scroll-p': ['scroll-padding']
|
|
3798
4184
|
};
|
|
3799
4185
|
function spacing(reg, root, props, allowAuto) {
|
|
3800
|
-
reg.dynamicRule(root, function (
|
|
3801
|
-
var value =
|
|
3802
|
-
negative =
|
|
3803
|
-
theme =
|
|
4186
|
+
reg.dynamicRule(root, function (_ref2) {
|
|
4187
|
+
var value = _ref2.value,
|
|
4188
|
+
negative = _ref2.negative,
|
|
4189
|
+
theme = _ref2.theme;
|
|
3804
4190
|
if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3805
4191
|
return decl(p, 'auto');
|
|
3806
4192
|
});
|
|
@@ -4054,6 +4440,12 @@ function registerTypography(reg) {
|
|
|
4054
4440
|
var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
|
|
4055
4441
|
return t ? [decl('letter-spacing', t)] : null;
|
|
4056
4442
|
});
|
|
4443
|
+
reg.dynamicRule('content', function (_ref4) {
|
|
4444
|
+
var value = _ref4.value;
|
|
4445
|
+
if (!value) return null;
|
|
4446
|
+
if (value.kind === 'arbitrary') return [decl('content', value.value)];
|
|
4447
|
+
return value.value === 'none' ? [decl('content', 'none')] : null;
|
|
4448
|
+
});
|
|
4057
4449
|
}
|
|
4058
4450
|
var WEIGHTS = {
|
|
4059
4451
|
thin: '100',
|
|
@@ -4142,6 +4534,18 @@ function registerVariants(reg) {
|
|
|
4142
4534
|
reg.variant('ltr', {
|
|
4143
4535
|
selector: '&:where([dir="ltr"], [dir="ltr"] *)'
|
|
4144
4536
|
});
|
|
4537
|
+
reg.variant('*', {
|
|
4538
|
+
selector: '& > *'
|
|
4539
|
+
}); // direct children
|
|
4540
|
+
reg.variant('**', {
|
|
4541
|
+
selector: '& *'
|
|
4542
|
+
}); // all descendants
|
|
4543
|
+
reg.variant('open', {
|
|
4544
|
+
selector: '&:is([open], :open)'
|
|
4545
|
+
});
|
|
4546
|
+
reg.variant('inert', {
|
|
4547
|
+
selector: '&:is([inert], [inert] *)'
|
|
4548
|
+
});
|
|
4145
4549
|
registerBreakpointVariants(reg);
|
|
4146
4550
|
|
|
4147
4551
|
// `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
|
|
@@ -4159,11 +4563,11 @@ function registerVariants(reg) {
|
|
|
4159
4563
|
reg.dynamicVariant('max', function (v) {
|
|
4160
4564
|
return mediaWidth('max-width', width(v));
|
|
4161
4565
|
});
|
|
4162
|
-
reg.dynamicVariant('group', function (v) {
|
|
4163
|
-
return relational(v, '.group', ' &');
|
|
4566
|
+
reg.dynamicVariant('group', function (v, m) {
|
|
4567
|
+
return relational(v, m, '.group', ' &');
|
|
4164
4568
|
});
|
|
4165
|
-
reg.dynamicVariant('peer', function (v) {
|
|
4166
|
-
return relational(v, '.peer', ' ~ &');
|
|
4569
|
+
reg.dynamicVariant('peer', function (v, m) {
|
|
4570
|
+
return relational(v, m, '.peer', ' ~ &');
|
|
4167
4571
|
});
|
|
4168
4572
|
reg.dynamicVariant('data', function (v) {
|
|
4169
4573
|
return named(v) ? {
|
|
@@ -4181,9 +4585,7 @@ function registerVariants(reg) {
|
|
|
4181
4585
|
} : null;
|
|
4182
4586
|
});
|
|
4183
4587
|
reg.dynamicVariant('not', function (v) {
|
|
4184
|
-
return
|
|
4185
|
-
selector: "&:not(".concat(named(v), ")")
|
|
4186
|
-
} : null;
|
|
4588
|
+
return notVariant(reg, v);
|
|
4187
4589
|
});
|
|
4188
4590
|
reg.dynamicVariant('supports', function (v) {
|
|
4189
4591
|
return named(v) ? {
|
|
@@ -4273,16 +4675,34 @@ function named(v) {
|
|
|
4273
4675
|
}
|
|
4274
4676
|
|
|
4275
4677
|
// `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
|
|
4276
|
-
// is a pseudo-class, an arbitrary one is a raw selector fragment.
|
|
4277
|
-
|
|
4678
|
+
// is a pseudo-class, an arbitrary one is a raw selector fragment. A `/name`
|
|
4679
|
+
// modifier scopes to a named group/peer (`group-hover/item` → `.group\/item:hover`).
|
|
4680
|
+
function relational(v, m, base, tail) {
|
|
4278
4681
|
var value = named(v);
|
|
4279
4682
|
if (!value) return null;
|
|
4280
4683
|
var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
|
|
4684
|
+
var scope = m ? "".concat(base, "\\/").concat(m.value) : base;
|
|
4281
4685
|
return {
|
|
4282
|
-
selector: "".concat(
|
|
4686
|
+
selector: "".concat(scope).concat(cond).concat(tail)
|
|
4283
4687
|
};
|
|
4284
4688
|
}
|
|
4285
4689
|
|
|
4690
|
+
// `not-hover` → `&:not(:hover)`, `not-first` → `&:not(:first-child)`: resolve the
|
|
4691
|
+
// inner variant's pseudo, so the selector is valid (not the literal name). Only
|
|
4692
|
+
// simple pseudo variants compose; `not-[…]` takes an arbitrary selector.
|
|
4693
|
+
function notVariant(reg, v) {
|
|
4694
|
+
var _reg$getVariant;
|
|
4695
|
+
var value = named(v);
|
|
4696
|
+
if (!value) return null;
|
|
4697
|
+
if (v.kind === 'arbitrary') return {
|
|
4698
|
+
selector: "&:not(".concat(value, ")")
|
|
4699
|
+
};
|
|
4700
|
+
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();
|
|
4701
|
+
return frag && frag.startsWith(':') ? {
|
|
4702
|
+
selector: "&:not(".concat(frag, ")")
|
|
4703
|
+
} : null;
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4286
4706
|
// The batteries-included registry: the default token theme plus the utility
|
|
4287
4707
|
// families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
|
|
4288
4708
|
// build a bare `new Registry(theme)` and register their own.
|
|
@@ -4491,8 +4911,18 @@ function scanSourceFiles(files) {
|
|
|
4491
4911
|
// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
|
|
4492
4912
|
// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
|
|
4493
4913
|
// so a fluixi-css theme *drives* the UI — change the theme, the components follow —
|
|
4494
|
-
// without copying any values across. A bridge is emitted only when its
|
|
4495
|
-
// token exists, so the UI's own defaults stand in for anything the theme omits.
|
|
4914
|
+
// without copying any values across. A primitive bridge is emitted only when its
|
|
4915
|
+
// source token exists, so the UI's own defaults stand in for anything the theme omits.
|
|
4916
|
+
//
|
|
4917
|
+
// Colour is the driven half: when the theme supplies the functional scales
|
|
4918
|
+
// (`--color-accent-1..12` / `--color-gray-1..12`), this also emits the UI's whole
|
|
4919
|
+
// *semantic* layer (`--flx-ui-color-primary`, …). That layer is purely structural —
|
|
4920
|
+
// every var references a scale/alias var, never a concrete colour — so it carries no
|
|
4921
|
+
// palette data across the package boundary; `@fluixi-ui/tokens` still owns the
|
|
4922
|
+
// default values. The semantic layer is re-emitted in a dark scope because
|
|
4923
|
+
// custom-property substitution freezes at the declaring element: a `:root`-only
|
|
4924
|
+
// `--flx-ui-color-primary: var(--flx-ui-accent-9)` would inherit light's *resolved*
|
|
4925
|
+
// colour into a dark subtree instead of re-resolving against the dark scale.
|
|
4496
4926
|
|
|
4497
4927
|
// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
|
|
4498
4928
|
var SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
|
|
@@ -4502,6 +4932,24 @@ var FONT_SIZE = [['xs', 'xs'], ['sm', 'sm'], ['md', 'base'], ['lg', 'lg'], ['xl'
|
|
|
4502
4932
|
var RADIUS = ['sm', 'md', 'lg', 'xl'];
|
|
4503
4933
|
var SHADOW = ['sm', 'md', 'lg', 'xl'];
|
|
4504
4934
|
var BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
4935
|
+
|
|
4936
|
+
// The UI's semantic layer, mirrored from `@fluixi-ui/tokens` (`semanticColors`).
|
|
4937
|
+
// Structural only — refs into the scales/aliases the bridge (or the UI's own
|
|
4938
|
+
// defaults) provide. `color-primary-fg` and `color-overlay` are intentionally
|
|
4939
|
+
// omitted: they're concrete kit defaults, not scale-derived, so the UI package
|
|
4940
|
+
// keeps ownership of them.
|
|
4941
|
+
var SEMANTIC = [['color-bg', 'gray-1'], ['color-bg-subtle', 'gray-2'], ['color-bg-muted', 'gray-3'], ['color-fg', 'gray-12'], ['color-fg-muted', 'gray-11'], ['color-border', 'gray-6'], ['color-border-strong', 'gray-7'], ['color-focus-ring', 'accent-8'], ['color-primary', 'accent-9'], ['color-primary-hover', 'accent-10'], ['color-primary-active', 'accent-11'], ['color-primary-subtle', 'accent-3'], ['color-danger', 'danger-solid'], ['color-danger-fg', 'danger-fg'], ['color-danger-subtle', 'danger-subtle'], ['color-success', 'success-solid'], ['color-success-fg', 'success-fg'], ['color-success-subtle', 'success-subtle'], ['color-warning', 'warning-solid'], ['color-warning-fg', 'warning-fg'], ['color-warning-subtle', 'warning-subtle']];
|
|
4942
|
+
|
|
4943
|
+
// Optional status-colour bridges: a theme may drive the UI's danger/success/
|
|
4944
|
+
// warning solids by supplying `--color-danger` / `--color-success` / `--color-warning`.
|
|
4945
|
+
var STATUS = [['danger-solid', '--color-danger'], ['success-solid', '--color-success'], ['warning-solid', '--color-warning']];
|
|
4946
|
+
|
|
4947
|
+
/** True once the theme supplies enough of the functional scales to drive colour. */
|
|
4948
|
+
function hasColorScales(theme) {
|
|
4949
|
+
return theme.has('--color-accent-9') || theme.has('--color-gray-1');
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
/** The primitive + scale bridges (non-colour and the raw scale refs). */
|
|
4505
4953
|
function uiTokenBridges(theme) {
|
|
4506
4954
|
var out = [];
|
|
4507
4955
|
var bridge = function bridge(flx, source) {
|
|
@@ -4567,10 +5015,8 @@ function uiTokenBridges(theme) {
|
|
|
4567
5015
|
bridge("breakpoint-".concat(_k2), "--breakpoint-".concat(_k2));
|
|
4568
5016
|
}
|
|
4569
5017
|
|
|
4570
|
-
//
|
|
4571
|
-
//
|
|
4572
|
-
// semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
|
|
4573
|
-
// built-in scales stand.
|
|
5018
|
+
// Functional colour scales are opt-in: supply a Radix-style 1..12 ramp and the
|
|
5019
|
+
// UI's semantic colours follow. Absent them, the UI's built-in scales stand.
|
|
4574
5020
|
} catch (err) {
|
|
4575
5021
|
_iterator5.e(err);
|
|
4576
5022
|
} finally {
|
|
@@ -4580,13 +5026,71 @@ function uiTokenBridges(theme) {
|
|
|
4580
5026
|
bridge("accent-".concat(i), "--color-accent-".concat(i));
|
|
4581
5027
|
bridge("gray-".concat(i), "--color-gray-".concat(i));
|
|
4582
5028
|
}
|
|
5029
|
+
var _iterator6 = _createForOfIteratorHelper(STATUS),
|
|
5030
|
+
_step6;
|
|
5031
|
+
try {
|
|
5032
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
5033
|
+
var _step6$value = _slicedToArray(_step6.value, 2),
|
|
5034
|
+
_flx = _step6$value[0],
|
|
5035
|
+
source = _step6$value[1];
|
|
5036
|
+
bridge(_flx, source);
|
|
5037
|
+
}
|
|
5038
|
+
} catch (err) {
|
|
5039
|
+
_iterator6.e(err);
|
|
5040
|
+
} finally {
|
|
5041
|
+
_iterator6.f();
|
|
5042
|
+
}
|
|
4583
5043
|
return out;
|
|
4584
5044
|
}
|
|
4585
5045
|
|
|
4586
|
-
|
|
5046
|
+
/** The structural semantic layer — emitted only when the theme drives colour. */
|
|
5047
|
+
function uiSemanticLayer(theme) {
|
|
5048
|
+
if (!hasColorScales(theme)) return [];
|
|
5049
|
+
return SEMANTIC.map(function (_ref) {
|
|
5050
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
5051
|
+
name = _ref2[0],
|
|
5052
|
+
ref = _ref2[1];
|
|
5053
|
+
return decl("--flx-ui-".concat(name), "var(--flx-ui-".concat(ref, ")"));
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
* The bridges as sibling top-level rules, ready to prepend to the compiled sheet:
|
|
5058
|
+
* `:root` (primitives + scales + semantic layer) and, when the theme drives
|
|
5059
|
+
* colour, a dark-scope re-emit of the colour half so its `var()` refs re-resolve
|
|
5060
|
+
* against the theme's dark-scoped `--color-*` values.
|
|
5061
|
+
*/
|
|
4587
5062
|
function emitUiTheme(theme) {
|
|
4588
|
-
var
|
|
4589
|
-
|
|
5063
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5064
|
+
var _options$selector = options.selector,
|
|
5065
|
+
selector = _options$selector === void 0 ? ':root' : _options$selector,
|
|
5066
|
+
_options$darkSelector = options.darkSelector,
|
|
5067
|
+
darkSelector = _options$darkSelector === void 0 ? "[data-theme='dark']" : _options$darkSelector;
|
|
5068
|
+
var out = [rule(selector, [].concat(_toConsumableArray(uiTokenBridges(theme)), _toConsumableArray(uiSemanticLayer(theme))))];
|
|
5069
|
+
if (darkSelector && hasColorScales(theme)) {
|
|
5070
|
+
// Re-emit only the colour half in the dark scope (primitives don't flip).
|
|
5071
|
+
var darkColor = [];
|
|
5072
|
+
for (var i = 1; i <= 12; i++) {
|
|
5073
|
+
if (theme.has("--color-accent-".concat(i))) darkColor.push(decl("--flx-ui-accent-".concat(i), "var(--color-accent-".concat(i, ")")));
|
|
5074
|
+
if (theme.has("--color-gray-".concat(i))) darkColor.push(decl("--flx-ui-gray-".concat(i), "var(--color-gray-".concat(i, ")")));
|
|
5075
|
+
}
|
|
5076
|
+
var _iterator7 = _createForOfIteratorHelper(STATUS),
|
|
5077
|
+
_step7;
|
|
5078
|
+
try {
|
|
5079
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
5080
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
5081
|
+
flx = _step7$value[0],
|
|
5082
|
+
source = _step7$value[1];
|
|
5083
|
+
if (theme.has(source)) darkColor.push(decl("--flx-ui-".concat(flx), "var(".concat(source, ")")));
|
|
5084
|
+
}
|
|
5085
|
+
} catch (err) {
|
|
5086
|
+
_iterator7.e(err);
|
|
5087
|
+
} finally {
|
|
5088
|
+
_iterator7.f();
|
|
5089
|
+
}
|
|
5090
|
+
darkColor.push.apply(darkColor, _toConsumableArray(uiSemanticLayer(theme)));
|
|
5091
|
+
out.push(rule(darkSelector, darkColor));
|
|
5092
|
+
}
|
|
5093
|
+
return out;
|
|
4590
5094
|
}
|
|
4591
5095
|
|
|
4592
5096
|
// Directives consumed to build the registry — dropped from the output.
|
|
@@ -4598,11 +5102,14 @@ var MARKER = 'fluixi';
|
|
|
4598
5102
|
// directives are consumed, and an `@fluixi;` marker is replaced by the generated
|
|
4599
5103
|
// token `:root` + utilities. With no marker the generated block is appended.
|
|
4600
5104
|
function transform(input) {
|
|
4601
|
-
var _options$registry, _options$classes, _options$from, _options$sources;
|
|
5105
|
+
var _options$registry, _options$classes, _options$from, _options$resetFrom, _options$sources;
|
|
4602
5106
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5107
|
+
var started = performance.now();
|
|
4603
5108
|
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
4604
|
-
loadTheme(
|
|
5109
|
+
if (options.theme) loadTheme(options.theme, reg.theme);
|
|
5110
|
+
loadTheme(input, reg.theme); // the input's own @theme overrides the base
|
|
4605
5111
|
registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides
|
|
5112
|
+
if (options.theme) loadDirectives(options.theme, reg);
|
|
4606
5113
|
loadDirectives(input, reg);
|
|
4607
5114
|
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4608
5115
|
var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
@@ -4674,19 +5181,16 @@ function transform(input) {
|
|
|
4674
5181
|
} finally {
|
|
4675
5182
|
_iterator4.f();
|
|
4676
5183
|
}
|
|
4677
|
-
var
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
}
|
|
4685
|
-
if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);
|
|
4686
|
-
generated.push.apply(generated, rules);
|
|
5184
|
+
var uiBlocks = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
5185
|
+
|
|
5186
|
+
// Pass the author CSS through first (expanding `@apply`), remembering where the
|
|
5187
|
+
// `@fluixi` marker sits so the generated block splices in at that point. Building
|
|
5188
|
+
// it up front lets the token tree-shake also see the author's own `var()` refs —
|
|
5189
|
+
// a hand-written or `@apply`-injected `var(--color-x)` must keep `--color-x`
|
|
5190
|
+
// alive, else the token is stripped and the reference resolves to nothing.
|
|
4687
5191
|
var from = (_options$from = options.from) !== null && _options$from !== void 0 ? _options$from : '<input>';
|
|
4688
|
-
var
|
|
4689
|
-
var
|
|
5192
|
+
var authorNodes = [];
|
|
5193
|
+
var markerAt = -1;
|
|
4690
5194
|
var _iterator5 = _createForOfIteratorHelper(parseCss(input).children),
|
|
4691
5195
|
_step5;
|
|
4692
5196
|
try {
|
|
@@ -4694,17 +5198,15 @@ function transform(input) {
|
|
|
4694
5198
|
var _node$loc, _node$loc2;
|
|
4695
5199
|
var node = _step5.value;
|
|
4696
5200
|
if (node.type === 'atrule' && node.name === MARKER) {
|
|
4697
|
-
if (
|
|
4698
|
-
nodes.push.apply(nodes, generated);
|
|
4699
|
-
injected = true;
|
|
4700
|
-
}
|
|
5201
|
+
if (markerAt < 0) markerAt = authorNodes.length;
|
|
4701
5202
|
continue;
|
|
4702
5203
|
}
|
|
4703
5204
|
if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;
|
|
4704
5205
|
var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
|
|
4705
5206
|
var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
|
|
4706
5207
|
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
4707
|
-
|
|
5208
|
+
var text = expandApply(input.slice(start.offset, end.offset), reg);
|
|
5209
|
+
authorNodes.push(raw(text, {
|
|
4708
5210
|
source: from,
|
|
4709
5211
|
line: start.line,
|
|
4710
5212
|
column: Math.max(0, start.column - 1)
|
|
@@ -4716,31 +5218,61 @@ function transform(input) {
|
|
|
4716
5218
|
} finally {
|
|
4717
5219
|
_iterator5.f();
|
|
4718
5220
|
}
|
|
4719
|
-
|
|
4720
|
-
if (options.
|
|
5221
|
+
var generated = [];
|
|
5222
|
+
if (options.emitTokens !== false) {
|
|
5223
|
+
var used = collectVarRefs(rules);
|
|
5224
|
+
if (uiBlocks) collectVarRefs(uiBlocks, used);
|
|
5225
|
+
collectVarRefs(authorNodes, used); // keep tokens the author CSS references by hand / via @apply
|
|
5226
|
+
var tokens = emitTheme(reg.theme, ':root', used);
|
|
5227
|
+
if (tokens.nodes.length) generated.push(tokens);
|
|
5228
|
+
}
|
|
5229
|
+
if (uiBlocks) generated.push.apply(generated, _toConsumableArray(uiBlocks.filter(function (b) {
|
|
5230
|
+
return b.nodes.length;
|
|
5231
|
+
})));
|
|
5232
|
+
generated.push.apply(generated, rules);
|
|
5233
|
+
var nodes = markerAt >= 0 ? [].concat(_toConsumableArray(authorNodes.slice(0, markerAt)), generated, _toConsumableArray(authorNodes.slice(markerAt))) : [].concat(authorNodes, generated);
|
|
5234
|
+
var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
|
|
5235
|
+
if (options.reset) nodes.unshift(raw(options.reset, {
|
|
5236
|
+
source: resetFrom,
|
|
5237
|
+
line: 1,
|
|
5238
|
+
column: 0
|
|
5239
|
+
}));
|
|
5240
|
+
var css;
|
|
5241
|
+
var map;
|
|
4721
5242
|
if (options.sourceMap) {
|
|
4722
|
-
var
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
map.setSourceContent(
|
|
4728
|
-
var json = map.toJSON();
|
|
5243
|
+
var out = stringifyWithMap(nodes, {
|
|
5244
|
+
minify: options.minify
|
|
5245
|
+
});
|
|
5246
|
+
css = out.css;
|
|
5247
|
+
out.map.setSourceContent(from, input);
|
|
5248
|
+
if (options.reset) out.map.setSourceContent(resetFrom, options.reset);
|
|
5249
|
+
var json = out.map.toJSON();
|
|
4729
5250
|
json.file = from;
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
classes: _toConsumableArray(classes),
|
|
4734
|
-
sources: sources,
|
|
4735
|
-
registry: reg
|
|
4736
|
-
};
|
|
4737
|
-
}
|
|
4738
|
-
return {
|
|
4739
|
-
css: stringify(nodes, {
|
|
5251
|
+
map = json;
|
|
5252
|
+
} else {
|
|
5253
|
+
css = stringify(nodes, {
|
|
4740
5254
|
minify: options.minify
|
|
4741
|
-
})
|
|
5255
|
+
});
|
|
5256
|
+
}
|
|
5257
|
+
var stats = {
|
|
5258
|
+
ms: performance.now() - started,
|
|
5259
|
+
scanned: classes.size,
|
|
5260
|
+
utilities: rules.length,
|
|
5261
|
+
bytes: css.length,
|
|
5262
|
+
sources: sources.length
|
|
5263
|
+
};
|
|
5264
|
+
return map ? {
|
|
5265
|
+
css: css,
|
|
5266
|
+
map: map,
|
|
5267
|
+
classes: _toConsumableArray(classes),
|
|
5268
|
+
sources: sources,
|
|
5269
|
+
stats: stats,
|
|
5270
|
+
registry: reg
|
|
5271
|
+
} : {
|
|
5272
|
+
css: css,
|
|
4742
5273
|
classes: _toConsumableArray(classes),
|
|
4743
5274
|
sources: sources,
|
|
5275
|
+
stats: stats,
|
|
4744
5276
|
registry: reg
|
|
4745
5277
|
};
|
|
4746
5278
|
}
|
|
@@ -4772,10 +5304,12 @@ function compile(input) {
|
|
|
4772
5304
|
var _options$registry, _options$classes, _options$sources;
|
|
4773
5305
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4774
5306
|
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
5307
|
+
if (options.theme) loadTheme(options.theme, reg.theme);
|
|
4775
5308
|
loadTheme(input, reg.theme);
|
|
4776
5309
|
// Re-seed the named breakpoint variants so a `@theme` breakpoint override reaches
|
|
4777
5310
|
// `sm:`/`md:`/… (they baked the default value at registry-creation time).
|
|
4778
5311
|
registerBreakpointVariants(reg);
|
|
5312
|
+
if (options.theme) loadDirectives(options.theme, reg);
|
|
4779
5313
|
loadDirectives(input, reg);
|
|
4780
5314
|
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4781
5315
|
var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
@@ -4852,17 +5386,19 @@ function compile(input) {
|
|
|
4852
5386
|
} finally {
|
|
4853
5387
|
_iterator5.f();
|
|
4854
5388
|
}
|
|
4855
|
-
var
|
|
5389
|
+
var uiBlocks = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
4856
5390
|
|
|
4857
5391
|
// Emit only the tokens the compiled rules (and any UI bridge) actually reference.
|
|
4858
5392
|
var nodes = [];
|
|
4859
5393
|
if (options.emitTokens !== false) {
|
|
4860
5394
|
var used = collectVarRefs(rules);
|
|
4861
|
-
if (
|
|
5395
|
+
if (uiBlocks) collectVarRefs(uiBlocks, used);
|
|
4862
5396
|
var tokens = emitTheme(reg.theme, ':root', used);
|
|
4863
5397
|
if (tokens.nodes.length) nodes.push(tokens);
|
|
4864
5398
|
}
|
|
4865
|
-
if (
|
|
5399
|
+
if (uiBlocks) nodes.push.apply(nodes, _toConsumableArray(uiBlocks.filter(function (b) {
|
|
5400
|
+
return b.nodes.length;
|
|
5401
|
+
})));
|
|
4866
5402
|
nodes.push.apply(nodes, rules);
|
|
4867
5403
|
return {
|
|
4868
5404
|
css: stringify(nodes, {
|
|
@@ -4874,5 +5410,5 @@ function compile(input) {
|
|
|
4874
5410
|
};
|
|
4875
5411
|
}
|
|
4876
5412
|
|
|
4877
|
-
export { Registry, SPECIAL_COLORS, Theme, atRule, collectVarRefs, colorValue, compile, compileAtom, compileClasses, createRegistry, decl, decodeUnderscores, defaultTheme, emitTheme, emitUiTheme, escapeClass, keywords, loadDirectives, loadTheme, parseAtom, parseSources, parseVariant, props, raw, registerBreakpointVariants, registerUtilities, registerVariants, resolveSourceFiles, rule, scanAtoms, scanSourceFiles, sizeValue, splitAtTopLevel, statics, stringify, stringifyWithMap, transform, uiTokenBridges };
|
|
5413
|
+
export { Registry, SPECIAL_COLORS, Theme, atRule, collectVarRefs, colorValue, compile, compileAtom, compileClasses, createRegistry, decl, decodeUnderscores, defaultTheme, emitTheme, emitUiTheme, escapeClass, expandApply, formatBuildLog, keywords, loadDirectives, loadTheme, parseAtom, parseSources, parseVariant, props, raw, registerBreakpointVariants, registerUtilities, registerVariants, resolveSourceFiles, rule, scanAtoms, scanSourceFiles, sizeValue, splitAtTopLevel, statics, stringify, stringifyWithMap, transform, uiSemanticLayer, uiTokenBridges };
|
|
4878
5414
|
//# sourceMappingURL=index.mjs.map
|