@radix-ui/react-switch
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,2 @@ | ||
var e,r,t=require("@radix-ui/utils").getSelector,n=require("@radix-ui/react-label").useLabelContext,a=require("@radix-ui/react-primitive").Primitive,i=require("@radix-ui/react-utils"),o=i.createContext,l=i.composeEventHandlers,c=i.useControlledState,u=i.useComposedRefs,d=(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 s(){return(s=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 f(e,r){if(null==e)return{};var t,n,a=function(e,r){if(null==e)return{};var t,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(a[t]=e[t]);return a}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function h(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,a=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(n=(o=l.next()).done)&&(t.push(o.value),!r||t.length!==r);n=!0);}catch(e){a=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(a)throw i}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return b(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 b(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 b(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 y=h(o("SwitchContext","Switch"),2),v=y[0],p=y[1],m=d.forwardRef((function(e,r){var i=e.as,o=void 0===i?"button":i,b=e.selector,y=void 0===b?t("Switch"):b,p=e["aria-labelledby"],m=e.children,g=e.name,O=e.checked,S=e.defaultChecked,k=e.required,x=e.disabled,C=e.readOnly,j=e.value,q=void 0===j?"on":j,E=e.onCheckedChange,P=f(e,["as","selector","aria-labelledby","children","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),A=d.useRef(null),R=d.useRef(null),T=u(r,R),I=n(R),F=p||I,M=h(c({prop:O,defaultProp:S}),2),N=M[0],_=void 0!==N&&N,D=M[1];return d.createElement(d.Fragment,null,d.createElement("input",{ref:A,type:"checkbox",name:g,checked:_,required:k,disabled:x,readOnly:C,value:q,hidden:!0,onChange:l(E,(function(e){D(e.target.checked)}))}),d.createElement(a,s({type:"button"},P,{as:o,selector:y,ref:T,role:"switch","aria-checked":_,"aria-labelledby":F,"aria-required":k,"data-state":w(_),"data-readonly":C,disabled:x,value:q,onClick:l(e.onClick,(function(){var e;return null===(e=A.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}),d.createElement(v.Provider,{value:_},m)))}));exports.Switch=m,m.displayName="Switch";var g=d.forwardRef((function(e,r){var n=e.as,i=void 0===n?"span":n,o=e.selector,l=void 0===o?t("SwitchThumb"):o,c=f(e,["as","selector"]),u=p("SwitchThumb");return d.createElement(a,s({},c,{as:i,selector:l,ref:r,"data-state":w(u)}))}));function w(e){return e?"checked":"unchecked"}exports.SwitchThumb=g,g.displayName="SwitchThumb";var O=m;exports.Root=O;var S=g;exports.Thumb=S; | ||
var e,r,t=require("@radix-ui/utils").getSelector,n=require("@radix-ui/react-label").useLabelContext,a=require("@radix-ui/react-primitive").Primitive,o=require("@radix-ui/react-utils"),i=o.createContext,l=o.composeEventHandlers,u=o.useControlledState,c=o.useComposedRefs,d=(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 s(){return(s=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 f(e,r){if(null==e)return{};var t,n,a=function(e,r){if(null==e)return{};var t,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t=o[n],r.indexOf(t)>=0||(a[t]=e[t]);return a}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)t=o[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function h(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,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return b(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 b(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 b(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 y=h(i("SwitchContext","Switch"),2),v=y[0],p=y[1],m=d.forwardRef((function(e,r){var o=e.as,i=void 0===o?"button":o,b=e.selector,y=void 0===b?t("Switch"):b,p=e["aria-labelledby"],m=e.name,g=e.checked,O=e.defaultChecked,S=e.required,k=e.disabled,x=e.readOnly,C=e.value,j=void 0===C?"on":C,q=e.onCheckedChange,E=f(e,["as","selector","aria-labelledby","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),P=d.useRef(null),A=d.useRef(null),R=c(r,A),T=n(A),I=p||T,F=h(u({prop:g,defaultProp:O}),2),M=F[0],N=void 0!==M&&M,_=F[1];return d.createElement(d.Fragment,null,d.createElement("input",{ref:P,type:"checkbox",name:m,checked:N,required:S,disabled:k,readOnly:x,value:j,hidden:!0,onChange:l(q,(function(e){_(e.target.checked)}))}),d.createElement(v.Provider,{value:N},d.createElement(a,s({type:"button"},E,{as:i,selector:y,ref:R,role:"switch","aria-checked":N,"aria-labelledby":I,"aria-required":S,"data-state":w(N),"data-readonly":x,disabled:k,value:j,onClick:l(e.onClick,(function(){var e;return null===(e=P.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));exports.Switch=m,m.displayName="Switch";var g=d.forwardRef((function(e,r){var n=e.as,o=void 0===n?"span":n,i=e.selector,l=void 0===i?t("SwitchThumb"):i,u=f(e,["as","selector"]),c=p("SwitchThumb");return d.createElement(a,s({},u,{as:o,selector:l,ref:r,"data-state":w(c)}))}));function w(e){return e?"checked":"unchecked"}exports.SwitchThumb=g,g.displayName="SwitchThumb";var O=m;exports.Root=O;var S=g;exports.Thumb=S; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{getSelector as e}from"@radix-ui/utils";import{useLabelContext as r}from"@radix-ui/react-label";import{Primitive as t}from"@radix-ui/react-primitive";import{createContext as a,composeEventHandlers as n,useControlledState as c,useComposedRefs as l}from"@radix-ui/react-utils";import*as o from"react";function i(){return(i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}function d(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},c=Object.keys(e);for(a=0;a<c.length;a++)t=c[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)t=c[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}const u="Switch",s="button",[h,f]=a(u+"Context",u);export const Switch=o.forwardRef(((a,f)=>{const{as:m=s,selector:p=e(u),"aria-labelledby":y,children:k,name:v,checked:w,defaultChecked:O,required:x,disabled:g,readOnly:C,value:S="on",onCheckedChange:j}=a,E=d(a,["as","selector","aria-labelledby","children","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),P=o.useRef(null),R=o.useRef(null),T=l(f,R),q=r(R),F=y||q,[N=!1,D]=c({prop:w,defaultProp:O});return o.createElement(o.Fragment,null,o.createElement("input",{ref:P,type:"checkbox",name:v,checked:N,required:x,disabled:g,readOnly:C,value:S,hidden:!0,onChange:n(j,(e=>{D(e.target.checked)}))}),o.createElement(t,i({type:"button"},E,{as:m,selector:p,ref:T,role:"switch","aria-checked":N,"aria-labelledby":F,"aria-required":x,"data-state":b(N),"data-readonly":C,disabled:g,value:S,onClick:n(a.onClick,(()=>{var e;return null===(e=P.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}),o.createElement(h.Provider,{value:N},k)))}));Switch.displayName=u;const m="SwitchThumb",p="span";export const SwitchThumb=o.forwardRef(((r,a)=>{const{as:n=p,selector:c=e(m)}=r,l=d(r,["as","selector"]),u=f(m);return o.createElement(t,i({},l,{as:n,selector:c,ref:a,"data-state":b(u)}))}));function b(e){return e?"checked":"unchecked"}SwitchThumb.displayName=m;export const Root=Switch;export const Thumb=SwitchThumb; | ||
import{getSelector as e}from"@radix-ui/utils";import{useLabelContext as r}from"@radix-ui/react-label";import{Primitive as t}from"@radix-ui/react-primitive";import{createContext as a,composeEventHandlers as n,useControlledState as c,useComposedRefs as l}from"@radix-ui/react-utils";import*as o from"react";function i(){return(i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}function u(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},c=Object.keys(e);for(a=0;a<c.length;a++)t=c[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)t=c[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}const d="Switch",s="button",[h,f]=a(d+"Context",d);export const Switch=o.forwardRef(((a,f)=>{const{as:m=s,selector:p=e(d),"aria-labelledby":y,name:k,checked:v,defaultChecked:w,required:O,disabled:x,readOnly:g,value:C="on",onCheckedChange:S}=a,j=u(a,["as","selector","aria-labelledby","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),E=o.useRef(null),P=o.useRef(null),R=l(f,P),T=r(P),q=y||T,[F=!1,N]=c({prop:v,defaultProp:w});return o.createElement(o.Fragment,null,o.createElement("input",{ref:E,type:"checkbox",name:k,checked:F,required:O,disabled:x,readOnly:g,value:C,hidden:!0,onChange:n(S,(e=>{N(e.target.checked)}))}),o.createElement(h.Provider,{value:F},o.createElement(t,i({type:"button"},j,{as:m,selector:p,ref:R,role:"switch","aria-checked":F,"aria-labelledby":q,"aria-required":O,"data-state":b(F),"data-readonly":g,disabled:x,value:C,onClick:n(a.onClick,(()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}))))}));Switch.displayName=d;const m="SwitchThumb",p="span";export const SwitchThumb=o.forwardRef(((r,a)=>{const{as:n=p,selector:c=e(m)}=r,l=u(r,["as","selector"]),d=f(m);return o.createElement(t,i({},l,{as:n,selector:c,ref:a,"data-state":b(d)}))}));function b(e){return e?"checked":"unchecked"}SwitchThumb.displayName=m;export const Root=Switch;export const Thumb=SwitchThumb; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-switch", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -19,6 +19,6 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@radix-ui/react-label": "0.0.3", | ||
"@radix-ui/react-polymorphic": "0.0.3", | ||
"@radix-ui/react-primitive": "0.0.2", | ||
"@radix-ui/react-utils": "0.0.3", | ||
"@radix-ui/react-label": "0.0.4", | ||
"@radix-ui/react-polymorphic": "0.0.4", | ||
"@radix-ui/react-primitive": "0.0.3", | ||
"@radix-ui/react-utils": "0.0.4", | ||
"@radix-ui/utils": "0.0.3" | ||
@@ -25,0 +25,0 @@ }, |
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
25563
+ Added@radix-ui/react-label@0.0.4(transitive)
+ Added@radix-ui/react-polymorphic@0.0.4(transitive)
+ Added@radix-ui/react-primitive@0.0.3(transitive)
+ Added@radix-ui/react-utils@0.0.4(transitive)
- Removed@radix-ui/react-label@0.0.3(transitive)
- Removed@radix-ui/react-polymorphic@0.0.3(transitive)
- Removed@radix-ui/react-primitive@0.0.2(transitive)
- Removed@radix-ui/react-utils@0.0.3(transitive)
Updated@radix-ui/react-label@0.0.4
Updated@radix-ui/react-utils@0.0.4