@react-hive/honey-style 2.1.0 → 2.3.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/middlewares.d.ts +7 -0
- package/dist/css/types.d.ts +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +41 -11
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.cjs
CHANGED
|
@@ -1879,6 +1879,9 @@ const CSS_SPACING_PROPERTIES = [
|
|
|
1879
1879
|
'paddingRight',
|
|
1880
1880
|
'paddingBottom',
|
|
1881
1881
|
'paddingLeft',
|
|
1882
|
+
'paddingBlock',
|
|
1883
|
+
'paddingBlockStart',
|
|
1884
|
+
'paddingBlockEnd',
|
|
1882
1885
|
'top',
|
|
1883
1886
|
'right',
|
|
1884
1887
|
'bottom',
|
|
@@ -1957,6 +1960,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1957
1960
|
/* harmony export */ CSS_COLOR_PROPERTIES: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_1__.CSS_COLOR_PROPERTIES),
|
|
1958
1961
|
/* harmony export */ CSS_SPACING_PROPERTIES: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_1__.CSS_SPACING_PROPERTIES),
|
|
1959
1962
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createSpacingMiddleware),
|
|
1963
|
+
/* harmony export */ createStackMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createStackMiddleware),
|
|
1960
1964
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_4__.css),
|
|
1961
1965
|
/* harmony export */ mediaQuery: () => (/* reexport safe */ _at_rules__WEBPACK_IMPORTED_MODULE_5__.mediaQuery),
|
|
1962
1966
|
/* harmony export */ processCss: () => (/* reexport safe */ _processor__WEBPACK_IMPORTED_MODULE_3__.processCss)
|
|
@@ -1985,7 +1989,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1985
1989
|
|
|
1986
1990
|
__webpack_require__.r(__webpack_exports__);
|
|
1987
1991
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1988
|
-
/* harmony export */ createSpacingMiddleware: () => (/* binding */ createSpacingMiddleware)
|
|
1992
|
+
/* harmony export */ createSpacingMiddleware: () => (/* binding */ createSpacingMiddleware),
|
|
1993
|
+
/* harmony export */ createStackMiddleware: () => (/* binding */ createStackMiddleware)
|
|
1989
1994
|
/* harmony export */ });
|
|
1990
1995
|
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/css/constants.ts");
|
|
1991
1996
|
|
|
@@ -1998,18 +2003,38 @@ const createSpacingMiddleware = ({ spacingMultiplier }) => element => {
|
|
|
1998
2003
|
if (typeof element.props === 'string' &&
|
|
1999
2004
|
KEBAB_CASE_SPACING_PROPERTIES.includes(element.props) &&
|
|
2000
2005
|
typeof element.children === 'string') {
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2006
|
+
// If the whole value contains parentheses, skip entirely (likely calc or var)
|
|
2007
|
+
if (/[()]/.test(element.children)) {
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
const transformedParts = [];
|
|
2011
|
+
const parts = element.children.trim().split(/\s+/);
|
|
2012
|
+
for (const value of parts) {
|
|
2013
|
+
transformedParts.push(
|
|
2014
|
+
// Accept only numeric strings (integers or floats), no units or symbols
|
|
2015
|
+
/^-?\d*\.?\d+$/.test(value) ? `${parseFloat(value) * spacingMultiplier}px` : value);
|
|
2016
|
+
}
|
|
2017
|
+
const transformed = transformedParts.join(' ');
|
|
2010
2018
|
element.return = `${element.props}:${transformed};`;
|
|
2011
2019
|
}
|
|
2012
2020
|
};
|
|
2021
|
+
const createStackMiddleware = ({ spacingMultiplier = 0 }) => element => {
|
|
2022
|
+
if (element.parent?.type !== 'rule' || element.type !== '@honey-stack') {
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
const match = element.value.match(`^${element.type}\\s*\\(\\s*([^)]+?)\\s*\\)`);
|
|
2026
|
+
if (!match) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
const rawGap = match[1].trim();
|
|
2030
|
+
// Matches values like: 1.5, -2, 10px, 0.25rem, 5%, etc.
|
|
2031
|
+
const hasUnit = /[a-z%]+$/i.test(rawGap);
|
|
2032
|
+
const gapValue = hasUnit ? rawGap : `${parseFloat(rawGap) * spacingMultiplier}px`;
|
|
2033
|
+
const parentSelector = element.parent?.value;
|
|
2034
|
+
// Transform @honey-stack(...) into three normal declarations
|
|
2035
|
+
element.type = 'decl';
|
|
2036
|
+
element.return = `${parentSelector}{display:flex;flex-direction:column;gap:${gapValue};}`;
|
|
2037
|
+
};
|
|
2013
2038
|
|
|
2014
2039
|
|
|
2015
2040
|
/***/ }),
|
|
@@ -2032,7 +2057,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2032
2057
|
|
|
2033
2058
|
const processCss = (rawCss, selector, { spacingMultiplier = 0 } = {}) => {
|
|
2034
2059
|
const scopedCss = selector ? `${selector}{${rawCss}}` : rawCss;
|
|
2035
|
-
const middlewares = [
|
|
2060
|
+
const middlewares = [
|
|
2061
|
+
(0,_middlewares__WEBPACK_IMPORTED_MODULE_0__.createSpacingMiddleware)({ spacingMultiplier }),
|
|
2062
|
+
(0,_middlewares__WEBPACK_IMPORTED_MODULE_0__.createStackMiddleware)({ spacingMultiplier }),
|
|
2063
|
+
stylis__WEBPACK_IMPORTED_MODULE_1__.stringify,
|
|
2064
|
+
];
|
|
2036
2065
|
return (0,stylis__WEBPACK_IMPORTED_MODULE_1__.serialize)((0,stylis__WEBPACK_IMPORTED_MODULE_2__.compile)(scopedCss), (0,stylis__WEBPACK_IMPORTED_MODULE_3__.middleware)(middlewares));
|
|
2037
2066
|
};
|
|
2038
2067
|
|
|
@@ -2798,6 +2827,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2798
2827
|
/* harmony export */ convertHexToHexWithAlpha: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.convertHexToHexWithAlpha),
|
|
2799
2828
|
/* harmony export */ createGlobalStyle: () => (/* reexport safe */ _global_style__WEBPACK_IMPORTED_MODULE_6__.createGlobalStyle),
|
|
2800
2829
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createSpacingMiddleware),
|
|
2830
|
+
/* harmony export */ createStackMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createStackMiddleware),
|
|
2801
2831
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.css),
|
|
2802
2832
|
/* harmony export */ filterNonHtmlAttrs: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.filterNonHtmlAttrs),
|
|
2803
2833
|
/* harmony export */ generateId: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.generateId),
|