@radix-ui/themes
Version:
[](https://radix-ui.com/themes)
3 lines (2 loc) • 2.48 kB
JavaScript
"use client";var M=Object.create;var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var H=(e,o)=>{for(var t in o)h(e,t,{get:o[t],enumerable:!0})},g=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of w(o))!B.call(e,c)&&c!==t&&h(e,c,{get:()=>o[c],enumerable:!(i=O(o,c))||i.enumerable});return e};var K=(e,o,t)=>(t=e!=null?M(T(e)):{},g(o||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e)),X=e=>g(h({},"__esModule",{value:!0}),e);var Y={};H(Y,{CheckboxGroup:()=>l,CheckboxGroupIndicator:()=>k,CheckboxGroupItem:()=>b,Indicator:()=>q,Item:()=>V,Root:()=>_,createCheckboxGroupScope:()=>F});module.exports=X(Y);var n=K(require("react")),s=require("radix-ui"),r=require("radix-ui/internal");const{useDirection:j}=s.Direction,R="CheckboxGroup",[z,F]=r.Context.createContextScope(R,[r.RovingFocus.createRovingFocusGroupScope,s.Checkbox.createCheckboxScope]),y=r.RovingFocus.createRovingFocusGroupScope(),S=s.Checkbox.createCheckboxScope(),[J,L]=z(R),l=n.forwardRef((e,o)=>{const{__scopeCheckboxGroup:t,name:i,defaultValue:c,value:p,required:u=!1,disabled:a=!1,orientation:x,dir:m,loop:P=!0,onValueChange:C,...v}=e,N=y(t),I=j(m),[D=[],d]=(0,r.useControllableState)({prop:p,defaultProp:c,onChange:C}),W=n.useCallback(f=>d((G=[])=>[...G,f]),[d]),U=n.useCallback(f=>d((G=[])=>G.filter(A=>A!==f)),[d]);return n.createElement(J,{scope:t,name:i,required:u,disabled:a,value:D,onItemCheck:W,onItemUncheck:U},n.createElement(r.RovingFocus.Root,{asChild:!0,...N,orientation:x,dir:I,loop:P},n.createElement(r.Primitive.div,{role:"group","data-disabled":a?"":void 0,dir:I,...v,ref:o})))});l.displayName=R;const E="CheckboxGroupItem",b=n.forwardRef((e,o)=>{const{__scopeCheckboxGroup:t,disabled:i,...c}=e,p=L(E,t),u=p.disabled||i,a=y(t),x=S(t),m=n.useRef(null),P=(0,r.useComposedRefs)(o,m),C=p.value?.includes(c.value);return n.createElement(r.RovingFocus.Item,{asChild:!0,...a,focusable:!u,active:C},n.createElement(s.Checkbox.Root,{name:p.name,disabled:u,required:p.required,checked:C,...x,...c,ref:P,onCheckedChange:v=>{v?p.onItemCheck(e.value):p.onItemUncheck(e.value)}}))});b.displayName=E;const Q="CheckboxGroupIndicator",k=n.forwardRef((e,o)=>{const{__scopeCheckboxGroup:t,...i}=e,c=S(t);return n.createElement(s.Checkbox.Indicator,{...c,...i,ref:o})});k.displayName=Q;const _=l,V=b,q=k;
//# sourceMappingURL=checkbox-group.primitive.js.map
;