@fluixi-css/core 1.0.0-next.1 → 1.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +6 -0
- 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 +34 -9
- package/dist/src/engine/transform.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 +619 -179
- package/dist/src/index.cjs.map +1 -1
- package/dist/src/index.mjs +618 -180
- 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 : '');
|
|
@@ -671,6 +699,298 @@ function splitRootValue(base, ctx) {
|
|
|
671
699
|
};
|
|
672
700
|
}
|
|
673
701
|
|
|
702
|
+
// Turns a parsed atom into CSS. Returns null when the utility or any of its
|
|
703
|
+
// variants aren't registered, so an unknown class simply produces nothing.
|
|
704
|
+
function compileAtom(atom, reg) {
|
|
705
|
+
var produced = producedFor(atom, reg);
|
|
706
|
+
if (!produced || produced.length === 0) return null;
|
|
707
|
+
var flat = [];
|
|
708
|
+
var nested = [];
|
|
709
|
+
var _iterator = _createForOfIteratorHelper(produced),
|
|
710
|
+
_step;
|
|
711
|
+
try {
|
|
712
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
713
|
+
var node = _step.value;
|
|
714
|
+
if (node.kind === 'declaration') flat.push(node);else nested.push(node);
|
|
715
|
+
}
|
|
716
|
+
} catch (err) {
|
|
717
|
+
_iterator.e(err);
|
|
718
|
+
} finally {
|
|
719
|
+
_iterator.f();
|
|
720
|
+
}
|
|
721
|
+
if (atom.important) {
|
|
722
|
+
var _iterator2 = _createForOfIteratorHelper(flat),
|
|
723
|
+
_step2;
|
|
724
|
+
try {
|
|
725
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
726
|
+
var d = _step2.value;
|
|
727
|
+
d.important = true;
|
|
728
|
+
}
|
|
729
|
+
} catch (err) {
|
|
730
|
+
_iterator2.e(err);
|
|
731
|
+
} finally {
|
|
732
|
+
_iterator2.f();
|
|
733
|
+
}
|
|
734
|
+
var _iterator3 = _createForOfIteratorHelper(nested),
|
|
735
|
+
_step3;
|
|
736
|
+
try {
|
|
737
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
738
|
+
var n = _step3.value;
|
|
739
|
+
markImportant$1(n.nodes);
|
|
740
|
+
}
|
|
741
|
+
} catch (err) {
|
|
742
|
+
_iterator3.e(err);
|
|
743
|
+
} finally {
|
|
744
|
+
_iterator3.f();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
var selector = '.' + escapeClass(atom.raw);
|
|
748
|
+
var atRules = [];
|
|
749
|
+
var _iterator4 = _createForOfIteratorHelper(atom.variants),
|
|
750
|
+
_step4;
|
|
751
|
+
try {
|
|
752
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
753
|
+
var variant = _step4.value;
|
|
754
|
+
var wrap = resolveVariant(variant, reg);
|
|
755
|
+
if (!wrap) return null;
|
|
756
|
+
if (wrap.selector) selector = substitute(wrap.selector, selector);
|
|
757
|
+
if (wrap.atRule) atRules.push(wrap.atRule);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// Flat declarations sit on the utility's own selector; nested rules weave that
|
|
761
|
+
// selector into their `&` (`space-x-4` → `.space-x-4 > :not([hidden]) ~ …`).
|
|
762
|
+
} catch (err) {
|
|
763
|
+
_iterator4.e(err);
|
|
764
|
+
} finally {
|
|
765
|
+
_iterator4.f();
|
|
766
|
+
}
|
|
767
|
+
var nodes = [];
|
|
768
|
+
if (flat.length) nodes.push(rule(selector, flat));
|
|
769
|
+
for (var _i = 0, _nested = nested; _i < _nested.length; _i++) {
|
|
770
|
+
var _n = _nested[_i];
|
|
771
|
+
nodes.push(rule(substitute(_n.selector, selector), _n.nodes));
|
|
772
|
+
}
|
|
773
|
+
for (var _i2 = 0, _atRules = atRules; _i2 < _atRules.length; _i2++) {
|
|
774
|
+
var ar = _atRules[_i2];
|
|
775
|
+
nodes = [atRule(ar.name, ar.params, nodes)];
|
|
776
|
+
}
|
|
777
|
+
return nodes;
|
|
778
|
+
}
|
|
779
|
+
function markImportant$1(nodes) {
|
|
780
|
+
var _iterator5 = _createForOfIteratorHelper(nodes),
|
|
781
|
+
_step5;
|
|
782
|
+
try {
|
|
783
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
784
|
+
var n = _step5.value;
|
|
785
|
+
if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant$1(n.nodes);
|
|
786
|
+
}
|
|
787
|
+
} catch (err) {
|
|
788
|
+
_iterator5.e(err);
|
|
789
|
+
} finally {
|
|
790
|
+
_iterator5.f();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function producedFor(atom, reg) {
|
|
794
|
+
if (atom.kind === 'arbitrary-property') {
|
|
795
|
+
return [decl(atom.property, atom.value)];
|
|
796
|
+
}
|
|
797
|
+
if (atom.kind === 'static') {
|
|
798
|
+
// Clone: static templates are shared, and `!important` / `&`-weaving mutate.
|
|
799
|
+
var products = reg.getRule(atom.root);
|
|
800
|
+
return products ? products.map(cloneProduct) : null;
|
|
801
|
+
}
|
|
802
|
+
var handler = reg.getDynamicRule(atom.root);
|
|
803
|
+
if (!handler) return null;
|
|
804
|
+
return handler({
|
|
805
|
+
value: atom.value,
|
|
806
|
+
modifier: atom.modifier,
|
|
807
|
+
negative: atom.negative,
|
|
808
|
+
theme: reg.theme
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
function cloneProduct(n) {
|
|
812
|
+
return n.kind === 'declaration' ? _objectSpread2({}, n) : cloneNode(n);
|
|
813
|
+
}
|
|
814
|
+
function cloneNode(n) {
|
|
815
|
+
if (n.kind === 'declaration') return _objectSpread2({}, n);
|
|
816
|
+
if (n.kind === 'rule') return rule(n.selector, n.nodes.map(cloneNode));
|
|
817
|
+
if (n.kind === 'at-rule') return atRule(n.name, n.params, n.nodes.map(cloneNode));
|
|
818
|
+
return _objectSpread2({}, n);
|
|
819
|
+
}
|
|
820
|
+
function resolveVariant(variant, reg) {
|
|
821
|
+
if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
|
|
822
|
+
if (variant.kind === 'static') return reg.getVariant(variant.root);
|
|
823
|
+
// functional: a null value means it's really a static variant (hover, md, …).
|
|
824
|
+
if (variant.value === null) return reg.getVariant(variant.root);
|
|
825
|
+
var handler = reg.getDynamicVariant(variant.root);
|
|
826
|
+
return handler ? handler(variant.value, variant.modifier) : null;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
|
|
830
|
+
// A bare selector with no `&` is attached to the element.
|
|
831
|
+
function arbitraryVariant(source) {
|
|
832
|
+
if (source[0] === '@') {
|
|
833
|
+
var cut = source.search(/[\s(]/);
|
|
834
|
+
var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
|
|
835
|
+
var params = cut === -1 ? '' : source.slice(cut).trim();
|
|
836
|
+
return {
|
|
837
|
+
atRule: {
|
|
838
|
+
name: name,
|
|
839
|
+
params: params
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
var sel = spacesFromUnderscores(source);
|
|
844
|
+
return {
|
|
845
|
+
selector: sel.includes('&') ? sel : "&".concat(sel)
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function spacesFromUnderscores(s) {
|
|
849
|
+
return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
|
|
850
|
+
}
|
|
851
|
+
function substitute(template, current) {
|
|
852
|
+
return template.replace(/&/g, current);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
|
|
856
|
+
// class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
|
|
857
|
+
function escapeClass(name) {
|
|
858
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
|
|
859
|
+
return '\\' + c;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// `@apply a b c;` — inline the declarations those utilities produce into the
|
|
864
|
+
// surrounding rule. Operates on author-CSS text (which `transform` passes through
|
|
865
|
+
// verbatim), replacing each `@apply` at-rule in place. Flat utilities inline as
|
|
866
|
+
// declarations; utilities that need their own selector (variants like `hover:` /
|
|
867
|
+
// `group-hover:`, child-combinators like `space-x`, at-rule variants like `md:`)
|
|
868
|
+
// emit a nested rule with `&` bound to the applying selector.
|
|
869
|
+
var APPLY_RE = /@apply\s+([^;{}]+);/g;
|
|
870
|
+
function expandApply(css, reg) {
|
|
871
|
+
if (!css.includes('@apply')) return css;
|
|
872
|
+
return css.replace(APPLY_RE, function (_match, listRaw) {
|
|
873
|
+
var list = listRaw.trim();
|
|
874
|
+
// A trailing `!important` marks every inlined declaration (Tailwind semantics).
|
|
875
|
+
var important = false;
|
|
876
|
+
var bang = list.match(/!important\s*$/);
|
|
877
|
+
if (bang) {
|
|
878
|
+
important = true;
|
|
879
|
+
list = list.slice(0, bang.index).trim();
|
|
880
|
+
}
|
|
881
|
+
var decls = [];
|
|
882
|
+
var rules = [];
|
|
883
|
+
var _iterator = _createForOfIteratorHelper(list.split(/\s+/)),
|
|
884
|
+
_step;
|
|
885
|
+
try {
|
|
886
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
887
|
+
var token = _step.value;
|
|
888
|
+
if (!token) continue;
|
|
889
|
+
var out = compileForApply(token, reg, important);
|
|
890
|
+
if (!out) continue;
|
|
891
|
+
if (out.decls) decls.push.apply(decls, _toConsumableArray(out.decls));
|
|
892
|
+
if (out.rule) rules.push(out.rule);
|
|
893
|
+
}
|
|
894
|
+
// Flat declarations first, then nested rules — same order as authored.
|
|
895
|
+
} catch (err) {
|
|
896
|
+
_iterator.e(err);
|
|
897
|
+
} finally {
|
|
898
|
+
_iterator.f();
|
|
899
|
+
}
|
|
900
|
+
return [].concat(decls, rules).join(' ');
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
function compileForApply(cls, reg, important) {
|
|
904
|
+
var atom = parseAtom(cls, reg);
|
|
905
|
+
if (!atom) return null;
|
|
906
|
+
var compiled = compileAtom(atom, reg);
|
|
907
|
+
if (!compiled || compiled.length === 0) return null;
|
|
908
|
+
var classSelector = '.' + escapeClass(atom.raw);
|
|
909
|
+
|
|
910
|
+
// A plain utility — one rule on the class itself with only declarations — inlines
|
|
911
|
+
// straight into the applying rule.
|
|
912
|
+
if (compiled.length === 1 && compiled[0].kind === 'rule' && compiled[0].selector === classSelector) {
|
|
913
|
+
var flat = compiled[0].nodes;
|
|
914
|
+
if (flat.every(function (n) {
|
|
915
|
+
return n.kind === 'declaration';
|
|
916
|
+
})) {
|
|
917
|
+
return {
|
|
918
|
+
decls: flat.map(function (n) {
|
|
919
|
+
return declText(n, important);
|
|
920
|
+
})
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// Everything else keeps its structure but nests: swap the class's own selector
|
|
926
|
+
// for `&`, so `hover:` → `&:hover`, `group-hover:` → `.group:hover &`, `md:` →
|
|
927
|
+
// `@media(...) { & { … } }`.
|
|
928
|
+
if (important) markImportant(compiled);
|
|
929
|
+
var text = stringify(compiled, {
|
|
930
|
+
minify: false
|
|
931
|
+
}).split(classSelector).join('&');
|
|
932
|
+
return {
|
|
933
|
+
rule: text
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function declText(d, important) {
|
|
937
|
+
return "".concat(d.property, ": ").concat(d.value).concat(important || d.important ? ' !important' : '', ";");
|
|
938
|
+
}
|
|
939
|
+
function markImportant(nodes) {
|
|
940
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
941
|
+
_step2;
|
|
942
|
+
try {
|
|
943
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
944
|
+
var n = _step2.value;
|
|
945
|
+
if (n.kind === 'declaration') n.important = true;else if (n.kind === 'rule' || n.kind === 'at-rule') markImportant(n.nodes);
|
|
946
|
+
}
|
|
947
|
+
} catch (err) {
|
|
948
|
+
_iterator2.e(err);
|
|
949
|
+
} finally {
|
|
950
|
+
_iterator2.f();
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// Renders a `transform()` result as a compact, colourised build line for the
|
|
955
|
+
// Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays
|
|
956
|
+
// side-effect free — the plugins own the actual `console.log`.
|
|
957
|
+
|
|
958
|
+
var ANSI = {
|
|
959
|
+
reset: '\x1b[0m',
|
|
960
|
+
dim: '\x1b[2m',
|
|
961
|
+
bold: '\x1b[1m',
|
|
962
|
+
cyan: '\x1b[36m',
|
|
963
|
+
green: '\x1b[32m',
|
|
964
|
+
yellow: '\x1b[33m',
|
|
965
|
+
red: '\x1b[31m'
|
|
966
|
+
};
|
|
967
|
+
function paint(code, s, color) {
|
|
968
|
+
return color ? code + s + ANSI.reset : s;
|
|
969
|
+
}
|
|
970
|
+
function humanBytes(n) {
|
|
971
|
+
return n < 1024 ? "".concat(n, " B") : "".concat((n / 1024).toFixed(1), " kB");
|
|
972
|
+
}
|
|
973
|
+
function humanMs(ms) {
|
|
974
|
+
return ms < 1 ? "".concat(ms * 1000 | 0, " \xB5s") : ms < 1000 ? "".concat(ms.toFixed(1), " ms") : "".concat((ms / 1000).toFixed(2), " s");
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Green under 10 ms, yellow under 50 ms, red beyond — a quick "is it fast?" cue.
|
|
978
|
+
function timeColor(ms) {
|
|
979
|
+
return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;
|
|
980
|
+
}
|
|
981
|
+
function formatBuildLog(label, stats) {
|
|
982
|
+
var _options$color;
|
|
983
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
984
|
+
var color = (_options$color = options.color) !== null && _options$color !== void 0 ? _options$color : true;
|
|
985
|
+
var head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);
|
|
986
|
+
var name = paint(ANSI.bold, label, color);
|
|
987
|
+
var time = paint(timeColor(stats.ms), humanMs(stats.ms), color);
|
|
988
|
+
var parts = ["".concat(stats.utilities, " ").concat(stats.utilities === 1 ? 'utility' : 'utilities'), "".concat(stats.scanned, " scanned"), humanBytes(stats.bytes)];
|
|
989
|
+
if (stats.sources) parts.push("".concat(stats.sources, " ").concat(stats.sources === 1 ? 'source' : 'sources'));
|
|
990
|
+
var detail = paint(ANSI.dim, parts.join(' · '), color);
|
|
991
|
+
return "".concat(head, " ").concat(name, " ").concat(time, "\n ").concat(detail);
|
|
992
|
+
}
|
|
993
|
+
|
|
674
994
|
// The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
|
|
675
995
|
// `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
|
|
676
996
|
// `var()` references, so the tokens stay live and themeable at runtime.
|
|
@@ -1074,8 +1394,13 @@ var CssParser = /*#__PURE__*/function () {
|
|
|
1074
1394
|
case 'counter-style':
|
|
1075
1395
|
case 'viewport':
|
|
1076
1396
|
case 'theme':
|
|
1077
|
-
case 'utility':
|
|
1078
1397
|
return 'declarations';
|
|
1398
|
+
// `@utility` bodies mix flat declarations with nested rules
|
|
1399
|
+
// (`&:hover`, `&::-webkit-scrollbar`); `rule` mode does the
|
|
1400
|
+
// declaration-vs-nesting lookahead. (`mixed` would read every line
|
|
1401
|
+
// as a selector and corrupt the block.)
|
|
1402
|
+
case 'utility':
|
|
1403
|
+
return 'rule';
|
|
1079
1404
|
case 'media':
|
|
1080
1405
|
case 'supports':
|
|
1081
1406
|
case 'container':
|
|
@@ -2242,53 +2567,84 @@ function registerUtility(atRule, reg) {
|
|
|
2242
2567
|
var _atRule$preludeText;
|
|
2243
2568
|
var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
|
|
2244
2569
|
if (!name || !atRule.block) return;
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
});
|
|
2251
|
-
if (decls.length === 0) return;
|
|
2570
|
+
|
|
2571
|
+
// Flat declarations plus any nested rules (`&:hover`, `&::-webkit-scrollbar`);
|
|
2572
|
+
// the nested `&` is later woven with the utility's own selector by the compiler.
|
|
2573
|
+
var products = toProducts(atRule.block.children);
|
|
2574
|
+
if (products.length === 0) return;
|
|
2252
2575
|
|
|
2253
2576
|
// A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
|
|
2254
2577
|
if (name.endsWith('-*')) {
|
|
2255
2578
|
var root = name.slice(0, -2);
|
|
2256
2579
|
if (root) reg.dynamicRule(root, function (ctx) {
|
|
2257
|
-
return
|
|
2580
|
+
return resolveProducts(products, ctx);
|
|
2258
2581
|
});
|
|
2259
2582
|
return;
|
|
2260
2583
|
}
|
|
2261
|
-
reg.rule(name,
|
|
2584
|
+
reg.rule(name, products);
|
|
2262
2585
|
}
|
|
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) {
|
|
2586
|
+
function toProducts(children) {
|
|
2269
2587
|
var out = [];
|
|
2270
|
-
var _iterator2 = _createForOfIteratorHelper(
|
|
2588
|
+
var _iterator2 = _createForOfIteratorHelper(children),
|
|
2271
2589
|
_step2;
|
|
2272
2590
|
try {
|
|
2273
2591
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2274
|
-
var
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2592
|
+
var c = _step2.value;
|
|
2593
|
+
if (c.type === 'declaration') {
|
|
2594
|
+
var _d$rawValue;
|
|
2595
|
+
var d = c;
|
|
2596
|
+
out.push(decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true));
|
|
2597
|
+
} else if (c.type === 'rule') {
|
|
2598
|
+
var _r$declarations, _r$children, _r$rawSelector;
|
|
2599
|
+
var r = c;
|
|
2600
|
+
// The parser splits a rule's own declarations from its nested rules; a
|
|
2601
|
+
// utility body wants both, declarations first.
|
|
2602
|
+
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 : []));
|
|
2603
|
+
out.push(rule(((_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : '').trim(), toProducts(kids)));
|
|
2604
|
+
}
|
|
2286
2605
|
}
|
|
2287
2606
|
} catch (err) {
|
|
2288
2607
|
_iterator2.e(err);
|
|
2289
2608
|
} finally {
|
|
2290
2609
|
_iterator2.f();
|
|
2291
2610
|
}
|
|
2611
|
+
return out;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
// Applies a functional utility's templates to one atom, walking nested rules too.
|
|
2615
|
+
// `--value()` is required — if it can't resolve, the whole utility is dropped
|
|
2616
|
+
// (returns null). `--modifier()` is optional — a declaration using it is skipped
|
|
2617
|
+
// when there's no matching modifier, so `text-lg` and `text-lg/7` share one def.
|
|
2618
|
+
function resolveProducts(templates, ctx) {
|
|
2619
|
+
var out = [];
|
|
2620
|
+
var _iterator3 = _createForOfIteratorHelper(templates),
|
|
2621
|
+
_step3;
|
|
2622
|
+
try {
|
|
2623
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2624
|
+
var t = _step3.value;
|
|
2625
|
+
if (t.kind === 'declaration') {
|
|
2626
|
+
var withValue = replaceFn(t.value, '--value', function (args) {
|
|
2627
|
+
return resolveValue(args, ctx);
|
|
2628
|
+
});
|
|
2629
|
+
if (withValue === null) return null;
|
|
2630
|
+
var withModifier = replaceFn(withValue, '--modifier', function (args) {
|
|
2631
|
+
return resolveModifier(args, ctx);
|
|
2632
|
+
});
|
|
2633
|
+
if (withModifier === null) continue;
|
|
2634
|
+
out.push(_objectSpread2(_objectSpread2({}, t), {}, {
|
|
2635
|
+
value: withModifier
|
|
2636
|
+
}));
|
|
2637
|
+
} else {
|
|
2638
|
+
var inner = resolveProducts(t.nodes, ctx);
|
|
2639
|
+
if (inner === null) return null;
|
|
2640
|
+
out.push(rule(t.selector, inner));
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
} catch (err) {
|
|
2644
|
+
_iterator3.e(err);
|
|
2645
|
+
} finally {
|
|
2646
|
+
_iterator3.f();
|
|
2647
|
+
}
|
|
2292
2648
|
return out.length ? out : null;
|
|
2293
2649
|
}
|
|
2294
2650
|
function resolveValue(args, ctx) {
|
|
@@ -2466,6 +2822,10 @@ function wrapFor(condition) {
|
|
|
2466
2822
|
};
|
|
2467
2823
|
}
|
|
2468
2824
|
|
|
2825
|
+
// A utility produces declarations on its own selector, and/or nested rules whose
|
|
2826
|
+
// `&` is woven with that selector — the latter is how child-combinator utilities
|
|
2827
|
+
// like `space-x`/`divide-y` reach `& > * + *`.
|
|
2828
|
+
|
|
2469
2829
|
// A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
|
|
2470
2830
|
// the rule in an at-rule (`@media`, `@supports`). It may do both.
|
|
2471
2831
|
|
|
@@ -2496,8 +2856,8 @@ var Registry = /*#__PURE__*/function () {
|
|
|
2496
2856
|
}
|
|
2497
2857
|
return _createClass(Registry, [{
|
|
2498
2858
|
key: "rule",
|
|
2499
|
-
value: function rule(name,
|
|
2500
|
-
this.rules.set(name,
|
|
2859
|
+
value: function rule(name, products) {
|
|
2860
|
+
this.rules.set(name, products);
|
|
2501
2861
|
return this;
|
|
2502
2862
|
}
|
|
2503
2863
|
}, {
|
|
@@ -2545,111 +2905,6 @@ var Registry = /*#__PURE__*/function () {
|
|
|
2545
2905
|
}]);
|
|
2546
2906
|
}();
|
|
2547
2907
|
|
|
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
2908
|
var Palettes = {
|
|
2654
2909
|
"slate": {
|
|
2655
2910
|
"50": "#f8fafc",
|
|
@@ -3124,6 +3379,23 @@ function registerBackgrounds(reg) {
|
|
|
3124
3379
|
props(reg, 'background-image', {
|
|
3125
3380
|
'bg-none': 'none'
|
|
3126
3381
|
});
|
|
3382
|
+
|
|
3383
|
+
// Form-control colours.
|
|
3384
|
+
reg.dynamicRule('accent', function (_ref2) {
|
|
3385
|
+
var value = _ref2.value,
|
|
3386
|
+
modifier = _ref2.modifier,
|
|
3387
|
+
theme = _ref2.theme;
|
|
3388
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];
|
|
3389
|
+
var c = colorValue(value, modifier, theme);
|
|
3390
|
+
return c ? [decl('accent-color', c)] : null;
|
|
3391
|
+
});
|
|
3392
|
+
reg.dynamicRule('caret', function (_ref3) {
|
|
3393
|
+
var value = _ref3.value,
|
|
3394
|
+
modifier = _ref3.modifier,
|
|
3395
|
+
theme = _ref3.theme;
|
|
3396
|
+
var c = colorValue(value, modifier, theme);
|
|
3397
|
+
return c ? [decl('caret-color', c)] : null;
|
|
3398
|
+
});
|
|
3127
3399
|
}
|
|
3128
3400
|
|
|
3129
3401
|
function registerBorders(reg) {
|
|
@@ -3144,6 +3416,8 @@ function registerBorders(reg) {
|
|
|
3144
3416
|
hidden: 'hidden',
|
|
3145
3417
|
none: 'none'
|
|
3146
3418
|
});
|
|
3419
|
+
divide(reg);
|
|
3420
|
+
ring(reg);
|
|
3147
3421
|
rounded(reg, 'rounded', ['']);
|
|
3148
3422
|
rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
|
|
3149
3423
|
rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
|
|
@@ -3223,6 +3497,59 @@ function outline(reg) {
|
|
|
3223
3497
|
});
|
|
3224
3498
|
}
|
|
3225
3499
|
|
|
3500
|
+
// Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
|
|
3501
|
+
// set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
|
|
3502
|
+
// edge via a `--flx-divide-*-reverse` toggle.
|
|
3503
|
+
var BETWEEN$1 = '& > :not([hidden]) ~ :not([hidden])';
|
|
3504
|
+
function divide(reg) {
|
|
3505
|
+
divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
|
|
3506
|
+
divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
|
|
3507
|
+
reg.dynamicRule('divide', function (_ref4) {
|
|
3508
|
+
var value = _ref4.value,
|
|
3509
|
+
modifier = _ref4.modifier,
|
|
3510
|
+
theme = _ref4.theme;
|
|
3511
|
+
if (value === null) return null;
|
|
3512
|
+
var style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
|
|
3513
|
+
if (style) return [rule(BETWEEN$1, [decl('border-style', style)])];
|
|
3514
|
+
var color = colorFor(value, modifier, theme);
|
|
3515
|
+
return color ? [rule(BETWEEN$1, [decl('border-color', color)])] : null;
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
var DIVIDE_STYLES = {
|
|
3519
|
+
solid: 'solid',
|
|
3520
|
+
dashed: 'dashed',
|
|
3521
|
+
dotted: 'dotted',
|
|
3522
|
+
"double": 'double',
|
|
3523
|
+
none: 'none'
|
|
3524
|
+
};
|
|
3525
|
+
function divideWidth(reg, axis, reverseProp, mainProp) {
|
|
3526
|
+
var flag = "--flx-divide-".concat(axis, "-reverse");
|
|
3527
|
+
reg.dynamicRule("divide-".concat(axis), function (_ref5) {
|
|
3528
|
+
var value = _ref5.value;
|
|
3529
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') return [rule(BETWEEN$1, [decl(flag, '1')])];
|
|
3530
|
+
var w = widthValue(value, '1px');
|
|
3531
|
+
if (w === null) return null;
|
|
3532
|
+
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, ")))"))])];
|
|
3533
|
+
});
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
// A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
|
|
3537
|
+
// (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
|
|
3538
|
+
function ring(reg) {
|
|
3539
|
+
reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
|
|
3540
|
+
reg.dynamicRule('ring', function (_ref6) {
|
|
3541
|
+
var value = _ref6.value,
|
|
3542
|
+
modifier = _ref6.modifier,
|
|
3543
|
+
theme = _ref6.theme;
|
|
3544
|
+
var w = value === null ? '3px' : widthValue(value, null);
|
|
3545
|
+
if (w !== null) {
|
|
3546
|
+
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)')];
|
|
3547
|
+
}
|
|
3548
|
+
var color = colorFor(value, modifier, theme);
|
|
3549
|
+
return color ? [decl('--flx-ring-color', color)] : null;
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3226
3553
|
function registerEffects(reg) {
|
|
3227
3554
|
reg.dynamicRule('shadow', function (_ref) {
|
|
3228
3555
|
var value = _ref.value,
|
|
@@ -3707,6 +4034,36 @@ function registerLayout(reg) {
|
|
|
3707
4034
|
if (value.value === 'auto') return [decl('z-index', 'auto')];
|
|
3708
4035
|
return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
|
|
3709
4036
|
});
|
|
4037
|
+
reg.dynamicRule('columns', function (_ref2) {
|
|
4038
|
+
var value = _ref2.value;
|
|
4039
|
+
if (!value) return null;
|
|
4040
|
+
if (value.kind === 'arbitrary') return [decl('columns', value.value)];
|
|
4041
|
+
if (value.value === 'auto' || /^\d+$/.test(value.value)) return [decl('columns', value.value)];
|
|
4042
|
+
return null;
|
|
4043
|
+
});
|
|
4044
|
+
|
|
4045
|
+
// Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
|
|
4046
|
+
// (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
|
|
4047
|
+
props(reg, 'scroll-snap-type', {
|
|
4048
|
+
'snap-none': 'none',
|
|
4049
|
+
'snap-x': 'x var(--flx-scroll-snap-strictness)',
|
|
4050
|
+
'snap-y': 'y var(--flx-scroll-snap-strictness)',
|
|
4051
|
+
'snap-both': 'both var(--flx-scroll-snap-strictness)'
|
|
4052
|
+
});
|
|
4053
|
+
props(reg, '--flx-scroll-snap-strictness', {
|
|
4054
|
+
'snap-mandatory': 'mandatory',
|
|
4055
|
+
'snap-proximity': 'proximity'
|
|
4056
|
+
});
|
|
4057
|
+
props(reg, 'scroll-snap-align', {
|
|
4058
|
+
'snap-start': 'start',
|
|
4059
|
+
'snap-end': 'end',
|
|
4060
|
+
'snap-center': 'center',
|
|
4061
|
+
'snap-align-none': 'none'
|
|
4062
|
+
});
|
|
4063
|
+
props(reg, 'scroll-snap-stop', {
|
|
4064
|
+
'snap-normal': 'normal',
|
|
4065
|
+
'snap-always': 'always'
|
|
4066
|
+
});
|
|
3710
4067
|
}
|
|
3711
4068
|
var OVERFLOW = {
|
|
3712
4069
|
auto: 'auto',
|
|
@@ -3716,11 +4073,11 @@ var OVERFLOW = {
|
|
|
3716
4073
|
scroll: 'scroll'
|
|
3717
4074
|
};
|
|
3718
4075
|
function inset(reg, root, props) {
|
|
3719
|
-
reg.dynamicRule(root, function (
|
|
3720
|
-
var value =
|
|
3721
|
-
negative =
|
|
3722
|
-
modifier =
|
|
3723
|
-
theme =
|
|
4076
|
+
reg.dynamicRule(root, function (_ref3) {
|
|
4077
|
+
var value = _ref3.value,
|
|
4078
|
+
negative = _ref3.negative,
|
|
4079
|
+
modifier = _ref3.modifier,
|
|
4080
|
+
theme = _ref3.theme;
|
|
3724
4081
|
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3725
4082
|
return decl(p, 'auto');
|
|
3726
4083
|
});
|
|
@@ -3770,6 +4127,29 @@ function registerSpacing(reg) {
|
|
|
3770
4127
|
props = _Object$entries$_i[1];
|
|
3771
4128
|
spacing(reg, root, props, root[0] === 'm');
|
|
3772
4129
|
}
|
|
4130
|
+
spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
|
|
4131
|
+
spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
// Only the space *between* siblings, applied to every child after the first via
|
|
4135
|
+
// the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
|
|
4136
|
+
// margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
|
|
4137
|
+
var BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
|
|
4138
|
+
function spaceBetween(reg, axis, startProp, endProp) {
|
|
4139
|
+
var flag = "--flx-space-".concat(axis, "-reverse");
|
|
4140
|
+
reg.dynamicRule("space-".concat(axis), function (_ref) {
|
|
4141
|
+
var value = _ref.value,
|
|
4142
|
+
negative = _ref.negative,
|
|
4143
|
+
theme = _ref.theme;
|
|
4144
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
|
|
4145
|
+
return [rule(BETWEEN, [decl(flag, '1')])];
|
|
4146
|
+
}
|
|
4147
|
+
var v = sizeValue(value, theme, {
|
|
4148
|
+
negative: negative
|
|
4149
|
+
});
|
|
4150
|
+
if (!v) return null;
|
|
4151
|
+
return [rule(BETWEEN, [decl(flag, '0'), decl(startProp, "calc(".concat(v, " * calc(1 - var(").concat(flag, ")))")), decl(endProp, "calc(".concat(v, " * var(").concat(flag, "))"))])];
|
|
4152
|
+
});
|
|
3773
4153
|
}
|
|
3774
4154
|
|
|
3775
4155
|
// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
|
|
@@ -3797,10 +4177,10 @@ var SPACING = {
|
|
|
3797
4177
|
'scroll-p': ['scroll-padding']
|
|
3798
4178
|
};
|
|
3799
4179
|
function spacing(reg, root, props, allowAuto) {
|
|
3800
|
-
reg.dynamicRule(root, function (
|
|
3801
|
-
var value =
|
|
3802
|
-
negative =
|
|
3803
|
-
theme =
|
|
4180
|
+
reg.dynamicRule(root, function (_ref2) {
|
|
4181
|
+
var value = _ref2.value,
|
|
4182
|
+
negative = _ref2.negative,
|
|
4183
|
+
theme = _ref2.theme;
|
|
3804
4184
|
if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3805
4185
|
return decl(p, 'auto');
|
|
3806
4186
|
});
|
|
@@ -4054,6 +4434,12 @@ function registerTypography(reg) {
|
|
|
4054
4434
|
var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
|
|
4055
4435
|
return t ? [decl('letter-spacing', t)] : null;
|
|
4056
4436
|
});
|
|
4437
|
+
reg.dynamicRule('content', function (_ref4) {
|
|
4438
|
+
var value = _ref4.value;
|
|
4439
|
+
if (!value) return null;
|
|
4440
|
+
if (value.kind === 'arbitrary') return [decl('content', value.value)];
|
|
4441
|
+
return value.value === 'none' ? [decl('content', 'none')] : null;
|
|
4442
|
+
});
|
|
4057
4443
|
}
|
|
4058
4444
|
var WEIGHTS = {
|
|
4059
4445
|
thin: '100',
|
|
@@ -4142,6 +4528,18 @@ function registerVariants(reg) {
|
|
|
4142
4528
|
reg.variant('ltr', {
|
|
4143
4529
|
selector: '&:where([dir="ltr"], [dir="ltr"] *)'
|
|
4144
4530
|
});
|
|
4531
|
+
reg.variant('*', {
|
|
4532
|
+
selector: '& > *'
|
|
4533
|
+
}); // direct children
|
|
4534
|
+
reg.variant('**', {
|
|
4535
|
+
selector: '& *'
|
|
4536
|
+
}); // all descendants
|
|
4537
|
+
reg.variant('open', {
|
|
4538
|
+
selector: '&:is([open], :open)'
|
|
4539
|
+
});
|
|
4540
|
+
reg.variant('inert', {
|
|
4541
|
+
selector: '&:is([inert], [inert] *)'
|
|
4542
|
+
});
|
|
4145
4543
|
registerBreakpointVariants(reg);
|
|
4146
4544
|
|
|
4147
4545
|
// `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
|
|
@@ -4159,11 +4557,11 @@ function registerVariants(reg) {
|
|
|
4159
4557
|
reg.dynamicVariant('max', function (v) {
|
|
4160
4558
|
return mediaWidth('max-width', width(v));
|
|
4161
4559
|
});
|
|
4162
|
-
reg.dynamicVariant('group', function (v) {
|
|
4163
|
-
return relational(v, '.group', ' &');
|
|
4560
|
+
reg.dynamicVariant('group', function (v, m) {
|
|
4561
|
+
return relational(v, m, '.group', ' &');
|
|
4164
4562
|
});
|
|
4165
|
-
reg.dynamicVariant('peer', function (v) {
|
|
4166
|
-
return relational(v, '.peer', ' ~ &');
|
|
4563
|
+
reg.dynamicVariant('peer', function (v, m) {
|
|
4564
|
+
return relational(v, m, '.peer', ' ~ &');
|
|
4167
4565
|
});
|
|
4168
4566
|
reg.dynamicVariant('data', function (v) {
|
|
4169
4567
|
return named(v) ? {
|
|
@@ -4181,9 +4579,7 @@ function registerVariants(reg) {
|
|
|
4181
4579
|
} : null;
|
|
4182
4580
|
});
|
|
4183
4581
|
reg.dynamicVariant('not', function (v) {
|
|
4184
|
-
return
|
|
4185
|
-
selector: "&:not(".concat(named(v), ")")
|
|
4186
|
-
} : null;
|
|
4582
|
+
return notVariant(reg, v);
|
|
4187
4583
|
});
|
|
4188
4584
|
reg.dynamicVariant('supports', function (v) {
|
|
4189
4585
|
return named(v) ? {
|
|
@@ -4273,16 +4669,34 @@ function named(v) {
|
|
|
4273
4669
|
}
|
|
4274
4670
|
|
|
4275
4671
|
// `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
|
-
|
|
4672
|
+
// is a pseudo-class, an arbitrary one is a raw selector fragment. A `/name`
|
|
4673
|
+
// modifier scopes to a named group/peer (`group-hover/item` → `.group\/item:hover`).
|
|
4674
|
+
function relational(v, m, base, tail) {
|
|
4278
4675
|
var value = named(v);
|
|
4279
4676
|
if (!value) return null;
|
|
4280
4677
|
var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
|
|
4678
|
+
var scope = m ? "".concat(base, "\\/").concat(m.value) : base;
|
|
4281
4679
|
return {
|
|
4282
|
-
selector: "".concat(
|
|
4680
|
+
selector: "".concat(scope).concat(cond).concat(tail)
|
|
4283
4681
|
};
|
|
4284
4682
|
}
|
|
4285
4683
|
|
|
4684
|
+
// `not-hover` → `&:not(:hover)`, `not-first` → `&:not(:first-child)`: resolve the
|
|
4685
|
+
// inner variant's pseudo, so the selector is valid (not the literal name). Only
|
|
4686
|
+
// simple pseudo variants compose; `not-[…]` takes an arbitrary selector.
|
|
4687
|
+
function notVariant(reg, v) {
|
|
4688
|
+
var _reg$getVariant;
|
|
4689
|
+
var value = named(v);
|
|
4690
|
+
if (!value) return null;
|
|
4691
|
+
if (v.kind === 'arbitrary') return {
|
|
4692
|
+
selector: "&:not(".concat(value, ")")
|
|
4693
|
+
};
|
|
4694
|
+
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();
|
|
4695
|
+
return frag && frag.startsWith(':') ? {
|
|
4696
|
+
selector: "&:not(".concat(frag, ")")
|
|
4697
|
+
} : null;
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4286
4700
|
// The batteries-included registry: the default token theme plus the utility
|
|
4287
4701
|
// families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
|
|
4288
4702
|
// build a bare `new Registry(theme)` and register their own.
|
|
@@ -4598,11 +5012,14 @@ var MARKER = 'fluixi';
|
|
|
4598
5012
|
// directives are consumed, and an `@fluixi;` marker is replaced by the generated
|
|
4599
5013
|
// token `:root` + utilities. With no marker the generated block is appended.
|
|
4600
5014
|
function transform(input) {
|
|
4601
|
-
var _options$registry, _options$classes, _options$from, _options$sources;
|
|
5015
|
+
var _options$registry, _options$classes, _options$from, _options$resetFrom, _options$sources;
|
|
4602
5016
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5017
|
+
var started = performance.now();
|
|
4603
5018
|
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
4604
|
-
loadTheme(
|
|
5019
|
+
if (options.theme) loadTheme(options.theme, reg.theme);
|
|
5020
|
+
loadTheme(input, reg.theme); // the input's own @theme overrides the base
|
|
4605
5021
|
registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides
|
|
5022
|
+
if (options.theme) loadDirectives(options.theme, reg);
|
|
4606
5023
|
loadDirectives(input, reg);
|
|
4607
5024
|
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4608
5025
|
var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
@@ -4704,7 +5121,8 @@ function transform(input) {
|
|
|
4704
5121
|
var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
|
|
4705
5122
|
var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
|
|
4706
5123
|
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
4707
|
-
|
|
5124
|
+
var text = expandApply(input.slice(start.offset, end.offset), reg);
|
|
5125
|
+
nodes.push(raw(text, {
|
|
4708
5126
|
source: from,
|
|
4709
5127
|
line: start.line,
|
|
4710
5128
|
column: Math.max(0, start.column - 1)
|
|
@@ -4717,30 +5135,48 @@ function transform(input) {
|
|
|
4717
5135
|
_iterator5.f();
|
|
4718
5136
|
}
|
|
4719
5137
|
if (!injected) nodes.push.apply(nodes, generated);
|
|
4720
|
-
|
|
5138
|
+
var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
|
|
5139
|
+
if (options.reset) nodes.unshift(raw(options.reset, {
|
|
5140
|
+
source: resetFrom,
|
|
5141
|
+
line: 1,
|
|
5142
|
+
column: 0
|
|
5143
|
+
}));
|
|
5144
|
+
var css;
|
|
5145
|
+
var map;
|
|
4721
5146
|
if (options.sourceMap) {
|
|
4722
|
-
var
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
map.setSourceContent(
|
|
4728
|
-
var json = map.toJSON();
|
|
5147
|
+
var out = stringifyWithMap(nodes, {
|
|
5148
|
+
minify: options.minify
|
|
5149
|
+
});
|
|
5150
|
+
css = out.css;
|
|
5151
|
+
out.map.setSourceContent(from, input);
|
|
5152
|
+
if (options.reset) out.map.setSourceContent(resetFrom, options.reset);
|
|
5153
|
+
var json = out.map.toJSON();
|
|
4729
5154
|
json.file = from;
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
classes: _toConsumableArray(classes),
|
|
4734
|
-
sources: sources,
|
|
4735
|
-
registry: reg
|
|
4736
|
-
};
|
|
4737
|
-
}
|
|
4738
|
-
return {
|
|
4739
|
-
css: stringify(nodes, {
|
|
5155
|
+
map = json;
|
|
5156
|
+
} else {
|
|
5157
|
+
css = stringify(nodes, {
|
|
4740
5158
|
minify: options.minify
|
|
4741
|
-
})
|
|
5159
|
+
});
|
|
5160
|
+
}
|
|
5161
|
+
var stats = {
|
|
5162
|
+
ms: performance.now() - started,
|
|
5163
|
+
scanned: classes.size,
|
|
5164
|
+
utilities: rules.length,
|
|
5165
|
+
bytes: css.length,
|
|
5166
|
+
sources: sources.length
|
|
5167
|
+
};
|
|
5168
|
+
return map ? {
|
|
5169
|
+
css: css,
|
|
5170
|
+
map: map,
|
|
5171
|
+
classes: _toConsumableArray(classes),
|
|
5172
|
+
sources: sources,
|
|
5173
|
+
stats: stats,
|
|
5174
|
+
registry: reg
|
|
5175
|
+
} : {
|
|
5176
|
+
css: css,
|
|
4742
5177
|
classes: _toConsumableArray(classes),
|
|
4743
5178
|
sources: sources,
|
|
5179
|
+
stats: stats,
|
|
4744
5180
|
registry: reg
|
|
4745
5181
|
};
|
|
4746
5182
|
}
|
|
@@ -4772,10 +5208,12 @@ function compile(input) {
|
|
|
4772
5208
|
var _options$registry, _options$classes, _options$sources;
|
|
4773
5209
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4774
5210
|
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
5211
|
+
if (options.theme) loadTheme(options.theme, reg.theme);
|
|
4775
5212
|
loadTheme(input, reg.theme);
|
|
4776
5213
|
// Re-seed the named breakpoint variants so a `@theme` breakpoint override reaches
|
|
4777
5214
|
// `sm:`/`md:`/… (they baked the default value at registry-creation time).
|
|
4778
5215
|
registerBreakpointVariants(reg);
|
|
5216
|
+
if (options.theme) loadDirectives(options.theme, reg);
|
|
4779
5217
|
loadDirectives(input, reg);
|
|
4780
5218
|
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4781
5219
|
var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
@@ -4874,5 +5312,5 @@ function compile(input) {
|
|
|
4874
5312
|
};
|
|
4875
5313
|
}
|
|
4876
5314
|
|
|
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 };
|
|
5315
|
+
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, uiTokenBridges };
|
|
4878
5316
|
//# sourceMappingURL=index.mjs.map
|