@bamboocss/generator 1.57.5 → 1.57.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +32 -16
- package/dist/index.mjs +32 -16
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2192,7 +2192,13 @@ function stringifyVars(options) {
|
|
|
2192
2192
|
}
|
|
2193
2193
|
const anyTheme = conditions.isThemeCondition(keys[0]) ? conditions.getThemeSelector() : void 0;
|
|
2194
2194
|
const rules = combos.map((segments) => {
|
|
2195
|
-
|
|
2195
|
+
let nested = false;
|
|
2196
|
+
const rule = getDeepestRule(root, segments.map((segment) => {
|
|
2197
|
+
if (segment.startsWith("@")) return segment;
|
|
2198
|
+
const meets = nested;
|
|
2199
|
+
nested = true;
|
|
2200
|
+
return meets ? transformNestedSegment(segment, anyTheme) : transformSegment(segment);
|
|
2201
|
+
}).filter(Boolean));
|
|
2196
2202
|
if (!rule) return;
|
|
2197
2203
|
getDeepestNode(rule)?.append(css);
|
|
2198
2204
|
return (0, _bamboocss_core.expandNestedCss)(rule.toString());
|
|
@@ -2233,26 +2239,29 @@ function transformSegment(seg) {
|
|
|
2233
2239
|
return parent ? `&${parent}` : seg;
|
|
2234
2240
|
}
|
|
2235
2241
|
/**
|
|
2236
|
-
* A condition
|
|
2242
|
+
* A condition after another selector condition, as the selector nested under the element that one
|
|
2243
|
+
* declares on: a theme's root, or the element `.dark &` names.
|
|
2237
2244
|
*
|
|
2238
2245
|
* A theme's tokens are declared on its root, `[data-bamboo-theme=pastel]`, and inherit from there.
|
|
2239
2246
|
* `.dark &` was compounded onto that root, as `transformSegment` writes it, and so held only where
|
|
2240
2247
|
* the theme attribute and the dark class share an element: a theme in a page that `<html
|
|
2241
2248
|
* class="dark">` puts in dark mode kept its light values, and a dark panel inside the theme took
|
|
2242
|
-
* the default dark values instead of the theme's.
|
|
2249
|
+
* the default dark values instead of the theme's. `.hc &` after `.dark &` was compounded the same
|
|
2250
|
+
* way outside a theme, `.dark.hc`, where an ordinary `css()` call nesting the two applies under
|
|
2251
|
+
* `.hc .dark`: a page with `.hc` above `.dark` kept the token's dark value alone.
|
|
2243
2252
|
*
|
|
2244
|
-
* So each `P &` in it meets
|
|
2245
|
-
* else is nested as it is written: `&:hover` on the
|
|
2253
|
+
* So each `P &` in it meets that element wherever the two can, as `boundaries` writes it. Anything
|
|
2254
|
+
* else is nested as it is written: `&:hover` on the element, `.dark > &` above it alone, and
|
|
2246
2255
|
* `.dark & .panel` around it.
|
|
2247
2256
|
*/
|
|
2248
|
-
function
|
|
2257
|
+
function transformNestedSegment(segment, anyTheme) {
|
|
2249
2258
|
if (segment.startsWith("@")) return segment;
|
|
2250
2259
|
const selectors = (0, _bamboocss_core.splitSelectors)(segment);
|
|
2251
2260
|
const parents = selectors.map(_bamboocss_core.nestingParent);
|
|
2252
2261
|
if (parents.some((parent) => parent !== void 0 && hasPseudoElement(parent))) return transformSegment(segment);
|
|
2253
2262
|
const meeting = selectors.flatMap((selector, index) => {
|
|
2254
2263
|
const parent = parents[index];
|
|
2255
|
-
return parent === void 0 ? [selector] :
|
|
2264
|
+
return parent === void 0 ? [selector] : boundaries(parent, anyTheme);
|
|
2256
2265
|
});
|
|
2257
2266
|
return [...new Set(meeting)].join(", ");
|
|
2258
2267
|
}
|
|
@@ -2261,20 +2270,27 @@ const hasPseudoElement = (selector) => withoutQuotes(selector).includes("::");
|
|
|
2261
2270
|
/** A selector without what its quoted values hold, so a `::` in one is not read as its own. */
|
|
2262
2271
|
const withoutQuotes = (selector) => selector.replace(/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g, "\"\"");
|
|
2263
2272
|
/**
|
|
2264
|
-
* Where `P` in `P &` meets
|
|
2265
|
-
*
|
|
2273
|
+
* Where `P` in `P &` meets the element `&` declares on — a theme's root, or the element an earlier
|
|
2274
|
+
* condition names: above it and on it, and for a theme inside it too, where the theme's values are
|
|
2275
|
+
* declared on the element `P` names.
|
|
2266
2276
|
*
|
|
2267
|
-
* Each is more specific than the
|
|
2268
|
-
*
|
|
2269
|
-
*
|
|
2270
|
-
*
|
|
2271
|
-
*
|
|
2272
|
-
*
|
|
2277
|
+
* Each is more specific than the values on `&` alone and than the default `P` rule, so it wins over
|
|
2278
|
+
* both in whichever order they are written — but for the root of another theme nested in this one.
|
|
2279
|
+
* There the nested theme's own `P` values have to win, and this one's only fill in what it leaves
|
|
2280
|
+
* out, so the rule for that root is no more specific than the root's own. It wins over the default
|
|
2281
|
+
* rule by coming after it, and against a value the nested theme sets for every condition, the order
|
|
2282
|
+
* of the two themes decides.
|
|
2283
|
+
*
|
|
2284
|
+
* Outside a theme nothing tells such a root from any other element, so a condition meets the one
|
|
2285
|
+
* before it from above and on it alone, where an ordinary `css()` call nesting the two applies and
|
|
2286
|
+
* where both are on one element. Inside it, `.dark .hc` would declare on a `.light` panel or the root
|
|
2287
|
+
* of a region of the project's own, `[data-color=pastel]`, over the values that one has to keep.
|
|
2273
2288
|
*/
|
|
2274
|
-
function
|
|
2289
|
+
function boundaries(parent, anyTheme) {
|
|
2275
2290
|
if (parent === "*") return ["* &"];
|
|
2276
2291
|
const compound = (0, _bamboocss_core.isCompound)(parent);
|
|
2277
2292
|
const on = compound && /^[.[:#]/.test(parent) ? parent : `:is(${parent})`;
|
|
2293
|
+
if (anyTheme === void 0) return [`${parent} &`, `&${on}`];
|
|
2278
2294
|
const inside = compound ? parent : `:is(${parent})`;
|
|
2279
2295
|
return [
|
|
2280
2296
|
`${parent} &`,
|
package/dist/index.mjs
CHANGED
|
@@ -2166,7 +2166,13 @@ function stringifyVars(options) {
|
|
|
2166
2166
|
}
|
|
2167
2167
|
const anyTheme = conditions.isThemeCondition(keys[0]) ? conditions.getThemeSelector() : void 0;
|
|
2168
2168
|
const rules = combos.map((segments) => {
|
|
2169
|
-
|
|
2169
|
+
let nested = false;
|
|
2170
|
+
const rule = getDeepestRule(root, segments.map((segment) => {
|
|
2171
|
+
if (segment.startsWith("@")) return segment;
|
|
2172
|
+
const meets = nested;
|
|
2173
|
+
nested = true;
|
|
2174
|
+
return meets ? transformNestedSegment(segment, anyTheme) : transformSegment(segment);
|
|
2175
|
+
}).filter(Boolean));
|
|
2170
2176
|
if (!rule) return;
|
|
2171
2177
|
getDeepestNode(rule)?.append(css);
|
|
2172
2178
|
return expandNestedCss(rule.toString());
|
|
@@ -2207,26 +2213,29 @@ function transformSegment(seg) {
|
|
|
2207
2213
|
return parent ? `&${parent}` : seg;
|
|
2208
2214
|
}
|
|
2209
2215
|
/**
|
|
2210
|
-
* A condition
|
|
2216
|
+
* A condition after another selector condition, as the selector nested under the element that one
|
|
2217
|
+
* declares on: a theme's root, or the element `.dark &` names.
|
|
2211
2218
|
*
|
|
2212
2219
|
* A theme's tokens are declared on its root, `[data-bamboo-theme=pastel]`, and inherit from there.
|
|
2213
2220
|
* `.dark &` was compounded onto that root, as `transformSegment` writes it, and so held only where
|
|
2214
2221
|
* the theme attribute and the dark class share an element: a theme in a page that `<html
|
|
2215
2222
|
* class="dark">` puts in dark mode kept its light values, and a dark panel inside the theme took
|
|
2216
|
-
* the default dark values instead of the theme's.
|
|
2223
|
+
* the default dark values instead of the theme's. `.hc &` after `.dark &` was compounded the same
|
|
2224
|
+
* way outside a theme, `.dark.hc`, where an ordinary `css()` call nesting the two applies under
|
|
2225
|
+
* `.hc .dark`: a page with `.hc` above `.dark` kept the token's dark value alone.
|
|
2217
2226
|
*
|
|
2218
|
-
* So each `P &` in it meets
|
|
2219
|
-
* else is nested as it is written: `&:hover` on the
|
|
2227
|
+
* So each `P &` in it meets that element wherever the two can, as `boundaries` writes it. Anything
|
|
2228
|
+
* else is nested as it is written: `&:hover` on the element, `.dark > &` above it alone, and
|
|
2220
2229
|
* `.dark & .panel` around it.
|
|
2221
2230
|
*/
|
|
2222
|
-
function
|
|
2231
|
+
function transformNestedSegment(segment, anyTheme) {
|
|
2223
2232
|
if (segment.startsWith("@")) return segment;
|
|
2224
2233
|
const selectors = splitSelectors(segment);
|
|
2225
2234
|
const parents = selectors.map(nestingParent);
|
|
2226
2235
|
if (parents.some((parent) => parent !== void 0 && hasPseudoElement(parent))) return transformSegment(segment);
|
|
2227
2236
|
const meeting = selectors.flatMap((selector, index) => {
|
|
2228
2237
|
const parent = parents[index];
|
|
2229
|
-
return parent === void 0 ? [selector] :
|
|
2238
|
+
return parent === void 0 ? [selector] : boundaries(parent, anyTheme);
|
|
2230
2239
|
});
|
|
2231
2240
|
return [...new Set(meeting)].join(", ");
|
|
2232
2241
|
}
|
|
@@ -2235,20 +2244,27 @@ const hasPseudoElement = (selector) => withoutQuotes(selector).includes("::");
|
|
|
2235
2244
|
/** A selector without what its quoted values hold, so a `::` in one is not read as its own. */
|
|
2236
2245
|
const withoutQuotes = (selector) => selector.replace(/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g, "\"\"");
|
|
2237
2246
|
/**
|
|
2238
|
-
* Where `P` in `P &` meets
|
|
2239
|
-
*
|
|
2247
|
+
* Where `P` in `P &` meets the element `&` declares on — a theme's root, or the element an earlier
|
|
2248
|
+
* condition names: above it and on it, and for a theme inside it too, where the theme's values are
|
|
2249
|
+
* declared on the element `P` names.
|
|
2240
2250
|
*
|
|
2241
|
-
* Each is more specific than the
|
|
2242
|
-
*
|
|
2243
|
-
*
|
|
2244
|
-
*
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
2251
|
+
* Each is more specific than the values on `&` alone and than the default `P` rule, so it wins over
|
|
2252
|
+
* both in whichever order they are written — but for the root of another theme nested in this one.
|
|
2253
|
+
* There the nested theme's own `P` values have to win, and this one's only fill in what it leaves
|
|
2254
|
+
* out, so the rule for that root is no more specific than the root's own. It wins over the default
|
|
2255
|
+
* rule by coming after it, and against a value the nested theme sets for every condition, the order
|
|
2256
|
+
* of the two themes decides.
|
|
2257
|
+
*
|
|
2258
|
+
* Outside a theme nothing tells such a root from any other element, so a condition meets the one
|
|
2259
|
+
* before it from above and on it alone, where an ordinary `css()` call nesting the two applies and
|
|
2260
|
+
* where both are on one element. Inside it, `.dark .hc` would declare on a `.light` panel or the root
|
|
2261
|
+
* of a region of the project's own, `[data-color=pastel]`, over the values that one has to keep.
|
|
2247
2262
|
*/
|
|
2248
|
-
function
|
|
2263
|
+
function boundaries(parent, anyTheme) {
|
|
2249
2264
|
if (parent === "*") return ["* &"];
|
|
2250
2265
|
const compound = isCompound(parent);
|
|
2251
2266
|
const on = compound && /^[.[:#]/.test(parent) ? parent : `:is(${parent})`;
|
|
2267
|
+
if (anyTheme === void 0) return [`${parent} &`, `&${on}`];
|
|
2252
2268
|
const inside = compound ? parent : `:is(${parent})`;
|
|
2253
2269
|
return [
|
|
2254
2270
|
`${parent} &`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.6",
|
|
4
4
|
"description": "The css generator for css bamboo",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"pluralize": "8.0.0",
|
|
39
39
|
"postcss": "8.5.26",
|
|
40
40
|
"ts-pattern": "5.9.0",
|
|
41
|
-
"@bamboocss/
|
|
42
|
-
"@bamboocss/
|
|
43
|
-
"@bamboocss/
|
|
44
|
-
"@bamboocss/
|
|
45
|
-
"@bamboocss/token-dictionary": "1.57.
|
|
46
|
-
"@bamboocss/types": "1.57.
|
|
41
|
+
"@bamboocss/is-valid-prop": "^1.57.6",
|
|
42
|
+
"@bamboocss/logger": "1.57.6",
|
|
43
|
+
"@bamboocss/shared": "1.57.6",
|
|
44
|
+
"@bamboocss/core": "1.57.6",
|
|
45
|
+
"@bamboocss/token-dictionary": "1.57.6",
|
|
46
|
+
"@bamboocss/types": "1.57.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|