@react-hive/honey-style 1.10.0 → 2.0.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.
@@ -1,8 +1,47 @@
1
- import type { HoneyTheme } from '../types';
1
+ import type { Nullable, HoneyTheme, HoneyColorKey, HoneyCSSColor, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSSpacingValue, HoneyDimensionName, HoneyFontName, HoneySpacings, HoneyStyledInterpolation } from '../types';
2
+ import type { HoneyResolveSpacingResult } from '../utils';
2
3
  export interface HoneyStyleContextValue {
3
4
  /**
4
5
  * Represents the theme object.
5
6
  */
6
7
  theme: HoneyTheme;
8
+ /**
9
+ * Function to resolve spacing values based on a given theme.
10
+ *
11
+ * @template Value - A type representing the spacing value(s), which could be a single value or an array of values.
12
+ * @template Unit - The CSS unit used for the resolved spacing value, e.g., 'px', 'em'.
13
+ *
14
+ * @param value - The spacing value(s) to be applied, which could be a single number or an array of numbers.
15
+ * @param [unit] - The CSS unit to use for the calculated value. Defaults to 'px'.
16
+ * @param [type] - The type of spacing to use from the theme (e.g., 'base', 'small', 'large').
17
+ *
18
+ * @returns The resolved spacing value, formatted as a string with the appropriate unit.
19
+ */
20
+ resolveSpacing: <Value extends HoneyCSSSpacingValue, Unit extends Nullable<HoneyCSSDimensionUnit> = 'px'>(value: Value, unit?: Unit, type?: keyof HoneySpacings) => HoneyResolveSpacingResult<Value, Unit>;
21
+ /**
22
+ * Function to resolve color values based on the theme.
23
+ *
24
+ * @param colorKey - The key representing the color in the theme.
25
+ * @param [alpha] - Optional alpha value to apply to the color for transparency.
26
+ *
27
+ * @returns The resolved CSS color, optionally with alpha transparency.
28
+ */
29
+ resolveColor: (colorKey: HoneyColorKey, alpha?: number) => HoneyCSSColor;
30
+ /**
31
+ * Function to resolve font styles based on the theme.
32
+ *
33
+ * @param fontName - The name of the font to resolve from the theme.
34
+ *
35
+ * @returns The CSS style rules for the specified font.
36
+ */
37
+ resolveFont: (fontName: HoneyFontName) => HoneyStyledInterpolation<object>;
38
+ /**
39
+ * Function to resolve dimension values based on the theme.
40
+ *
41
+ * @param dimensionName - The name of the dimension to resolve from the theme.
42
+ *
43
+ * @returns The resolved CSS dimension value (e.g., width, height).
44
+ */
45
+ resolveDimension: (dimensionName: HoneyDimensionName) => HoneyCSSDimensionValue;
7
46
  }
8
47
  export declare const HoneyStyleContext: import("react").Context<HoneyStyleContextValue | undefined>;
@@ -0,0 +1,3 @@
1
+ import type { HoneyCSSColorProperty, HoneyCSSSpacingProperty } from './types';
2
+ export declare const CSS_SPACING_PROPERTIES: readonly HoneyCSSSpacingProperty[];
3
+ export declare const CSS_COLOR_PROPERTIES: readonly HoneyCSSColorProperty[];
@@ -1,2 +1,2 @@
1
- import type { HoneyStyledInterpolation, HoneyStyledContext } from './types';
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,5 @@
1
+ export * from './types';
2
+ export * from './constants';
3
+ export * from './middlewares';
4
+ export * from './processor';
5
+ export * from './css';
@@ -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 {};
@@ -0,0 +1,8 @@
1
+ interface ProcessCssOptions {
2
+ /**
3
+ * @default 0
4
+ */
5
+ spacingMultiplier?: number;
6
+ }
7
+ export declare const processCss: (rawCss: string, selector?: string, { spacingMultiplier }?: ProcessCssOptions) => string;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import * as CSS from 'csstype';
2
+ /**
3
+ * Represents CSS properties related to spacing and positioning.
4
+ */
5
+ export type HoneyCSSSpacingProperty = keyof Pick<CSS.Properties, 'margin' | 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'padding' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'top' | 'right' | 'bottom' | 'left' | 'gap' | 'rowGap' | 'columnGap'>;
6
+ /**
7
+ * Represents a subset of CSS properties that define color-related styles.
8
+ */
9
+ export type HoneyCSSColorProperty = keyof Pick<CSS.Properties, 'color' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'outlineColor' | 'textDecorationColor' | 'fill' | 'stroke'>;
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:()=>g,VALID_DOM_ELEMENT_ATTRS:()=>f,__DEV__:()=>r,assert:()=>re,boolFilter:()=>de,checkIsThemeColorValue:()=>ve,combineClassNames:()=>he,convertHexToHexWithAlpha:()=>be,createGlobalStyle:()=>ke,css:()=>oe,filterNonHtmlAttrs:()=>ye,generateId:()=>ae,isFunction:()=>le,isNil:()=>ue,isObject:()=>ce,isString:()=>se,isStyledComponent:()=>me,mediaQuery:()=>Me,processCss:()=>pe,pxToRem:()=>ge,resolveClassName:()=>fe,resolveColor:()=>we,resolveDimension:()=>Ce,resolveFont:()=>Se,styled:()=>_e,toKebabCase:()=>ie,useHoneyStyle:()=>xe});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"]),f=new Set([...l,...u,...d,...h]),m=require("react"),p=(0,m.createContext)(void 0);var y=n(848);const g=({children:e,theme:t})=>{const n=(0,m.useMemo)(()=>({theme:t}),[t]);return(0,y.jsx)(p,{value:n,children:e})};var v="comm",S="rule",b="decl",w=Math.abs,C=String.fromCharCode;function x(e){return e.trim()}function k(e,t,n){return e.replace(t,n)}function E(e,t,n){return e.indexOf(t,n)}function T(e,t){return 0|e.charCodeAt(t)}function $(e,t,n){return e.slice(t,n)}function O(e){return e.length}function P(e,t){return t.push(e),e}function _(e,t){for(var n="",o=0;o<e.length;o++)n+=t(e[o],o,e,t)||"";return n}function M(e,t,n,o){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case b:return e.return=e.return||e.value;case v:return"";case"@keyframes":return e.return=e.value+"{"+_(e.children,o)+"}";case S:if(!O(e.value=e.props.join(",")))return""}return O(n=_(e.children,o))?e.return=e.value+"{"+n+"}":""}Object.assign;var A=1,D=1,L=0,j=0,H=0,N="";function R(e,t,n,o,r,a,i,s){return{value:e,root:t,parent:n,type:o,props:r,children:a,line:A,column:D,length:i,return:"",siblings:s}}function I(){return H=j>0?T(N,--j):0,D--,10===H&&(D=1,A--),H}function W(){return H=j<L?T(N,j++):0,D++,10===H&&(D=1,A++),H}function Y(){return T(N,j)}function B(){return j}function F(e,t){return $(N,e,t)}function K(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 z(e){return x(F(j-1,q(91===e?e+2:40===e?e+1:e)))}function U(e){for(;(H=Y())&&H<33;)W();return K(e)>2||K(H)>3?"":" "}function V(e,t){for(;--t&&W()&&!(H<48||H>102||H>57&&H<65||H>70&&H<97););return F(e,B()+(t<6&&32==Y()&&32==W()))}function q(e){for(;W();)switch(H){case e:return j;case 34:case 39:34!==e&&39!==e&&q(H);break;case 40:41===e&&q(e);break;case 92:W()}return j}function G(e,t){for(;W()&&e+H!==57&&(e+H!==84||47!==Y()););return"/*"+F(t,j-1)+"*"+C(47===e?e:W())}function J(e){for(;!K(Y());)W();return F(e,j)}function Q(e){return function(e){return N="",e}(X("",null,null,null,[""],e=function(e){return A=D=1,L=O(N=e),j=0,[]}(e),0,[0],e))}function X(e,t,n,o,r,a,i,s,c){for(var l=0,u=0,d=i,h=0,f=0,m=0,p=1,y=1,g=1,v=0,S="",b=r,x=a,_=o,M=S;y;)switch(m=v,v=W()){case 40:if(108!=m&&58==T(M,d-1)){-1!=E(M+=k(z(v),"&","&\f"),"&\f",w(l?s[l-1]:0))&&(g=-1);break}case 34:case 39:case 91:M+=z(v);break;case 9:case 10:case 13:case 32:M+=U(m);break;case 92:M+=V(B()-1,7);continue;case 47:switch(Y()){case 42:case 47:P(ee(G(W(),B()),t,n,c),c),5!=K(m||1)&&5!=K(Y()||1)||!O(M)||" "===$(M,-1,void 0)||(M+=" ");break;default:M+="/"}break;case 123*p:s[l++]=O(M)*g;case 125*p:case 59:case 0:switch(v){case 0:case 125:y=0;case 59+u:-1==g&&(M=k(M,/\f/g,"")),f>0&&(O(M)-d||0===p&&47===m)&&P(f>32?te(M+";",o,n,d-1,c):te(k(M," ","")+";",o,n,d-2,c),c);break;case 59:M+=";";default:if(P(_=Z(M,t,n,l,u,r,s,S,b=[],x=[],d,a),a),123===v)if(0===u)X(M,t,_,_,b,a,d,s,x);else{switch(h){case 99:if(110===T(M,3))break;case 108:if(97===T(M,2))break;default:u=0;case 100:case 109:case 115:}u?X(e,_,_,o&&P(Z(e,_,_,0,0,r,s,S,r,b=[],d,x),x),r,x,d,s,o?b:x):X(M,_,_,_,[""],x,0,s,x)}}l=u=f=0,p=g=1,S=M="",d=i;break;case 58:d=1+O(M),f=m;default:if(p<1)if(123==v)--p;else if(125==v&&0==p++&&125==I())continue;switch(M+=C(v),v*p){case 38:g=u>0?1:(M+="\f",-1);break;case 44:s[l++]=(O(M)-1)*g,g=1;break;case 64:45===Y()&&(M+=z(W())),h=Y(),u=d=O(S=M+=J(B())),v++;break;case 45:45===m&&2==O(M)&&(p=0)}}return a}function Z(e,t,n,o,r,a,i,s,c,l,u,d){for(var h=r-1,f=0===r?a:[""],m=function(e){return e.length}(f),p=0,y=0,g=0;p<o;++p)for(var v=0,b=$(e,h+1,h=w(y=i[p])),C=e;v<m;++v)(C=x(y>0?f[v]+" "+b:k(b,/&\f/g,f[v])))&&(c[g++]=C);return R(e,t,n,0===r?S:s,c,l,u,d)}function ee(e,t,n,o){return R(e,t,n,v,C(H),$(e,2,-2),0,o)}function te(e,t,n,o,r){return R(e,t,n,b,$(e,0,o),$(e,o+1,-1),o,r)}const ne=(e,t)=>""===e||!1===e||ue(e)?"":le(e)?me(e)?`.${e[a]}`:ne(e(t),t):Array.isArray(e)?e.map(e=>ne(e,t)).join("\n"):ce(e)?Object.entries(e).filter(([,e])=>void 0!==e&&!1!==e).map(([e,t])=>`${ie(e)}: ${t};`).join("\n"):e.toString?.()??"",oe=(e,...t)=>n=>e.reduce((e,o,r)=>e+o+ne(t[r],n),"");function re(e,t){if(!e)throw new Error(t)}const ae=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,ie=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),se=e=>"string"==typeof e,ce=e=>"object"==typeof e,le=e=>"function"==typeof e,ue=e=>null==e,de=e=>e.filter(Boolean),he=e=>e.filter(Boolean).join(" ").trim(),fe=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,pe=(e,t)=>_(Q(t?`${t}{${e}}`:e),M),ye=e=>Object.entries(e).reduce((e,[t,n])=>((f.has(t)||t.startsWith("data-")||t.startsWith("aria-"))&&(e[t]=n),e),{}),ge=(e,t=16)=>e/t+"rem",ve=e=>2===e.split(".").length,Se=e=>({theme:t})=>{const n=t.fonts[e];return oe`
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:()=>$e,VALID_DOM_ELEMENT_ATTRS:()=>h,__DEV__:()=>r,assert:()=>ce,boolFilter:()=>fe,checkIsThemeColorValue:()=>Ce,combineClassNames:()=>ge,convertHexToHexWithAlpha:()=>Ee,createGlobalStyle:()=>Me,createSpacingMiddleware:()=>b,css:()=>se,filterNonHtmlAttrs:()=>be,generateId:()=>le,isFunction:()=>he,isNil:()=>me,isObject:()=>de,isString:()=>pe,isStyledComponent:()=>ve,mediaQuery:()=>je,processCss:()=>ae,pxToRem:()=>Se,resolveClassName:()=>ye,resolveColor:()=>ke,resolveDimension:()=>Te,resolveFont:()=>xe,resolveSpacing:()=>we,styled:()=>Re,toKebabCase:()=>ue,useHoneyStyle:()=>Oe});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"]),h=new Set([...l,...u,...p,...d]),m=require("react"),f=(0,m.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=({spacingMultiplier:e})=>t=>{if(e&&"decl"===t.type&&"string"==typeof t.props&&y.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 S="comm",C="rule",w="decl",x=Math.abs,E=String.fromCharCode;function k(e){return e.trim()}function T(e,t,n){return e.replace(t,n)}function $(e,t,n){return e.indexOf(t,n)}function O(e,t){return 0|e.charCodeAt(t)}function M(e,t,n){return e.slice(t,n)}function P(e){return e.length}function _(e){return e.length}function A(e,t){return t.push(e),e}function L(e,t){for(var n="",o=0;o<e.length;o++)n+=t(e[o],o,e,t)||"";return n}function D(e,t,n,o){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case w:return e.return=e.return||e.value;case S:return"";case"@keyframes":return e.return=e.value+"{"+L(e.children,o)+"}";case C:if(!P(e.value=e.props.join(",")))return""}return P(n=L(e.children,o))?e.return=e.value+"{"+n+"}":""}Object.assign;var R=1,j=1,H=0,N=0,I=0,B="";function W(e,t,n,o,r,a,i,s){return{value:e,root:t,parent:n,type:o,props:r,children:a,line:R,column:j,length:i,return:"",siblings:s}}function F(){return I=N>0?O(B,--N):0,j--,10===I&&(j=1,R--),I}function Y(){return I=N<H?O(B,N++):0,j++,10===I&&(j=1,R++),I}function z(){return O(B,N)}function K(){return N}function G(e,t){return M(B,e,t)}function U(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 V(e){return k(G(N-1,Q(91===e?e+2:40===e?e+1:e)))}function q(e){for(;(I=z())&&I<33;)Y();return U(e)>2||U(I)>3?"":" "}function J(e,t){for(;--t&&Y()&&!(I<48||I>102||I>57&&I<65||I>70&&I<97););return G(e,K()+(t<6&&32==z()&&32==Y()))}function Q(e){for(;Y();)switch(I){case e:return N;case 34:case 39:34!==e&&39!==e&&Q(I);break;case 40:41===e&&Q(e);break;case 92:Y()}return N}function X(e,t){for(;Y()&&e+I!==57&&(e+I!==84||47!==z()););return"/*"+G(t,N-1)+"*"+E(47===e?e:Y())}function Z(e){for(;!U(z());)Y();return G(e,N)}function ee(e){return function(e){return B="",e}(te("",null,null,null,[""],e=function(e){return R=j=1,H=P(B=e),N=0,[]}(e),0,[0],e))}function te(e,t,n,o,r,a,i,s,c){for(var l=0,u=0,p=i,d=0,h=0,m=0,f=1,g=1,y=1,v=0,b="",S=r,C=a,w=o,k=b;g;)switch(m=v,v=Y()){case 40:if(108!=m&&58==O(k,p-1)){-1!=$(k+=T(V(v),"&","&\f"),"&\f",x(l?s[l-1]:0))&&(y=-1);break}case 34:case 39:case 91:k+=V(v);break;case 9:case 10:case 13:case 32:k+=q(m);break;case 92:k+=J(K()-1,7);continue;case 47:switch(z()){case 42:case 47:A(oe(X(Y(),K()),t,n,c),c),5!=U(m||1)&&5!=U(z()||1)||!P(k)||" "===M(k,-1,void 0)||(k+=" ");break;default:k+="/"}break;case 123*f:s[l++]=P(k)*y;case 125*f:case 59:case 0:switch(v){case 0:case 125:g=0;case 59+u:-1==y&&(k=T(k,/\f/g,"")),h>0&&(P(k)-p||0===f&&47===m)&&A(h>32?re(k+";",o,n,p-1,c):re(T(k," ","")+";",o,n,p-2,c),c);break;case 59:k+=";";default:if(A(w=ne(k,t,n,l,u,r,s,b,S=[],C=[],p,a),a),123===v)if(0===u)te(k,t,w,w,S,a,p,s,C);else{switch(d){case 99:if(110===O(k,3))break;case 108:if(97===O(k,2))break;default:u=0;case 100:case 109:case 115:}u?te(e,w,w,o&&A(ne(e,w,w,0,0,r,s,b,r,S=[],p,C),C),r,C,p,s,o?S:C):te(k,w,w,w,[""],C,0,s,C)}}l=u=h=0,f=y=1,b=k="",p=i;break;case 58:p=1+P(k),h=m;default:if(f<1)if(123==v)--f;else if(125==v&&0==f++&&125==F())continue;switch(k+=E(v),v*f){case 38:y=u>0?1:(k+="\f",-1);break;case 44:s[l++]=(P(k)-1)*y,y=1;break;case 64:45===z()&&(k+=V(Y())),d=z(),u=p=P(b=k+=Z(K())),v++;break;case 45:45===m&&2==P(k)&&(f=0)}}return a}function ne(e,t,n,o,r,a,i,s,c,l,u,p){for(var d=r-1,h=0===r?a:[""],m=_(h),f=0,g=0,y=0;f<o;++f)for(var v=0,b=M(e,d+1,d=x(g=i[f])),S=e;v<m;++v)(S=k(g>0?h[v]+" "+b:T(b,/&\f/g,h[v])))&&(c[y++]=S);return W(e,t,n,0===r?C:s,c,l,u,p)}function oe(e,t,n,o){return W(e,t,n,S,E(I),M(e,2,-2),0,o)}function re(e,t,n,o,r){return W(e,t,n,w,M(e,0,o),M(e,o+1,-1),o,r)}const ae=(e,t,{spacingMultiplier:n=0}={})=>{const o=t?`${t}{${e}}`:e,r=[b({spacingMultiplier:n}),D];return L(ee(o),(i=_(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},ie=(e,t)=>""===e||!1===e||me(e)?"":he(e)?ve(e)?`.${e[a]}`:ie(e(t),t):Array.isArray(e)?e.map(e=>ie(e,t)).join("\n"):de(e)?Object.entries(e).filter(([,e])=>void 0!==e&&!1!==e).map(([e,t])=>`${ue(e)}: ${t};`).join("\n"):e.toString?.()??"",se=(e,...t)=>n=>e.reduce((e,o,r)=>e+o+ie(t[r],n),"");function ce(e,t){if(!e)throw new Error(t)}const le=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,ue=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pe=e=>"string"==typeof e,de=e=>"object"==typeof e,he=e=>"function"==typeof e,me=e=>null==e,fe=e=>e.filter(Boolean),ge=e=>e.filter(Boolean).join(" ").trim(),ye=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)}`,ve=e=>a in e,be=e=>Object.entries(e).reduce((e,[t,n])=>((h.has(t)||t.startsWith("data-")||t.startsWith("aria-"))&&(e[t]=n),e),{}),Se=(e,t=16)=>e/t+"rem",Ce=e=>2===e.split(".").length,we=(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(" ")},xe=e=>({theme:t})=>{const n=t.fonts[e];return se`
3
3
  font-family: ${n.family};
4
- font-size: ${ge(n.size)};
4
+ font-size: ${Se(n.size)};
5
5
  font-weight: ${n.weight};
6
- line-height: ${void 0!==n.lineHeight&&ge(n.lineHeight)};
7
- letter-spacing: ${void 0!==n.letterSpacing&&ge(n.letterSpacing)};
8
- `},be=(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")}`},we=(e,t)=>({theme:n})=>{const[o,r]=e.split("."),a=r?n.colors[o][r]:o;return void 0===t?a:be(a,t)},Ce=e=>({theme:t})=>t.dimensions[e],xe=()=>{const e=(0,m.useContext)(p);return re(e,"The `useHoneyStyle()` hook must be used inside <HoneyStyleProvider/> component!"),e},ke=(e,...t)=>{const n=ae("hsg"),o=oe(e,...t);return()=>{const{theme:e}=xe();return(0,m.useInsertionEffect)(()=>{const t=o({theme:e}),r=pe(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}},Ee=(window.__honeyStyleRegistry||(window.__honeyStyleRegistry=new Map),window.__honeyStyleRegistry);let Te=null;const $e=()=>{const e=(Te||(Te=document.querySelector(`style[${s}="true"]`),Te||(Te=document.createElement("style"),Te.setAttribute(s,"true"),document.head.appendChild(Te))),Te),t=Array.from(Ee.entries()).sort(([,e],[,t])=>e.priority-t.priority).map(([,e])=>e.css).join("\n");e.textContent=t},Oe=e=>()=>{const t=Ee.get(e);t&&(t.usages--,t.usages<=0&&(Ee.delete(e),$e()))},Pe=(e,t,n=0)=>{const o=Ee.get(e);return o?(o.usages++,Oe(e)):(Ee.set(e,{css:t,priority:n,usages:1}),$e(),Oe(e))},_e=(e,t)=>(n,...o)=>{const i=ae("hsc"),s=oe(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}=xe(),d=Object.fromEntries(Object.entries(l).filter(([,e])=>void 0!==e)),h=le(t)?t({theme:u,as:n,className:o,...d}):t??{},f={...h,...d,theme:u},p=s(f),y=fe(p);(0,m.useInsertionEffect)(()=>{const e=pe(p,`.${y}`);return Pe(y,e,a)},[y]);const g=((e,t)=>e?se(e)?e:oe([""],[e])(t):"")(le(c)?c(f):c,f),v=g?fe(g):"";(0,m.useInsertionEffect)(()=>{if(v){const e=pe(g,`.${v}`);return Pe(v,e,1)}},[v]);const S={...h,...d,className:he([i,y,o,v])},b=n||e;if(se(e)){const e=se(b)?ye(S):S;return(0,m.createElement)(b,e)}return(0,m.createElement)(e,{...S,...n&&{as:n},...me(e)&&{__compositionDepth:a-1}})};if(c[a]=i,r){const t=se(e)?e:e.displayName||e.name||"Component";c.displayName=`HoneyStyledComponent(${t})`}return c},Me=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=de(t).map(e=>`(${e[0]}: ${e[1]})`).join(" and "),o=n?` and ${n}`:"";return`${e.operator?`${e.operator} `:""}${e.mediaType??"screen"}${o}`}).join(", ")}`;module.exports=o})();
6
+ line-height: ${void 0!==n.lineHeight&&Se(n.lineHeight)};
7
+ letter-spacing: ${void 0!==n.letterSpacing&&Se(n.letterSpacing)};
8
+ `},Ee=(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")}`},ke=(e,t)=>({theme:n})=>{const[o,r]=e.split("."),a=r?n.colors[o][r]:o;return void 0===t?a:Ee(a,t)},Te=e=>({theme:t})=>t.dimensions[e],$e=({children:e,theme:t})=>{const n=(0,m.useMemo)(()=>({theme:t,resolveSpacing:(...e)=>we(...e)({theme:t}),resolveColor:(...e)=>ke(...e)({theme:t}),resolveFont:(...e)=>xe(...e)({theme:t}),resolveDimension:(...e)=>Te(...e)({theme:t})}),[t]);return(0,g.jsx)(f,{value:n,children:e})},Oe=()=>{const e=(0,m.useContext)(f);return ce(e,"The `useHoneyStyle()` hook must be used inside <HoneyStyleProvider/> component!"),e},Me=(e,...t)=>{const n=le("hsg"),o=se(e,...t);return()=>{const{theme:e}=Oe();return(0,m.useInsertionEffect)(()=>{const t=o({theme:e}),r=ae(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}},Pe=(window.__honeyStyleRegistry||(window.__honeyStyleRegistry=new Map),window.__honeyStyleRegistry);let _e=null;const Ae=()=>{const e=(_e||(_e=document.querySelector(`style[${s}="true"]`),_e||(_e=document.createElement("style"),_e.setAttribute(s,"true"),document.head.appendChild(_e))),_e),t=Array.from(Pe.entries()).sort(([,e],[,t])=>e.priority-t.priority).map(([,e])=>e.css).join("\n");e.textContent=t},Le=e=>()=>{const t=Pe.get(e);t&&(t.usages--,t.usages<=0&&(Pe.delete(e),Ae()))},De=(e,t,n=0)=>{const o=Pe.get(e);return o?(o.usages++,Le(e)):(Pe.set(e,{css:t,priority:n,usages:1}),Ae(),Le(e))},Re=(e,t)=>(n,...o)=>{const i=le("hsc"),s=se(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}=Oe(),p=Object.fromEntries(Object.entries(l).filter(([,e])=>void 0!==e)),d=he(t)?t({theme:u,as:n,className:o,...p}):t??{},h={...d,...p,theme:u},f=s(h),g=ye(f);(0,m.useInsertionEffect)(()=>{const e=ae(f,`.${g}`,{spacingMultiplier:u.spacings.base});return De(g,e,a)},[g]);const y=((e,t)=>e?pe(e)?e:se([""],[e])(t):"")(he(c)?c(h):c,h),v=y?ye(y):"";(0,m.useInsertionEffect)(()=>{if(v){const e=ae(y,`.${v}`,{spacingMultiplier:u.spacings.base});return De(v,e,1)}},[v]);const b={...d,...p,className:ge([i,g,o,v])},S=n||e;if(pe(e)){const e=pe(S)?be(b):b;return(0,m.createElement)(S,e)}return(0,m.createElement)(e,{...b,...n&&{as:n},...ve(e)&&{__compositionDepth:a-1}})};if(c[a]=i,r){const t=pe(e)?e:e.displayName||e.name||"Component";c.displayName=`HoneyStyledComponent(${t})`}return c},je=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=fe(t).map(e=>`(${e[0]}: ${e[1]})`).join(" and "),o=n?` and ${n}`:"";return`${e.operator?`${e.operator} `:""}${e.mediaType??"screen"}${o}`}).join(", ")}`;module.exports=o})();
9
9
  //# sourceMappingURL=index.cjs.map