🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-switch

Package Overview
Dependencies
Maintainers
6
Versions
216
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

to
1.2.0-rc.1744311029001

86

dist/index.js

@@ -103,3 +103,3 @@ "use strict";

isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
BubbleInput,
SwitchBubbleInput,
{

@@ -138,38 +138,52 @@ control: button,

SwitchThumb.displayName = THUMB_NAME;
var BubbleInput = (props) => {
const { control, checked, bubbles = true, ...inputProps } = props;
const ref = React.useRef(null);
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
const controlSize = (0, import_react_use_size.useSize)(control);
React.useEffect(() => {
const input = ref.current;
const inputProto = window.HTMLInputElement.prototype;
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
const setChecked = descriptor.set;
if (prevChecked !== checked && setChecked) {
const event = new Event("click", { bubbles });
setChecked.call(input, checked);
input.dispatchEvent(event);
}
}, [prevChecked, checked, bubbles]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"input",
{
type: "checkbox",
"aria-hidden": true,
defaultChecked: checked,
...inputProps,
tabIndex: -1,
ref,
style: {
...props.style,
...controlSize,
position: "absolute",
pointerEvents: "none",
opacity: 0,
margin: 0
var BUBBLE_INPUT_NAME = "SwitchBubbleInput";
var SwitchBubbleInput = React.forwardRef(
({
__scopeSwitch,
control,
checked,
bubbles = true,
...props
}, forwardedRef) => {
const ref = React.useRef(null);
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(ref, forwardedRef);
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
const controlSize = (0, import_react_use_size.useSize)(control);
React.useEffect(() => {
const input = ref.current;
if (!input) return;
const inputProto = window.HTMLInputElement.prototype;
const descriptor = Object.getOwnPropertyDescriptor(
inputProto,
"checked"
);
const setChecked = descriptor.set;
if (prevChecked !== checked && setChecked) {
const event = new Event("click", { bubbles });
setChecked.call(input, checked);
input.dispatchEvent(event);
}
}
);
};
}, [prevChecked, checked, bubbles]);
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"input",
{
type: "checkbox",
"aria-hidden": true,
defaultChecked: checked,
...props,
tabIndex: -1,
ref: composedRefs,
style: {
...props.style,
...controlSize,
position: "absolute",
pointerEvents: "none",
opacity: 0,
margin: 0
}
}
);
}
);
SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;
function getState(checked) {

@@ -176,0 +190,0 @@ return checked ? "checked" : "unchecked";

{
"name": "@radix-ui/react-switch",
"version": "1.1.5-rc.1744259481941",
"version": "1.2.0-rc.1744311029001",
"license": "MIT",

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

"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-primitive": "2.0.3",
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-primitive": "2.1.0-rc.1744311029001",
"@radix-ui/react-use-controllable-state": "1.2.0-rc.1744311029001",
"@radix-ui/react-use-previous": "1.1.1",
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-use-controllable-state": "1.2.0-rc.1744259481941",
"@radix-ui/react-use-size": "1.1.1"

@@ -22,0 +22,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