@react-hive/honey-style 2.6.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/ellipsis-at-rule.d.ts +1 -0
- package/dist/css/middlewares/factory.d.ts +54 -14
- package/dist/css/middlewares/index.d.ts +2 -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 +296 -160
- 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 +8 -7
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?.() ?? '';
|
|
@@ -1962,12 +2029,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1962
2029
|
/* harmony export */ CSS_SPACING_PROPERTIES: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_1__.CSS_SPACING_PROPERTIES),
|
|
1963
2030
|
/* harmony export */ createAbsoluteFillAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createAbsoluteFillAtRuleMiddleware),
|
|
1964
2031
|
/* harmony export */ createCenterAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createCenterAtRuleMiddleware),
|
|
2032
|
+
/* harmony export */ createEllipsisAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createEllipsisAtRuleMiddleware),
|
|
1965
2033
|
/* harmony export */ createInlineAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createInlineAtRuleMiddleware),
|
|
1966
2034
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createSpacingMiddleware),
|
|
1967
2035
|
/* harmony export */ createStackAtRuleMiddleware: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_2__.createStackAtRuleMiddleware),
|
|
1968
2036
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_4__.css),
|
|
1969
2037
|
/* harmony export */ mediaQuery: () => (/* reexport safe */ _at_rules__WEBPACK_IMPORTED_MODULE_5__.mediaQuery),
|
|
1970
|
-
/* 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)
|
|
1971
2040
|
/* harmony export */ });
|
|
1972
2041
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/css/types.ts");
|
|
1973
2042
|
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/css/constants.ts");
|
|
@@ -1999,7 +2068,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1999
2068
|
|
|
2000
2069
|
const createAbsoluteFillAtRuleMiddleware = () => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2001
2070
|
name: 'absolute-fill',
|
|
2002
|
-
transform: () =>
|
|
2071
|
+
transform: () => {
|
|
2072
|
+
const declarations = ['position:absolute;', 'inset:0;'];
|
|
2073
|
+
return declarations.join('');
|
|
2074
|
+
},
|
|
2003
2075
|
});
|
|
2004
2076
|
|
|
2005
2077
|
|
|
@@ -2019,7 +2091,56 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2019
2091
|
|
|
2020
2092
|
const createCenterAtRuleMiddleware = () => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2021
2093
|
name: 'center',
|
|
2022
|
-
transform: () =>
|
|
2094
|
+
transform: (args = []) => {
|
|
2095
|
+
const declarations = [];
|
|
2096
|
+
switch (args[0]) {
|
|
2097
|
+
case 'horizontal':
|
|
2098
|
+
case 'x':
|
|
2099
|
+
declarations.push('display:flex;', 'justify-content:center;');
|
|
2100
|
+
break;
|
|
2101
|
+
case 'vertical':
|
|
2102
|
+
case 'y':
|
|
2103
|
+
declarations.push('display:flex;', 'align-items:center;');
|
|
2104
|
+
break;
|
|
2105
|
+
case 'block':
|
|
2106
|
+
declarations.push('display:block;', 'text-align:center;');
|
|
2107
|
+
break;
|
|
2108
|
+
case 'inline':
|
|
2109
|
+
declarations.push('display:inline-flex;', 'align-items:center;', 'justify-content:center;');
|
|
2110
|
+
break;
|
|
2111
|
+
default:
|
|
2112
|
+
declarations.push('display:flex;', 'align-items:center;', 'justify-content:center;');
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
return declarations.join('');
|
|
2116
|
+
},
|
|
2117
|
+
});
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
/***/ }),
|
|
2121
|
+
|
|
2122
|
+
/***/ "./src/css/middlewares/ellipsis-at-rule.ts":
|
|
2123
|
+
/*!*************************************************!*\
|
|
2124
|
+
!*** ./src/css/middlewares/ellipsis-at-rule.ts ***!
|
|
2125
|
+
\*************************************************/
|
|
2126
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2127
|
+
|
|
2128
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2129
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2130
|
+
/* harmony export */ createEllipsisAtRuleMiddleware: () => (/* binding */ createEllipsisAtRuleMiddleware)
|
|
2131
|
+
/* harmony export */ });
|
|
2132
|
+
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./factory */ "./src/css/middlewares/factory.ts");
|
|
2133
|
+
|
|
2134
|
+
const createEllipsisAtRuleMiddleware = () => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2135
|
+
name: 'ellipsis',
|
|
2136
|
+
transform: () => {
|
|
2137
|
+
const declarations = [
|
|
2138
|
+
'white-space:nowrap;',
|
|
2139
|
+
'overflow:hidden;',
|
|
2140
|
+
'text-overflow:ellipsis;',
|
|
2141
|
+
];
|
|
2142
|
+
return declarations.join('');
|
|
2143
|
+
},
|
|
2023
2144
|
});
|
|
2024
2145
|
|
|
2025
2146
|
|
|
@@ -2039,20 +2160,42 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2039
2160
|
/* harmony import */ var stylis__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! stylis */ "./node_modules/stylis/src/Parser.js");
|
|
2040
2161
|
|
|
2041
2162
|
/**
|
|
2042
|
-
* Creates a Stylis middleware
|
|
2043
|
-
*
|
|
2044
|
-
* and nested rule content.
|
|
2163
|
+
* Creates a Stylis middleware for transforming custom `@honey-*` at-rules into
|
|
2164
|
+
* regular CSS declarations.
|
|
2045
2165
|
*
|
|
2046
|
-
*
|
|
2047
|
-
*
|
|
2166
|
+
* This utility enables the definition of expressive, domain-specific at-rules
|
|
2167
|
+
* such as `@honey-stack`, `@honey-inline`, or `@honey-center`, which can then be
|
|
2168
|
+
* expanded into valid CSS at build time.
|
|
2169
|
+
*
|
|
2170
|
+
* Supports optional arguments passed via parentheses (e.g., `@honey-stack(2)`),
|
|
2171
|
+
* as well as nested rule bodies (e.g., `@honey-stack { .child { ... } }`).
|
|
2172
|
+
*
|
|
2173
|
+
* ---
|
|
2174
|
+
*
|
|
2175
|
+
* ### Example
|
|
2176
|
+
* ```ts
|
|
2048
2177
|
* createAtRuleMiddleware({
|
|
2049
2178
|
* name: 'stack',
|
|
2050
|
-
* transform: args =>
|
|
2179
|
+
* transform: args => {
|
|
2180
|
+
* const gap = parseFloat(args?.[0] ?? '0') * 8;
|
|
2181
|
+
*
|
|
2182
|
+
* return `display:flex;flex-direction:column;gap:${gap}px;`;
|
|
2183
|
+
* }
|
|
2051
2184
|
* });
|
|
2185
|
+
* ```
|
|
2186
|
+
*
|
|
2187
|
+
* ---
|
|
2052
2188
|
*
|
|
2053
|
-
*
|
|
2189
|
+
* ### Behavior
|
|
2190
|
+
* - Matches only rules of the form `@honey-${name}` inside standard CSS rules.
|
|
2191
|
+
* - Parses arguments from parentheses (e.g. `@honey-name (arg1 arg2)`).
|
|
2192
|
+
* - Serializes nested content (children) and appends it to the output.
|
|
2054
2193
|
*
|
|
2055
|
-
* @
|
|
2194
|
+
* @param options - Options for configuring the middleware:
|
|
2195
|
+
* - `name`: the custom at-rule suffix, without the `@honey-` prefix.
|
|
2196
|
+
* - `transform`: a function to convert parsed args and the AST node into CSS declarations.
|
|
2197
|
+
*
|
|
2198
|
+
* @returns A Stylis `Middleware` function that replaces the matched at-rule with the generated CSS.
|
|
2056
2199
|
*/
|
|
2057
2200
|
const createAtRuleMiddleware = ({ name, transform, }) => {
|
|
2058
2201
|
return (element, _i, _children, callback) => {
|
|
@@ -2066,7 +2209,7 @@ const createAtRuleMiddleware = ({ name, transform, }) => {
|
|
|
2066
2209
|
const argsMatch = element.value
|
|
2067
2210
|
.trim()
|
|
2068
2211
|
.match(new RegExp(`^${element.type}\\s*\\(\\s*([^)]+?)\\s*\\)\\s*;?$`, 'i'));
|
|
2069
|
-
const args = argsMatch ? argsMatch[1].
|
|
2212
|
+
const args = argsMatch ? argsMatch[1].split(' ').filter(Boolean) : undefined;
|
|
2070
2213
|
const transformedCSS = transform(args, element, name);
|
|
2071
2214
|
const serializedChildren = Array.isArray(element.children)
|
|
2072
2215
|
? (0,stylis__WEBPACK_IMPORTED_MODULE_0__.serialize)(element.children, callback)
|
|
@@ -2089,15 +2232,21 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2089
2232
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2090
2233
|
/* harmony export */ createAbsoluteFillAtRuleMiddleware: () => (/* reexport safe */ _absolute_fill_at_rule__WEBPACK_IMPORTED_MODULE_4__.createAbsoluteFillAtRuleMiddleware),
|
|
2091
2234
|
/* harmony export */ createCenterAtRuleMiddleware: () => (/* reexport safe */ _center_at_rule__WEBPACK_IMPORTED_MODULE_3__.createCenterAtRuleMiddleware),
|
|
2235
|
+
/* harmony export */ createEllipsisAtRuleMiddleware: () => (/* reexport safe */ _ellipsis_at_rule__WEBPACK_IMPORTED_MODULE_5__.createEllipsisAtRuleMiddleware),
|
|
2092
2236
|
/* harmony export */ createInlineAtRuleMiddleware: () => (/* reexport safe */ _inline_at_rule__WEBPACK_IMPORTED_MODULE_2__.createInlineAtRuleMiddleware),
|
|
2093
2237
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _spacing__WEBPACK_IMPORTED_MODULE_0__.createSpacingMiddleware),
|
|
2094
|
-
/* 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)
|
|
2095
2240
|
/* harmony export */ });
|
|
2096
2241
|
/* harmony import */ var _spacing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./spacing */ "./src/css/middlewares/spacing.ts");
|
|
2097
2242
|
/* harmony import */ var _stack_at_rule__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stack-at-rule */ "./src/css/middlewares/stack-at-rule.ts");
|
|
2098
2243
|
/* harmony import */ var _inline_at_rule__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./inline-at-rule */ "./src/css/middlewares/inline-at-rule.ts");
|
|
2099
2244
|
/* harmony import */ var _center_at_rule__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./center-at-rule */ "./src/css/middlewares/center-at-rule.ts");
|
|
2100
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");
|
|
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
|
+
|
|
2249
|
+
|
|
2101
2250
|
|
|
2102
2251
|
|
|
2103
2252
|
|
|
@@ -2119,13 +2268,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2119
2268
|
/* harmony export */ });
|
|
2120
2269
|
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./factory */ "./src/css/middlewares/factory.ts");
|
|
2121
2270
|
|
|
2122
|
-
const createInlineAtRuleMiddleware = ({
|
|
2271
|
+
const createInlineAtRuleMiddleware = ({ spacing = 0, } = {}) => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2123
2272
|
name: 'inline',
|
|
2124
2273
|
transform: args => {
|
|
2125
2274
|
const declarations = ['display:flex;', 'align-items:center;'];
|
|
2126
|
-
if (args) {
|
|
2127
|
-
const isNumber = /^-?\d*\.?\d+$/.test(args);
|
|
2128
|
-
const gap = isNumber ? `${parseFloat(args) *
|
|
2275
|
+
if (args?.length) {
|
|
2276
|
+
const isNumber = /^-?\d*\.?\d+$/.test(args[0]);
|
|
2277
|
+
const gap = isNumber ? `${parseFloat(args[0]) * spacing}px` : args;
|
|
2129
2278
|
declarations.push(`gap:${gap};`);
|
|
2130
2279
|
}
|
|
2131
2280
|
return declarations.join('');
|
|
@@ -2149,7 +2298,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2149
2298
|
|
|
2150
2299
|
const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2151
2300
|
const KEBAB_CASE_SPACING_PROPERTIES = _constants__WEBPACK_IMPORTED_MODULE_0__.CSS_SPACING_PROPERTIES.map(toKebabCase);
|
|
2152
|
-
const createSpacingMiddleware = ({
|
|
2301
|
+
const createSpacingMiddleware = ({ spacing = 0 }) => element => {
|
|
2153
2302
|
if (element.type !== 'decl') {
|
|
2154
2303
|
return;
|
|
2155
2304
|
}
|
|
@@ -2165,7 +2314,7 @@ const createSpacingMiddleware = ({ spacingMultiplier = 0 }) => element => {
|
|
|
2165
2314
|
for (const value of parts) {
|
|
2166
2315
|
transformedParts.push(
|
|
2167
2316
|
// Accept only numeric strings (integers or floats), no units or symbols
|
|
2168
|
-
/^-?\d*\.?\d+$/.test(value) ? `${parseFloat(value) *
|
|
2317
|
+
/^-?\d*\.?\d+$/.test(value) ? `${parseFloat(value) * spacing}px` : value);
|
|
2169
2318
|
}
|
|
2170
2319
|
const transformed = transformedParts.join(' ');
|
|
2171
2320
|
element.return = `${element.props}:${transformed};`;
|
|
@@ -2187,13 +2336,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2187
2336
|
/* harmony export */ });
|
|
2188
2337
|
/* harmony import */ var _factory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./factory */ "./src/css/middlewares/factory.ts");
|
|
2189
2338
|
|
|
2190
|
-
const createStackAtRuleMiddleware = ({
|
|
2339
|
+
const createStackAtRuleMiddleware = ({ spacing = 0 }) => (0,_factory__WEBPACK_IMPORTED_MODULE_0__.createAtRuleMiddleware)({
|
|
2191
2340
|
name: 'stack',
|
|
2192
2341
|
transform: args => {
|
|
2193
2342
|
const declarations = ['display:flex;', 'flex-direction:column;'];
|
|
2194
|
-
if (args) {
|
|
2195
|
-
const isNumber = /^-?\d*\.?\d+$/.test(args);
|
|
2196
|
-
const gap = isNumber ? `${parseFloat(args) *
|
|
2343
|
+
if (args?.length) {
|
|
2344
|
+
const isNumber = /^-?\d*\.?\d+$/.test(args[0]);
|
|
2345
|
+
const gap = isNumber ? `${parseFloat(args[0]) * spacing}px` : args;
|
|
2197
2346
|
declarations.push(`gap:${gap};`);
|
|
2198
2347
|
}
|
|
2199
2348
|
return declarations.join('');
|
|
@@ -2201,6 +2350,63 @@ const createStackAtRuleMiddleware = ({ spacingMultiplier = 0, }) => (0,_factory_
|
|
|
2201
2350
|
});
|
|
2202
2351
|
|
|
2203
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
|
+
|
|
2204
2410
|
/***/ }),
|
|
2205
2411
|
|
|
2206
2412
|
/***/ "./src/css/processor.ts":
|
|
@@ -2213,23 +2419,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2213
2419
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2214
2420
|
/* harmony export */ processCss: () => (/* binding */ processCss)
|
|
2215
2421
|
/* harmony export */ });
|
|
2216
|
-
/* harmony import */ var
|
|
2217
|
-
/* harmony import */ var
|
|
2218
|
-
/* harmony import */ var
|
|
2219
|
-
/* 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
|
+
|
|
2220
2428
|
|
|
2221
2429
|
|
|
2222
|
-
const processCss = (rawCss, selector, {
|
|
2430
|
+
const processCss = (rawCss, selector, { spacing } = {}) => {
|
|
2223
2431
|
const scopedCss = selector ? `${selector}{${rawCss}}` : rawCss;
|
|
2224
|
-
const middlewares = [
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
stylis__WEBPACK_IMPORTED_MODULE_1__.stringify,
|
|
2231
|
-
];
|
|
2232
|
-
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));
|
|
2233
2438
|
};
|
|
2234
2439
|
|
|
2235
2440
|
|
|
@@ -2321,14 +2526,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2321
2526
|
/* harmony export */ });
|
|
2322
2527
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
2323
2528
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2324
|
-
/* 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");
|
|
2325
2530
|
/* harmony import */ var _contexts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../contexts */ "./src/contexts/index.ts");
|
|
2326
2531
|
|
|
2327
2532
|
|
|
2328
2533
|
|
|
2329
2534
|
const useHoneyStyle = () => {
|
|
2330
2535
|
const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_contexts__WEBPACK_IMPORTED_MODULE_2__.HoneyStyleContext);
|
|
2331
|
-
(0,
|
|
2536
|
+
(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, 'The `useHoneyStyle()` hook must be used inside <HoneyStyleProvider/> component!');
|
|
2332
2537
|
return context;
|
|
2333
2538
|
};
|
|
2334
2539
|
|
|
@@ -2489,11 +2694,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2489
2694
|
/* harmony export */ });
|
|
2490
2695
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
2491
2696
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2492
|
-
/* harmony import */ var
|
|
2493
|
-
/* harmony import */ var
|
|
2494
|
-
/* harmony import */ var
|
|
2495
|
-
/* harmony import */ var
|
|
2496
|
-
/* 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
|
+
|
|
2497
2704
|
|
|
2498
2705
|
|
|
2499
2706
|
|
|
@@ -2504,23 +2711,23 @@ const evaluateDynamicCss = (interpolation, context) => {
|
|
|
2504
2711
|
if (!interpolation) {
|
|
2505
2712
|
return '';
|
|
2506
2713
|
}
|
|
2507
|
-
if ((0,
|
|
2714
|
+
if ((0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isString)(interpolation)) {
|
|
2508
2715
|
return interpolation;
|
|
2509
2716
|
}
|
|
2510
2717
|
// @ts-expect-error
|
|
2511
|
-
return (0,
|
|
2718
|
+
return (0,_css__WEBPACK_IMPORTED_MODULE_4__.css)([''], [interpolation])(context);
|
|
2512
2719
|
};
|
|
2513
2720
|
const styled = (target, defaultProps) => {
|
|
2514
2721
|
return (strings, ...interpolations) => {
|
|
2515
|
-
const componentId = (0,
|
|
2516
|
-
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);
|
|
2517
2724
|
const StyledComponent = ({ as, className, __compositionDepth = 0, css: cssProp, ...props }) => {
|
|
2518
|
-
if (
|
|
2725
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_2__.__DEV__ && cssProp) {
|
|
2519
2726
|
console.warn(`[@react-hive/honey-style]: The "css" prop is deprecated. Please use inheritance or composition instead.`);
|
|
2520
2727
|
}
|
|
2521
|
-
const { theme } = (0,
|
|
2728
|
+
const { theme } = (0,_hooks__WEBPACK_IMPORTED_MODULE_6__.useHoneyStyle)();
|
|
2522
2729
|
const cleanedProps = Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
|
|
2523
|
-
const resolvedDefaultProps = (0,
|
|
2730
|
+
const resolvedDefaultProps = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(defaultProps)
|
|
2524
2731
|
? defaultProps({ theme, as, className, ...cleanedProps })
|
|
2525
2732
|
: (defaultProps ?? {});
|
|
2526
2733
|
const context = {
|
|
@@ -2529,47 +2736,47 @@ const styled = (target, defaultProps) => {
|
|
|
2529
2736
|
theme,
|
|
2530
2737
|
};
|
|
2531
2738
|
const rawCss = computeCss(context);
|
|
2532
|
-
const baseClassName = (0,
|
|
2739
|
+
const baseClassName = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveClassName)(rawCss);
|
|
2533
2740
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useInsertionEffect)(() => {
|
|
2534
|
-
const baseCss = (0,
|
|
2535
|
-
|
|
2741
|
+
const baseCss = (0,_css__WEBPACK_IMPORTED_MODULE_4__.processCss)(rawCss, `.${baseClassName}`, {
|
|
2742
|
+
spacing: theme.spacings.base,
|
|
2536
2743
|
});
|
|
2537
|
-
return (0,
|
|
2744
|
+
return (0,_mount_style__WEBPACK_IMPORTED_MODULE_5__.mountStyle)(baseClassName, baseCss, __compositionDepth);
|
|
2538
2745
|
}, [baseClassName]);
|
|
2539
|
-
const cssPropRaw = (0,
|
|
2746
|
+
const cssPropRaw = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(cssProp) ? cssProp(context) : cssProp;
|
|
2540
2747
|
const cssPropString = evaluateDynamicCss(cssPropRaw, context);
|
|
2541
|
-
const cssPropClassName = cssPropString ? (0,
|
|
2748
|
+
const cssPropClassName = cssPropString ? (0,_utils__WEBPACK_IMPORTED_MODULE_3__.resolveClassName)(cssPropString) : '';
|
|
2542
2749
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useInsertionEffect)(() => {
|
|
2543
2750
|
if (cssPropClassName) {
|
|
2544
|
-
const overrideCss = (0,
|
|
2545
|
-
|
|
2751
|
+
const overrideCss = (0,_css__WEBPACK_IMPORTED_MODULE_4__.processCss)(cssPropString, `.${cssPropClassName}`, {
|
|
2752
|
+
spacing: theme.spacings.base,
|
|
2546
2753
|
});
|
|
2547
|
-
return (0,
|
|
2754
|
+
return (0,_mount_style__WEBPACK_IMPORTED_MODULE_5__.mountStyle)(cssPropClassName, overrideCss, 1);
|
|
2548
2755
|
}
|
|
2549
2756
|
}, [cssPropClassName]);
|
|
2550
2757
|
const mergedProps = {
|
|
2551
2758
|
...resolvedDefaultProps,
|
|
2552
2759
|
...cleanedProps,
|
|
2553
|
-
className: (0,
|
|
2760
|
+
className: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.combineClassNames)([componentId, baseClassName, className, cssPropClassName]),
|
|
2554
2761
|
};
|
|
2555
2762
|
const finalComponent = as || target;
|
|
2556
|
-
if ((0,
|
|
2557
|
-
const filteredProps = (0,
|
|
2558
|
-
? (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)
|
|
2559
2766
|
: mergedProps;
|
|
2560
2767
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(finalComponent, filteredProps);
|
|
2561
2768
|
}
|
|
2562
2769
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(target, {
|
|
2563
2770
|
...mergedProps,
|
|
2564
2771
|
...(as && { as }),
|
|
2565
|
-
...((0,
|
|
2772
|
+
...((0,_utils__WEBPACK_IMPORTED_MODULE_3__.isStyledComponent)(target) && {
|
|
2566
2773
|
__compositionDepth: __compositionDepth - 1,
|
|
2567
2774
|
}),
|
|
2568
2775
|
});
|
|
2569
2776
|
};
|
|
2570
|
-
StyledComponent[
|
|
2571
|
-
if (
|
|
2572
|
-
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)
|
|
2573
2780
|
? target
|
|
2574
2781
|
: target.displayName || target.name || 'Component';
|
|
2575
2782
|
StyledComponent.displayName = `HoneyStyledComponent(${componentName})`;
|
|
@@ -2629,100 +2836,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2629
2836
|
|
|
2630
2837
|
__webpack_require__.r(__webpack_exports__);
|
|
2631
2838
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2632
|
-
/* harmony export */ assert: () => (/* binding */ assert),
|
|
2633
|
-
/* harmony export */ boolFilter: () => (/* binding */ boolFilter),
|
|
2634
2839
|
/* harmony export */ checkIsThemeColorValue: () => (/* binding */ checkIsThemeColorValue),
|
|
2635
2840
|
/* harmony export */ combineClassNames: () => (/* binding */ combineClassNames),
|
|
2636
2841
|
/* harmony export */ convertHexToHexWithAlpha: () => (/* binding */ convertHexToHexWithAlpha),
|
|
2637
2842
|
/* harmony export */ filterNonHtmlAttrs: () => (/* binding */ filterNonHtmlAttrs),
|
|
2638
2843
|
/* harmony export */ generateId: () => (/* binding */ generateId),
|
|
2639
|
-
/* harmony export */ isFunction: () => (/* binding */ isFunction),
|
|
2640
|
-
/* harmony export */ isNil: () => (/* binding */ isNil),
|
|
2641
|
-
/* harmony export */ isObject: () => (/* binding */ isObject),
|
|
2642
|
-
/* harmony export */ isString: () => (/* binding */ isString),
|
|
2643
2844
|
/* harmony export */ isStyledComponent: () => (/* binding */ isStyledComponent),
|
|
2644
2845
|
/* harmony export */ pxToRem: () => (/* binding */ pxToRem),
|
|
2645
2846
|
/* harmony export */ resolveClassName: () => (/* binding */ resolveClassName),
|
|
2646
2847
|
/* harmony export */ resolveColor: () => (/* binding */ resolveColor),
|
|
2647
2848
|
/* harmony export */ resolveDimension: () => (/* binding */ resolveDimension),
|
|
2648
2849
|
/* harmony export */ resolveFont: () => (/* binding */ resolveFont),
|
|
2649
|
-
/* harmony export */ resolveSpacing: () => (/* binding */ resolveSpacing)
|
|
2650
|
-
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
2850
|
+
/* harmony export */ resolveSpacing: () => (/* binding */ resolveSpacing)
|
|
2651
2851
|
/* harmony export */ });
|
|
2652
|
-
/* harmony import */ var
|
|
2653
|
-
/* 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
|
+
|
|
2654
2856
|
|
|
2655
2857
|
|
|
2656
|
-
function assert(condition, message) {
|
|
2657
|
-
if (!condition) {
|
|
2658
|
-
throw new Error(message);
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
2858
|
const generateId = (prefix) => `${prefix}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2662
|
-
const toKebabCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2663
|
-
const isString = (value) => typeof value === 'string';
|
|
2664
|
-
const isObject = (value) => typeof value === 'object';
|
|
2665
|
-
const isFunction = (value) => typeof value === 'function';
|
|
2666
|
-
/**
|
|
2667
|
-
* Checks if a value is null or undefined.
|
|
2668
|
-
*
|
|
2669
|
-
* @param value - The value to check.
|
|
2670
|
-
*
|
|
2671
|
-
* @returns `true` if the value is `null` or `undefined`, otherwise `false`.
|
|
2672
|
-
*/
|
|
2673
|
-
const isNil = (value) => value === undefined || value === null;
|
|
2674
|
-
/**
|
|
2675
|
-
* Filters out `null`, `undefined`, and other falsy values from an array,
|
|
2676
|
-
* returning a typed array of only truthy `Item` values.
|
|
2677
|
-
*
|
|
2678
|
-
* Useful when working with optional or nullable items that need to be sanitized.
|
|
2679
|
-
*
|
|
2680
|
-
* @template T - The type of the items in the array.
|
|
2681
|
-
*
|
|
2682
|
-
* @param array - An array of items that may include `null`, `undefined`, or falsy values.
|
|
2683
|
-
*
|
|
2684
|
-
* @returns A new array containing only truthy `Item` values.
|
|
2685
|
-
*/
|
|
2686
|
-
const boolFilter = (array) => array.filter(Boolean);
|
|
2687
|
-
/**
|
|
2688
|
-
* Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
|
|
2689
|
-
*
|
|
2690
|
-
* This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
|
|
2691
|
-
* based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
|
|
2692
|
-
* which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
|
|
2693
|
-
*
|
|
2694
|
-
* Useful for:
|
|
2695
|
-
* - Generating stable class names in CSS-in-JS libraries.
|
|
2696
|
-
* - Producing consistent cache keys.
|
|
2697
|
-
* - Quick and lightweight hashing needs where cryptographic security is not required.
|
|
2698
|
-
*
|
|
2699
|
-
* ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
|
|
2700
|
-
*
|
|
2701
|
-
* @param str - The input string to hash.
|
|
2702
|
-
*
|
|
2703
|
-
* @returns A short, base-36 encoded hash string.
|
|
2704
|
-
*
|
|
2705
|
-
* @example
|
|
2706
|
-
* ```ts
|
|
2707
|
-
* const className = hashString('background-color: red;');
|
|
2708
|
-
* // → 'e4k1z0x'
|
|
2709
|
-
* ```
|
|
2710
|
-
*/
|
|
2711
|
-
const hashString = (str) => {
|
|
2712
|
-
let hash = 5381;
|
|
2713
|
-
for (let i = 0; i < str.length; i++) {
|
|
2714
|
-
hash = (hash * 33) ^ str.charCodeAt(i);
|
|
2715
|
-
}
|
|
2716
|
-
return (hash >>> 0).toString(36);
|
|
2717
|
-
};
|
|
2718
2859
|
/**
|
|
2719
2860
|
* Combines multiple class names into a single space-separated string
|
|
2720
2861
|
*
|
|
2721
2862
|
* @param classNames - Array of class names to combine
|
|
2722
2863
|
*/
|
|
2723
2864
|
const combineClassNames = (classNames) => classNames.filter(Boolean).join(' ').trim();
|
|
2724
|
-
const resolveClassName = (css) => `hscn-${hashString(css)}`;
|
|
2725
|
-
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;
|
|
2726
2867
|
/**
|
|
2727
2868
|
* Filters out non-standard HTML attributes from a props object intended for a native HTML element.
|
|
2728
2869
|
*
|
|
@@ -2741,7 +2882,7 @@ const isStyledComponent = (component) => _constants__WEBPACK_IMPORTED_MODULE_0__
|
|
|
2741
2882
|
* @returns A new object containing only props that are safe and valid for use on native DOM elements.
|
|
2742
2883
|
*/
|
|
2743
2884
|
const filterNonHtmlAttrs = (attrs) => Object.entries(attrs).reduce((allowedAttrs, [name, value]) => {
|
|
2744
|
-
if (
|
|
2885
|
+
if (_constants__WEBPACK_IMPORTED_MODULE_1__.VALID_DOM_ELEMENT_ATTRS.has(name) || name.startsWith('data-') || name.startsWith('aria-')) {
|
|
2745
2886
|
allowedAttrs[name] = value;
|
|
2746
2887
|
}
|
|
2747
2888
|
return allowedAttrs;
|
|
@@ -2814,7 +2955,7 @@ const resolveSpacing = (value, unit = 'px', type = 'base') => ({ theme }) => {
|
|
|
2814
2955
|
*/
|
|
2815
2956
|
const resolveFont = (fontName) => ({ theme }) => {
|
|
2816
2957
|
const font = theme.fonts[fontName];
|
|
2817
|
-
return (0,
|
|
2958
|
+
return (0,_css__WEBPACK_IMPORTED_MODULE_2__.css) `
|
|
2818
2959
|
font-family: ${font.family};
|
|
2819
2960
|
font-size: ${pxToRem(font.size)};
|
|
2820
2961
|
font-weight: ${font.weight};
|
|
@@ -2987,13 +3128,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2987
3128
|
/* harmony export */ HoneyStyleProvider: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_2__.HoneyStyleProvider),
|
|
2988
3129
|
/* harmony export */ VALID_DOM_ELEMENT_ATTRS: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_0__.VALID_DOM_ELEMENT_ATTRS),
|
|
2989
3130
|
/* harmony export */ __DEV__: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_0__.__DEV__),
|
|
2990
|
-
/* harmony export */ assert: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.assert),
|
|
2991
|
-
/* harmony export */ boolFilter: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.boolFilter),
|
|
2992
3131
|
/* harmony export */ checkIsThemeColorValue: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.checkIsThemeColorValue),
|
|
2993
3132
|
/* harmony export */ combineClassNames: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.combineClassNames),
|
|
2994
3133
|
/* harmony export */ convertHexToHexWithAlpha: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.convertHexToHexWithAlpha),
|
|
2995
3134
|
/* harmony export */ createAbsoluteFillAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createAbsoluteFillAtRuleMiddleware),
|
|
2996
3135
|
/* harmony export */ createCenterAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createCenterAtRuleMiddleware),
|
|
3136
|
+
/* harmony export */ createEllipsisAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createEllipsisAtRuleMiddleware),
|
|
2997
3137
|
/* harmony export */ createGlobalStyle: () => (/* reexport safe */ _global_style__WEBPACK_IMPORTED_MODULE_6__.createGlobalStyle),
|
|
2998
3138
|
/* harmony export */ createInlineAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createInlineAtRuleMiddleware),
|
|
2999
3139
|
/* harmony export */ createSpacingMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.createSpacingMiddleware),
|
|
@@ -3001,10 +3141,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3001
3141
|
/* harmony export */ css: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.css),
|
|
3002
3142
|
/* harmony export */ filterNonHtmlAttrs: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.filterNonHtmlAttrs),
|
|
3003
3143
|
/* harmony export */ generateId: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.generateId),
|
|
3004
|
-
/* harmony export */ isFunction: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isFunction),
|
|
3005
|
-
/* harmony export */ isNil: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isNil),
|
|
3006
|
-
/* harmony export */ isObject: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isObject),
|
|
3007
|
-
/* harmony export */ isString: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isString),
|
|
3008
3144
|
/* harmony export */ isStyledComponent: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.isStyledComponent),
|
|
3009
3145
|
/* harmony export */ mediaQuery: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.mediaQuery),
|
|
3010
3146
|
/* harmony export */ processCss: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.processCss),
|
|
@@ -3015,7 +3151,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3015
3151
|
/* harmony export */ resolveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.resolveFont),
|
|
3016
3152
|
/* harmony export */ resolveSpacing: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_8__.resolveSpacing),
|
|
3017
3153
|
/* harmony export */ styled: () => (/* reexport safe */ _styled__WEBPACK_IMPORTED_MODULE_7__.styled),
|
|
3018
|
-
/* harmony export */
|
|
3154
|
+
/* harmony export */ suggestAtRuleMiddleware: () => (/* reexport safe */ _css__WEBPACK_IMPORTED_MODULE_5__.suggestAtRuleMiddleware),
|
|
3019
3155
|
/* harmony export */ useHoneyStyle: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_3__.useHoneyStyle)
|
|
3020
3156
|
/* harmony export */ });
|
|
3021
3157
|
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|