@ui5/webcomponents-tools 2.28.0 → 2.29.0-rc.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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.29.0-rc.0](https://github.com/UI5/webcomponents/compare/v2.28.1...v2.29.0-rc.0) (2026-10-30)
7
+
8
+
9
+ ### Reverts
10
+
11
+ * Revert "chore(tools): remove postcss workaround for CSS container style queries" (#14203) ([aeaa29a](https://github.com/UI5/webcomponents/commit/aeaa29a82718aaad1fd7d6493f0b0e2fdc4ff670)), closes [#14203](https://github.com/UI5/webcomponents/issues/14203)
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.28.1](https://github.com/UI5/webcomponents/compare/v2.28.0...v2.28.1) (2026-10-21)
18
+
19
+ **Note:** Version bump only for package @ui5/webcomponents-tools
20
+
21
+
22
+
23
+
24
+
6
25
  # [2.28.0](https://github.com/UI5/webcomponents/compare/v2.28.0-rc.0...v2.28.0) (2026-10-21)
7
26
 
8
27
  **Note:** Version bump only for package @ui5/webcomponents-tools
@@ -5,6 +5,7 @@ import * as path from "path";
5
5
  import { writeFile, mkdir } from "fs/promises";
6
6
  import postcss from "postcss";
7
7
  import combineDuplicatedSelectors from "../postcss-combine-duplicated-selectors/index.js"
8
+ import postcssPlugin from "./postcss-plugin.mjs";
8
9
  import { writeFileIfChanged, getFileContent } from "./shared.mjs";
9
10
  import scopeVariables from "./scope-variables.mjs";
10
11
  import { mergeLightDark } from "./merge-light-dark.mjs";
@@ -74,7 +75,8 @@ const generate = async (argv) => {
74
75
  const processComponentPackageFile = async (f) => {
75
76
  if (CSS_VARIABLES_TARGET) {
76
77
  const result = await postcss([
77
- combineDuplicatedSelectors
78
+ combineDuplicatedSelectors,
79
+ postcssPlugin
78
80
  ]).process(f.text, { from: undefined });
79
81
 
80
82
  return { css: result.css };
@@ -160,6 +162,7 @@ const generate = async (argv) => {
160
162
  await esbuild.build(config);
161
163
  }
162
164
  }
165
+
163
166
  /**
164
167
  * Adds auto theme setup CSS: color-scheme declaration.
165
168
  * @param {string} mergedCSS - The merged :root CSS from mergeLightDark()
@@ -0,0 +1,152 @@
1
+
2
+ import postcss from "postcss";
3
+
4
+ const hostVariables = new Map();
5
+
6
+ const SELECTOR = ":host";
7
+
8
+ const saveVariable = (variable, value, density) => {
9
+ if (!hostVariables.has(variable)) {
10
+ hostVariables.set(variable, {});
11
+ }
12
+ hostVariables.get(variable)[density] = value;
13
+ }
14
+
15
+ /**
16
+ * PostCSS plugin for handling CSS variables across density modes (cozy and compact).
17
+ *
18
+ * The plugin scans CSS for `:host` rules that define density-specific custom properties.
19
+ * Variables declared in a root-level `:host` rule are treated as **cozy** values, while
20
+ * variables declared inside `@ui5-compact-size` `:host` rules are treated as **compact** values.
21
+ *
22
+ * All discovered variables are merged into a single root `:host` rule. For variables that
23
+ * exist in both modes, the plugin generates a value that uses CSS variable fallbacks to
24
+ * dynamically switch between compact and cozy values based on the active density.
25
+ *
26
+ * Variables that exist in only one mode are preserved, with appropriate fallbacks added
27
+ * when needed.
28
+ *
29
+ * Example input:
30
+ *
31
+ * ```css
32
+ * :host {
33
+ * --my-variable: cozy-value;
34
+ * --cozy-only-variable: cozy-only-value;
35
+ * }
36
+ *
37
+ * @ui5-compact-size {
38
+ * :host {
39
+ * --my-variable: compact-value;
40
+ * --compact-only-variable: compact-only;
41
+ * }
42
+ * }
43
+ * ```
44
+ *
45
+ * Output:
46
+ *
47
+ * ```css
48
+ * :host {
49
+ * --my-variable: var(--_ui5-compact-size, compact-value) var(--_ui5-cozy-size, cozy-value);
50
+ * --compact-only-variable: var(--_ui5-compact-size, compact-only) var(--_ui5-cozy-size, initial);
51
+ * --cozy-only-variable: cozy-only-value;
52
+ * }
53
+ * ```
54
+ *
55
+ * This enables seamless runtime switching between density modes using CSS variables alone.
56
+ */
57
+
58
+ export default function postcssPlugin() {
59
+ return {
60
+ postcssPlugin: 'postcss-content-density-variables',
61
+ Once(root) {
62
+ let hasRootHost = false;
63
+ let hostRule;
64
+
65
+ root.walkRules((rule) => {
66
+ // Only process :host rules
67
+ if (rule.selector !== SELECTOR) {
68
+ return;
69
+ }
70
+
71
+ // Handle root-level :host rules (cozy)
72
+ if (rule.parent.type === "root") {
73
+ if (!hasRootHost) {
74
+ hasRootHost = true;
75
+ hostRule = rule;
76
+ }
77
+
78
+ rule.walkDecls((decl) => {
79
+ if (decl.prop.startsWith('--')) {
80
+ saveVariable(decl.prop, decl.value, 'cozy');
81
+ decl.remove();
82
+ }
83
+ });
84
+ }
85
+
86
+ // Handle :host rules inside @ui5-compact-size (compact)
87
+ if (rule.parent.type === "atrule") {
88
+ if (rule.parent.name === "ui5-compact-size") {
89
+ rule.walkDecls((decl) => {
90
+ if (decl.prop.startsWith('--')) {
91
+ saveVariable(decl.prop, decl.value, 'compact');
92
+ decl.remove();
93
+ }
94
+ });
95
+ }
96
+ }
97
+
98
+ let current = rule;
99
+ // Remove up empty rules
100
+ while (current) {
101
+ if (current.nodes.length === 0) {
102
+ const parent = current.parent;
103
+ current.remove();
104
+ current = parent;
105
+ }
106
+
107
+ if (current.type === "root") {
108
+ break;
109
+ }
110
+ }
111
+ });
112
+
113
+ if (!hasRootHost) {
114
+ hostRule = postcss.rule({ selector: SELECTOR });
115
+ }
116
+
117
+ // Construct merged variable declarations depending on available modes
118
+ for (const [variable, variableData] of hostVariables) {
119
+ if (variableData.cozy && variableData.compact) {
120
+ hostRule.append({
121
+ prop: variable,
122
+ value: `var(--_ui5-compact-size, ${variableData.compact}) var(--_ui5-cozy-size, ${variableData.cozy})`,
123
+ });
124
+ } else if (variableData.compact) {
125
+
126
+ // Use a non-existent variable to always trigger the fallback.
127
+ // Because this variable is never defined, the fallback is used
128
+ // in all cases.
129
+
130
+ // Using `initial` as a fallback can work only for properties
131
+ // that treat it as an invalid value. To avoid this inconsistency,
132
+ // we intentionally reference an undefined variable, which is
133
+ // always considered invalid and undefined.
134
+ hostRule.append({
135
+ prop: variable,
136
+ value: `var(--_ui5-compact-size, ${variableData.compact}) var(--_ui5-cozy-size, var(--_ui5-f2d95f8))`,
137
+ });
138
+ } else {
139
+ hostRule.append({
140
+ prop: variable,
141
+ value: variableData.cozy,
142
+ });
143
+ }
144
+ }
145
+
146
+ root.prepend(hostRule);
147
+ hostVariables.clear();
148
+ }
149
+ }
150
+ }
151
+
152
+ postcssPlugin.postcss = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "2.28.0",
3
+ "version": "2.29.0-rc.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -82,5 +82,5 @@
82
82
  "esbuild": "^0.25.0",
83
83
  "yargs": "^17.5.1"
84
84
  },
85
- "gitHead": "8fdaadeb2c7cbf0eb3a42e6dbdbdca1f27bb6797"
85
+ "gitHead": "ace8be9008be626e7be5bca0e23ace75c045a188"
86
86
  }