@react-hive/honey-style 1.10.0 → 1.11.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/contexts/HoneyStyleContext.d.ts +40 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +63 -1
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/providers/HoneyStyleProvider.d.ts +1 -2
- package/dist/types/css.types.d.ts +57 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +2 -2
- package/dist/types/utility.types.d.ts +1 -0
- package/dist/utils.d.ts +41 -1
- package/package.json +1 -1
package/dist/index.dev.cjs
CHANGED
|
@@ -1796,12 +1796,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1796
1796
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
|
|
1797
1797
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
1798
1798
|
/* harmony import */ var _contexts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../contexts */ "./src/contexts/index.ts");
|
|
1799
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils */ "./src/utils.ts");
|
|
1800
|
+
|
|
1799
1801
|
|
|
1800
1802
|
|
|
1801
1803
|
|
|
1802
1804
|
const HoneyStyleProvider = ({ children, theme, }) => {
|
|
1803
1805
|
const contextValue = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(() => ({
|
|
1804
1806
|
theme,
|
|
1807
|
+
resolveSpacing: (...args) => (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveSpacing)(...args)({ theme }),
|
|
1808
|
+
resolveColor: (...args) => (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveColor)(...args)({ theme }),
|
|
1809
|
+
resolveFont: (...args) => (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveFont)(...args)({ theme }),
|
|
1810
|
+
resolveDimension: (...args) => (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveDimension)(...args)({ theme }),
|
|
1805
1811
|
}), [theme]);
|
|
1806
1812
|
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_contexts__WEBPACK_IMPORTED_MODULE_2__.HoneyStyleContext, { value: contextValue, children: children });
|
|
1807
1813
|
};
|
|
@@ -1945,7 +1951,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1945
1951
|
|
|
1946
1952
|
__webpack_require__.r(__webpack_exports__);
|
|
1947
1953
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/types/types.ts");
|
|
1948
|
-
/* harmony import */ var
|
|
1954
|
+
/* harmony import */ var _utility_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utility.types */ "./src/types/utility.types.ts");
|
|
1955
|
+
/* harmony import */ var _css_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css.types */ "./src/types/css.types.ts");
|
|
1956
|
+
|
|
1949
1957
|
|
|
1950
1958
|
|
|
1951
1959
|
|
|
@@ -1963,6 +1971,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1963
1971
|
|
|
1964
1972
|
|
|
1965
1973
|
|
|
1974
|
+
/***/ }),
|
|
1975
|
+
|
|
1976
|
+
/***/ "./src/types/utility.types.ts":
|
|
1977
|
+
/*!************************************!*\
|
|
1978
|
+
!*** ./src/types/utility.types.ts ***!
|
|
1979
|
+
\************************************/
|
|
1980
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1981
|
+
|
|
1982
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1966
1986
|
/***/ }),
|
|
1967
1987
|
|
|
1968
1988
|
/***/ "./src/utils.ts":
|
|
@@ -1991,6 +2011,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1991
2011
|
/* harmony export */ resolveColor: () => (/* binding */ resolveColor),
|
|
1992
2012
|
/* harmony export */ resolveDimension: () => (/* binding */ resolveDimension),
|
|
1993
2013
|
/* harmony export */ resolveFont: () => (/* binding */ resolveFont),
|
|
2014
|
+
/* harmony export */ resolveSpacing: () => (/* binding */ resolveSpacing),
|
|
1994
2015
|
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
1995
2016
|
/* harmony export */ });
|
|
1996
2017
|
/* harmony import */ var stylis__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! stylis */ "./node_modules/stylis/src/Serializer.js");
|
|
@@ -2116,6 +2137,46 @@ const pxToRem = (px, base = 16) => `${px / base}rem`;
|
|
|
2116
2137
|
* @returns True if the string value is a theme color value, false otherwise.
|
|
2117
2138
|
*/
|
|
2118
2139
|
const checkIsThemeColorValue = (propertyValue) => propertyValue.split('.').length === 2;
|
|
2140
|
+
/**
|
|
2141
|
+
* Resolves a spacing value or shorthand spacing array using the theme and optional unit.
|
|
2142
|
+
*
|
|
2143
|
+
* This function takes spacing multipliers and converts them into pixel or unit-based values
|
|
2144
|
+
* using a theme spacing scale (e.g., `theme.spacings.base`). Useful for applying consistent
|
|
2145
|
+
* layout spacing with theming and token support.
|
|
2146
|
+
*
|
|
2147
|
+
* @template Value - The spacing value(s) to resolve. Can be:
|
|
2148
|
+
* - A number (e.g., `1`) representing a multiplier.
|
|
2149
|
+
* - An array of numbers (e.g., `[1, 2, 3, 4]`) for shorthand spacing.
|
|
2150
|
+
* - A dimension string (e.g., `'10px'`) will be returned as `never`.
|
|
2151
|
+
* @template Unit - Optional CSS unit (`'px'`, `'em'`, etc.), or `null` to skip units.
|
|
2152
|
+
*
|
|
2153
|
+
* @param value - Spacing multiplier(s) to apply.
|
|
2154
|
+
* @param [unit='px'] - The CSS unit to append. If `null`, values remain numeric.
|
|
2155
|
+
* @param [type='base'] - The spacing type to use from the theme (e.g., `'base'`, `'small'`).
|
|
2156
|
+
*
|
|
2157
|
+
* @returns A function that takes a theme context and returns:
|
|
2158
|
+
* - A single resolved value (e.g., `'16px'`) if `value` is a number.
|
|
2159
|
+
* - A space-separated string (e.g., `'8px 12px'`) if `value` is an array.
|
|
2160
|
+
* - `never` if the input is a raw string (unsupported).
|
|
2161
|
+
*/
|
|
2162
|
+
const resolveSpacing = (value, unit = 'px', type = 'base') => ({ theme }) => {
|
|
2163
|
+
if (typeof value === 'string') {
|
|
2164
|
+
return value;
|
|
2165
|
+
}
|
|
2166
|
+
const selectedSpacing = theme.spacings[type] ?? 0;
|
|
2167
|
+
if (typeof value === 'number') {
|
|
2168
|
+
const normalizedValue = value * selectedSpacing;
|
|
2169
|
+
return (unit ? `${normalizedValue}${unit}` : normalizedValue);
|
|
2170
|
+
}
|
|
2171
|
+
const calculatedValues = value.map(shorthandValue => {
|
|
2172
|
+
if (typeof shorthandValue === 'string') {
|
|
2173
|
+
return shorthandValue;
|
|
2174
|
+
}
|
|
2175
|
+
const calculatedValue = shorthandValue * selectedSpacing;
|
|
2176
|
+
return unit ? `${calculatedValue}${unit}` : calculatedValue;
|
|
2177
|
+
});
|
|
2178
|
+
return calculatedValues.join(' ');
|
|
2179
|
+
};
|
|
2119
2180
|
/**
|
|
2120
2181
|
* Resolves the font styles based on the provided font name from the theme.
|
|
2121
2182
|
*
|
|
@@ -2317,6 +2378,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2317
2378
|
/* harmony export */ resolveColor: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.resolveColor),
|
|
2318
2379
|
/* harmony export */ resolveDimension: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.resolveDimension),
|
|
2319
2380
|
/* harmony export */ resolveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.resolveFont),
|
|
2381
|
+
/* harmony export */ resolveSpacing: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.resolveSpacing),
|
|
2320
2382
|
/* harmony export */ styled: () => (/* reexport safe */ _styled__WEBPACK_IMPORTED_MODULE_7__.styled),
|
|
2321
2383
|
/* harmony export */ toKebabCase: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_9__.toKebabCase),
|
|
2322
2384
|
/* harmony export */ useHoneyStyle: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_3__.useHoneyStyle)
|