@react-hive/honey-style 1.11.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contexts/HoneyStyleContext.d.ts +2 -1
- package/dist/css/constants.d.ts +3 -0
- package/dist/{css.d.ts → css/css.d.ts} +1 -1
- package/dist/css/index.d.ts +6 -0
- package/dist/css/middlewares.d.ts +9 -0
- package/dist/css/processor.d.ts +8 -0
- package/dist/{types/css.types.d.ts → css/types.d.ts} +16 -0
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.dev.cjs +574 -141
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/styled.d.ts +2 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/{types.d.ts → theme.d.ts} +1 -1
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
- /package/dist/{at-rules → css/at-rules}/index.d.ts +0 -0
- /package/dist/{at-rules → css/at-rules}/media-query.d.ts +0 -0
- /package/dist/types/{utility.types.d.ts → utility.d.ts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HoneyCSSColor, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSSpacingValue } from '../css';
|
|
2
|
+
import type { Nullable, HoneyTheme, HoneyColorKey, HoneyDimensionName, HoneyFontName, HoneySpacings, HoneyStyledInterpolation } from '../types';
|
|
2
3
|
import type { HoneyResolveSpacingResult } from '../utils';
|
|
3
4
|
export interface HoneyStyleContextValue {
|
|
4
5
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { HoneyStyledInterpolation, HoneyStyledContext } from '
|
|
1
|
+
import type { HoneyStyledInterpolation, HoneyStyledContext } from '../types';
|
|
2
2
|
export declare const css: <Props extends object>(strings: TemplateStringsArray, ...interpolations: HoneyStyledInterpolation<Props>[]) => (context: HoneyStyledContext<Props>) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Middleware } from 'stylis';
|
|
2
|
+
interface SpacingMiddlewareOptions {
|
|
3
|
+
/**
|
|
4
|
+
* @default 0
|
|
5
|
+
*/
|
|
6
|
+
spacingMultiplier?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const createSpacingMiddleware: ({ spacingMultiplier }: SpacingMiddlewareOptions) => Middleware;
|
|
9
|
+
export {};
|
|
@@ -112,4 +112,20 @@ export type HoneyCSSMultiValue<T> = T | HoneyCSSShorthandTuple<T>;
|
|
|
112
112
|
* Commonly used for properties like `margin`, `padding`, `gap`, etc.
|
|
113
113
|
*/
|
|
114
114
|
export type HoneyCSSSpacingValue = HoneyCSSMultiValue<number | HoneyCSSDimensionValue>;
|
|
115
|
+
export type HoneyRawCSSSpacingValue = number | HoneyCSSDimensionValue | CSS.Globals;
|
|
116
|
+
/**
|
|
117
|
+
* Represents CSS properties related to spacing and positioning.
|
|
118
|
+
*/
|
|
119
|
+
export type HoneyCSSSpacingProperty = keyof Pick<CSS.Properties, 'margin' | 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'padding' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'top' | 'right' | 'bottom' | 'left' | 'gap' | 'rowGap' | 'columnGap'>;
|
|
120
|
+
/**
|
|
121
|
+
* Represents shorthand spacing properties that support multi-value arrays.
|
|
122
|
+
*
|
|
123
|
+
* These properties accept 2–4 space-separated values
|
|
124
|
+
* to control spacing on multiple sides (e.g., top, right, bottom, left).
|
|
125
|
+
*/
|
|
126
|
+
export type HoneyCSSShorthandSpacingProperty = keyof Pick<CSS.Properties, 'margin' | 'padding' | 'gap'>;
|
|
127
|
+
/**
|
|
128
|
+
* Represents a subset of CSS properties that define color-related styles.
|
|
129
|
+
*/
|
|
130
|
+
export type HoneyCSSColorProperty = keyof Pick<CSS.Properties, 'color' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'outlineColor' | 'textDecorationColor' | 'fill' | 'stroke'>;
|
|
115
131
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! For license information please see index.cjs.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e={698:(e,t)=>{var n=Symbol.for("react.transitional.element");Symbol.for("react.fragment"),t.jsx=function(e,t,o){var r=null;if(void 0!==o&&(r=""+o),void 0!==t.key&&(r=""+t.key),"key"in t)for(var a in o={},t)"key"!==a&&(o[a]=t[a]);else o=t;return t=o.ref,{$$typeof:n,type:e,key:r,ref:void 0!==t?t:null,props:o}}},848:(e,t,n)=>{e.exports=n(698)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{HONEY_BREAKPOINTS:()=>c,HONEY_GLOBAL_STYLE_ATTR:()=>i,HONEY_STYLED_COMPONENT_ID_PROP:()=>a,HONEY_STYLE_ATTR:()=>s,HoneyStyleContext:()=>p,HoneyStyleProvider:()=>xe,VALID_DOM_ELEMENT_ATTRS:()=>m,__DEV__:()=>r,assert:()=>oe,boolFilter:()=>ue,checkIsThemeColorValue:()=>ge,combineClassNames:()=>de,convertHexToHexWithAlpha:()=>be,createGlobalStyle:()=>Ee,css:()=>ne,filterNonHtmlAttrs:()=>pe,generateId:()=>re,isFunction:()=>ce,isNil:()=>le,isObject:()=>se,isString:()=>ie,isStyledComponent:()=>me,mediaQuery:()=>Ae,processCss:()=>fe,pxToRem:()=>ye,resolveClassName:()=>he,resolveColor:()=>Ce,resolveDimension:()=>we,resolveFont:()=>Se,resolveSpacing:()=>ve,styled:()=>Me,toKebabCase:()=>ae,useHoneyStyle:()=>ke});const r=!1;r&&"undefined"!=typeof window&&!process.env.JEST_WORKER_ID&&console.info("[@react-hive/honey-style]: You are running in development mode. This build is not optimized for production and may include extra checks or logs.");const a="$$ComponentId",i="data-honey-global-style",s="data-honey-style",c=["xs","sm","md","lg","xl"],l=new Set(["accept","accessKey","autoCapitalize","autoComplete","autoFocus","capture","class","className","contentEditable","contextMenu","dir","draggable","hidden","id","inert","inputMode","is","lang","nonce","part","slot","spellCheck","style","tabIndex","title","translate","unselectable","checked","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","list","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","size","step","type","value","alt","controls","crossOrigin","height","isMap","loop","media","muted","poster","preload","role","src","srcSet","useMap","width","download","href","hrefLang","referrerPolicy","rel","target","dangerouslySetInnerHTML","key","ref","children","char","charOff","exportparts","popover","popoverTarget","popoverTargetAction","virtualkeyboardpolicy","writingsuggestions"]),u=new Set(["colSpan","rowSpan","headers","abbr","scope","align","valign"]),d=new Set(["viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeOpacity","fillOpacity","opacity","pointerEvents","focusable","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","d","points","height","transform","xmlns","preserveAspectRatio","mask","clipPath","pathLength","markerStart","markerMid","markerEnd","refX","refY","dominantBaseline","textAnchor"]),h=new Set(["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onFocus","onBlur","onChange","onInput","onInvalid","onReset","onSubmit","onKeyDown","onKeyPress","onKeyUp","onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onGotPointerCapture","onLostPointerCapture","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onScroll","onWheel","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onLoad","onError","onTransitionEnd","onTransitionStart","onTransitionRun","onTransitionCancel","onAnimationStart","onAnimationEnd","onAnimationIteration","onAnimationCancel"]),m=new Set([...l,...u,...d,...h]),f=require("react"),p=(0,f.createContext)(void 0);var y=n(848),g="comm",v="rule",S="decl",b=Math.abs,C=String.fromCharCode;function w(e){return e.trim()}function x(e,t,n){return e.replace(t,n)}function k(e,t,n){return e.indexOf(t,n)}function E(e,t){return 0|e.charCodeAt(t)}function T(e,t,n){return e.slice(t,n)}function $(e){return e.length}function O(e,t){return t.push(e),e}function P(e,t){for(var n="",o=0;o<e.length;o++)n+=t(e[o],o,e,t)||"";return n}function _(e,t,n,o){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case S:return e.return=e.return||e.value;case g:return"";case"@keyframes":return e.return=e.value+"{"+P(e.children,o)+"}";case v:if(!$(e.value=e.props.join(",")))return""}return $(n=P(e.children,o))?e.return=e.value+"{"+n+"}":""}Object.assign;var M=1,A=1,D=0,L=0,j=0,H="";function N(e,t,n,o,r,a,i,s){return{value:e,root:t,parent:n,type:o,props:r,children:a,line:M,column:A,length:i,return:"",siblings:s}}function R(){return j=L>0?E(H,--L):0,A--,10===j&&(A=1,M--),j}function I(){return j=L<D?E(H,L++):0,A++,10===j&&(A=1,M++),j}function W(){return E(H,L)}function Y(){return L}function B(e,t){return T(H,e,t)}function F(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function K(e){return w(B(L-1,V(91===e?e+2:40===e?e+1:e)))}function z(e){for(;(j=W())&&j<33;)I();return F(e)>2||F(j)>3?"":" "}function U(e,t){for(;--t&&I()&&!(j<48||j>102||j>57&&j<65||j>70&&j<97););return B(e,Y()+(t<6&&32==W()&&32==I()))}function V(e){for(;I();)switch(j){case e:return L;case 34:case 39:34!==e&&39!==e&&V(j);break;case 40:41===e&&V(e);break;case 92:I()}return L}function q(e,t){for(;I()&&e+j!==57&&(e+j!==84||47!==W()););return"/*"+B(t,L-1)+"*"+C(47===e?e:I())}function G(e){for(;!F(W());)I();return B(e,L)}function J(e){return function(e){return H="",e}(Q("",null,null,null,[""],e=function(e){return M=A=1,D=$(H=e),L=0,[]}(e),0,[0],e))}function Q(e,t,n,o,r,a,i,s,c){for(var l=0,u=0,d=i,h=0,m=0,f=0,p=1,y=1,g=1,v=0,S="",w=r,P=a,_=o,M=S;y;)switch(f=v,v=I()){case 40:if(108!=f&&58==E(M,d-1)){-1!=k(M+=x(K(v),"&","&\f"),"&\f",b(l?s[l-1]:0))&&(g=-1);break}case 34:case 39:case 91:M+=K(v);break;case 9:case 10:case 13:case 32:M+=z(f);break;case 92:M+=U(Y()-1,7);continue;case 47:switch(W()){case 42:case 47:O(Z(q(I(),Y()),t,n,c),c),5!=F(f||1)&&5!=F(W()||1)||!$(M)||" "===T(M,-1,void 0)||(M+=" ");break;default:M+="/"}break;case 123*p:s[l++]=$(M)*g;case 125*p:case 59:case 0:switch(v){case 0:case 125:y=0;case 59+u:-1==g&&(M=x(M,/\f/g,"")),m>0&&($(M)-d||0===p&&47===f)&&O(m>32?ee(M+";",o,n,d-1,c):ee(x(M," ","")+";",o,n,d-2,c),c);break;case 59:M+=";";default:if(O(_=X(M,t,n,l,u,r,s,S,w=[],P=[],d,a),a),123===v)if(0===u)Q(M,t,_,_,w,a,d,s,P);else{switch(h){case 99:if(110===E(M,3))break;case 108:if(97===E(M,2))break;default:u=0;case 100:case 109:case 115:}u?Q(e,_,_,o&&O(X(e,_,_,0,0,r,s,S,r,w=[],d,P),P),r,P,d,s,o?w:P):Q(M,_,_,_,[""],P,0,s,P)}}l=u=m=0,p=g=1,S=M="",d=i;break;case 58:d=1+$(M),m=f;default:if(p<1)if(123==v)--p;else if(125==v&&0==p++&&125==R())continue;switch(M+=C(v),v*p){case 38:g=u>0?1:(M+="\f",-1);break;case 44:s[l++]=($(M)-1)*g,g=1;break;case 64:45===W()&&(M+=K(I())),h=W(),u=d=$(S=M+=G(Y())),v++;break;case 45:45===f&&2==$(M)&&(p=0)}}return a}function X(e,t,n,o,r,a,i,s,c,l,u,d){for(var h=r-1,m=0===r?a:[""],f=function(e){return e.length}(m),p=0,y=0,g=0;p<o;++p)for(var S=0,C=T(e,h+1,h=b(y=i[p])),k=e;S<f;++S)(k=w(y>0?m[S]+" "+C:x(C,/&\f/g,m[S])))&&(c[g++]=k);return N(e,t,n,0===r?v:s,c,l,u,d)}function Z(e,t,n,o){return N(e,t,n,g,C(j),T(e,2,-2),0,o)}function ee(e,t,n,o,r){return N(e,t,n,S,T(e,0,o),T(e,o+1,-1),o,r)}const te=(e,t)=>""===e||!1===e||le(e)?"":ce(e)?me(e)?`.${e[a]}`:te(e(t),t):Array.isArray(e)?e.map(e=>te(e,t)).join("\n"):se(e)?Object.entries(e).filter(([,e])=>void 0!==e&&!1!==e).map(([e,t])=>`${ae(e)}: ${t};`).join("\n"):e.toString?.()??"",ne=(e,...t)=>n=>e.reduce((e,o,r)=>e+o+te(t[r],n),"");function oe(e,t){if(!e)throw new Error(t)}const re=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,ae=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ie=e=>"string"==typeof e,se=e=>"object"==typeof e,ce=e=>"function"==typeof e,le=e=>null==e,ue=e=>e.filter(Boolean),de=e=>e.filter(Boolean).join(" ").trim(),he=e=>`hscn-${(e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)})(e)}`,me=e=>a in e,fe=(e,t)=>P(J(t?`${t}{${e}}`:e),_),pe=e=>Object.entries(e).reduce((e,[t,n])=>((m.has(t)||t.startsWith("data-")||t.startsWith("aria-"))&&(e[t]=n),e),{}),ye=(e,t=16)=>e/t+"rem",ge=e=>2===e.split(".").length,ve=(e,t="px",n="base")=>({theme:o})=>{if("string"==typeof e)return e;const r=o.spacings[n]??0;if("number"==typeof e){const n=e*r;return t?`${n}${t}`:n}return e.map(e=>{if("string"==typeof e)return e;const n=e*r;return t?`${n}${t}`:n}).join(" ")},Se=e=>({theme:t})=>{const n=t.fonts[e];return ne`
|
|
2
|
+
(()=>{"use strict";var e={698:(e,t)=>{var n=Symbol.for("react.transitional.element");Symbol.for("react.fragment"),t.jsx=function(e,t,o){var r=null;if(void 0!==o&&(r=""+o),void 0!==t.key&&(r=""+t.key),"key"in t)for(var a in o={},t)"key"!==a&&(o[a]=t[a]);else o=t;return t=o.ref,{$$typeof:n,type:e,key:r,ref:void 0!==t?t:null,props:o}}},848:(e,t,n)=>{e.exports=n(698)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{CSS_COLOR_PROPERTIES:()=>v,CSS_SPACING_PROPERTIES:()=>y,HONEY_BREAKPOINTS:()=>c,HONEY_GLOBAL_STYLE_ATTR:()=>i,HONEY_STYLED_COMPONENT_ID_PROP:()=>a,HONEY_STYLE_ATTR:()=>s,HoneyStyleContext:()=>f,HoneyStyleProvider:()=>Me,VALID_DOM_ELEMENT_ATTRS:()=>m,__DEV__:()=>r,assert:()=>ue,boolFilter:()=>ye,checkIsThemeColorValue:()=>xe,combineClassNames:()=>ve,convertHexToHexWithAlpha:()=>Te,createGlobalStyle:()=>_e,createSpacingMiddleware:()=>S,css:()=>ce,filterNonHtmlAttrs:()=>Ce,generateId:()=>pe,isFunction:()=>fe,isNil:()=>ge,isObject:()=>he,isString:()=>me,isStyledComponent:()=>Se,mediaQuery:()=>le,processCss:()=>ie,pxToRem:()=>we,resolveClassName:()=>be,resolveColor:()=>$e,resolveDimension:()=>Oe,resolveFont:()=>ke,resolveSpacing:()=>Ee,styled:()=>He,toKebabCase:()=>de,useHoneyStyle:()=>Pe});const r=!1;r&&"undefined"!=typeof window&&!process.env.JEST_WORKER_ID&&console.info("[@react-hive/honey-style]: You are running in development mode. This build is not optimized for production and may include extra checks or logs.");const a="$$ComponentId",i="data-honey-global-style",s="data-honey-style",c=["xs","sm","md","lg","xl"],l=new Set(["accept","accessKey","autoCapitalize","autoComplete","autoFocus","capture","class","className","contentEditable","contextMenu","dir","draggable","hidden","id","inert","inputMode","is","lang","nonce","part","slot","spellCheck","style","tabIndex","title","translate","unselectable","checked","disabled","form","formAction","formEncType","formMethod","formNoValidate","formTarget","list","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","size","step","type","value","alt","controls","crossOrigin","height","isMap","loop","media","muted","poster","preload","role","src","srcSet","useMap","width","download","href","hrefLang","referrerPolicy","rel","target","dangerouslySetInnerHTML","key","ref","children","char","charOff","exportparts","popover","popoverTarget","popoverTargetAction","virtualkeyboardpolicy","writingsuggestions"]),u=new Set(["colSpan","rowSpan","headers","abbr","scope","align","valign"]),p=new Set(["viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeOpacity","fillOpacity","opacity","pointerEvents","focusable","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","d","points","height","transform","xmlns","preserveAspectRatio","mask","clipPath","pathLength","markerStart","markerMid","markerEnd","refX","refY","dominantBaseline","textAnchor"]),d=new Set(["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onFocus","onBlur","onChange","onInput","onInvalid","onReset","onSubmit","onKeyDown","onKeyPress","onKeyUp","onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onGotPointerCapture","onLostPointerCapture","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onScroll","onWheel","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onLoad","onError","onTransitionEnd","onTransitionStart","onTransitionRun","onTransitionCancel","onAnimationStart","onAnimationEnd","onAnimationIteration","onAnimationCancel"]),m=new Set([...l,...u,...p,...d]),h=require("react"),f=(0,h.createContext)(void 0);var g=n(848);const y=["margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","top","right","bottom","left","gap","rowGap","columnGap"],v=["color","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor","textDecorationColor","fill","stroke"],b=y.map(e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),S=({spacingMultiplier:e})=>t=>{if(e&&"decl"===t.type&&"string"==typeof t.props&&b.includes(t.props)&&"string"==typeof t.children){const n=t.children.split(/\s+/).map(t=>/[a-z%]+$/i.test(t)?t:parseFloat(t)*e+"px").join(" ");t.return=`${t.props}:${n};`}};var C="comm",w="rule",x="decl",E=Math.abs,k=String.fromCharCode;function T(e){return e.trim()}function $(e,t,n){return e.replace(t,n)}function O(e,t,n){return e.indexOf(t,n)}function M(e,t){return 0|e.charCodeAt(t)}function P(e,t,n){return e.slice(t,n)}function _(e){return e.length}function A(e){return e.length}function L(e,t){return t.push(e),e}function D(e,t){for(var n="",o=0;o<e.length;o++)n+=t(e[o],o,e,t)||"";return n}function R(e,t,n,o){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case x:return e.return=e.return||e.value;case C:return"";case"@keyframes":return e.return=e.value+"{"+D(e.children,o)+"}";case w:if(!_(e.value=e.props.join(",")))return""}return _(n=D(e.children,o))?e.return=e.value+"{"+n+"}":""}Object.assign;var j=1,H=1,N=0,I=0,B=0,W="";function F(e,t,n,o,r,a,i,s){return{value:e,root:t,parent:n,type:o,props:r,children:a,line:j,column:H,length:i,return:"",siblings:s}}function Y(){return B=I>0?M(W,--I):0,H--,10===B&&(H=1,j--),B}function z(){return B=I<N?M(W,I++):0,H++,10===B&&(H=1,j++),B}function K(){return M(W,I)}function G(){return I}function U(e,t){return P(W,e,t)}function V(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function q(e){return T(U(I-1,Q(91===e?e+2:40===e?e+1:e)))}function Z(e){for(;(B=K())&&B<33;)z();return V(e)>2||V(B)>3?"":" "}function J(e,t){for(;--t&&z()&&!(B<48||B>102||B>57&&B<65||B>70&&B<97););return U(e,G()+(t<6&&32==K()&&32==z()))}function Q(e){for(;z();)switch(B){case e:return I;case 34:case 39:34!==e&&39!==e&&Q(B);break;case 40:41===e&&Q(e);break;case 92:z()}return I}function X(e,t){for(;z()&&e+B!==57&&(e+B!==84||47!==K()););return"/*"+U(t,I-1)+"*"+k(47===e?e:z())}function ee(e){for(;!V(K());)z();return U(e,I)}function te(e){return function(e){return W="",e}(ne("",null,null,null,[""],e=function(e){return j=H=1,N=_(W=e),I=0,[]}(e),0,[0],e))}function ne(e,t,n,o,r,a,i,s,c){for(var l=0,u=0,p=i,d=0,m=0,h=0,f=1,g=1,y=1,v=0,b="",S=r,C=a,w=o,x=b;g;)switch(h=v,v=z()){case 40:if(108!=h&&58==M(x,p-1)){-1!=O(x+=$(q(v),"&","&\f"),"&\f",E(l?s[l-1]:0))&&(y=-1);break}case 34:case 39:case 91:x+=q(v);break;case 9:case 10:case 13:case 32:x+=Z(h);break;case 92:x+=J(G()-1,7);continue;case 47:switch(K()){case 42:case 47:L(re(X(z(),G()),t,n,c),c),5!=V(h||1)&&5!=V(K()||1)||!_(x)||" "===P(x,-1,void 0)||(x+=" ");break;default:x+="/"}break;case 123*f:s[l++]=_(x)*y;case 125*f:case 59:case 0:switch(v){case 0:case 125:g=0;case 59+u:-1==y&&(x=$(x,/\f/g,"")),m>0&&(_(x)-p||0===f&&47===h)&&L(m>32?ae(x+";",o,n,p-1,c):ae($(x," ","")+";",o,n,p-2,c),c);break;case 59:x+=";";default:if(L(w=oe(x,t,n,l,u,r,s,b,S=[],C=[],p,a),a),123===v)if(0===u)ne(x,t,w,w,S,a,p,s,C);else{switch(d){case 99:if(110===M(x,3))break;case 108:if(97===M(x,2))break;default:u=0;case 100:case 109:case 115:}u?ne(e,w,w,o&&L(oe(e,w,w,0,0,r,s,b,r,S=[],p,C),C),r,C,p,s,o?S:C):ne(x,w,w,w,[""],C,0,s,C)}}l=u=m=0,f=y=1,b=x="",p=i;break;case 58:p=1+_(x),m=h;default:if(f<1)if(123==v)--f;else if(125==v&&0==f++&&125==Y())continue;switch(x+=k(v),v*f){case 38:y=u>0?1:(x+="\f",-1);break;case 44:s[l++]=(_(x)-1)*y,y=1;break;case 64:45===K()&&(x+=q(z())),d=K(),u=p=_(b=x+=ee(G())),v++;break;case 45:45===h&&2==_(x)&&(f=0)}}return a}function oe(e,t,n,o,r,a,i,s,c,l,u,p){for(var d=r-1,m=0===r?a:[""],h=A(m),f=0,g=0,y=0;f<o;++f)for(var v=0,b=P(e,d+1,d=E(g=i[f])),S=e;v<h;++v)(S=T(g>0?m[v]+" "+b:$(b,/&\f/g,m[v])))&&(c[y++]=S);return F(e,t,n,0===r?w:s,c,l,u,p)}function re(e,t,n,o){return F(e,t,n,C,k(B),P(e,2,-2),0,o)}function ae(e,t,n,o,r){return F(e,t,n,x,P(e,0,o),P(e,o+1,-1),o,r)}const ie=(e,t,{spacingMultiplier:n=0}={})=>{const o=t?`${t}{${e}}`:e,r=[S({spacingMultiplier:n}),R];return D(te(o),(i=A(a=r),function(e,t,n,o){for(var r="",s=0;s<i;s++)r+=a[s](e,t,n,o)||"";return r}));var a,i},se=(e,t)=>""===e||!1===e||ge(e)?"":fe(e)?Se(e)?`.${e[a]}`:se(e(t),t):Array.isArray(e)?e.map(e=>se(e,t)).join("\n"):he(e)?Object.entries(e).filter(([,e])=>void 0!==e&&!1!==e).map(([e,t])=>`${de(e)}: ${t};`).join("\n"):e.toString?.()??"",ce=(e,...t)=>n=>e.reduce((e,o,r)=>e+o+se(t[r],n),""),le=e=>`@media ${e.map(e=>{const t=[e.width&&["width",e.width],e.minWidth&&["min-width",e.minWidth],e.maxWidth&&["max-width",e.maxWidth],e.height&&["height",e.height],e.minHeight&&["min-height",e.minHeight],e.maxHeight&&["max-height",e.maxHeight],e.orientation&&["orientation",e.orientation],e.minResolution&&["min-resolution",e.minResolution],e.maxResolution&&["max-resolution",e.maxResolution],e.resolution&&["resolution",e.resolution],e.update&&["update",e.update]],n=ye(t).map(e=>`(${e[0]}: ${e[1]})`).join(" and "),o=n?` and ${n}`:"";return`${e.operator?`${e.operator} `:""}${e.mediaType??"screen"}${o}`}).join(", ")}`;function ue(e,t){if(!e)throw new Error(t)}const pe=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,de=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),me=e=>"string"==typeof e,he=e=>"object"==typeof e,fe=e=>"function"==typeof e,ge=e=>null==e,ye=e=>e.filter(Boolean),ve=e=>e.filter(Boolean).join(" ").trim(),be=e=>`hscn-${(e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)})(e)}`,Se=e=>a in e,Ce=e=>Object.entries(e).reduce((e,[t,n])=>((m.has(t)||t.startsWith("data-")||t.startsWith("aria-"))&&(e[t]=n),e),{}),we=(e,t=16)=>e/t+"rem",xe=e=>2===e.split(".").length,Ee=(e,t="px",n="base")=>({theme:o})=>{if("string"==typeof e)return e;const r=o.spacings[n]??0;if("number"==typeof e){const n=e*r;return t?`${n}${t}`:n}return e.map(e=>{if("string"==typeof e)return e;const n=e*r;return t?`${n}${t}`:n}).join(" ")},ke=e=>({theme:t})=>{const n=t.fonts[e];return ce`
|
|
3
3
|
font-family: ${n.family};
|
|
4
|
-
font-size: ${
|
|
4
|
+
font-size: ${we(n.size)};
|
|
5
5
|
font-weight: ${n.weight};
|
|
6
|
-
line-height: ${void 0!==n.lineHeight&&
|
|
7
|
-
letter-spacing: ${void 0!==n.letterSpacing&&
|
|
8
|
-
`},
|
|
6
|
+
line-height: ${void 0!==n.lineHeight&&we(n.lineHeight)};
|
|
7
|
+
letter-spacing: ${void 0!==n.letterSpacing&&we(n.letterSpacing)};
|
|
8
|
+
`},Te=(e,t)=>{if(t<0||t>1)throw new Error(`[honey-layout]: Alpha "${t}" is not a valid hex format.`);const n=e.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);if(!n)throw new Error("[honey-layout]: Invalid hex format.");const o=n[1];return`#${(3===o.length?o[0]+o[0]+o[1]+o[1]+o[2]+o[2]:o)+Math.round(255*t).toString(16).toUpperCase().padStart(2,"0")}`},$e=(e,t)=>({theme:n})=>{const[o,r]=e.split("."),a=r?n.colors[o][r]:o;return void 0===t?a:Te(a,t)},Oe=e=>({theme:t})=>t.dimensions[e],Me=({children:e,theme:t})=>{const n=(0,h.useMemo)(()=>({theme:t,resolveSpacing:(...e)=>Ee(...e)({theme:t}),resolveColor:(...e)=>$e(...e)({theme:t}),resolveFont:(...e)=>ke(...e)({theme:t}),resolveDimension:(...e)=>Oe(...e)({theme:t})}),[t]);return(0,g.jsx)(f,{value:n,children:e})},Pe=()=>{const e=(0,h.useContext)(f);return ue(e,"The `useHoneyStyle()` hook must be used inside <HoneyStyleProvider/> component!"),e},_e=(e,...t)=>{const n=pe("hsg"),o=ce(e,...t);return()=>{const{theme:e}=Pe();return(0,h.useInsertionEffect)(()=>{const t=o({theme:e}),r=ie(t),a=document.createElement("style");return a.id=n,a.innerHTML=r,a.setAttribute(i,"true"),document.head.insertBefore(a,document.head.firstChild),()=>{a.remove()}},[e]),null}},Ae=(window.__honeyStyleRegistry||(window.__honeyStyleRegistry=new Map),window.__honeyStyleRegistry);let Le=null;const De=()=>{const e=(Le||(Le=document.querySelector(`style[${s}="true"]`),Le||(Le=document.createElement("style"),Le.setAttribute(s,"true"),document.head.appendChild(Le))),Le),t=Array.from(Ae.entries()).sort(([,e],[,t])=>e.priority-t.priority).map(([,e])=>e.css).join("\n");e.textContent=t},Re=e=>()=>{const t=Ae.get(e);t&&(t.usages--,t.usages<=0&&(Ae.delete(e),De()))},je=(e,t,n=0)=>{const o=Ae.get(e);return o?(o.usages++,Re(e)):(Ae.set(e,{css:t,priority:n,usages:1}),De(),Re(e))},He=(e,t)=>(n,...o)=>{const i=pe("hsc"),s=ce(n,...o),c=({as:n,className:o,__compositionDepth:a=0,css:c,...l})=>{r&&c&&console.warn('[@react-hive/honey-style]: The "css" prop is deprecated. Please use inheritance or composition instead.');const{theme:u}=Pe(),p=Object.fromEntries(Object.entries(l).filter(([,e])=>void 0!==e)),d=fe(t)?t({theme:u,as:n,className:o,...p}):t??{},m={...d,...p,theme:u},f=s(m),g=be(f);(0,h.useInsertionEffect)(()=>{const e=ie(f,`.${g}`,{spacingMultiplier:u.spacings.base});return je(g,e,a)},[g]);const y=((e,t)=>e?me(e)?e:ce([""],[e])(t):"")(fe(c)?c(m):c,m),v=y?be(y):"";(0,h.useInsertionEffect)(()=>{if(v){const e=ie(y,`.${v}`,{spacingMultiplier:u.spacings.base});return je(v,e,1)}},[v]);const b={...d,...p,className:ve([i,g,o,v])},S=n||e;if(me(e)){const e=me(S)?Ce(b):b;return(0,h.createElement)(S,e)}return(0,h.createElement)(e,{...b,...n&&{as:n},...Se(e)&&{__compositionDepth:a-1}})};if(c[a]=i,r){const t=me(e)?e:e.displayName||e.name||"Component";c.displayName=`HoneyStyledComponent(${t})`}return c};module.exports=o})();
|
|
9
9
|
//# sourceMappingURL=index.cjs.map
|