aha-components 1.8.4 → 1.8.5

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.
Files changed (59) hide show
  1. package/dist/Avatar.esm.js +1 -1
  2. package/dist/Avatar.esm.js.map +1 -1
  3. package/dist/Avatar.js +1 -1
  4. package/dist/Avatar.js.map +1 -1
  5. package/dist/Badge.esm.js +1 -1
  6. package/dist/Badge.esm.js.map +1 -1
  7. package/dist/Badge.js +1 -1
  8. package/dist/Badge.js.map +1 -1
  9. package/dist/Button.esm.js +1 -1
  10. package/dist/Button.esm.js.map +1 -1
  11. package/dist/Button.js +1 -1
  12. package/dist/Button.js.map +1 -1
  13. package/dist/Checkbox.esm.js +1 -1
  14. package/dist/Checkbox.esm.js.map +1 -1
  15. package/dist/Checkbox.js +1 -1
  16. package/dist/Checkbox.js.map +1 -1
  17. package/dist/Input.esm.js +1 -1
  18. package/dist/Input.esm.js.map +1 -1
  19. package/dist/Input.js +1 -1
  20. package/dist/Input.js.map +1 -1
  21. package/dist/Loading.esm.js +1 -1
  22. package/dist/Loading.esm.js.map +1 -1
  23. package/dist/Loading.js +1 -1
  24. package/dist/Loading.js.map +1 -1
  25. package/dist/Pagination.esm.js +1 -1
  26. package/dist/Pagination.esm.js.map +1 -1
  27. package/dist/Pagination.js +1 -1
  28. package/dist/Pagination.js.map +1 -1
  29. package/dist/Popover.esm.js +1 -1
  30. package/dist/Popover.esm.js.map +1 -1
  31. package/dist/Popover.js +1 -1
  32. package/dist/Popover.js.map +1 -1
  33. package/dist/Radio.esm.js +1 -1
  34. package/dist/Radio.esm.js.map +1 -1
  35. package/dist/Radio.js +1 -1
  36. package/dist/Radio.js.map +1 -1
  37. package/dist/Table.esm.js +1 -1
  38. package/dist/Table.esm.js.map +1 -1
  39. package/dist/Table.js +1 -1
  40. package/dist/Table.js.map +1 -1
  41. package/dist/Textarea.esm.js +1 -1
  42. package/dist/Textarea.esm.js.map +1 -1
  43. package/dist/Textarea.js +1 -1
  44. package/dist/Textarea.js.map +1 -1
  45. package/dist/components/Badge/index.d.ts +2 -1
  46. package/dist/components/shared/badgeColors.d.ts +25 -0
  47. package/dist/components/shared/buttonStyles.d.ts +18 -0
  48. package/dist/components/shared/colorUtils.d.ts +6 -0
  49. package/dist/components/shared/controlStyles.d.ts +27 -0
  50. package/dist/components/shared/fieldStyles.d.ts +37 -0
  51. package/dist/index.css +1924 -0
  52. package/dist/index.d.ts +26 -1
  53. package/dist/index.esm.css +1924 -0
  54. package/dist/index.esm.js +1 -1
  55. package/dist/index.esm.js.map +1 -1
  56. package/dist/index.js +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/tokens.d.ts +14 -14
  59. package/package.json +1 -1
package/dist/Input.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import t,{forwardRef as n,useRef as i,useState as l,useEffect as a,createContext as d,useContext as c}from"react";var s=function(){return s=Object.assign||function(e){for(var o,r=1,t=arguments.length;r<t;r++)for(var n in o=arguments[r])Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n]);return e},s.apply(this,arguments)};function p(e,o){var r={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(e);n<t.length;n++)o.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(e,t[n])&&(r[t[n]]=e[t[n]])}return r}function u(e,o,r){if(r||2===arguments.length)for(var t,n=0,i=o.length;n<i;n++)!t&&n in o||(t||(t=Array.prototype.slice.call(o,0,n)),t[n]=o[n]);return e.concat(t||Array.prototype.slice.call(o))}"function"==typeof SuppressedError&&SuppressedError;var h="var(--shadow-xs)",f={small:{pt:"5px",pb:"5px"},mediumSmall:{pt:"7px",pb:"7px"},medium:{pt:"9px",pb:"9px"},large:{pt:"11px",pb:"11px"}},x=n(function(r,t){var n=r.size,d=void 0===n?"mediumSmall":n,c=r.error,u=void 0!==c&&c,x=r.disabled,b=void 0!==x&&x,g=r.readOnly,v=void 0!==g&&g,y=r.prefix,m=r.suffix,F=r.leadingText,S=r.trailingText,w=r.leadingAddon,k=r.trailingAddon,C=r.className,z=void 0===C?"":C,E=r.style,B=r.onFocus,D=r.onBlur,O=r.onKeyDown,P=r.onPressEnter,I=r.value,A=r.defaultValue,T=r.onChange,L=r.placeholder,W=r.type,R=void 0===W?"text":W,H=r.label,G=r.required,j=r.hintText,N=p(r,["size","error","disabled","readOnly","prefix","suffix","leadingText","trailingText","leadingAddon","trailingAddon","className","style","onFocus","onBlur","onKeyDown","onPressEnter","value","defaultValue","onChange","placeholder","type","label","required","hintText"]),M=i(null),q=l(!1),V=q[0],_=q[1],K=l(null!=A?A:""),Y=K[0],J=K[1];a(function(){"function"==typeof t?t(M.current):t&&(t.current=M.current)},[t]);var Q=void 0!==I,U=Q?I:Y,X=b?{border:"1px solid var(--color-border-disabled)",boxShadow:h,outline:"none"}:u&&V?{border:"1px solid var(--color-border-error)",boxShadow:h,outline:"2px solid var(--color-border-error)",outlineOffset:"-2px"}:u?{border:"1px solid var(--color-border-error_subtle)",boxShadow:h,outline:"none"}:V?{border:"1px solid var(--color-border-brand)",boxShadow:h,outline:"2px solid var(--color-border-brand)",outlineOffset:"-2px"}:{border:"1px solid var(--color-border-primary)",boxShadow:h,outline:"none"},Z=X.border,$=X.boxShadow,ee=X.outline,oe=X.outlineOffset,re=f[d],te=re.pt,ne=re.pb,ie=b?"var(--color-border-disabled)":"var(--color-border-primary)",le=!!y,ae=!!m,de={position:"absolute",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:b?"var(--color-fg-disabled)":"var(--color-fg-quaternary)",zIndex:1,pointerEvents:"none"},ce={display:"flex",alignItems:"center",paddingTop:te,paddingBottom:ne,paddingLeft:"14px",paddingRight:"12px",color:"var(--color-text-tertiary)",fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-md)",lineHeight:"var(--line-height-text-md)",whiteSpace:"nowrap",flexShrink:0,backgroundColor:b?"var(--color-bg-disabled_subtle)":"transparent"},se=e("div",{className:"aha-input-group ".concat(z),style:s({display:"flex",alignItems:"stretch",width:"100%",border:Z,boxShadow:$,outline:ee,outlineOffset:oe,borderRadius:"var(--radius-md)",backgroundColor:b||v?"var(--color-bg-disabled_subtle)":"var(--color-bg-primary)",overflow:"hidden",boxSizing:"border-box",transition:"border-color 0.15s ease, box-shadow 0.15s ease"},E),children:[void 0!==F&&o("div",{style:s(s({},ce),{borderRight:"1px solid ".concat(ie)}),children:F}),void 0!==w&&o("div",{style:{display:"flex",alignItems:"stretch",flexShrink:0,borderRight:"1px solid ".concat(ie)},children:w}),e("div",{style:{flex:1,position:"relative",display:"flex",alignItems:"stretch",minWidth:0},children:[le&&o("span",{style:s(s({},de),{left:"14px"}),children:y}),o("input",s({ref:M,type:R,value:U,placeholder:L,disabled:b,readOnly:v,onChange:function(e){Q||J(e.target.value),null==T||T(e)},onFocus:function(e){_(!0),null==B||B(e)},onBlur:function(e){_(!1),null==D||D(e)},onKeyDown:function(e){"Enter"===e.key&&P&&P(e),null==O||O(e)},style:{flex:1,border:"none",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-md)",fontWeight:400,lineHeight:"var(--line-height-text-md)",backgroundColor:"transparent",color:b?"var(--color-text-disabled)":"var(--color-text-primary)",paddingTop:te,paddingBottom:ne,paddingLeft:le?"40px":"14px",paddingRight:ae?"40px":"14px"},autoComplete:N.autoComplete||"off"},N)),ae&&o("span",{style:s(s({},de),{right:"14px"}),children:m})]}),void 0!==S&&o("div",{style:s(s({},ce),{paddingLeft:"12px",paddingRight:"14px",borderLeft:"1px solid ".concat(ie)}),children:S}),void 0!==k&&o("div",{style:{display:"flex",alignItems:"stretch",flexShrink:0,borderLeft:"1px solid ".concat(ie)},children:k})]});if(!H&&!j)return se;var pe={margin:0,fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:400,lineHeight:"20px",color:u?"var(--color-error-600)":"var(--color-text-tertiary)"};return e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[H&&e("label",{style:{fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:500,lineHeight:"20px",color:"var(--color-text-secondary)"},children:[H,G&&o("span",{style:{color:"var(--color-error-600)",marginLeft:"2px"},children:"*"})]}),se,j&&o("p",{style:pe,children:j})]})});x.displayName="InputGroup";var b={primaryColor:"#FB6011"},g=d(b),v={Green:{light:{bg:"#ECFDF5",text:"#006045",border:"#A4F4CF"},fill:{bg:"#00BC7D",text:"#FFFFFF"}},Red:{light:{bg:"#FEF2F2",text:"#9F0712",border:"#FFC9C9"},fill:{bg:"#FB2C36",text:"#FFFFFF"}},Orange:{light:{bg:"#FFF6ED",text:"#9B2911",border:"#FFD1A9"},fill:{bg:"#FB6011",text:"#FFFFFF"}},Cyan:{light:{bg:"#ECFEFF",text:"#005F78",border:"#A2F4FD"},fill:{bg:"#00B8DB",text:"#FFFFFF"}},Violet:{light:{bg:"#F5F3FF",text:"#5D0EC0",border:"#DDD6FF"},fill:{bg:"#8E51FF",text:"#FFFFFF"}},Pink:{light:{bg:"#FDF2F8",text:"#A3004C",border:"#FCCEE8"},fill:{bg:"#F6339A",text:"#FFFFFF"}},Gray:{light:{bg:"#F5F5F4",text:"#292524",border:"#E7E5E4"},fill:{bg:"#292524",text:"#FFFFFF"}},Yellow:{light:{bg:"#FFFBEB",text:"#973C00",border:"#FEE685"},fill:{bg:"#FE9A00",text:"#FFFFFF"}},Blue:{light:{bg:"#EFF6FF",text:"#193CB8",border:"#BEDBFF"},fill:{bg:"#2B7FFF",text:"#FFFFFF"}}},y={sm:{basePx:8,basePy:3,plCheckbox:5,plAvatar:4,plDot:6,plIcon:4,prClose:4,prCount:4,fontSize:12,lineHeight:"18px",height:24,avatarSize:16,checkboxSize:14,contentGap:4,rootGap:3,countPx:4,countFontSize:12,closeSize:10,closePad:2},md:{basePx:9,basePy:2,plCheckbox:4,plAvatar:5,plDot:7,plIcon:5,prClose:4,prCount:3,fontSize:14,lineHeight:"20px",height:24,avatarSize:16,checkboxSize:16,contentGap:5,rootGap:4,countPx:5,countFontSize:12,closeSize:12,closePad:2},lg:{basePx:10,basePy:4,plCheckbox:5,plAvatar:7,plDot:9,plIcon:7,prClose:4,prCount:4,fontSize:14,lineHeight:"20px",height:28,avatarSize:18,checkboxSize:18,contentGap:6,rootGap:4,countPx:6,countFontSize:14,closeSize:14,closePad:3}},m=function(r){var t=r.src,n=r.alt,i=void 0===n?"Avatar":n,a=r.size,d=void 0===a?16:a,c=l(!1),s=c[0],p=c[1];return o("div",{style:{width:d,height:d,borderRadius:"50%",overflow:"hidden",flexShrink:0,border:"0.667px solid rgba(0,0,0,0.08)",background:"#e5e5e4",display:"flex",alignItems:"center",justifyContent:"center"},children:t&&!s?o("img",{src:t,alt:i,onError:function(){return p(!0)},style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):e("svg",{width:.625*d,height:.625*d,viewBox:"0 0 10 10",fill:"none",children:[o("circle",{cx:"5",cy:"3.5",r:"2",stroke:"#999",strokeWidth:"1.2"}),o("path",{d:"M1 9.5c0-2.2 1.8-4 4-4s4 1.8 4 4",stroke:"#999",strokeWidth:"1.2",strokeLinecap:"round"})]})})},F=function(r){var n=r.children,i=r.color,a=r.variant,d=void 0===a?"light":a,u=r.size,h=void 0===u?"md":u,f=r.stroke,x=void 0!==f&&f,F=r.iconType,S=r.icon,w=r.avatarSrc,k=r.dotColor,C=r.action,z=void 0===C?"none":C,E=r.count,B=r.onClose,D=r.checkbox,O=void 0!==D&&D,P=r.checked,I=r.onCheckedChange,A=r.iconPosition,T=r.className,L=void 0===T?"":T,W=r.onClick,R=p(r,["children","color","variant","size","stroke","iconType","icon","avatarSrc","dotColor","action","count","onClose","checkbox","checked","onCheckedChange","iconPosition","className","onClick"]),H=(c(g)||b).primaryColor,G=l(!1),j=G[0],N=G[1],M=function(e){return"large"===e?"lg":"small"===e?"sm":e}(h),q=y[M],V=void 0!==P?P:j,_=null!=F?F:S&&"leading"===A?"icon":"none",K="none"!==z?z:void 0,Y=O?q.plCheckbox:"dot"===_?q.plDot:"avatar"===_||"icon"===_?q.plAvatar:q.basePx,J="x-close"===K?q.prClose:"count"===K?q.prCount:q.basePx,Q={display:"inline-flex",alignItems:"center",gap:"x-close"===K?q.rootGap:0,paddingLeft:Y,paddingRight:J,paddingTop:q.basePy,paddingBottom:q.basePy,height:q.height,borderRadius:6,fontFamily:"DM Sans, sans-serif",fontWeight:500,fontSize:q.fontSize,lineHeight:q.lineHeight,transition:"all 0.2s",cursor:W?"pointer":"default",boxSizing:"border-box",backgroundColor:"#ffffff",color:"#44403c",outline:"1px solid #d7d3d0",outlineOffset:"-1px"};if(i){var U=function(e,o){if(e in v){var r=v[e];return"Orange"===e&&o?s(s({},r),{fill:s(s({},r.fill),{bg:o})}):r}if(e.startsWith("#")){var t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return{light:{bg:"rgba(".concat(t,",").concat(n,",").concat(i,",0.1)"),text:e,border:"rgba(".concat(t,",").concat(n,",").concat(i,",0.3)")},fill:{bg:e,text:"#FFFFFF"}}}return v.Gray}(i,H);"light"===d?(Q.backgroundColor=U.light.bg,Q.color=U.light.text,Q.outline=x?"1px solid ".concat(function(e){var o={Green:"#A4F4CF",Red:"#FFC9C9",Orange:"#FFD1A9",Blue:"#BEDBFF",Yellow:"#FFD1A9",Cyan:"#A2F4FD",Violet:"#DDD6FF",Pink:"#FCCEE8",Gray:"#E7E5E4"};if(e in o)return o[e];if(e.startsWith("#")){var r=parseInt(e.slice(1,3),16),t=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return"rgba(".concat(r,",").concat(t,",").concat(n,",0.3)")}return"#E7E5E4"}(i)):"none",Q.outlineOffset=x?"-1px":void 0):(Q.backgroundColor=U.fill.bg,Q.color=U.fill.text,Q.outline="none")}W&&(Q.cursor="pointer");return e("div",s({className:L,style:Q,onClick:W},R,{children:[e("div",{style:{display:"flex",alignItems:"center",gap:q.contentGap,flexShrink:0},children:[O&&o("div",{role:"checkbox","aria-checked":V,onClick:function(e){e.stopPropagation();var o=!V;void 0===P&&N(o),null==I||I(o)},style:{width:q.checkboxSize,height:q.checkboxSize,borderRadius:4,flexShrink:0,border:V?"none":"1px solid #d7d3d0",background:V?H||"#7F56D9":"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:V&&o("svg",{width:Math.round(.65*q.checkboxSize),height:Math.round(.65*q.checkboxSize),viewBox:"0 0 10 10",fill:"none",children:o("path",{d:"M8.5 2L4 7.5 1.5 5",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),"avatar"===_?o(m,{src:w,size:q.avatarSize}):"dot"===_?o("svg",{width:8,height:8,viewBox:"0 0 8 8",fill:"none",style:{flexShrink:0},children:o("circle",{cx:4,cy:4,r:3.5,fill:k||"currentColor"})}):"icon"===_&&S?o("span",{style:{display:"flex",alignItems:"center",flexShrink:0},children:t.cloneElement(S,{width:q.avatarSize,height:q.avatarSize})}):null,o("span",{style:{whiteSpace:"nowrap"},children:n}),"count"===K&&"number"==typeof E&&o("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:q.countPx,paddingRight:q.countPx,paddingTop:1,paddingBottom:1,background:"rgba(0,0,0,0.07)",borderRadius:3,fontSize:q.countFontSize,fontWeight:500,lineHeight:"16px",flexShrink:0},children:E})]}),"x-close"===K&&o("button",{"aria-label":"Remove",onClick:function(e){e.stopPropagation(),null==B||B()},style:{display:"flex",alignItems:"center",justifyContent:"center",padding:q.closePad,borderRadius:3,border:"none",background:"transparent",cursor:"pointer",flexShrink:0,color:"inherit",opacity:.55,lineHeight:0},children:o("svg",{width:q.closeSize,height:q.closeSize,viewBox:"0 0 10 10",fill:"none",children:o("path",{d:"M7.5 2.5l-5 5M2.5 2.5l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),"after"===A&&S&&!F&&o("span",{style:{display:"flex",alignItems:"center",flexShrink:0,marginLeft:q.contentGap},children:S})]}))},S="var(--shadow-xs)",w={small:"4px",mediumSmall:"6px",medium:"8px",large:"10px"},k={small:"sm",mediumSmall:"sm",medium:"md",large:"lg"},C=function(r){var t=r.value,n=r.defaultValue,a=void 0===n?[]:n,d=r.onChange,c=r.placeholder,p=void 0===c?"Add tag...":c,h=r.disabled,f=void 0!==h&&h,x=r.error,b=void 0!==x&&x,g=r.size,v=void 0===g?"mediumSmall":g,y=r.className,m=void 0===y?"":y,C=r.style,z=r.label,E=r.required,B=r.hintText,D=l(a),O=D[0],P=D[1],I=l(""),A=I[0],T=I[1],L=l(!1),W=L[0],R=L[1],H=i(null),G=void 0!==t,j=G?t:O,N=function(e){G||P(e),null==d||d(e)},M=function(e){var o=e.trim();o&&!j.includes(o)&&(N(u(u([],j,!0),[o],!1)),T(""))},q=function(e){N(j.filter(function(o,r){return r!==e}))},V=f?{border:"1px solid var(--color-border-disabled)",boxShadow:S,outline:"none"}:b&&W?{border:"1px solid var(--color-border-error)",boxShadow:S,outline:"2px solid var(--color-border-error)",outlineOffset:"-2px"}:b?{border:"1px solid var(--color-border-error_subtle)",boxShadow:S,outline:"none"}:W?{border:"1px solid var(--color-border-brand)",boxShadow:S,outline:"2px solid var(--color-border-brand)",outlineOffset:"-2px"}:{border:"1px solid var(--color-border-primary)",boxShadow:S,outline:"none"},_=V.border,K=V.boxShadow,Y=V.outline,J=V.outlineOffset,Q=w[v],U=k[v],X=e("div",{className:"aha-input-tags ".concat(m),onClick:function(){var e;return null===(e=H.current)||void 0===e?void 0:e.focus()},style:s({display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px",padding:Q,border:_,boxShadow:K,outline:Y,outlineOffset:J,borderRadius:"var(--radius-md)",backgroundColor:f?"var(--color-bg-disabled_subtle)":"var(--color-bg-primary)",boxSizing:"border-box",width:"100%",transition:"border-color 0.15s ease, box-shadow 0.15s ease",cursor:f?"not-allowed":"text"},C),children:[j.map(function(e,r){return o(F,{size:U,action:f?"none":"x-close",onClose:function(){return q(r)},children:e},r)}),o("input",{ref:H,value:A,onChange:function(e){return T(e.target.value)},onKeyDown:function(e){"Enter"!==e.key&&","!==e.key||!A||(e.preventDefault(),M(A)),"Backspace"===e.key&&!A&&j.length>0&&q(j.length-1)},onFocus:function(){return R(!0)},onBlur:function(){R(!1),A&&M(A)},disabled:f,placeholder:0===j.length?p:"",style:{flex:1,minWidth:"80px",border:"none",outline:"none",padding:0,fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-md)",lineHeight:"var(--line-height-text-md)",color:f?"var(--color-text-disabled)":"var(--color-text-primary)",backgroundColor:"transparent"}}),o("style",{children:"\n .aha-input-tags input::placeholder { color: var(--color-text-placeholder); }\n "})]});return z||B?e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[z&&e("label",{style:{fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:500,lineHeight:"20px",color:"var(--color-text-secondary)"},children:[z,E&&o("span",{style:{color:"var(--color-error-600)",marginLeft:"2px"},children:"*"})]}),X,B&&o("p",{style:{margin:0,fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:400,lineHeight:"20px",color:b?"var(--color-error-600)":"var(--color-text-tertiary)"},children:B})]}):X},z={small:{height:"36px",paddingTop:"5px",paddingBottom:"5px"},mediumSmall:{height:"40px",paddingTop:"7px",paddingBottom:"7px"},medium:{height:"44px",paddingTop:"9px",paddingBottom:"9px"},large:{height:"48px",paddingTop:"11px",paddingBottom:"11px"}},E="var(--shadow-xs)",B=function(e){var r=e.onClick;return o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",onClick:r,style:{cursor:"pointer",flexShrink:0},children:o("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},D=n(function(n,l){var d=n.size,c=void 0===d?"mediumSmall":d,u=n.disabled,h=void 0!==u&&u,f=n.error,x=void 0!==f&&f,b=n.readOnly,g=void 0!==b&&b,v=n.prefix,y=n.suffix,m=n.allowClear,F=void 0!==m&&m,S=n.onClear,w=n.className,k=void 0===w?"":w,C=n.style,D=n.type,O=void 0===D?"text":D,P=n.placeholder,I=n.value,A=n.defaultValue,T=n.onChange,L=n.onFocus,W=n.onBlur,R=n.onPressEnter,H=n.label,G=n.required,j=n.hintText,N=p(n,["size","disabled","error","readOnly","prefix","suffix","allowClear","onClear","className","style","type","placeholder","value","defaultValue","onChange","onFocus","onBlur","onPressEnter","label","required","hintText"]),M=i(null),q=t.useState(A||I||""),V=q[0],_=q[1],K=t.useState(!1),Y=K[0],J=K[1];a(function(){"function"==typeof l?l(M.current):l&&(l.current=M.current)},[l]);var Q=void 0!==I,U=Q?I:V,X=F&&U&&!h,Z=h?{border:"1px solid var(--color-border-disabled)",boxShadow:E,outline:"none"}:x&&Y?{border:"1px solid var(--color-border-error)",boxShadow:E,outline:"2px solid var(--color-border-error)",outlineOffset:"-2px"}:x?{border:"1px solid var(--color-border-error_subtle)",boxShadow:E,outline:"none"}:Y?{border:"1px solid var(--color-border-brand)",boxShadow:E,outline:"2px solid var(--color-border-brand)",outlineOffset:"-2px"}:{border:"1px solid var(--color-border-primary)",boxShadow:E,outline:"none"},$=Z.border,ee=Z.boxShadow,oe=Z.outline,re=Z.outlineOffset,te=z[c],ne=te.height,ie=te.paddingTop,le=te.paddingBottom,ae=s({width:"100%",height:ne,boxSizing:"border-box",fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-md)",fontWeight:400,lineHeight:"var(--line-height-text-md)",borderRadius:"var(--radius-md)",border:$,boxShadow:ee,backgroundColor:h||g?"var(--color-bg-disabled_subtle)":"var(--color-bg-primary)",color:h?"var(--color-text-disabled)":"var(--color-text-primary)",paddingTop:ie,paddingBottom:le,paddingLeft:v?"40px":"14px",paddingRight:y||X?"40px":"14px",transition:"border-color 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease",outline:oe,outlineOffset:re,WebkitAppearance:"none",MozAppearance:"textfield",appearance:"none"},C),de={position:"absolute",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:h?"var(--color-fg-disabled)":"var(--color-fg-quaternary)",zIndex:1},ce=e(r,{children:[o("style",{children:'\n .aha-input-wrapper input::placeholder {\n color: var(--color-text-placeholder);\n font-size: var(--font-size-text-md);\n font-weight: 400;\n opacity: 1;\n }\n .aha-input-wrapper input::-webkit-input-placeholder { color: var(--color-text-placeholder); }\n .aha-input-wrapper input::-moz-placeholder { color: var(--color-text-placeholder); }\n .aha-input-wrapper input:-ms-input-placeholder { color: var(--color-text-placeholder); }\n .aha-input-wrapper input {\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n touch-action: manipulation;\n }\n .aha-input-wrapper input[type="number"]::-webkit-inner-spin-button,\n .aha-input-wrapper input[type="number"]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n .aha-input-wrapper input[type="number"] { -moz-appearance: textfield; }\n '}),e("div",{className:"aha-input-wrapper ".concat(k),style:{position:"relative",display:"block",width:"100%"},children:[v&&o("span",{style:s(s({},de),{left:"14px",pointerEvents:"none"}),children:v}),o("input",s({ref:M,type:O,value:U,placeholder:P,disabled:h,readOnly:g,onChange:function(e){Q||_(e.target.value),null==T||T(e)},onFocus:function(e){J(!0),null==L||L(e)},onBlur:function(e){J(!1),null==W||W(e)},onKeyDown:function(e){var o;"Enter"===e.key&&R&&R(e),null===(o=N.onKeyDown)||void 0===o||o.call(N,e)},style:ae,autoComplete:N.autoComplete||"off",autoCorrect:N.autoCorrect||"off",autoCapitalize:N.autoCapitalize||"off",spellCheck:N.spellCheck||!1},N)),(y||X)&&e("span",{style:s(s({},de),{right:"14px",gap:"var(--spacing-xs)"}),children:[X&&o(B,{onClick:function(e){var o;e.stopPropagation(),Q||_("");null==T||T({target:{value:""},currentTarget:{value:""}}),null==S||S(),null===(o=M.current)||void 0===o||o.focus()}}),y]})]})]});return H||j?e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[H&&e("label",{style:{fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:500,lineHeight:"20px",color:"var(--color-text-secondary)"},children:[H,G&&o("span",{style:{color:"var(--color-error-600)",marginLeft:"2px"},children:"*"})]}),ce,j&&o("p",{style:{margin:0,fontFamily:"var(--font-family-body)",fontSize:"var(--font-size-text-sm)",fontWeight:400,lineHeight:"20px",color:x?"var(--color-error-600)":"var(--color-text-tertiary)"},children:j})]}):ce});D.displayName="Input";export{x as InputGroup,C as InputTags,D as default};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import n,{createContext as r,useContext as i,forwardRef as l,useRef as a,useState as d,useEffect as c}from"react";var s=function(){return s=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};function p(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}function u(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var f={primaryColor:"#FB6011"},h=r(f),x=function(){var e=i(h);return e||f},g="#1c1917",b="#44403c",y="#57534e",m="#79716b",F="#79716b",v="#d7d3d0",C="#fb6011",S="#f04438",k="#fda29b",w="#d7d3d0",z="#ffffff",D="#fafaf9",P="#a9a29d",E="#a9a29d",B={xs:"12px",sm:"14px",base:"16px",md:"16px",lg:"18px",xl:"20px",displayXs:"24px",displaySm:"30px",displayMd:"36px",displayLg:"48px",displayXl:"60px",display2xl:"72px"},I={xs:"18px",sm:"20px",base:"24px",md:"24px",lg:"28px",xl:"30px",displayXs:"32px",displaySm:"38px",displayMd:"44px",displayLg:"60px",displayXl:"72px",display2xl:"90px"},O={display:'"DM Sans", system-ui, -apple-system, sans-serif',body:'"DM Sans", system-ui, -apple-system, sans-serif',base:'"DM Sans", system-ui, -apple-system, sans-serif'}.body,T=B.md,A=B.sm,L=I.md,R=I.sm,W="8px",G={textPrimary:g,textSecondary:b,textTertiary:y,textDisabled:m,textPlaceholder:F,borderPrimary:v,borderDisabled:w,borderBrand:C,borderError:S,borderErrorSubtle:k,bgPrimary:z,bgDisabledSubtle:D,fgDisabled:E,fgQuaternary:P,error600:"#d92d20"};function M(e){var t=e.disabled,o=void 0!==t&&t,n=e.error,r=void 0!==n&&n,i=e.focused,l=void 0!==i&&i,a=e.brandColor,d=G,c="0px 1px 2px 0px #0a0d120d",s=a||d.borderBrand;return o?{border:"1px solid ".concat(d.borderDisabled),boxShadow:c,outline:"none"}:r&&l?{border:"1px solid ".concat(d.borderError),boxShadow:c,outline:"2px solid ".concat(d.borderError),outlineOffset:"-2px"}:r?{border:"1px solid ".concat(d.borderErrorSubtle),boxShadow:c,outline:"none"}:l?{border:"1px solid ".concat(s),boxShadow:c,outline:"2px solid ".concat(s),outlineOffset:"-2px"}:{border:"1px solid ".concat(d.borderPrimary),boxShadow:c,outline:"none"}}function j(){return{fontFamily:O,fontSize:A,fontWeight:500,lineHeight:R,color:G.textSecondary}}function H(e){return void 0===e&&(e=!1),{margin:0,fontFamily:O,fontSize:A,fontWeight:400,lineHeight:R,color:e?G.error600:G.textTertiary}}function N(e,t,o){return void 0===t&&(t=""),void 0===o&&(o=G.textPlaceholder),"\n ".concat(e,"::placeholder {\n color: ").concat(o,";\n font-size: ").concat(T,";\n font-weight: 400;\n opacity: 1;\n }\n ").concat(e,"::-webkit-input-placeholder { color: ").concat(o,"; }\n ").concat(e,"::-moz-placeholder { color: ").concat(o,"; }\n ").concat(e,":-ms-input-placeholder { color: ").concat(o,"; }\n ").concat(t,"\n ")}var V={small:{pt:"5px",pb:"5px"},mediumSmall:{pt:"7px",pb:"7px"},medium:{pt:"9px",pb:"9px"},large:{pt:"11px",pb:"11px"}},K=l(function(o,n){var r=o.size,i=void 0===r?"mediumSmall":r,l=o.error,u=void 0!==l&&l,f=o.disabled,h=void 0!==f&&f,g=o.readOnly,b=void 0!==g&&g,y=o.prefix,m=o.suffix,F=o.leadingText,v=o.trailingText,C=o.leadingAddon,S=o.trailingAddon,k=o.className,w=void 0===k?"":k,z=o.style,D=o.onFocus,P=o.onBlur,E=o.onKeyDown,B=o.onPressEnter,I=o.value,A=o.defaultValue,R=o.onChange,N=o.placeholder,K=o.type,q=void 0===K?"text":K,X=o.label,Y=o.required,Q=o.hintText,J=p(o,["size","error","disabled","readOnly","prefix","suffix","leadingText","trailingText","leadingAddon","trailingAddon","className","style","onFocus","onBlur","onKeyDown","onPressEnter","value","defaultValue","onChange","placeholder","type","label","required","hintText"]),U=a(null),Z=d(!1),$=Z[0],_=Z[1],ee=d(null!=A?A:""),te=ee[0],oe=ee[1],ne=x().primaryColor;c(function(){"function"==typeof n?n(U.current):n&&(n.current=U.current)},[n]);var re=void 0!==I,ie=re?I:te,le=M({disabled:h,error:u,focused:$,brandColor:ne}),ae=le.border,de=le.boxShadow,ce=le.outline,se=le.outlineOffset,pe=V[i],ue=pe.pt,fe=pe.pb,he=h?G.borderDisabled:G.borderPrimary,xe=!!y,ge=!!m,be={position:"absolute",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:h?G.fgDisabled:G.fgQuaternary,zIndex:1,pointerEvents:"none"},ye={display:"flex",alignItems:"center",paddingTop:ue,paddingBottom:fe,paddingLeft:"14px",paddingRight:"12px",color:G.textTertiary,fontFamily:O,fontSize:T,lineHeight:L,whiteSpace:"nowrap",flexShrink:0,backgroundColor:h?G.bgDisabledSubtle:"transparent"},me=e("div",{className:"aha-input-group ".concat(w),style:s({display:"flex",alignItems:"stretch",width:"100%",border:ae,boxShadow:de,outline:ce,outlineOffset:se,borderRadius:W,backgroundColor:h||b?G.bgDisabledSubtle:G.bgPrimary,overflow:"hidden",boxSizing:"border-box",transition:"border-color 0.15s ease, box-shadow 0.15s ease"},z),children:[void 0!==F&&t("div",{style:s(s({},ye),{borderRight:"1px solid ".concat(he)}),children:F}),void 0!==C&&t("div",{style:{display:"flex",alignItems:"stretch",flexShrink:0,borderRight:"1px solid ".concat(he)},children:C}),e("div",{style:{flex:1,position:"relative",display:"flex",alignItems:"stretch",minWidth:0},children:[xe&&t("span",{style:s(s({},be),{left:"14px"}),children:y}),t("input",s({ref:U,type:q,value:ie,placeholder:N,disabled:h,readOnly:b,onChange:function(e){re||oe(e.target.value),null==R||R(e)},onFocus:function(e){_(!0),null==D||D(e)},onBlur:function(e){_(!1),null==P||P(e)},onKeyDown:function(e){"Enter"===e.key&&B&&B(e),null==E||E(e)},style:{flex:1,border:"none",outline:"none",width:"100%",boxSizing:"border-box",fontFamily:O,fontSize:T,fontWeight:400,lineHeight:L,backgroundColor:"transparent",color:h?G.textDisabled:G.textPrimary,paddingTop:ue,paddingBottom:fe,paddingLeft:xe?"40px":"14px",paddingRight:ge?"40px":"14px"},autoComplete:J.autoComplete||"off"},J)),ge&&t("span",{style:s(s({},be),{right:"14px"}),children:m})]}),void 0!==v&&t("div",{style:s(s({},ye),{paddingLeft:"12px",paddingRight:"14px",borderLeft:"1px solid ".concat(he)}),children:v}),void 0!==S&&t("div",{style:{display:"flex",alignItems:"stretch",flexShrink:0,borderLeft:"1px solid ".concat(he)},children:S})]});return X||Q?e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[X&&e("label",{style:j(),children:[X,Y&&t("span",{style:{color:G.error600,marginLeft:"2px"},children:"*"})]}),me,Q&&t("p",{style:H(u),children:Q})]}):me});K.displayName="InputGroup";var q={Green:{light:{bg:"#ECFDF5",text:"#006045",border:"#A4F4CF"},fill:{bg:"#00BC7D",text:"#FFFFFF"}},Red:{light:{bg:"#FEF2F2",text:"#9F0712",border:"#FFC9C9"},fill:{bg:"#FB2C36",text:"#FFFFFF"}},Orange:{light:{bg:"#FFF6ED",text:"#9B2911",border:"#FFD1A9"},fill:{bg:"#FB6011",text:"#FFFFFF"}},Cyan:{light:{bg:"#ECFEFF",text:"#005F78",border:"#A2F4FD"},fill:{bg:"#00B8DB",text:"#FFFFFF"}},Violet:{light:{bg:"#F5F3FF",text:"#5D0EC0",border:"#DDD6FF"},fill:{bg:"#8E51FF",text:"#FFFFFF"}},Pink:{light:{bg:"#FDF2F8",text:"#A3004C",border:"#FCCEE8"},fill:{bg:"#F6339A",text:"#FFFFFF"}},Gray:{light:{bg:"#F5F5F4",text:"#292524",border:"#E7E5E4"},fill:{bg:"#292524",text:"#FFFFFF"}},Yellow:{light:{bg:"#FFFBEB",text:"#973C00",border:"#FEE685"},fill:{bg:"#FE9A00",text:"#FFFFFF"}},Blue:{light:{bg:"#EFF6FF",text:"#193CB8",border:"#BEDBFF"},fill:{bg:"#2B7FFF",text:"#FFFFFF"}}},X={sm:{basePx:8,basePy:3,plCheckbox:5,plAvatar:4,plDot:6,plIcon:4,prClose:4,prCount:4,fontSize:12,lineHeight:"18px",height:24,avatarSize:16,checkboxSize:14,contentGap:4,rootGap:3,countPx:4,countFontSize:12,closeSize:10,closePad:2},md:{basePx:9,basePy:2,plCheckbox:4,plAvatar:5,plDot:7,plIcon:5,prClose:4,prCount:3,fontSize:14,lineHeight:"20px",height:24,avatarSize:16,checkboxSize:16,contentGap:5,rootGap:4,countPx:5,countFontSize:12,closeSize:12,closePad:2},lg:{basePx:10,basePy:4,plCheckbox:5,plAvatar:7,plDot:9,plIcon:7,prClose:4,prCount:4,fontSize:14,lineHeight:"20px",height:28,avatarSize:18,checkboxSize:18,contentGap:6,rootGap:4,countPx:6,countFontSize:14,closeSize:14,closePad:3}},Y=function(o){var n=o.src,r=o.alt,i=void 0===r?"Avatar":r,l=o.size,a=void 0===l?16:l,c=d(!1),s=c[0],p=c[1];return t("div",{style:{width:a,height:a,borderRadius:"50%",overflow:"hidden",flexShrink:0,border:"0.667px solid rgba(0,0,0,0.08)",background:"#e5e5e4",display:"flex",alignItems:"center",justifyContent:"center"},children:n&&!s?t("img",{src:n,alt:i,onError:function(){return p(!0)},style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):e("svg",{width:.625*a,height:.625*a,viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"3.5",r:"2",stroke:"#999",strokeWidth:"1.2"}),t("path",{d:"M1 9.5c0-2.2 1.8-4 4-4s4 1.8 4 4",stroke:"#999",strokeWidth:"1.2",strokeLinecap:"round"})]})})},Q=function(o){var r=o.children,i=o.color,l=o.variant,a=void 0===l?"light":l,c=o.size,u=void 0===c?"md":c,f=o.stroke,h=void 0!==f&&f,g=o.iconType,b=o.icon,y=o.avatarSrc,m=o.dotColor,F=o.action,v=void 0===F?"none":F,C=o.count,S=o.onClose,k=o.checkbox,w=void 0!==k&&k,z=o.checked,D=o.onCheckedChange,P=o.iconPosition,E=o.className,B=void 0===E?"":E,I=o.onClick,O=p(o,["children","color","variant","size","stroke","iconType","icon","avatarSrc","dotColor","action","count","onClose","checkbox","checked","onCheckedChange","iconPosition","className","onClick"]),T=x().primaryColor,A=d(!1),L=A[0],R=A[1],W=function(e){return"large"===e?"lg":"small"===e?"sm":e}(u),G=X[W],M=void 0!==z?z:L,j=null!=g?g:b&&"leading"===P?"icon":"none",H="none"!==v?v:void 0,N=w?G.plCheckbox:"dot"===j?G.plDot:"avatar"===j||"icon"===j?G.plAvatar:G.basePx,V="x-close"===H?G.prClose:"count"===H?G.prCount:G.basePx,K={display:"inline-flex",alignItems:"center",gap:"x-close"===H?G.rootGap:0,paddingLeft:N,paddingRight:V,paddingTop:G.basePy,paddingBottom:G.basePy,height:G.height,borderRadius:6,fontFamily:"DM Sans, sans-serif",fontWeight:500,fontSize:G.fontSize,lineHeight:G.lineHeight,transition:"all 0.2s",cursor:I?"pointer":"default",boxSizing:"border-box",backgroundColor:"#ffffff",color:"#44403c",outline:"1px solid #d7d3d0",outlineOffset:"-1px"};if(i){var Q=function(e,t){if(e in q){var o=q[e];return"Orange"===e&&t?s(s({},o),{fill:s(s({},o.fill),{bg:t})}):o}if(e.startsWith("#")){var n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return{light:{bg:"rgba(".concat(n,",").concat(r,",").concat(i,",0.1)"),text:e,border:"rgba(".concat(n,",").concat(r,",").concat(i,",0.3)")},fill:{bg:e,text:"#FFFFFF"}}}return q.Gray}(i,T);"light"===a?(K.backgroundColor=Q.light.bg,K.color=Q.light.text,K.outline=h?"1px solid ".concat(function(e){var t={Green:"#A4F4CF",Red:"#FFC9C9",Orange:"#FFD1A9",Blue:"#BEDBFF",Yellow:"#FFD1A9",Cyan:"#A2F4FD",Violet:"#DDD6FF",Pink:"#FCCEE8",Gray:"#E7E5E4"};if(e in t)return t[e];if(e.startsWith("#")){var o=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return"rgba(".concat(o,",").concat(n,",").concat(r,",0.3)")}return"#E7E5E4"}(i)):"none",K.outlineOffset=h?"-1px":void 0):(K.backgroundColor=Q.fill.bg,K.color=Q.fill.text,K.outline="none")}I&&(K.cursor="pointer");return e("div",s({className:B,style:K,onClick:I},O,{children:[e("div",{style:{display:"flex",alignItems:"center",gap:G.contentGap,flexShrink:0},children:[w&&t("div",{role:"checkbox","aria-checked":M,onClick:function(e){e.stopPropagation();var t=!M;void 0===z&&R(t),null==D||D(t)},style:{width:G.checkboxSize,height:G.checkboxSize,borderRadius:4,flexShrink:0,border:M?"none":"1px solid #d7d3d0",background:M?T||"#7F56D9":"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:M&&t("svg",{width:Math.round(.65*G.checkboxSize),height:Math.round(.65*G.checkboxSize),viewBox:"0 0 10 10",fill:"none",children:t("path",{d:"M8.5 2L4 7.5 1.5 5",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),"avatar"===j?t(Y,{src:y,size:G.avatarSize}):"dot"===j?t("svg",{width:8,height:8,viewBox:"0 0 8 8",fill:"none",style:{flexShrink:0},children:t("circle",{cx:4,cy:4,r:3.5,fill:m||"currentColor"})}):"icon"===j&&b?t("span",{style:{display:"flex",alignItems:"center",flexShrink:0},children:n.cloneElement(b,{width:G.avatarSize,height:G.avatarSize})}):null,t("span",{style:{whiteSpace:"nowrap"},children:r}),"count"===H&&"number"==typeof C&&t("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:G.countPx,paddingRight:G.countPx,paddingTop:1,paddingBottom:1,background:"rgba(0,0,0,0.07)",borderRadius:3,fontSize:G.countFontSize,fontWeight:500,lineHeight:"16px",flexShrink:0},children:C})]}),"x-close"===H&&t("button",{"aria-label":"Remove",onClick:function(e){e.stopPropagation(),null==S||S()},style:{display:"flex",alignItems:"center",justifyContent:"center",padding:G.closePad,borderRadius:3,border:"none",background:"transparent",cursor:"pointer",flexShrink:0,color:"inherit",opacity:.55,lineHeight:0},children:t("svg",{width:G.closeSize,height:G.closeSize,viewBox:"0 0 10 10",fill:"none",children:t("path",{d:"M7.5 2.5l-5 5M2.5 2.5l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),"after"===P&&b&&!g&&t("span",{style:{display:"flex",alignItems:"center",flexShrink:0,marginLeft:G.contentGap},children:b})]}))},J={small:"4px",mediumSmall:"6px",medium:"8px",large:"10px"},U={small:"sm",mediumSmall:"sm",medium:"md",large:"lg"},Z=function(o){var n=o.value,r=o.defaultValue,i=void 0===r?[]:r,l=o.onChange,c=o.placeholder,p=void 0===c?"Add tag...":c,f=o.disabled,h=void 0!==f&&f,g=o.error,b=void 0!==g&&g,y=o.size,m=void 0===y?"mediumSmall":y,F=o.className,v=void 0===F?"":F,C=o.style,S=o.label,k=o.required,w=o.hintText,z=d(i),D=z[0],P=z[1],E=d(""),B=E[0],I=E[1],A=d(!1),R=A[0],V=A[1],K=a(null),q=x().primaryColor,X=void 0!==n,Y=X?n:D,Z=function(e){X||P(e),null==l||l(e)},$=function(e){var t=e.trim();t&&!Y.includes(t)&&(Z(u(u([],Y,!0),[t],!1)),I(""))},_=function(e){Z(Y.filter(function(t,o){return o!==e}))},ee=M({disabled:h,error:b,focused:R,brandColor:q}),te=ee.border,oe=ee.boxShadow,ne=ee.outline,re=ee.outlineOffset,ie=J[m],le=U[m],ae=e("div",{className:"aha-input-tags ".concat(v),onClick:function(){var e;return null===(e=K.current)||void 0===e?void 0:e.focus()},style:s({display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px",padding:ie,border:te,boxShadow:oe,outline:ne,outlineOffset:re,borderRadius:W,backgroundColor:h?G.bgDisabledSubtle:G.bgPrimary,boxSizing:"border-box",width:"100%",transition:"border-color 0.15s ease, box-shadow 0.15s ease",cursor:h?"not-allowed":"text"},C),children:[Y.map(function(e,o){return t(Q,{size:le,action:h?"none":"x-close",onClose:function(){return _(o)},children:e},o)}),t("input",{ref:K,value:B,onChange:function(e){return I(e.target.value)},onKeyDown:function(e){"Enter"!==e.key&&","!==e.key||!B||(e.preventDefault(),$(B)),"Backspace"===e.key&&!B&&Y.length>0&&_(Y.length-1)},onFocus:function(){return V(!0)},onBlur:function(){V(!1),B&&$(B)},disabled:h,placeholder:0===Y.length?p:"",style:{flex:1,minWidth:"80px",border:"none",outline:"none",padding:0,fontFamily:O,fontSize:T,lineHeight:L,color:h?G.textDisabled:G.textPrimary,backgroundColor:"transparent"}}),t("style",{children:N(".aha-input-tags input")})]});return S||w?e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[S&&e("label",{style:j(),children:[S,k&&t("span",{style:{color:G.error600,marginLeft:"2px"},children:"*"})]}),ae,w&&t("p",{style:H(b),children:w})]}):ae},$={small:{height:"36px",paddingTop:"5px",paddingBottom:"5px"},mediumSmall:{height:"40px",paddingTop:"7px",paddingBottom:"7px"},medium:{height:"44px",paddingTop:"9px",paddingBottom:"9px"},large:{height:"48px",paddingTop:"11px",paddingBottom:"11px"}},_=function(e){var o=e.onClick;return t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",onClick:o,style:{cursor:"pointer",flexShrink:0},children:t("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},ee=l(function(r,i){var l=r.size,d=void 0===l?"mediumSmall":l,u=r.disabled,f=void 0!==u&&u,h=r.error,g=void 0!==h&&h,b=r.readOnly,y=void 0!==b&&b,m=r.prefix,F=r.suffix,v=r.allowClear,C=void 0!==v&&v,S=r.onClear,k=r.className,w=void 0===k?"":k,z=r.style,D=r.type,P=void 0===D?"text":D,E=r.placeholder,B=r.value,I=r.defaultValue,A=r.onChange,R=r.onFocus,V=r.onBlur,K=r.onPressEnter,q=r.label,X=r.required,Y=r.hintText,Q=p(r,["size","disabled","error","readOnly","prefix","suffix","allowClear","onClear","className","style","type","placeholder","value","defaultValue","onChange","onFocus","onBlur","onPressEnter","label","required","hintText"]),J=a(null),U=n.useState(I||B||""),Z=U[0],ee=U[1],te=n.useState(!1),oe=te[0],ne=te[1],re=x().primaryColor;c(function(){"function"==typeof i?i(J.current):i&&(i.current=J.current)},[i]);var ie=void 0!==B,le=ie?B:Z,ae=C&&le&&!f,de=M({disabled:f,error:g,focused:oe,brandColor:re}),ce=$[d],se=ce.height,pe=ce.paddingTop,ue=ce.paddingBottom,fe=m?"40px":"14px",he=F||ae?"40px":"14px",xe=s(s(s({width:"100%",height:se,boxSizing:"border-box",fontFamily:O,fontSize:T,fontWeight:400,lineHeight:L,borderRadius:W},de),{backgroundColor:f||y?G.bgDisabledSubtle:G.bgPrimary,color:f?G.textDisabled:G.textPrimary,paddingTop:pe,paddingBottom:ue,paddingLeft:fe,paddingRight:he,transition:"border-color 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease",WebkitAppearance:"none",MozAppearance:"textfield",appearance:"none"}),z),ge=N(".aha-input-wrapper input",'\n .aha-input-wrapper input {\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n touch-action: manipulation;\n }\n .aha-input-wrapper input[type="number"]::-webkit-inner-spin-button,\n .aha-input-wrapper input[type="number"]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n .aha-input-wrapper input[type="number"] { -moz-appearance: textfield; }\n '),be={position:"absolute",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",color:f?G.fgDisabled:G.fgQuaternary,zIndex:1},ye=e(o,{children:[t("style",{children:ge}),e("div",{className:"aha-input-wrapper ".concat(w),style:{position:"relative",display:"block",width:"100%"},children:[m&&t("span",{style:s(s({},be),{left:"14px",pointerEvents:"none"}),children:m}),t("input",s({ref:J,type:P,value:le,placeholder:E,disabled:f,readOnly:y,onChange:function(e){ie||ee(e.target.value),null==A||A(e)},onFocus:function(e){ne(!0),null==R||R(e)},onBlur:function(e){ne(!1),null==V||V(e)},onKeyDown:function(e){var t;"Enter"===e.key&&K&&K(e),null===(t=Q.onKeyDown)||void 0===t||t.call(Q,e)},style:xe,autoComplete:Q.autoComplete||"off",autoCorrect:Q.autoCorrect||"off",autoCapitalize:Q.autoCapitalize||"off",spellCheck:Q.spellCheck||!1},Q)),(F||ae)&&e("span",{style:s(s({},be),{right:"14px",gap:"4px"}),children:[ae&&t(_,{onClick:function(e){var t;e.stopPropagation(),ie||ee("");null==A||A({target:{value:""},currentTarget:{value:""}}),null==S||S(),null===(t=J.current)||void 0===t||t.focus()}}),F]})]})]});return q||Y?e("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%"},children:[q&&e("label",{style:j(),children:[q,X&&t("span",{style:{color:G.error600,marginLeft:"2px"},children:"*"})]}),ye,Y&&t("p",{style:H(g),children:Y})]}):ye});ee.displayName="Input";export{K as InputGroup,Z as InputTags,ee as default};
2
2
  //# sourceMappingURL=Input.esm.js.map