@tenphi/tasty 3.9.11 → 3.11.0
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/README.md +399 -380
- package/dist/babel-types-BKDTT4--.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-5d8WlQbq.js +60 -0
- package/dist/chunks/build-config-5d8WlQbq.js.map +1 -0
- package/dist/chunks/{collector-D2ARGT2L.js → collector-CjCak4iE.js} +8 -6
- package/dist/chunks/collector-CjCak4iE.js.map +1 -0
- package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-uOFYZidB.js} +4 -4
- package/dist/chunks/{config-engine-DEmmPPdp.js.map → config-engine-uOFYZidB.js.map} +1 -1
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/{css-definitions-DotDkIXt.js → css-definitions-ubrHP97m.js} +130 -96
- package/dist/chunks/css-definitions-ubrHP97m.js.map +1 -0
- package/dist/chunks/{debug-D8pg9RGI.js → debug-CJ31U_WE.js} +6 -6
- package/dist/chunks/{debug-D8pg9RGI.js.map → debug-CJ31U_WE.js.map} +1 -1
- package/dist/chunks/{dsl-DRhFWQzo.js → dsl-DYSJc1-T.js} +11 -6
- package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
- package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-CyyCI02N.js} +190 -63
- package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
- package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-BQmOu5-W.js} +69 -53
- package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
- package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-DEsyUMU-.js} +28 -3
- package/dist/chunks/runtime-state-DEsyUMU-.js.map +1 -0
- package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-BX2LshDZ.js} +309 -103
- package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
- package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-Dw0P4yGM.js} +62 -27
- package/dist/chunks/zero-engine-Dw0P4yGM.js.map +1 -0
- package/dist/{collector-w4mBj5gd.d.ts → collector-CTU-nl0g.d.ts} +2 -2
- package/dist/{config-CZWCzBr6.d.ts → config-CcxqSZI2.d.ts} +35 -16
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +7 -7
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-G9JuwM9p.d.ts → index-xtey-KDu.d.ts} +43 -13
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -2
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +3 -22
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +13 -18
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-JEY8PVYP.d.ts → types-DJEM_BOJ.d.ts} +6 -6
- package/dist/zero/babel.d.ts +67 -2
- package/dist/zero/babel.js +47 -44
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +58 -3
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +2 -1
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +37 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +174 -59
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +122 -81
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +39 -40
- package/docs/methodology.md +45 -20
- package/docs/migration-v3.md +2 -2
- package/docs/pipeline.md +20 -17
- package/docs/plugins.md +20 -40
- package/docs/react-api.md +28 -8
- package/docs/runtime-benchmarks.md +4 -4
- package/docs/ssr.md +83 -63
- package/docs/styles.md +27 -17
- package/docs/tasty-static.md +142 -55
- package/package.json +24 -10
- package/dist/babel-rZcEwPLM.d.ts +0 -82
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/build-config-CL4eRu2z.js +0 -42
- package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
- package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
- package/dist/chunks/css-definitions-DotDkIXt.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
- package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
- package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
- package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
- package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as toSnakeCase, N as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, j as normalizeDslName, u as normalizeColorTokenValue, w as Lru } from "./dsl-
|
|
1
|
+
import { M as toSnakeCase, N as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, c as getGlobalParser, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, j as normalizeDslName, u as normalizeColorTokenValue, w as Lru } from "./dsl-DYSJc1-T.js";
|
|
2
2
|
import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv } from "./shared-utils-y-HjvPN4.js";
|
|
3
3
|
//#region src/config-state.ts
|
|
4
4
|
let stylesGenerated = false;
|
|
@@ -87,6 +87,10 @@ function setGlobalPredefinedStates(states) {
|
|
|
87
87
|
function getGlobalPredefinedStates() {
|
|
88
88
|
return globalPredefinedStates;
|
|
89
89
|
}
|
|
90
|
+
function clearGlobalPredefinedStates() {
|
|
91
|
+
globalPredefinedStates = {};
|
|
92
|
+
emittedWarnings.clear();
|
|
93
|
+
}
|
|
90
94
|
const PREDEFINED_STATE_PATTERN = /@[A-Za-z][A-Za-z0-9-]*(?![A-Za-z0-9-:(])/g;
|
|
91
95
|
function extractPredefinedStateRefs(value) {
|
|
92
96
|
const matches = value.match(PREDEFINED_STATE_PATTERN);
|
|
@@ -130,8 +134,28 @@ function resolvePredefinedState(stateKey, ctx) {
|
|
|
130
134
|
function expandDimensionShorthands(condition) {
|
|
131
135
|
return condition.replace(/\b(?:w|h|is|bs)\b/g, (dimension) => dimension === "w" ? "width" : dimension === "h" ? "height" : dimension === "is" ? "inline-size" : "block-size");
|
|
132
136
|
}
|
|
137
|
+
const RE_QUERY_UNIT_NUMBER = /(?<![\w.-])(?:\d*\.\d+|\d+)([a-z][a-z0-9]*)\b/g;
|
|
133
138
|
function expandTastyUnits(value) {
|
|
134
|
-
|
|
139
|
+
const units = getGlobalParser().getUnits();
|
|
140
|
+
if (!units) return value;
|
|
141
|
+
return value.replace(RE_QUERY_UNIT_NUMBER, (token, unit) => {
|
|
142
|
+
if (!Object.prototype.hasOwnProperty.call(units, unit)) return token;
|
|
143
|
+
const resolved = parseStyle(token).groups[0]?.values[0] ?? token;
|
|
144
|
+
if (resolved.includes("var(")) warnOnce(`query-unit-var:${unit}`, `[Tasty] Unit '${unit}' resolves to '${resolved}', which @media and @container conditions cannot read: custom properties are not available there. Write '${token}' as a px, em, or rem length.`);
|
|
145
|
+
return resolved;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const RE_LENGTH_FEATURE = /^(?:min-|max-)?(?:width|height|inline-size|block-size)$/;
|
|
149
|
+
const RE_QUERY_OPERATOR = /<=|>=|<|>|=/;
|
|
150
|
+
const RE_FEATURE_NAME = /^[a-z][a-z-]*$/;
|
|
151
|
+
function expandQueryUnits(condition) {
|
|
152
|
+
let feature;
|
|
153
|
+
if (RE_QUERY_OPERATOR.test(condition)) feature = condition.split(RE_QUERY_OPERATOR).map((operand) => operand.trim()).find((operand) => RE_FEATURE_NAME.test(operand));
|
|
154
|
+
else {
|
|
155
|
+
const colonIdx = condition.indexOf(":");
|
|
156
|
+
feature = (colonIdx === -1 ? condition : condition.slice(0, colonIdx)).trim();
|
|
157
|
+
}
|
|
158
|
+
return feature && RE_LENGTH_FEATURE.test(feature) ? expandTastyUnits(condition) : condition;
|
|
135
159
|
}
|
|
136
160
|
function findTopLevelComma(s) {
|
|
137
161
|
let depth = 0;
|
|
@@ -175,6 +199,16 @@ const CHUNK_NAMES = {
|
|
|
175
199
|
};
|
|
176
200
|
const APPEARANCE_CHUNK_STYLES = [
|
|
177
201
|
"fill",
|
|
202
|
+
"backgroundColor",
|
|
203
|
+
"image",
|
|
204
|
+
"backgroundImage",
|
|
205
|
+
"backgroundPosition",
|
|
206
|
+
"backgroundSize",
|
|
207
|
+
"backgroundRepeat",
|
|
208
|
+
"backgroundAttachment",
|
|
209
|
+
"backgroundOrigin",
|
|
210
|
+
"backgroundClip",
|
|
211
|
+
"background",
|
|
178
212
|
"color",
|
|
179
213
|
"opacity",
|
|
180
214
|
"border",
|
|
@@ -299,6 +333,113 @@ function resetStyleChunks() {
|
|
|
299
333
|
for (const [style, chunk] of builtinSnapshot) STYLE_TO_CHUNK.set(style, chunk);
|
|
300
334
|
}
|
|
301
335
|
//#endregion
|
|
336
|
+
//#region src/styles/createStyle.ts
|
|
337
|
+
const CACHE = {};
|
|
338
|
+
function createStyle(styleName, cssStyle, converter) {
|
|
339
|
+
const key = `${styleName}.${cssStyle ?? ""}`;
|
|
340
|
+
if (!CACHE[key]) {
|
|
341
|
+
const styleHandler = (styleMap) => {
|
|
342
|
+
let styleValue = styleMap[styleName];
|
|
343
|
+
if (styleValue == null || styleValue === false) return null;
|
|
344
|
+
let finalCssStyle;
|
|
345
|
+
const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
|
|
346
|
+
if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
|
|
347
|
+
else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
|
|
348
|
+
else finalCssStyle = cssStyle || toSnakeCase(styleName);
|
|
349
|
+
if (isColorToken) {
|
|
350
|
+
const normalized = normalizeColorTokenValue(styleValue);
|
|
351
|
+
if (normalized === null) return null;
|
|
352
|
+
styleValue = normalized;
|
|
353
|
+
}
|
|
354
|
+
if (converter) {
|
|
355
|
+
const converted = converter(styleValue);
|
|
356
|
+
if (converted) styleValue = converted;
|
|
357
|
+
else if (typeof styleValue !== "string") return null;
|
|
358
|
+
}
|
|
359
|
+
if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
|
|
360
|
+
styleValue = styleValue.trim();
|
|
361
|
+
return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
|
|
362
|
+
}
|
|
363
|
+
const processed = parseStyle(styleValue);
|
|
364
|
+
return { [finalCssStyle]: processed.output };
|
|
365
|
+
};
|
|
366
|
+
styleHandler.__lookupStyles = [styleName];
|
|
367
|
+
CACHE[key] = styleHandler;
|
|
368
|
+
}
|
|
369
|
+
return CACHE[key];
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/styles/animation.ts
|
|
373
|
+
const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert revert-layer auto normal running paused reverse alternate alternate-reverse forwards backwards both infinite ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
|
|
374
|
+
const RE_NAME = /^(?:--|-?[a-zA-Z_\u0080-])[\w\-\u0080-]*$/;
|
|
375
|
+
function nameAt(value, start, end) {
|
|
376
|
+
const token = value.slice(start, end);
|
|
377
|
+
return RE_NAME.test(token) && !NON_NAME_KEYWORDS.has(token.toLowerCase()) ? {
|
|
378
|
+
name: token,
|
|
379
|
+
index: start
|
|
380
|
+
} : null;
|
|
381
|
+
}
|
|
382
|
+
function scanAnimationNames(value) {
|
|
383
|
+
const items = [];
|
|
384
|
+
let found = null;
|
|
385
|
+
let start = -1;
|
|
386
|
+
let depth = 0;
|
|
387
|
+
let quote = "";
|
|
388
|
+
for (let i = 0; i < value.length; i++) {
|
|
389
|
+
const ch = value[i];
|
|
390
|
+
if (quote) {
|
|
391
|
+
if (ch === "\\") i++;
|
|
392
|
+
else if (ch === quote) quote = "";
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (depth === 0 && (ch === "," || /\s/.test(ch))) {
|
|
396
|
+
if (start !== -1) found ??= nameAt(value, start, i);
|
|
397
|
+
start = -1;
|
|
398
|
+
if (ch === ",") {
|
|
399
|
+
items.push(found);
|
|
400
|
+
found = null;
|
|
401
|
+
}
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
if (start === -1) start = i;
|
|
405
|
+
if (ch === "\"" || ch === "'") quote = ch;
|
|
406
|
+
else if (ch === "\\") i++;
|
|
407
|
+
else if (ch === "(") depth++;
|
|
408
|
+
else if (ch === ")" && depth > 0) depth--;
|
|
409
|
+
}
|
|
410
|
+
if (start !== -1) found ??= nameAt(value, start, value.length);
|
|
411
|
+
items.push(found);
|
|
412
|
+
return items;
|
|
413
|
+
}
|
|
414
|
+
function restoreAnimationNameCase(authored, output) {
|
|
415
|
+
if (authored === output || authored === authored.toLowerCase()) return output;
|
|
416
|
+
const authoredNames = scanAnimationNames(authored);
|
|
417
|
+
const outputNames = scanAnimationNames(output);
|
|
418
|
+
if (authoredNames.length !== outputNames.length) return output;
|
|
419
|
+
let result = output;
|
|
420
|
+
for (let i = outputNames.length - 1; i >= 0; i--) {
|
|
421
|
+
const from = outputNames[i];
|
|
422
|
+
const to = authoredNames[i];
|
|
423
|
+
if (!from || !to || from.name === to.name) continue;
|
|
424
|
+
if (from.name !== to.name.toLowerCase()) continue;
|
|
425
|
+
result = result.slice(0, from.index) + to.name + result.slice(from.index + from.name.length);
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
function animationNameHandler(styleName, property) {
|
|
430
|
+
const base = createStyle(styleName);
|
|
431
|
+
const handler = (styleMap) => {
|
|
432
|
+
const result = base(styleMap);
|
|
433
|
+
const value = styleMap[styleName];
|
|
434
|
+
if (!result || typeof value !== "string") return result;
|
|
435
|
+
return { [property]: restoreAnimationNameCase(value, String(result[property])) };
|
|
436
|
+
};
|
|
437
|
+
handler.__lookupStyles = [styleName];
|
|
438
|
+
return handler;
|
|
439
|
+
}
|
|
440
|
+
const animationStyle = animationNameHandler("animation", "animation");
|
|
441
|
+
const animationNameStyle = animationNameHandler("animationName", "animation-name");
|
|
442
|
+
//#endregion
|
|
302
443
|
//#region src/styles/const.ts
|
|
303
444
|
const BORDER_STYLES = [
|
|
304
445
|
"none",
|
|
@@ -314,6 +455,9 @@ const BORDER_STYLES = [
|
|
|
314
455
|
];
|
|
315
456
|
//#endregion
|
|
316
457
|
//#region src/styles/shared.ts
|
|
458
|
+
function resolveDefaultValue(value) {
|
|
459
|
+
return parseStyle(value).groups[0]?.values[0] ?? value;
|
|
460
|
+
}
|
|
317
461
|
function extractCSSWideKeyword(group) {
|
|
318
462
|
if (group.values.length !== 1 || group.colors.length > 0) return null;
|
|
319
463
|
return CSS_WIDE_KEYWORDS.has(group.values[0]) ? group.values[0] : null;
|
|
@@ -353,9 +497,9 @@ function processGroup$1(group) {
|
|
|
353
497
|
else if (mod === "longhand") modFlags |= 16;
|
|
354
498
|
else if (lineStyle === void 0 && BORDER_STYLES.includes(mod)) lineStyle = mod;
|
|
355
499
|
const slots = assignLineSlots(values, lineStyle, colors[0]);
|
|
356
|
-
const width = values[0] || "
|
|
500
|
+
const width = values[0] || resolveDefaultValue("1bw");
|
|
357
501
|
const style = slots.style || "solid";
|
|
358
|
-
const color = slots.color || "var(--border-color
|
|
502
|
+
const color = slots.color || "var(--border-color)";
|
|
359
503
|
return {
|
|
360
504
|
modFlags,
|
|
361
505
|
width,
|
|
@@ -438,7 +582,7 @@ function borderStyle({ border }) {
|
|
|
438
582
|
}
|
|
439
583
|
const result = {};
|
|
440
584
|
const fallbackStyle = allDirectionsValue?.style || "solid";
|
|
441
|
-
const fallbackColor = allDirectionsValue?.color || "var(--border-color
|
|
585
|
+
const fallbackColor = allDirectionsValue?.color || "var(--border-color)";
|
|
442
586
|
for (const dir of DIRECTIONS) {
|
|
443
587
|
const value = directionMap[dir];
|
|
444
588
|
if (value) result[`border-${dir}`] = formatBorderValue(value);
|
|
@@ -449,8 +593,13 @@ function borderStyle({ border }) {
|
|
|
449
593
|
borderStyle.__lookupStyles = ["border"];
|
|
450
594
|
//#endregion
|
|
451
595
|
//#region src/styles/dimension.ts
|
|
452
|
-
const DEFAULT_MIN_SIZE = "
|
|
596
|
+
const DEFAULT_MIN_SIZE = "1x";
|
|
453
597
|
const DEFAULT_MAX_SIZE = "100%";
|
|
598
|
+
const STRETCH_FALLBACKS = [
|
|
599
|
+
"-webkit-fill-available",
|
|
600
|
+
"-moz-available",
|
|
601
|
+
"stretch"
|
|
602
|
+
];
|
|
454
603
|
function parseDimensionValue(val) {
|
|
455
604
|
if (val == null) return null;
|
|
456
605
|
if (typeof val === "number") return `${val}px`;
|
|
@@ -499,7 +648,7 @@ function dimensionStyle(name) {
|
|
|
499
648
|
let flag = false;
|
|
500
649
|
for (const mod of mods) switch (mod) {
|
|
501
650
|
case "min":
|
|
502
|
-
styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;
|
|
651
|
+
styles[minStyle] = values[0] || resolveDefaultValue(DEFAULT_MIN_SIZE);
|
|
503
652
|
flag = true;
|
|
504
653
|
break;
|
|
505
654
|
case "max":
|
|
@@ -525,14 +674,7 @@ function dimensionStyle(name) {
|
|
|
525
674
|
styles[maxStyle] = values[2];
|
|
526
675
|
} else styles[name] = values[0] || "auto";
|
|
527
676
|
}
|
|
528
|
-
if (styles[name] === "stretch")
|
|
529
|
-
if (name === "width") styles[name] = [
|
|
530
|
-
"stretch",
|
|
531
|
-
"-webkit-fill-available",
|
|
532
|
-
"-moz-available"
|
|
533
|
-
];
|
|
534
|
-
else styles[name] = "auto";
|
|
535
|
-
}
|
|
677
|
+
if (styles[name] === "stretch") styles[name] = STRETCH_FALLBACKS;
|
|
536
678
|
}
|
|
537
679
|
const minVal = parseDimensionValue(min);
|
|
538
680
|
const maxVal = parseDimensionValue(max);
|
|
@@ -554,53 +696,18 @@ function blockSizeStyle({ blockSize, minBlockSize, maxBlockSize }) {
|
|
|
554
696
|
blockSizeStyle.__lookupStyles = [...BLOCK_SIZE_STYLES];
|
|
555
697
|
//#endregion
|
|
556
698
|
//#region src/styles/color.ts
|
|
699
|
+
const RE_HEX_LITERAL = /^#[0-9a-f]+$/i;
|
|
557
700
|
const RE_READS_CURRENT = /var\(--current-color[,)]|currentcolor/i;
|
|
558
701
|
function colorStyle({ color }) {
|
|
559
702
|
if (!color) return null;
|
|
560
703
|
if (color === true) color = "currentColor";
|
|
561
|
-
color = parseColor(color, true).color || resolveCustomProperties(color);
|
|
704
|
+
color = (RE_HEX_LITERAL.test(color) ? parseStyle(color).groups[0]?.colors[0] : parseColor(color, true).color) || resolveCustomProperties(color);
|
|
562
705
|
const styles = { color };
|
|
563
706
|
if (!RE_READS_CURRENT.test(color)) styles["--current-color"] = color;
|
|
564
707
|
return styles;
|
|
565
708
|
}
|
|
566
709
|
colorStyle.__lookupStyles = ["color"];
|
|
567
710
|
//#endregion
|
|
568
|
-
//#region src/styles/createStyle.ts
|
|
569
|
-
const CACHE = {};
|
|
570
|
-
function createStyle(styleName, cssStyle, converter) {
|
|
571
|
-
const key = `${styleName}.${cssStyle ?? ""}`;
|
|
572
|
-
if (!CACHE[key]) {
|
|
573
|
-
const styleHandler = (styleMap) => {
|
|
574
|
-
let styleValue = styleMap[styleName];
|
|
575
|
-
if (styleValue == null || styleValue === false) return null;
|
|
576
|
-
let finalCssStyle;
|
|
577
|
-
const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
|
|
578
|
-
if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
|
|
579
|
-
else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
|
|
580
|
-
else finalCssStyle = cssStyle || toSnakeCase(styleName);
|
|
581
|
-
if (isColorToken) {
|
|
582
|
-
const normalized = normalizeColorTokenValue(styleValue);
|
|
583
|
-
if (normalized === null) return null;
|
|
584
|
-
styleValue = normalized;
|
|
585
|
-
}
|
|
586
|
-
if (converter) {
|
|
587
|
-
const converted = converter(styleValue);
|
|
588
|
-
if (converted) styleValue = converted;
|
|
589
|
-
else if (typeof styleValue !== "string") return null;
|
|
590
|
-
}
|
|
591
|
-
if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
|
|
592
|
-
styleValue = styleValue.trim();
|
|
593
|
-
return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
|
|
594
|
-
}
|
|
595
|
-
const processed = parseStyle(styleValue);
|
|
596
|
-
return { [finalCssStyle]: processed.output };
|
|
597
|
-
};
|
|
598
|
-
styleHandler.__lookupStyles = [styleName];
|
|
599
|
-
CACHE[key] = styleHandler;
|
|
600
|
-
}
|
|
601
|
-
return CACHE[key];
|
|
602
|
-
}
|
|
603
|
-
//#endregion
|
|
604
711
|
//#region src/styles/display.ts
|
|
605
712
|
function applyTextOverflow(result, textOverflow, whiteSpace) {
|
|
606
713
|
if (textOverflow === true || textOverflow === "initial") {
|
|
@@ -662,7 +769,7 @@ function processGroup(group, isOnlyGroup, gradients) {
|
|
|
662
769
|
const { input, values, mods, colors } = group;
|
|
663
770
|
const transparentColor = colors[0] || DEFAULT_TRANSPARENT_COLOR;
|
|
664
771
|
const opaqueColor = colors[1] || DEFAULT_OPAQUE_COLOR;
|
|
665
|
-
const firstSize = values.length ? values[0] : "
|
|
772
|
+
const firstSize = values.length ? values[0] : resolveDefaultValue("2x");
|
|
666
773
|
let namedCount = 0;
|
|
667
774
|
for (const mod of mods) {
|
|
668
775
|
const directionIndex = DIRECTIONS.indexOf(mod);
|
|
@@ -699,7 +806,8 @@ fadeStyle.__lookupStyles = ["fade"];
|
|
|
699
806
|
function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
|
|
700
807
|
if (background) return { background: parseStyle(background).output || background };
|
|
701
808
|
const result = {};
|
|
702
|
-
|
|
809
|
+
if (fill === true) warnOnceDev("fill-true", "fill: true has no default color and is ignored. Write a color (fill: '#surface'), or false for no fill.");
|
|
810
|
+
const colorValue = backgroundColor ?? (typeof fill === "string" ? fill : void 0);
|
|
703
811
|
if (colorValue) {
|
|
704
812
|
const parsed = parseStyle(colorValue);
|
|
705
813
|
const firstColor = parsed.groups[0]?.colors[0];
|
|
@@ -814,7 +922,7 @@ function parseSingleValue(val, defaultValue, trueValue) {
|
|
|
814
922
|
const strVal = String(val);
|
|
815
923
|
if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;
|
|
816
924
|
const { values } = parseStyle(strVal).groups[0] ?? { values: [] };
|
|
817
|
-
return values[0] || defaultValue;
|
|
925
|
+
return values[0] || resolveDefaultValue(defaultValue);
|
|
818
926
|
}
|
|
819
927
|
function directionModFlags(mods, spanModifiers) {
|
|
820
928
|
let flags = 0;
|
|
@@ -832,7 +940,7 @@ function directionModFlags(mods, spanModifiers) {
|
|
|
832
940
|
return flags;
|
|
833
941
|
}
|
|
834
942
|
function applyGroup(dirs, group, modFlags, property, defaultValue) {
|
|
835
|
-
const values = group.values.length ? group.values : [defaultValue];
|
|
943
|
+
const values = group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
|
|
836
944
|
const directions = modFlags & DIRECTION_MASK;
|
|
837
945
|
const span = modFlags & DIRECTION_SPAN;
|
|
838
946
|
if (directions && values.length > (span ? 2 : 1)) warnExtraGroupValues(property, group.input, span ? 2 : 1);
|
|
@@ -1018,7 +1126,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
|
|
|
1018
1126
|
const modFlags = logicalModFlags(group.mods);
|
|
1019
1127
|
const hasDirection = modFlags & 3;
|
|
1020
1128
|
const keyword = extractCSSWideKeyword(group);
|
|
1021
|
-
const values = keyword ? [keyword] : group.values.length ? group.values : [defaultValue];
|
|
1129
|
+
const values = keyword ? [keyword] : group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
|
|
1022
1130
|
if (hasDirection && values.length > 1) warnExtraGroupValues(styleName, group.input, 1, LOGICAL_DIRECTIONS);
|
|
1023
1131
|
else if (!hasDirection && values.length > 2) warnOnceDev(`extra-logical-axis-values:${styleName}:${group.input}`, `${styleName}="${group.input}": a logical axis takes at most two values in start/end order. The extra values are ignored.`);
|
|
1024
1132
|
if (modFlags & LOGICAL_LONGHAND) useLonghand = true;
|
|
@@ -1041,7 +1149,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
|
|
|
1041
1149
|
}
|
|
1042
1150
|
function zeroBorderValue(value) {
|
|
1043
1151
|
const firstSpace = value.indexOf(" ");
|
|
1044
|
-
return firstSpace === -1 ? "0 solid var(--border-color
|
|
1152
|
+
return firstSpace === -1 ? "0 solid var(--border-color)" : `0${value.slice(firstSpace)}`;
|
|
1045
1153
|
}
|
|
1046
1154
|
function logicalBorderStyle(styleName, cssProperty) {
|
|
1047
1155
|
const handler = ((styles) => {
|
|
@@ -1055,7 +1163,7 @@ function logicalBorderStyle(styleName, cssProperty) {
|
|
|
1055
1163
|
start: null,
|
|
1056
1164
|
end: null
|
|
1057
1165
|
};
|
|
1058
|
-
let fallback = "0 solid var(--border-color
|
|
1166
|
+
let fallback = "0 solid var(--border-color)";
|
|
1059
1167
|
let useLonghand = false;
|
|
1060
1168
|
for (const group of groups) {
|
|
1061
1169
|
const borderValue = parseBorderValue(group.input);
|
|
@@ -1096,8 +1204,8 @@ function logicalBorderStyles(styleNames) {
|
|
|
1096
1204
|
return Object.fromEntries(styleNames.map((styleName, index) => [styleName, logicalBorderStyle(styleName, `border-${index ? "inline" : "block"}`)]));
|
|
1097
1205
|
}
|
|
1098
1206
|
const logicalStyleHandlers = {
|
|
1099
|
-
...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "
|
|
1100
|
-
...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "
|
|
1207
|
+
...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "1x", "1x", "0"),
|
|
1208
|
+
...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "1x", "1x", "0"),
|
|
1101
1209
|
...logicalAxisStyles(LOGICAL_INSET_STYLES, "inset", "0", "0", "auto"),
|
|
1102
1210
|
...logicalAxisStyles(LOGICAL_SCROLL_MARGIN_STYLES, "scroll-margin", "0", "1x", "0"),
|
|
1103
1211
|
...logicalAxisStyles(LOGICAL_SCROLL_PADDING_STYLES, "scroll-padding", "0", "1x", "0"),
|
|
@@ -1107,7 +1215,7 @@ const logicalStyleHandlers = {
|
|
|
1107
1215
|
//#region src/styles/margin.ts
|
|
1108
1216
|
const MARGIN_CONFIG = {
|
|
1109
1217
|
property: "margin",
|
|
1110
|
-
defaultValue: "
|
|
1218
|
+
defaultValue: "1x",
|
|
1111
1219
|
trueValue: "1x",
|
|
1112
1220
|
defaultInit: "0"
|
|
1113
1221
|
};
|
|
@@ -1152,7 +1260,7 @@ function outlineStyle({ outline, outlineOffset }) {
|
|
|
1152
1260
|
break;
|
|
1153
1261
|
}
|
|
1154
1262
|
const slots = assignLineSlots(outlinePart.values, lineStyle, outlinePart.colors[0]);
|
|
1155
|
-
result.outline = `${outlinePart.values[0] || "
|
|
1263
|
+
result.outline = `${outlinePart.values[0] || resolveDefaultValue("1ow")} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
|
|
1156
1264
|
if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
|
|
1157
1265
|
}
|
|
1158
1266
|
}
|
|
@@ -1168,7 +1276,7 @@ outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
|
|
|
1168
1276
|
//#region src/styles/padding.ts
|
|
1169
1277
|
const PADDING_CONFIG = {
|
|
1170
1278
|
property: "padding",
|
|
1171
|
-
defaultValue: "
|
|
1279
|
+
defaultValue: "1x",
|
|
1172
1280
|
trueValue: "1x",
|
|
1173
1281
|
defaultInit: "0"
|
|
1174
1282
|
};
|
|
@@ -1262,6 +1370,7 @@ const PRESET_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
1262
1370
|
"normal"
|
|
1263
1371
|
]);
|
|
1264
1372
|
const SANS_FONT = "var(--font-sans, var(--font-sans-fallback))";
|
|
1373
|
+
const MONO_FONT = "var(--font-mono, var(--font-mono-fallback))";
|
|
1265
1374
|
function toCSS(value, isNumeric) {
|
|
1266
1375
|
if (value == null) return null;
|
|
1267
1376
|
if (typeof value === "number") return isNumeric ? `${value}px` : String(value);
|
|
@@ -1281,7 +1390,7 @@ function setCSSValue(styles, styleName, presetName, mode) {
|
|
|
1281
1390
|
function resolveFontFamily(font, fontFamily) {
|
|
1282
1391
|
if (fontFamily) return resolveCustomProperties(fontFamily);
|
|
1283
1392
|
if (font == null || font === false) return null;
|
|
1284
|
-
if (font === "monospace") return
|
|
1393
|
+
if (font === "monospace") return MONO_FONT;
|
|
1285
1394
|
if (font === true) return SANS_FONT;
|
|
1286
1395
|
return `${resolveCustomProperties(font)}, ${SANS_FONT}`;
|
|
1287
1396
|
}
|
|
@@ -1350,7 +1459,7 @@ presetStyle.__lookupStyles = [
|
|
|
1350
1459
|
];
|
|
1351
1460
|
//#endregion
|
|
1352
1461
|
//#region src/styles/radius.ts
|
|
1353
|
-
const
|
|
1462
|
+
const DEFAULT_RADIUS = "1r";
|
|
1354
1463
|
const SHARP = "var(--sharp-radius)";
|
|
1355
1464
|
const RADIUS_LONGHANDS = [
|
|
1356
1465
|
"border-top-left-radius",
|
|
@@ -1395,19 +1504,20 @@ function radiusStyle({ radius }) {
|
|
|
1395
1504
|
for (const i of corners) result[RADIUS_LONGHANDS[i]] = keyword;
|
|
1396
1505
|
return result;
|
|
1397
1506
|
}
|
|
1507
|
+
const defaultRadius = resolveDefaultValue(DEFAULT_RADIUS);
|
|
1398
1508
|
if (mods.includes("round")) values = ["9999rem"];
|
|
1399
1509
|
else if (mods.includes("ellipse")) values = ["50%"];
|
|
1400
|
-
else if (!values.length) values = [
|
|
1510
|
+
else if (!values.length) values = [defaultRadius];
|
|
1401
1511
|
if (mods.includes("leaf")) values = [
|
|
1402
1512
|
values[1] || SHARP,
|
|
1403
|
-
values[0] ||
|
|
1513
|
+
values[0] || defaultRadius,
|
|
1404
1514
|
values[1] || SHARP,
|
|
1405
|
-
values[0] ||
|
|
1515
|
+
values[0] || defaultRadius
|
|
1406
1516
|
];
|
|
1407
1517
|
else if (mods.includes("backleaf")) values = [
|
|
1408
|
-
values[0] ||
|
|
1518
|
+
values[0] || defaultRadius,
|
|
1409
1519
|
values[1] || SHARP,
|
|
1410
|
-
values[0] ||
|
|
1520
|
+
values[0] || defaultRadius,
|
|
1411
1521
|
values[1] || SHARP
|
|
1412
1522
|
];
|
|
1413
1523
|
else if (mods.length) {
|
|
@@ -1419,7 +1529,7 @@ function radiusStyle({ radius }) {
|
|
|
1419
1529
|
"0",
|
|
1420
1530
|
"0"
|
|
1421
1531
|
];
|
|
1422
|
-
for (const i of corners) arr[i] = values[0] ||
|
|
1532
|
+
for (const i of corners) arr[i] = values[0] || defaultRadius;
|
|
1423
1533
|
values = arr;
|
|
1424
1534
|
}
|
|
1425
1535
|
}
|
|
@@ -1611,7 +1721,6 @@ const MAP = {
|
|
|
1611
1721
|
"height"
|
|
1612
1722
|
],
|
|
1613
1723
|
gap: ["gap", "margin"],
|
|
1614
|
-
zIndex: ["z-index"],
|
|
1615
1724
|
inset: [
|
|
1616
1725
|
"inset",
|
|
1617
1726
|
"top",
|
|
@@ -1620,6 +1729,7 @@ const MAP = {
|
|
|
1620
1729
|
"left"
|
|
1621
1730
|
]
|
|
1622
1731
|
};
|
|
1732
|
+
const NAME_ALIASES = { zindex: "z-index" };
|
|
1623
1733
|
const DEFAULT_EASING = "linear";
|
|
1624
1734
|
const EASING_KEYWORDS = new Set("ease ease-in ease-out ease-in-out linear step-start step-end".split(" "));
|
|
1625
1735
|
function isEasing(token) {
|
|
@@ -1636,8 +1746,9 @@ function transitionStyle({ transition }) {
|
|
|
1636
1746
|
const named = /* @__PURE__ */ new Set();
|
|
1637
1747
|
for (const group of processed.groups) {
|
|
1638
1748
|
const tokens = group.all;
|
|
1639
|
-
|
|
1749
|
+
let name = tokens[0];
|
|
1640
1750
|
if (!name || isTokenNameReference("transition", name)) continue;
|
|
1751
|
+
name = NAME_ALIASES[name] ?? name;
|
|
1641
1752
|
let timing;
|
|
1642
1753
|
let easing;
|
|
1643
1754
|
let delay;
|
|
@@ -1723,6 +1834,8 @@ function predefine() {
|
|
|
1723
1834
|
[
|
|
1724
1835
|
displayStyle,
|
|
1725
1836
|
transitionStyle,
|
|
1837
|
+
animationStyle,
|
|
1838
|
+
animationNameStyle,
|
|
1726
1839
|
fillStyle,
|
|
1727
1840
|
svgFillStyle,
|
|
1728
1841
|
widthStyle,
|
|
@@ -1879,6 +1992,58 @@ const ELEMENT_NAME_RE = /(^|[\s>+~,(])([A-Z][a-zA-Z0-9]*)/g;
|
|
|
1879
1992
|
function transformSelectorContent(content) {
|
|
1880
1993
|
return content.replace(ELEMENT_NAME_RE, (_, prefix, name) => `${prefix}[data-element="${name}"]`);
|
|
1881
1994
|
}
|
|
1995
|
+
const HTML_TYPE_RE = /^html(?![\w\-|\\\u0080-\uffff])/i;
|
|
1996
|
+
const LEGACY_PSEUDO_ELEMENT_RE = /^:(?:before|after|first-line|first-letter)$/i;
|
|
1997
|
+
function rootStateIndex(selector) {
|
|
1998
|
+
let isRoot = HTML_TYPE_RE.test(selector);
|
|
1999
|
+
let pseudoElementAt = -1;
|
|
2000
|
+
let squareDepth = 0;
|
|
2001
|
+
let parenDepth = 0;
|
|
2002
|
+
let quote = "";
|
|
2003
|
+
let rootFunctionParen = -1;
|
|
2004
|
+
let rootFunctionArgs = -1;
|
|
2005
|
+
for (let i = 0; i < selector.length; i++) {
|
|
2006
|
+
const char = selector[i];
|
|
2007
|
+
if (char === "\\") {
|
|
2008
|
+
i++;
|
|
2009
|
+
continue;
|
|
2010
|
+
}
|
|
2011
|
+
if (quote) {
|
|
2012
|
+
if (char === quote) quote = "";
|
|
2013
|
+
continue;
|
|
2014
|
+
}
|
|
2015
|
+
if (char === "\"" || char === "'") {
|
|
2016
|
+
quote = char;
|
|
2017
|
+
continue;
|
|
2018
|
+
}
|
|
2019
|
+
if (char === "[") squareDepth++;
|
|
2020
|
+
else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
|
|
2021
|
+
else if (char === "(") {
|
|
2022
|
+
if (i === rootFunctionParen && parenDepth === 0) rootFunctionArgs = i + 1;
|
|
2023
|
+
parenDepth++;
|
|
2024
|
+
} else if (char === ")") {
|
|
2025
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
2026
|
+
if (parenDepth === 0 && rootFunctionArgs !== -1) {
|
|
2027
|
+
const args = splitSelectorsSafely(selector.slice(rootFunctionArgs, i));
|
|
2028
|
+
if (args.length > 0 && args.every((arg) => rootStateIndex(arg) === arg.length)) isRoot = true;
|
|
2029
|
+
rootFunctionArgs = -1;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
if (squareDepth > 0 || parenDepth > 0) continue;
|
|
2033
|
+
if (/[\s>+~,]/.test(char) || char === "/" && selector[i + 1] === "*") return -1;
|
|
2034
|
+
if (char !== ":" || pseudoElementAt !== -1) continue;
|
|
2035
|
+
if (selector[i + 1] === ":") {
|
|
2036
|
+
pseudoElementAt = i;
|
|
2037
|
+
continue;
|
|
2038
|
+
}
|
|
2039
|
+
const name = (/^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "").toLowerCase();
|
|
2040
|
+
if (name === ":root") isRoot = true;
|
|
2041
|
+
else if (LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
|
|
2042
|
+
else if ((name === ":is" || name === ":where") && selector[i + name.length] === "(") rootFunctionParen = i + name.length;
|
|
2043
|
+
}
|
|
2044
|
+
if (!isRoot) return -1;
|
|
2045
|
+
return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
|
|
2046
|
+
}
|
|
1882
2047
|
function splitSelectorsSafely(selectorList) {
|
|
1883
2048
|
if (!selectorList.includes(",")) {
|
|
1884
2049
|
const selector = selectorList.trim();
|
|
@@ -1925,6 +2090,17 @@ function splitSelectorsSafely(selectorList) {
|
|
|
1925
2090
|
}
|
|
1926
2091
|
//#endregion
|
|
1927
2092
|
//#region src/pipeline/conditions.ts
|
|
2093
|
+
function getRangeUnit(range) {
|
|
2094
|
+
const lower = range.lowerBound && getBoundUnit(range.lowerBound);
|
|
2095
|
+
const upper = range.upperBound && getBoundUnit(range.upperBound);
|
|
2096
|
+
if (lower === null || upper === null) return null;
|
|
2097
|
+
if (lower !== void 0 && upper !== void 0 && lower !== upper) return null;
|
|
2098
|
+
return lower ?? upper ?? null;
|
|
2099
|
+
}
|
|
2100
|
+
function getBoundUnit(bound) {
|
|
2101
|
+
if (bound.valueNumeric == null) return null;
|
|
2102
|
+
return /[a-z%]*$/i.exec(bound.value)[0].toLowerCase();
|
|
2103
|
+
}
|
|
1928
2104
|
function buildDimensionCondition(dimension, lowerBound, upperBound, emptyDimension = dimension) {
|
|
1929
2105
|
if (lowerBound && upperBound) {
|
|
1930
2106
|
const lowerOp = lowerBound.inclusive ? "<=" : "<";
|
|
@@ -2359,8 +2535,12 @@ function hasRangeContradiction(terms) {
|
|
|
2359
2535
|
const containerByDim = /* @__PURE__ */ new Map();
|
|
2360
2536
|
for (const term of terms) {
|
|
2361
2537
|
if (term.kind !== "state") continue;
|
|
2362
|
-
if (term.type
|
|
2363
|
-
|
|
2538
|
+
if (term.type !== "media" && term.type !== "container") continue;
|
|
2539
|
+
if (term.subtype !== "dimension") continue;
|
|
2540
|
+
const unit = getRangeUnit(term);
|
|
2541
|
+
if (unit === null) continue;
|
|
2542
|
+
if (term.type === "media") {
|
|
2543
|
+
const key = `${term.dimension || "width"}|${unit}`;
|
|
2364
2544
|
let group = mediaByDim.get(key);
|
|
2365
2545
|
if (!group) {
|
|
2366
2546
|
group = {
|
|
@@ -2372,8 +2552,8 @@ function hasRangeContradiction(terms) {
|
|
|
2372
2552
|
if (term.negated) group.negated.push(term);
|
|
2373
2553
|
else group.positive.push(term);
|
|
2374
2554
|
}
|
|
2375
|
-
if (term.type === "container"
|
|
2376
|
-
const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
|
|
2555
|
+
if (term.type === "container") {
|
|
2556
|
+
const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
|
|
2377
2557
|
let group = containerByDim.get(key);
|
|
2378
2558
|
if (!group) {
|
|
2379
2559
|
group = {
|
|
@@ -2568,8 +2748,12 @@ function mergeRanges(terms) {
|
|
|
2568
2748
|
const containerByDim = /* @__PURE__ */ new Map();
|
|
2569
2749
|
terms.forEach((term, index) => {
|
|
2570
2750
|
if (term.kind !== "state") return;
|
|
2571
|
-
if (term.type
|
|
2572
|
-
|
|
2751
|
+
if (term.type !== "media" && term.type !== "container") return;
|
|
2752
|
+
if (term.subtype !== "dimension" || term.negated) return;
|
|
2753
|
+
const unit = getRangeUnit(term);
|
|
2754
|
+
if (unit === null) return;
|
|
2755
|
+
if (term.type === "media") {
|
|
2756
|
+
const key = `${term.dimension || "width"}|${unit}`;
|
|
2573
2757
|
let group = mediaByDim.get(key);
|
|
2574
2758
|
if (!group) {
|
|
2575
2759
|
group = {
|
|
@@ -2581,8 +2765,8 @@ function mergeRanges(terms) {
|
|
|
2581
2765
|
group.conditions.push(term);
|
|
2582
2766
|
group.indices.push(index);
|
|
2583
2767
|
}
|
|
2584
|
-
if (term.type === "container"
|
|
2585
|
-
const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
|
|
2768
|
+
if (term.type === "container") {
|
|
2769
|
+
const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
|
|
2586
2770
|
let group = containerByDim.get(key);
|
|
2587
2771
|
if (!group) {
|
|
2588
2772
|
group = {
|
|
@@ -2843,14 +3027,16 @@ function hasMediaContradiction(conditions) {
|
|
|
2843
3027
|
if (existing !== void 0 && existing !== !cond.negated) return true;
|
|
2844
3028
|
polarities.set(key, !cond.negated);
|
|
2845
3029
|
if (cond.subtype !== "dimension" || cond.negated) continue;
|
|
2846
|
-
const
|
|
2847
|
-
|
|
3030
|
+
const unit = getRangeUnit(cond);
|
|
3031
|
+
if (unit === null) continue;
|
|
3032
|
+
const rangeKey = `${cond.dimension || "width"}|${unit}`;
|
|
3033
|
+
let bounds = dimensionsByDim.get(rangeKey);
|
|
2848
3034
|
if (!bounds) {
|
|
2849
3035
|
bounds = {
|
|
2850
3036
|
lowerBound: null,
|
|
2851
3037
|
upperBound: null
|
|
2852
3038
|
};
|
|
2853
|
-
dimensionsByDim.set(
|
|
3039
|
+
dimensionsByDim.set(rangeKey, bounds);
|
|
2854
3040
|
}
|
|
2855
3041
|
if (cond.lowerBound?.valueNumeric != null) {
|
|
2856
3042
|
const value = cond.lowerBound.valueNumeric;
|
|
@@ -3207,13 +3393,16 @@ function optimizeGroups(groups) {
|
|
|
3207
3393
|
}, facts);
|
|
3208
3394
|
});
|
|
3209
3395
|
}
|
|
3210
|
-
function
|
|
3396
|
+
function rootGroupsToStateCSS(groups) {
|
|
3211
3397
|
if (groups.length === 0) return void 0;
|
|
3212
3398
|
const optimized = optimizeGroups(groups);
|
|
3213
3399
|
if (optimized.length === 0) return void 0;
|
|
3214
|
-
let
|
|
3215
|
-
for (const group of optimized)
|
|
3216
|
-
return
|
|
3400
|
+
let state = "";
|
|
3401
|
+
for (const group of optimized) state += selectorGroupToCSS(group);
|
|
3402
|
+
return state;
|
|
3403
|
+
}
|
|
3404
|
+
function rootStateToPrefix(state) {
|
|
3405
|
+
return wrapWhere(`:root${state}`);
|
|
3217
3406
|
}
|
|
3218
3407
|
function parentGroupsToCSS(groups) {
|
|
3219
3408
|
let result = "";
|
|
@@ -4230,14 +4419,14 @@ var Parser = class {
|
|
|
4230
4419
|
const content = raw.slice(7, -1);
|
|
4231
4420
|
if (!content.trim()) return trueCondition();
|
|
4232
4421
|
let condition = expandDimensionShorthands(content);
|
|
4233
|
-
condition =
|
|
4422
|
+
condition = expandQueryUnits(condition);
|
|
4234
4423
|
if (condition.includes(":") && !condition.includes("<") && !condition.includes(">") && !condition.includes("=")) {
|
|
4235
4424
|
const colonIdx = condition.indexOf(":");
|
|
4236
4425
|
return createMediaFeatureCondition(condition.slice(0, colonIdx).trim(), condition.slice(colonIdx + 1).trim(), false, raw);
|
|
4237
4426
|
}
|
|
4238
4427
|
if (!condition.includes("<") && !condition.includes(">") && !condition.includes("=")) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
|
|
4239
4428
|
const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(condition);
|
|
4240
|
-
if (!dimension) return
|
|
4429
|
+
if (!dimension) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
|
|
4241
4430
|
return createMediaDimensionCondition(dimension, lowerBound, upperBound, false, raw);
|
|
4242
4431
|
}
|
|
4243
4432
|
parseDimensionCondition(condition) {
|
|
@@ -4370,9 +4559,9 @@ var Parser = class {
|
|
|
4370
4559
|
}
|
|
4371
4560
|
if (/^[a-zA-Z][\w-]*\s*\(/.test(condition)) return createContainerRawCondition(condition, containerName, false, raw);
|
|
4372
4561
|
let expandedCondition = expandDimensionShorthands(condition);
|
|
4373
|
-
expandedCondition =
|
|
4562
|
+
expandedCondition = expandQueryUnits(expandedCondition);
|
|
4374
4563
|
const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(expandedCondition);
|
|
4375
|
-
if (!dimension) return
|
|
4564
|
+
if (!dimension) return createContainerRawCondition(`(${expandedCondition.trim()})`, containerName, false, raw);
|
|
4376
4565
|
return createContainerDimensionCondition(dimension, lowerBound, upperBound, containerName, false, raw);
|
|
4377
4566
|
}
|
|
4378
4567
|
parsePredefinedState(raw) {
|
|
@@ -4422,6 +4611,9 @@ function parseStateKey(stateKey, options = {}) {
|
|
|
4422
4611
|
parseCache.set(cacheKey, result);
|
|
4423
4612
|
return result;
|
|
4424
4613
|
}
|
|
4614
|
+
function clearParseCache() {
|
|
4615
|
+
parseCache.clear();
|
|
4616
|
+
}
|
|
4425
4617
|
//#endregion
|
|
4426
4618
|
//#region src/pipeline/index.ts
|
|
4427
4619
|
const RE_UPPER_CASE = /[A-Z]/;
|
|
@@ -4534,7 +4726,10 @@ function invokeHandler(handler, stateSnapshots, selectorSuffix) {
|
|
|
4534
4726
|
const declarations = {};
|
|
4535
4727
|
for (const [prop, val] of Object.entries(styleProps)) {
|
|
4536
4728
|
if (RE_UPPER_CASE.test(prop) && !prop.startsWith("--") && isDevEnv()) emitWarning("HANDLER_CAMEL_CASE_KEY", `A style handler returned "${prop}". CSS property names must be kebab-case ("${toSnakeCase(prop)}"). The declaration was emitted verbatim and the browser will ignore it.`);
|
|
4537
|
-
if (val
|
|
4729
|
+
if (Array.isArray(val)) {
|
|
4730
|
+
const chain = val.filter((v) => v != null && v !== "").map((v) => String(v));
|
|
4731
|
+
if (chain.length) declarations[prop] = chain.length === 1 ? chain[0] : chain;
|
|
4732
|
+
} else if (val != null && val !== "") declarations[prop] = String(val);
|
|
4538
4733
|
}
|
|
4539
4734
|
if (Object.keys(declarations).length === 0) continue;
|
|
4540
4735
|
const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
|
|
@@ -4865,12 +5060,13 @@ function buildSelectorFromVariant(variant, selectorSuffix) {
|
|
|
4865
5060
|
function materializeComputedRule(rule) {
|
|
4866
5061
|
const components = conditionToCSS(rule.condition);
|
|
4867
5062
|
if (components.isImpossible || components.variants.length === 0) return [];
|
|
4868
|
-
const declarations = Object.entries(rule.declarations).map(([prop, value]) => `${prop}: ${value};`).join(" ");
|
|
5063
|
+
const declarations = Object.entries(rule.declarations).map(([prop, value]) => Array.isArray(value) ? value.map((v) => `${prop}: ${v};`).join(" ") : `${prop}: ${value};`).join(" ");
|
|
4869
5064
|
const byAtRules = /* @__PURE__ */ new Map();
|
|
4870
5065
|
for (const variant of components.variants) {
|
|
4871
5066
|
const atRules = buildAtRulesFromVariant(variant);
|
|
4872
5067
|
const startingStyle = variant.startingStyle;
|
|
4873
|
-
const
|
|
5068
|
+
const rootState = rootGroupsToStateCSS(variant.rootGroups);
|
|
5069
|
+
const rootPrefix = rootState === void 0 ? void 0 : rootStateToPrefix(rootState);
|
|
4874
5070
|
const key = atRules.sort().join("|||") + "###" + (rootPrefix || "") + "###" + (startingStyle ? "1" : "0");
|
|
4875
5071
|
const group = byAtRules.get(key);
|
|
4876
5072
|
if (group) group.variants.push(variant);
|
|
@@ -4878,6 +5074,7 @@ function materializeComputedRule(rule) {
|
|
|
4878
5074
|
variants: [variant],
|
|
4879
5075
|
atRules,
|
|
4880
5076
|
rootPrefix,
|
|
5077
|
+
rootState,
|
|
4881
5078
|
startingStyle: startingStyle || void 0
|
|
4882
5079
|
});
|
|
4883
5080
|
}
|
|
@@ -4890,7 +5087,10 @@ function materializeComputedRule(rule) {
|
|
|
4890
5087
|
order: rule.order
|
|
4891
5088
|
};
|
|
4892
5089
|
if (group.atRules.length > 0) cssRule.atRules = group.atRules;
|
|
4893
|
-
if (group.rootPrefix)
|
|
5090
|
+
if (group.rootPrefix) {
|
|
5091
|
+
cssRule.rootPrefix = group.rootPrefix;
|
|
5092
|
+
cssRule.rootState = group.rootState;
|
|
5093
|
+
}
|
|
4894
5094
|
if (group.startingStyle) cssRule.startingStyle = true;
|
|
4895
5095
|
rules.push(cssRule);
|
|
4896
5096
|
}
|
|
@@ -4920,17 +5120,23 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
|
|
|
4920
5120
|
}
|
|
4921
5121
|
if (directSelector) {
|
|
4922
5122
|
const shouldDouble = options?.doubleSelector ?? false;
|
|
5123
|
+
const items = splitSelectorsSafely(classNameOrSelector);
|
|
5124
|
+
const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => ({
|
|
5125
|
+
base,
|
|
5126
|
+
rootAt: rootStateIndex(base)
|
|
5127
|
+
}));
|
|
4923
5128
|
return mergeStyleResults(rules.map((rule) => {
|
|
4924
5129
|
const result = {
|
|
4925
|
-
selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).
|
|
4926
|
-
|
|
5130
|
+
selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part) => bases.map(({ base, rootAt }) => {
|
|
5131
|
+
const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
|
|
5132
|
+
let sel = joinsRoot ? `${base.slice(0, rootAt)}${wrapWhere(rule.rootState)}${base.slice(rootAt)}${part}` : `${base}${part}`;
|
|
4927
5133
|
if (shouldDouble && sel.startsWith(".")) {
|
|
4928
5134
|
const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
|
|
4929
5135
|
if (classMatch) sel = classMatch[0] + sel;
|
|
4930
5136
|
}
|
|
4931
|
-
if (rule.rootPrefix) sel = `${rule.rootPrefix} ${sel}`;
|
|
5137
|
+
if (rule.rootPrefix && !joinsRoot) sel = `${rule.rootPrefix} ${sel}`;
|
|
4932
5138
|
return sel;
|
|
4933
|
-
}).join(", "),
|
|
5139
|
+
})).join(", "),
|
|
4934
5140
|
declarations: rule.declarations
|
|
4935
5141
|
};
|
|
4936
5142
|
if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
|
|
@@ -5255,6 +5461,6 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
|
5255
5461
|
return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
|
|
5256
5462
|
}
|
|
5257
5463
|
//#endregion
|
|
5258
|
-
export {
|
|
5464
|
+
export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
|
|
5259
5465
|
|
|
5260
|
-
//# sourceMappingURL=style-engine-
|
|
5466
|
+
//# sourceMappingURL=style-engine-BX2LshDZ.js.map
|