@adam-milo/ui 1.0.71 → 1.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index17.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("./index68.cjs"),a=require("./index52.cjs"),s=require("./index53.cjs"),o=require("./index69.cjs"),d=require("./index61.cjs"),l=require("./index70.cjs"),n=r.forwardRef(({label:n,tooltip:i,error:c,helperText:u,fullWidth:x=!1,autoResize:h=!1,minRows:v=3,maxRows:p,showCharCount:g=!1,maxLength:m,validate:y=s.defaultValidation,onValidationChange:f,customHeader:b,customFooterActions:j,borderVariant:w,className:$,id:S,onChange:N,onBlur:C,required:q,value:M,"data-cy":R,"data-testid":B,...E},L)=>{const[k,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("./index68.cjs"),a=require("./index52.cjs"),s=require("./index53.cjs"),o=require("./index69.cjs"),d=require("./index61.cjs"),l=require("./index70.cjs"),n=r.forwardRef(({label:n,tooltip:i,error:c,helperText:u,fullWidth:x=!1,autoResize:h=!1,minRows:v=3,maxRows:p,showCharCount:g=!1,maxLength:m,validate:y=s.defaultValidation,onValidationChange:f,customHeader:b,customFooterActions:j,borderVariant:w,className:$,id:S,onChange:N,onBlur:C,required:q,value:M,"data-cy":R,"data-testid":B,...E},L)=>{const[k,I]=r.useState(),[T,F]=r.useState(!1),[V,_]=r.useState(!1),[H,P]=r.useState(0),W=r.useRef(!1),z=r.useRef(null),A=d.useMergedRef(L,z),O=r.useId(),D=S||O,G=`${D}-error`,J=`${D}-helper`,K=R||"textarea",Q=B||"textarea",U=n&&q&&!n.includes("*")?`${n} *`:n,X=r.useCallback(()=>{const e=z.current;if(!e||!h)return;e.style.height="auto";const r=window.getComputedStyle(e),t=parseInt(r.lineHeight)||22,a=parseInt(r.paddingTop)||0,s=parseInt(r.paddingBottom)||0,o=t*v+a+s,d=p?t*p+a+s:1/0,l=Math.min(Math.max(e.scrollHeight,o),d);e.style.height=`${l}px`},[h,v,p]);r.useEffect(()=>{X()},[M,X]);const Y=r.useMemo(()=>l.debounce(e=>{if(y&&W.current){const r=y(e);I(r),f?.(!r)}else null===y&&W.current&&(I(void 0),f?.(!0))},300),[y,f]),Z=r.useRef(Y);r.useEffect(()=>{Z.current=Y},[Y]),r.useEffect(()=>()=>{Z.current.cancel()},[]),r.useEffect(()=>{P((M||"").length)},[M]);const ee=e=>{const r=e.target.value;P(r.length),N?.(e),h&&X(),W.current&&Y(r)},re=e=>{F(!0),E.onFocus?.(e)},te=e=>{if(F(!1),W.current=!0,y){const r=y(e.target.value);I(r),f?.(!r)}C?.(e)},ae=()=>_(!0),se=()=>_(!1),oe=c||k,de=E.disabled?"disabled":oe?"error":T?"focus":V?"hover":"idle",le=m&&H>m,ne=g||u&&!oe,ie=(()=>{if(!w)return"";if("green-accent"===w){return`relative ${T||V?"shadow-[0_0.25rem_1rem_0_var(--shadow-color-sm)]":""}`}return""})(),ce="green-accent"===w?{background:"linear-gradient(var(--color-card), var(--color-card)) padding-box, var(--gradient-green-blue) border-box",border:T||V?"2px solid transparent":"1px solid transparent"}:{};return e.jsxs("div",{className:a.cn(o.wrapperStyles,$),"data-cy":`${K}-wrapper`,"data-testid":`${Q}-wrapper`,children:[b?e.jsx("div",{className:"w-full","data-cy":`${K}-custom-header`,children:b}):(n||i)&&e.jsxs("div",{className:o.labelRowStyles,children:[n&&e.jsx("label",{htmlFor:D,className:o.labelStyles,"data-cy":`${K}-label`,"data-testid":`${Q}-label`,children:U}),i&&e.jsx(t.Provider,{delayDuration:200,children:e.jsxs(t.Root,{children:[e.jsx(t.Trigger,{asChild:!0,children:e.jsx("button",{type:"button",className:o.tooltipTriggerStyles,"aria-label":"More information","data-cy":`${K}-tooltip-trigger`,"data-testid":`${Q}-tooltip-trigger`,children:e.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[e.jsx("circle",{cx:"6",cy:"6",r:"5.5",stroke:"currentColor",strokeWidth:"1",fill:"none"}),e.jsx("path",{d:"M6 5.5V8.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"}),e.jsx("circle",{cx:"6",cy:"4",r:"0.5",fill:"currentColor"})]})})}),e.jsx(t.Portal,{children:e.jsxs(t.Content,{className:o.tooltipContentStyles,side:"top",sideOffset:4,"data-cy":`${K}-tooltip-content`,"data-testid":`${Q}-tooltip-content`,children:[i,e.jsx(t.Arrow,{className:"fill-text"})]})})]})})]}),j?e.jsxs("div",{className:a.cn("w-full rounded-[var(--radius-md)] flex flex-col gap-[var(--spacing-3)] p-[0.875rem] transition-all duration-200",!oe&&ie,oe&&"border border-[var(--color-error)] bg-[var(--color-card)]"),style:oe?void 0:ce,onMouseEnter:ae,onMouseLeave:se,children:[e.jsx("textarea",{ref:A,id:D,value:M,className:a.cn("w-full resize-none bg-transparent text-[1.125rem] leading-[1.375rem] outline-none border-none","placeholder:text-[var(--color-system-text)]","disabled:cursor-not-allowed disabled:text-[var(--color-system-text)]",M?"text-[var(--color-text)]":"text-[var(--color-system-text)]"),"aria-invalid":oe?"true":"false","aria-required":q?"true":void 0,"aria-describedby":oe?G:u?J:void 0,"data-cy":K,"data-testid":Q,"data-state":de,onChange:ee,onFocus:re,onBlur:te,required:q,maxLength:m,rows:v,...E}),j]}):"green-accent"===w?e.jsx("div",{className:a.cn("w-full rounded-[var(--radius-md)] transition-all duration-200",!oe&&"p-[1px]",oe&&"border border-[var(--color-error)] bg-[var(--color-card)]",!oe&&ie),style:oe?void 0:ce,onMouseEnter:ae,onMouseLeave:se,"data-cy":`${K}-gradient-wrapper`,"data-testid":`${Q}-gradient-wrapper`,children:e.jsx("div",{className:oe?o.errorBorderInnerStyles:o.gradientBorderInnerStyles,children:e.jsx("textarea",{ref:A,id:D,value:M,className:a.cn(o.textareaInsideGradientStyles,!h&&"overflow-y-auto"),"aria-invalid":oe?"true":"false","aria-required":q?"true":void 0,"aria-describedby":oe?G:u?J:void 0,"data-cy":K,"data-testid":Q,"data-state":de,onChange:ee,onFocus:re,onBlur:te,required:q,maxLength:m,rows:h?void 0:v,...E})})}):e.jsx("textarea",{ref:A,id:D,value:M,className:a.cn(o.textareaBaseStyles,oe&&o.textareaErrorStyles,!h&&"overflow-y-auto",ie),"aria-invalid":oe?"true":"false","aria-required":q?"true":void 0,"aria-describedby":oe?G:u?J:void 0,"data-cy":K,"data-testid":Q,"data-state":de,onChange:ee,onFocus:re,onBlur:te,onMouseEnter:ae,onMouseLeave:se,required:q,maxLength:m,rows:h?void 0:v,...E}),oe&&e.jsx("span",{id:G,className:o.errorStyles,role:"alert","data-cy":`${K}-error`,"data-testid":`${Q}-error`,children:oe}),!j&&ne&&e.jsxs("div",{className:o.footerStyles,children:[u&&!oe&&e.jsx("span",{id:J,className:o.helperStyles,"data-cy":`${K}-helper`,"data-testid":`${Q}-helper`,children:u}),g&&e.jsxs("span",{className:a.cn(o.charCountStyles,le&&o.charCountExceededStyles),"data-cy":`${K}-char-count`,"data-testid":`${Q}-char-count`,children:[H,m&&` / ${m}`]})]})]})});n.displayName="Textarea",exports.Textarea=n;
|
package/dist/index17.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r
|
|
2
|
-
return e("div",{className:
|
|
3
|
-
/* @__PURE__ */r(
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{forwardRef as a,useState as t,useRef as o,useId as d,useCallback as i,useEffect as n,useMemo as l}from"react";import{Provider as s,Root as c,Trigger as u,Portal as m,Content as h,Arrow as p}from"./index68.js";import{cn as v}from"./index52.js";import{defaultValidation as g}from"./index53.js";import{labelRowStyles as x,labelStyles as f,tooltipTriggerStyles as b,tooltipContentStyles as y,errorBorderInnerStyles as w,gradientBorderInnerStyles as $,errorStyles as N,footerStyles as C,helperStyles as M,textareaInsideGradientStyles as L,textareaErrorStyles as j,textareaBaseStyles as q,charCountExceededStyles as k,charCountStyles as B,wrapperStyles as F}from"./index69.js";import{useMergedRef as R}from"./index61.js";import{debounce as _}from"./index70.js";const E=a(({label:a,tooltip:E,error:H,helperText:I,fullWidth:T=!1,autoResize:V=!1,minRows:W=3,maxRows:z,showCharCount:A=!1,maxLength:D,validate:O=g,onValidationChange:S,customHeader:G,customFooterActions:J,borderVariant:K,className:P,id:Q,onChange:U,onBlur:X,required:Y,value:Z,"data-cy":ee,"data-testid":re,...ae},te)=>{const[oe,de]=t(),[ie,ne]=t(!1),[le,se]=t(!1),[ce,ue]=t(0),me=o(!1),he=o(null),pe=R(te,he),ve=d(),ge=Q||ve,xe=`${ge}-error`,fe=`${ge}-helper`,be=ee||"textarea",ye=re||"textarea",we=a&&Y&&!a.includes("*")?`${a} *`:a,$e=i(()=>{const e=he.current;if(!e||!V)return;e.style.height="auto";const r=window.getComputedStyle(e),a=parseInt(r.lineHeight)||22,t=parseInt(r.paddingTop)||0,o=parseInt(r.paddingBottom)||0,d=a*W+t+o,i=z?a*z+t+o:1/0,n=Math.min(Math.max(e.scrollHeight,d),i);e.style.height=`${n}px`},[V,W,z]);n(()=>{$e()},[Z,$e]);const Ne=l(()=>_(e=>{if(O&&me.current){const r=O(e);de(r),S?.(!r)}else null===O&&me.current&&(de(void 0),S?.(!0))},300),[O,S]),Ce=o(Ne);n(()=>{Ce.current=Ne},[Ne]),n(()=>()=>{Ce.current.cancel()},[]),n(()=>{ue((Z||"").length)},[Z]);const Me=e=>{const r=e.target.value;ue(r.length),U?.(e),V&&$e(),me.current&&Ne(r)},Le=e=>{ne(!0),ae.onFocus?.(e)},je=e=>{if(ne(!1),me.current=!0,O){const r=O(e.target.value);de(r),S?.(!r)}X?.(e)},qe=()=>se(!0),ke=()=>se(!1),Be=H||oe,Fe=ae.disabled?"disabled":Be?"error":ie?"focus":le?"hover":"idle",Re=D&&ce>D,_e=A||I&&!Be,Ee=(()=>{if(!K)return"";if("green-accent"===K){return`relative ${ie||le?"shadow-[0_0.25rem_1rem_0_var(--shadow-color-sm)]":""}`}return""})(),He="green-accent"===K?{background:"linear-gradient(var(--color-card), var(--color-card)) padding-box, var(--gradient-green-blue) border-box",border:ie||le?"2px solid transparent":"1px solid transparent"}:{};/* @__PURE__ */
|
|
2
|
+
return e("div",{className:v(F,P),"data-cy":`${be}-wrapper`,"data-testid":`${ye}-wrapper`,children:[G?/* @__PURE__ */r("div",{className:"w-full","data-cy":`${be}-custom-header`,children:G}):(a||E)&&/* @__PURE__ */e("div",{className:x,children:[a&&/* @__PURE__ */r("label",{htmlFor:ge,className:f,"data-cy":`${be}-label`,"data-testid":`${ye}-label`,children:we}),E&&/* @__PURE__ */r(s,{delayDuration:200,children:/* @__PURE__ */e(c,{children:[
|
|
3
|
+
/* @__PURE__ */r(u,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button",className:b,"aria-label":"More information","data-cy":`${be}-tooltip-trigger`,"data-testid":`${ye}-tooltip-trigger`,children:/* @__PURE__ */e("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[
|
|
4
4
|
/* @__PURE__ */r("circle",{cx:"6",cy:"6",r:"5.5",stroke:"currentColor",strokeWidth:"1",fill:"none"}),
|
|
5
5
|
/* @__PURE__ */r("path",{d:"M6 5.5V8.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"}),
|
|
6
6
|
/* @__PURE__ */r("circle",{cx:"6",cy:"4",r:"0.5",fill:"currentColor"})]})})}),
|
|
7
|
-
/* @__PURE__ */r(
|
|
8
|
-
/* @__PURE__ */r(
|
|
9
|
-
/* @__PURE__ */r("textarea",{ref:
|
|
7
|
+
/* @__PURE__ */r(m,{children:/* @__PURE__ */e(h,{className:y,side:"top",sideOffset:4,"data-cy":`${be}-tooltip-content`,"data-testid":`${ye}-tooltip-content`,children:[E,
|
|
8
|
+
/* @__PURE__ */r(p,{className:"fill-text"})]})})]})})]}),J?/* @__PURE__ */e("div",{className:v("w-full rounded-[var(--radius-md)] flex flex-col gap-[var(--spacing-3)] p-[0.875rem] transition-all duration-200",!Be&&Ee,Be&&"border border-[var(--color-error)] bg-[var(--color-card)]"),style:Be?void 0:He,onMouseEnter:qe,onMouseLeave:ke,children:[
|
|
9
|
+
/* @__PURE__ */r("textarea",{ref:pe,id:ge,value:Z,className:v("w-full resize-none bg-transparent text-[1.125rem] leading-[1.375rem] outline-none border-none","placeholder:text-[var(--color-system-text)]","disabled:cursor-not-allowed disabled:text-[var(--color-system-text)]",Z?"text-[var(--color-text)]":"text-[var(--color-system-text)]"),"aria-invalid":Be?"true":"false","aria-required":Y?"true":void 0,"aria-describedby":Be?xe:I?fe:void 0,"data-cy":be,"data-testid":ye,"data-state":Fe,onChange:Me,onFocus:Le,onBlur:je,required:Y,maxLength:D,rows:W,...ae}),J]}):"green-accent"===K?/* @__PURE__ */r("div",{className:v("w-full rounded-[var(--radius-md)] transition-all duration-200",!Be&&"p-[1px]",Be&&"border border-[var(--color-error)] bg-[var(--color-card)]",!Be&&Ee),style:Be?void 0:He,onMouseEnter:qe,onMouseLeave:ke,"data-cy":`${be}-gradient-wrapper`,"data-testid":`${ye}-gradient-wrapper`,children:/* @__PURE__ */r("div",{className:Be?w:$,children:/* @__PURE__ */r("textarea",{ref:pe,id:ge,value:Z,className:v(L,!V&&"overflow-y-auto"),"aria-invalid":Be?"true":"false","aria-required":Y?"true":void 0,"aria-describedby":Be?xe:I?fe:void 0,"data-cy":be,"data-testid":ye,"data-state":Fe,onChange:Me,onFocus:Le,onBlur:je,required:Y,maxLength:D,rows:V?void 0:W,...ae})})}):/* @__PURE__ */r("textarea",{ref:pe,id:ge,value:Z,className:v(q,Be&&j,!V&&"overflow-y-auto",Ee),"aria-invalid":Be?"true":"false","aria-required":Y?"true":void 0,"aria-describedby":Be?xe:I?fe:void 0,"data-cy":be,"data-testid":ye,"data-state":Fe,onChange:Me,onFocus:Le,onBlur:je,onMouseEnter:qe,onMouseLeave:ke,required:Y,maxLength:D,rows:V?void 0:W,...ae}),Be&&/* @__PURE__ */r("span",{id:xe,className:N,role:"alert","data-cy":`${be}-error`,"data-testid":`${ye}-error`,children:Be}),!J&&_e&&/* @__PURE__ */e("div",{className:C,children:[I&&!Be&&/* @__PURE__ */r("span",{id:fe,className:M,"data-cy":`${be}-helper`,"data-testid":`${ye}-helper`,children:I}),A&&/* @__PURE__ */e("span",{className:v(B,Re&&k),"data-cy":`${be}-char-count`,"data-testid":`${ye}-char-count`,children:[ce,D&&` / ${D}`]})]})]})});E.displayName="Textarea";export{E as Textarea};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/textarea/Textarea.component.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmBtD,eAAO,MAAM,QAAQ,+
|
|
1
|
+
{"version":3,"file":"Textarea.component.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/textarea/Textarea.component.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmBtD,eAAO,MAAM,QAAQ,+GAoZpB,CAAC;AAIF,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|