@rdsaude/pulso-react-components
Version:
Biblioteca de componentes React do Pulso Design System da RD Saúde oferece componentes consistentes e de alto desempenho, alinhados com os padrões da RDSaúde. Ideal para desenvolver aplicações modernas e acessíveis.
54 lines (53 loc) • 17.5 kB
JavaScript
;var Uo=Object.create;var S=Object.defineProperty,Go=Object.defineProperties,Wo=Object.getOwnPropertyDescriptor,$o=Object.getOwnPropertyDescriptors,Xo=Object.getOwnPropertyNames,E=Object.getOwnPropertySymbols,Yo=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable;var j=(o,r,e)=>r in o?S(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,s=(o,r)=>{for(var e in r||(r={}))A.call(r,e)&&j(o,e,r[e]);if(E)for(var e of E(r))oo.call(r,e)&&j(o,e,r[e]);return o},u=(o,r)=>Go(o,$o(r));var c=(o,r)=>{var e={};for(var n in o)A.call(o,n)&&r.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&E)for(var n of E(o))r.indexOf(n)<0&&oo.call(o,n)&&(e[n]=o[n]);return e};var L=(o,r)=>{for(var e in r)S(o,e,{get:r[e],enumerable:!0})},eo=(o,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of Xo(r))!A.call(o,t)&&t!==e&&S(o,t,{get:()=>r[t],enumerable:!(n=Wo(r,t))||n.enumerable});return o};var x=(o,r,e)=>(e=o!=null?Uo(Yo(o)):{},eo(r||!o||!o.__esModule?S(e,"default",{value:o,enumerable:!0}):e,o)),Jo=o=>eo(S({},"__esModule",{value:!0}),o);var re={};L(re,{InputCounter:()=>qo});module.exports=Jo(re);var Lo=require("react"),Ko=require("@radix-ui/react-context");var R={};L(R,{Icon:()=>F,IconDualColor:()=>$,Root:()=>q});var T=x(require("react"),1),co=require("@ark-ui/react/factory");var ro=x(require("react"),1);var v=x(require("react"),1);function K(o,r){let{targets:e,props:n,keyPrefix:t="inject",asChild:l}=r,a=v.Children.map(o,(i,d)=>{var p,g;if(!v.isValidElement(i))return i;let b=(g=(p=i.type)==null?void 0:p.displayName)!=null?g:"",C=e.includes(b),I=i.props;return v.cloneElement(i,u(s({},C?n:{}),{key:`${t}-${d.toString()}`}),K(I==null?void 0:I.children,{targets:e,props:n,keyPrefix:t,asChild:I==null?void 0:I.asChild}))});return l?a==null?void 0:a[0]:a}function O(o,{targets:r,props:e,asChild:n}){let t=ro.useId();return K(o,{targets:r,props:e,asChild:n,keyPrefix:t})}var to=require("clsx"),no=require("tailwind-merge"),B=(...o)=>(0,no.twMerge)((0,to.clsx)(...o));var so=x(require("react"),1);var V=x(require("react"),1),f=require("@raiadrogasil/pulso-design-tokens");var ao=x(require("react"),1),Qo=require("react/jsx-runtime"),lo=ao.createContext({currentTheme:"rdsaudesistemas"});function _(){let o=V.useMemo(()=>({rdsaudesistemas:f.RDSAUDESISTEMAS_TOKENS,drogasil:f.DROGASIL_TOKENS,raia:f.RAIA_TOKENS,subscription:f.SUBSCRIPTION_TOKENS,prime:f.PRIME_TOKENS}),[]),r=V.useContext(lo);if(!r)throw new Error("[Pulso] useTheme precisa estar dentro de um <ThemeProvider>. Verifique se o provedor est\xE1 corretamente configurado na raiz da aplica\xE7\xE3o.");let{currentTheme:e}=r;return s(s({},f.GLOBALS_TOKENS),o[e])}var P=require("react/jsx-runtime");function io({color:o="brand",srText:r}){let e=_(),t=so.useMemo(()=>({brand:e.colorActionFillBrandPrimaryEnabled,neutral:e.colorTextNeutralReadonly,black:e.colorTextNeutralDefault,white:e.colorTextNeutralInverse}),[e])[o];return(0,P.jsx)("div",{role:"status",className:B("grid size-8 place-items-center"),"aria-label":r,children:(0,P.jsxs)("svg",{className:B("size-6 animate-spin fill-none"),viewBox:"0 0 24 24",children:[(0,P.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0v2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12H0z",fill:t}),(0,P.jsx)("title",{children:r})]})})}var uo=require("tailwind-variants"),m=(0,uo.createTV)({twMerge:!0,twMergeConfig:{extend:{classGroups:{"font-size":[{text:["threepulse","threeandhalfpulse"]}],"border-width":[{border:["quarterpulse","halfpulse"]}],"--tw-ring-inset":[{ring:["none","quarterpulse","halfpulse"]}]}}}});var Zo=m({slots:{root:["inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap","gap-x-[var(--spacing-inline-twopulse)] rounded-full","outline-[var(--color-action-border-focused)] outline-offset-2","font-inherit font-bold tracking-[var(--letter-spacing-default)]","focus-visible:outline-2","disabled:cursor-not-allowed disabled:text-[var(--color-text-neutral-disabled)]"]},variants:{variant:{"brand-primary":{root:["bg-[var(--color-action-fill-brand-primary-enabled)]","text-[var(--color-text-neutral-inverse)]","enabled:hover:bg-[var(--color-action-fill-brand-primary-hovered)]","active:bg-[var(--color-action-fill-brand-primary-pressed)]","disabled:bg-[var(--color-action-fill-brand-primary-disabled)]"]},"neutral-secondary":{root:["ring-[var(--color-action-border-neutral-secondary-enabled)]","ring-[length:var(--border-width-quarterpulse)]","bg-[var(--color-action-fill-neutral-secondary-enabled)]","text-[var(--color-text-neutral-default)]","enabled:hover:ring-[var(--color-action-border-neutral-secondary-hovered)]","enabled:hover:bg-[var(--color-action-fill-neutral-secondary-hovered)]","active:ring-[var(--color-action-border-neutral-secondary-pressed)]","active:bg-[var(--color-action-fill-neutral-secondary-pressed)]","disabled:ring-[var(--color-action-border-neutral-secondary-disabled)]","disabled:bg-[var(--color-action-fill-neutral-secondary-disabled)]"]},"neutral-tertiary":{root:["ring-[var(--color-action-border-neutral-tertiary-enabled)]","ring-[length:var(--border-width-quarterpulse)]","bg-[var(--color-action-fill-neutral-tertiary-enabled)]","text-[var(--color-text-neutral-default)]","enabled:hover:ring-[var(--color-action-border-neutral-tertiary-hovered)]","enabled:hover:bg-[var(--color-action-fill-neutral-tertiary-hovered)]","active:ring-[var(--color-action-border-neutral-tertiary-pressed)]","active:bg-[var(--color-action-fill-neutral-tertiary-pressed)]","disabled:ring-[var(--color-action-border-neutral-tertiary-disabled)]","disabled:bg-[var(--color-action-fill-neutral-tertiary-disabled)]"]}},size:{md:{root:["h-[var(--sizing-medium)] min-w-8 px-[var(--padding-inset-fourpulse)]","text-[length:var(--font-size-threepulse)]","leading-[var(--line-height-medium)]"]},ml:{root:["h-[var(--sizing-mediumlarge)] min-w-10 px-[var(--padding-inset-fourpulse)]"]},lg:{root:["h-[var(--sizing-large)] min-w-12 px-[var(--padding-inset-fivepulse)]"]},xl:{root:["h-[var(--sizing-extralarge)] min-w-14 px-[var(--padding-inset-sixpulse)]"]}},asIconOnly:{true:{root:"aspect-square px-0"}}},compoundVariants:[{size:["ml","lg"],class:{root:["text-[length:var(--font-size-threeandhalfpulse)]","leading-[var(--line-height-small)]"]}}],defaultVariants:{variant:"brand-primary",size:"ml",asIconOnly:!1}}),{root:po}=Zo();var H=require("react/jsx-runtime");function q(b){var C=b,{children:o,className:r,variant:e="brand-primary",size:n,disabled:t,loading:l,asChild:a,full:i}=C,d=c(C,["children","className","variant","size","disabled","loading","asChild","full"]);let I=O(o,{targets:["ButtonIcon","ButtonIconDualColor"],props:{variant:e,size:n,disabled:t},asChild:a}),p=!t&&l,g={"brand-primary":"white","neutral-secondary":"black","neutral-tertiary":"black"},k={"aria-live":"polite","aria-busy":!0},M=T.useCallback(()=>{var Q,Z;if(T.Children.count(o)===1&&T.isValidElement(o)){let Fo=(Z=(Q=o.type)==null?void 0:Q.displayName)!=null?Z:"";return["ButtonIcon","ButtonIconDualColor"].includes(Fo)}return!1},[o]);return(0,H.jsx)(co.ark.button,u(s(s({},d),p&&k),{className:B(po({variant:e,size:n,asIconOnly:M(),className:p&&"pointer-events-none"}),i&&"w-full",r),disabled:t,"data-scope":"button",children:p?(0,H.jsx)(io,{color:g[e]}):I}))}q.displayName="ButtonRoot";var ho=require("react");var mo=x(require("react"),1);var fo=require("react/jsx-runtime");function y(t){var l=t,{symbol:o="rdicon-default",size:r="small",color:e="colorActionFillBrandPrimaryEnabled"}=l,n=c(l,["symbol","size","color"]);let a=_(),i=mo.useMemo(()=>({tiny:a.sizingTiny,"extra-small":a.sizingExtrasmall,small:a.sizingSmall,medium:a.sizingMedium}),[]);return(0,fo.jsx)("i",u(s({},n),{className:o,style:{fontSize:i[r],color:a[e],display:"inline-flex"}}))}y.displayName="Icon";var Io=require("react/jsx-runtime");function F({variant:o,size:r,disabled:e,iconColor:n,symbol:t}){let l={md:"extra-small",ml:"small",lg:"small",xl:"small"},a={"brand-primary":"colorTextNeutralInverse","neutral-secondary":"colorTextNeutralDefault","neutral-tertiary":"colorTextNeutralDefault"},i=(0,ho.useMemo)(()=>e?"colorTextNeutralDisabled":n||a[o],[e,o]),d=l[r];return(0,Io.jsx)(y,{color:i,size:d,symbol:t})}F.displayName="ButtonIcon";var z={};L(z,{Bottom:()=>W,Root:()=>U,Top:()=>G});var Co=require("@ark-ui/react/factory");var bo=require("react/jsx-runtime");function U(l){var a=l,{children:o,size:r="small",disabled:e=!1,asChild:n}=a,t=c(a,["children","size","disabled","asChild"]);let i=O(o,{targets:["IconDualColorTop","IconDualColorBottom"],props:{size:r,disabled:e},asChild:n});return(0,bo.jsx)(Co.ark.div,u(s({"data-testid":"icon-dual-color-root","aria-label":"\xCDcones","aria-disabled":e,asChild:n},t),{className:"relative flex [&>[data-icon=top]]:absolute",children:i}))}U.displayName="IconDualColorRoot";var yo=require("react/jsx-runtime");function G(l){var a=l,{children:o,color:r="colorActionTextOnbrandDefault",size:e,disabled:n}=a,t=c(a,["children","color","size","disabled"]);return(0,yo.jsx)(y,u(s({"data-testid":"icon-dual-color-top","data-icon":"top","data-size":e,color:n?"colorTextNeutralDisabled":r,size:e},t),{children:o}))}G.displayName="IconDualColorTop";var xo=require("react/jsx-runtime");function W(l){var a=l,{children:o,color:r="colorTextNeutralDefault",size:e,disabled:n}=a,t=c(a,["children","color","size","disabled"]);return(0,xo.jsx)(y,u(s({"data-testid":"icon-dual-color-bottom","data-icon":"bottom","data-size":e,color:n?"colorTextNeutralDisabled":r,size:e},t),{children:o}))}W.displayName="IconDualColorBottom";var go=require("react/jsx-runtime");function $(e){var n=e,{size:o="ml"}=n,r=c(n,["size"]);let t={md:"extra-small",ml:"small",lg:"small",xl:"small"};return(0,go.jsx)(z.Root,u(s({},r),{size:t[o]}))}$.displayName="ButtonIconDualColor";var D=require("react/jsx-runtime"),vo=o=>{let{symbol:r,__scopeInputCounter:e}=o,{size:n}=h("InputCounterButton",e),t=l=>({md:"md",ml:"md",lg:"ml",xl:"ml"})[l];return(0,D.jsx)(R.Root,u(s({},o),{variant:"neutral-tertiary",size:t(n||"md"),children:(0,D.jsx)(R.Icon,{symbol:r})}))},Po=o=>{let{__scopeInputCounter:r,onClick:e}=o,{setCurrentValue:n,currentValue:t,disabled:l,readOnly:a}=h("InputCounterButton",r);return(0,D.jsx)(vo,u(s({},o),{symbol:t===1?"rdicon-delete":"rdicon-minus",tabIndex:0,onClick:i=>{t>0&&n(t-1),e==null||e(i)},disabled:l||a||t===0}))},To=o=>{let{__scopeInputCounter:r,onClick:e}=o,{setCurrentValue:n,currentValue:t,disabled:l,readOnly:a}=h("InputCounterButton",r);return(0,D.jsx)(vo,u(s({},o),{symbol:"rdicon-plus",tabIndex:0,onClick:i=>{t>=0&&t<999&&n(t+1),e==null||e(i)},disabled:l||a||t===999}))};var Ro=m({base:[`grid grid-cols-[auto_1fr_auto] place-content-center w-full gap-onepulse duration-100 ease-in overflow-hidden
bg-[var(--color-forms-fill-default)]
has-[:placeholder-shown]:bg-forms-fill
has-[:placeholder-shown]:border-transparent
has-[:placeholder-shown]:border-none
has-[:focus-within]:has-[:placeholder-shown]:bg-forms-fill-focused
`],variants:{size:{md:"h-medium rounded-form px-threepulse",ml:"h-mediumlarge rounded-form px-threepulse",lg:"h-large rounded-form px-threepulse",xl:"h-extralarge rounded-largecontainer px-threepulse"},readOnly:{true:`
cursor-not-allowed
has-[:placeholder-shown]:bg-forms-fill-readonly
has-[:placeholder-shown]:ring-forms-border-readonly
has-[:placeholder-shown]:ring-quarterpulse
`},disabled:{true:`
cursor-not-allowed
has-[:placeholder-shown]:bg-forms-fill-disabled
has-[:placeholder-shown]:ring-forms-border-disabled
has-[:placeholder-shown]:ring-quarterpulse
`},hasFilled:{true:""},hasError:{true:`
has-[:placeholder-shown]:ring-forms-border-error
has-[:placeholder-shown]:ring-quarterpulse
has-[:placeholder-shown]:hover:ring-halfpulse
`}},compoundVariants:[{hasError:!1,hasFilled:!0,readOnly:!1,disabled:!1,class:`
[&:not(:focus-within)]:bg-forms-fill-filled
[&:not(:focus-within)]:border-forms-border-filled
[&:not(:focus-within)]:border-quarterpulse
[&:not(:focus-within)]:hover:border-halfpulse
`},{hasError:!1,readOnly:!1,disabled:!1,class:`
has-[:focus-within]:ring-action-border-focused
has-[:focus-within]:ring-halfpulse
has-[:focus-within]:bg-forms-fill-focused
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:bg-forms-fill-hovered
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:border-forms-border-hovered
`},{hasError:!0,hasFilled:!0,readOnly:!1,disabled:!1,class:`
has-[:not(:placeholder-shown)]:ring-forms-border-error
has-[:not(:placeholder-shown)]:bg-forms-fill-error
has-[:not(:placeholder-shown)]:ring-quarterpulse
has-[:not(:placeholder-shown)]:hover:ring-halfpulse
has-[:not(:placeholder-shown)]:border-none
`},{hasError:!1,hasFilled:!0,readOnly:!1,disabled:!0,class:`
has-[:not(:placeholder-shown)]:ring-forms-border-disabled
has-[:not(:placeholder-shown)]:bg-forms-fill-disabled
has-[:not(:placeholder-shown)]:ring-quarterpulse
has-[:not(:placeholder-shown)]:border-none
`},{hasError:!1,hasFilled:!0,readOnly:!0,disabled:!1,class:`
has-[:not(:placeholder-shown)]:ring-forms-border-readonly
has-[:not(:placeholder-shown)]:bg-forms-fill-readonly
has-[:not(:placeholder-shown)]:ring-quarterpulse
has-[:not(:placeholder-shown)]:border-none
`}],defaultVariants:{size:"md",isFocused:!1,hasError:!1,readOnly:!1,disabled:!1}});var No=require("react/jsx-runtime"),wo=o=>{let{children:r,__scopeInputCounter:e}=o,{size:n,disabled:t,hasError:l,readOnly:a,currentValue:i}=h("InputCounterControl",e),d=i>=1;return(0,No.jsx)("div",{className:Ro({size:n,disabled:t,hasError:l,readOnly:a,hasFilled:d}),children:r})};var zo=require("react");var So=m({base:`flex flex-row justify-star w-[100%] items-center px-onepulse
`,variants:{}}),Bo=m({base:`
flex text-left font-rdmodern font-semibold text-text-neutral-alternative text-threepulse
line-clamp-2
`,variants:{hasError:{true:"text-text-danger-alternative",false:""},readOnly:{true:"cursor-not-allowed"},disabled:{true:"cursor-not-allowed text-text-neutral-disabled",false:""}},compoundVariants:[{readOnly:!0,disabled:!1,class:"text-text-neutral-readonly"}],defaultVariants:{hasError:!1,disabled:!1,readOnly:!1}});var w=require("react/jsx-runtime"),Do=o=>{let{children:r,iconName:e="",__scopeInputCounter:n}=o,{hasError:t,disabled:l,readOnly:a}=h("InputCounterHelperText",n),i=t?"rdicon-warning-circle":e,d=(0,zo.useMemo)(()=>l?"colorTextNeutralDisabled":a?"colorTextNeutralReadonly":t?"colorTextDangerAlternative":"colorTextNeutralAlternative",[l,t,a]);if(!r)return null;let b=t||e!=="";return(0,w.jsxs)("div",u(s({},o),{"aria-disabled":l,className:So({}),children:[b&&(0,w.jsx)("div",{className:"mr-onepulse flex items-center",children:(0,w.jsx)(y,{symbol:i,color:d,size:"tiny"})}),(0,w.jsx)("span",{className:Bo({hasError:t,disabled:l,readOnly:a}),children:r})]}))};var N=require("react");var Eo=m({base:["w-full bg-transparent text-center text-text-neutral-alternative tabular-nums outline-none placeholder:invisible focus-within:text-text-neutral","disabled:cursor-not-allowed disabled:text-text-neutral-disabled","read-only:pointer-events-none read-only:cursor-not-allowed read-only:text-text-neutral-readonly"],variants:{hasError:{true:"text-text-neutral-alternative"}}});var Vo=require("react/jsx-runtime"),Oo=0,jo=999,X=(0,N.forwardRef)((e,r)=>{var o=c(e,[]);let{__scopeInputCounter:n}=o,{currentValue:t,setCurrentValue:l,disabled:a,readOnly:i,hasError:d,onValueChange:b}=h("InputCounterInput",n),C=(0,N.useRef)(null);function I(p){let g=/[^0-9]/g,k=p.replace(g,"").trim(),M=Math.min(jo,Math.max(Oo,Number.parseInt(k)||Oo));l(Number(M))}return(0,N.useEffect)(()=>{C.current&&(C.current.value=t>0?String(t):"",b(t))},[t]),(0,Vo.jsx)("input",u(s({},o),{ref:p=>{typeof r=="function"&&r(p),C.current=p},inputMode:"numeric",type:"tel",pattern:"[0-9]*",className:Eo({hasError:d}),maxLength:3,onChange:p=>{I(p.target.value),b(Number(p.target.value))},value:t,disabled:a,readOnly:i,placeholder:"0"}))});X.displayName="InputCounterInput";var _o=m({base:"line-clamp-1 rounded-none px-onepulse font-rdmodern font-regular text-text-neutral",variants:{size:{md:"text-threepulse",ml:"text-threeandhalfpulse",lg:"text-threeandhalfpulse",xl:"text-threeandhalfpulse"},disabled:{true:"cursor-not-allowed text-text-neutral-disabled",false:""},readOnly:{true:"cursor-not-allowed text-text-neutral-readonly",false:""}}});var Mo=require("react/jsx-runtime"),ko=o=>{let{children:r,__scopeInputCounter:e}=o,{disabled:n,readOnly:t,size:l}=h("InputCounterControl",e);return(0,Mo.jsx)("label",{className:_o({disabled:n,readOnly:t,size:l}),children:r})};var Ao=m({base:"flex w-full min-w-[calc(var(--sizing-colossal)_+_var(--sizing-micro))] flex-col gap-halfpulse ",variants:{}});var Y=require("react/jsx-runtime"),J="InputCounterRoot",Ho=o=>{let{size:r="ml",children:e,value:n,onValueChange:t,disabled:l,hasError:a,readOnly:i,__scopeInputCounter:d}=o,[b,C]=(0,Lo.useState)(n!=null?n:0);return(0,Y.jsx)(ee,u(s({},{size:r,scope:d,setCurrentValue:C,currentValue:b,value:n,onValueChange:t,disabled:l,readOnly:i,hasError:a}),{children:(0,Y.jsx)("div",{className:Ao({}),children:e})}))};Ho.displayName=J;var[oe]=(0,Ko.createContextScope)(J),[ee,h]=oe(J),qo={Root:Ho,Decrement:Po,Increment:To,Control:wo,Input:X,Label:ko,HelperText:Do};0&&(module.exports={InputCounter});
//# sourceMappingURL=index.cjs.map