@fluixi-css/core 1.0.0-next.2 → 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/src/engine/atom.js +8 -1
- package/dist/src/engine/atom.js.map +1 -1
- package/dist/src/engine/index.js +5 -5
- package/dist/src/engine/index.js.map +1 -1
- package/dist/src/engine/transform.js +27 -22
- 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/index.cjs +130 -31
- package/dist/src/index.cjs.map +1 -1
- package/dist/src/index.mjs +130 -32
- package/dist/src/index.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/index.cjs
CHANGED
|
@@ -593,9 +593,15 @@ function parseAtom(raw) {
|
|
|
593
593
|
if (arbProp !== null && arbProp.includes(':')) {
|
|
594
594
|
var colon = arbProp.indexOf(':');
|
|
595
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;
|
|
596
602
|
return {
|
|
597
603
|
kind: 'arbitrary-property',
|
|
598
|
-
property:
|
|
604
|
+
property: property,
|
|
599
605
|
value: decodeUnderscores(arbProp.slice(colon + 1)),
|
|
600
606
|
modifier: modifier,
|
|
601
607
|
important: important,
|
|
@@ -4907,8 +4913,18 @@ function scanSourceFiles(files) {
|
|
|
4907
4913
|
// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
|
|
4908
4914
|
// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
|
|
4909
4915
|
// so a fluixi-css theme *drives* the UI — change the theme, the components follow —
|
|
4910
|
-
// without copying any values across. A bridge is emitted only when its
|
|
4911
|
-
// 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.
|
|
4912
4928
|
|
|
4913
4929
|
// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
|
|
4914
4930
|
var SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
|
|
@@ -4918,6 +4934,24 @@ var FONT_SIZE = [['xs', 'xs'], ['sm', 'sm'], ['md', 'base'], ['lg', 'lg'], ['xl'
|
|
|
4918
4934
|
var RADIUS = ['sm', 'md', 'lg', 'xl'];
|
|
4919
4935
|
var SHADOW = ['sm', 'md', 'lg', 'xl'];
|
|
4920
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). */
|
|
4921
4955
|
function uiTokenBridges(theme) {
|
|
4922
4956
|
var out = [];
|
|
4923
4957
|
var bridge = function bridge(flx, source) {
|
|
@@ -4983,10 +5017,8 @@ function uiTokenBridges(theme) {
|
|
|
4983
5017
|
bridge("breakpoint-".concat(_k2), "--breakpoint-".concat(_k2));
|
|
4984
5018
|
}
|
|
4985
5019
|
|
|
4986
|
-
//
|
|
4987
|
-
//
|
|
4988
|
-
// semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
|
|
4989
|
-
// 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.
|
|
4990
5022
|
} catch (err) {
|
|
4991
5023
|
_iterator5.e(err);
|
|
4992
5024
|
} finally {
|
|
@@ -4996,13 +5028,71 @@ function uiTokenBridges(theme) {
|
|
|
4996
5028
|
bridge("accent-".concat(i), "--color-accent-".concat(i));
|
|
4997
5029
|
bridge("gray-".concat(i), "--color-gray-".concat(i));
|
|
4998
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
|
+
}
|
|
4999
5045
|
return out;
|
|
5000
5046
|
}
|
|
5001
5047
|
|
|
5002
|
-
|
|
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
|
+
*/
|
|
5003
5064
|
function emitUiTheme(theme) {
|
|
5004
|
-
var
|
|
5005
|
-
|
|
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;
|
|
5006
5096
|
}
|
|
5007
5097
|
|
|
5008
5098
|
// Directives consumed to build the registry — dropped from the output.
|
|
@@ -5093,19 +5183,16 @@ function transform(input) {
|
|
|
5093
5183
|
} finally {
|
|
5094
5184
|
_iterator4.f();
|
|
5095
5185
|
}
|
|
5096
|
-
var
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
}
|
|
5104
|
-
if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);
|
|
5105
|
-
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.
|
|
5106
5193
|
var from = (_options$from = options.from) !== null && _options$from !== void 0 ? _options$from : '<input>';
|
|
5107
|
-
var
|
|
5108
|
-
var
|
|
5194
|
+
var authorNodes = [];
|
|
5195
|
+
var markerAt = -1;
|
|
5109
5196
|
var _iterator5 = _createForOfIteratorHelper(parseCss(input).children),
|
|
5110
5197
|
_step5;
|
|
5111
5198
|
try {
|
|
@@ -5113,10 +5200,7 @@ function transform(input) {
|
|
|
5113
5200
|
var _node$loc, _node$loc2;
|
|
5114
5201
|
var node = _step5.value;
|
|
5115
5202
|
if (node.type === 'atrule' && node.name === MARKER) {
|
|
5116
|
-
if (
|
|
5117
|
-
nodes.push.apply(nodes, generated);
|
|
5118
|
-
injected = true;
|
|
5119
|
-
}
|
|
5203
|
+
if (markerAt < 0) markerAt = authorNodes.length;
|
|
5120
5204
|
continue;
|
|
5121
5205
|
}
|
|
5122
5206
|
if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;
|
|
@@ -5124,7 +5208,7 @@ function transform(input) {
|
|
|
5124
5208
|
var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
|
|
5125
5209
|
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
5126
5210
|
var text = expandApply(input.slice(start.offset, end.offset), reg);
|
|
5127
|
-
|
|
5211
|
+
authorNodes.push(raw(text, {
|
|
5128
5212
|
source: from,
|
|
5129
5213
|
line: start.line,
|
|
5130
5214
|
column: Math.max(0, start.column - 1)
|
|
@@ -5136,7 +5220,19 @@ function transform(input) {
|
|
|
5136
5220
|
} finally {
|
|
5137
5221
|
_iterator5.f();
|
|
5138
5222
|
}
|
|
5139
|
-
|
|
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);
|
|
5140
5236
|
var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
|
|
5141
5237
|
if (options.reset) nodes.unshift(raw(options.reset, {
|
|
5142
5238
|
source: resetFrom,
|
|
@@ -5292,17 +5388,19 @@ function compile(input) {
|
|
|
5292
5388
|
} finally {
|
|
5293
5389
|
_iterator5.f();
|
|
5294
5390
|
}
|
|
5295
|
-
var
|
|
5391
|
+
var uiBlocks = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
5296
5392
|
|
|
5297
5393
|
// Emit only the tokens the compiled rules (and any UI bridge) actually reference.
|
|
5298
5394
|
var nodes = [];
|
|
5299
5395
|
if (options.emitTokens !== false) {
|
|
5300
5396
|
var used = collectVarRefs(rules);
|
|
5301
|
-
if (
|
|
5397
|
+
if (uiBlocks) collectVarRefs(uiBlocks, used);
|
|
5302
5398
|
var tokens = emitTheme(reg.theme, ':root', used);
|
|
5303
5399
|
if (tokens.nodes.length) nodes.push(tokens);
|
|
5304
5400
|
}
|
|
5305
|
-
if (
|
|
5401
|
+
if (uiBlocks) nodes.push.apply(nodes, _toConsumableArray(uiBlocks.filter(function (b) {
|
|
5402
|
+
return b.nodes.length;
|
|
5403
|
+
})));
|
|
5306
5404
|
nodes.push.apply(nodes, rules);
|
|
5307
5405
|
return {
|
|
5308
5406
|
css: stringify(nodes, {
|
|
@@ -5353,5 +5451,6 @@ exports.statics = statics;
|
|
|
5353
5451
|
exports.stringify = stringify;
|
|
5354
5452
|
exports.stringifyWithMap = stringifyWithMap;
|
|
5355
5453
|
exports.transform = transform;
|
|
5454
|
+
exports.uiSemanticLayer = uiSemanticLayer;
|
|
5356
5455
|
exports.uiTokenBridges = uiTokenBridges;
|
|
5357
5456
|
//# sourceMappingURL=index.cjs.map
|