@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.
38 lines (35 loc) • 7.58 kB
JavaScript
import{a as t}from"./chunk-2MB3Y6WI.js";import{a as b}from"./chunk-MNT4RB4T.js";import{a as c,b as f,c as u}from"./chunk-DDCCLFYC.js";import{createContextScope as K}from"@radix-ui/react-context";import{useRef as j}from"react";import{useState as U}from"react";function R(){let[e,o]=U("");return{UseRadio:R,selectedValue:e,setSelectedValue:o,isChecked:(r,a)=>a||e===r,iconSizeMapping:{md:"tiny",ml:"small",lg:"medium",xl:"medium"}}}var I=t({base:`
flex items-center rounded-pill min-width-size-huge p-[4px]
active:border-focused focus:border-focused mb-twopulse
`,variants:{hasError:{true:"border-forms-border-error border-halfpulse"},readOnly:{true:"cursor-not-allowed border-[#00000000]"},disabled:{true:"cursor-not-allowed border-[transparent]"},hasIconOnly:{true:`justify-center overflow-hidden
`}},compoundVariants:[{readOnly:!0,disabled:!1,class:"cursor-not-allowed"},{hasIconOnly:!0,size:"md",class:""},{hasIconOnly:!0,size:"ml",class:""},{hasIconOnly:!0,size:"lg",class:""},{hasIconOnly:!0,size:"xl",class:""}],defaultVariants:{size:"xl",hasError:!1,readOnly:!1,disabled:!1,hasIconOnly:!1}}),P=t({base:`
group flex items-center justify-start rounded-pill min-w-[128px] relative font-wheight-regular
font-rdmodern font-regular bg-action-fill-neutral-tertiary-enabled border-action-border-neutral-tertiary-enabled
hover:bg-action-fill-neutral-tertiary-hovered hover:border-action-border-neutral-tertiary-hovered active:bg-action-fill-neutral-tertiary-pressed active:border-action-border-focused cursor:pointer
has-[:focus]:border-action-border-focused border-halfpulse focus:border-action-border-focused focus-visible:border-action-border-focused
`,variants:{size:{md:"min-h-medium gap-onepulse px-fourpulse py-onepulse text-threepulse leading-medium",ml:"min-h-mediumlarge gap-twopulse px-fourpulse py-twopulse text-threeandhalfpulse leading-small",lg:"min-h-large gap-twopulse px-fivepulse py-twopulse text-fourpulse leading-small",xl:"min-h-extralarge gap-twopulse px-sixpulse py-threepulse text-fourpulse leading-small"},hasError:{true:`
bg-action-fill-neutral-tertiary-enabled border-action-border-neutral-tertiary-enabled focus:border-action-border-neutral-tertiary-enabled hover:bg-action-fill-neutral-tertiary-hovered
active:border-action-border-neutral-tertiary-enabled has-[:unchecked]:border-none focus-visible:border-action-border-neutral-tertiary-enabled
`},readOnly:{true:`
border-[#00000000] bg-[#00000000] hover:border-[#00000000] hover:bg-[#00000000] focus:border-[#00000000]
focus:bg-[#00000000] focus-visible:bg-[#00000000] active:border-[#00000000] active:bg-[#00000000]
`},disabled:{true:`
cursor-not-allowed border-action-fill-neutral-tertiary-disabled bg-action-fill-neutral-tertiary-disabled hover:bg-action-fill-neutral-tertiary-disabled
active:bg-action-fill-neutral-tertiary-disabled active:border-action-border-neutral-tertiary-disabled focus:bg-action-fill-neutral-tertiary-disabled
focus:border-action-border-neutral-tertiary-disabled focus-visible:bg-action-fill-neutral-tertiary-disabled
`},hasIconOnly:{true:`justify-center min-w-[auto] gap-none
`}},compoundVariants:[{readOnly:!1,disabled:!1,class:`
[&:not(:focus-within)]:has-[:placeholder-shown]:bg-forms-fill
[&:not(:focus-within)]:has-[:placeholder-shown]:hover:bg-forms-fill-hovered
`},{hasError:!1,readOnly:!1,disabled:!1,class:`
`},{hasIconOnly:!0,size:"xl",class:"h-extralarge w-extralarge px-threepulse py-threepulse"},{hasIconOnly:!0,size:"lg",class:"h-large w-large px-twopulse py-twopulse"},{hasIconOnly:!0,size:"ml",class:"h-mediumlarge w-mediumlarge px-twopulse py-twopulse"},{hasIconOnly:!0,size:"md",class:"h-medium w-medium px-twopulse py-twopulse"}],defaultVariants:{size:"xl",hasError:!1,readOnly:!1,disabled:!1,hasIconOnly:!1}}),C=t({base:`
flex justify-start items-center font-rdmodern text-text-neutral tracking-tiny font-wheight-regular text-left min-h-small line-clamp-4 mt-[5px]
`,variants:{size:{md:"min-h-medium text-threepulse leading-medium",ml:"text-threeandhalfpulse leading-small",lg:"text-fourpulse leading-small",xl:"text-fourpulse leading-small"},readOnly:{true:"text-text-neutral-readonly"},disabled:{true:"cursor-not-allowed text-text-neutral-disabled",false:""},hasIconOnly:{true:"hidden"}},compoundVariants:[{readOnly:!0,disabled:!1,class:"cursor-not-allowed text-text-neutral-readonly"}],defaultVariants:{readOnly:!1,disabled:!1,hasIconOnly:!1}}),S=t({base:`
hidden
`}),N=t({base:`
group-has-[:checked]:hidden
`,variants:{size:{md:"h-tiny",ml:"h-small",lg:"h-medium",xl:"h-medium"},readOnly:{true:""},disabled:{true:"cursor-not-allowed text-text-neutral-disabled"}}}),k=t({base:`
hidden group-has-[:checked]:block
`,variants:{size:{md:"h-tiny",ml:"h-small",lg:"h-medium",xl:"h-medium"},readOnly:{true:""},disabled:{true:"cursor-not-allowed text-text-neutral-disabled"}}});import{jsx as p,jsxs as Y}from"react/jsx-runtime";var L=e=>{let V=e,{__scopeRadio:o,name:l,value:s,checked:r,children:a,onChange:h,iconOnly:n,id:y=null}=V,g=u(V,["__scopeRadio","name","value","checked","children","onChange","iconOnly","id"]),{disabled:i,size:d="lg",id:M,readOnly:x,error:w,selectedValue:A}=m("RadioButton",o),{iconSizeMapping:z}=R(),G=j(null),T=r||s===A;return p("div",{className:I({disabled:i,readOnly:x,hasIconOnly:n,hasError:w}),children:Y("label",{className:P({disabled:i,readOnly:x,size:d,hasIconOnly:n,hasError:w}),"aria-disabled":i,children:[p("input",c({ref:G,type:"radio",className:S(),id:y||M,disabled:i,name:l,value:s,checked:T,onChange:h,defaultChecked:T},g)),p("span",{className:N({size:d}),children:p(b,{size:z[d],symbol:"rdicon-radio-button-unselected",color:i?"colorTextNeutralDisabled":x?"colorTextNeutralReadonly":"colorTextNeutralDefault"})}),p("span",{className:k({size:d}),children:p(b,{size:z[d],symbol:"rdicon-radio-button-selected",color:i?"colorTextNeutralDisabled":x?"colorTextNeutralReadonly":"colorTextNeutralDefault"})}),!n&&a]})})};var E=t({base:` flex justify-start items-center gap-onepulse font-rdmodern font-semibold text-text-danger-alternative text-threepulse
`,variants:{size:{md:"px-fourpulse",ml:"px-fourpulse",lg:"px-fivepulse",xl:"px-sixpulse"}},compoundVariants:[]});import{Fragment as F,jsx as v,jsxs as q}from"react/jsx-runtime";var H=s=>{var r=s,{children:e,__scopeRadio:o}=r,l=u(r,["children","__scopeRadio"]);let{error:a,size:h="lg",iconOnly:n}=m("RadioHelperText",o);return a?v(F,{children:!n&&q("div",f(c({},l),{className:E({size:h}),children:[v(b,{symbol:"rdicon-warning-circle",color:"colorTextDangerAlternative",size:"tiny"}),v("span",{className:"line-clamp-2",children:e})]}))}):null};import{jsx as J}from"react/jsx-runtime";var D=e=>{let{children:o,__scopeRadio:l}=e,{disabled:s,readOnly:r,size:a}=m("RadioLabel",l);return o?J("span",{className:C({disabled:s,readOnly:r,size:a}),children:o}):null};import{jsx as _}from"react/jsx-runtime";var O="Radio",B=e=>{let d=e,{size:o,children:l,disabled:s,readOnly:r,defaultValue:a,legend:h,error:n,iconOnly:y,__scopeRadio:g}=d,i=u(d,["size","children","disabled","readOnly","defaultValue","legend","error","iconOnly","__scopeRadio"]);return _(W,f(c({},e),{size:o,disabled:s,readOnly:r,error:n,scope:g,iconOnly:y,selectedValue:a,children:_("fieldset",f(c({},i),{className:"flex flex-col border-none",children:l}))}))};B.displayName=O;var[Q]=K(O),[W,m]=Q(O),X={Root:B,Button:L,Label:D,Helper:H};export{X as a};
//# sourceMappingURL=chunk-2OB6S26Y.js.map