@react-hive/honey-style 1.4.3 → 1.5.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +149 -48
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/css.types.d.ts +57 -1
- package/dist/utils.d.ts +31 -2
- package/package.json +14 -9
package/dist/index.dev.cjs
CHANGED
|
@@ -378,7 +378,8 @@
|
|
|
378
378
|
|
|
379
379
|
|
|
380
380
|
|
|
381
|
-
if (false)
|
|
381
|
+
if (false) // removed by dead control flow
|
|
382
|
+
{} else {
|
|
382
383
|
module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ "./node_modules/react/cjs/react-jsx-runtime.development.js");
|
|
383
384
|
}
|
|
384
385
|
|
|
@@ -1191,80 +1192,95 @@ const HONEY_GLOBAL_STYLE_ATTR = 'data-honey-global-style';
|
|
|
1191
1192
|
const HONEY_STYLE_ATTR = 'data-honey-style';
|
|
1192
1193
|
const HONEY_BREAKPOINTS = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
1193
1194
|
const VALID_HTML_ATTRS = new Set([
|
|
1195
|
+
// Standard Attributes
|
|
1194
1196
|
'accept',
|
|
1195
1197
|
'accessKey',
|
|
1196
|
-
'alt',
|
|
1197
|
-
'aria',
|
|
1198
|
-
'as',
|
|
1199
1198
|
'autoCapitalize',
|
|
1200
1199
|
'autoComplete',
|
|
1201
1200
|
'autoFocus',
|
|
1202
1201
|
'capture',
|
|
1203
|
-
'
|
|
1202
|
+
'class',
|
|
1204
1203
|
'className',
|
|
1205
1204
|
'contentEditable',
|
|
1206
1205
|
'contextMenu',
|
|
1207
|
-
'controls',
|
|
1208
|
-
'crossOrigin',
|
|
1209
|
-
'dangerouslySetInnerHTML',
|
|
1210
|
-
'data',
|
|
1211
1206
|
'dir',
|
|
1212
|
-
'disabled',
|
|
1213
|
-
'download',
|
|
1214
1207
|
'draggable',
|
|
1208
|
+
'hidden',
|
|
1209
|
+
'id',
|
|
1210
|
+
'inert',
|
|
1211
|
+
'inputMode',
|
|
1212
|
+
'is',
|
|
1213
|
+
'lang',
|
|
1214
|
+
'nonce',
|
|
1215
|
+
'part',
|
|
1216
|
+
'slot',
|
|
1217
|
+
'spellCheck',
|
|
1218
|
+
'style',
|
|
1219
|
+
'tabIndex',
|
|
1220
|
+
'title',
|
|
1221
|
+
'translate',
|
|
1222
|
+
'unselectable',
|
|
1223
|
+
// Form Attributes
|
|
1224
|
+
'checked',
|
|
1225
|
+
'disabled',
|
|
1215
1226
|
'form',
|
|
1216
1227
|
'formAction',
|
|
1217
1228
|
'formEncType',
|
|
1218
1229
|
'formMethod',
|
|
1219
1230
|
'formNoValidate',
|
|
1220
1231
|
'formTarget',
|
|
1221
|
-
'height',
|
|
1222
|
-
'hidden',
|
|
1223
|
-
'href',
|
|
1224
|
-
'hrefLang',
|
|
1225
|
-
'id',
|
|
1226
|
-
'is',
|
|
1227
|
-
'isMap',
|
|
1228
|
-
'inert',
|
|
1229
|
-
'key',
|
|
1230
|
-
'lang',
|
|
1231
1232
|
'list',
|
|
1232
|
-
'loop',
|
|
1233
1233
|
'max',
|
|
1234
1234
|
'maxLength',
|
|
1235
|
-
'media',
|
|
1236
1235
|
'min',
|
|
1237
1236
|
'minLength',
|
|
1238
1237
|
'multiple',
|
|
1239
|
-
'muted',
|
|
1240
1238
|
'name',
|
|
1241
1239
|
'pattern',
|
|
1242
1240
|
'placeholder',
|
|
1243
1241
|
'readOnly',
|
|
1244
1242
|
'required',
|
|
1245
|
-
'role',
|
|
1246
1243
|
'size',
|
|
1247
|
-
'slot',
|
|
1248
|
-
'spellCheck',
|
|
1249
|
-
'src',
|
|
1250
|
-
'srcSet',
|
|
1251
1244
|
'step',
|
|
1252
|
-
'style',
|
|
1253
|
-
'tabIndex',
|
|
1254
|
-
'target',
|
|
1255
|
-
'title',
|
|
1256
|
-
'translate',
|
|
1257
1245
|
'type',
|
|
1258
|
-
'useMap',
|
|
1259
1246
|
'value',
|
|
1247
|
+
// Media Attributes
|
|
1248
|
+
'alt',
|
|
1249
|
+
'controls',
|
|
1250
|
+
'crossOrigin',
|
|
1251
|
+
'height',
|
|
1252
|
+
'isMap',
|
|
1253
|
+
'loop',
|
|
1254
|
+
'media',
|
|
1255
|
+
'muted',
|
|
1256
|
+
'poster',
|
|
1257
|
+
'preload',
|
|
1258
|
+
'src',
|
|
1259
|
+
'srcSet',
|
|
1260
|
+
'useMap',
|
|
1260
1261
|
'width',
|
|
1262
|
+
// Anchor & Link Attributes
|
|
1263
|
+
'download',
|
|
1264
|
+
'href',
|
|
1265
|
+
'hrefLang',
|
|
1266
|
+
'referrerPolicy',
|
|
1267
|
+
'rel',
|
|
1268
|
+
'target',
|
|
1269
|
+
// React Specific
|
|
1270
|
+
'dangerouslySetInnerHTML',
|
|
1271
|
+
'key',
|
|
1261
1272
|
'ref',
|
|
1262
1273
|
'children',
|
|
1263
|
-
|
|
1274
|
+
// Deprecated/Obscure Attributes (still valid in some contexts)
|
|
1264
1275
|
'char',
|
|
1265
1276
|
'charOff',
|
|
1266
|
-
|
|
1267
|
-
'
|
|
1277
|
+
// Web Components / Shadow DOM
|
|
1278
|
+
'exportparts',
|
|
1279
|
+
'popover',
|
|
1280
|
+
'popoverTarget',
|
|
1281
|
+
'popoverTargetAction',
|
|
1282
|
+
'virtualkeyboardpolicy',
|
|
1283
|
+
'writingsuggestions',
|
|
1268
1284
|
]);
|
|
1269
1285
|
const VALID_TABLE_ATTRS = new Set([
|
|
1270
1286
|
'colSpan',
|
|
@@ -1473,10 +1489,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1473
1489
|
|
|
1474
1490
|
|
|
1475
1491
|
const resolveCssInterpolation = (value, context) => {
|
|
1476
|
-
if (value === '' || value === false || value
|
|
1492
|
+
if (value === '' || value === false || (0,_utils__WEBPACK_IMPORTED_MODULE_1__.isNil)(value)) {
|
|
1477
1493
|
return '';
|
|
1478
1494
|
}
|
|
1479
|
-
if (
|
|
1495
|
+
if ((0,_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(value)) {
|
|
1480
1496
|
if ((0,_utils__WEBPACK_IMPORTED_MODULE_1__.isStyledComponent)(value)) {
|
|
1481
1497
|
return `.${value[_constants__WEBPACK_IMPORTED_MODULE_0__.HONEY_STYLED_COMPONENT_ID_PROP]}`;
|
|
1482
1498
|
}
|
|
@@ -1485,7 +1501,7 @@ const resolveCssInterpolation = (value, context) => {
|
|
|
1485
1501
|
if (Array.isArray(value)) {
|
|
1486
1502
|
return value.map(v => resolveCssInterpolation(v, context)).join('\n');
|
|
1487
1503
|
}
|
|
1488
|
-
if (value
|
|
1504
|
+
if ((0,_utils__WEBPACK_IMPORTED_MODULE_1__.isObject)(value)) {
|
|
1489
1505
|
return Object.entries(value)
|
|
1490
1506
|
.filter(([, v]) => v !== undefined && v !== false)
|
|
1491
1507
|
.map(([k, v]) => `${(0,_utils__WEBPACK_IMPORTED_MODULE_1__.toKebabCase)(k)}: ${v};`)
|
|
@@ -1751,7 +1767,7 @@ const evaluateDynamicCss = (interpolation, context) => {
|
|
|
1751
1767
|
if (!interpolation) {
|
|
1752
1768
|
return '';
|
|
1753
1769
|
}
|
|
1754
|
-
if (
|
|
1770
|
+
if ((0,_utils__WEBPACK_IMPORTED_MODULE_2__.isString)(interpolation)) {
|
|
1755
1771
|
return interpolation;
|
|
1756
1772
|
}
|
|
1757
1773
|
// @ts-expect-error
|
|
@@ -1767,7 +1783,7 @@ const styled = (target, defaultProps) => {
|
|
|
1767
1783
|
}
|
|
1768
1784
|
const { theme } = (0,_hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneyStyle)();
|
|
1769
1785
|
const cleanedProps = Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
|
|
1770
|
-
const resolvedDefaultProps =
|
|
1786
|
+
const resolvedDefaultProps = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isFunction)(defaultProps)
|
|
1771
1787
|
? defaultProps({ theme, as, className, ...cleanedProps })
|
|
1772
1788
|
: (defaultProps ?? {});
|
|
1773
1789
|
const context = {
|
|
@@ -1781,7 +1797,7 @@ const styled = (target, defaultProps) => {
|
|
|
1781
1797
|
const baseCss = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.processCss)(rawCss, `.${baseClassName}`);
|
|
1782
1798
|
return (0,_mount_style__WEBPACK_IMPORTED_MODULE_4__.mountStyle)(baseClassName, baseCss, __compositionDepth);
|
|
1783
1799
|
}, [baseClassName]);
|
|
1784
|
-
const cssPropRaw =
|
|
1800
|
+
const cssPropRaw = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isFunction)(cssProp) ? cssProp(context) : cssProp;
|
|
1785
1801
|
const cssPropString = evaluateDynamicCss(cssPropRaw, context);
|
|
1786
1802
|
const cssPropClassName = cssPropString ? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.resolveClassName)(cssPropString) : '';
|
|
1787
1803
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useInsertionEffect)(() => {
|
|
@@ -1796,8 +1812,10 @@ const styled = (target, defaultProps) => {
|
|
|
1796
1812
|
className: (0,_utils__WEBPACK_IMPORTED_MODULE_2__.combineClassNames)([componentId, baseClassName, className, cssPropClassName]),
|
|
1797
1813
|
};
|
|
1798
1814
|
const finalComponent = as || target;
|
|
1799
|
-
if (
|
|
1800
|
-
const filteredProps =
|
|
1815
|
+
if ((0,_utils__WEBPACK_IMPORTED_MODULE_2__.isString)(target)) {
|
|
1816
|
+
const filteredProps = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isString)(finalComponent)
|
|
1817
|
+
? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.filterNonHtmlAttrs)(mergedProps)
|
|
1818
|
+
: mergedProps;
|
|
1801
1819
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(finalComponent, filteredProps);
|
|
1802
1820
|
}
|
|
1803
1821
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(target, {
|
|
@@ -1810,7 +1828,9 @@ const styled = (target, defaultProps) => {
|
|
|
1810
1828
|
};
|
|
1811
1829
|
StyledComponent[_constants__WEBPACK_IMPORTED_MODULE_1__.HONEY_STYLED_COMPONENT_ID_PROP] = componentId;
|
|
1812
1830
|
if (_constants__WEBPACK_IMPORTED_MODULE_1__.__DEV__) {
|
|
1813
|
-
const componentName =
|
|
1831
|
+
const componentName = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isString)(target)
|
|
1832
|
+
? target
|
|
1833
|
+
: target.displayName || target.name || 'Component';
|
|
1814
1834
|
StyledComponent.displayName = `HoneyStyledComponent(${componentName})`;
|
|
1815
1835
|
}
|
|
1816
1836
|
return StyledComponent;
|
|
@@ -1872,8 +1892,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1872
1892
|
/* harmony export */ combineClassNames: () => (/* binding */ combineClassNames),
|
|
1873
1893
|
/* harmony export */ filterNonHtmlAttrs: () => (/* binding */ filterNonHtmlAttrs),
|
|
1874
1894
|
/* harmony export */ generateId: () => (/* binding */ generateId),
|
|
1875
|
-
/* harmony export */
|
|
1895
|
+
/* harmony export */ isFunction: () => (/* binding */ isFunction),
|
|
1896
|
+
/* harmony export */ isNil: () => (/* binding */ isNil),
|
|
1897
|
+
/* harmony export */ isObject: () => (/* binding */ isObject),
|
|
1898
|
+
/* harmony export */ isString: () => (/* binding */ isString),
|
|
1876
1899
|
/* harmony export */ isStyledComponent: () => (/* binding */ isStyledComponent),
|
|
1900
|
+
/* harmony export */ mediaQuery: () => (/* binding */ mediaQuery),
|
|
1877
1901
|
/* harmony export */ processCss: () => (/* binding */ processCss),
|
|
1878
1902
|
/* harmony export */ resolveClassName: () => (/* binding */ resolveClassName),
|
|
1879
1903
|
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
@@ -1890,6 +1914,41 @@ function assert(condition, message) {
|
|
|
1890
1914
|
}
|
|
1891
1915
|
const generateId = (prefix) => `${prefix}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1892
1916
|
const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
1917
|
+
const isString = (value) => typeof value === 'string';
|
|
1918
|
+
const isObject = (value) => typeof value === 'object';
|
|
1919
|
+
const isFunction = (value) => typeof value === 'function';
|
|
1920
|
+
/**
|
|
1921
|
+
* Checks if a value is null or undefined.
|
|
1922
|
+
*
|
|
1923
|
+
* @param value - The value to check.
|
|
1924
|
+
*
|
|
1925
|
+
* @returns `true` if the value is `null` or `undefined`, otherwise `false`.
|
|
1926
|
+
*/
|
|
1927
|
+
const isNil = (value) => value === undefined || value === null;
|
|
1928
|
+
/**
|
|
1929
|
+
* Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
|
|
1930
|
+
*
|
|
1931
|
+
* This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
|
|
1932
|
+
* based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
|
|
1933
|
+
* which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
|
|
1934
|
+
*
|
|
1935
|
+
* Useful for:
|
|
1936
|
+
* - Generating stable class names in CSS-in-JS libraries.
|
|
1937
|
+
* - Producing consistent cache keys.
|
|
1938
|
+
* - Quick and lightweight hashing needs where cryptographic security is not required.
|
|
1939
|
+
*
|
|
1940
|
+
* ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
|
|
1941
|
+
*
|
|
1942
|
+
* @param str - The input string to hash.
|
|
1943
|
+
*
|
|
1944
|
+
* @returns A short, base-36 encoded hash string.
|
|
1945
|
+
*
|
|
1946
|
+
* @example
|
|
1947
|
+
* ```ts
|
|
1948
|
+
* const className = hashString('background-color: red;');
|
|
1949
|
+
* // → 'e4k1z0x'
|
|
1950
|
+
* ```
|
|
1951
|
+
*/
|
|
1893
1952
|
const hashString = (str) => {
|
|
1894
1953
|
let hash = 5381;
|
|
1895
1954
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -1932,6 +1991,48 @@ const filterNonHtmlAttrs = (attrs) => Object.entries(attrs).reduce((allowedAttrs
|
|
|
1932
1991
|
}
|
|
1933
1992
|
return allowedAttrs;
|
|
1934
1993
|
}, {});
|
|
1994
|
+
/**
|
|
1995
|
+
* Constructs a complete `@media` query string from an array of media rule objects.
|
|
1996
|
+
* Each rule defines conditions such as screen size, orientation, or resolution,
|
|
1997
|
+
* which are converted into standard CSS media query syntax.
|
|
1998
|
+
*
|
|
1999
|
+
* @param rules - An array of media rule objects used to generate individual media queries.
|
|
2000
|
+
*
|
|
2001
|
+
* @returns A string containing a full `@media` query that can be used in CSS or injected into a stylesheet.
|
|
2002
|
+
*
|
|
2003
|
+
* @example
|
|
2004
|
+
* ```ts
|
|
2005
|
+
* atMedia([
|
|
2006
|
+
* { minWidth: '768px', orientation: 'landscape' },
|
|
2007
|
+
* { mediaType: 'print' }
|
|
2008
|
+
* ]);
|
|
2009
|
+
* // Returns: "@media screen and (min-width: 768px) and (orientation: landscape), print"
|
|
2010
|
+
* ```
|
|
2011
|
+
*/
|
|
2012
|
+
const mediaQuery = (rules) => {
|
|
2013
|
+
const mediaRules = rules.map(rule => {
|
|
2014
|
+
const conditions = [
|
|
2015
|
+
rule.width && ['width', rule.width],
|
|
2016
|
+
rule.minWidth && ['min-width', rule.minWidth],
|
|
2017
|
+
rule.maxWidth && ['max-width', rule.maxWidth],
|
|
2018
|
+
rule.height && ['height', rule.height],
|
|
2019
|
+
rule.minHeight && ['min-height', rule.minHeight],
|
|
2020
|
+
rule.maxHeight && ['max-height', rule.maxHeight],
|
|
2021
|
+
rule.orientation && ['orientation', rule.orientation],
|
|
2022
|
+
rule.minResolution && ['min-resolution', rule.minResolution],
|
|
2023
|
+
rule.maxResolution && ['max-resolution', rule.maxResolution],
|
|
2024
|
+
rule.resolution && ['resolution', rule.resolution],
|
|
2025
|
+
rule.update && ['update', rule.update],
|
|
2026
|
+
]
|
|
2027
|
+
.filter(Boolean)
|
|
2028
|
+
.map(r => r && `(${r[0]}: ${r[1]})`)
|
|
2029
|
+
.join(' and ');
|
|
2030
|
+
const operatorPart = rule.operator ? `${rule.operator} ` : '';
|
|
2031
|
+
const conditionsPart = conditions ? ` and ${conditions}` : '';
|
|
2032
|
+
return `${operatorPart}${rule.mediaType ?? 'screen'}${conditionsPart}`;
|
|
2033
|
+
});
|
|
2034
|
+
return `@media ${mediaRules.join(', ')}`;
|
|
2035
|
+
};
|
|
1935
2036
|
|
|
1936
2037
|
|
|
1937
2038
|
/***/ }),
|