@pikacss/core 0.0.29 → 0.0.30
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 +15 -7
- package/dist/index.mjs +15 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -78,12 +78,12 @@ function renderCSSStyleBlocks(blocks, isFormatted, depth = 0) {
|
|
|
78
78
|
const lineEnd = isFormatted ? "\n" : "";
|
|
79
79
|
const lines = [];
|
|
80
80
|
blocks.forEach(({ properties, children }, selector) => {
|
|
81
|
-
if (properties.length === 0 && children == null)
|
|
81
|
+
if (properties.length === 0 && (children == null || children.size === 0))
|
|
82
82
|
return;
|
|
83
83
|
lines.push(...[
|
|
84
84
|
`${blockIndent}${selector}${selectorEnd}{`,
|
|
85
85
|
...properties.map(({ property, value }) => `${blockBodyIndent}${property}:${propertySpace}${value};`),
|
|
86
|
-
...children != null ? [renderCSSStyleBlocks(children, isFormatted, depth + 1)] : [],
|
|
86
|
+
...children != null && children.size > 0 ? [renderCSSStyleBlocks(children, isFormatted, depth + 1)] : [],
|
|
87
87
|
`${blockIndent}}`
|
|
88
88
|
]);
|
|
89
89
|
});
|
|
@@ -240,6 +240,14 @@ function defineEnginePlugin(plugin) {
|
|
|
240
240
|
return plugin;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
function modifyPropertyValue(value) {
|
|
244
|
+
if (value == null)
|
|
245
|
+
return null;
|
|
246
|
+
if (Array.isArray(value)) {
|
|
247
|
+
return [`${value[0]} !important`, value[1].map((i) => `${i} !important`)];
|
|
248
|
+
}
|
|
249
|
+
return `${value} !important`;
|
|
250
|
+
}
|
|
243
251
|
function important() {
|
|
244
252
|
let defaultValue;
|
|
245
253
|
return defineEnginePlugin({
|
|
@@ -260,10 +268,10 @@ function important() {
|
|
|
260
268
|
return rest;
|
|
261
269
|
return Object.fromEntries(
|
|
262
270
|
Object.entries(rest).map(([k, v]) => {
|
|
263
|
-
if (isPropertyValue(v)
|
|
264
|
-
return [k, v];
|
|
265
|
-
|
|
266
|
-
return [k,
|
|
271
|
+
if (isPropertyValue(v)) {
|
|
272
|
+
return [k, modifyPropertyValue(v)];
|
|
273
|
+
}
|
|
274
|
+
return [k, v];
|
|
267
275
|
})
|
|
268
276
|
);
|
|
269
277
|
});
|
|
@@ -1059,7 +1067,7 @@ async function _renderPreflightDefinition({
|
|
|
1059
1067
|
} else {
|
|
1060
1068
|
currentBlockBody.children ||= /* @__PURE__ */ new Map();
|
|
1061
1069
|
currentBlockBody.children.set(k, currentBlockBody.children.get(k) || { properties: [] });
|
|
1062
|
-
_renderPreflightDefinition({
|
|
1070
|
+
await _renderPreflightDefinition({
|
|
1063
1071
|
engine,
|
|
1064
1072
|
preflightDefinition: { [k]: v },
|
|
1065
1073
|
blocks: currentBlockBody.children
|
package/dist/index.mjs
CHANGED
|
@@ -76,12 +76,12 @@ function renderCSSStyleBlocks(blocks, isFormatted, depth = 0) {
|
|
|
76
76
|
const lineEnd = isFormatted ? "\n" : "";
|
|
77
77
|
const lines = [];
|
|
78
78
|
blocks.forEach(({ properties, children }, selector) => {
|
|
79
|
-
if (properties.length === 0 && children == null)
|
|
79
|
+
if (properties.length === 0 && (children == null || children.size === 0))
|
|
80
80
|
return;
|
|
81
81
|
lines.push(...[
|
|
82
82
|
`${blockIndent}${selector}${selectorEnd}{`,
|
|
83
83
|
...properties.map(({ property, value }) => `${blockBodyIndent}${property}:${propertySpace}${value};`),
|
|
84
|
-
...children != null ? [renderCSSStyleBlocks(children, isFormatted, depth + 1)] : [],
|
|
84
|
+
...children != null && children.size > 0 ? [renderCSSStyleBlocks(children, isFormatted, depth + 1)] : [],
|
|
85
85
|
`${blockIndent}}`
|
|
86
86
|
]);
|
|
87
87
|
});
|
|
@@ -238,6 +238,14 @@ function defineEnginePlugin(plugin) {
|
|
|
238
238
|
return plugin;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
function modifyPropertyValue(value) {
|
|
242
|
+
if (value == null)
|
|
243
|
+
return null;
|
|
244
|
+
if (Array.isArray(value)) {
|
|
245
|
+
return [`${value[0]} !important`, value[1].map((i) => `${i} !important`)];
|
|
246
|
+
}
|
|
247
|
+
return `${value} !important`;
|
|
248
|
+
}
|
|
241
249
|
function important() {
|
|
242
250
|
let defaultValue;
|
|
243
251
|
return defineEnginePlugin({
|
|
@@ -258,10 +266,10 @@ function important() {
|
|
|
258
266
|
return rest;
|
|
259
267
|
return Object.fromEntries(
|
|
260
268
|
Object.entries(rest).map(([k, v]) => {
|
|
261
|
-
if (isPropertyValue(v)
|
|
262
|
-
return [k, v];
|
|
263
|
-
|
|
264
|
-
return [k,
|
|
269
|
+
if (isPropertyValue(v)) {
|
|
270
|
+
return [k, modifyPropertyValue(v)];
|
|
271
|
+
}
|
|
272
|
+
return [k, v];
|
|
265
273
|
})
|
|
266
274
|
);
|
|
267
275
|
});
|
|
@@ -1057,7 +1065,7 @@ async function _renderPreflightDefinition({
|
|
|
1057
1065
|
} else {
|
|
1058
1066
|
currentBlockBody.children ||= /* @__PURE__ */ new Map();
|
|
1059
1067
|
currentBlockBody.children.set(k, currentBlockBody.children.get(k) || { properties: [] });
|
|
1060
|
-
_renderPreflightDefinition({
|
|
1068
|
+
await _renderPreflightDefinition({
|
|
1061
1069
|
engine,
|
|
1062
1070
|
preflightDefinition: { [k]: v },
|
|
1063
1071
|
blocks: currentBlockBody.children
|