🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@radix-ui/react-switch

Package Overview
Dependencies
Maintainers
6
Versions
226
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.1744660991666

93

dist/index.js

@@ -73,7 +73,6 @@ "use strict";

const isFormControl = button ? form || !!button.closest("form") : true;
const [checked, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
const [checked = false, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
prop: checkedProp,
defaultProp: defaultChecked ?? false,
onChange: onCheckedChange,
caller: SWITCH_NAME
defaultProp: defaultChecked,
onChange: onCheckedChange
});

@@ -104,3 +103,3 @@ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [

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

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

SwitchThumb.displayName = THUMB_NAME;
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);
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
}
}, [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) {

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

{
"name": "@radix-ui/react-switch",
"version": "1.2.0-rc.1744574857111",
"version": "1.2.0-rc.1744660991666",
"license": "MIT",

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

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

@@ -30,5 +30,5 @@ "devDependencies": {

"typescript": "^5.7.3",
"@repo/builder": "0.0.0",
"@repo/eslint-config": "0.0.0",
"@repo/typescript-config": "0.0.0",
"@repo/builder": "0.0.0"
"@repo/typescript-config": "0.0.0"
},

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