@react-hive/honey-style 2.7.0 → 2.8.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/index.d.ts +1 -0
- package/dist/css/middlewares/inline-at-rule.d.ts +2 -2
- package/dist/css/middlewares/spacing.d.ts +2 -2
- package/dist/css/middlewares/stack-at-rule.d.ts +2 -2
- package/dist/css/middlewares/suggest.d.ts +2 -0
- package/dist/css/processor.d.ts +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +202 -146
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.ts +0 -26
- package/package.json +5 -4
package/dist/index.dev.cjs
CHANGED
|
@@ -2,6 +2,71 @@
|
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
|
5
|
+
/***/ "./node_modules/@react-hive/honey-utils/dist/index.mjs":
|
|
6
|
+
/*!*************************************************************!*\
|
|
7
|
+
!*** ./node_modules/@react-hive/honey-utils/dist/index.mjs ***!
|
|
8
|
+
\*************************************************************/
|
|
9
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
10
|
+
|
|
11
|
+
__webpack_require__.r(__webpack_exports__);
|
|
12
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
/* harmony export */ assert: () => (/* binding */ a),
|
|
14
|
+
/* harmony export */ boolFilter: () => (/* binding */ S),
|
|
15
|
+
/* harmony export */ calculateEuclideanDistance: () => (/* binding */ V),
|
|
16
|
+
/* harmony export */ calculateMovingSpeed: () => (/* binding */ G),
|
|
17
|
+
/* harmony export */ calculatePercentage: () => (/* binding */ H),
|
|
18
|
+
/* harmony export */ camelToDashCase: () => (/* binding */ t),
|
|
19
|
+
/* harmony export */ chunk: () => (/* binding */ B),
|
|
20
|
+
/* harmony export */ cloneBlob: () => (/* binding */ K),
|
|
21
|
+
/* harmony export */ compose: () => (/* binding */ Z),
|
|
22
|
+
/* harmony export */ convertBlobToFile: () => (/* binding */ Q),
|
|
23
|
+
/* harmony export */ delay: () => (/* binding */ I),
|
|
24
|
+
/* harmony export */ difference: () => (/* binding */ L),
|
|
25
|
+
/* harmony export */ everyAsync: () => (/* binding */ v),
|
|
26
|
+
/* harmony export */ filterAsync: () => (/* binding */ R),
|
|
27
|
+
/* harmony export */ findAsync: () => (/* binding */ E),
|
|
28
|
+
/* harmony export */ forAsync: () => (/* binding */ N),
|
|
29
|
+
/* harmony export */ hashString: () => (/* binding */ r),
|
|
30
|
+
/* harmony export */ intersection: () => (/* binding */ F),
|
|
31
|
+
/* harmony export */ invokeIfFunction: () => (/* binding */ D),
|
|
32
|
+
/* harmony export */ isArray: () => (/* binding */ p),
|
|
33
|
+
/* harmony export */ isBool: () => (/* binding */ u),
|
|
34
|
+
/* harmony export */ isDate: () => (/* binding */ b),
|
|
35
|
+
/* harmony export */ isDefined: () => (/* binding */ i),
|
|
36
|
+
/* harmony export */ isEmptyArray: () => (/* binding */ w),
|
|
37
|
+
/* harmony export */ isEmptyObject: () => (/* binding */ h),
|
|
38
|
+
/* harmony export */ isFiniteNumber: () => (/* binding */ M),
|
|
39
|
+
/* harmony export */ isFunction: () => (/* binding */ g),
|
|
40
|
+
/* harmony export */ isInteger: () => (/* binding */ x),
|
|
41
|
+
/* harmony export */ isMap: () => (/* binding */ k),
|
|
42
|
+
/* harmony export */ isNil: () => (/* binding */ l),
|
|
43
|
+
/* harmony export */ isNilOrEmptyString: () => (/* binding */ s),
|
|
44
|
+
/* harmony export */ isNull: () => (/* binding */ o),
|
|
45
|
+
/* harmony export */ isNumber: () => (/* binding */ f),
|
|
46
|
+
/* harmony export */ isObject: () => (/* binding */ y),
|
|
47
|
+
/* harmony export */ isPromise: () => (/* binding */ m),
|
|
48
|
+
/* harmony export */ isRegExp: () => (/* binding */ A),
|
|
49
|
+
/* harmony export */ isSet: () => (/* binding */ C),
|
|
50
|
+
/* harmony export */ isString: () => (/* binding */ c),
|
|
51
|
+
/* harmony export */ isSymbol: () => (/* binding */ X),
|
|
52
|
+
/* harmony export */ isUndefined: () => (/* binding */ Y),
|
|
53
|
+
/* harmony export */ isValidDate: () => (/* binding */ d),
|
|
54
|
+
/* harmony export */ mapAsync: () => (/* binding */ P),
|
|
55
|
+
/* harmony export */ noop: () => (/* binding */ q),
|
|
56
|
+
/* harmony export */ parse2DMatrix: () => (/* binding */ J),
|
|
57
|
+
/* harmony export */ pipe: () => (/* binding */ T),
|
|
58
|
+
/* harmony export */ reduceAsync: () => (/* binding */ z),
|
|
59
|
+
/* harmony export */ retry: () => (/* binding */ O),
|
|
60
|
+
/* harmony export */ someAsync: () => (/* binding */ j),
|
|
61
|
+
/* harmony export */ splitStringIntoWords: () => (/* binding */ n),
|
|
62
|
+
/* harmony export */ toKebabCase: () => (/* binding */ e),
|
|
63
|
+
/* harmony export */ unique: () => (/* binding */ $)
|
|
64
|
+
/* harmony export */ });
|
|
65
|
+
const e=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),t=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},n=e=>e.split(" ").filter(Boolean),r=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)};function a(e,t){if(!e)throw new Error(t)}const o=e=>null===e,l=e=>null==e,s=e=>""===e||l(e),i=e=>null!=e,c=e=>"string"==typeof e,f=e=>"number"==typeof e,u=e=>"boolean"==typeof e,y=e=>"object"==typeof e,h=e=>y(e)&&!o(e)&&0===Object.keys(e).length,p=e=>Array.isArray(e),w=e=>p(e)&&0===e.length,g=e=>"function"==typeof e,m=e=>g(e?.then),b=e=>e instanceof Date,d=e=>b(e)&&!isNaN(e.getTime()),A=e=>e instanceof RegExp,k=e=>e instanceof Map,C=e=>e instanceof Set,X=e=>"symbol"==typeof e,Y=e=>void 0===e,M=e=>f(e)&&isFinite(e),x=e=>f(e)&&Number.isInteger(e),S=e=>e.filter(Boolean),$=e=>[...new Set(e)],B=(e,t)=>(a(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),F=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return $(t).filter(e=>n.every(t=>t.includes(e)))},L=(e,t)=>e.filter(e=>!t.includes(e)),N=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},P=async(e,t)=>Promise.all(e.map(t)),R=async(e,t)=>{const n=await P(e,async(e,n,r)=>!!await t(e,n,r)&&e);return S(n)},j=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},v=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},E=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},T=(...e)=>t=>e.reduce((e,t)=>t(e),t),Z=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),q=()=>{},D=(e,...t)=>"function"==typeof e?e(...t):e,I=e=>new Promise(t=>setTimeout(t,e)),O=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...o)=>{let l;for(let s=1;s<=t;s++)try{return await e(...o)}catch(e){if(l=e,s<t){a?.(s,e);const t=r?n*2**(s-1):n;await I(t)}}throw l},V=(e,t,n,r)=>{const a=n-e,o=r-t;return Math.sqrt(a**2+o**2)},G=(e,t)=>Math.abs(e/t),H=(e,t)=>e*t/100,J=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,o,l,s]=t[1].split(", ").map(parseFloat);return{translateX:l,translateY:s,scaleX:n,scaleY:o,skewX:a,skewY:r}},K=e=>new Blob([e],{type:e.type}),Q=(e,t)=>new File([e],t,{type:e.type});
|
|
66
|
+
//# sourceMappingURL=index.mjs.map
|
|
67
|
+
|
|
68
|
+
/***/ }),
|
|
69
|
+
|
|
5
70
|
/***/ "./node_modules/react/cjs/react-jsx-runtime.development.js":
|
|
6
71
|
/*!*****************************************************************!*\
|
|
7
72
|
!*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***!
|
|
@@ -1809,7 +1874,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1809
1874
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1810
1875
|
/* harmony export */ mediaQuery: () => (/* binding */ mediaQuery)
|
|
1811
1876
|
/* harmony export */ });
|
|
1812
|
-
/* harmony import */ var
|
|
1877
|
+
/* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
|
|
1813
1878
|
|
|
1814
1879
|
/**
|
|
1815
1880
|
* Constructs a complete `@media` query string from an array of media rule objects.
|
|
@@ -1844,7 +1909,7 @@ const mediaQuery = (rules) => {
|
|
|
1844
1909
|
rule.resolution && ['resolution', rule.resolution],
|
|
1845
1910
|
rule.update && ['update', rule.update],
|
|
1846
1911
|
];
|
|
1847
|
-
const conditions = (0,
|
|
1912
|
+
const conditions = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.boolFilter)(rulesConfig)
|
|
1848
1913
|
.map(ruleConfig => `(${ruleConfig[0]}: ${ruleConfig[1]})`)
|
|
1849
1914
|
.join(' and ');
|
|
1850
1915
|
const operatorPart = rule.operator ? `${rule.operator} ` : '';
|
|
@@ -1918,27 +1983,29 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1918
1983
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1919
1984
|
/* harmony export */ css: () => (/* binding */ css)
|
|
1920
1985
|
/* harmony export */ });
|
|
1921
|
-
/* harmony import */ var
|
|
1922
|
-
/* harmony import */ var
|
|
1986
|
+
/* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
|
|
1987
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants */ "./src/constants.ts");
|
|
1988
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils */ "./src/utils.ts");
|
|
1989
|
+
|
|
1923
1990
|
|
|
1924
1991
|
|
|
1925
1992
|
const resolveCssInterpolation = (value, context) => {
|
|
1926
|
-
if (value === '' || value === false || (0,
|
|
1993
|
+
if (value === '' || value === false || (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.isNil)(value)) {
|
|
1927
1994
|
return '';
|
|
1928
1995
|
}
|
|
1929
|
-
if ((0,
|
|
1930
|
-
if ((0,
|
|
1931
|
-
return `.${value[
|
|
1996
|
+
if ((0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.isFunction)(value)) {
|
|
1997
|
+
if ((0,_utils__WEBPACK_IMPORTED_MODULE_2__.isStyledComponent)(value)) {
|
|
1998
|
+
return `.${value[_constants__WEBPACK_IMPORTED_MODULE_1__.HONEY_STYLED_COMPONENT_ID_PROP]}`;
|
|
1932
1999
|
}
|
|
1933
2000
|
return resolveCssInterpolation(value(context), context);
|
|
1934
2001
|
}
|
|
1935
2002
|
if (Array.isArray(value)) {
|
|
1936
2003
|
return value.map(v => resolveCssInterpolation(v, context)).join('\n');
|
|
1937
2004
|
}
|
|
1938
|
-
if ((0,
|
|
2005
|
+
if ((0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.isObject)(value)) {
|
|
1939
2006
|
return Object.entries(value)
|
|
1940
2007
|
.filter(([, v]) => v !== undefined && v !== false)
|
|
1941
|
-
.map(([k, v]) => `${(0,
|
|
2008
|
+
.map(([k, v]) => `${(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.toKebabCase)(k)}: ${v};`)
|
|
1942
2009
|
.join('\n');
|
|
1943
2010
|
}
|
|
1944
2011
|
return value.toString?.() ?? '';
|
|
@@ -1968,7 +2035,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1968
2035
|
/* harmony export */ createStackAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createStackAtRuleMiddleware),
|
|
1969
2036
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_4__.css),
|
|
1970
2037
|
/* harmony export */ mediaQuery: () => (/* reexport safe */ _at_rules__WEBPACK_IMPORTED_MODULE_5__.mediaQuery),
|
|
1971
|
-
/* harmony export */ processCss: () => (/* reexport safe */ _processor__WEBPACK_IMPORTED_MODULE_3__.processCss)
|
|
2038
|
+
/* harmony export */ processCss: () => (/* reexport safe */ _processor__WEBPACK_IMPORTED_MODULE_3__.processCss),
|
|
2039
|
+
/* harmony export */ suggestAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.suggestAtRuleMiddleware)
|
|
1972
2040
|
/* harmony export */ });
|
|
1973
2041
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/css/types.ts");
|
|
1974
2042
|
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/css/constants.ts");
|
|
@@ -2167,7 +2235,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2167
2235
|
/* harmony export */ createEllipsisAtRuleMiddleware: () => (/* reexport safe */ _ellipsis_at_rule__WEBPACK_IMPORTED_MODULE_5__.createEllipsisAtRuleMiddleware),
|
|
2168
2236
|
/* harmony export */ createInlineAtRuleMiddleware: () => (/* reexport safe */ _inline_at_rule__WEBPACK_IMPORTED_MODULE_2__.createInlineAtRuleMiddleware),
|
|
2169
2237
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _spacing__WEBPACK_IMPORTED_MODULE_0__.createSpacingMiddleware),
|
|
2170
|
-
/* harmony export */ createStackAtRuleMiddleware: () => (/* reexport safe */ _stack_at_rule__WEBPACK_IMPORTED_MODULE_1__.createStackAtRuleMiddleware)
|
|
2238
|
+
/* harmony export */ createStackAtRuleMiddleware: () => (/* reexport safe */ _stack_at_rule__WEBPACK_IMPORTED_MODULE_1__.createStackAtRuleMiddleware),
|
|
2239
|
+
/* harmony export */ suggestAtRuleMiddleware: () => (/* reexport safe */ _suggest__WEBPACK_IMPORTED_MODULE_6__.suggestAtRuleMiddleware)
|
|
2171
2240
|
/* harmony export */ });
|
|
2172
2241
|
/* harmony import */ var _spacing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./spacing */ "./src/css/middlewares/spacing.ts");
|
|
2173
2242
|
/* harmony import */ var _stack_at_rule__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stack-at-rule */ "./src/css/middlewares/stack-at-rule.ts");
|
|
@@ -2175,6 +2244,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2175
2244
|
/* harmony import */ var _center_at_rule__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./center-at-rule */ "./src/css/middlewares/center-at-rule.ts");
|
|
2176
2245
|
/* harmony import */ var _absolute_fill_at_rule__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./absolute-fill-at-rule */ "./src/css/middlewares/absolute-fill-at-rule.ts");
|
|
2177
2246
|
/* harmony import */ var _ellipsis_at_rule__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipsis-at-rule */ "./src/css/middlewares/ellipsis-at-rule.ts");
|
|
2247
|
+
/* harmony import */ var _suggest__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./suggest */ "./src/css/middlewares/suggest.ts");
|
|
2248
|
+
|
|
2178
2249
|
|
|
2179
2250
|
|
|
2180
2251
|
|
|
@@ -2197,13 +2268,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2197
2268
|
/* harmony export */ });
|
|
2198
2269
|
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./factory */ "./src/css/middlewares/factory.ts");
|
|
2199
2270
|
|
|
2200
|
-
const createInlineAtRuleMiddleware = ({
|
|
2271
|
+
const createInlineAtRuleMiddleware = ({ spacing = 0, } = {}) => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2201
2272
|
name: 'inline',
|
|
2202
2273
|
transform: args => {
|
|
2203
2274
|
const declarations = ['display:flex;', 'align-items:center;'];
|
|
2204
2275
|
if (args?.length) {
|
|
2205
2276
|
const isNumber = /^-?\d*\.?\d+$/.test(args[0]);
|
|
2206
|
-
const gap = isNumber ? `${parseFloat(args[0]) *
|
|
2277
|
+
const gap = isNumber ? `${parseFloat(args[0]) * spacing}px` : args;
|
|
2207
2278
|
declarations.push(`gap:${gap};`);
|
|
2208
2279
|
}
|
|
2209
2280
|
return declarations.join('');
|
|
@@ -2227,7 +2298,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2227
2298
|
|
|
2228
2299
|
const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2229
2300
|
const KEBAB_CASE_SPACING_PROPERTIES = _constants__WEBPACK_IMPORTED_MODULE_0__.CSS_SPACING_PROPERTIES.map(toKebabCase);
|
|
2230
|
-
const createSpacingMiddleware = ({
|
|
2301
|
+
const createSpacingMiddleware = ({ spacing = 0 }) => element => {
|
|
2231
2302
|
if (element.type !== 'decl') {
|
|
2232
2303
|
return;
|
|
2233
2304
|
}
|
|
@@ -2243,7 +2314,7 @@ const createSpacingMiddleware = ({ spacingMultiplier = 0 }) => element => {
|
|
|
2243
2314
|
for (const value of parts) {
|
|
2244
2315
|
transformedParts.push(
|
|
2245
2316
|
// Accept only numeric strings (integers or floats), no units or symbols
|
|
2246
|
-
/^-?\d*\.?\d+$/.test(value) ? `${parseFloat(value) *
|
|
2317
|
+
/^-?\d*\.?\d+$/.test(value) ? `${parseFloat(value) * spacing}px` : value);
|
|
2247
2318
|
}
|
|
2248
2319
|
const transformed = transformedParts.join(' ');
|
|
2249
2320
|
element.return = `${element.props}:${transformed};`;
|
|
@@ -2265,13 +2336,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2265
2336
|
/* harmony export */ });
|
|
2266
2337
|
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./factory */ "./src/css/middlewares/factory.ts");
|
|
2267
2338
|
|
|
2268
|
-
const createStackAtRuleMiddleware = ({
|
|
2339
|
+
const createStackAtRuleMiddleware = ({ spacing = 0 }) => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2269
2340
|
name: 'stack',
|
|
2270
2341
|
transform: args => {
|
|
2271
2342
|
const declarations = ['display:flex;', 'flex-direction:column;'];
|
|
2272
2343
|
if (args?.length) {
|
|
2273
2344
|
const isNumber = /^-?\d*\.?\d+$/.test(args[0]);
|
|
2274
|
-
const gap = isNumber ? `${parseFloat(args[0]) *
|
|
2345
|
+
const gap = isNumber ? `${parseFloat(args[0]) * spacing}px` : args;
|
|
2275
2346
|
declarations.push(`gap:${gap};`);
|
|
2276
2347
|
}
|
|
2277
2348
|
return declarations.join('');
|
|
@@ -2279,6 +2350,63 @@ const createStackAtRuleMiddleware = ({ spacingMultiplier = 0, }) => (0,_factory_
|
|
|
2279
2350
|
});
|
|
2280
2351
|
|
|
2281
2352
|
|
|
2353
|
+
/***/ }),
|
|
2354
|
+
|
|
2355
|
+
/***/ "./src/css/middlewares/suggest.ts":
|
|
2356
|
+
/*!****************************************!*\
|
|
2357
|
+
!*** ./src/css/middlewares/suggest.ts ***!
|
|
2358
|
+
\****************************************/
|
|
2359
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2360
|
+
|
|
2361
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2362
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2363
|
+
/* harmony export */ suggestAtRuleMiddleware: () => (/* binding */ suggestAtRuleMiddleware)
|
|
2364
|
+
/* harmony export */ });
|
|
2365
|
+
const collectDeclarations = (rule) => {
|
|
2366
|
+
if (!rule.children || !Array.isArray(rule.children)) {
|
|
2367
|
+
return [];
|
|
2368
|
+
}
|
|
2369
|
+
return rule.children
|
|
2370
|
+
.filter(child => child.type === 'decl' &&
|
|
2371
|
+
typeof child.props === 'string' &&
|
|
2372
|
+
typeof child.children === 'string')
|
|
2373
|
+
.map(child => ({
|
|
2374
|
+
prop: child.props,
|
|
2375
|
+
value: child.children,
|
|
2376
|
+
}));
|
|
2377
|
+
};
|
|
2378
|
+
const knownPatterns = [
|
|
2379
|
+
{
|
|
2380
|
+
name: '@honey-center',
|
|
2381
|
+
match: (declarations) => declarations.some(d => d.prop === 'display' && d.value === 'flex') &&
|
|
2382
|
+
declarations.some(d => d.prop === 'align-items' && d.value === 'center') &&
|
|
2383
|
+
declarations.some(d => d.prop === 'justify-content' && d.value === 'center'),
|
|
2384
|
+
},
|
|
2385
|
+
{
|
|
2386
|
+
name: '@honey-stack',
|
|
2387
|
+
match: (declarations) => declarations.some(d => d.prop === 'display' && d.value === 'flex') &&
|
|
2388
|
+
declarations.some(d => d.prop === 'flex-direction' && d.value === 'column'),
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
name: '@honey-inline',
|
|
2392
|
+
match: (declarations) => declarations.some(d => d.prop === 'display' && d.value === 'flex') &&
|
|
2393
|
+
declarations.some(d => d.prop === 'align-items' && d.value === 'center'),
|
|
2394
|
+
},
|
|
2395
|
+
];
|
|
2396
|
+
const suggestAtRuleMiddleware = element => {
|
|
2397
|
+
if (element.type !== 'rule' || !element.children) {
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
const declarations = collectDeclarations(element);
|
|
2401
|
+
for (const pattern of knownPatterns) {
|
|
2402
|
+
if (pattern.match(declarations)) {
|
|
2403
|
+
console.info(`[@react-hive/honey-style]: The CSS rule "${element.value}" can be simplified using the shorthand at-rule "${pattern.name}".`);
|
|
2404
|
+
break;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
|
|
2282
2410
|
/***/ }),
|
|
2283
2411
|
|
|
2284
2412
|
/***/ "./src/css/processor.ts":
|
|
@@ -2291,24 +2419,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2291
2419
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2292
2420
|
/* harmony export */ processCss: () => (/* binding */ processCss)
|
|
2293
2421
|
/* harmony export */ });
|
|
2294
|
-
/* harmony import */ var
|
|
2295
|
-
/* harmony import */ var
|
|
2296
|
-
/* harmony import */ var
|
|
2297
|
-
/* harmony import */ var
|
|
2422
|
+
/* harmony import */ var stylis__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! stylis */ "./node_modules/stylis/src/Serializer.js");
|
|
2423
|
+
/* harmony import */ var stylis__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! stylis */ "./node_modules/stylis/src/Parser.js");
|
|
2424
|
+
/* harmony import */ var stylis__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! stylis */ "./node_modules/stylis/src/Middleware.js");
|
|
2425
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants */ "./src/constants.ts");
|
|
2426
|
+
/* harmony import */ var _middlewares__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./middlewares */ "./src/css/middlewares/index.ts");
|
|
2427
|
+
|
|
2298
2428
|
|
|
2299
2429
|
|
|
2300
|
-
const processCss = (rawCss, selector, {
|
|
2430
|
+
const processCss = (rawCss, selector, { spacing } = {}) => {
|
|
2301
2431
|
const scopedCss = selector ? `${selector}{${rawCss}}` : rawCss;
|
|
2302
|
-
const middlewares = [
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
(0,_middlewares__WEBPACK_IMPORTED_MODULE_0__.createSpacingMiddleware)({ spacingMultiplier }),
|
|
2309
|
-
stylis__WEBPACK_IMPORTED_MODULE_1__.stringify,
|
|
2310
|
-
];
|
|
2311
|
-
return (0,stylis__WEBPACK_IMPORTED_MODULE_1__.serialize)((0,stylis__WEBPACK_IMPORTED_MODULE_2__.compile)(scopedCss), (0,stylis__WEBPACK_IMPORTED_MODULE_3__.middleware)(middlewares));
|
|
2432
|
+
const middlewares = [];
|
|
2433
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_0__.__DEV__) {
|
|
2434
|
+
// middlewares.push(suggestAtRuleMiddleware);
|
|
2435
|
+
}
|
|
2436
|
+
middlewares.push((0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createStackAtRuleMiddleware)({ spacing }), (0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createInlineAtRuleMiddleware)({ spacing }), (0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createCenterAtRuleMiddleware)(), (0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createEllipsisAtRuleMiddleware)(), (0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createAbsoluteFillAtRuleMiddleware)(), (0,_middlewares__WEBPACK_IMPORTED_MODULE_1__.createSpacingMiddleware)({ spacing }), stylis__WEBPACK_IMPORTED_MODULE_2__.stringify);
|
|
2437
|
+
return (0,stylis__WEBPACK_IMPORTED_MODULE_2__.serialize)((0,stylis__WEBPACK_IMPORTED_MODULE_3__.compile)(scopedCss), (0,stylis__WEBPACK_IMPORTED_MODULE_4__.middleware)(middlewares));
|
|
2312
2438
|
};
|
|
2313
2439
|
|
|
2314
2440
|
|
|
@@ -2400,14 +2526,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2400
2526
|
/* harmony export */ });
|
|
2401
2527
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
2402
2528
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2403
|
-
/* harmony import */ var
|
|
2529
|
+
/* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
|
|
2404
2530
|
/* harmony import */ var _contexts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../contexts */ "./src/contexts/index.ts");
|
|
2405
2531
|
|
|
2406
2532
|
|
|
2407
2533
|
|
|
2408
2534
|
const useHoneyStyle = () => {
|
|
2409
2535
|
const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_contexts__WEBPACK_IMPORTED_MODULE_2__.HoneyStyleContext);
|
|
2410
|
-
(0,
|
|
2536
|
+
(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, 'The `useHoneyStyle()` hook must be used inside <HoneyStyleProvider/> component!');
|
|
2411
2537
|
return context;
|
|
2412
2538
|
};
|
|
2413
2539
|
|
|
@@ -2568,11 +2694,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2568
2694
|
/* harmony export */ });
|
|
2569
2695
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
2570
2696
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2571
|
-
/* harmony import */ var
|
|
2572
|
-
/* harmony import */ var
|
|
2573
|
-
/* harmony import */ var
|
|
2574
|
-
/* harmony import */ var
|
|
2575
|
-
/* harmony import */ var
|
|
2697
|
+
/* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
|
|
2698
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
2699
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/utils.ts");
|
|
2700
|
+
/* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./css */ "./src/css/index.ts");
|
|
2701
|
+
/* harmony import */ var _mount_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./mount-style */ "./src/mount-style.ts");
|
|
2702
|
+
/* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./hooks */ "./src/hooks/index.ts");
|
|
2703
|
+
|
|
2576
2704
|
|
|
2577
2705
|
|
|
2578
2706
|
|
|
@@ -2583,23 +2711,23 @@ const evaluateDynamicCss = (interpolation, context) => {
|
|
|
2583
2711
|
if (!interpolation) {
|
|
2584
2712
|
return '';
|
|
2585
2713
|
}
|
|
2586
|
-
if ((0,
|
|
2714
|
+
if ((0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isString)(interpolation)) {
|
|
2587
2715
|
return interpolation;
|
|
2588
2716
|
}
|
|
2589
2717
|
// @ts-expect-error
|
|
2590
|
-
return (0,
|
|
2718
|
+
return (0,_css__WEBPACK_IMPORTED_MODULE_4__.css)([''], [interpolation])(context);
|
|
2591
2719
|
};
|
|
2592
2720
|
const styled = (target, defaultProps) => {
|
|
2593
2721
|
return (strings, ...interpolations) => {
|
|
2594
|
-
const componentId = (0,
|
|
2595
|
-
const computeCss = (0,
|
|
2722
|
+
const componentId = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.generateId)('hsc');
|
|
2723
|
+
const computeCss = (0,_css__WEBPACK_IMPORTED_MODULE_4__.css)(strings, ...interpolations);
|
|
2596
2724
|
const StyledComponent = ({ as, className, __compositionDepth = 0, css: cssProp, ...props }) => {
|
|
2597
|
-
if (
|
|
2725
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_2__.__DEV__ && cssProp) {
|
|
2598
2726
|
console.warn(`[@react-hive/honey-style]: The "css" prop is deprecated. Please use inheritance or composition instead.`);
|
|
2599
2727
|
}
|
|
2600
|
-
const { theme } = (0,
|
|
2728
|
+
const { theme } = (0,_hooks__WEBPACK_IMPORTED_MODULE_6__.useHoneyStyle)();
|
|
2601
2729
|
const cleanedProps = Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
|
|
2602
|
-
const resolvedDefaultProps = (0,
|
|
2730
|
+
const resolvedDefaultProps = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(defaultProps)
|
|
2603
2731
|
? defaultProps({ theme, as, className, ...cleanedProps })
|
|
2604
2732
|
: (defaultProps ?? {});
|
|
2605
2733
|
const context = {
|
|
@@ -2608,47 +2736,47 @@ const styled = (target, defaultProps) => {
|
|
|
2608
2736
|
theme,
|
|
2609
2737
|
};
|
|
2610
2738
|
const rawCss = computeCss(context);
|
|
2611
|
-
const baseClassName = (0,
|
|
2739
|
+
const baseClassName = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveClassName)(rawCss);
|
|
2612
2740
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useInsertionEffect)(() => {
|
|
2613
|
-
const baseCss = (0,
|
|
2614
|
-
|
|
2741
|
+
const baseCss = (0,_css__WEBPACK_IMPORTED_MODULE_4__.processCss)(rawCss, `.${baseClassName}`, {
|
|
2742
|
+
spacing: theme.spacings.base,
|
|
2615
2743
|
});
|
|
2616
|
-
return (0,
|
|
2744
|
+
return (0,_mount_style__WEBPACK_IMPORTED_MODULE_5__.mountStyle)(baseClassName, baseCss, __compositionDepth);
|
|
2617
2745
|
}, [baseClassName]);
|
|
2618
|
-
const cssPropRaw = (0,
|
|
2746
|
+
const cssPropRaw = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(cssProp) ? cssProp(context) : cssProp;
|
|
2619
2747
|
const cssPropString = evaluateDynamicCss(cssPropRaw, context);
|
|
2620
|
-
const cssPropClassName = cssPropString ? (0,
|
|
2748
|
+
const cssPropClassName = cssPropString ? (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveClassName)(cssPropString) : '';
|
|
2621
2749
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useInsertionEffect)(() => {
|
|
2622
2750
|
if (cssPropClassName) {
|
|
2623
|
-
const overrideCss = (0,
|
|
2624
|
-
|
|
2751
|
+
const overrideCss = (0,_css__WEBPACK_IMPORTED_MODULE_4__.processCss)(cssPropString, `.${cssPropClassName}`, {
|
|
2752
|
+
spacing: theme.spacings.base,
|
|
2625
2753
|
});
|
|
2626
|
-
return (0,
|
|
2754
|
+
return (0,_mount_style__WEBPACK_IMPORTED_MODULE_5__.mountStyle)(cssPropClassName, overrideCss, 1);
|
|
2627
2755
|
}
|
|
2628
2756
|
}, [cssPropClassName]);
|
|
2629
2757
|
const mergedProps = {
|
|
2630
2758
|
...resolvedDefaultProps,
|
|
2631
2759
|
...cleanedProps,
|
|
2632
|
-
className: (0,
|
|
2760
|
+
className: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.combineClassNames)([componentId, baseClassName, className, cssPropClassName]),
|
|
2633
2761
|
};
|
|
2634
2762
|
const finalComponent = as || target;
|
|
2635
|
-
if ((0,
|
|
2636
|
-
const filteredProps = (0,
|
|
2637
|
-
? (0,
|
|
2763
|
+
if ((0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isString)(target)) {
|
|
2764
|
+
const filteredProps = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isString)(finalComponent)
|
|
2765
|
+
? (0,_utils__WEBPACK_IMPORTED_MODULE_3__.filterNonHtmlAttrs)(mergedProps)
|
|
2638
2766
|
: mergedProps;
|
|
2639
2767
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(finalComponent, filteredProps);
|
|
2640
2768
|
}
|
|
2641
2769
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(target, {
|
|
2642
2770
|
...mergedProps,
|
|
2643
2771
|
...(as && { as }),
|
|
2644
|
-
...((0,
|
|
2772
|
+
...((0,_utils__WEBPACK_IMPORTED_MODULE_3__.isStyledComponent)(target) && {
|
|
2645
2773
|
__compositionDepth: __compositionDepth - 1,
|
|
2646
2774
|
}),
|
|
2647
2775
|
});
|
|
2648
2776
|
};
|
|
2649
|
-
StyledComponent[
|
|
2650
|
-
if (
|
|
2651
|
-
const componentName = (0,
|
|
2777
|
+
StyledComponent[_constants__WEBPACK_IMPORTED_MODULE_2__.HONEY_STYLED_COMPONENT_ID_PROP] = componentId;
|
|
2778
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_2__.__DEV__) {
|
|
2779
|
+
const componentName = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isString)(target)
|
|
2652
2780
|
? target
|
|
2653
2781
|
: target.displayName || target.name || 'Component';
|
|
2654
2782
|
StyledComponent.displayName = `HoneyStyledComponent(${componentName})`;
|
|
@@ -2708,100 +2836,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2708
2836
|
|
|
2709
2837
|
__webpack_require__.r(__webpack_exports__);
|
|
2710
2838
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2711
|
-
/* harmony export */ assert: () => (/* binding */ assert),
|
|
2712
|
-
/* harmony export */ boolFilter: () => (/* binding */ boolFilter),
|
|
2713
2839
|
/* harmony export */ checkIsThemeColorValue: () => (/* binding */ checkIsThemeColorValue),
|
|
2714
2840
|
/* harmony export */ combineClassNames: () => (/* binding */ combineClassNames),
|
|
2715
2841
|
/* harmony export */ convertHexToHexWithAlpha: () => (/* binding */ convertHexToHexWithAlpha),
|
|
2716
2842
|
/* harmony export */ filterNonHtmlAttrs: () => (/* binding */ filterNonHtmlAttrs),
|
|
2717
2843
|
/* harmony export */ generateId: () => (/* binding */ generateId),
|
|
2718
|
-
/* harmony export */ isFunction: () => (/* binding */ isFunction),
|
|
2719
|
-
/* harmony export */ isNil: () => (/* binding */ isNil),
|
|
2720
|
-
/* harmony export */ isObject: () => (/* binding */ isObject),
|
|
2721
|
-
/* harmony export */ isString: () => (/* binding */ isString),
|
|
2722
2844
|
/* harmony export */ isStyledComponent: () => (/* binding */ isStyledComponent),
|
|
2723
2845
|
/* harmony export */ pxToRem: () => (/* binding */ pxToRem),
|
|
2724
2846
|
/* harmony export */ resolveClassName: () => (/* binding */ resolveClassName),
|
|
2725
2847
|
/* harmony export */ resolveColor: () => (/* binding */ resolveColor),
|
|
2726
2848
|
/* harmony export */ resolveDimension: () => (/* binding */ resolveDimension),
|
|
2727
2849
|
/* harmony export */ resolveFont: () => (/* binding */ resolveFont),
|
|
2728
|
-
/* harmony export */ resolveSpacing: () => (/* binding */ resolveSpacing)
|
|
2729
|
-
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
2850
|
+
/* harmony export */ resolveSpacing: () => (/* binding */ resolveSpacing)
|
|
2730
2851
|
/* harmony export */ });
|
|
2731
|
-
/* harmony import */ var
|
|
2732
|
-
/* harmony import */ var
|
|
2852
|
+
/* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
|
|
2853
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
2854
|
+
/* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./src/css/index.ts");
|
|
2855
|
+
|
|
2733
2856
|
|
|
2734
2857
|
|
|
2735
|
-
function assert(condition, message) {
|
|
2736
|
-
if (!condition) {
|
|
2737
|
-
throw new Error(message);
|
|
2738
|
-
}
|
|
2739
|
-
}
|
|
2740
2858
|
const generateId = (prefix) => `${prefix}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2741
|
-
const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2742
|
-
const isString = (value) => typeof value === 'string';
|
|
2743
|
-
const isObject = (value) => typeof value === 'object';
|
|
2744
|
-
const isFunction = (value) => typeof value === 'function';
|
|
2745
|
-
/**
|
|
2746
|
-
* Checks if a value is null or undefined.
|
|
2747
|
-
*
|
|
2748
|
-
* @param value - The value to check.
|
|
2749
|
-
*
|
|
2750
|
-
* @returns `true` if the value is `null` or `undefined`, otherwise `false`.
|
|
2751
|
-
*/
|
|
2752
|
-
const isNil = (value) => value === undefined || value === null;
|
|
2753
|
-
/**
|
|
2754
|
-
* Filters out `null`, `undefined`, and other falsy values from an array,
|
|
2755
|
-
* returning a typed array of only truthy `Item` values.
|
|
2756
|
-
*
|
|
2757
|
-
* Useful when working with optional or nullable items that need to be sanitized.
|
|
2758
|
-
*
|
|
2759
|
-
* @template T - The type of the items in the array.
|
|
2760
|
-
*
|
|
2761
|
-
* @param array - An array of items that may include `null`, `undefined`, or falsy values.
|
|
2762
|
-
*
|
|
2763
|
-
* @returns A new array containing only truthy `Item` values.
|
|
2764
|
-
*/
|
|
2765
|
-
const boolFilter = (array) => array.filter(Boolean);
|
|
2766
|
-
/**
|
|
2767
|
-
* Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
|
|
2768
|
-
*
|
|
2769
|
-
* This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
|
|
2770
|
-
* based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
|
|
2771
|
-
* which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
|
|
2772
|
-
*
|
|
2773
|
-
* Useful for:
|
|
2774
|
-
* - Generating stable class names in CSS-in-JS libraries.
|
|
2775
|
-
* - Producing consistent cache keys.
|
|
2776
|
-
* - Quick and lightweight hashing needs where cryptographic security is not required.
|
|
2777
|
-
*
|
|
2778
|
-
* ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
|
|
2779
|
-
*
|
|
2780
|
-
* @param str - The input string to hash.
|
|
2781
|
-
*
|
|
2782
|
-
* @returns A short, base-36 encoded hash string.
|
|
2783
|
-
*
|
|
2784
|
-
* @example
|
|
2785
|
-
* ```ts
|
|
2786
|
-
* const className = hashString('background-color: red;');
|
|
2787
|
-
* // → 'e4k1z0x'
|
|
2788
|
-
* ```
|
|
2789
|
-
*/
|
|
2790
|
-
const hashString = (str) => {
|
|
2791
|
-
let hash = 5381;
|
|
2792
|
-
for (let i = 0; i < str.length; i++) {
|
|
2793
|
-
hash = (hash * 33) ^ str.charCodeAt(i);
|
|
2794
|
-
}
|
|
2795
|
-
return (hash >>> 0).toString(36);
|
|
2796
|
-
};
|
|
2797
2859
|
/**
|
|
2798
2860
|
* Combines multiple class names into a single space-separated string
|
|
2799
2861
|
*
|
|
2800
2862
|
* @param classNames - Array of class names to combine
|
|
2801
2863
|
*/
|
|
2802
2864
|
const combineClassNames = (classNames) => classNames.filter(Boolean).join(' ').trim();
|
|
2803
|
-
const resolveClassName = (css) => `hscn-${hashString(css)}`;
|
|
2804
|
-
const isStyledComponent = (component) =>
|
|
2865
|
+
const resolveClassName = (css) => `hscn-${(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_0__.hashString)(css)}`;
|
|
2866
|
+
const isStyledComponent = (component) => _constants__WEBPACK_IMPORTED_MODULE_1__.HONEY_STYLED_COMPONENT_ID_PROP in component;
|
|
2805
2867
|
/**
|
|
2806
2868
|
* Filters out non-standard HTML attributes from a props object intended for a native HTML element.
|
|
2807
2869
|
*
|
|
@@ -2820,7 +2882,7 @@ const isStyledComponent = (component) => _constants__WEBPACK_IMPORTED_MODULE_0__
|
|
|
2820
2882
|
* @returns A new object containing only props that are safe and valid for use on native DOM elements.
|
|
2821
2883
|
*/
|
|
2822
2884
|
const filterNonHtmlAttrs = (attrs) => Object.entries(attrs).reduce((allowedAttrs, [name, value]) => {
|
|
2823
|
-
if (
|
|
2885
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_1__.VALID_DOM_ELEMENT_ATTRS.has(name) || name.startsWith('data-') || name.startsWith('aria-')) {
|
|
2824
2886
|
allowedAttrs[name] = value;
|
|
2825
2887
|
}
|
|
2826
2888
|
return allowedAttrs;
|
|
@@ -2893,7 +2955,7 @@ const resolveSpacing = (value, unit = 'px', type = 'base') => ({ theme }) => {
|
|
|
2893
2955
|
*/
|
|
2894
2956
|
const resolveFont = (fontName) => ({ theme }) => {
|
|
2895
2957
|
const font = theme.fonts[fontName];
|
|
2896
|
-
return (0,
|
|
2958
|
+
return (0,_css__WEBPACK_IMPORTED_MODULE_2__.css) `
|
|
2897
2959
|
font-family: ${font.family};
|
|
2898
2960
|
font-size: ${pxToRem(font.size)};
|
|
2899
2961
|
font-weight: ${font.weight};
|
|
@@ -3066,8 +3128,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3066
3128
|
/* harmony export */ HoneyStyleProvider: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_2__.HoneyStyleProvider),
|
|
3067
3129
|
/* harmony export */ VALID_DOM_ELEMENT_ATTRS: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_0__.VALID_DOM_ELEMENT_ATTRS),
|
|
3068
3130
|
/* harmony export */ __DEV__: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_0__.__DEV__),
|
|
3069
|
-
/* harmony export */ assert: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.assert),
|
|
3070
|
-
/* harmony export */ boolFilter: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.boolFilter),
|
|
3071
3131
|
/* harmony export */ checkIsThemeColorValue: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.checkIsThemeColorValue),
|
|
3072
3132
|
/* harmony export */ combineClassNames: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.combineClassNames),
|
|
3073
3133
|
/* harmony export */ convertHexToHexWithAlpha: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.convertHexToHexWithAlpha),
|
|
@@ -3081,10 +3141,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3081
3141
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.css),
|
|
3082
3142
|
/* harmony export */ filterNonHtmlAttrs: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.filterNonHtmlAttrs),
|
|
3083
3143
|
/* harmony export */ generateId: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.generateId),
|
|
3084
|
-
/* harmony export */ isFunction: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isFunction),
|
|
3085
|
-
/* harmony export */ isNil: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isNil),
|
|
3086
|
-
/* harmony export */ isObject: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isObject),
|
|
3087
|
-
/* harmony export */ isString: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isString),
|
|
3088
3144
|
/* harmony export */ isStyledComponent: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isStyledComponent),
|
|
3089
3145
|
/* harmony export */ mediaQuery: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.mediaQuery),
|
|
3090
3146
|
/* harmony export */ processCss: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.processCss),
|
|
@@ -3095,7 +3151,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3095
3151
|
/* harmony export */ resolveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.resolveFont),
|
|
3096
3152
|
/* harmony export */ resolveSpacing: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.resolveSpacing),
|
|
3097
3153
|
/* harmony export */ styled: () => (/* reexport safe */ _styled__WEBPACK_IMPORTED_MODULE_7__.styled),
|
|
3098
|
-
/* harmony export */
|
|
3154
|
+
/* harmony export */ suggestAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.suggestAtRuleMiddleware),
|
|
3099
3155
|
/* harmony export */ useHoneyStyle: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_3__.useHoneyStyle)
|
|
3100
3156
|
/* harmony export */ });
|
|
3101
3157
|
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|