@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.
47 lines • 17.1 kB
JavaScript
import{a as O}from"./chunk-ZPQX6QQ4.js";import{a as U}from"./chunk-WFY27F6Y.js";import{a as B}from"./chunk-3PY4FLM4.js";import{a as C}from"./chunk-M6UU4BVN.js";import{a as $}from"./chunk-UFSELALI.js";import{a as d}from"./chunk-2MB3Y6WI.js";import{a as u,b as m,c as S}from"./chunk-DDCCLFYC.js";import{createContextScope as $e}from"@radix-ui/react-context";import{jsx as ye}from"react/jsx-runtime";var K=({children:t})=>ye("div",{className:"input-select-actions","data-testid":"input-name-actions",children:t});import{forwardRef as Ae,useEffect as se,useRef as Me,useState as De}from"react";import{createContextScope as Se}from"@radix-ui/react-context";import{forwardRef as Ce}from"react";var W=d({base:`
group flex items-center justify-between rounded-pill min-w-[11.25rem] w-full gap-onepulse pl-threepulse pr-onepulse relative py-[2px]
text-text-neutral leading-none border-solid bg-forms-fill border-forms-fill duration-100 ease-in
hover:bg-forms-fill-hovered hover:border-forms-fill-hovered
focus:border-forms-border-focused focus:bg-forms-fill-focused focus:border-halfpulse
active:border-forms-fill-focused active:bg-forms-fill-focused active:border-halfpulse
has-[:focus]:ring-forms-border-filled has-[:focus]:bg-forms-fill-focused has-[:focus]:border-halfpulse
has-[:active]:ring-forms-border-focused has-[:active]:bg-forms-fill-focused has-[:active]:border-halfpulse
focus-within:ring-action-border-focused
[&:not(:focus-within)]:has-[:placeholder-shown]:border-action-border-focused
[&:not(:focus-within)]:has-[:placeholder-shown]:bg-forms-fill
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:bg-forms-fill-hovered
[&:not(:focus-within)]:has-[:not(:placeholder-shown)]:border-forms-border-filled
has-[:active]:[&:not(:focus-within)]:has-[:placeholder-shown]:bg-forms-fill-focused
has-[:active]:[&:not(:focus-within)]:has-[:placeholder-shown]:border-forms-border-focused
has-[:active]:[&:not(:focus-within)]:has-[:not(:placeholder-shown)]:border-forms-border-focused
has-[:focus]:has-[:not(:placeholder-shown)]:border-forms-border-focused
`,variants:{size:{md:"h-medium",ml:"h-mediumlarge",lg:"h-large"},hasFilled:{true:`
border-forms-border-filled border-quarterpulse bg-forms-fill-filled
active:border-forms-fill-focused active:bg-forms-fill-focused active:border-halfpulse
hover:bg-forms-fill-filled hover:border-forms-border-filled hover:border-halfpulse
has-[:active]:border-forms-fill-focused has-[:active]:bg-forms-fill-focused has-[:active]:border-halfpulse
[&:not(:focus-within)]:has-[:placeholder-shown]:bg-forms-fill
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:bg-forms-fill-hovered
[&:not(:focus-within)]:has-[:placeholder-shown]:ring-forms-border
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:ring-forms-border-hovered
[&:not(:focus-within)]:has-[:placeholder-shown]:ring-none
`}},defaultVariants:{size:"md"}}),G=d({base:`
peer/field font-wheight-regular text-text-neutral-alternative font-rdmodern font-regular text-threeandhalfpulse leading-none border-none bg-[transparent]
flex-1 align-middle self-center focus-visible:border-none focus-visible:outline-none placeholder:text-text-neutral-alternative
active:placeholder:text-text-neutral-placeholder focus:placeholder:text-text-neutral-placeholder
active:text-text-neutral-placeholder focus:text-text-neutral-placeholder
`,variants:{size:{md:"h-extrasmall",ml:"h-extrasmall",lg:"h-extrasmall"},hasFilled:{true:`text-text-neutral active:text-text-neutral
`}},defaultVariants:{size:"md"}}),J=d({base:"searchbar-button bg-none",variants:{size:{md:"h-medium w-medium min-w-medium",ml:"h-mediumlarge w-mediumlarge min-w-mediumlarge",lg:"h-mediumlarge w-mediumlarge min-w-mediumlarge"}},defaultVariants:{size:"md"}}),Q=d({base:`
searchbar-clear-button hidden
peer-focus/field:peer-[:not(:placeholder-shown)]/field:flex peer-focus/field:peer-[:not(:placeholder-shown)]/field:visible
group-hover:peer-[:not(:placeholder-shown)]/field:flex
`,variants:{size:{md:"h-medium w-medium min-w-medium",ml:"h-mediumlarge w-mediumlarge min-w-mediumlarge",lg:"h-mediumlarge w-mediumlarge min-w-mediumlarge"}}});import{jsx as P,jsxs as Ne}from"react/jsx-runtime";var H="SearchBar",X=Ce((t,n)=>{let{onChange:r=()=>{},handleSearch:a=()=>{},handleClear:e=()=>{},placeholder:l,datatestid:o="search-bar",value:i="",size:s="md",__scopeSearchBar:p}=t,c=f=>f==="lg"?"ml":f;return P(we,m(u({},t),{scope:p,children:Ne("div",{className:W({size:s,hasFilled:i!==""}),children:[P("input",{ref:n,type:"text",className:G({size:s,hasFilled:i!==""}),placeholder:l,onChange:f=>r(f),value:i,"data-testid":o}),P(B.Root,{size:c(s),variant:"neutral-tertiary",className:Q({size:s}),onClick:e,children:P(B.Icon,{symbol:"rdicon-dismiss-circle-outline"})}),P(B.Root,{size:c(s),variant:"neutral-tertiary",className:J({size:s}),onClick:a,children:P(B.Icon,{symbol:"rdicon-search"})})]})}))});X.displayName=H;var[Pe]=Se(H),[we,tr]=Pe(H),Te={Root:X};import{createContextScope as Oe}from"@radix-ui/react-context";import F,{useMemo as te,useState as oe}from"react";var Z=d({base:"flex flex-col items-center justify-center gap-twopulse border-none",variants:{disabled:{true:"cursor-not-allowed text-text-neutral-disabled outline-none"},orientation:{horizontal:"rounded-pill",vertical:"rounded-hugecontainer"},context:{brand:"",neutral:""}},compoundVariants:[{orientation:"horizontal",disabled:!1,class:"outline-action-border-focused outline-offset-4 focus:outline-1"},{orientation:"vertical",disabled:!1,class:"outline-action-border-focused outline-offset-4 focus:outline-1"},{context:"brand",disabled:!0,class:"border-border-browsing-border-onbrand-disabled bg-[#E6E6E6]"},{context:"neutral",disabled:!0,class:"border-action-border-neutral-tertiary-disabled bg-action-fill-neutral-tertiary-disabled"}]}),j=d({base:"flex min-w-[6rem] border-none bg-action-fill-emphasis-enabled py-threepulse outline-none",variants:{orientation:{vertical:"max-w-[6rem] flex-col items-center rounded-hugecontainer",horizontal:"h-large max-h-large min-h-large flex-row items-center justify-center gap-twopulse rounded-pill p-threepulse pr-fourpulse"},disabled:{true:"cursor-not-allowed bg-action-fill-emphasis-disabled",false:"hover:bg-action-fill-emphasis-hovered active:bg-action-fill-emphasis-pressed"},context:{brand:"roudend-pill border-none",neutral:"roudend-pill border-none"}},compoundVariants:[{disabled:!1,context:"brand",class:"bg-browsing-fill-onbrand-enabled pressed:bg-browsing-fill-onbrand-pressed hover:bg-browsing-fill-onbrand-hovered active:bg-browsing-fill-onbrand-activated"},{disabled:!1,context:"neutral",class:"bg-action-fill-neutral-tertiary pressed:bg-action-fill-neutral-tertiary-pressed hover:bg-action-fill-neutral-tertiary-hovered active:bg-action-fill-neutral-tertiary-activated"},{disabled:!0,context:"neutral",class:"bg-action-fill-neutral-tertiary-disabled"},{disabled:!0,context:"brand",class:"bg-action-fill-neutral-tertiary-disabled"}]}),ee=d({base:"font-rdmodern text-text-neutral text-threeandhalfpulse leading-small",variants:{orientation:{vertical:"line-clamp-2 text-center",horizontal:"line-clamp-1"},context:{brand:"",neutral:""},disabled:{true:"text-text-neutral-disabled",false:""},isPressed:{true:"",false:""},isHovered:{true:"",false:""}},compoundVariants:[{disabled:!0,context:"neutral",class:"text-text-neutral-disabled"},{disabled:!0,context:"brand",class:"text-text-neutral-disabled"},{isPressed:!1,disabled:!1,context:"brand",class:"active:font-semibold active:text-action-text-onbrand-activated"},{isPressed:!1,disabled:!1,context:"neutral",class:"font-regular"},{isPressed:!0,disabled:!1,context:"brand",class:"font-semibold"},{isPressed:!0,disabled:!1,context:"neutral",class:"font-semibold"},{context:void 0,orientation:"horizontal",class:"font-semibold"},{context:void 0,orientation:"vertical",class:"font-semibold"},{context:"brand",isHovered:!0,disabled:!1,class:"text-action-text-onbrand-hovered"},{context:"brand",isPressed:!0,class:"text-action-text-onbrand-pressed"}]});import{useMemo as Be}from"react";import{jsx as ze}from"react/jsx-runtime";var re=t=>{let{__scopeCardCategory:n}=t,{orientation:r,disabled:a,isHovered:e,isPressed:l,context:o}=L("CardCategoryLabel",n),i=Be(()=>{if(a&&o==="neutral"||a)return"colorTextNeutralDisabled";if(o==="brand"&&l)return"colorActionTextOnbrandPressed";if(o==="brand"&&e)return"colorActionTextOnbrandHovered";if(o==="neutral"||o==="brand")return"colorTextNeutralAlternative";if(l)return"colorActionTextOnbrandPressed";if(e)return"colorActionTextOnbrandHovered"},[e,l,a,o]);return ze(C,m(u({},t),{size:r==="horizontal"?"small":"medium",color:i}))};import{jsx as Ie}from"react/jsx-runtime";var w=t=>{let{__scopeCardCategory:n,children:r}=t,{orientation:a,context:e,disabled:l,isPressed:o,isHovered:i}=L("CardCategoryLabel",n);return Ie("span",{className:ee({orientation:a,context:e,disabled:l,isPressed:o,isHovered:i}),children:r})};import{jsx as V,jsxs as He}from"react/jsx-runtime";var ae="CardCategory",Le=t=>{let{children:n,orientation:r="horizontal",testID:a,disabled:e,onClick:l,context:o,__scopeCardCategory:i}=t,s=$(),[p,c]=oe(!1),[f,v]=oe(!1),y=F.Children.map(n,b=>F.isValidElement(b)&&(b.type===w&&r==="horizontal"||b.type!==w)?b:null),T=te(()=>!e&&f?s.colorBrowsingFillOnbrandPressed:!e&&p?s.colorBrowsingFillOnbrandHovered:e?s.colorBrowsingFillOnbrandDisabled:s.colorBrowsingFillOnbrandEnabled,[e,p,f,s]),N=te(()=>o?"horizontal":r,[o,r]);return V(Ee,{scope:i,orientation:N,disabled:e,"data-testid":a,isHovered:p,isPressed:f,context:o,children:He("div",{"data-testid":a,className:Z({disabled:e,orientation:r,context:o}),children:[V("button",{type:"button",className:U(j({orientation:r,disabled:e,context:o})),onClick:l,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onMouseDown:()=>v(!0),onMouseUp:()=>v(!1),style:{backgroundColor:o==="brand"?T:void 0},disabled:e,children:y}),r==="vertical"&&V(w,{children:F.Children.toArray(n).find(b=>F.isValidElement(b)&&b.type===w)})]})})},[Fe]=Oe(ae),[Ee,L]=Fe(ae),Re={Root:Le,Icon:re,Label:w};import{useState as Ve}from"react";function z(){let[t,n]=Ve();return{useSelect:z,selectedOption:t,setSelectedOption:n}}var le=d({base:`
flex justify-between w-full h-extrasmall p-none px-twopulse items-center text-text-neutral font-rdmodern flex-1 rounded-none leading-small z-80
placeholder:opacity-transparent focus-visible:border-none focus-visible:outline-none tracking-onepulse
`,variants:{size:{md:"text-threepulse",ml:"text-threeandhalfpulse",lg:"text-threeandhalfpulse",xl:"text-threeandhalfpulse"},readOnly:{true:"text-text-neutral-readonly",false:""},disabled:{true:"text-text-neutral-disabled",false:""},hasError:{true:"bg-forms-fill-error",false:"bg-forms-fill-filled"}},defaultVariants:{size:"md",readOnly:!1,disabled:!1,hasError:!1}});import{jsx as I,jsxs as ne}from"react/jsx-runtime";var A=Ae(o=>{var i=o,{children:t,__scopeInputSelect:n,onChangeSelectionValue:r,value:a,optionMaxHeight:e}=i,l=S(i,["children","__scopeInputSelect","onChangeSelectionValue","value","optionMaxHeight"]);let{size:s,hasError:p,disabled:c,readOnly:f,placeholder:v,options:y=[]}=h("InputSelectField",n),[T,N]=De(!1),{setSelectedOption:b,selectedOption:k}=z(),E=Me(null),q={label:v!=null?v:"Selecione...",value:""};se(()=>{if(a){let x=y.find(g=>g.value===a);return b(x)}return b(q)},[a]),se(()=>{function x(g){E.current&&!E.current.contains(g.target)&&N(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);let ve=x=>{b(x),N(!1),r==null||r(x.value)},Y=()=>{!c&&!f&&N(!T)};return ne("div",{ref:E,className:"relative flex w-full flex-col",children:[ne("div",m(u({},Object.keys(l).reduce((g,R)=>(R.startsWith("data-")&&(g[R]=l[R]),g),{})),{className:le(u({size:s,hasError:p,readOnly:f,disabled:c},l)),onClick:()=>Y(),onKeyUp:()=>Y(),"data-testid":"select-field",children:[k?k.label:q.label,I(M.Icon,{symbol:T?"rdicon-chevron-up":"rdicon-chevron-down",color:c?"colorTextNeutralDisabled":f?"colorTextNeutralReadonly":"colorTextNeutralDefault"})]})),T&&I("div",{className:"x-full absolute top-full left-0 z-10 w-full py-fivepulse","data-testid":"select-option-menu",children:I(O.Root,m(u({type:"single"},l),{children:I(O.List,{maxHeight:e,children:y==null?void 0:y.map((x,g)=>I(O.Item,{content:x,onPress:()=>ve(x),disabled:c,"data-testid":"select-item"},`${x.label}-${g}`))})}))})]})});A.displayName="InputSelectField";var ie=d({base:`
flex w-full border border-solid bg-forms-fill-filled border-forms-border-filled px-onepulse py-threepulse items-center gap-none self-stretch rounded-form border opacity-opaque group hover:border-halfpulse
`,variants:{size:{md:"h-medium text-threepulse",ml:"h-mediumlarge text-threeandhalfpulse",lg:"h-large text-hreeandhalfpulse",xl:"h-extralarge text-threeandhalfpulse"},readOnly:{true:"border-forms-border-readonly bg-forms-fill-readonly text-text-neutral-readonly hover:border-quarterpulse",false:""},disabled:{true:"border-forms-border-disabled bg-forms-fill-disabled text-text-neutral-disabled hover:border-quarterpulse",false:""},hasError:{true:"border-forms-border-error border-quarterpulse bg-forms-fill-error",false:"border-quarterpulse"}},defaultVariants:{}});import{jsx as _e}from"react/jsx-runtime";var de=({__scopeInputSelect:t,children:n})=>{let{hasError:r,size:a,disabled:e,readOnly:l}=h("InputSelectHelperText",t);return _e("div",{"data-testid":"select-field-container",className:ie({hasError:r,size:a,disabled:e,readOnly:l}),children:n})};import{useMemo as ke}from"react";var ce=d({base:"justify-star flex w-[100%] flex-wrap items-center gap-onepulse px-twopulse text-left font-rdmodern font-semibold text-text-neutral-alternative text-threepulse tracking-inline-onepulse",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:{error:!1,disabled:!1,readOnly:!1}});import{jsx as D,jsxs as qe}from"react/jsx-runtime";var pe=l=>{var o=l,{withIcon:t,iconName:n="rdicon-warning-circle",__scopeInputSelect:r,children:a}=o,e=S(o,["withIcon","iconName","__scopeInputSelect","children"]);let{hasError:i,readOnly:s,disabled:p}=h("InputSelectHelperText",r),c=i?"rdicon-warning-circle":n,f=ke(()=>p?"colorTextNeutralDisabled":s?"colorTextNeutralReadonly":i?"colorTextDangerAlternative":"colorTextNeutralAlternative",[p,i,s]);return a?qe("div",m(u({},e),{"aria-disabled":p,className:ce({hasError:i,disabled:p,readOnly:s}),children:[t&&D("div",{className:"flex items-center",children:D(C,{symbol:c,color:f,size:"tiny"})}),D("span",{className:"flex flex-1",children:a})]})):null};import Ye from"react";import{jsx as fe}from"react/jsx-runtime";function ue(a){var e=a,{__scopeInputSelect:t,color:n="colorTextNeutralDefault"}=e,r=S(e,["__scopeInputSelect","color"]);let{size:l,hasError:o,disabled:i,readOnly:s}=h("InputSelectField",t),p=Ye.useMemo(()=>{let c={md:"small",ml:"small",lg:"small",xl:"small"};return c==null?void 0:c[l]},[l]);return fe("div",{className:"flex h-6 h-small w-6 items-center justify-center rounded-none opacity-100",children:fe(C,m(u({},r),{size:p,color:o?"colorTextDangerAlternative":i?"colorTextNeutralDisabled":s?"colorTextNeutralReadonly":"colorTextNeutralDefault"}))})}var me=d({base:`
w-[100%] align-middle m-none p-none
text-left font-rdmodern font-semibold tracking-tiny text-text-neutral text-nowrap truncate leading
`,variants:{size:{md:"text-threepulse",ml:"text-threeandhalfpulse",lg:"text-threeandhalfpulse",xl:"text-threeandhalfpulse"},readOnly:{true:"",false:""},disabled:{true:"cursor-not-allowed text-text-neutral-disabled",false:""}},compoundVariants:[{readOnly:!0,disabled:!1,class:"cursor-not-allowed text-text-neutral-readonly"}],defaultVariants:{disabled:!1,readOnly:!1}});import{jsx as be}from"react/jsx-runtime";var xe=({htmlFor:t,__scopeInputSelect:n,children:r})=>{let{size:a,disabled:e,readOnly:l}=h("InputSelectLabel",n);return be("div",{className:"flex h-extrasmall w-[100%] items-center rounded-none rounded-none border-none px-twopulse text-left",children:be("label",{htmlFor:t,className:me({disabled:e,readOnly:l,size:a}),"data-testid":"testid-label",children:r})})};import{jsx as he}from"react/jsx-runtime";var _="Select",ge=t=>{let{size:n="md",hasError:r=!1,disabled:a=!1,__scopeInputSelect:e,options:l,children:o,placeholder:i}=t,{selectedOption:s}=z();return he(Ke,m(u({},t),{size:n,scope:e,hasError:r,disabled:a,options:l,value:s==null?void 0:s.value,placeholder:i,children:he("div",{className:"size-${size} min-w-[5rem] flex-1 flex-shrink-0 flex-col items-start gap-halfpulse rounded-none border-none bg-transparent p-none font-rdmodern text-align-center opacity-opaque",children:o})}))};ge.displayName=_;var[Ue]=$e(_),[Ke,h]=Ue(_),M={Root:ge,Label:xe,FieldContainer:de,Icon:ue,Field:A,Actions:K,HelperText:pe};export{M as a,Te as b,Re as c};
//# sourceMappingURL=chunk-NSJY3JEC.js.map