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