Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-radio-group

Package Overview
Dependencies
Maintainers
5
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-radio-group - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

18

dist/index.d.ts

@@ -21,2 +21,3 @@ import * as React from "react";

required?: React.ComponentProps<typeof Radio>['required'];
rovingFocus?: boolean;
onValueChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;

@@ -26,10 +27,11 @@ }>;

export const RadioGroup: RadioGroupPrimitive;
type RadioGroupItemOwnProps = Merge<Omit<Polymorphic.OwnProps<typeof Radio>, 'name'>, {
type RadioGroupItemOwnProps = Polymorphic.OwnProps<typeof RadioGroupItemImpl>;
type RadioGroupItemPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof RadioGroupItemImpl>, RadioGroupItemOwnProps>;
export const RadioGroupItem: RadioGroupItemPrimitive;
type RadioGroupItemImplOwnProps = Merge<Omit<Polymorphic.OwnProps<typeof Radio>, 'name'>, {
value: string;
}>;
type RadioGroupItemPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Radio>, RadioGroupItemOwnProps>;
export const RadioGroupItem: RadioGroupItemPrimitive;
export const RadioGroupIndicator: Polymorphic.ForwardRefComponent<"span", Merge<{
selector?: string | null | undefined;
}, {
type RadioGroupItemImplPrimitive = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Radio>, RadioGroupItemImplOwnProps>;
declare const RadioGroupItemImpl: RadioGroupItemImplPrimitive;
export const RadioGroupIndicator: Polymorphic.ForwardRefComponent<"span", Merge<import("@radix-ui/react-primitive").PrimitiveOwnProps, {
forceMount?: true | undefined;

@@ -39,5 +41,3 @@ }>>;

export const Item: RadioGroupItemPrimitive;
export const Indicator: Polymorphic.ForwardRefComponent<"span", Merge<{
selector?: string | null | undefined;
}, {
export const Indicator: Polymorphic.ForwardRefComponent<"span", Merge<import("@radix-ui/react-primitive").PrimitiveOwnProps, {
forceMount?: true | undefined;

@@ -44,0 +44,0 @@ }>>;

@@ -1,2 +0,2 @@

var e,r,t=require("@radix-ui/react-roving-focus"),n=t.RovingFocusGroup,o=t.useRovingFocus,a=require("@radix-ui/utils").getSelector,i=require("@radix-ui/react-label").useLabelContext,u=require("@radix-ui/react-presence").Presence,l=require("@radix-ui/react-primitive").Primitive,c=require("@radix-ui/react-utils"),d=c.composeEventHandlers,s=c.createContext,f=c.useCallbackRef,p=c.useControlledState,v=c.useComposedRefs,y=c.extendComponent,b=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e);function m(){return(m=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function h(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function g(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var R=g(s("RadioContext","Radio"),2),C=R[0],k=R[1],w=b.forwardRef((function(e,r){var t=e.as,n=void 0===t?"button":t,o=e.selector,u=void 0===o?a("Radio"):o,c=e["aria-labelledby"],s=e.name,f=e.checked,y=e.defaultChecked,O=e.required,R=e.disabled,k=e.readOnly,w=e.value,x=void 0===w?"on":w,I=e.onCheckedChange,S=h(e,["as","selector","aria-labelledby","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),q=b.useRef(null),E=b.useRef(null),P=v(r,E),A=i(E),G=c||A,M=g(p({prop:f,defaultProp:y}),2),D=M[0],F=void 0!==D&&D,V=M[1],N=b.useMemo((function(){return{checked:F,disabled:R}}),[F,R]);return b.createElement(b.Fragment,null,b.createElement("input",{ref:q,type:"radio",name:s,checked:F,required:O,disabled:R,readOnly:k,value:x,hidden:!0,onChange:d(I,(function(e){V(e.target.checked)}))}),b.createElement(C.Provider,{value:N},b.createElement(l,m({type:"button",role:"radio","aria-checked":F,"aria-labelledby":G,"data-state":j(F),"data-readonly":k,"data-disabled":R?"":void 0},S,{as:n,selector:u,ref:P,disabled:R,value:x,onClick:d(e.onClick,(function(){var e;return null===(e=q.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));w.displayName="Radio";var x=b.forwardRef((function(e,r){var t=e.as,n=void 0===t?"span":t,o=e.selector,i=void 0===o?a("RadioIndicator"):o,c=e.forceMount,d=h(e,["as","selector","forceMount"]),s=k("RadioIndicator");return b.createElement(u,{present:c||s.checked},b.createElement(l,m({"data-state":j(s.checked),"data-disabled":s.disabled?"":void 0},d,{as:n,selector:i,ref:r})))}));function j(e){return e?"checked":"unchecked"}function I(){return(I=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function S(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function q(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return E(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return E(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}x.displayName="RadioIndicator";var P=q(s("RadioGroupContext","RadioGroup"),2),A=P[0],G=P[1],M=b.forwardRef((function(e,r){var t=e.name,o=e.selector,u=void 0===o?a("RadioGroup"):o,c=e["aria-labelledby"],s=e.defaultValue,v=e.value,y=e.required,m=e.onValueChange,h=S(e,["name","selector","aria-labelledby","defaultValue","value","required","onValueChange"]),g=i(),O=c||g,R=f(m),C=q(p({prop:v,defaultProp:s}),2),k=C[0],w=C[1],x=b.useMemo((function(){return{name:t,value:k,required:y,onValueChange:d(R,(function(e){w(e.target.value)}))}}),[t,k,y,R,w]);return b.createElement(A.Provider,{value:x},b.createElement(n,{loop:!0},b.createElement(l,I({},h,{selector:u,ref:r,role:"radiogroup","aria-labelledby":O}))))}));exports.RadioGroup=M,M.displayName="RadioGroup";var D=b.forwardRef((function(e,r){var t=e.selector,n=void 0===t?a("RadioGroupItem"):t,i=e.disabled,u=e.required,l=S(e,["selector","disabled","required"]),c=G("RadioGroupItem"),s=b.useRef(null),f=v(r,s),p=c.value===e.value,y=o({disabled:i,active:p}),m=d(l.onCheckedChange,c.onValueChange),h=d(l.onKeyDown,y.onKeyDown),g=d(l.onMouseDown,y.onMouseDown),O=d(l.onFocus,d(y.onFocus,(function(){var e;void 0!==c.value&&(null===(e=s.current)||void 0===e||e.click())})));return b.createElement(w,I({},l,y,{name:c.name,selector:n,ref:f,disabled:i,required:null!=u?u:c.required,checked:p,onCheckedChange:m,onKeyDown:h,onMouseDown:g,onFocus:O}))}));exports.RadioGroupItem=D,D.displayName="RadioGroupItem";var F=y(x,"RadioGroupIndicator");exports.RadioGroupIndicator=F;var V=M;exports.Root=V;var N=D;exports.Item=N;var K=F;exports.Indicator=K;
var e,r,t=require("@radix-ui/react-roving-focus"),n=t.RovingFocusGroup,o=t.useRovingFocus,a=require("@radix-ui/utils").getSelector,i=require("@radix-ui/react-label").useLabelContext,u=require("@radix-ui/react-presence").Presence,l=require("@radix-ui/react-primitive").Primitive,c=require("@radix-ui/react-utils"),d=c.composeEventHandlers,f=c.createContext,s=c.useCallbackRef,v=c.useControlledState,p=c.useComposedRefs,y=c.extendComponent,b=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e);function m(){return(m=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function h(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function g(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return R(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return R(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var O=g(f("RadioContext","Radio"),2),C=O[0],k=O[1],w=b.forwardRef((function(e,r){var t=e.as,n=void 0===t?"button":t,o=e.selector,u=void 0===o?a("Radio"):o,c=e["aria-labelledby"],f=e.name,s=e.checked,y=e.defaultChecked,R=e.required,O=e.disabled,k=e.readOnly,w=e.value,x=void 0===w?"on":w,I=e.onCheckedChange,E=h(e,["as","selector","aria-labelledby","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),S=b.useRef(null),q=b.useRef(null),G=p(r,q),P=i(q),A=c||P,F=g(v({prop:s,defaultProp:y}),2),M=F[0],D=void 0!==M&&M,V=F[1],N=b.useMemo((function(){return{checked:D,disabled:O}}),[D,O]);return b.createElement(b.Fragment,null,b.createElement("input",{ref:S,type:"radio",name:f,checked:D,required:R,disabled:O,readOnly:k,value:x,hidden:!0,onChange:d(I,(function(e){V(e.target.checked)}))}),b.createElement(C.Provider,{value:N},b.createElement(l,m({type:"button",role:"radio","aria-checked":D,"aria-labelledby":A,"data-state":j(D),"data-readonly":k,"data-disabled":O?"":void 0},E,{as:n,selector:u,ref:G,disabled:O,value:x,onClick:d(e.onClick,(function(){var e;return null===(e=S.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));w.displayName="Radio";var x=b.forwardRef((function(e,r){var t=e.as,n=void 0===t?"span":t,o=e.selector,i=void 0===o?a("RadioIndicator"):o,c=e.forceMount,d=h(e,["as","selector","forceMount"]),f=k("RadioIndicator");return b.createElement(u,{present:c||f.checked},b.createElement(l,m({"data-state":j(f.checked),"data-disabled":f.disabled?"":void 0},d,{as:n,selector:i,ref:r})))}));function j(e){return e?"checked":"unchecked"}function I(){return(I=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function E(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function S(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return q(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return q(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}x.displayName="RadioIndicator";var G=S(f("RadioGroupContext","RadioGroup"),2),P=G[0],A=G[1],F=b.forwardRef((function(e,r){var t=e.name,o=e.selector,u=void 0===o?a("RadioGroup"):o,c=e["aria-labelledby"],f=e.defaultValue,p=e.value,y=e.required,m=e.rovingFocus,h=void 0===m||m,g=e.onValueChange,R=E(e,["name","selector","aria-labelledby","defaultValue","value","required","rovingFocus","onValueChange"]),O=i(),C=c||O,k=s(g),w=S(v({prop:p,defaultProp:f}),2),x=w[0],j=w[1],q=b.useMemo((function(){return{name:t,value:x,required:y,rovingFocus:h,onValueChange:d(k,(function(e){j(e.target.value)}))}}),[t,x,y,h,k,j]),G=b.createElement(l,I({},R,{selector:u,ref:r,role:"radiogroup","aria-labelledby":C}));return b.createElement(P.Provider,{value:q},h?b.createElement(n,{loop:!0},G):G)}));exports.RadioGroup=F,F.displayName="RadioGroup";var M=b.forwardRef((function(e,r){return A("RadioGroupItem").rovingFocus?b.createElement(D,I({},e,{ref:r})):b.createElement(V,I({},e,{ref:r}))}));exports.RadioGroupItem=M,M.displayName="RadioGroupItem";var D=b.forwardRef((function(e,r){var t=e.disabled,n=E(e,["disabled"]),a=A("RadioGroupItem"),i=b.useRef(null),u=p(r,i),l=a.value===n.value,c=o({disabled:t,active:l});return b.createElement(V,I({},n,c,{ref:u,disabled:t,onKeyDown:d(n.onKeyDown,c.onKeyDown),onMouseDown:d(n.onMouseDown,c.onMouseDown),onFocus:d(n.onFocus,d(c.onFocus,(function(){var e;void 0!==a.value&&(null===(e=i.current)||void 0===e||e.click())})))}))})),V=b.forwardRef((function(e,r){var t=e.selector,n=void 0===t?a("RadioGroupItem"):t,o=e.disabled,i=e.required,u=E(e,["selector","disabled","required"]),l=A("RadioGroupItem"),c=l.value===e.value,f=d(u.onCheckedChange,l.onValueChange);return b.createElement(w,I({},u,{name:l.name,selector:n,ref:r,disabled:o,required:null!=i?i:l.required,checked:c,onCheckedChange:f}))})),N=y(x,"RadioGroupIndicator");exports.RadioGroupIndicator=N;var K=F;exports.Root=K;var T=M;exports.Item=T;var U=N;exports.Indicator=U;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{RovingFocusGroup as e,useRovingFocus as r}from"@radix-ui/react-roving-focus";import{getSelector as o}from"@radix-ui/utils";import{useLabelContext as a}from"@radix-ui/react-label";import{Presence as t}from"@radix-ui/react-presence";import{Primitive as n}from"@radix-ui/react-primitive";import{composeEventHandlers as l,createContext as d,useCallbackRef as i,useControlledState as c,useComposedRefs as u,extendComponent as s}from"@radix-ui/react-utils";import*as p from"react";function f(){return(f=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}function m(e,r){if(null==e)return{};var o,a,t=function(e,r){if(null==e)return{};var o,a,t={},n=Object.keys(e);for(a=0;a<n.length;a++)o=n[a],r.indexOf(o)>=0||(t[o]=e[o]);return t}(e,r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a<n.length;a++)o=n[a],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(t[o]=e[o])}return t}const b="Radio",v="button",[y,h]=d(b+"Context",b),g=p.forwardRef(((e,r)=>{const{as:t=v,selector:d=o(b),"aria-labelledby":i,name:s,checked:h,defaultChecked:g,required:O,disabled:k,readOnly:R,value:x="on",onCheckedChange:w}=e,j=m(e,["as","selector","aria-labelledby","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),E=p.useRef(null),G=p.useRef(null),I=u(r,G),P=a(G),q=i||P,[D=!1,M]=c({prop:h,defaultProp:g}),V=p.useMemo((()=>({checked:D,disabled:k})),[D,k]);return p.createElement(p.Fragment,null,p.createElement("input",{ref:E,type:"radio",name:s,checked:D,required:O,disabled:k,readOnly:R,value:x,hidden:!0,onChange:l(w,(e=>{M(e.target.checked)}))}),p.createElement(y.Provider,{value:V},p.createElement(n,f({type:"button",role:"radio","aria-checked":D,"aria-labelledby":q,"data-state":C(D),"data-readonly":R,"data-disabled":k?"":void 0},j,{as:t,selector:d,ref:I,disabled:k,value:x,onClick:l(e.onClick,(()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));g.displayName=b;const O="RadioIndicator",k="span",R=p.forwardRef(((e,r)=>{const{as:a=k,selector:l=o(O),forceMount:d}=e,i=m(e,["as","selector","forceMount"]),c=h(O);return p.createElement(t,{present:d||c.checked},p.createElement(n,f({"data-state":C(c.checked),"data-disabled":c.disabled?"":void 0},i,{as:a,selector:l,ref:r})))}));function C(e){return e?"checked":"unchecked"}function x(){return(x=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}function w(e,r){if(null==e)return{};var o,a,t=function(e,r){if(null==e)return{};var o,a,t={},n=Object.keys(e);for(a=0;a<n.length;a++)o=n[a],r.indexOf(o)>=0||(t[o]=e[o]);return t}(e,r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a<n.length;a++)o=n[a],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(t[o]=e[o])}return t}R.displayName=O;const j="RadioGroup",[E,G]=d("RadioGroupContext",j);export const RadioGroup=p.forwardRef(((r,t)=>{const{name:d,selector:u=o(j),"aria-labelledby":s,defaultValue:f,value:m,required:b,onValueChange:v}=r,y=w(r,["name","selector","aria-labelledby","defaultValue","value","required","onValueChange"]),h=a(),g=s||h,O=i(v),[k,R]=c({prop:m,defaultProp:f}),C=p.useMemo((()=>({name:d,value:k,required:b,onValueChange:l(O,(e=>{R(e.target.value)}))})),[d,k,b,O,R]);return p.createElement(E.Provider,{value:C},p.createElement(e,{loop:!0},p.createElement(n,x({},y,{selector:u,ref:t,role:"radiogroup","aria-labelledby":g}))))}));RadioGroup.displayName=j;const I="RadioGroupItem";export const RadioGroupItem=p.forwardRef(((e,a)=>{const{selector:t=o(I),disabled:n,required:d}=e,i=w(e,["selector","disabled","required"]),c=G(I),s=p.useRef(null),f=u(a,s),m=c.value===e.value,b=r({disabled:n,active:m}),v=l(i.onCheckedChange,c.onValueChange),y=l(i.onKeyDown,b.onKeyDown),h=l(i.onMouseDown,b.onMouseDown),O=l(i.onFocus,l(b.onFocus,(()=>{var e;void 0!==c.value&&(null===(e=s.current)||void 0===e||e.click())})));return p.createElement(g,x({},i,b,{name:c.name,selector:t,ref:f,disabled:n,required:null!=d?d:c.required,checked:m,onCheckedChange:v,onKeyDown:y,onMouseDown:h,onFocus:O}))}));RadioGroupItem.displayName=I;export const RadioGroupIndicator=s(R,"RadioGroupIndicator");export const Root=RadioGroup;export const Item=RadioGroupItem;export const Indicator=RadioGroupIndicator;
import{RovingFocusGroup as e,useRovingFocus as r}from"@radix-ui/react-roving-focus";import{getSelector as o}from"@radix-ui/utils";import{useLabelContext as a}from"@radix-ui/react-label";import{Presence as t}from"@radix-ui/react-presence";import{Primitive as n}from"@radix-ui/react-primitive";import{composeEventHandlers as d,createContext as l,useCallbackRef as i,useControlledState as c,useComposedRefs as u,extendComponent as s}from"@radix-ui/react-utils";import*as p from"react";function f(){return(f=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}const m="Radio",v="button",[h,b]=l(m+"Context",m),R=p.forwardRef(((e,r)=>{const{as:t=v,selector:l=o(m),"aria-labelledby":i,name:s,checked:b,defaultChecked:R,required:y,disabled:g,readOnly:k,value:w="on",onCheckedChange:x,...E}=e,G=p.useRef(null),I=p.useRef(null),F=u(r,I),O=a(I),q=i||O,[D=!1,P]=c({prop:b,defaultProp:R}),M=p.useMemo((()=>({checked:D,disabled:g})),[D,g]);return p.createElement(p.Fragment,null,p.createElement("input",{ref:G,type:"radio",name:s,checked:D,required:y,disabled:g,readOnly:k,value:w,hidden:!0,onChange:d(x,(e=>{P(e.target.checked)}))}),p.createElement(h.Provider,{value:M},p.createElement(n,f({type:"button",role:"radio","aria-checked":D,"aria-labelledby":q,"data-state":C(D),"data-readonly":k,"data-disabled":g?"":void 0},E,{as:t,selector:l,ref:F,disabled:g,value:w,onClick:d(e.onClick,(()=>{var e;return null===(e=G.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));R.displayName=m;const y="RadioIndicator",g="span",k=p.forwardRef(((e,r)=>{const{as:a=g,selector:d=o(y),forceMount:l,...i}=e,c=b(y);return p.createElement(t,{present:l||c.checked},p.createElement(n,f({"data-state":C(c.checked),"data-disabled":c.disabled?"":void 0},i,{as:a,selector:d,ref:r})))}));function C(e){return e?"checked":"unchecked"}function w(){return(w=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}k.displayName=y;const x="RadioGroup",[E,G]=l("RadioGroupContext",x);export const RadioGroup=p.forwardRef(((r,t)=>{const{name:l,selector:u=o(x),"aria-labelledby":s,defaultValue:f,value:m,required:v,rovingFocus:h=!0,onValueChange:b,...R}=r,y=a(),g=s||y,k=i(b),[C,G]=c({prop:m,defaultProp:f}),I=p.useMemo((()=>({name:l,value:C,required:v,rovingFocus:h,onValueChange:d(k,(e=>{G(e.target.value)}))})),[l,C,v,h,k,G]),F=p.createElement(n,w({},R,{selector:u,ref:t,role:"radiogroup","aria-labelledby":g}));return p.createElement(E.Provider,{value:I},h?p.createElement(e,{loop:!0},F):F)}));RadioGroup.displayName=x;const I="RadioGroupItem";export const RadioGroupItem=p.forwardRef(((e,r)=>G(I).rovingFocus?p.createElement(F,w({},e,{ref:r})):p.createElement(O,w({},e,{ref:r}))));RadioGroupItem.displayName=I;const F=p.forwardRef(((e,o)=>{const{disabled:a,...t}=e,n=G(I),l=p.useRef(null),i=u(o,l),c=n.value===t.value,s=r({disabled:a,active:c});return p.createElement(O,w({},t,s,{ref:i,disabled:a,onKeyDown:d(t.onKeyDown,s.onKeyDown),onMouseDown:d(t.onMouseDown,s.onMouseDown),onFocus:d(t.onFocus,d(s.onFocus,(()=>{var e;void 0!==n.value&&(null===(e=l.current)||void 0===e||e.click())})))}))})),O=p.forwardRef(((e,r)=>{const{selector:a=o(I),disabled:t,required:n,...l}=e,i=G(I),c=i.value===e.value,u=d(l.onCheckedChange,i.onValueChange);return p.createElement(R,w({},l,{name:i.name,selector:a,ref:r,disabled:t,required:null!=n?n:i.required,checked:c,onCheckedChange:u}))}));export const RadioGroupIndicator=s(k,"RadioGroupIndicator");export const Root=RadioGroup;export const Item=RadioGroupItem;export const Indicator=RadioGroupIndicator;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-radio-group",
"version": "0.0.5",
"version": "0.0.6",
"license": "MIT",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc