@vacano/ui 1.10.1 → 1.11.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/README.md +1 -1
- package/dist/index.cjs +25 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +151 -144
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<img src="https://img.shields.io/badge/version-1.
|
|
10
|
+
<img src="https://img.shields.io/badge/version-1.11.0-blue" />
|
|
11
11
|
<a href="https://www.npmjs.com/package/@vacano/ui"><img src="https://img.shields.io/npm/v/@vacano/ui" alt="npm version" /></a>
|
|
12
12
|
<a href="https://github.com/vacano-house/vacano-ui/blob/master/LICENSE.md"><img src="https://img.shields.io/npm/l/@vacano/ui" alt="license" /></a>
|
|
13
13
|
</p>
|
package/dist/index.cjs
CHANGED
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
:focus:not(:focus-visible) {
|
|
101
101
|
outline: none;
|
|
102
102
|
}
|
|
103
|
-
`,lo=()=>a.jsx(be.Global,{styles:ao});var co=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,so=a.memoize(function(e){return co.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),po=so,uo=function(r){return r!=="theme"},Nt=function(r){return typeof r=="string"&&r.charCodeAt(0)>96?po:uo},Tt=function(r,o,n){var i;if(o){var l=o.shouldForwardProp;i=r.__emotion_forwardProp&&l?function(c){return r.__emotion_forwardProp(c)&&l(c)}:l}return typeof i!="function"&&n&&(i=r.__emotion_forwardProp),i},ho=function(r){var o=r.cache,n=r.serialized,i=r.isStringTag;return a.registerStyles(o,n,i),a.useInsertionEffectAlwaysWithSyncFallback(function(){return a.insertStyles(o,n,i)}),null},bo=function e(r,o){var n=r.__emotion_real===r,i=n&&r.__emotion_base||r,l,c;o!==void 0&&(l=o.label,c=o.target);var d=Tt(r,o,n),p=d||Nt(i),b=!p("as");return function(){var h=arguments,f=n&&r.__emotion_styles!==void 0?r.__emotion_styles.slice(0):[];if(l!==void 0&&f.push("label:"+l+";"),h[0]==null||h[0].raw===void 0)f.push.apply(f,h);else{var
|
|
103
|
+
`,lo=()=>a.jsx(be.Global,{styles:ao});var co=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,so=a.memoize(function(e){return co.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),po=so,uo=function(r){return r!=="theme"},Nt=function(r){return typeof r=="string"&&r.charCodeAt(0)>96?po:uo},Tt=function(r,o,n){var i;if(o){var l=o.shouldForwardProp;i=r.__emotion_forwardProp&&l?function(c){return r.__emotion_forwardProp(c)&&l(c)}:l}return typeof i!="function"&&n&&(i=r.__emotion_forwardProp),i},ho=function(r){var o=r.cache,n=r.serialized,i=r.isStringTag;return a.registerStyles(o,n,i),a.useInsertionEffectAlwaysWithSyncFallback(function(){return a.insertStyles(o,n,i)}),null},bo=function e(r,o){var n=r.__emotion_real===r,i=n&&r.__emotion_base||r,l,c;o!==void 0&&(l=o.label,c=o.target);var d=Tt(r,o,n),p=d||Nt(i),b=!p("as");return function(){var h=arguments,f=n&&r.__emotion_styles!==void 0?r.__emotion_styles.slice(0):[];if(l!==void 0&&f.push("label:"+l+";"),h[0]==null||h[0].raw===void 0)f.push.apply(f,h);else{var O=h[0];f.push(O[0]);for(var w=h.length,S=1;S<w;S++)f.push(h[S],O[S])}var x=be.withEmotionCache(function(C,$,y){var g=b&&C.as||i,L="",N=[],j=C;if(C.theme==null){j={};for(var Y in C)j[Y]=C[Y];j.theme=Re.useContext(be.ThemeContext)}typeof C.className=="string"?L=a.getRegisteredStyles($.registered,N,C.className):C.className!=null&&(L=C.className+" ");var P=a.serializeStyles(f.concat(N),$.registered,j);L+=$.key+"-"+P.name,c!==void 0&&(L+=" "+c);var _=b&&d===void 0?Nt(g):p,M={};for(var E in C)b&&E==="as"||_(E)&&(M[E]=C[E]);return M.className=L,y&&(M.ref=y),Re.createElement(Re.Fragment,null,Re.createElement(ho,{cache:$,serialized:P,isStringTag:typeof g=="string"}),Re.createElement(g,M))});return x.displayName=l!==void 0?l:"Styled("+(typeof i=="string"?i:i.displayName||i.name||"Component")+")",x.defaultProps=r.defaultProps,x.__emotion_real=x,x.__emotion_base=i,x.__emotion_styles=f,x.__emotion_forwardProp=d,Object.defineProperty(x,"toString",{value:function(){return"."+c}}),x.withComponent=function(C,$){var y=e(C,Ct({},o,$,{shouldForwardProp:Tt(x,$,!0)}));return y.apply(void 0,f)},x}},go=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],s=bo.bind(null);go.forEach(function(e){s[e]=s(e)});const fo=s.span`
|
|
104
104
|
font-size: 12px;
|
|
105
105
|
font-weight: 500;
|
|
106
106
|
color: ${e=>e.$variant==="normal"?t.COLORS.black:t.COLORS.red};
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
border-top-color: ${At.indicator};
|
|
230
230
|
border-radius: 50%;
|
|
231
231
|
animation: ${Lo} 0.8s linear infinite;
|
|
232
|
-
`,Po=T.newClassNameGetter("spinner"),kt=({"aria-label":e="Loading",className:r,ref:o,size:n="md",...i})=>a.jsx(Eo,{...i,ref:o,className:Po("container",r),role:"status","aria-label":e,$size:n}),ke=T.newClassNameGetter("autocomplete"),jo=({className:e,classnames:r,disabled:o,fullWidth:n,label:i,ref:l,size:c="default",variant:d="normal",value:p,onChange:b,onSearch:h,debounceMs:f=300,minChars:
|
|
232
|
+
`,Po=T.newClassNameGetter("spinner"),kt=({"aria-label":e="Loading",className:r,ref:o,size:n="md",...i})=>a.jsx(Eo,{...i,ref:o,className:Po("container",r),role:"status","aria-label":e,$size:n}),ke=T.newClassNameGetter("autocomplete"),jo=({className:e,classnames:r,disabled:o,fullWidth:n,label:i,ref:l,size:c="default",variant:d="normal",value:p,onChange:b,onSearch:h,debounceMs:f=300,minChars:O=1,noResultsMessage:w="No results found",...S})=>{const[x,C]=u.useState((p==null?void 0:p.value)??""),[$,y]=u.useState([]),[g,L]=u.useState(!1),[N,j]=u.useState(!1),[Y,P]=u.useState(!1),_=u.useRef(null),M=u.useRef(null);u.useEffect(()=>{(p==null?void 0:p.value)!==void 0&&C(p.value)},[p==null?void 0:p.value]);const E=u.useCallback(async z=>{if(z.length<O){y([]),P(!1);return}L(!0),P(!0);try{const B=await h(z);y(B),j(!0)}catch{y([])}finally{L(!1)}},[h,O]),A=u.useCallback(z=>{const B=z.target.value;C(B),b==null||b({value:B,image_url:null}),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{E(B)},f)},[b,E,f]),m=u.useCallback(z=>{C(z.value),y([]),j(!1),P(!1),b==null||b({value:z.value,image_url:z.image_url})},[b]),I=u.useCallback(()=>{setTimeout(()=>{j(!1)},150)},[]),R=u.useCallback(()=>{$.length>0&&j(!0)},[$.length]);return u.useEffect(()=>()=>{M.current&&clearTimeout(M.current)},[]),a.jsxs(Oo,{ref:_,className:ke("container",e),$fullWidth:!!n,children:[i&&a.jsx(So,{variant:d,className:ke("label",r==null?void 0:r.label),children:i}),a.jsxs($o,{children:[a.jsx(yo,{...S,ref:l,type:"text",value:x,onChange:A,onBlur:I,onFocus:R,disabled:o,$size:c,$variant:d,className:ke("input",r==null?void 0:r.input)}),g&&a.jsx(Co,{children:a.jsx(kt,{size:"xs"})})]}),a.jsx(mo,{$open:N&&Y,className:ke("dropdown",r==null?void 0:r.dropdown),children:$.length>0?$.map(z=>a.jsxs(wo,{onClick:()=>m(z),className:ke("item",r==null?void 0:r.item),children:[z.image_url&&a.jsx(vo,{src:z.image_url,alt:z.value}),a.jsx(Ro,{children:z.value})]},z.id)):!g&&a.jsx(ko,{children:w})})]})},Dt={compact:{height:"32px",padding:"0 8px",radius:"12px",iconSize:"16px"},default:{height:"40px",padding:"0 12px",radius:"16px",iconSize:"20px"}},_t={normal:{background:{static:t.COLORS["steel-blue"],hover:t.alpha(t.COLORS["steel-blue"],90),active:t.alpha(t.COLORS["steel-blue"],80),disabled:t.alpha(t.COLORS["steel-blue"],50)},color:{static:t.COLORS.white,hover:t.COLORS.white,active:t.COLORS.white,disabled:t.COLORS.white},borderColor:{static:"transparent",hover:"transparent",active:"transparent",disabled:"transparent"}},system:{background:{static:t.COLORS.black,hover:t.alpha(t.COLORS.black,90),active:t.alpha(t.COLORS.black,80),disabled:t.alpha(t.COLORS.black,50)},color:{static:t.COLORS.white,hover:t.COLORS.white,active:t.COLORS.white,disabled:t.COLORS.white},borderColor:{static:"transparent",hover:"transparent",active:"transparent",disabled:"transparent"}},success:{background:{static:t.COLORS.green,hover:t.alpha(t.COLORS.green,90),active:t.alpha(t.COLORS.green,80),disabled:t.alpha(t.COLORS.green,50)},color:{static:t.COLORS.white,hover:t.COLORS.white,active:t.COLORS.white,disabled:t.COLORS.white},borderColor:{static:"transparent",hover:"transparent",active:"transparent",disabled:"transparent"}},warning:{background:{static:t.COLORS.yellow,hover:t.alpha(t.COLORS.yellow,90),active:t.alpha(t.COLORS.yellow,80),disabled:t.alpha(t.COLORS.yellow,50)},color:{static:t.COLORS.black,hover:t.COLORS.black,active:t.COLORS.black,disabled:t.COLORS.black},borderColor:{static:"transparent",hover:"transparent",active:"transparent",disabled:"transparent"}},danger:{background:{static:t.COLORS.red,hover:t.alpha(t.COLORS.red,90),active:t.alpha(t.COLORS.red,80),disabled:t.alpha(t.COLORS.red,50)},color:{static:t.COLORS.white,hover:t.COLORS.white,active:t.COLORS.white,disabled:t.COLORS.white},borderColor:{static:"transparent",hover:"transparent",active:"transparent",disabled:"transparent"}},transparent:{background:{static:t.alpha(t.COLORS["iron-grey"],1),hover:t.alpha(t.COLORS["iron-grey"],5),active:t.alpha(t.COLORS["iron-grey"],10),disabled:t.alpha(t.COLORS["iron-grey"],5)},color:{static:t.COLORS.black,hover:t.COLORS.black,active:t.COLORS.black,disabled:t.alpha(t.COLORS.black,30)},borderColor:{static:t.alpha(t.COLORS["iron-grey"],20),hover:t.alpha(t.COLORS["iron-grey"],20),active:t.alpha(t.COLORS["iron-grey"],20),disabled:t.alpha(t.COLORS["iron-grey"],10)}}},J=e=>{const r=_t[e];return r||_t.normal},re=e=>{const r=Dt[e];return r||Dt.default},zo=e=>e?"auto":"fit-content",No=s.button`
|
|
233
233
|
display: flex;
|
|
234
234
|
gap: 6px;
|
|
235
235
|
text-decoration: none;
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
border-radius: 4px;
|
|
297
297
|
width: fit-content;
|
|
298
298
|
background-color: ${e=>e.$variant==="light"?t.alpha(t.COLORS.white,25):t.alpha(t.COLORS.black,25)};
|
|
299
|
-
`,Mo=T.newClassNameGetter("key-symbol"),yr=({className:e,ref:r,symbol:o,variant:n="light",...i})=>o?a.jsx(_o,{...i,ref:r,className:Mo("container",e),$variant:n,children:o}):null,Mt=T.newClassNameGetter("key-bindings"),Cr=({className:e,classnames:r,keys:o,ref:n,variant:i,...l})=>{const c=u.useMemo(()=>t.getKeySymbols(o),[o]);return c.length===0?null:a.jsx(Do,{...l,ref:n,className:Mt("container",e),children:c.map(d=>a.jsx(yr,{symbol:d,className:Mt("item",r==null?void 0:r.item),variant:i},d))})},Ft=T.newClassNameGetter("button"),De=({children:e,className:r,classnames:o,disabled:n,fullWidth:i,icon:l,loading:c,onClick:d,ref:p=null,keyBindings:b=[],size:h="default",type:f="button",variant:
|
|
299
|
+
`,Mo=T.newClassNameGetter("key-symbol"),yr=({className:e,ref:r,symbol:o,variant:n="light",...i})=>o?a.jsx(_o,{...i,ref:r,className:Mo("container",e),$variant:n,children:o}):null,Mt=T.newClassNameGetter("key-bindings"),Cr=({className:e,classnames:r,keys:o,ref:n,variant:i,...l})=>{const c=u.useMemo(()=>t.getKeySymbols(o),[o]);return c.length===0?null:a.jsx(Do,{...l,ref:n,className:Mt("container",e),children:c.map(d=>a.jsx(yr,{symbol:d,className:Mt("item",r==null?void 0:r.item),variant:i},d))})},Ft=T.newClassNameGetter("button"),De=({children:e,className:r,classnames:o,disabled:n,fullWidth:i,icon:l,loading:c,onClick:d,ref:p=null,keyBindings:b=[],size:h="default",type:f="button",variant:O="normal",...w})=>{const S=u.useRef(null);u.useImperativeHandle(p,()=>S.current,[]),t.useKeyBinding(b,()=>{var C;(C=S.current)==null||C.click()});const x=u.useMemo(()=>{switch(f){case"link":return"button";default:return f}},[f]);return a.jsxs(No,{...w,onClick:d,ref:S,type:x,disabled:n,className:Ft("container",r),$variant:O,$size:h,$fullWidth:!!i,$iconOnly:!!l&&!(e||(b==null?void 0:b.length)>0),children:[c&&a.jsx(Ao,{$size:h}),l&&!c&&a.jsx(To,{$size:h,children:l}),e&&a.jsx(Io,{className:Ft("label",o==null?void 0:o.label),children:e}),a.jsx(Cr,{keys:b,variant:O==="system"?"light":"dark"})]})},Fo=s.div`
|
|
300
300
|
background-color: ${t.COLORS.white};
|
|
301
301
|
border-radius: 16px;
|
|
302
302
|
border: ${e=>e.$border?`1px solid ${t.alpha(t.COLORS["iron-grey"],15)}`:"none"};
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
display: flex;
|
|
431
431
|
flex-direction: column;
|
|
432
432
|
gap: 12px;
|
|
433
|
-
`,nt=T.newClassNameGetter("checkbox-group"),oi=({className:e,classnames:r,disabled:o,label:n,onChange:i,options:l,ref:c,value:d,...p})=>{const b=(h,f)=>{i(f?[...d,h]:d.filter(
|
|
433
|
+
`,nt=T.newClassNameGetter("checkbox-group"),oi=({className:e,classnames:r,disabled:o,label:n,onChange:i,options:l,ref:c,value:d,...p})=>{const b=(h,f)=>{i(f?[...d,h]:d.filter(O=>O!==h))};return a.jsxs(ei,{...p,ref:c,className:nt("container",e),children:[n&&a.jsx(ti,{className:nt("label",r==null?void 0:r.label),$disabled:o,children:n}),a.jsx(ri,{className:nt("options",r==null?void 0:r.options),children:l.map(h=>a.jsx(et,{className:r==null?void 0:r.checkbox,checked:d.includes(h.value),label:h.label,disabled:o,onChange:f=>b(h.value,f.target.checked)},h.value))})]})},Ht={gray:{background:t.alpha(t.COLORS["iron-grey"],10),color:t.COLORS["iron-grey"],deleteHover:t.alpha(t.COLORS["iron-grey"],20)},red:{background:t.alpha(t.COLORS.red,10),color:t.COLORS.red,deleteHover:t.alpha(t.COLORS.red,20)},blue:{background:t.alpha(t.COLORS["steel-blue"],10),color:t.COLORS["steel-blue"],deleteHover:t.alpha(t.COLORS["steel-blue"],20)},black:{background:t.COLORS.black,color:t.COLORS.white,deleteHover:t.alpha(t.COLORS.white,20)}},mt=e=>Ht[e]??Ht.gray,ii=s.span`
|
|
434
434
|
display: inline-flex;
|
|
435
435
|
align-items: center;
|
|
436
436
|
gap: 4px;
|
|
@@ -510,7 +510,7 @@
|
|
|
510
510
|
display: flex;
|
|
511
511
|
align-items: center;
|
|
512
512
|
gap: 8px;
|
|
513
|
-
`,bi=({confirmation:e,onDone:r})=>{const[o,n]=u.useState(!1),[i,l]=u.useState(!1),{message:c,onConfirm:d,onCancel:p,options:b}=e,h=b.confirmLabel||li,f=b.cancelLabel||di,
|
|
513
|
+
`,bi=({confirmation:e,onDone:r})=>{const[o,n]=u.useState(!1),[i,l]=u.useState(!1),{message:c,onConfirm:d,onCancel:p,options:b}=e,h=b.confirmLabel||li,f=b.cancelLabel||di,O=u.useCallback(x=>{n(!0),setTimeout(()=>{x==null||x(),r()},200)},[r]),w=u.useCallback(async()=>{const x=d();if(x instanceof Promise){l(!0);try{await x}finally{l(!1)}}O()},[O,d]),S=u.useCallback(()=>{i||O(p)},[O,i,p]);return u.useEffect(()=>{const x=C=>{C.key==="Escape"&&!i&&S()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[S,i]),a.jsxs(pi,{$isExiting:o,children:[a.jsx(ui,{children:c}),a.jsxs(hi,{children:[a.jsx(De,{variant:"system",size:"compact",onClick:S,disabled:i,children:f}),a.jsx(De,{variant:"danger",size:"compact",onClick:w,loading:i,children:h})]})]})},mr=u.createContext(null),gi=()=>{},fi=({children:e})=>{const[r,o]=u.useState(null),n=u.useCallback((l,c,d,p)=>{o({open:!0,message:l,onConfirm:c,onCancel:d||gi,options:p||{}})},[]),i=u.useCallback(()=>{o(null)},[]);return a.jsxs(mr.Provider,{value:{show:n,hide:i},children:[e,r&&a.jsx(bi,{confirmation:r,onDone:i})]})},xi=()=>{const e=u.useContext(mr);if(!e)throw new Error("useConfirmation must be used within ConfirmationProvider");return e},Ee={sm:`${t.BREAKPOINTS.sm}px`,md:`${t.BREAKPOINTS.md}px`,lg:`${t.BREAKPOINTS.lg}px`,xl:`${t.BREAKPOINTS.xl}px`,"2xl":`${t.BREAKPOINTS["2xl"]}px`},Oi=s.div`
|
|
514
514
|
width: 100%;
|
|
515
515
|
|
|
516
516
|
${t.mediaUp("sm")} {
|
|
@@ -532,7 +532,7 @@
|
|
|
532
532
|
${t.mediaUp("2xl")} {
|
|
533
533
|
max-width: ${Ee["2xl"]};
|
|
534
534
|
}
|
|
535
|
-
`,Si=T.newClassNameGetter("container"),$i=({children:e,className:r,ref:o,...n})=>a.jsx(Oi,{...n,ref:o,className:Si("container",r),children:e}),Ze={compact:{height:"32px",padding:"0 10px",radius:"14px",iconSize:16},default:{height:"40px",padding:"0 14px",radius:"16px",iconSize:20}},Pe={normal:{background:{static:t.alpha(t.COLORS.black,2),disabled:t.alpha(t.COLORS.black,10)},border:{static:t.alpha(t.COLORS.black,60),disabled:t.alpha(t.COLORS.black,10)},color:{static:t.COLORS.black,disabled:t.alpha(t.COLORS.black,65)},placeholder:{static:t.alpha(t.COLORS.black,40),disabled:t.alpha(t.COLORS.black,65)},focus:t.alpha(t.COLORS["iron-grey"],30)},error:{background:{static:t.alpha(t.COLORS.red,2),disabled:t.alpha(t.COLORS.red,10)},border:{static:t.alpha(t.COLORS.red,60),disabled:t.alpha(t.COLORS.red,10)},color:{static:t.COLORS.red,disabled:t.alpha(t.COLORS.red,65)},placeholder:{static:t.alpha(t.COLORS.red,40),disabled:t.alpha(t.COLORS.red,65)},focus:t.alpha(t.COLORS.red,30)}},oe=36,tt=2,yi=12,wr=(e,r,o="en")=>{const n=e.getFullYear(),i=e.getMonth(),l=e.getDate(),c=e.getHours(),d=e.getMinutes(),p=e.getSeconds(),b=c%12||12,h=c>=12,f=new Intl.DateTimeFormat(o,{month:"long"}).format(e),
|
|
535
|
+
`,Si=T.newClassNameGetter("container"),$i=({children:e,className:r,ref:o,...n})=>a.jsx(Oi,{...n,ref:o,className:Si("container",r),children:e}),Ze={compact:{height:"32px",padding:"0 10px",radius:"14px",iconSize:16},default:{height:"40px",padding:"0 14px",radius:"16px",iconSize:20}},Pe={normal:{background:{static:t.alpha(t.COLORS.black,2),disabled:t.alpha(t.COLORS.black,10)},border:{static:t.alpha(t.COLORS.black,60),disabled:t.alpha(t.COLORS.black,10)},color:{static:t.COLORS.black,disabled:t.alpha(t.COLORS.black,65)},placeholder:{static:t.alpha(t.COLORS.black,40),disabled:t.alpha(t.COLORS.black,65)},focus:t.alpha(t.COLORS["iron-grey"],30)},error:{background:{static:t.alpha(t.COLORS.red,2),disabled:t.alpha(t.COLORS.red,10)},border:{static:t.alpha(t.COLORS.red,60),disabled:t.alpha(t.COLORS.red,10)},color:{static:t.COLORS.red,disabled:t.alpha(t.COLORS.red,65)},placeholder:{static:t.alpha(t.COLORS.red,40),disabled:t.alpha(t.COLORS.red,65)},focus:t.alpha(t.COLORS.red,30)}},oe=36,tt=2,yi=12,wr=(e,r,o="en")=>{const n=e.getFullYear(),i=e.getMonth(),l=e.getDate(),c=e.getHours(),d=e.getMinutes(),p=e.getSeconds(),b=c%12||12,h=c>=12,f=new Intl.DateTimeFormat(o,{month:"long"}).format(e),O=new Intl.DateTimeFormat(o,{month:"short"}).format(e),w=new Intl.DateTimeFormat(o,{weekday:"long"}).format(e),S=new Intl.DateTimeFormat(o,{weekday:"short"}).format(e),x=L=>L.toString().padStart(2,"0"),C=L=>L.toString().padStart(2," "),$=L=>`\0${L}\0`,y=[["2006","YEARFOUR",n.toString()],["January","MONTHLONG",f],["Monday","WEEKDAYLONG",w],["Jan","MONTHSHORT",O],["Mon","WEEKDAYSHORT",S],["06","YEARTWO",n.toString().slice(-2)],["01","MONTHPAD",x(i+1)],["_2","DAYSPACE",C(l)],["02","DAYPAD",x(l)],["15","HOURTWENTYFOUR",x(c)],["03","HOURTWELVEPAD",x(b)],["04","MINUTE",x(d)],["05","SECOND",x(p)],["PM","AMPMUP",h?"PM":"AM"],["pm","AMPMLOW",h?"pm":"am"],["1","MONTH",(i+1).toString()],["2","DAY",l.toString()],["3","HOURTWELVE",b.toString()]];let g=r;for(const[L,N]of y)g=g.split(L).join($(N));for(const[,L,N]of y)g=g.split($(L)).join(N);return g},Ci=(e,r)=>new Date(e,r+1,0).getDate(),mi=(e,r)=>new Date(e,r,1).getDay(),wi=(e,r,o=1)=>{const n=Ci(e,r);let l=mi(e,r)-o;l<0&&(l+=7);const c=[];for(let d=0;d<l;d++)c.push(null);for(let d=1;d<=n;d++)c.push(d);for(;c.length<42;)c.push(null);return c},vi=(e,r=1)=>{const o=[];for(let n=0;n<7;n++){const i=(r+n)%7,l=new Date(2024,0,7+i);o.push(new Intl.DateTimeFormat(e,{weekday:"short"}).format(l))}return o},Ri=e=>{const r=[];for(let o=0;o<12;o++){const n=new Date(2024,o,1);r.push(new Intl.DateTimeFormat(e,{month:"short"}).format(n))}return r},Gt=(e,r)=>e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate(),Wt=(e,r)=>e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth(),ki=(e,r)=>e.getFullYear()===r.getFullYear(),Kt=(e,r,o,n,i)=>{const l=new Date(e,r,o);if(n){const c=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(l<c)return!0}if(i){const c=new Date(i.getFullYear(),i.getMonth(),i.getDate());if(l>c)return!0}return!1},Ut=(e,r,o,n)=>{if(o){const i=o.getFullYear(),l=o.getMonth();if(e<i||e===i&&r<l)return!0}if(n){const i=n.getFullYear(),l=n.getMonth();if(e>i||e===i&&r>l)return!0}return!1},Xt=(e,r,o)=>!!(r&&e<r.getFullYear()||o&&e>o.getFullYear()),Li=(e,r=12)=>{const o=e-Math.floor(r/2),n=[];for(let i=0;i<r;i++)n.push(o+i);return n},Ei=e=>{switch(e){case"date":return"02.01.2006";case"month":return"January 2006";case"year":return"2006"}},Pi=s.div`
|
|
536
536
|
position: relative;
|
|
537
537
|
display: inline-flex;
|
|
538
538
|
flex-direction: column;
|
|
@@ -748,7 +748,7 @@
|
|
|
748
748
|
`,Gi=s.div`
|
|
749
749
|
width: ${oe}px;
|
|
750
750
|
height: ${oe}px;
|
|
751
|
-
`,q=T.newClassNameGetter("date-picker"),Ve=4,Wi=300,Ki=({value:e,onChange:r,mode:o="date",displayFormat:n,placeholder:i,locale:l="en",weekStartsOn:c=1,minDate:d,maxDate:p,size:b="default",variant:h="normal",disabled:f=!1,fullWidth:
|
|
751
|
+
`,q=T.newClassNameGetter("date-picker"),Ve=4,Wi=300,Ki=({value:e,onChange:r,mode:o="date",displayFormat:n,placeholder:i,locale:l="en",weekStartsOn:c=1,minDate:d,maxDate:p,size:b="default",variant:h="normal",disabled:f=!1,fullWidth:O=!1,label:w,portalRenderNode:S,open:x,onOpen:C,onClose:$,className:y,classnames:g,ref:L,...N})=>{const j=u.useMemo(()=>new Date,[]),[Y,P]=u.useState(!1),[_,M]=u.useState({top:0,left:0}),[E,A]=u.useState("bottom"),[m,I]=u.useState(()=>o==="year"?"years":o==="month"?"months":"days"),[R,z]=u.useState(()=>e??j),[B,F]=u.useState(()=>((e==null?void 0:e.getFullYear())??j.getFullYear())-6),H=u.useRef(null),k=u.useRef(null),D=u.useRef(null),U=x!==void 0,X=U?x:Y,fe=n??Ei(o),_e=u.useMemo(()=>vi(l,c),[l,c]),rt=u.useMemo(()=>Ri(l),[l]),Br=u.useMemo(()=>wi(R.getFullYear(),R.getMonth(),c),[R,c]),Me=u.useMemo(()=>Li(B+6,12),[B]),Et=u.useMemo(()=>e?wr(e,fe,l):null,[e,fe,l]),Yr=i??fe.replace(/2006|06|January|Jan|01|02/g,"__"),me=u.useCallback(()=>{var ve;if(!k.current)return;const v=k.current.getBoundingClientRect(),V=((ve=D.current)==null?void 0:ve.offsetHeight)??Wi,we=window.innerHeight-v.bottom-Ve,Fe=v.top-Ve,xe=we<V&&Fe>we?"top":"bottom";if(A(xe),S){const Be=xe==="bottom"?v.bottom+Ve:v.top-V-Ve;M({top:Be,left:v.left})}},[S]),Pt=u.useCallback(()=>{if(f)return;U||P(!0),C==null||C(),I(o==="year"?"years":o==="month"?"months":"days");const v=e??j;z(v),F(v.getFullYear()-6)},[f,U,C,o,e,j]),Z=u.useCallback(()=>{U||P(!1),$==null||$()},[U,$]),Vr=u.useCallback(()=>{X?Z():Pt()},[X,Z,Pt]),Hr=u.useCallback(v=>{const V=new Date(R.getFullYear(),R.getMonth(),v);r==null||r(V),Z()},[R,r,Z]),Gr=u.useCallback(v=>{if(o==="month"){const V=new Date(R.getFullYear(),v,1);r==null||r(V),Z()}else z(new Date(R.getFullYear(),v,1)),I("days")},[o,R,r,Z]),Wr=u.useCallback(v=>{if(o==="year"){const V=new Date(v,0,1);r==null||r(V),Z()}else o==="month"?(z(new Date(v,R.getMonth(),1)),I("months")):(z(new Date(v,R.getMonth(),1)),I("months"))},[o,R,r,Z]),Kr=u.useCallback(()=>{z(v=>new Date(v.getFullYear(),v.getMonth()-1,1))},[]),Ur=u.useCallback(()=>{z(v=>new Date(v.getFullYear(),v.getMonth()+1,1))},[]),Xr=u.useCallback(()=>{z(v=>new Date(v.getFullYear()-1,v.getMonth(),1))},[]),qr=u.useCallback(()=>{z(v=>new Date(v.getFullYear()+1,v.getMonth(),1))},[]),Zr=u.useCallback(()=>{F(v=>v-12)},[]),Jr=u.useCallback(()=>{F(v=>v+12)},[]),jt=u.useCallback(()=>{m==="days"?I("months"):m==="months"&&I("years")},[m]);u.useLayoutEffect(()=>{X&&me()},[X,me]),u.useEffect(()=>{const v=xe=>{const ve=xe.target,Be=H.current&&!H.current.contains(ve),io=D.current&&!D.current.contains(ve);S?Be&&io&&Z():Be&&Z()},V=xe=>{xe.key==="Escape"&&Z()},we=()=>{X&&S&&me()},Fe=()=>{X&&S&&me()};return X&&(document.addEventListener("mousedown",v),document.addEventListener("keydown",V),S&&(window.addEventListener("scroll",we,!0),window.addEventListener("resize",Fe))),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",V),window.removeEventListener("scroll",we,!0),window.removeEventListener("resize",Fe)}},[X,Z,S,me]);const Qr=Ze[b].iconSize,eo=()=>a.jsxs(a.Fragment,{children:[a.jsxs(lt,{className:q("header",g==null?void 0:g.header),children:[a.jsx(dt,{onClick:jt,type:"button",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(R)}),a.jsxs(ct,{children:[a.jsx(Oe,{onClick:Kr,type:"button","aria-label":"Previous month",children:a.jsx(a.ChevronLeft,{size:16})}),a.jsx(Oe,{onClick:Ur,type:"button","aria-label":"Next month",children:a.jsx(a.ChevronRight,{size:16})})]})]}),a.jsx(Di,{children:_e.map((v,V)=>a.jsx(_i,{children:v},V))}),a.jsx(Mi,{className:q("grid",g==null?void 0:g.grid),children:Br.map((v,V)=>v===null?a.jsx(Gi,{},V):a.jsx(Fi,{type:"button",className:q("cell",g==null?void 0:g.cell),$selected:e?Gt(e,new Date(R.getFullYear(),R.getMonth(),v)):!1,$today:Gt(j,new Date(R.getFullYear(),R.getMonth(),v)),$disabled:Kt(R.getFullYear(),R.getMonth(),v,d,p),disabled:Kt(R.getFullYear(),R.getMonth(),v,d,p),onClick:()=>Hr(v),children:v},V))})]}),to=()=>a.jsxs(a.Fragment,{children:[a.jsxs(lt,{className:q("header",g==null?void 0:g.header),children:[a.jsx(dt,{onClick:jt,type:"button",children:R.getFullYear()}),a.jsxs(ct,{children:[a.jsx(Oe,{onClick:Xr,type:"button","aria-label":"Previous year",children:a.jsx(a.ChevronLeft,{size:16})}),a.jsx(Oe,{onClick:qr,type:"button","aria-label":"Next year",children:a.jsx(a.ChevronRight,{size:16})})]})]}),a.jsx(Bi,{className:q("grid",g==null?void 0:g.grid),children:rt.map((v,V)=>a.jsx(Yi,{type:"button",className:q("cell",g==null?void 0:g.cell),$selected:e?Wt(e,new Date(R.getFullYear(),V,1)):!1,$current:Wt(j,new Date(R.getFullYear(),V,1)),$disabled:Ut(R.getFullYear(),V,d,p),disabled:Ut(R.getFullYear(),V,d,p),onClick:()=>Gr(V),children:v},V))})]}),ro=()=>a.jsxs(a.Fragment,{children:[a.jsxs(lt,{className:q("header",g==null?void 0:g.header),children:[a.jsxs(dt,{type:"button",style:{cursor:"default"},children:[Me[0]," - ",Me[Me.length-1]]}),a.jsxs(ct,{children:[a.jsx(Oe,{onClick:Zr,type:"button","aria-label":"Previous years",children:a.jsx(a.ChevronLeft,{size:16})}),a.jsx(Oe,{onClick:Jr,type:"button","aria-label":"Next years",children:a.jsx(a.ChevronRight,{size:16})})]})]}),a.jsx(Vi,{className:q("grid",g==null?void 0:g.grid),children:Me.map(v=>a.jsx(Hi,{type:"button",className:q("cell",g==null?void 0:g.cell),$selected:e?ki(e,new Date(v,0,1)):!1,$current:j.getFullYear()===v,$disabled:Xt(v,d,p),disabled:Xt(v,d,p),onClick:()=>Wr(v),children:v},v))})]}),zt=()=>{switch(m){case"days":return eo();case"months":return to();case"years":return ro()}},oo=S?ge.createPortal(a.jsx(Ai,{ref:D,$open:X,$position:E,className:q("calendar",g==null?void 0:g.calendar),style:{top:_.top,left:_.left},children:zt()}),S):a.jsx(Ii,{ref:D,$open:X,$position:E,className:q("calendar",g==null?void 0:g.calendar),children:zt()});return a.jsxs(Pi,{...N,ref:L??H,$fullWidth:O,className:q("container",y),children:[w&&a.jsx(ji,{children:w}),a.jsxs(zi,{ref:k,type:"button",onClick:Vr,disabled:f,$size:b,$variant:h,$disabled:f,$open:X,$hasValue:!!Et,className:q("trigger",g==null?void 0:g.trigger),children:[a.jsx(Ni,{children:Et??Yr}),a.jsx(Ti,{$open:X,children:a.jsx(a.ChevronDown,{size:Qr})})]}),oo]})},Ui={left:t.KEYFRAMES.slideInLeft,right:t.KEYFRAMES.slideInRight,top:t.KEYFRAMES.slideInTop,bottom:t.KEYFRAMES.slideInBottom},Xi=(e,r)=>{switch(e){case"left":return`
|
|
752
752
|
top: 0;
|
|
753
753
|
left: 0;
|
|
754
754
|
height: 100%;
|
|
@@ -810,7 +810,7 @@
|
|
|
810
810
|
opacity 0.15s ease,
|
|
811
811
|
transform 0.15s ease,
|
|
812
812
|
visibility 0.15s;
|
|
813
|
-
`,He=T.newClassNameGetter("dropdown"),Ge=4,on=100,nn=({align:e="left",autoClose:r=!0,children:o,className:n,classnames:i,onClose:l,onOpen:c,open:d,portalRenderNode:p,ref:b,trigger:h,...f})=>{const[
|
|
813
|
+
`,He=T.newClassNameGetter("dropdown"),Ge=4,on=100,nn=({align:e="left",autoClose:r=!0,children:o,className:n,classnames:i,onClose:l,onOpen:c,open:d,portalRenderNode:p,ref:b,trigger:h,...f})=>{const[O,w]=u.useState(!1),[S,x]=u.useState({top:0,left:0}),[C,$]=u.useState("bottom"),y=u.useRef(null),g=u.useRef(null),L=u.useRef(null),N=d!==void 0,j=N?d:O,Y=u.useCallback(()=>{var F,H;if(!g.current)return;const A=g.current.getBoundingClientRect(),m=((F=L.current)==null?void 0:F.offsetHeight)??on,I=((H=L.current)==null?void 0:H.offsetWidth)??160,R=window.innerHeight-A.bottom-Ge,z=A.top-Ge,B=R<m&&z>R?"top":"bottom";if($(B),p){let k;e==="left"?k=A.left:k=A.right-I;const D=B==="bottom"?A.bottom+Ge:A.top-m-Ge;x({top:D,left:k})}},[e,p]),P=u.useCallback(()=>{N?j?l==null||l():c==null||c():w(A=>{const m=!A;return m?c==null||c():l==null||l(),m})},[N,j,l,c]),_=u.useCallback(()=>{N||w(!1),l==null||l()},[N,l]),M=u.useCallback(()=>{r&&_()},[r,_]);u.useLayoutEffect(()=>{j&&Y()},[j,Y]),u.useEffect(()=>{const A=z=>{const B=z.target,F=y.current&&!y.current.contains(B),H=L.current&&!L.current.contains(B);p?F&&H&&_():F&&_()},m=z=>{z.key==="Escape"&&_()},I=()=>{j&&p&&Y()},R=()=>{j&&p&&Y()};return j&&(document.addEventListener("mousedown",A),document.addEventListener("keydown",m),p&&(window.addEventListener("scroll",I,!0),window.addEventListener("resize",R))),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",m),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",R)}},[j,_,p,Y]);const E=p?ge.createPortal(a.jsx(rn,{ref:L,$open:j,$position:C,className:He("content",i==null?void 0:i.content),style:{top:S.top,left:S.left},onClick:M,children:o}),p):a.jsx(tn,{ref:L,$align:e,$open:j,$position:C,className:He("content",i==null?void 0:i.content),onClick:M,children:o});return a.jsxs(Qi,{...f,ref:b??y,className:He("container",n),children:[a.jsx(en,{ref:g,onClick:P,className:He("trigger",i==null?void 0:i.trigger),children:u.cloneElement(h)}),E]})},an=s.div`
|
|
814
814
|
display: inline-flex;
|
|
815
815
|
align-items: center;
|
|
816
816
|
gap: 8px;
|
|
@@ -841,7 +841,7 @@
|
|
|
841
841
|
&:hover {
|
|
842
842
|
opacity: ${({$disabled:e})=>e?.5:1};
|
|
843
843
|
}
|
|
844
|
-
`,cn=({value:e,onChange:r,disabled:o=!1,placeholder:n,className:i,classnames:l,"data-test-id":c})=>{const[d,p]=u.useState(!1),b=u.useRef(null),h=u.useRef(null),f=u.useCallback(()=>{var x;p(!1);const
|
|
844
|
+
`,cn=({value:e,onChange:r,disabled:o=!1,placeholder:n,className:i,classnames:l,"data-test-id":c})=>{const[d,p]=u.useState(!1),b=u.useRef(null),h=u.useRef(null),f=u.useCallback(()=>{var x;p(!1);const S=((x=h.current)==null?void 0:x.textContent)||"";S!==e&&r(S)},[r,e]);u.useEffect(()=>{if(d&&h.current){h.current.focus();const S=document.createRange(),x=window.getSelection();S.selectNodeContents(h.current),S.collapse(!1),x==null||x.removeAllRanges(),x==null||x.addRange(S)}},[d]),u.useEffect(()=>{if(!d)return;const S=x=>{b.current&&!b.current.contains(x.target)&&f()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[d,f]);const O=()=>{o||p(!0)},w=S=>{S.key==="Enter"&&S.metaKey?(S.preventDefault(),f()):S.key==="Escape"&&(h.current&&(h.current.textContent=e),p(!1))};return a.jsxs(an,{ref:b,className:i,"data-test-id":c,children:[a.jsx(ln,{ref:h,className:l==null?void 0:l.text,contentEditable:d,suppressContentEditableWarning:!0,onKeyDown:w,$isEmpty:!e,children:e||n}),a.jsx(dn,{type:"button",className:l==null?void 0:l.button,$disabled:o&&!d,onClick:d?f:O,disabled:o&&!d,"aria-label":d?"Save":"Edit",children:d?a.jsx(a.Check,{size:16}):a.jsx(a.Pencil,{size:14})})]})},sn={normal:t.COLORS["iron-grey"],error:t.COLORS.red,success:t.COLORS.green,warning:t.COLORS.yellow},pn=s.span`
|
|
845
845
|
display: block;
|
|
846
846
|
font-size: 12px;
|
|
847
847
|
font-weight: 500;
|
|
@@ -1121,7 +1121,7 @@
|
|
|
1121
1121
|
${We(r.handlerResizeTopRight[0],"tr")}
|
|
1122
1122
|
${Pn(r.root[0])}
|
|
1123
1123
|
${jn(r.sourceImage[0])}
|
|
1124
|
-
`,n=document.createElement("style");return n.innerHTML=o,document.getElementsByTagName("head")[0].prepend(n),r};let Tn=0;const In=e=>{const r=new Map,o=new Proxy({...e},{set(n,i,l){return Reflect.set(n,i,l),(r.get(i)||[]).forEach(c=>c.action(l,n,i)),!0}});return{getState:()=>({...o}),setState:n=>{for(const i of Object.keys(n)){const l=n[i];l!==void 0&&(o[i]=l)}},subscribe:(n,i)=>{const l=String(++Tn),c=r.get(n)||[];return r.set(n,[...c,{action:i,id:l}]),l},unsubscribe:n=>{for(const[i,l]of r.entries()){const c=l.filter(d=>d.id!==n);if(c.length!==l.length){r.set(i,c);return}}},unsubscribeAll:()=>{r.clear()}}},wt={action:null,sourceBase64:"",fileName:"",sourceHeight:0,sourceWidth:0,frame:{left:0,top:0,width:0,height:0},portal:{left:0,top:0,size:0},emitted:{X:0,Y:0,left:0,top:0,size:0},config:{applyButtonLabel:"Apply",cancelButtonLabel:"Cancel",compression:1,framePadding:3,minPortalSize:50,portalPosition:"center",portalSize:150,outputSize:0,type:"jpeg",maxFileSize:0,allowedTypes:["image/jpeg","image/png","image/gif","image/webp"]}},An=(e={},r={})=>In({...wt,config:{...wt.config,...e},css:Nn(r)}),Dn=(e,r)=>{var S;const o=e(),n=document.querySelector(`.${(S=o.css)==null?void 0:S.body[0]}`);if(!n)return o.frame;const{width:i,height:l}=n.getBoundingClientRect(),c=i/l,d=r.width/r.height;let p,b,h=0,f=0;return c>d?(p=l*d,b=l,f=(i-p)/2):(p=i,b=i*(r.height/r.width),h=(l-b)/2),{width:p,height:b,left:f,top:h}},_n=(e,r,o)=>{const[n,i]=r,l=n+e>o.width?(o.width-e)/2:n,c=i+e>o.height?(o.height-e)/2:i;return[l,c]},Mn=(e,r)=>{const{config:o}=e(),n=Math.min(r.width,r.height)-o.framePadding*2,i=o.portalSize>n?n:o.portalSize;if(Array.isArray(o.portalPosition)&&o.portalPosition.length===2){const[l,c]=_n(i,o.portalPosition,r);return{left:l,top:c,size:i}}return o.portalPosition==="center"?{size:i,left:(r.width-i)/2,top:(r.height-i)/2}:{left:0,top:0,size:i}};var te=(e=>(e.MOVE="MOVE",e.RESIZE_TL="RESIZE_TL",e.RESIZE_TR="RESIZE_TR",e.RESIZE_BR="RESIZE_BR",e.RESIZE_BL="RESIZE_BL",e))(te||{});const Fn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerMove),o.setAttribute("data-action",te.MOVE),o},Bn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeBottomLeft),o.setAttribute("data-action",te.RESIZE_BL),o},Yn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeBottomRight),o.setAttribute("data-action",te.RESIZE_BR),o},Vn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeTopLeft),o.setAttribute("data-action",te.RESIZE_TL),o},Hn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeTopRight),o.setAttribute("data-action",te.RESIZE_TR),o},Gn=e=>{var n;const r=e(),o=document.createElement("img");return K(o,(n=r.css)==null?void 0:n.previewImage),o},Wn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.preview),o.appendChild(Gn(e)),o},Kn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.portal),o.appendChild(Wn(e)),o.appendChild(Fn(e)),o.appendChild(Vn(e)),o.appendChild(Hn(e)),o.appendChild(Bn(e)),o.appendChild(Yn(e)),o},Un=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.portalArea),o.appendChild(Kn(e)),o},Xn=e=>{var n;const r=e(),o=document.createElement("img");return K(o,(n=r.css)==null?void 0:n.sourceImage),o.setAttribute("alt","source"),o.setAttribute("crossOrigin","anonymous"),o.setAttribute("draggable","false"),o.setAttribute("src",r.sourceBase64),o},qn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.body),o.appendChild(Xn(e)),o.appendChild(Un(e)),o},Zn=(e,r)=>{var i;const o=e(),n=document.createElement("div");return K(n,(i=o.css)==null?void 0:i.applyButton),n.setAttribute("role","button"),n.innerText=o.config.applyButtonLabel,n.addEventListener("click",r),n},Jn=(e,r)=>{var i;const o=e(),n=document.createElement("div");return K(n,(i=o.css)==null?void 0:i.cancelButton),n.setAttribute("role","button"),n.innerText=o.config.cancelButtonLabel,n.addEventListener("click",r),n},Qn=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");return K(i,(l=n.css)==null?void 0:l.footer),i.appendChild(Jn(e,o)),i.appendChild(Zn(e,r)),i},ea=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.header),o},ta=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");return K(i,(l=n.css)==null?void 0:l.container),i.appendChild(ea(e)),i.appendChild(qn(e)),i.appendChild(Qn(e,r,o)),i},ra=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");K(i,(l=n.css)==null?void 0:l.root),i.appendChild(ta(e,r,o)),document.body.appendChild(i)},oa=e=>{const r=document.createElement("input");return r.style.display="none",r.setAttribute("type","file"),r.setAttribute("accept","image/x-png,image/jpeg"),r.addEventListener("change",e,!1),document.body.appendChild(r),r},Ie=new Map,ia={header:"header",sourceImage:"sourceImage",portalArea:"portalArea",portal:"portal",previewImage:"previewImage"},pe=(e,r)=>{if(Ie.has(e))return Ie.get(e);if(!r)return null;const o=r[ia[e]],n=document.querySelector(`.${o[0]}`);return Ie.set(e,n),n},na=()=>{Ie.clear()},aa=()=>{Ie.clear()},la=(e,r)=>{const o=pe("header",r.css);o&&(o.innerText=e)},da=(e,r)=>{const o=pe("sourceImage",r.css);o&&(o.setAttribute("src",e),o.style.height=`${r.frame.height}px`,o.style.width=`${r.frame.width}px`,o.style.left=`${r.frame.left}px`,o.style.top=`${r.frame.top}px`);const n=pe("portalArea",r.css);n&&(n.style.height=`${r.frame.height}px`,n.style.width=`${r.frame.width}px`,n.style.left=`${r.frame.left}px`,n.style.top=`${r.frame.top}px`);const i=pe("portal",r.css);i&&(i.style.width=`${r.portal.size}px`,i.style.height=`${r.portal.size}px`,i.style.left=`${r.portal.left}px`,i.style.top=`${r.portal.top}px`);const l=pe("previewImage",r.css);l&&(l.setAttribute("src",e),l.style.height=`${r.frame.height}px`,l.style.width=`${r.frame.width}px`,l.style.marginLeft=`-${r.portal.left}px`,l.style.marginTop=`-${r.portal.top}px`)},ca=(e,r)=>{const o=pe("portal",r.css);o&&(o.style.left=`${e.left}px`,o.style.top=`${e.top}px`,o.style.width=`${e.size}px`,o.style.height=`${e.size}px`);const n=pe("previewImage",r.css);n&&(n.style.marginLeft=`-${e.left}px`,n.style.marginTop=`-${e.top}px`)},st=1,sa=e=>{var w,O;const r=e(),o=document.createElement("canvas"),n=r.frame.width||st,i=r.frame.height||st,l=r.sourceWidth/n,c=r.sourceHeight/i,d=r.portal.left*l,p=r.portal.top*c,b=Math.max(r.portal.size*Math.min(l,c),st),h=r.config.outputSize>0?r.config.outputSize:b;o.width=h,o.height=h;const f=document.querySelector(`.${(w=r.css)==null?void 0:w.sourceImage[0]}`);f&&((O=o.getContext("2d"))==null||O.drawImage(f,d,p,b,b,0,0,h,h));const S=o.toDataURL(`image/${r.config.type}`,r.config.compression);return new Promise((x,C)=>{try{o.toBlob($=>{if(o.remove(),!$){C(new Error(`Failed to create blob for type: image/${r.config.type}`));return}x([S,$])},`image/${r.config.type}`,r.config.compression)}catch($){o.remove(),C($)}})},pa=(e,r,o)=>{const{emitted:n,portal:i,frame:l,config:c}=r();let d=n.left-n.X+e.clientX,p=n.top-n.Y+e.clientY;const b=c.framePadding,h=l.width-c.framePadding-i.size,f=c.framePadding,S=l.height-c.framePadding-i.size;d<b&&(d=b),d>h&&(d=h),p<f&&(p=f),p>S&&(p=S),o({portal:{...i,left:d,top:p}})},ua=(e,r,o)=>{const{action:n,emitted:i,portal:l,frame:c,config:d}=r(),p=e.pageX-i.X,b=e.pageY-i.Y;switch(n){case te.RESIZE_BR:{let h=i.size+Math.max(p,b);return h<d.minPortalSize&&(h=d.minPortalSize),i.top+h>c.height-d.framePadding&&(h=c.height-i.top-d.framePadding),i.left+h>c.width-d.framePadding&&(h=c.width-i.left-d.framePadding),o({portal:{...l,size:h}})}case te.RESIZE_TR:{let h=p+b>0?i.size+p:i.size-b,f=p+b>0?i.top-p:i.top+b;return h<d.minPortalSize&&(f=i.top+i.size-d.minPortalSize,h=d.minPortalSize),i.left+h>c.width-d.framePadding&&(h=c.width-i.left-d.framePadding,f=i.top-c.width+i.left+i.size),f<d.framePadding&&(h=i.top+i.size,f=d.framePadding),o({portal:{...l,top:f,size:h}})}case te.RESIZE_TL:{const h=Math.min(p,b);let f=i.size-h,S=i.left+h,w=i.top+h;if(f<d.minPortalSize){const O=i.size-d.minPortalSize;f=d.minPortalSize,S=i.left+O,w=i.top+O}if(w<d.framePadding){const O=d.framePadding-w;w=d.framePadding,S=S+O,f=f-O}if(S<d.framePadding){const O=d.framePadding-S;S=d.framePadding,w=w+O,f=f-O}return o({portal:{...l,top:w,left:S,size:f}})}case te.RESIZE_BL:{let h=p+b>0?i.size+b:i.size-p,f=p+b>0?i.left-b:i.left+p;return h<d.minPortalSize&&(f=i.left+i.size-d.minPortalSize,h=d.minPortalSize),h+i.top>c.height-d.framePadding&&(f=i.left-c.height+i.top+i.size,h=c.height-i.top-d.framePadding),f<d.framePadding&&(f=d.framePadding,h=i.left+i.size-d.framePadding),o({portal:{...l,left:f,size:h}})}default:return}},qt=e=>{if("touches"in e&&e.touches.length>0){const o=e.touches[0];return{clientX:o.clientX,clientY:o.clientY,pageX:o.pageX,pageY:o.pageY}}if("changedTouches"in e&&e.changedTouches.length>0){const o=e.changedTouches[0];return{clientX:o.clientX,clientY:o.clientY,pageX:o.pageX,pageY:o.pageY}}const r=e;return{clientX:r.clientX,clientY:r.clientY,pageX:r.pageX,pageY:r.pageY}},ha=(e,r)=>{var S,w,O;const o=e(),n=document.querySelector(`.${(S=o.css)==null?void 0:S.portal[0]}`),i=document.querySelector(`.${(w=o.css)==null?void 0:w.portalArea[0]}`),l=document.querySelector(`.${(O=o.css)==null?void 0:O.root[0]}`);let c=null,d=null;const p=x=>{x.preventDefault();const{portal:C}=e(),$=qt(x);if(x.target){const y=x.target.getAttribute("data-action"),g={X:$.pageX,Y:$.pageY,left:C.left,top:C.top,size:C.size};r({action:y,emitted:g})}},b=()=>{const{action:x}=e();c!==null&&(cancelAnimationFrame(c),c=null),d=null,x&&r({action:null})},h=()=>{if(c=null,!d)return;const x=d;d=null;const{action:C}=e();if(C)switch(C){case te.MOVE:pa(x,e,r);break;default:ua(x,e,r)}},f=x=>{const{action:C}=e();C&&(x.preventDefault(),d=qt(x),c===null&&(c=requestAnimationFrame(h)))};return l&&(l.addEventListener("mouseup",b),l.addEventListener("touchend",b),l.addEventListener("touchcancel",b)),n&&(n.addEventListener("mousedown",p),n.addEventListener("touchstart",p,{passive:!1})),i&&(i.addEventListener("mousemove",f),i.addEventListener("touchmove",f,{passive:!1})),()=>{c!==null&&cancelAnimationFrame(c),l&&(l.removeEventListener("mouseup",b),l.removeEventListener("touchend",b),l.removeEventListener("touchcancel",b)),n&&(n.removeEventListener("mousedown",p),n.removeEventListener("touchstart",p)),i&&(i.removeEventListener("mousemove",f),i.removeEventListener("touchmove",f))}},Zt=1024*1024,ba=(e,r)=>{if(!r.allowedTypes.includes(e.type))return`Invalid file type "${e.type}". Allowed types: ${r.allowedTypes.join(", ")}`;if(r.maxFileSize>0&&e.size>r.maxFileSize){const o=(r.maxFileSize/Zt).toFixed(2);return`File size (${(e.size/Zt).toFixed(2)}MB) exceeds maximum allowed size (${o}MB)`}return null},ga=(e,r,o,n,i,l,c)=>{const d=$=>{c?c($):console.error(`HqCropper: ${$}`)};if(!e.target.files||e.target.files.length===0){d("Can't read file input");return}const p=e.target.files[0],{config:b}=r(),h=ba(p,b);if(h){d(h),e.target.value="";return}const f=new FileReader;let S=null;const w=()=>{var g;const $=r(),y=document.querySelector(`.${(g=$.css)==null?void 0:g.root[0]}`);y&&(y.remove(),document.removeEventListener("keydown",O),S==null||S(),aa(),l(),o(wt))},O=$=>{$.key==="Escape"&&r().sourceBase64&&x($)},x=$=>{$.preventDefault(),w()},C=$=>{$.preventDefault();const y=r();sa(r).then(([g,L])=>{n(g,L,y),x($)}).catch(g=>{d(g instanceof Error?g.message:"Failed to crop image")})};f.onload=$=>{const y=new Image;if(!$.target||typeof $.target.result!="string"){d("Can't load result image");return}y.src=$.target.result,y.onerror=()=>{d("Failed to load image")},y.onload=()=>{var N;ra(r,C,x),na(),i("fileName",la),i("sourceBase64",da),i("portal",ca);const g=Dn(r,y),L=Mn(r,g);o({frame:g,portal:L,fileName:p.name,sourceBase64:(N=$.target)==null?void 0:N.result,sourceHeight:y.height,sourceWidth:y.width}),S=ha(r,o),document.addEventListener("keydown",O)}},f.onerror=()=>{d("Failed to read file")},f.readAsDataURL(p),e.target.value=""},fa=(e,r,o,n)=>{const{getState:i,setState:l,subscribe:c,unsubscribeAll:d}=An(r,o),p=oa(b=>ga(b,i,l,e,c,d,n));return{open:()=>p.click()}},ae={portalSize:200,outputSize:400,compression:.9,type:"jpeg",maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/webp"],applyLabel:"Apply",cancelLabel:"Cancel"},Jt="vacano-image-cropper-styles",xa=`
|
|
1124
|
+
`,n=document.createElement("style");return n.innerHTML=o,document.getElementsByTagName("head")[0].prepend(n),r};let Tn=0;const In=e=>{const r=new Map,o=new Proxy({...e},{set(n,i,l){return Reflect.set(n,i,l),(r.get(i)||[]).forEach(c=>c.action(l,n,i)),!0}});return{getState:()=>({...o}),setState:n=>{for(const i of Object.keys(n)){const l=n[i];l!==void 0&&(o[i]=l)}},subscribe:(n,i)=>{const l=String(++Tn),c=r.get(n)||[];return r.set(n,[...c,{action:i,id:l}]),l},unsubscribe:n=>{for(const[i,l]of r.entries()){const c=l.filter(d=>d.id!==n);if(c.length!==l.length){r.set(i,c);return}}},unsubscribeAll:()=>{r.clear()}}},wt={action:null,sourceBase64:"",fileName:"",sourceHeight:0,sourceWidth:0,frame:{left:0,top:0,width:0,height:0},portal:{left:0,top:0,size:0},emitted:{X:0,Y:0,left:0,top:0,size:0},config:{applyButtonLabel:"Apply",cancelButtonLabel:"Cancel",compression:1,framePadding:3,minPortalSize:50,portalPosition:"center",portalSize:150,outputSize:0,type:"jpeg",maxFileSize:0,allowedTypes:["image/jpeg","image/png","image/gif","image/webp"]}},An=(e={},r={})=>In({...wt,config:{...wt.config,...e},css:Nn(r)}),Dn=(e,r)=>{var O;const o=e(),n=document.querySelector(`.${(O=o.css)==null?void 0:O.body[0]}`);if(!n)return o.frame;const{width:i,height:l}=n.getBoundingClientRect(),c=i/l,d=r.width/r.height;let p,b,h=0,f=0;return c>d?(p=l*d,b=l,f=(i-p)/2):(p=i,b=i*(r.height/r.width),h=(l-b)/2),{width:p,height:b,left:f,top:h}},_n=(e,r,o)=>{const[n,i]=r,l=n+e>o.width?(o.width-e)/2:n,c=i+e>o.height?(o.height-e)/2:i;return[l,c]},Mn=(e,r)=>{const{config:o}=e(),n=Math.min(r.width,r.height)-o.framePadding*2,i=o.portalSize>n?n:o.portalSize;if(Array.isArray(o.portalPosition)&&o.portalPosition.length===2){const[l,c]=_n(i,o.portalPosition,r);return{left:l,top:c,size:i}}return o.portalPosition==="center"?{size:i,left:(r.width-i)/2,top:(r.height-i)/2}:{left:0,top:0,size:i}};var te=(e=>(e.MOVE="MOVE",e.RESIZE_TL="RESIZE_TL",e.RESIZE_TR="RESIZE_TR",e.RESIZE_BR="RESIZE_BR",e.RESIZE_BL="RESIZE_BL",e))(te||{});const Fn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerMove),o.setAttribute("data-action",te.MOVE),o},Bn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeBottomLeft),o.setAttribute("data-action",te.RESIZE_BL),o},Yn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeBottomRight),o.setAttribute("data-action",te.RESIZE_BR),o},Vn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeTopLeft),o.setAttribute("data-action",te.RESIZE_TL),o},Hn=e=>{var n;const r=e(),o=document.createElement("span");return K(o,(n=r.css)==null?void 0:n.handlerResizeTopRight),o.setAttribute("data-action",te.RESIZE_TR),o},Gn=e=>{var n;const r=e(),o=document.createElement("img");return K(o,(n=r.css)==null?void 0:n.previewImage),o},Wn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.preview),o.appendChild(Gn(e)),o},Kn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.portal),o.appendChild(Wn(e)),o.appendChild(Fn(e)),o.appendChild(Vn(e)),o.appendChild(Hn(e)),o.appendChild(Bn(e)),o.appendChild(Yn(e)),o},Un=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.portalArea),o.appendChild(Kn(e)),o},Xn=e=>{var n;const r=e(),o=document.createElement("img");return K(o,(n=r.css)==null?void 0:n.sourceImage),o.setAttribute("alt","source"),o.setAttribute("crossOrigin","anonymous"),o.setAttribute("draggable","false"),o.setAttribute("src",r.sourceBase64),o},qn=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.body),o.appendChild(Xn(e)),o.appendChild(Un(e)),o},Zn=(e,r)=>{var i;const o=e(),n=document.createElement("div");return K(n,(i=o.css)==null?void 0:i.applyButton),n.setAttribute("role","button"),n.innerText=o.config.applyButtonLabel,n.addEventListener("click",r),n},Jn=(e,r)=>{var i;const o=e(),n=document.createElement("div");return K(n,(i=o.css)==null?void 0:i.cancelButton),n.setAttribute("role","button"),n.innerText=o.config.cancelButtonLabel,n.addEventListener("click",r),n},Qn=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");return K(i,(l=n.css)==null?void 0:l.footer),i.appendChild(Jn(e,o)),i.appendChild(Zn(e,r)),i},ea=e=>{var n;const r=e(),o=document.createElement("div");return K(o,(n=r.css)==null?void 0:n.header),o},ta=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");return K(i,(l=n.css)==null?void 0:l.container),i.appendChild(ea(e)),i.appendChild(qn(e)),i.appendChild(Qn(e,r,o)),i},ra=(e,r,o)=>{var l;const n=e(),i=document.createElement("div");K(i,(l=n.css)==null?void 0:l.root),i.appendChild(ta(e,r,o)),document.body.appendChild(i)},oa=e=>{const r=document.createElement("input");return r.style.display="none",r.setAttribute("type","file"),r.setAttribute("accept","image/x-png,image/jpeg"),r.addEventListener("change",e,!1),document.body.appendChild(r),r},Ie=new Map,ia={header:"header",sourceImage:"sourceImage",portalArea:"portalArea",portal:"portal",previewImage:"previewImage"},pe=(e,r)=>{if(Ie.has(e))return Ie.get(e);if(!r)return null;const o=r[ia[e]],n=document.querySelector(`.${o[0]}`);return Ie.set(e,n),n},na=()=>{Ie.clear()},aa=()=>{Ie.clear()},la=(e,r)=>{const o=pe("header",r.css);o&&(o.innerText=e)},da=(e,r)=>{const o=pe("sourceImage",r.css);o&&(o.setAttribute("src",e),o.style.height=`${r.frame.height}px`,o.style.width=`${r.frame.width}px`,o.style.left=`${r.frame.left}px`,o.style.top=`${r.frame.top}px`);const n=pe("portalArea",r.css);n&&(n.style.height=`${r.frame.height}px`,n.style.width=`${r.frame.width}px`,n.style.left=`${r.frame.left}px`,n.style.top=`${r.frame.top}px`);const i=pe("portal",r.css);i&&(i.style.width=`${r.portal.size}px`,i.style.height=`${r.portal.size}px`,i.style.left=`${r.portal.left}px`,i.style.top=`${r.portal.top}px`);const l=pe("previewImage",r.css);l&&(l.setAttribute("src",e),l.style.height=`${r.frame.height}px`,l.style.width=`${r.frame.width}px`,l.style.marginLeft=`-${r.portal.left}px`,l.style.marginTop=`-${r.portal.top}px`)},ca=(e,r)=>{const o=pe("portal",r.css);o&&(o.style.left=`${e.left}px`,o.style.top=`${e.top}px`,o.style.width=`${e.size}px`,o.style.height=`${e.size}px`);const n=pe("previewImage",r.css);n&&(n.style.marginLeft=`-${e.left}px`,n.style.marginTop=`-${e.top}px`)},st=1,sa=e=>{var w,S;const r=e(),o=document.createElement("canvas"),n=r.frame.width||st,i=r.frame.height||st,l=r.sourceWidth/n,c=r.sourceHeight/i,d=r.portal.left*l,p=r.portal.top*c,b=Math.max(r.portal.size*Math.min(l,c),st),h=r.config.outputSize>0?r.config.outputSize:b;o.width=h,o.height=h;const f=document.querySelector(`.${(w=r.css)==null?void 0:w.sourceImage[0]}`);f&&((S=o.getContext("2d"))==null||S.drawImage(f,d,p,b,b,0,0,h,h));const O=o.toDataURL(`image/${r.config.type}`,r.config.compression);return new Promise((x,C)=>{try{o.toBlob($=>{if(o.remove(),!$){C(new Error(`Failed to create blob for type: image/${r.config.type}`));return}x([O,$])},`image/${r.config.type}`,r.config.compression)}catch($){o.remove(),C($)}})},pa=(e,r,o)=>{const{emitted:n,portal:i,frame:l,config:c}=r();let d=n.left-n.X+e.clientX,p=n.top-n.Y+e.clientY;const b=c.framePadding,h=l.width-c.framePadding-i.size,f=c.framePadding,O=l.height-c.framePadding-i.size;d<b&&(d=b),d>h&&(d=h),p<f&&(p=f),p>O&&(p=O),o({portal:{...i,left:d,top:p}})},ua=(e,r,o)=>{const{action:n,emitted:i,portal:l,frame:c,config:d}=r(),p=e.pageX-i.X,b=e.pageY-i.Y;switch(n){case te.RESIZE_BR:{let h=i.size+Math.max(p,b);return h<d.minPortalSize&&(h=d.minPortalSize),i.top+h>c.height-d.framePadding&&(h=c.height-i.top-d.framePadding),i.left+h>c.width-d.framePadding&&(h=c.width-i.left-d.framePadding),o({portal:{...l,size:h}})}case te.RESIZE_TR:{let h=p+b>0?i.size+p:i.size-b,f=p+b>0?i.top-p:i.top+b;return h<d.minPortalSize&&(f=i.top+i.size-d.minPortalSize,h=d.minPortalSize),i.left+h>c.width-d.framePadding&&(h=c.width-i.left-d.framePadding,f=i.top-c.width+i.left+i.size),f<d.framePadding&&(h=i.top+i.size,f=d.framePadding),o({portal:{...l,top:f,size:h}})}case te.RESIZE_TL:{const h=Math.min(p,b);let f=i.size-h,O=i.left+h,w=i.top+h;if(f<d.minPortalSize){const S=i.size-d.minPortalSize;f=d.minPortalSize,O=i.left+S,w=i.top+S}if(w<d.framePadding){const S=d.framePadding-w;w=d.framePadding,O=O+S,f=f-S}if(O<d.framePadding){const S=d.framePadding-O;O=d.framePadding,w=w+S,f=f-S}return o({portal:{...l,top:w,left:O,size:f}})}case te.RESIZE_BL:{let h=p+b>0?i.size+b:i.size-p,f=p+b>0?i.left-b:i.left+p;return h<d.minPortalSize&&(f=i.left+i.size-d.minPortalSize,h=d.minPortalSize),h+i.top>c.height-d.framePadding&&(f=i.left-c.height+i.top+i.size,h=c.height-i.top-d.framePadding),f<d.framePadding&&(f=d.framePadding,h=i.left+i.size-d.framePadding),o({portal:{...l,left:f,size:h}})}default:return}},qt=e=>{if("touches"in e&&e.touches.length>0){const o=e.touches[0];return{clientX:o.clientX,clientY:o.clientY,pageX:o.pageX,pageY:o.pageY}}if("changedTouches"in e&&e.changedTouches.length>0){const o=e.changedTouches[0];return{clientX:o.clientX,clientY:o.clientY,pageX:o.pageX,pageY:o.pageY}}const r=e;return{clientX:r.clientX,clientY:r.clientY,pageX:r.pageX,pageY:r.pageY}},ha=(e,r)=>{var O,w,S;const o=e(),n=document.querySelector(`.${(O=o.css)==null?void 0:O.portal[0]}`),i=document.querySelector(`.${(w=o.css)==null?void 0:w.portalArea[0]}`),l=document.querySelector(`.${(S=o.css)==null?void 0:S.root[0]}`);let c=null,d=null;const p=x=>{x.preventDefault();const{portal:C}=e(),$=qt(x);if(x.target){const y=x.target.getAttribute("data-action"),g={X:$.pageX,Y:$.pageY,left:C.left,top:C.top,size:C.size};r({action:y,emitted:g})}},b=()=>{const{action:x}=e();c!==null&&(cancelAnimationFrame(c),c=null),d=null,x&&r({action:null})},h=()=>{if(c=null,!d)return;const x=d;d=null;const{action:C}=e();if(C)switch(C){case te.MOVE:pa(x,e,r);break;default:ua(x,e,r)}},f=x=>{const{action:C}=e();C&&(x.preventDefault(),d=qt(x),c===null&&(c=requestAnimationFrame(h)))};return l&&(l.addEventListener("mouseup",b),l.addEventListener("touchend",b),l.addEventListener("touchcancel",b)),n&&(n.addEventListener("mousedown",p),n.addEventListener("touchstart",p,{passive:!1})),i&&(i.addEventListener("mousemove",f),i.addEventListener("touchmove",f,{passive:!1})),()=>{c!==null&&cancelAnimationFrame(c),l&&(l.removeEventListener("mouseup",b),l.removeEventListener("touchend",b),l.removeEventListener("touchcancel",b)),n&&(n.removeEventListener("mousedown",p),n.removeEventListener("touchstart",p)),i&&(i.removeEventListener("mousemove",f),i.removeEventListener("touchmove",f))}},Zt=1024*1024,ba=(e,r)=>{if(!r.allowedTypes.includes(e.type))return`Invalid file type "${e.type}". Allowed types: ${r.allowedTypes.join(", ")}`;if(r.maxFileSize>0&&e.size>r.maxFileSize){const o=(r.maxFileSize/Zt).toFixed(2);return`File size (${(e.size/Zt).toFixed(2)}MB) exceeds maximum allowed size (${o}MB)`}return null},ga=(e,r,o,n,i,l,c)=>{const d=$=>{c?c($):console.error(`HqCropper: ${$}`)};if(!e.target.files||e.target.files.length===0){d("Can't read file input");return}const p=e.target.files[0],{config:b}=r(),h=ba(p,b);if(h){d(h),e.target.value="";return}const f=new FileReader;let O=null;const w=()=>{var g;const $=r(),y=document.querySelector(`.${(g=$.css)==null?void 0:g.root[0]}`);y&&(y.remove(),document.removeEventListener("keydown",S),O==null||O(),aa(),l(),o(wt))},S=$=>{$.key==="Escape"&&r().sourceBase64&&x($)},x=$=>{$.preventDefault(),w()},C=$=>{$.preventDefault();const y=r();sa(r).then(([g,L])=>{n(g,L,y),x($)}).catch(g=>{d(g instanceof Error?g.message:"Failed to crop image")})};f.onload=$=>{const y=new Image;if(!$.target||typeof $.target.result!="string"){d("Can't load result image");return}y.src=$.target.result,y.onerror=()=>{d("Failed to load image")},y.onload=()=>{var N;ra(r,C,x),na(),i("fileName",la),i("sourceBase64",da),i("portal",ca);const g=Dn(r,y),L=Mn(r,g);o({frame:g,portal:L,fileName:p.name,sourceBase64:(N=$.target)==null?void 0:N.result,sourceHeight:y.height,sourceWidth:y.width}),O=ha(r,o),document.addEventListener("keydown",S)}},f.onerror=()=>{d("Failed to read file")},f.readAsDataURL(p),e.target.value=""},fa=(e,r,o,n)=>{const{getState:i,setState:l,subscribe:c,unsubscribeAll:d}=An(r,o),p=oa(b=>ga(b,i,l,e,c,d,n));return{open:()=>p.click()}},ae={portalSize:200,outputSize:400,compression:.9,type:"jpeg",maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/webp"],applyLabel:"Apply",cancelLabel:"Cancel"},Jt="vacano-image-cropper-styles",xa=`
|
|
1125
1125
|
.vacano-cropper-root {
|
|
1126
1126
|
background-color: rgba(0, 0, 0, 0.5);
|
|
1127
1127
|
backdrop-filter: blur(4px);
|
|
@@ -1169,7 +1169,7 @@
|
|
|
1169
1169
|
.vacano-cropper-apply-button:hover {
|
|
1170
1170
|
background-color: ${t.COLORS["iron-grey"]};
|
|
1171
1171
|
}
|
|
1172
|
-
`,Oa=()=>{if(typeof document>"u"||document.getElementById(Jt))return;const e=document.createElement("style");e.id=Jt,e.textContent=xa,document.head.appendChild(e)},Sa={root:["vacano-cropper-root"],container:["vacano-cropper-container"],header:["vacano-cropper-header"],body:["vacano-cropper-body"],footer:["vacano-cropper-footer"],cancelButton:["vacano-cropper-cancel-button"],applyButton:["vacano-cropper-apply-button"],portal:["vacano-cropper-portal"]},Er=(e={})=>{const{allowedTypes:r=ae.allowedTypes,applyLabel:o=ae.applyLabel,cancelLabel:n=ae.cancelLabel,compression:i=ae.compression,maxFileSize:l=ae.maxFileSize,onCrop:c,onError:d,outputSize:p=ae.outputSize,portalSize:b=ae.portalSize,type:h=ae.type}=e,f=u.useRef(null);return{open:u.useCallback(()=>{f.current||(Oa(),f.current=fa((w,
|
|
1172
|
+
`,Oa=()=>{if(typeof document>"u"||document.getElementById(Jt))return;const e=document.createElement("style");e.id=Jt,e.textContent=xa,document.head.appendChild(e)},Sa={root:["vacano-cropper-root"],container:["vacano-cropper-container"],header:["vacano-cropper-header"],body:["vacano-cropper-body"],footer:["vacano-cropper-footer"],cancelButton:["vacano-cropper-cancel-button"],applyButton:["vacano-cropper-apply-button"],portal:["vacano-cropper-portal"]},Er=(e={})=>{const{allowedTypes:r=ae.allowedTypes,applyLabel:o=ae.applyLabel,cancelLabel:n=ae.cancelLabel,compression:i=ae.compression,maxFileSize:l=ae.maxFileSize,onCrop:c,onError:d,outputSize:p=ae.outputSize,portalSize:b=ae.portalSize,type:h=ae.type}=e,f=u.useRef(null);return{open:u.useCallback(()=>{f.current||(Oa(),f.current=fa((w,S,x)=>{S&&(c==null||c({base64:w,blob:S,state:x}))},{portalSize:b,outputSize:p,compression:i,type:h,maxFileSize:l,allowedTypes:r,applyButtonLabel:o,cancelButtonLabel:n},Sa,w=>{d==null||d({code:"CROPPER_ERROR",message:w})})),f.current.open()},[r,o,n,i,l,c,d,p,b,h])}},pt=T.newClassNameGetter("image-cropper"),$a=({allowedTypes:e,applyLabel:r,buttonLabel:o="Select Image",cancelLabel:n,className:i,classnames:l,compression:c,maxFileSize:d,onCrop:p,onError:b,outputSize:h,portalSize:f,previewSize:O=120,ref:w,type:S,value:x,...C})=>{const[$,y]=u.useState(x??null),{open:g}=Er({allowedTypes:e,applyLabel:r,cancelLabel:n,compression:c,maxFileSize:d,onCrop:L=>{y(L.base64),p==null||p(L)},onError:b,outputSize:h,portalSize:f,type:S});return a.jsxs(bn,{...C,ref:w,className:pt("container",i),children:[a.jsx(gn,{$size:O,className:pt("preview",l==null?void 0:l.preview),children:$?a.jsx("img",{src:$,alt:"Preview"}):a.jsx(fn,{children:"No image"})}),a.jsx(De,{variant:"system",onClick:g,className:pt("button",l==null?void 0:l.button),style:{width:O},children:o})]})},Qt={compact:{height:"32px",padding:"0 10px",radius:"14px",prefixSize:"16px"},default:{height:"40px",padding:"0 14px",radius:"16px",prefixSize:"20px"}},er={normal:{background:{static:t.alpha(t.COLORS.black,2),disabled:t.alpha(t.COLORS.black,10)},border:{static:t.alpha(t.COLORS.black,60),disabled:t.alpha(t.COLORS.black,10)},color:{static:t.COLORS.black,disabled:t.alpha(t.COLORS.black,65)},placeholder:{static:t.alpha(t.COLORS.black,40),disabled:t.alpha(t.COLORS.black,65)},focus:t.alpha(t.COLORS["iron-grey"],30)},error:{background:{static:t.alpha(t.COLORS.red,2),disabled:t.alpha(t.COLORS.red,10)},border:{static:t.alpha(t.COLORS.red,60),disabled:t.alpha(t.COLORS.red,10)},color:{static:t.COLORS.red,disabled:t.alpha(t.COLORS.red,65)},placeholder:{static:t.alpha(t.COLORS.red,40),disabled:t.alpha(t.COLORS.red,65)},focus:t.alpha(t.COLORS.red,30)}},le=e=>er[e]??er.normal,ut=e=>Qt[e]??Qt.default,ya=s.div`
|
|
1173
1173
|
display: grid;
|
|
1174
1174
|
flex-direction: column;
|
|
1175
1175
|
gap: 2px;
|
|
@@ -1297,7 +1297,7 @@
|
|
|
1297
1297
|
color: ${t.COLORS["iron-grey"]};
|
|
1298
1298
|
font-size: 14px;
|
|
1299
1299
|
text-align: center;
|
|
1300
|
-
`,Q=T.newClassNameGetter("multi-select"),Da=({className:e,classnames:r,disabled:o=!1,emptyMessage:n="No options found",label:i,maxVisible:l=1/0,modalTitle:c="Select options",onChange:d,options:p,placeholder:b="Select...",ref:h,searchPlaceholder:f="Search...",value:
|
|
1300
|
+
`,Q=T.newClassNameGetter("multi-select"),Da=({className:e,classnames:r,disabled:o=!1,emptyMessage:n="No options found",label:i,maxVisible:l=1/0,modalTitle:c="Select options",onChange:d,options:p,placeholder:b="Select...",ref:h,searchPlaceholder:f="Search...",value:O,variant:w="normal",...S})=>{const[x,C]=u.useState(!1),[$,y]=u.useState(""),g=u.useMemo(()=>p.filter(E=>O.includes(E.value)),[p,O]),L=u.useMemo(()=>{if(!$.trim())return p;const E=$.toLowerCase().trim();return p.filter(A=>A.label.toLowerCase().includes(E))},[p,$]),N=l===1/0?g:g.slice(0,l),j=g.length-N.length,Y=()=>{o||(C(!0),y(""))},P=()=>{C(!1),y("")},_=E=>{O.includes(E)?d(O.filter(A=>A!==E)):d([...O,E])},M=E=>{d(O.filter(A=>A!==E))};return a.jsxs(Ra,{...S,ref:h,className:Q("container",e),children:[i&&a.jsx(ka,{$variant:w,className:Q("label",r==null?void 0:r.trigger),children:i}),a.jsx(La,{type:"button",$variant:w,$disabled:o,disabled:o,onClick:Y,className:Q("trigger",r==null?void 0:r.trigger),children:g.length===0?a.jsx(Ea,{className:Q("placeholder",r==null?void 0:r.placeholder),children:b}):a.jsxs(a.Fragment,{children:[N.map(E=>a.jsx(Je,{deletable:!0,onDelete:()=>M(E.value),onClick:A=>A.stopPropagation(),className:Q("chip",r==null?void 0:r.chip),children:E.label},E.value)),j>0&&a.jsxs(Je,{variant:"gray",onClick:E=>E.stopPropagation(),className:Q("chip",r==null?void 0:r.chip),children:["+",j]})]})}),a.jsx(jr,{open:x,width:"400px",animated:!0,className:Q("modal",r==null?void 0:r.modal),children:a.jsxs(Pa,{children:[a.jsxs(ja,{children:[a.jsx(za,{children:c}),a.jsx(De,{variant:"transparent",size:"compact",icon:a.jsx(a.X,{}),onClick:P})]}),a.jsx(Pr,{type:"text",value:$,onChange:E=>y(E.target.value),placeholder:f,autoFocus:!0,fullWidth:!0,className:Q("search",r==null?void 0:r.search)}),a.jsx(Na,{className:Q("options",r==null?void 0:r.options),children:L.length===0?a.jsx(Aa,{className:Q("empty",r==null?void 0:r.empty),children:n}):L.map(E=>a.jsxs(Ta,{$disabled:!!E.disabled,className:Q("option",r==null?void 0:r.option),children:[a.jsx(et,{checked:O.includes(E.value),disabled:E.disabled,onChange:()=>_(E.value)}),a.jsx(Ia,{children:E.label})]},E.value))})]})})]})},_a=5e3,rr={default:{background:"#374151",text:t.COLORS.white},success:{background:t.COLORS.green,text:t.COLORS.white},warning:{background:t.COLORS.yellow,text:t.COLORS.white},danger:{background:t.COLORS.red,text:t.COLORS.white},info:{background:t.COLORS["steel-blue"],text:t.COLORS.white}},Nr=u.createContext(null),or=e=>rr[e]??rr.default,Ma=s.div`
|
|
1301
1301
|
position: fixed;
|
|
1302
1302
|
top: 0;
|
|
1303
1303
|
left: 0;
|
|
@@ -1378,7 +1378,7 @@
|
|
|
1378
1378
|
&::selection {
|
|
1379
1379
|
background-color: transparent;
|
|
1380
1380
|
}
|
|
1381
|
-
`,bt=T.newClassNameGetter("otp-code"),Qa=({autoFocus:e,className:r,classnames:o,disabled:n,label:i,length:l=6,onChange:c,ref:d,size:p="default",value:b="",variant:h="normal",...f})=>{const
|
|
1381
|
+
`,bt=T.newClassNameGetter("otp-code"),Qa=({autoFocus:e,className:r,classnames:o,disabled:n,label:i,length:l=6,onChange:c,ref:d,size:p="default",value:b="",variant:h="normal",...f})=>{const O=u.useRef([]);u.useEffect(()=>{e&&O.current[0]&&O.current[0].focus()},[e]);const w=u.useCallback($=>{const y=O.current[$];y&&(y.focus(),y.select())},[]),S=u.useCallback(($,y)=>{const L=y.target.value.replace(/\D/g,"").slice(-1);if(!L)return;const N=b.padEnd(l," ").split(""),j=N.findIndex(M=>M===" "||M===""),Y=j!==-1?j:$;N[Y]=L;const P=N.join("").replace(/ /g,"");c==null||c(P);const _=Y+1;_<l&&w(_)},[b,l,c,w]),x=u.useCallback(($,y)=>{if(y.key==="Backspace"){y.preventDefault();const g=b.split("");g[$]?(g[$]="",c==null||c(g.join(""))):$>0&&(g[$-1]="",c==null||c(g.join("")),w($-1))}else y.key==="ArrowLeft"&&$>0?(y.preventDefault(),w($-1)):y.key==="ArrowRight"&&$<l-1&&(y.preventDefault(),w($+1))},[b,l,c,w]),C=u.useCallback($=>{$.preventDefault();const y=$.clipboardData.getData("text").replace(/\D/g,"").slice(0,l);if(y){c==null||c(y);const g=Math.min(y.length,l-1);w(g)}},[l,c,w]);return a.jsxs(Xa,{ref:d,className:bt("container",r),...f,children:[i&&a.jsx(qa,{variant:h,className:bt("label",o==null?void 0:o.label),children:i}),a.jsx(Za,{$size:p,children:Array.from({length:l}).map(($,y)=>a.jsx(Ja,{ref:g=>{O.current[y]=g},type:"text",inputMode:"numeric",autoComplete:"one-time-code",maxLength:2,disabled:n,value:b[y]??"",onChange:g=>S(y,g),onKeyDown:g=>x(y,g),onPaste:C,onFocus:g=>g.target.select(),$size:p,$variant:h,className:bt("input",o==null?void 0:o.input)},y))})]})},ar={light:{background:t.COLORS.white,border:t.alpha(t.COLORS.black,30),title:t.COLORS.black,description:t.COLORS["iron-grey"]},dark:{background:t.alpha(t.COLORS.white,5),border:t.alpha(t.COLORS.white,30),title:t.COLORS.white,description:"#9ca3af"}},Qe=e=>ar[e]??ar.light,el=s.div`
|
|
1382
1382
|
display: flex;
|
|
1383
1383
|
flex-direction: column;
|
|
1384
1384
|
gap: 16px;
|
|
@@ -1634,13 +1634,20 @@
|
|
|
1634
1634
|
&:hover:not(:disabled) {
|
|
1635
1635
|
background: ${t.alpha(t.COLORS.black,8)};
|
|
1636
1636
|
}
|
|
1637
|
+
|
|
1638
|
+
& > span {
|
|
1639
|
+
overflow: hidden;
|
|
1640
|
+
text-overflow: ellipsis;
|
|
1641
|
+
white-space: nowrap;
|
|
1642
|
+
min-width: 0;
|
|
1643
|
+
}
|
|
1637
1644
|
`,Al=s.span`
|
|
1638
1645
|
display: flex;
|
|
1639
1646
|
align-items: center;
|
|
1640
1647
|
justify-content: center;
|
|
1641
1648
|
flex-shrink: 0;
|
|
1642
1649
|
color: ${t.COLORS.black};
|
|
1643
|
-
`,$e=T.newClassNameGetter("select"),Dl=({className:e,classnames:r,disabled:o=!1,fullWidth:n=!1,label:i,onChange:l,options:c,placeholder:d="Select...",portalRenderNode:p,ref:b,size:h="default",value:f,variant:
|
|
1650
|
+
`,$e=T.newClassNameGetter("select"),Dl=({className:e,classnames:r,disabled:o=!1,fullWidth:n=!1,label:i,onChange:l,options:c,placeholder:d="Select...",portalRenderNode:p,ref:b,size:h="default",value:f,variant:O="normal",...w})=>{const[S,x]=u.useState(!1),[C,$]=u.useState({top:0,left:0,width:0}),y=u.useRef(null),g=u.useRef(null),L=u.useRef(null),N=c.find(m=>m.value===f),j=Math.max(0,c.findIndex(m=>m.value===f)),Y=-(j*ft+ze),P=()=>{if(!g.current||!p)return;const m=g.current.getBoundingClientRect(),I=j*ft+ze;let R=m.top-I;const z=c.length*ft+ze*2,B=8,F=window.innerHeight-z-8;R<B&&(R=B),R>F&&(R=F),$({top:R,left:m.left-ze,width:m.width+ze*2})},_=m=>{var I;l==null||l(m),x(!1),(I=g.current)==null||I.focus()},M=m=>{o||c.length===0||(m.key==="Enter"||m.key===" "?(m.preventDefault(),x(I=>!I)):m.key==="Escape"&&S?(m.preventDefault(),x(!1)):m.key==="ArrowDown"&&!S&&(m.preventDefault(),x(!0)))};u.useLayoutEffect(()=>{S&&p&&P()},[S,p,j,c.length]),u.useEffect(()=>{if(!S)return;const m=z=>{const B=z.target,F=y.current&&!y.current.contains(B),H=L.current&&!L.current.contains(B);p?F&&H&&x(!1):F&&x(!1)},I=()=>{p&&P()},R=()=>{p&&P()};return document.addEventListener("mousedown",m),p&&(window.addEventListener("scroll",I,!0),window.addEventListener("resize",R)),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",R)}},[S,p]);const E=()=>c.map(m=>a.jsxs(Il,{type:"button",role:"option",$selected:m.value===f,$disabled:m.disabled??!1,disabled:m.disabled,"aria-selected":m.value===f,onClick:()=>_(m.value),className:$e("option",r==null?void 0:r.option),children:[a.jsx("span",{children:m.label}),m.value===f&&a.jsx(Al,{children:a.jsx(a.Check,{size:16})})]},m.value)),A=p?ge.createPortal(a.jsx(Tl,{ref:L,role:"listbox",style:{top:C.top,left:C.left,width:C.width},className:$e("dropdown",r==null?void 0:r.dropdown),children:E()}),p):a.jsx(Nl,{ref:L,role:"listbox",style:{top:Y},className:$e("dropdown",r==null?void 0:r.dropdown),children:E()});return a.jsxs(Ll,{...w,ref:m=>{y.current=m,typeof b=="function"?b(m):b&&(b.current=m)},$fullWidth:n,className:$e("container",e),children:[i&&a.jsx(El,{variant:O==="error"?"error":"normal",className:$e("label",r==null?void 0:r.label),children:i}),a.jsxs(Pl,{ref:g,type:"button",$size:h,$variant:O,$disabled:o,$hasValue:!!N,disabled:o,onClick:()=>!o&&c.length>0&&x(m=>!m),onKeyDown:M,"aria-haspopup":"listbox","aria-expanded":S,className:$e("trigger",r==null?void 0:r.trigger),children:[a.jsx(jl,{children:(N==null?void 0:N.label)??d}),a.jsx(zl,{$open:S,children:a.jsx(a.ChevronDown,{size:16})})]}),S&&A]})},hr={positive:t.COLORS.green,negative:t.COLORS.red,neutral:t.COLORS["iron-grey"]},_l=e=>hr[e]??hr.neutral,Ml=s.div`
|
|
1644
1651
|
display: flex;
|
|
1645
1652
|
flex-direction: column;
|
|
1646
1653
|
gap: 4px;
|
|
@@ -1748,7 +1755,7 @@
|
|
|
1748
1755
|
min-width: 16px;
|
|
1749
1756
|
margin: 0 12px;
|
|
1750
1757
|
`}
|
|
1751
|
-
`,Ne=T.newClassNameGetter("stepper"),Jl=({className:e,classnames:r,onChange:o,orientation:n="horizontal",ref:i,steps:l,value:c,...d})=>{const p=u.useMemo(()=>l.findIndex(b=>b.value===c),[l,c]);return a.jsx(Wl,{...d,ref:i,$orientation:n,className:Ne("container",e),children:l.map((b,h)=>{const f=b.value===c,
|
|
1758
|
+
`,Ne=T.newClassNameGetter("stepper"),Jl=({className:e,classnames:r,onChange:o,orientation:n="horizontal",ref:i,steps:l,value:c,...d})=>{const p=u.useMemo(()=>l.findIndex(b=>b.value===c),[l,c]);return a.jsx(Wl,{...d,ref:i,$orientation:n,className:Ne("container",e),children:l.map((b,h)=>{const f=b.value===c,O=h<p,w=h===l.length-1;return a.jsxs(Kl,{$orientation:n,children:[a.jsxs(Ul,{type:"button",$active:f,$completed:O,$clickable:!!o,onClick:()=>o==null?void 0:o(b.value),className:Ne("step",r==null?void 0:r.step),children:[a.jsx(Xl,{$active:f,$completed:O,className:Ne("circle",r==null?void 0:r.circle),children:h+1}),a.jsx(ql,{$active:f,$completed:O,className:Ne("label",r==null?void 0:r.label),children:b.label})]}),!w&&a.jsx(Zl,{$completed:O,$orientation:n,className:Ne("line",r==null?void 0:r.line)})]},b.value)})})},Rt={normal:{border:t.COLORS["iron-grey"],label:t.COLORS.black},error:{border:t.COLORS.red,label:t.COLORS.red}},Ql=s.div`
|
|
1752
1759
|
position: relative;
|
|
1753
1760
|
display: flex;
|
|
1754
1761
|
flex-direction: column;
|
|
@@ -1860,7 +1867,7 @@
|
|
|
1860
1867
|
color: ${t.COLORS["iron-grey"]};
|
|
1861
1868
|
font-size: 14px;
|
|
1862
1869
|
text-align: center;
|
|
1863
|
-
`,ee=T.newClassNameGetter("tags"),qe=4,nd=({className:e,classnames:r,createKey:o="Tab",disabled:n=!1,emptyMessage:i="No options",freeSolo:l=!0,label:c,onChange:d,options:p=[],placeholder:b="Add tag...",portalRenderNode:h,ref:f,value:
|
|
1870
|
+
`,ee=T.newClassNameGetter("tags"),qe=4,nd=({className:e,classnames:r,createKey:o="Tab",disabled:n=!1,emptyMessage:i="No options",freeSolo:l=!0,label:c,onChange:d,options:p=[],placeholder:b="Add tag...",portalRenderNode:h,ref:f,value:O,variant:w="normal",...S})=>{const x=u.useRef(null),C=u.useRef(null),$=u.useRef(null),y=u.useRef(null),[g,L]=u.useState(""),[N,j]=u.useState(!1),[Y,P]=u.useState("bottom"),[_,M]=u.useState({top:0,left:0,width:0}),E=u.useMemo(()=>{const k=p.filter(U=>!O.includes(U.value));if(!g.trim())return k;const D=g.toLowerCase().trim();return k.filter(U=>U.label.toLowerCase().includes(D))},[p,O,g]),A=N&&p.length>0,m=u.useCallback(()=>{var _e;if(!C.current)return;const k=C.current.getBoundingClientRect(),D=((_e=$.current)==null?void 0:_e.offsetHeight)??200,U=window.innerHeight-k.bottom-qe,X=k.top-qe,fe=U<D&&X>U?"top":"bottom";if(P(fe),h){const rt=fe==="bottom"?k.bottom+qe:k.top-D-qe;M({top:rt,left:k.left,width:k.width})}},[h]);u.useEffect(()=>{if(N)return m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[N,m]);const I=u.useCallback(k=>{const D=k.trim();return!D||O.includes(D)?!1:(d([...O,D]),L(""),!0)},[O,d]),R=k=>{if(k.key===o&&g.trim())if(k.preventDefault(),l)I(g);else{const D=E.find(U=>U.label.toLowerCase()===g.toLowerCase().trim());D&&I(D.value)}else k.key==="Backspace"&&!g&&O.length>0&&d(O.slice(0,-1))},z=k=>{var D;I(k),(D=y.current)==null||D.focus()},B=k=>{d(O.filter(D=>D!==k))},F=()=>{var k;n||(k=y.current)==null||k.focus()},H=k=>{const D=p.find(U=>U.value===k);return(D==null?void 0:D.label)??k};return a.jsxs(Ql,{...S,ref:f,className:ee("container",e),children:[c&&a.jsx(ed,{$variant:w,className:ee("label"),children:c}),a.jsxs("div",{ref:x,style:{position:"relative"},children:[a.jsxs(td,{ref:C,$variant:w,$disabled:n,$focused:N,onClick:F,className:ee("trigger",r==null?void 0:r.trigger),children:[O.map(k=>a.jsx(Je,{deletable:!n,onDelete:()=>B(k),className:ee("chip",r==null?void 0:r.chip),children:H(k)},k)),a.jsx(rd,{ref:y,type:"text",value:g,onChange:k=>L(k.target.value),onFocus:()=>j(!0),onBlur:()=>setTimeout(()=>j(!1),150),onKeyDown:R,placeholder:O.length===0?b:"",disabled:n,$disabled:n,className:ee("input",r==null?void 0:r.input)})]}),p.length>0&&(h?ge.createPortal(a.jsx(id,{ref:$,$open:A,$position:Y,style:{top:_.top,left:_.left,width:_.width},className:ee("dropdown",r==null?void 0:r.dropdown),children:E.length===0?a.jsx(gr,{className:ee("empty",r==null?void 0:r.empty),children:i}):E.map(k=>a.jsx(br,{type:"button",onMouseDown:D=>D.preventDefault(),onClick:()=>z(k.value),className:ee("option",r==null?void 0:r.option),children:k.label},k.value))}),h):a.jsx(od,{ref:$,$open:A,$position:Y,className:ee("dropdown",r==null?void 0:r.dropdown),children:E.length===0?a.jsx(gr,{className:ee("empty",r==null?void 0:r.empty),children:i}):E.map(k=>a.jsx(br,{type:"button",onMouseDown:D=>D.preventDefault(),onClick:()=>z(k.value),className:ee("option",r==null?void 0:r.option),children:k.label},k.value))}))]})]})},ad=s.div`
|
|
1864
1871
|
display: flex;
|
|
1865
1872
|
align-items: center;
|
|
1866
1873
|
gap: 6px;
|
|
@@ -1992,7 +1999,7 @@
|
|
|
1992
1999
|
font-weight: 500;
|
|
1993
2000
|
white-space: nowrap;
|
|
1994
2001
|
margin-left: auto;
|
|
1995
|
-
`,Sr=({toast:e,
|
|
2002
|
+
`,Sr=({toast:e,onHide:r})=>{const[o,n]=u.useState(!1),i=()=>{n(!0),setTimeout(()=>{r(e.id)},300)};return u.useEffect(()=>{if(e.duration){const l=setTimeout(()=>{i()},e.duration);return()=>clearTimeout(l)}},[e.duration,e.id]),a.jsxs(fd,{$variant:e.variant,$isExiting:o,children:[a.jsx(xd,{children:e.message}),a.jsx(Od,{onClick:i,children:a.jsx(a.X,{style:{width:16,height:16}})})]})},yd=({toasts:e,queueCount:r,onHide:o})=>{if(e.length===0)return null;const n=e.length-1;return a.jsx(gd,{children:e.map((i,l)=>l===n&&r>0?a.jsxs(Sd,{children:[a.jsx(Sr,{toast:i,onHide:o}),a.jsxs($d,{children:["+",r]})]},i.id):a.jsx(Sr,{toast:i,onHide:o},i.id))})},Cd=({children:e})=>{const[r,o]=u.useReducer(hd,bd),n=u.useCallback((l,c="default",d)=>{const p=`toast-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;o({type:"ADD_TOAST",payload:{id:p,message:l,variant:c,duration:d}})},[]),i=u.useCallback(l=>{o({type:"REMOVE_TOAST",payload:l})},[]);return a.jsxs(Mr.Provider,{value:{show:n,hide:i},children:[e,a.jsx(yd,{toasts:r.toasts,queueCount:r.queue.length,onHide:i})]})},md=()=>{const e=u.useContext(Mr);if(!e)throw new Error("useToastr must be used within ToastProvider");return e},$r={dark:{background:t.COLORS.black,text:t.COLORS.white},light:{background:t.COLORS.white,text:t.COLORS.black,border:t.COLORS.gray},success:{background:t.COLORS.green,text:t.COLORS.white},warning:{background:t.COLORS.yellow,text:t.COLORS.white},danger:{background:t.COLORS.red,text:t.COLORS.white}},Ae=e=>$r[e]??$r.dark,wd=(e,r)=>{const o=Ae(r).background;switch(e){case"top":return`
|
|
1996
2003
|
bottom: -12px;
|
|
1997
2004
|
left: 50%;
|
|
1998
2005
|
margin-left: -6px;
|
|
@@ -2107,5 +2114,5 @@
|
|
|
2107
2114
|
`,Ed=s.div`
|
|
2108
2115
|
position: fixed;
|
|
2109
2116
|
${e=>Fr(e)}
|
|
2110
|
-
`,yt=T.newClassNameGetter("tooltip"),ce=8,Pd=({children:e,className:r,classnames:o,content:n,delay:i=200,placement:l="top",portalRenderNode:c,ref:d,variant:p="dark",...b})=>{const[h,f]=u.useState(!1),[
|
|
2117
|
+
`,yt=T.newClassNameGetter("tooltip"),ce=8,Pd=({children:e,className:r,classnames:o,content:n,delay:i=200,placement:l="top",portalRenderNode:c,ref:d,variant:p="dark",...b})=>{const[h,f]=u.useState(!1),[O,w]=u.useState(null),[S,x]=u.useState(l),[C,$]=u.useState({top:0,left:0}),y=u.useRef(null),g=u.useRef(null),L=u.useCallback(()=>{var z,B;if(!y.current)return;const P=y.current.getBoundingClientRect(),_=((z=g.current)==null?void 0:z.offsetWidth)??100,M=((B=g.current)==null?void 0:B.offsetHeight)??30,E=P.top-ce,A=window.innerHeight-P.bottom-ce,m=P.left-ce,I=window.innerWidth-P.right-ce;let R=l;if(l==="top"&&E<M&&A>E?R="bottom":l==="bottom"&&A<M&&E>A?R="top":l==="left"&&m<_&&I>m?R="right":l==="right"&&I<_&&m>I&&(R="left"),x(R),c){let F,H;switch(R){case"top":F=P.top-M-ce,H=P.left+P.width/2-_/2;break;case"bottom":F=P.bottom+ce,H=P.left+P.width/2-_/2;break;case"left":F=P.top+P.height/2-M/2,H=P.left-_-ce;break;case"right":F=P.top+P.height/2-M/2,H=P.right+ce;break;default:F=0,H=0}const k=8;H=Math.max(k,Math.min(H,window.innerWidth-_-k)),F=Math.max(k,Math.min(F,window.innerHeight-M-k)),$({top:F,left:H})}},[l,c]);u.useLayoutEffect(()=>{h&&L()},[h,L]);const N=()=>{const P=setTimeout(()=>{f(!0)},i);w(P)},j=()=>{O&&(clearTimeout(O),w(null)),f(!1)},Y=c?ge.createPortal(a.jsx(Ed,{ref:g,className:yt("content",o==null?void 0:o.content),$placement:S,$variant:p,$visible:h,style:{top:C.top,left:C.left},children:n}),c):a.jsx(Ld,{ref:g,className:yt("content",o==null?void 0:o.content),$placement:S,$variant:p,$visible:h,children:n});return a.jsxs(Rd,{...b,ref:P=>{y.current=P,typeof d=="function"?d(P):d&&(d.current=P)},className:yt("wrapper",r),onMouseEnter:N,onMouseLeave:j,children:[e,Y]})};exports.BREAKPOINTS=t.BREAKPOINTS;exports.COLORS=t.COLORS;exports.KEYFRAMES=t.KEYFRAMES;exports.KEY_SYMBOLS=t.KEY_SYMBOLS;exports.alpha=t.alpha;exports.getBrowser=t.getBrowser;exports.getKeySymbols=t.getKeySymbols;exports.getOperatingSystem=t.getOperatingSystem;exports.isValid=t.isValid;exports.mediaBetween=t.mediaBetween;exports.mediaDown=t.mediaDown;exports.mediaUp=t.mediaUp;exports.toHEX=t.toHEX;exports.useKeyBinding=t.useKeyBinding;exports.newClassNameGetter=T.newClassNameGetter;exports.Autocomplete=jo;exports.Button=De;exports.Card=Yo;exports.Checkbox=et;exports.CheckboxCard=Qo;exports.CheckboxGroup=oi;exports.Chip=Je;exports.ConfirmationProvider=fi;exports.Container=$i;exports.DatePicker=Ki;exports.Drawer=Ji;exports.Dropdown=nn;exports.EditableText=cn;exports.FieldLabel=ie;exports.FieldMessage=hn;exports.GlobalStyle=lo;exports.ImageCropper=$a;exports.Input=Pr;exports.KeySymbol=yr;exports.KeysBindings=Cr;exports.Modal=jr;exports.MultiSelect=Da;exports.NotificationProvider=Ka;exports.OtpCode=Qa;exports.Panel=nl;exports.Progress=dl;exports.Radio=Lt;exports.RadioCard=Sl;exports.RadioGroup=ml;exports.SaveProgressProvider=Rl;exports.Select=Dl;exports.Spinner=kt;exports.StatusCard=Gl;exports.Stepper=Jl;exports.Tabs=dd;exports.Tags=nd;exports.Textarea=ud;exports.ToastProvider=Cd;exports.Tooltip=Pd;exports.formatDateGo=wr;exports.useConfirmation=xi;exports.useImageCropper=Er;exports.useNotification=Ua;exports.useSaveProgress=kl;exports.useToastr=md;
|
|
2111
2118
|
//# sourceMappingURL=index.cjs.map
|