@radix-ui/react-switch
Advanced tools
Comparing version 0.0.2 to 0.0.3
import * as React from "react"; | ||
import { Primitive } from "@radix-ui/react-primitive"; | ||
import * as Polymorphic from "@radix-ui/react-polymorphic"; | ||
import { Merge } from "@radix-ui/utils"; | ||
declare const SWITCH_DEFAULT_TAG = "button"; | ||
type InputDOMProps = React.ComponentProps<'input'>; | ||
type SwitchOwnProps = { | ||
type SwitchOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, { | ||
checked?: boolean; | ||
@@ -9,9 +13,12 @@ defaultChecked?: boolean; | ||
onCheckedChange?: InputDOMProps['onChange']; | ||
onChange: never; | ||
}; | ||
export const Switch: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"button", SwitchOwnProps>; | ||
export const SwitchThumb: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", {}>; | ||
export const Root: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"button", SwitchOwnProps>; | ||
export const Thumb: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", {}>; | ||
}>; | ||
type SwitchPrimitive = Polymorphic.ForwardRefComponent<typeof SWITCH_DEFAULT_TAG, SwitchOwnProps>; | ||
export const Switch: SwitchPrimitive; | ||
declare const THUMB_DEFAULT_TAG = "span"; | ||
type SwitchThumbOwnProps = Polymorphic.OwnProps<typeof Primitive>; | ||
type SwitchThumbPrimitive = Polymorphic.ForwardRefComponent<typeof THUMB_DEFAULT_TAG, SwitchThumbOwnProps>; | ||
export const SwitchThumb: SwitchThumbPrimitive; | ||
export const Root: SwitchPrimitive; | ||
export const Thumb: SwitchThumbPrimitive; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -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,u=i.useControlledState,c=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 f(){return(f=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,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),p=y[0],v=y[1],m=d.forwardRef((function(e,r){var i=e["aria-labelledby"],o=e.children,b=e.name,y=e.checked,v=e.defaultChecked,m=e.required,g=e.disabled,O=e.readOnly,S=e.value,k=void 0===S?"on":S,x=e.onCheckedChange,C=s(e,["aria-labelledby","children","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),j=d.useRef(null),q=d.useRef(null),E=c(r,q),P=n(q),A=i||P,R=h(u({prop:y,defaultProp:v}),2),T=R[0],I=void 0!==T&&T,F=R[1];return d.createElement(d.Fragment,null,d.createElement("input",{ref:j,type:"checkbox",name:b,checked:I,required:m,disabled:g,readOnly:O,value:k,hidden:!0,onChange:l(x,(function(e){F(e.target.checked)}))}),d.createElement(a,f({as:"button",selector:t("Switch"),type:"button"},C,{ref:E,role:"switch","aria-checked":I,"aria-labelledby":A,"aria-required":m,"data-state":w(I),"data-readonly":O,disabled:g,value:k,onClick:l(e.onClick,(function(){var e;return null===(e=j.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}),d.createElement(p.Provider,{value:I},o)))}));exports.Switch=m,m.displayName="Switch";var g=d.forwardRef((function(e,r){var n=v("SwitchThumb");return d.createElement(a,f({as:"span",selector:t("SwitchThumb")},e,{"data-state":w(n),ref:r}))}));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,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; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{getSelector as e}from"@radix-ui/utils";import{useLabelContext as t}from"@radix-ui/react-label";import{Primitive as r}from"@radix-ui/react-primitive";import{createContext as a,composeEventHandlers as n,useControlledState as c,useComposedRefs as i}from"@radix-ui/react-utils";import*as l from"react";function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}function u(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},c=Object.keys(e);for(a=0;a<c.length;a++)r=c[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)r=c[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const[d,h]=a("SwitchContext","Switch");export const Switch=l.forwardRef(((a,h)=>{const{"aria-labelledby":f,children:m,name:b,checked:p,defaultChecked:y,required:w,disabled:k,readOnly:v,value:S="on",onCheckedChange:O}=a,x=u(a,["aria-labelledby","children","name","checked","defaultChecked","required","disabled","readOnly","value","onCheckedChange"]),g=l.useRef(null),C=l.useRef(null),T=i(h,C),j=t(C),E=f||j,[P=!1,R]=c({prop:p,defaultProp:y});return l.createElement(l.Fragment,null,l.createElement("input",{ref:g,type:"checkbox",name:b,checked:P,required:w,disabled:k,readOnly:v,value:S,hidden:!0,onChange:n(O,(e=>{R(e.target.checked)}))}),l.createElement(r,o({as:"button",selector:e("Switch"),type:"button"},x,{ref:T,role:"switch","aria-checked":P,"aria-labelledby":E,"aria-required":w,"data-state":s(P),"data-readonly":v,disabled:k,value:S,onClick:n(a.onClick,(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.click()}),{checkForDefaultPrevented:!1})}),l.createElement(d.Provider,{value:P},m)))}));Switch.displayName="Switch";export const SwitchThumb=l.forwardRef(((t,a)=>{const n=h("SwitchThumb");return l.createElement(r,o({as:"span",selector:e("SwitchThumb")},t,{"data-state":s(n),ref:a}))}));function s(e){return e?"checked":"unchecked"}SwitchThumb.displayName="SwitchThumb";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 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; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-switch", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "MIT", | ||
@@ -15,13 +15,11 @@ "source": "src/index.ts", | ||
"scripts": { | ||
"build": "parcel build src/index.ts --no-cache", | ||
"clean": "rm -rf dist", | ||
"version": "yarn version", | ||
"prepublish": "yarn clean && yarn build" | ||
"prepublish": "yarn clean" | ||
}, | ||
"dependencies": { | ||
"@radix-ui/react-label": "0.0.2", | ||
"@radix-ui/react-polymorphic": "0.0.2", | ||
"@radix-ui/react-primitive": "0.0.1", | ||
"@radix-ui/react-utils": "0.0.2", | ||
"@radix-ui/utils": "0.0.2" | ||
"@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/utils": "0.0.3" | ||
}, | ||
@@ -28,0 +26,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25679
47
+ Added@radix-ui/react-label@0.0.3(transitive)
+ Added@radix-ui/react-polymorphic@0.0.3(transitive)
+ Added@radix-ui/react-primitive@0.0.2(transitive)
+ Added@radix-ui/react-utils@0.0.3(transitive)
+ Added@radix-ui/utils@0.0.3(transitive)
- Removed@radix-ui/react-label@0.0.2(transitive)
- Removed@radix-ui/react-polymorphic@0.0.2(transitive)
- Removed@radix-ui/react-primitive@0.0.1(transitive)
- Removed@radix-ui/react-utils@0.0.2(transitive)
- Removed@radix-ui/utils@0.0.2(transitive)
Updated@radix-ui/react-label@0.0.3
Updated@radix-ui/react-utils@0.0.3
Updated@radix-ui/utils@0.0.3