@react-hive/honey-style 3.0.0 → 3.1.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/dist/css/css.d.ts +8 -2
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +22 -16
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.cjs
CHANGED
|
@@ -871,25 +871,31 @@ const css = (strings, ...interpolations) => {
|
|
|
871
871
|
};
|
|
872
872
|
const createCssRule = (selector, css) => `${selector}{${css}}`;
|
|
873
873
|
const getChildrenCss = (element, callback) => (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.isArray)(element.children) ? (0,stylis__WEBPACK_IMPORTED_MODULE_1__.serialize)(element.children, callback) : element.children;
|
|
874
|
+
/**
|
|
875
|
+
* Splits Stylis children into:
|
|
876
|
+
*
|
|
877
|
+
* - pseudoRules: rules that start with a pseudo selector (e.g. ":hover", ":not(...)")
|
|
878
|
+
* - otherRules: everything else
|
|
879
|
+
*/
|
|
874
880
|
const splitStylisChildren = (children) => {
|
|
875
881
|
if (!(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.isArray)(children) || children.length === 0) {
|
|
876
882
|
return {
|
|
877
|
-
|
|
878
|
-
|
|
883
|
+
pseudoRules: [],
|
|
884
|
+
otherRules: [],
|
|
879
885
|
};
|
|
880
886
|
}
|
|
881
|
-
return children.reduce((
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
887
|
+
return children.reduce((groups, child) => {
|
|
888
|
+
const isPseudoRule = child.value.startsWith('&');
|
|
889
|
+
if (isPseudoRule) {
|
|
890
|
+
groups.pseudoRules.push(child);
|
|
885
891
|
}
|
|
886
892
|
else {
|
|
887
|
-
|
|
893
|
+
groups.otherRules.push(child);
|
|
888
894
|
}
|
|
889
|
-
return
|
|
895
|
+
return groups;
|
|
890
896
|
}, {
|
|
891
|
-
|
|
892
|
-
|
|
897
|
+
pseudoRules: [],
|
|
898
|
+
otherRules: [],
|
|
893
899
|
});
|
|
894
900
|
};
|
|
895
901
|
|
|
@@ -1259,7 +1265,7 @@ const createMediaAtRuleMiddleware = ({ theme }) => (0,_factory__WEBPACK_IMPORTED
|
|
|
1259
1265
|
return null;
|
|
1260
1266
|
}
|
|
1261
1267
|
const childrenGroups = (0,_css__WEBPACK_IMPORTED_MODULE_4__.splitStylisChildren)(element.children);
|
|
1262
|
-
if (!childrenGroups.
|
|
1268
|
+
if (!childrenGroups.pseudoRules.length && !childrenGroups.otherRules.length) {
|
|
1263
1269
|
return null;
|
|
1264
1270
|
}
|
|
1265
1271
|
const mediaQueryRules = [];
|
|
@@ -1313,13 +1319,13 @@ const createMediaAtRuleMiddleware = ({ theme }) => (0,_factory__WEBPACK_IMPORTED
|
|
|
1313
1319
|
orientation,
|
|
1314
1320
|
mediaType,
|
|
1315
1321
|
}));
|
|
1316
|
-
const
|
|
1317
|
-
? `${parent.value}${(0,stylis__WEBPACK_IMPORTED_MODULE_0__.serialize)(childrenGroups.
|
|
1322
|
+
const pseudoSelectorCss = childrenGroups.pseudoRules.length > 0
|
|
1323
|
+
? `${parent.value}${(0,stylis__WEBPACK_IMPORTED_MODULE_0__.serialize)(childrenGroups.pseudoRules, callback)}`
|
|
1318
1324
|
: '';
|
|
1319
|
-
const
|
|
1320
|
-
? (0,_css__WEBPACK_IMPORTED_MODULE_4__.createCssRule)(parent.value, (0,stylis__WEBPACK_IMPORTED_MODULE_0__.serialize)(childrenGroups.
|
|
1325
|
+
const nestedSelectorCss = childrenGroups.otherRules.length > 0
|
|
1326
|
+
? (0,_css__WEBPACK_IMPORTED_MODULE_4__.createCssRule)(parent.value, (0,stylis__WEBPACK_IMPORTED_MODULE_0__.serialize)(childrenGroups.otherRules, callback))
|
|
1321
1327
|
: '';
|
|
1322
|
-
return (0,_css__WEBPACK_IMPORTED_MODULE_4__.createCssRule)((0,_at_rules__WEBPACK_IMPORTED_MODULE_3__.mediaQuery)(finalMediaQueryRules), `${
|
|
1328
|
+
return (0,_css__WEBPACK_IMPORTED_MODULE_4__.createCssRule)((0,_at_rules__WEBPACK_IMPORTED_MODULE_3__.mediaQuery)(finalMediaQueryRules), `${pseudoSelectorCss}${nestedSelectorCss}`);
|
|
1323
1329
|
},
|
|
1324
1330
|
});
|
|
1325
1331
|
|