@tenphi/tasty 3.10.0 → 3.11.1
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 +403 -380
- package/dist/{babel-types-C_7kRP38.d.ts → babel-types-BKDTT4--.d.ts} +2 -2
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/{build-config-l2Ys-AJr.js → build-config-5d8WlQbq.js} +5 -5
- package/dist/chunks/{build-config-l2Ys-AJr.js.map → build-config-5d8WlQbq.js.map} +1 -1
- package/dist/chunks/{collector-CaNtsRtn.js → collector-CjCak4iE.js} +4 -4
- package/dist/chunks/{collector-CaNtsRtn.js.map → collector-CjCak4iE.js.map} +1 -1
- package/dist/chunks/{config-engine-CpExZO_T.js → config-engine-uOFYZidB.js} +4 -4
- package/dist/chunks/{config-engine-CpExZO_T.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-DAIJxzFY.js → css-definitions-ubrHP97m.js} +88 -77
- package/dist/chunks/css-definitions-ubrHP97m.js.map +1 -0
- package/dist/chunks/{debug-CKy49GEr.js → debug-CJ31U_WE.js} +6 -6
- package/dist/chunks/{debug-CKy49GEr.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-oi6i3ELR.js → react-runtime-CyyCI02N.js} +168 -61
- package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
- package/dist/chunks/{runtime-engine-DoULyhPt.js → runtime-engine-BQmOu5-W.js} +53 -36
- package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
- package/dist/chunks/{runtime-state-CZ2J5QiZ.js → runtime-state-DEsyUMU-.js} +14 -3
- package/dist/chunks/runtime-state-DEsyUMU-.js.map +1 -0
- package/dist/chunks/{style-engine-CeKsjtIr.js → style-engine-BX2LshDZ.js} +116 -56
- package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
- package/dist/chunks/{zero-engine-fxKu8Jbn.js → zero-engine-Dw0P4yGM.js} +22 -7
- 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-CrZOfNJ5.d.ts → config-CcxqSZI2.d.ts} +28 -9
- 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-CYJtAI9a.d.ts → index--GdqCPlp.d.ts} +58 -16
- 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 +6 -17
- 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 +1 -1
- package/dist/zero/babel.js +30 -19
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +24 -6
- package/dist/zero/index.js +4 -4
- package/dist/zero/index.js.map +1 -1
- package/dist/zero/next.d.ts +1 -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 +39 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +174 -58
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +145 -81
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +41 -40
- package/docs/methodology.md +46 -21
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +19 -16
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +61 -9
- package/docs/runtime-benchmarks.md +4 -4
- package/docs/ssr.md +92 -66
- package/docs/styles.md +33 -17
- package/docs/tasty-static.md +129 -58
- package/package.json +23 -9
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/css-definitions-DAIJxzFY.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-oi6i3ELR.js.map +0 -1
- package/dist/chunks/runtime-engine-DoULyhPt.js.map +0 -1
- package/dist/chunks/runtime-state-CZ2J5QiZ.js.map +0 -1
- package/dist/chunks/style-engine-CeKsjtIr.js.map +0 -1
- package/dist/chunks/zero-engine-fxKu8Jbn.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as DEFAULT_PROPERTIES, R as indexPropertiesByName } from "./css-definitions-ubrHP97m.js";
|
|
2
2
|
//#region src/config-resources.ts
|
|
3
3
|
let runtimeConfig = null;
|
|
4
4
|
let globalFontFace = null;
|
|
@@ -34,6 +34,17 @@ function getEffectiveProperties() {
|
|
|
34
34
|
...properties
|
|
35
35
|
} : DEFAULT_PROPERTIES;
|
|
36
36
|
}
|
|
37
|
+
let effectivePropertyIndex = null;
|
|
38
|
+
function getEffectivePropertiesByName() {
|
|
39
|
+
const source = globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES);
|
|
40
|
+
if (effectivePropertyIndex && effectivePropertyIndex.source === source) return effectivePropertyIndex.index;
|
|
41
|
+
const index = indexPropertiesByName(getEffectiveProperties());
|
|
42
|
+
effectivePropertyIndex = {
|
|
43
|
+
source,
|
|
44
|
+
index
|
|
45
|
+
};
|
|
46
|
+
return index;
|
|
47
|
+
}
|
|
37
48
|
function getGlobalFontFaces() {
|
|
38
49
|
return globalFontFace ?? getFromGlobalThis(GTKEY_FONT_FACE) ?? null;
|
|
39
50
|
}
|
|
@@ -136,6 +147,6 @@ function getRegisteredSSRCollector() {
|
|
|
136
147
|
return getter ? getter() : null;
|
|
137
148
|
}
|
|
138
149
|
//#endregion
|
|
139
|
-
export {
|
|
150
|
+
export { mergeGlobalKeyframes as _, getEffectivePropertiesByName as a, resetConfigResources as b, getGlobalFontFaces as c, getGlobalStyles as d, getRuntimeConfigState as f, mergeGlobalFunctions as g, mergeGlobalFontFaces as h, getEffectiveProperties as i, getGlobalFunctions as l, mergeGlobalCounterStyles as m, registerSSRCollectorGetter as n, getGlobalConfigTokens as o, mergeGlobalConfigTokens as p, registerSSRCollectorGetterGlobal as r, getGlobalCounterStyles as s, getRegisteredSSRCollector as t, getGlobalKeyframes as u, mergeGlobalProperties as v, setRuntimeConfigState as x, mergeGlobalStyles as y };
|
|
140
151
|
|
|
141
|
-
//# sourceMappingURL=runtime-state-
|
|
152
|
+
//# sourceMappingURL=runtime-state-DEsyUMU-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-state-DEsyUMU-.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { DeclaredPropertyEntry } from './properties';\nimport { indexPropertiesByName } from './properties';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nlet effectivePropertyIndex: {\n source: Record<string, PropertyDefinition> | null | undefined;\n index: ReadonlyMap<string, DeclaredPropertyEntry>;\n} | null = null;\n\n/**\n * The effective properties (Tasty's defaults and `configure({ properties })`)\n * keyed by the custom property each one registers — see\n * `indexPropertiesByName()`. Rebuilt only when `configure({ properties })`\n * replaces the set.\n */\nexport function getEffectivePropertiesByName(): ReadonlyMap<\n string,\n DeclaredPropertyEntry\n> {\n const source =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n\n if (effectivePropertyIndex && effectivePropertyIndex.source === source) {\n return effectivePropertyIndex.index;\n }\n\n const index = indexPropertiesByName(getEffectiveProperties());\n effectivePropertyIndex = { source, index };\n return index;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":"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"}
|
|
@@ -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;
|
|
@@ -134,8 +134,28 @@ function resolvePredefinedState(stateKey, ctx) {
|
|
|
134
134
|
function expandDimensionShorthands(condition) {
|
|
135
135
|
return condition.replace(/\b(?:w|h|is|bs)\b/g, (dimension) => dimension === "w" ? "width" : dimension === "h" ? "height" : dimension === "is" ? "inline-size" : "block-size");
|
|
136
136
|
}
|
|
137
|
+
const RE_QUERY_UNIT_NUMBER = /(?<![\w.-])(?:\d*\.\d+|\d+)([a-z][a-z0-9]*)\b/g;
|
|
137
138
|
function expandTastyUnits(value) {
|
|
138
|
-
|
|
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;
|
|
139
159
|
}
|
|
140
160
|
function findTopLevelComma(s) {
|
|
141
161
|
let depth = 0;
|
|
@@ -179,6 +199,16 @@ const CHUNK_NAMES = {
|
|
|
179
199
|
};
|
|
180
200
|
const APPEARANCE_CHUNK_STYLES = [
|
|
181
201
|
"fill",
|
|
202
|
+
"backgroundColor",
|
|
203
|
+
"image",
|
|
204
|
+
"backgroundImage",
|
|
205
|
+
"backgroundPosition",
|
|
206
|
+
"backgroundSize",
|
|
207
|
+
"backgroundRepeat",
|
|
208
|
+
"backgroundAttachment",
|
|
209
|
+
"backgroundOrigin",
|
|
210
|
+
"backgroundClip",
|
|
211
|
+
"background",
|
|
182
212
|
"color",
|
|
183
213
|
"opacity",
|
|
184
214
|
"border",
|
|
@@ -425,6 +455,9 @@ const BORDER_STYLES = [
|
|
|
425
455
|
];
|
|
426
456
|
//#endregion
|
|
427
457
|
//#region src/styles/shared.ts
|
|
458
|
+
function resolveDefaultValue(value) {
|
|
459
|
+
return parseStyle(value).groups[0]?.values[0] ?? value;
|
|
460
|
+
}
|
|
428
461
|
function extractCSSWideKeyword(group) {
|
|
429
462
|
if (group.values.length !== 1 || group.colors.length > 0) return null;
|
|
430
463
|
return CSS_WIDE_KEYWORDS.has(group.values[0]) ? group.values[0] : null;
|
|
@@ -464,9 +497,9 @@ function processGroup$1(group) {
|
|
|
464
497
|
else if (mod === "longhand") modFlags |= 16;
|
|
465
498
|
else if (lineStyle === void 0 && BORDER_STYLES.includes(mod)) lineStyle = mod;
|
|
466
499
|
const slots = assignLineSlots(values, lineStyle, colors[0]);
|
|
467
|
-
const width = values[0] || "
|
|
500
|
+
const width = values[0] || resolveDefaultValue("1bw");
|
|
468
501
|
const style = slots.style || "solid";
|
|
469
|
-
const color = slots.color || "var(--border-color
|
|
502
|
+
const color = slots.color || "var(--border-color)";
|
|
470
503
|
return {
|
|
471
504
|
modFlags,
|
|
472
505
|
width,
|
|
@@ -549,7 +582,7 @@ function borderStyle({ border }) {
|
|
|
549
582
|
}
|
|
550
583
|
const result = {};
|
|
551
584
|
const fallbackStyle = allDirectionsValue?.style || "solid";
|
|
552
|
-
const fallbackColor = allDirectionsValue?.color || "var(--border-color
|
|
585
|
+
const fallbackColor = allDirectionsValue?.color || "var(--border-color)";
|
|
553
586
|
for (const dir of DIRECTIONS) {
|
|
554
587
|
const value = directionMap[dir];
|
|
555
588
|
if (value) result[`border-${dir}`] = formatBorderValue(value);
|
|
@@ -560,8 +593,13 @@ function borderStyle({ border }) {
|
|
|
560
593
|
borderStyle.__lookupStyles = ["border"];
|
|
561
594
|
//#endregion
|
|
562
595
|
//#region src/styles/dimension.ts
|
|
563
|
-
const DEFAULT_MIN_SIZE = "
|
|
596
|
+
const DEFAULT_MIN_SIZE = "1x";
|
|
564
597
|
const DEFAULT_MAX_SIZE = "100%";
|
|
598
|
+
const STRETCH_FALLBACKS = [
|
|
599
|
+
"-webkit-fill-available",
|
|
600
|
+
"-moz-available",
|
|
601
|
+
"stretch"
|
|
602
|
+
];
|
|
565
603
|
function parseDimensionValue(val) {
|
|
566
604
|
if (val == null) return null;
|
|
567
605
|
if (typeof val === "number") return `${val}px`;
|
|
@@ -610,7 +648,7 @@ function dimensionStyle(name) {
|
|
|
610
648
|
let flag = false;
|
|
611
649
|
for (const mod of mods) switch (mod) {
|
|
612
650
|
case "min":
|
|
613
|
-
styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;
|
|
651
|
+
styles[minStyle] = values[0] || resolveDefaultValue(DEFAULT_MIN_SIZE);
|
|
614
652
|
flag = true;
|
|
615
653
|
break;
|
|
616
654
|
case "max":
|
|
@@ -636,14 +674,7 @@ function dimensionStyle(name) {
|
|
|
636
674
|
styles[maxStyle] = values[2];
|
|
637
675
|
} else styles[name] = values[0] || "auto";
|
|
638
676
|
}
|
|
639
|
-
if (styles[name] === "stretch")
|
|
640
|
-
if (name === "width") styles[name] = [
|
|
641
|
-
"stretch",
|
|
642
|
-
"-webkit-fill-available",
|
|
643
|
-
"-moz-available"
|
|
644
|
-
];
|
|
645
|
-
else styles[name] = "auto";
|
|
646
|
-
}
|
|
677
|
+
if (styles[name] === "stretch") styles[name] = STRETCH_FALLBACKS;
|
|
647
678
|
}
|
|
648
679
|
const minVal = parseDimensionValue(min);
|
|
649
680
|
const maxVal = parseDimensionValue(max);
|
|
@@ -665,11 +696,12 @@ function blockSizeStyle({ blockSize, minBlockSize, maxBlockSize }) {
|
|
|
665
696
|
blockSizeStyle.__lookupStyles = [...BLOCK_SIZE_STYLES];
|
|
666
697
|
//#endregion
|
|
667
698
|
//#region src/styles/color.ts
|
|
699
|
+
const RE_HEX_LITERAL = /^#[0-9a-f]+$/i;
|
|
668
700
|
const RE_READS_CURRENT = /var\(--current-color[,)]|currentcolor/i;
|
|
669
701
|
function colorStyle({ color }) {
|
|
670
702
|
if (!color) return null;
|
|
671
703
|
if (color === true) color = "currentColor";
|
|
672
|
-
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);
|
|
673
705
|
const styles = { color };
|
|
674
706
|
if (!RE_READS_CURRENT.test(color)) styles["--current-color"] = color;
|
|
675
707
|
return styles;
|
|
@@ -737,7 +769,7 @@ function processGroup(group, isOnlyGroup, gradients) {
|
|
|
737
769
|
const { input, values, mods, colors } = group;
|
|
738
770
|
const transparentColor = colors[0] || DEFAULT_TRANSPARENT_COLOR;
|
|
739
771
|
const opaqueColor = colors[1] || DEFAULT_OPAQUE_COLOR;
|
|
740
|
-
const firstSize = values.length ? values[0] : "
|
|
772
|
+
const firstSize = values.length ? values[0] : resolveDefaultValue("2x");
|
|
741
773
|
let namedCount = 0;
|
|
742
774
|
for (const mod of mods) {
|
|
743
775
|
const directionIndex = DIRECTIONS.indexOf(mod);
|
|
@@ -774,7 +806,8 @@ fadeStyle.__lookupStyles = ["fade"];
|
|
|
774
806
|
function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
|
|
775
807
|
if (background) return { background: parseStyle(background).output || background };
|
|
776
808
|
const result = {};
|
|
777
|
-
|
|
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);
|
|
778
811
|
if (colorValue) {
|
|
779
812
|
const parsed = parseStyle(colorValue);
|
|
780
813
|
const firstColor = parsed.groups[0]?.colors[0];
|
|
@@ -889,7 +922,7 @@ function parseSingleValue(val, defaultValue, trueValue) {
|
|
|
889
922
|
const strVal = String(val);
|
|
890
923
|
if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;
|
|
891
924
|
const { values } = parseStyle(strVal).groups[0] ?? { values: [] };
|
|
892
|
-
return values[0] || defaultValue;
|
|
925
|
+
return values[0] || resolveDefaultValue(defaultValue);
|
|
893
926
|
}
|
|
894
927
|
function directionModFlags(mods, spanModifiers) {
|
|
895
928
|
let flags = 0;
|
|
@@ -907,7 +940,7 @@ function directionModFlags(mods, spanModifiers) {
|
|
|
907
940
|
return flags;
|
|
908
941
|
}
|
|
909
942
|
function applyGroup(dirs, group, modFlags, property, defaultValue) {
|
|
910
|
-
const values = group.values.length ? group.values : [defaultValue];
|
|
943
|
+
const values = group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
|
|
911
944
|
const directions = modFlags & DIRECTION_MASK;
|
|
912
945
|
const span = modFlags & DIRECTION_SPAN;
|
|
913
946
|
if (directions && values.length > (span ? 2 : 1)) warnExtraGroupValues(property, group.input, span ? 2 : 1);
|
|
@@ -1093,7 +1126,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
|
|
|
1093
1126
|
const modFlags = logicalModFlags(group.mods);
|
|
1094
1127
|
const hasDirection = modFlags & 3;
|
|
1095
1128
|
const keyword = extractCSSWideKeyword(group);
|
|
1096
|
-
const values = keyword ? [keyword] : group.values.length ? group.values : [defaultValue];
|
|
1129
|
+
const values = keyword ? [keyword] : group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
|
|
1097
1130
|
if (hasDirection && values.length > 1) warnExtraGroupValues(styleName, group.input, 1, LOGICAL_DIRECTIONS);
|
|
1098
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.`);
|
|
1099
1132
|
if (modFlags & LOGICAL_LONGHAND) useLonghand = true;
|
|
@@ -1116,7 +1149,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
|
|
|
1116
1149
|
}
|
|
1117
1150
|
function zeroBorderValue(value) {
|
|
1118
1151
|
const firstSpace = value.indexOf(" ");
|
|
1119
|
-
return firstSpace === -1 ? "0 solid var(--border-color
|
|
1152
|
+
return firstSpace === -1 ? "0 solid var(--border-color)" : `0${value.slice(firstSpace)}`;
|
|
1120
1153
|
}
|
|
1121
1154
|
function logicalBorderStyle(styleName, cssProperty) {
|
|
1122
1155
|
const handler = ((styles) => {
|
|
@@ -1130,7 +1163,7 @@ function logicalBorderStyle(styleName, cssProperty) {
|
|
|
1130
1163
|
start: null,
|
|
1131
1164
|
end: null
|
|
1132
1165
|
};
|
|
1133
|
-
let fallback = "0 solid var(--border-color
|
|
1166
|
+
let fallback = "0 solid var(--border-color)";
|
|
1134
1167
|
let useLonghand = false;
|
|
1135
1168
|
for (const group of groups) {
|
|
1136
1169
|
const borderValue = parseBorderValue(group.input);
|
|
@@ -1171,8 +1204,8 @@ function logicalBorderStyles(styleNames) {
|
|
|
1171
1204
|
return Object.fromEntries(styleNames.map((styleName, index) => [styleName, logicalBorderStyle(styleName, `border-${index ? "inline" : "block"}`)]));
|
|
1172
1205
|
}
|
|
1173
1206
|
const logicalStyleHandlers = {
|
|
1174
|
-
...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "
|
|
1175
|
-
...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "
|
|
1207
|
+
...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "1x", "1x", "0"),
|
|
1208
|
+
...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "1x", "1x", "0"),
|
|
1176
1209
|
...logicalAxisStyles(LOGICAL_INSET_STYLES, "inset", "0", "0", "auto"),
|
|
1177
1210
|
...logicalAxisStyles(LOGICAL_SCROLL_MARGIN_STYLES, "scroll-margin", "0", "1x", "0"),
|
|
1178
1211
|
...logicalAxisStyles(LOGICAL_SCROLL_PADDING_STYLES, "scroll-padding", "0", "1x", "0"),
|
|
@@ -1182,7 +1215,7 @@ const logicalStyleHandlers = {
|
|
|
1182
1215
|
//#region src/styles/margin.ts
|
|
1183
1216
|
const MARGIN_CONFIG = {
|
|
1184
1217
|
property: "margin",
|
|
1185
|
-
defaultValue: "
|
|
1218
|
+
defaultValue: "1x",
|
|
1186
1219
|
trueValue: "1x",
|
|
1187
1220
|
defaultInit: "0"
|
|
1188
1221
|
};
|
|
@@ -1227,7 +1260,7 @@ function outlineStyle({ outline, outlineOffset }) {
|
|
|
1227
1260
|
break;
|
|
1228
1261
|
}
|
|
1229
1262
|
const slots = assignLineSlots(outlinePart.values, lineStyle, outlinePart.colors[0]);
|
|
1230
|
-
result.outline = `${outlinePart.values[0] || "
|
|
1263
|
+
result.outline = `${outlinePart.values[0] || resolveDefaultValue("1ow")} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
|
|
1231
1264
|
if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
|
|
1232
1265
|
}
|
|
1233
1266
|
}
|
|
@@ -1243,7 +1276,7 @@ outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
|
|
|
1243
1276
|
//#region src/styles/padding.ts
|
|
1244
1277
|
const PADDING_CONFIG = {
|
|
1245
1278
|
property: "padding",
|
|
1246
|
-
defaultValue: "
|
|
1279
|
+
defaultValue: "1x",
|
|
1247
1280
|
trueValue: "1x",
|
|
1248
1281
|
defaultInit: "0"
|
|
1249
1282
|
};
|
|
@@ -1337,6 +1370,7 @@ const PRESET_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
1337
1370
|
"normal"
|
|
1338
1371
|
]);
|
|
1339
1372
|
const SANS_FONT = "var(--font-sans, var(--font-sans-fallback))";
|
|
1373
|
+
const MONO_FONT = "var(--font-mono, var(--font-mono-fallback))";
|
|
1340
1374
|
function toCSS(value, isNumeric) {
|
|
1341
1375
|
if (value == null) return null;
|
|
1342
1376
|
if (typeof value === "number") return isNumeric ? `${value}px` : String(value);
|
|
@@ -1356,7 +1390,7 @@ function setCSSValue(styles, styleName, presetName, mode) {
|
|
|
1356
1390
|
function resolveFontFamily(font, fontFamily) {
|
|
1357
1391
|
if (fontFamily) return resolveCustomProperties(fontFamily);
|
|
1358
1392
|
if (font == null || font === false) return null;
|
|
1359
|
-
if (font === "monospace") return
|
|
1393
|
+
if (font === "monospace") return MONO_FONT;
|
|
1360
1394
|
if (font === true) return SANS_FONT;
|
|
1361
1395
|
return `${resolveCustomProperties(font)}, ${SANS_FONT}`;
|
|
1362
1396
|
}
|
|
@@ -1425,7 +1459,7 @@ presetStyle.__lookupStyles = [
|
|
|
1425
1459
|
];
|
|
1426
1460
|
//#endregion
|
|
1427
1461
|
//#region src/styles/radius.ts
|
|
1428
|
-
const
|
|
1462
|
+
const DEFAULT_RADIUS = "1r";
|
|
1429
1463
|
const SHARP = "var(--sharp-radius)";
|
|
1430
1464
|
const RADIUS_LONGHANDS = [
|
|
1431
1465
|
"border-top-left-radius",
|
|
@@ -1470,19 +1504,20 @@ function radiusStyle({ radius }) {
|
|
|
1470
1504
|
for (const i of corners) result[RADIUS_LONGHANDS[i]] = keyword;
|
|
1471
1505
|
return result;
|
|
1472
1506
|
}
|
|
1507
|
+
const defaultRadius = resolveDefaultValue(DEFAULT_RADIUS);
|
|
1473
1508
|
if (mods.includes("round")) values = ["9999rem"];
|
|
1474
1509
|
else if (mods.includes("ellipse")) values = ["50%"];
|
|
1475
|
-
else if (!values.length) values = [
|
|
1510
|
+
else if (!values.length) values = [defaultRadius];
|
|
1476
1511
|
if (mods.includes("leaf")) values = [
|
|
1477
1512
|
values[1] || SHARP,
|
|
1478
|
-
values[0] ||
|
|
1513
|
+
values[0] || defaultRadius,
|
|
1479
1514
|
values[1] || SHARP,
|
|
1480
|
-
values[0] ||
|
|
1515
|
+
values[0] || defaultRadius
|
|
1481
1516
|
];
|
|
1482
1517
|
else if (mods.includes("backleaf")) values = [
|
|
1483
|
-
values[0] ||
|
|
1518
|
+
values[0] || defaultRadius,
|
|
1484
1519
|
values[1] || SHARP,
|
|
1485
|
-
values[0] ||
|
|
1520
|
+
values[0] || defaultRadius,
|
|
1486
1521
|
values[1] || SHARP
|
|
1487
1522
|
];
|
|
1488
1523
|
else if (mods.length) {
|
|
@@ -1494,7 +1529,7 @@ function radiusStyle({ radius }) {
|
|
|
1494
1529
|
"0",
|
|
1495
1530
|
"0"
|
|
1496
1531
|
];
|
|
1497
|
-
for (const i of corners) arr[i] = values[0] ||
|
|
1532
|
+
for (const i of corners) arr[i] = values[0] || defaultRadius;
|
|
1498
1533
|
values = arr;
|
|
1499
1534
|
}
|
|
1500
1535
|
}
|
|
@@ -1686,7 +1721,6 @@ const MAP = {
|
|
|
1686
1721
|
"height"
|
|
1687
1722
|
],
|
|
1688
1723
|
gap: ["gap", "margin"],
|
|
1689
|
-
zIndex: ["z-index"],
|
|
1690
1724
|
inset: [
|
|
1691
1725
|
"inset",
|
|
1692
1726
|
"top",
|
|
@@ -1695,6 +1729,7 @@ const MAP = {
|
|
|
1695
1729
|
"left"
|
|
1696
1730
|
]
|
|
1697
1731
|
};
|
|
1732
|
+
const NAME_ALIASES = { zindex: "z-index" };
|
|
1698
1733
|
const DEFAULT_EASING = "linear";
|
|
1699
1734
|
const EASING_KEYWORDS = new Set("ease ease-in ease-out ease-in-out linear step-start step-end".split(" "));
|
|
1700
1735
|
function isEasing(token) {
|
|
@@ -1711,8 +1746,9 @@ function transitionStyle({ transition }) {
|
|
|
1711
1746
|
const named = /* @__PURE__ */ new Set();
|
|
1712
1747
|
for (const group of processed.groups) {
|
|
1713
1748
|
const tokens = group.all;
|
|
1714
|
-
|
|
1749
|
+
let name = tokens[0];
|
|
1715
1750
|
if (!name || isTokenNameReference("transition", name)) continue;
|
|
1751
|
+
name = NAME_ALIASES[name] ?? name;
|
|
1716
1752
|
let timing;
|
|
1717
1753
|
let easing;
|
|
1718
1754
|
let delay;
|
|
@@ -2054,6 +2090,17 @@ function splitSelectorsSafely(selectorList) {
|
|
|
2054
2090
|
}
|
|
2055
2091
|
//#endregion
|
|
2056
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
|
+
}
|
|
2057
2104
|
function buildDimensionCondition(dimension, lowerBound, upperBound, emptyDimension = dimension) {
|
|
2058
2105
|
if (lowerBound && upperBound) {
|
|
2059
2106
|
const lowerOp = lowerBound.inclusive ? "<=" : "<";
|
|
@@ -2488,8 +2535,12 @@ function hasRangeContradiction(terms) {
|
|
|
2488
2535
|
const containerByDim = /* @__PURE__ */ new Map();
|
|
2489
2536
|
for (const term of terms) {
|
|
2490
2537
|
if (term.kind !== "state") continue;
|
|
2491
|
-
if (term.type
|
|
2492
|
-
|
|
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}`;
|
|
2493
2544
|
let group = mediaByDim.get(key);
|
|
2494
2545
|
if (!group) {
|
|
2495
2546
|
group = {
|
|
@@ -2501,8 +2552,8 @@ function hasRangeContradiction(terms) {
|
|
|
2501
2552
|
if (term.negated) group.negated.push(term);
|
|
2502
2553
|
else group.positive.push(term);
|
|
2503
2554
|
}
|
|
2504
|
-
if (term.type === "container"
|
|
2505
|
-
const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
|
|
2555
|
+
if (term.type === "container") {
|
|
2556
|
+
const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
|
|
2506
2557
|
let group = containerByDim.get(key);
|
|
2507
2558
|
if (!group) {
|
|
2508
2559
|
group = {
|
|
@@ -2697,8 +2748,12 @@ function mergeRanges(terms) {
|
|
|
2697
2748
|
const containerByDim = /* @__PURE__ */ new Map();
|
|
2698
2749
|
terms.forEach((term, index) => {
|
|
2699
2750
|
if (term.kind !== "state") return;
|
|
2700
|
-
if (term.type
|
|
2701
|
-
|
|
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}`;
|
|
2702
2757
|
let group = mediaByDim.get(key);
|
|
2703
2758
|
if (!group) {
|
|
2704
2759
|
group = {
|
|
@@ -2710,8 +2765,8 @@ function mergeRanges(terms) {
|
|
|
2710
2765
|
group.conditions.push(term);
|
|
2711
2766
|
group.indices.push(index);
|
|
2712
2767
|
}
|
|
2713
|
-
if (term.type === "container"
|
|
2714
|
-
const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
|
|
2768
|
+
if (term.type === "container") {
|
|
2769
|
+
const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
|
|
2715
2770
|
let group = containerByDim.get(key);
|
|
2716
2771
|
if (!group) {
|
|
2717
2772
|
group = {
|
|
@@ -2972,14 +3027,16 @@ function hasMediaContradiction(conditions) {
|
|
|
2972
3027
|
if (existing !== void 0 && existing !== !cond.negated) return true;
|
|
2973
3028
|
polarities.set(key, !cond.negated);
|
|
2974
3029
|
if (cond.subtype !== "dimension" || cond.negated) continue;
|
|
2975
|
-
const
|
|
2976
|
-
|
|
3030
|
+
const unit = getRangeUnit(cond);
|
|
3031
|
+
if (unit === null) continue;
|
|
3032
|
+
const rangeKey = `${cond.dimension || "width"}|${unit}`;
|
|
3033
|
+
let bounds = dimensionsByDim.get(rangeKey);
|
|
2977
3034
|
if (!bounds) {
|
|
2978
3035
|
bounds = {
|
|
2979
3036
|
lowerBound: null,
|
|
2980
3037
|
upperBound: null
|
|
2981
3038
|
};
|
|
2982
|
-
dimensionsByDim.set(
|
|
3039
|
+
dimensionsByDim.set(rangeKey, bounds);
|
|
2983
3040
|
}
|
|
2984
3041
|
if (cond.lowerBound?.valueNumeric != null) {
|
|
2985
3042
|
const value = cond.lowerBound.valueNumeric;
|
|
@@ -4362,14 +4419,14 @@ var Parser = class {
|
|
|
4362
4419
|
const content = raw.slice(7, -1);
|
|
4363
4420
|
if (!content.trim()) return trueCondition();
|
|
4364
4421
|
let condition = expandDimensionShorthands(content);
|
|
4365
|
-
condition =
|
|
4422
|
+
condition = expandQueryUnits(condition);
|
|
4366
4423
|
if (condition.includes(":") && !condition.includes("<") && !condition.includes(">") && !condition.includes("=")) {
|
|
4367
4424
|
const colonIdx = condition.indexOf(":");
|
|
4368
4425
|
return createMediaFeatureCondition(condition.slice(0, colonIdx).trim(), condition.slice(colonIdx + 1).trim(), false, raw);
|
|
4369
4426
|
}
|
|
4370
4427
|
if (!condition.includes("<") && !condition.includes(">") && !condition.includes("=")) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
|
|
4371
4428
|
const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(condition);
|
|
4372
|
-
if (!dimension) return
|
|
4429
|
+
if (!dimension) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
|
|
4373
4430
|
return createMediaDimensionCondition(dimension, lowerBound, upperBound, false, raw);
|
|
4374
4431
|
}
|
|
4375
4432
|
parseDimensionCondition(condition) {
|
|
@@ -4502,9 +4559,9 @@ var Parser = class {
|
|
|
4502
4559
|
}
|
|
4503
4560
|
if (/^[a-zA-Z][\w-]*\s*\(/.test(condition)) return createContainerRawCondition(condition, containerName, false, raw);
|
|
4504
4561
|
let expandedCondition = expandDimensionShorthands(condition);
|
|
4505
|
-
expandedCondition =
|
|
4562
|
+
expandedCondition = expandQueryUnits(expandedCondition);
|
|
4506
4563
|
const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(expandedCondition);
|
|
4507
|
-
if (!dimension) return
|
|
4564
|
+
if (!dimension) return createContainerRawCondition(`(${expandedCondition.trim()})`, containerName, false, raw);
|
|
4508
4565
|
return createContainerDimensionCondition(dimension, lowerBound, upperBound, containerName, false, raw);
|
|
4509
4566
|
}
|
|
4510
4567
|
parsePredefinedState(raw) {
|
|
@@ -4669,7 +4726,10 @@ function invokeHandler(handler, stateSnapshots, selectorSuffix) {
|
|
|
4669
4726
|
const declarations = {};
|
|
4670
4727
|
for (const [prop, val] of Object.entries(styleProps)) {
|
|
4671
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.`);
|
|
4672
|
-
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);
|
|
4673
4733
|
}
|
|
4674
4734
|
if (Object.keys(declarations).length === 0) continue;
|
|
4675
4735
|
const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
|
|
@@ -5000,7 +5060,7 @@ function buildSelectorFromVariant(variant, selectorSuffix) {
|
|
|
5000
5060
|
function materializeComputedRule(rule) {
|
|
5001
5061
|
const components = conditionToCSS(rule.condition);
|
|
5002
5062
|
if (components.isImpossible || components.variants.length === 0) return [];
|
|
5003
|
-
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(" ");
|
|
5004
5064
|
const byAtRules = /* @__PURE__ */ new Map();
|
|
5005
5065
|
for (const variant of components.variants) {
|
|
5006
5066
|
const atRules = buildAtRulesFromVariant(variant);
|
|
@@ -5403,4 +5463,4 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
|
5403
5463
|
//#endregion
|
|
5404
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 };
|
|
5405
5465
|
|
|
5406
|
-
//# sourceMappingURL=style-engine-
|
|
5466
|
+
//# sourceMappingURL=style-engine-BX2LshDZ.js.map
|