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

@radix-ui/react-switch

Package Overview
Dependencies
Maintainers
8
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-switch - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

2

dist/index.d.ts

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

required?: InputDOMProps['required'];
onCheckedChange?: InputDOMProps['onChange'];
onCheckedChange?(checked: boolean): void;
}>;

@@ -13,0 +13,0 @@ export type SwitchPrimitive = Polymorphic.ForwardRefComponent<typeof SWITCH_DEFAULT_TAG, SwitchOwnProps>;

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

var e,t,r,a=require("@radix-ui/react-label").useLabelContext,i=require("@radix-ui/react-primitive").Primitive,c=require("@radix-ui/react-use-controllable-state").useControllableState,d=require("@radix-ui/react-context").createContext,n=require("@radix-ui/react-compose-refs").useComposedRefs,l=require("@radix-ui/primitive").composeEventHandlers,u=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e),o=(r=require("@babel/runtime/helpers/extends"))&&r.__esModule?r.default:r;const s="button",[b,h]=d("Switch"),f=/*#__PURE__*/u.forwardRef(((e,t)=>{const{as:r=s,"aria-labelledby":d,name:h,checked:f,defaultChecked:m,required:p,disabled:x,value:v="on",onCheckedChange:q,...C}=e,y=u.useRef(null),[w,E]=u.useState(null),S=n(t,(e=>E(e))),g=a(w),R=d||g,[P=!1,_]=c({prop:f,defaultProp:m});/*#__PURE__*/return u.createElement(u.Fragment,null,/*#__PURE__*/u.createElement("input",{ref:y,type:"checkbox",name:h,checked:P,required:p,disabled:x,value:v,style:{display:"none"},onChange:l(q,(e=>{_(e.target.checked)}))}),/*#__PURE__*/u.createElement(b,{checked:P,disabled:x},/*#__PURE__*/u.createElement(i,o({type:"button",role:"switch","aria-checked":P,"aria-labelledby":R,"aria-required":p,"data-state":k(P),"data-disabled":x?"":void 0,disabled:x,value:v},C,{as:r,ref:S,onClick:l(e.onClick,(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));exports.Switch=f;const m="span",p=/*#__PURE__*/u.forwardRef(((e,t)=>{const{as:r=m,...a}=e,c=h("SwitchThumb");/*#__PURE__*/return u.createElement(i,o({"data-state":k(c.checked),"data-disabled":c.disabled?"":void 0},a,{as:r,ref:t}))}));function k(e){return e?"checked":"unchecked"}exports.SwitchThumb=p;const x=f;exports.Root=x;const v=p;exports.Thumb=v;
var e,t,r,a=require("@radix-ui/react-label").useLabelContext,i=require("@radix-ui/react-primitive").Primitive,c=require("@radix-ui/react-use-size").useSize,o=require("@radix-ui/react-use-previous").usePrevious,n=require("@radix-ui/react-use-controllable-state").useControllableState,s=require("@radix-ui/react-context").createContext,u=require("@radix-ui/react-compose-refs").useComposedRefs,l=require("@radix-ui/primitive").composeEventHandlers,d=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e),b=(r=require("@babel/runtime/helpers/extends"))&&r.__esModule?r.default:r;const p="button",[f,h]=s("Switch"),m=/*#__PURE__*/d.forwardRef(((e,t)=>{const{as:r=p,"aria-labelledby":c,name:o,checked:s,defaultChecked:h,required:m,disabled:x,value:k="on",onCheckedChange:y,...E}=e,[w,C]=d.useState(null),S=u(t,(e=>C(e))),g=a(w),P=c||g,R=d.useRef(!1),O=!w||Boolean(w.closest("form")),[T=!1,_]=n({prop:s,defaultProp:h,onChange:y});/*#__PURE__*/return d.createElement(f,{checked:T,disabled:x},/*#__PURE__*/d.createElement(i,b({type:"button",role:"switch","aria-checked":T,"aria-labelledby":P,"aria-required":m,"data-state":q(T),"data-disabled":x?"":void 0,disabled:x,value:k},E,{as:r,ref:S,onClick:l(e.onClick,(e=>{_((e=>!e)),O&&(R.current=e.isPropagationStopped(),R.current||e.stopPropagation())}))})),O&&/*#__PURE__*/d.createElement(v,{control:w,bubbles:!R.current,name:o,value:k,checked:T,required:m,disabled:x,style:{transform:"translateX(-100%)"}}))}));exports.Switch=m;const x="span",k=/*#__PURE__*/d.forwardRef(((e,t)=>{const{as:r=x,...a}=e,c=h("SwitchThumb");/*#__PURE__*/return d.createElement(i,b({"data-state":q(c.checked),"data-disabled":c.disabled?"":void 0},a,{as:r,ref:t}))}));exports.SwitchThumb=k;const v=e=>{const{control:t,checked:r,bubbles:a=!0,...i}=e,n=d.useRef(null),s=o(r),u=c(t);return d.useEffect((()=>{const e=n.current,t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,"checked").set;if(s!==r&&i){const t=new Event("click",{bubbles:a});i.call(e,r),e.dispatchEvent(t)}}),[s,r,a]),/*#__PURE__*/d.createElement("input",b({type:"checkbox",defaultChecked:r},i,{tabIndex:-1,ref:n,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function q(e){return e?"checked":"unchecked"}const y=m;exports.Root=y;const E=k;exports.Thumb=E;
//# sourceMappingURL=index.js.map

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

import{useLabelContext as e}from"@radix-ui/react-label";import{Primitive as t}from"@radix-ui/react-primitive";import{useControllableState as r}from"@radix-ui/react-use-controllable-state";import{createContext as a}from"@radix-ui/react-context";import{useComposedRefs as i}from"@radix-ui/react-compose-refs";import{composeEventHandlers as c}from"@radix-ui/primitive";import*as o from"react";import d from"@babel/runtime/helpers/esm/extends";const n="button",[l,u]=a("Switch");export const Switch=/*#__PURE__*/o.forwardRef(((a,u)=>{const{as:s=n,"aria-labelledby":h,name:p,checked:b,defaultChecked:f,required:k,disabled:x,value:v="on",onCheckedChange:w,...S}=a,y=o.useRef(null),[C,E]=o.useState(null),g=i(u,(e=>E(e))),R=e(C),T=h||R,[q=!1,F]=r({prop:b,defaultProp:f});/*#__PURE__*/return o.createElement(o.Fragment,null,/*#__PURE__*/o.createElement("input",{ref:y,type:"checkbox",name:p,checked:q,required:k,disabled:x,value:v,style:{display:"none"},onChange:c(w,(e=>{F(e.target.checked)}))}),/*#__PURE__*/o.createElement(l,{checked:q,disabled:x},/*#__PURE__*/o.createElement(t,d({type:"button",role:"switch","aria-checked":q,"aria-labelledby":T,"aria-required":k,"data-state":m(q),"data-disabled":x?"":void 0,disabled:x,value:v},S,{as:s,ref:g,onClick:c(a.onClick,(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));/*#__PURE__*/const s="span";export const SwitchThumb=/*#__PURE__*/o.forwardRef(((e,r)=>{const{as:a=s,...i}=e,c=u("SwitchThumb");/*#__PURE__*/return o.createElement(t,d({"data-state":m(c.checked),"data-disabled":c.disabled?"":void 0},i,{as:a,ref:r}))}));/*#__PURE__*/function m(e){return e?"checked":"unchecked"}export const Root=Switch;export const Thumb=SwitchThumb;
import{useLabelContext as e}from"@radix-ui/react-label";import{Primitive as t}from"@radix-ui/react-primitive";import{useSize as r}from"@radix-ui/react-use-size";import{usePrevious as o}from"@radix-ui/react-use-previous";import{useControllableState as a}from"@radix-ui/react-use-controllable-state";import{createContext as c}from"@radix-ui/react-context";import{useComposedRefs as i}from"@radix-ui/react-compose-refs";import{composeEventHandlers as n}from"@radix-ui/primitive";import*as s from"react";import d from"@babel/runtime/helpers/esm/extends";const l="button",[u,m]=c("Switch");export const Switch=/*#__PURE__*/s.forwardRef(((r,o)=>{const{as:c=l,"aria-labelledby":m,name:p,checked:h,defaultChecked:k,required:x,disabled:w,value:v="on",onCheckedChange:y,...E}=r,[S,C]=s.useState(null),g=i(o,(e=>C(e))),R=e(S),T=m||R,P=s.useRef(!1),q=!S||Boolean(S.closest("form")),[I=!1,O]=a({prop:h,defaultProp:k,onChange:y});/*#__PURE__*/return s.createElement(u,{checked:I,disabled:w},/*#__PURE__*/s.createElement(t,d({type:"button",role:"switch","aria-checked":I,"aria-labelledby":T,"aria-required":x,"data-state":f(I),"data-disabled":w?"":void 0,disabled:w,value:v},E,{as:c,ref:g,onClick:n(r.onClick,(e=>{O((e=>!e)),q&&(P.current=e.isPropagationStopped(),P.current||e.stopPropagation())}))})),q&&/*#__PURE__*/s.createElement(b,{control:S,bubbles:!P.current,name:p,value:v,checked:I,required:x,disabled:w,style:{transform:"translateX(-100%)"}}))}));/*#__PURE__*/const p="span";export const SwitchThumb=/*#__PURE__*/s.forwardRef(((e,r)=>{const{as:o=p,...a}=e,c=m("SwitchThumb");/*#__PURE__*/return s.createElement(t,d({"data-state":f(c.checked),"data-disabled":c.disabled?"":void 0},a,{as:o,ref:r}))}));/*#__PURE__*/const b=e=>{const{control:t,checked:a,bubbles:c=!0,...i}=e,n=s.useRef(null),l=o(a),u=r(t);return s.useEffect((()=>{const e=n.current,t=window.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(t,"checked").set;if(l!==a&&r){const t=new Event("click",{bubbles:c});r.call(e,a),e.dispatchEvent(t)}}),[l,a,c]),/*#__PURE__*/s.createElement("input",d({type:"checkbox",defaultChecked:a},i,{tabIndex:-1,ref:n,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function f(e){return e?"checked":"unchecked"}export const Root=Switch;export const Thumb=SwitchThumb;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-switch",
"version": "0.0.13",
"version": "0.0.14",
"license": "MIT",

@@ -24,6 +24,8 @@ "source": "src/index.ts",

"@radix-ui/react-context": "0.0.5",
"@radix-ui/react-label": "0.0.13",
"@radix-ui/react-polymorphic": "0.0.11",
"@radix-ui/react-primitive": "0.0.13",
"@radix-ui/react-use-controllable-state": "0.0.6"
"@radix-ui/react-label": "0.0.14",
"@radix-ui/react-polymorphic": "0.0.12",
"@radix-ui/react-primitive": "0.0.14",
"@radix-ui/react-use-controllable-state": "0.0.6",
"@radix-ui/react-use-previous": "0.0.5",
"@radix-ui/react-use-size": "0.0.6"
},

@@ -30,0 +32,0 @@ "peerDependencies": {

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