2 lines
1.6 KiB
JavaScript
2 lines
1.6 KiB
JavaScript
import{r as a,u as m,j as t,c as k}from"./index-B92aEPQH.js";import{F as i,a as V}from"./FormContext-IkkKm1bh.js";function A(s,e){return a.Children.toArray(s).some(o=>a.isValidElement(o)&&o.type===e)}const j=a.forwardRef(({id:s,bsPrefix:e,className:o,type:r="checkbox",isValid:n=!1,isInvalid:c=!1,as:h="input",...u},p)=>{const{controlId:l}=a.useContext(i);return e=m(e,"form-check-input"),t.jsx(h,{...u,ref:p,type:r,id:s||l,className:k(o,e,n&&"is-valid",c&&"is-invalid")})});j.displayName="FormCheckInput";const d=a.forwardRef(({bsPrefix:s,className:e,htmlFor:o,...r},n)=>{const{controlId:c}=a.useContext(i);return s=m(s,"form-check-label"),t.jsx("label",{...r,ref:n,htmlFor:o||c,className:k(e,s)})});d.displayName="FormCheckLabel";const I=a.forwardRef(({id:s,bsPrefix:e,bsSwitchPrefix:o,inline:r=!1,reverse:n=!1,disabled:c=!1,isValid:h=!1,isInvalid:u=!1,feedbackTooltip:p=!1,feedback:l,feedbackType:v,className:N,style:w,title:L="",type:f="checkbox",label:C,children:F,as:R="input",...E},$)=>{e=m(e,"form-check"),o=m(o,"form-switch");const{controlId:x}=a.useContext(i),g=a.useMemo(()=>({controlId:s||x}),[x,s]),y=!F&&C!=null&&C!==!1||A(F,d),O=t.jsx(j,{...E,type:f==="switch"?"checkbox":f,ref:$,isValid:h,isInvalid:u,disabled:c,as:R});return t.jsx(i.Provider,{value:g,children:t.jsx("div",{style:w,className:k(N,y&&e,r&&`${e}-inline`,n&&`${e}-reverse`,f==="switch"&&o),children:F||t.jsxs(t.Fragment,{children:[O,y&&t.jsx(d,{title:L,children:C}),l&&t.jsx(V,{type:v,tooltip:p,children:l})]})})})});I.displayName="FormCheck";const T=Object.assign(I,{Input:j,Label:d});export{T as F,j as a};
|