@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.mjs
CHANGED
|
@@ -591,9 +591,15 @@ function parseAtom(raw) {
|
|
|
591
591
|
if (arbProp !== null && arbProp.includes(':')) {
|
|
592
592
|
var colon = arbProp.indexOf(':');
|
|
593
593
|
if (colon <= 0) return null;
|
|
594
|
+
// The head must be a real CSS property or custom property. Scanners pull
|
|
595
|
+
// `[...]` runs out of JS/TS too (array/object literals like
|
|
596
|
+
// `[...prev, { value } as T]`); rejecting a non-property head keeps those
|
|
597
|
+
// from emitting broken rules that later crash the CSS parser.
|
|
598
|
+
var property = arbProp.slice(0, colon);
|
|
599
|
+
if (!/^-{0,2}[a-zA-Z][a-zA-Z0-9-]*$/.test(property)) return null;
|
|
594
600
|
return {
|
|
595
601
|
kind: 'arbitrary-property',
|
|
596
|
-
property:
|
|
602
|
+
property: property,
|
|
597
603
|
value: decodeUnderscores(arbProp.slice(colon + 1)),
|
|
598
604
|
modifier: modifier,
|
|
599
605
|
important: important,
|
|
@@ -4905,8 +4911,18 @@ function scanSourceFiles(files) {
|
|
|
4905
4911
|
// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
|
|
4906
4912
|
// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
|
|
4907
4913
|
// so a fluixi-css theme *drives* the UI — change the theme, the components follow —
|
|
4908
|
-
// without copying any values across. A bridge is emitted only when its
|
|
4909
|
-
// token exists, so the UI's own defaults stand in for anything the theme omits.
|
|
4914
|
+
// without copying any values across. A primitive bridge is emitted only when its
|
|
4915
|
+
// source token exists, so the UI's own defaults stand in for anything the theme omits.
|
|
4916
|
+
//
|
|
4917
|
+
// Colour is the driven half: when the theme supplies the functional scales
|
|
4918
|
+
// (`--color-accent-1..12` / `--color-gray-1..12`), this also emits the UI's whole
|
|
4919
|
+
// *semantic* layer (`--flx-ui-color-primary`, …). That layer is purely structural —
|
|
4920
|
+
// every var references a scale/alias var, never a concrete colour — so it carries no
|
|
4921
|
+
// palette data across the package boundary; `@fluixi-ui/tokens` still owns the
|
|
4922
|
+
// default values. The semantic layer is re-emitted in a dark scope because
|
|
4923
|
+
// custom-property substitution freezes at the declaring element: a `:root`-only
|
|
4924
|
+
// `--flx-ui-color-primary: var(--flx-ui-accent-9)` would inherit light's *resolved*
|
|
4925
|
+
// colour into a dark subtree instead of re-resolving against the dark scale.
|
|
4910
4926
|
|
|
4911
4927
|
// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
|
|
4912
4928
|
var SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
|
|
@@ -4916,6 +4932,24 @@ var FONT_SIZE = [['xs', 'xs'], ['sm', 'sm'], ['md', 'base'], ['lg', 'lg'], ['xl'
|
|
|
4916
4932
|
var RADIUS = ['sm', 'md', 'lg', 'xl'];
|
|
4917
4933
|
var SHADOW = ['sm', 'md', 'lg', 'xl'];
|
|
4918
4934
|
var BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
4935
|
+
|
|
4936
|
+
// The UI's semantic layer, mirrored from `@fluixi-ui/tokens` (`semanticColors`).
|
|
4937
|
+
// Structural only — refs into the scales/aliases the bridge (or the UI's own
|
|
4938
|
+
// defaults) provide. `color-primary-fg` and `color-overlay` are intentionally
|
|
4939
|
+
// omitted: they're concrete kit defaults, not scale-derived, so the UI package
|
|
4940
|
+
// keeps ownership of them.
|
|
4941
|
+
var SEMANTIC = [['color-bg', 'gray-1'], ['color-bg-subtle', 'gray-2'], ['color-bg-muted', 'gray-3'], ['color-fg', 'gray-12'], ['color-fg-muted', 'gray-11'], ['color-border', 'gray-6'], ['color-border-strong', 'gray-7'], ['color-focus-ring', 'accent-8'], ['color-primary', 'accent-9'], ['color-primary-hover', 'accent-10'], ['color-primary-active', 'accent-11'], ['color-primary-subtle', 'accent-3'], ['color-danger', 'danger-solid'], ['color-danger-fg', 'danger-fg'], ['color-danger-subtle', 'danger-subtle'], ['color-success', 'success-solid'], ['color-success-fg', 'success-fg'], ['color-success-subtle', 'success-subtle'], ['color-warning', 'warning-solid'], ['color-warning-fg', 'warning-fg'], ['color-warning-subtle', 'warning-subtle']];
|
|
4942
|
+
|
|
4943
|
+
// Optional status-colour bridges: a theme may drive the UI's danger/success/
|
|
4944
|
+
// warning solids by supplying `--color-danger` / `--color-success` / `--color-warning`.
|
|
4945
|
+
var STATUS = [['danger-solid', '--color-danger'], ['success-solid', '--color-success'], ['warning-solid', '--color-warning']];
|
|
4946
|
+
|
|
4947
|
+
/** True once the theme supplies enough of the functional scales to drive colour. */
|
|
4948
|
+
function hasColorScales(theme) {
|
|
4949
|
+
return theme.has('--color-accent-9') || theme.has('--color-gray-1');
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
/** The primitive + scale bridges (non-colour and the raw scale refs). */
|
|
4919
4953
|
function uiTokenBridges(theme) {
|
|
4920
4954
|
var out = [];
|
|
4921
4955
|
var bridge = function bridge(flx, source) {
|
|
@@ -4981,10 +5015,8 @@ function uiTokenBridges(theme) {
|
|
|
4981
5015
|
bridge("breakpoint-".concat(_k2), "--breakpoint-".concat(_k2));
|
|
4982
5016
|
}
|
|
4983
5017
|
|
|
4984
|
-
//
|
|
4985
|
-
//
|
|
4986
|
-
// semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
|
|
4987
|
-
// built-in scales stand.
|
|
5018
|
+
// Functional colour scales are opt-in: supply a Radix-style 1..12 ramp and the
|
|
5019
|
+
// UI's semantic colours follow. Absent them, the UI's built-in scales stand.
|
|
4988
5020
|
} catch (err) {
|
|
4989
5021
|
_iterator5.e(err);
|
|
4990
5022
|
} finally {
|
|
@@ -4994,13 +5026,71 @@ function uiTokenBridges(theme) {
|
|
|
4994
5026
|
bridge("accent-".concat(i), "--color-accent-".concat(i));
|
|
4995
5027
|
bridge("gray-".concat(i), "--color-gray-".concat(i));
|
|
4996
5028
|
}
|
|
5029
|
+
var _iterator6 = _createForOfIteratorHelper(STATUS),
|
|
5030
|
+
_step6;
|
|
5031
|
+
try {
|
|
5032
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
5033
|
+
var _step6$value = _slicedToArray(_step6.value, 2),
|
|
5034
|
+
_flx = _step6$value[0],
|
|
5035
|
+
source = _step6$value[1];
|
|
5036
|
+
bridge(_flx, source);
|
|
5037
|
+
}
|
|
5038
|
+
} catch (err) {
|
|
5039
|
+
_iterator6.e(err);
|
|
5040
|
+
} finally {
|
|
5041
|
+
_iterator6.f();
|
|
5042
|
+
}
|
|
4997
5043
|
return out;
|
|
4998
5044
|
}
|
|
4999
5045
|
|
|
5000
|
-
|
|
5046
|
+
/** The structural semantic layer — emitted only when the theme drives colour. */
|
|
5047
|
+
function uiSemanticLayer(theme) {
|
|
5048
|
+
if (!hasColorScales(theme)) return [];
|
|
5049
|
+
return SEMANTIC.map(function (_ref) {
|
|
5050
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
5051
|
+
name = _ref2[0],
|
|
5052
|
+
ref = _ref2[1];
|
|
5053
|
+
return decl("--flx-ui-".concat(name), "var(--flx-ui-".concat(ref, ")"));
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
5056
|
+
/**
|
|
5057
|
+
* The bridges as sibling top-level rules, ready to prepend to the compiled sheet:
|
|
5058
|
+
* `:root` (primitives + scales + semantic layer) and, when the theme drives
|
|
5059
|
+
* colour, a dark-scope re-emit of the colour half so its `var()` refs re-resolve
|
|
5060
|
+
* against the theme's dark-scoped `--color-*` values.
|
|
5061
|
+
*/
|
|
5001
5062
|
function emitUiTheme(theme) {
|
|
5002
|
-
var
|
|
5003
|
-
|
|
5063
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5064
|
+
var _options$selector = options.selector,
|
|
5065
|
+
selector = _options$selector === void 0 ? ':root' : _options$selector,
|
|
5066
|
+
_options$darkSelector = options.darkSelector,
|
|
5067
|
+
darkSelector = _options$darkSelector === void 0 ? "[data-theme='dark']" : _options$darkSelector;
|
|
5068
|
+
var out = [rule(selector, [].concat(_toConsumableArray(uiTokenBridges(theme)), _toConsumableArray(uiSemanticLayer(theme))))];
|
|
5069
|
+
if (darkSelector && hasColorScales(theme)) {
|
|
5070
|
+
// Re-emit only the colour half in the dark scope (primitives don't flip).
|
|
5071
|
+
var darkColor = [];
|
|
5072
|
+
for (var i = 1; i <= 12; i++) {
|
|
5073
|
+
if (theme.has("--color-accent-".concat(i))) darkColor.push(decl("--flx-ui-accent-".concat(i), "var(--color-accent-".concat(i, ")")));
|
|
5074
|
+
if (theme.has("--color-gray-".concat(i))) darkColor.push(decl("--flx-ui-gray-".concat(i), "var(--color-gray-".concat(i, ")")));
|
|
5075
|
+
}
|
|
5076
|
+
var _iterator7 = _createForOfIteratorHelper(STATUS),
|
|
5077
|
+
_step7;
|
|
5078
|
+
try {
|
|
5079
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
5080
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
5081
|
+
flx = _step7$value[0],
|
|
5082
|
+
source = _step7$value[1];
|
|
5083
|
+
if (theme.has(source)) darkColor.push(decl("--flx-ui-".concat(flx), "var(".concat(source, ")")));
|
|
5084
|
+
}
|
|
5085
|
+
} catch (err) {
|
|
5086
|
+
_iterator7.e(err);
|
|
5087
|
+
} finally {
|
|
5088
|
+
_iterator7.f();
|
|
5089
|
+
}
|
|
5090
|
+
darkColor.push.apply(darkColor, _toConsumableArray(uiSemanticLayer(theme)));
|
|
5091
|
+
out.push(rule(darkSelector, darkColor));
|
|
5092
|
+
}
|
|
5093
|
+
return out;
|
|
5004
5094
|
}
|
|
5005
5095
|
|
|
5006
5096
|
// Directives consumed to build the registry — dropped from the output.
|
|
@@ -5091,19 +5181,16 @@ function transform(input) {
|
|
|
5091
5181
|
} finally {
|
|
5092
5182
|
_iterator4.f();
|
|
5093
5183
|
}
|
|
5094
|
-
var
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
}
|
|
5102
|
-
if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);
|
|
5103
|
-
generated.push.apply(generated, rules);
|
|
5184
|
+
var uiBlocks = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
5185
|
+
|
|
5186
|
+
// Pass the author CSS through first (expanding `@apply`), remembering where the
|
|
5187
|
+
// `@fluixi` marker sits so the generated block splices in at that point. Building
|
|
5188
|
+
// it up front lets the token tree-shake also see the author's own `var()` refs —
|
|
5189
|
+
// a hand-written or `@apply`-injected `var(--color-x)` must keep `--color-x`
|
|
5190
|
+
// alive, else the token is stripped and the reference resolves to nothing.
|
|
5104
5191
|
var from = (_options$from = options.from) !== null && _options$from !== void 0 ? _options$from : '<input>';
|
|
5105
|
-
var
|
|
5106
|
-
var
|
|
5192
|
+
var authorNodes = [];
|
|
5193
|
+
var markerAt = -1;
|
|
5107
5194
|
var _iterator5 = _createForOfIteratorHelper(parseCss(input).children),
|
|
5108
5195
|
_step5;
|
|
5109
5196
|
try {
|
|
@@ -5111,10 +5198,7 @@ function transform(input) {
|
|
|
5111
5198
|
var _node$loc, _node$loc2;
|
|
5112
5199
|
var node = _step5.value;
|
|
5113
5200
|
if (node.type === 'atrule' && node.name === MARKER) {
|
|
5114
|
-
if (
|
|
5115
|
-
nodes.push.apply(nodes, generated);
|
|
5116
|
-
injected = true;
|
|
5117
|
-
}
|
|
5201
|
+
if (markerAt < 0) markerAt = authorNodes.length;
|
|
5118
5202
|
continue;
|
|
5119
5203
|
}
|
|
5120
5204
|
if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;
|
|
@@ -5122,7 +5206,7 @@ function transform(input) {
|
|
|
5122
5206
|
var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
|
|
5123
5207
|
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
5124
5208
|
var text = expandApply(input.slice(start.offset, end.offset), reg);
|
|
5125
|
-
|
|
5209
|
+
authorNodes.push(raw(text, {
|
|
5126
5210
|
source: from,
|
|
5127
5211
|
line: start.line,
|
|
5128
5212
|
column: Math.max(0, start.column - 1)
|
|
@@ -5134,7 +5218,19 @@ function transform(input) {
|
|
|
5134
5218
|
} finally {
|
|
5135
5219
|
_iterator5.f();
|
|
5136
5220
|
}
|
|
5137
|
-
|
|
5221
|
+
var generated = [];
|
|
5222
|
+
if (options.emitTokens !== false) {
|
|
5223
|
+
var used = collectVarRefs(rules);
|
|
5224
|
+
if (uiBlocks) collectVarRefs(uiBlocks, used);
|
|
5225
|
+
collectVarRefs(authorNodes, used); // keep tokens the author CSS references by hand / via @apply
|
|
5226
|
+
var tokens = emitTheme(reg.theme, ':root', used);
|
|
5227
|
+
if (tokens.nodes.length) generated.push(tokens);
|
|
5228
|
+
}
|
|
5229
|
+
if (uiBlocks) generated.push.apply(generated, _toConsumableArray(uiBlocks.filter(function (b) {
|
|
5230
|
+
return b.nodes.length;
|
|
5231
|
+
})));
|
|
5232
|
+
generated.push.apply(generated, rules);
|
|
5233
|
+
var nodes = markerAt >= 0 ? [].concat(_toConsumableArray(authorNodes.slice(0, markerAt)), generated, _toConsumableArray(authorNodes.slice(markerAt))) : [].concat(authorNodes, generated);
|
|
5138
5234
|
var resetFrom = (_options$resetFrom = options.resetFrom) !== null && _options$resetFrom !== void 0 ? _options$resetFrom : 'fluixi:reset.css';
|
|
5139
5235
|
if (options.reset) nodes.unshift(raw(options.reset, {
|
|
5140
5236
|
source: resetFrom,
|
|
@@ -5290,17 +5386,19 @@ function compile(input) {
|
|
|
5290
5386
|
} finally {
|
|
5291
5387
|
_iterator5.f();
|
|
5292
5388
|
}
|
|
5293
|
-
var
|
|
5389
|
+
var uiBlocks = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
5294
5390
|
|
|
5295
5391
|
// Emit only the tokens the compiled rules (and any UI bridge) actually reference.
|
|
5296
5392
|
var nodes = [];
|
|
5297
5393
|
if (options.emitTokens !== false) {
|
|
5298
5394
|
var used = collectVarRefs(rules);
|
|
5299
|
-
if (
|
|
5395
|
+
if (uiBlocks) collectVarRefs(uiBlocks, used);
|
|
5300
5396
|
var tokens = emitTheme(reg.theme, ':root', used);
|
|
5301
5397
|
if (tokens.nodes.length) nodes.push(tokens);
|
|
5302
5398
|
}
|
|
5303
|
-
if (
|
|
5399
|
+
if (uiBlocks) nodes.push.apply(nodes, _toConsumableArray(uiBlocks.filter(function (b) {
|
|
5400
|
+
return b.nodes.length;
|
|
5401
|
+
})));
|
|
5304
5402
|
nodes.push.apply(nodes, rules);
|
|
5305
5403
|
return {
|
|
5306
5404
|
css: stringify(nodes, {
|
|
@@ -5312,5 +5410,5 @@ function compile(input) {
|
|
|
5312
5410
|
};
|
|
5313
5411
|
}
|
|
5314
5412
|
|
|
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 };
|
|
5413
|
+
export { Registry, SPECIAL_COLORS, Theme, atRule, collectVarRefs, colorValue, compile, compileAtom, compileClasses, createRegistry, decl, decodeUnderscores, defaultTheme, emitTheme, emitUiTheme, escapeClass, expandApply, formatBuildLog, keywords, loadDirectives, loadTheme, parseAtom, parseSources, parseVariant, props, raw, registerBreakpointVariants, registerUtilities, registerVariants, resolveSourceFiles, rule, scanAtoms, scanSourceFiles, sizeValue, splitAtTopLevel, statics, stringify, stringifyWithMap, transform, uiSemanticLayer, uiTokenBridges };
|
|
5316
5414
|
//# sourceMappingURL=index.mjs.map
|