@react-hive/honey-style 2.0.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/index.d.ts +1 -0
- package/dist/css/types.d.ts +122 -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 +109 -120
- 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 -1
- package/package.json +1 -1
- package/dist/types/css.types.d.ts +0 -115
- /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
|
/**
|
package/dist/css/index.d.ts
CHANGED
package/dist/css/types.d.ts
CHANGED
|
@@ -1,9 +1,131 @@
|
|
|
1
1
|
import * as CSS from 'csstype';
|
|
2
|
+
export type HoneyCSSClassName = string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Represents a hexadecimal color value.
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - `'#ffffff'`
|
|
8
|
+
* - `'#123abc'`
|
|
9
|
+
* - `'#000'`
|
|
10
|
+
*/
|
|
11
|
+
export type HoneyHEXColor = `#${string}`;
|
|
12
|
+
/**
|
|
13
|
+
* Represents any valid CSS color, either a named color (like `'red'`, `'blue'`)
|
|
14
|
+
* or a hexadecimal color code (like `'#ff0000'`).
|
|
15
|
+
*/
|
|
16
|
+
export type HoneyCSSColor = HoneyHEXColor | CSS.DataType.NamedColor | CSS.Globals;
|
|
17
|
+
/**
|
|
18
|
+
* Represents absolute CSS dimension units.
|
|
19
|
+
*
|
|
20
|
+
* These units are fixed in physical measurements.
|
|
21
|
+
*
|
|
22
|
+
* - `'px'` — pixels
|
|
23
|
+
* - `'cm'` — centimeters
|
|
24
|
+
* - `'mm'` — millimeters
|
|
25
|
+
* - `'in'` — inches
|
|
26
|
+
* - `'pt'` — points
|
|
27
|
+
* - `'pc'` — picas
|
|
28
|
+
*/
|
|
29
|
+
type HoneyCSSAbsoluteDimensionUnit = 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
|
|
30
|
+
/**
|
|
31
|
+
* Represents relative CSS dimension units.
|
|
32
|
+
*
|
|
33
|
+
* These units scale depending on the context.
|
|
34
|
+
*
|
|
35
|
+
* - `'em'` — relative to the font-size of the element
|
|
36
|
+
* - `'rem'` — relative to the font-size of the root element
|
|
37
|
+
* - `'%'` — percentage of the parent element
|
|
38
|
+
* - `'vh'` — 1% of the viewport height
|
|
39
|
+
* - `'vw'` — 1% of the viewport width
|
|
40
|
+
* - `'vmin'` — 1% of the smaller dimension of the viewport
|
|
41
|
+
* - `'vmax'` — 1% of the larger dimension of the viewport
|
|
42
|
+
*/
|
|
43
|
+
type HoneyCSSRelativeDimensionUnit = 'em' | 'rem' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax';
|
|
44
|
+
/**
|
|
45
|
+
* Represents any valid CSS dimension unit, including both absolute and relative types.
|
|
46
|
+
*/
|
|
47
|
+
export type HoneyCSSDimensionUnit = HoneyCSSAbsoluteDimensionUnit | HoneyCSSRelativeDimensionUnit;
|
|
48
|
+
/**
|
|
49
|
+
* Represents a numeric CSS dimension value with an optional specific unit.
|
|
50
|
+
*
|
|
51
|
+
* This type can represent:
|
|
52
|
+
* - A value with a specific CSS unit, such as `'8px'`, `'1.5rem'`, or `'100%'`.
|
|
53
|
+
* - The special value `'auto'` commonly used for flexible layout values.
|
|
54
|
+
*
|
|
55
|
+
* @template Unit - The CSS unit to use (e.g., `'px'`, `'em'`, `'rem'`).
|
|
56
|
+
*/
|
|
57
|
+
export type HoneyCSSDimensionValue<Unit extends HoneyCSSDimensionUnit = HoneyCSSDimensionUnit> = `${number}${Unit}` | 'auto';
|
|
58
|
+
/**
|
|
59
|
+
* Represents a tuple of 2 to 4 values using standard CSS shorthand conventions.
|
|
60
|
+
*
|
|
61
|
+
* This type models how properties like `margin`, `padding`, `gap`, and `borderRadius`
|
|
62
|
+
* can accept multiple values to control different sides or axes.
|
|
63
|
+
*
|
|
64
|
+
* Value interpretation follows CSS shorthand behavior:
|
|
65
|
+
* - `[T, T]` → [top & bottom, left & right]
|
|
66
|
+
* - `[T, T, T]` → [top, left & right, bottom]
|
|
67
|
+
* - `[T, T, T, T]` → [top, right, bottom, left]
|
|
68
|
+
*
|
|
69
|
+
* @template T - The type of each spacing value (e.g., number, string, or token).
|
|
70
|
+
*/
|
|
71
|
+
export type HoneyCSSShorthandTuple<T> = [T, T] | [T, T, T] | [T, T, T, T];
|
|
72
|
+
/**
|
|
73
|
+
* Converts a tuple of spacing values into a valid CSS shorthand string using a consistent unit.
|
|
74
|
+
*
|
|
75
|
+
* Acts as a type-level converter that transforms 2–4 spacing values (e.g., `[8, 12]`) into a space-separated
|
|
76
|
+
* CSS string (e.g., `'8px 12px'`), suitable for shorthand-compatible properties like `margin`, `padding`, or `gap`.
|
|
77
|
+
*
|
|
78
|
+
* This type enforces unit consistency across all values and is useful for generating precise, typed spacing strings.
|
|
79
|
+
*
|
|
80
|
+
* Example outputs:
|
|
81
|
+
* - `'8px 12px'` for `[8, 12]`
|
|
82
|
+
* - `'1rem 2rem 1.5rem'` for `[1, 2, 1.5]`
|
|
83
|
+
* - `'4px 8px 12px 16px'` for `[4, 8, 12, 16]`
|
|
84
|
+
*
|
|
85
|
+
* @template Tuple - A tuple of 2 to 4 values to be converted into a CSS shorthand string.
|
|
86
|
+
* @template Unit - The CSS unit to apply to each value (e.g., `'px'`, `'rem'`, `'%'`).
|
|
87
|
+
*/
|
|
88
|
+
export type HoneyCSSShorthandDimensionOutput<Tuple extends HoneyCSSShorthandTuple<unknown>, Unit extends HoneyCSSDimensionUnit> = Tuple extends [unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Tuple extends [unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Tuple extends [unknown, unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : never;
|
|
89
|
+
/**
|
|
90
|
+
* Represents a CSS layout value that can be a single value or a shorthand array of values.
|
|
91
|
+
*
|
|
92
|
+
* Useful for properties like `margin`, `padding`, or `borderRadius`, which allow:
|
|
93
|
+
* - A single value (applied to all sides)
|
|
94
|
+
* - A tuple of 2–4 values using standard CSS shorthand behavior
|
|
95
|
+
*
|
|
96
|
+
* Examples:
|
|
97
|
+
* - `'8px'`
|
|
98
|
+
* - `['8px', '12px']`
|
|
99
|
+
* - `['8px', '12px', '16px', '20px']`
|
|
100
|
+
*
|
|
101
|
+
* @template T - The type of each individual value.
|
|
102
|
+
*/
|
|
103
|
+
export type HoneyCSSMultiValue<T> = T | HoneyCSSShorthandTuple<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Represents a spacing value used in layout-related CSS properties.
|
|
106
|
+
*
|
|
107
|
+
* Can be:
|
|
108
|
+
* - A single numeric value (e.g., `8`)
|
|
109
|
+
* - A single dimension string (e.g., `'1rem'`)
|
|
110
|
+
* - A shorthand array of 2–4 values (e.g., `[8, 12]` or `['1rem', '2rem', '1.5rem']`)
|
|
111
|
+
*
|
|
112
|
+
* Commonly used for properties like `margin`, `padding`, `gap`, etc.
|
|
113
|
+
*/
|
|
114
|
+
export type HoneyCSSSpacingValue = HoneyCSSMultiValue<number | HoneyCSSDimensionValue>;
|
|
115
|
+
export type HoneyRawCSSSpacingValue = number | HoneyCSSDimensionValue | CSS.Globals;
|
|
2
116
|
/**
|
|
3
117
|
* Represents CSS properties related to spacing and positioning.
|
|
4
118
|
*/
|
|
5
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'>;
|
|
6
127
|
/**
|
|
7
128
|
* Represents a subset of CSS properties that define color-related styles.
|
|
8
129
|
*/
|
|
9
130
|
export type HoneyCSSColorProperty = keyof Pick<CSS.Properties, 'color' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'outlineColor' | 'textDecorationColor' | 'fill' | 'stroke'>;
|
|
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,{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`
|
|
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
|