@radix-ui/react-switch 1.0.3 → 1.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,20 +1,32 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- export const createSwitchScope: import("@radix-ui/react-context").CreateScope;
5
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
6
- export interface SwitchProps extends PrimitiveButtonProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare type Scope<C = any> = {
6
+ [scopeName: string]: React.Context<C>[];
7
+ } | undefined;
8
+ declare type ScopeHook = (scope: Scope) => {
9
+ [__scopeProp: string]: Scope;
10
+ };
11
+ interface CreateScope {
12
+ scopeName: string;
13
+ (): ScopeHook;
14
+ }
15
+
16
+ declare const createSwitchScope: CreateScope;
17
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
18
+ interface SwitchProps extends PrimitiveButtonProps {
7
19
  checked?: boolean;
8
20
  defaultChecked?: boolean;
9
21
  required?: boolean;
10
22
  onCheckedChange?(checked: boolean): void;
11
23
  }
12
- export const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
13
- type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
14
- export interface SwitchThumbProps extends PrimitiveSpanProps {
24
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
25
+ declare type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
26
+ interface SwitchThumbProps extends PrimitiveSpanProps {
15
27
  }
16
- export const SwitchThumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
17
- export const Root: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
18
- export const Thumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
28
+ declare const SwitchThumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
29
+ declare const Root: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
30
+ declare const Thumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
19
31
 
20
- //# sourceMappingURL=index.d.ts.map
32
+ export { Root, Switch, type SwitchProps, SwitchThumb, type SwitchThumbProps, Thumb, createSwitchScope };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,32 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- export const createSwitchScope: import("@radix-ui/react-context").CreateScope;
5
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
6
- export interface SwitchProps extends PrimitiveButtonProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+
5
+ declare type Scope<C = any> = {
6
+ [scopeName: string]: React.Context<C>[];
7
+ } | undefined;
8
+ declare type ScopeHook = (scope: Scope) => {
9
+ [__scopeProp: string]: Scope;
10
+ };
11
+ interface CreateScope {
12
+ scopeName: string;
13
+ (): ScopeHook;
14
+ }
15
+
16
+ declare const createSwitchScope: CreateScope;
17
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
18
+ interface SwitchProps extends PrimitiveButtonProps {
7
19
  checked?: boolean;
8
20
  defaultChecked?: boolean;
9
21
  required?: boolean;
10
22
  onCheckedChange?(checked: boolean): void;
11
23
  }
12
- export const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
13
- type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
14
- export interface SwitchThumbProps extends PrimitiveSpanProps {
24
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
25
+ declare type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
26
+ interface SwitchThumbProps extends PrimitiveSpanProps {
15
27
  }
16
- export const SwitchThumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
17
- export const Root: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
18
- export const Thumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
28
+ declare const SwitchThumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
29
+ declare const Root: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
30
+ declare const Thumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<HTMLSpanElement>>;
19
31
 
20
- //# sourceMappingURL=index.d.ts.map
32
+ export { Root, Switch, type SwitchProps, SwitchThumb, type SwitchThumbProps, Thumb, createSwitchScope };
package/dist/index.js CHANGED
@@ -1,155 +1,166 @@
1
- var $cWV9h$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $cWV9h$react = require("react");
3
- var $cWV9h$radixuiprimitive = require("@radix-ui/primitive");
4
- var $cWV9h$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
5
- var $cWV9h$radixuireactcontext = require("@radix-ui/react-context");
6
- var $cWV9h$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
7
- var $cWV9h$radixuireactuseprevious = require("@radix-ui/react-use-previous");
8
- var $cWV9h$radixuireactusesize = require("@radix-ui/react-use-size");
9
- var $cWV9h$radixuireactprimitive = require("@radix-ui/react-primitive");
1
+ "use strict";
2
+ (() => {
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
10
31
 
11
- function $parcel$export(e, n, v, s) {
12
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
- }
14
- function $parcel$interopDefault(a) {
15
- return a && a.__esModule ? a.default : a;
16
- }
17
-
18
- $parcel$export(module.exports, "createSwitchScope", () => $4465bdeb0ef4ccd7$export$cf7f5f17f69cbd43);
19
- $parcel$export(module.exports, "Switch", () => $4465bdeb0ef4ccd7$export$b5d5cf8927ab7262);
20
- $parcel$export(module.exports, "SwitchThumb", () => $4465bdeb0ef4ccd7$export$4d07bf653ea69106);
21
- $parcel$export(module.exports, "Root", () => $4465bdeb0ef4ccd7$export$be92b6f5f03c0fe9);
22
- $parcel$export(module.exports, "Thumb", () => $4465bdeb0ef4ccd7$export$6521433ed15a34db);
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
- /* -------------------------------------------------------------------------------------------------
33
- * Switch
34
- * -----------------------------------------------------------------------------------------------*/ const $4465bdeb0ef4ccd7$var$SWITCH_NAME = 'Switch';
35
- const [$4465bdeb0ef4ccd7$var$createSwitchContext, $4465bdeb0ef4ccd7$export$cf7f5f17f69cbd43] = $cWV9h$radixuireactcontext.createContextScope($4465bdeb0ef4ccd7$var$SWITCH_NAME);
36
- const [$4465bdeb0ef4ccd7$var$SwitchProvider, $4465bdeb0ef4ccd7$var$useSwitchContext] = $4465bdeb0ef4ccd7$var$createSwitchContext($4465bdeb0ef4ccd7$var$SWITCH_NAME);
37
- const $4465bdeb0ef4ccd7$export$b5d5cf8927ab7262 = /*#__PURE__*/ $cWV9h$react.forwardRef((props, forwardedRef)=>{
38
- const { __scopeSwitch: __scopeSwitch , name: name , checked: checkedProp , defaultChecked: defaultChecked , required: required , disabled: disabled , value: value = 'on' , onCheckedChange: onCheckedChange , ...switchProps } = props;
39
- const [button, setButton] = $cWV9h$react.useState(null);
40
- const composedRefs = $cWV9h$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setButton(node)
41
- );
42
- const hasConsumerStoppedPropagationRef = $cWV9h$react.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
43
- const isFormControl = button ? Boolean(button.closest('form')) : true;
44
- const [checked = false, setChecked] = $cWV9h$radixuireactusecontrollablestate.useControllableState({
32
+ // packages/react/switch/src/Switch.tsx
33
+ var React = __toESM(__require("react"));
34
+ var import_primitive = __require("@radix-ui/primitive");
35
+ var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
36
+ var import_react_context = __require("@radix-ui/react-context");
37
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
38
+ var import_react_use_previous = __require("@radix-ui/react-use-previous");
39
+ var import_react_use_size = __require("@radix-ui/react-use-size");
40
+ var import_react_primitive = __require("@radix-ui/react-primitive");
41
+ var import_jsx_runtime = __require("react/jsx-runtime");
42
+ var SWITCH_NAME = "Switch";
43
+ var [createSwitchContext, createSwitchScope] = (0, import_react_context.createContextScope)(SWITCH_NAME);
44
+ var [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
45
+ var Switch = React.forwardRef(
46
+ (props, forwardedRef) => {
47
+ const {
48
+ __scopeSwitch,
49
+ name,
50
+ checked: checkedProp,
51
+ defaultChecked,
52
+ required,
53
+ disabled,
54
+ value = "on",
55
+ onCheckedChange,
56
+ ...switchProps
57
+ } = props;
58
+ const [button, setButton] = React.useState(null);
59
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node));
60
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
61
+ const isFormControl = button ? Boolean(button.closest("form")) : true;
62
+ const [checked = false, setChecked] = (0, import_react_use_controllable_state.useControllableState)({
45
63
  prop: checkedProp,
46
64
  defaultProp: defaultChecked,
47
65
  onChange: onCheckedChange
48
- });
49
- return /*#__PURE__*/ $cWV9h$react.createElement($4465bdeb0ef4ccd7$var$SwitchProvider, {
50
- scope: __scopeSwitch,
51
- checked: checked,
52
- disabled: disabled
53
- }, /*#__PURE__*/ $cWV9h$react.createElement($cWV9h$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($cWV9h$babelruntimehelpersextends))({
54
- type: "button",
55
- role: "switch",
56
- "aria-checked": checked,
57
- "aria-required": required,
58
- "data-state": $4465bdeb0ef4ccd7$var$getState(checked),
59
- "data-disabled": disabled ? '' : undefined,
60
- disabled: disabled,
61
- value: value
62
- }, switchProps, {
63
- ref: composedRefs,
64
- onClick: $cWV9h$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
65
- setChecked((prevChecked)=>!prevChecked
66
- );
67
- if (isFormControl) {
68
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if switch is in a form, stop propagation from the button so that we only propagate
69
- // one click event (from the input). We propagate changes from an input so that native
70
- // form validation works and form events reflect switch updates.
66
+ });
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_react_primitive.Primitive.button,
70
+ {
71
+ type: "button",
72
+ role: "switch",
73
+ "aria-checked": checked,
74
+ "aria-required": required,
75
+ "data-state": getState(checked),
76
+ "data-disabled": disabled ? "" : void 0,
77
+ disabled,
78
+ value,
79
+ ...switchProps,
80
+ ref: composedRefs,
81
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
82
+ setChecked((prevChecked) => !prevChecked);
83
+ if (isFormControl) {
84
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
71
85
  if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
72
- }
73
- })
74
- })), isFormControl && /*#__PURE__*/ $cWV9h$react.createElement($4465bdeb0ef4ccd7$var$BubbleInput, {
75
- control: button,
76
- bubbles: !hasConsumerStoppedPropagationRef.current,
77
- name: name,
78
- value: value,
79
- checked: checked,
80
- required: required,
81
- disabled: disabled // We transform because the input is absolutely positioned but we have
82
- ,
83
- style: {
84
- transform: 'translateX(-100%)'
86
+ }
87
+ })
88
+ }
89
+ ),
90
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
+ BubbleInput,
92
+ {
93
+ control: button,
94
+ bubbles: !hasConsumerStoppedPropagationRef.current,
95
+ name,
96
+ value,
97
+ checked,
98
+ required,
99
+ disabled,
100
+ style: { transform: "translateX(-100%)" }
101
+ }
102
+ )
103
+ ] });
104
+ }
105
+ );
106
+ Switch.displayName = SWITCH_NAME;
107
+ var THUMB_NAME = "SwitchThumb";
108
+ var SwitchThumb = React.forwardRef(
109
+ (props, forwardedRef) => {
110
+ const { __scopeSwitch, ...thumbProps } = props;
111
+ const context = useSwitchContext(THUMB_NAME, __scopeSwitch);
112
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
113
+ import_react_primitive.Primitive.span,
114
+ {
115
+ "data-state": getState(context.checked),
116
+ "data-disabled": context.disabled ? "" : void 0,
117
+ ...thumbProps,
118
+ ref: forwardedRef
85
119
  }
86
- }));
87
- });
88
- /*#__PURE__*/ Object.assign($4465bdeb0ef4ccd7$export$b5d5cf8927ab7262, {
89
- displayName: $4465bdeb0ef4ccd7$var$SWITCH_NAME
90
- });
91
- /* -------------------------------------------------------------------------------------------------
92
- * SwitchThumb
93
- * -----------------------------------------------------------------------------------------------*/ const $4465bdeb0ef4ccd7$var$THUMB_NAME = 'SwitchThumb';
94
- const $4465bdeb0ef4ccd7$export$4d07bf653ea69106 = /*#__PURE__*/ $cWV9h$react.forwardRef((props, forwardedRef)=>{
95
- const { __scopeSwitch: __scopeSwitch , ...thumbProps } = props;
96
- const context = $4465bdeb0ef4ccd7$var$useSwitchContext($4465bdeb0ef4ccd7$var$THUMB_NAME, __scopeSwitch);
97
- return /*#__PURE__*/ $cWV9h$react.createElement($cWV9h$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($cWV9h$babelruntimehelpersextends))({
98
- "data-state": $4465bdeb0ef4ccd7$var$getState(context.checked),
99
- "data-disabled": context.disabled ? '' : undefined
100
- }, thumbProps, {
101
- ref: forwardedRef
102
- }));
103
- });
104
- /*#__PURE__*/ Object.assign($4465bdeb0ef4ccd7$export$4d07bf653ea69106, {
105
- displayName: $4465bdeb0ef4ccd7$var$THUMB_NAME
106
- });
107
- /* ---------------------------------------------------------------------------------------------- */ const $4465bdeb0ef4ccd7$var$BubbleInput = (props)=>{
108
- const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
109
- const ref = $cWV9h$react.useRef(null);
110
- const prevChecked = $cWV9h$radixuireactuseprevious.usePrevious(checked);
111
- const controlSize = $cWV9h$radixuireactusesize.useSize(control); // Bubble checked change to parents (e.g form change event)
112
- $cWV9h$react.useEffect(()=>{
113
- const input = ref.current;
114
- const inputProto = window.HTMLInputElement.prototype;
115
- const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
116
- const setChecked = descriptor.set;
117
- if (prevChecked !== checked && setChecked) {
118
- const event = new Event('click', {
119
- bubbles: bubbles
120
- });
121
- setChecked.call(input, checked);
122
- input.dispatchEvent(event);
123
- }
124
- }, [
125
- prevChecked,
126
- checked,
127
- bubbles
128
- ]);
129
- return /*#__PURE__*/ $cWV9h$react.createElement("input", ($parcel$interopDefault($cWV9h$babelruntimehelpersextends))({
120
+ );
121
+ }
122
+ );
123
+ SwitchThumb.displayName = THUMB_NAME;
124
+ var BubbleInput = (props) => {
125
+ const { control, checked, bubbles = true, ...inputProps } = props;
126
+ const ref = React.useRef(null);
127
+ const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
128
+ const controlSize = (0, import_react_use_size.useSize)(control);
129
+ React.useEffect(() => {
130
+ const input = ref.current;
131
+ const inputProto = window.HTMLInputElement.prototype;
132
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
133
+ const setChecked = descriptor.set;
134
+ if (prevChecked !== checked && setChecked) {
135
+ const event = new Event("click", { bubbles });
136
+ setChecked.call(input, checked);
137
+ input.dispatchEvent(event);
138
+ }
139
+ }, [prevChecked, checked, bubbles]);
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
+ "input",
142
+ {
130
143
  type: "checkbox",
131
144
  "aria-hidden": true,
132
- defaultChecked: checked
133
- }, inputProps, {
145
+ defaultChecked: checked,
146
+ ...inputProps,
134
147
  tabIndex: -1,
135
- ref: ref,
148
+ ref,
136
149
  style: {
137
- ...props.style,
138
- ...controlSize,
139
- position: 'absolute',
140
- pointerEvents: 'none',
141
- opacity: 0,
142
- margin: 0
150
+ ...props.style,
151
+ ...controlSize,
152
+ position: "absolute",
153
+ pointerEvents: "none",
154
+ opacity: 0,
155
+ margin: 0
143
156
  }
144
- }));
145
- };
146
- function $4465bdeb0ef4ccd7$var$getState(checked) {
147
- return checked ? 'checked' : 'unchecked';
148
- }
149
- const $4465bdeb0ef4ccd7$export$be92b6f5f03c0fe9 = $4465bdeb0ef4ccd7$export$b5d5cf8927ab7262;
150
- const $4465bdeb0ef4ccd7$export$6521433ed15a34db = $4465bdeb0ef4ccd7$export$4d07bf653ea69106;
151
-
152
-
153
-
154
-
157
+ }
158
+ );
159
+ };
160
+ function getState(checked) {
161
+ return checked ? "checked" : "unchecked";
162
+ }
163
+ var Root = Switch;
164
+ var Thumb = SwitchThumb;
165
+ })();
155
166
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;ACYA;;oGAEA,CAEA,MAAMa,iCAAW,GAAG,QAApB,AAAA;AAGA,MAAM,CAACC,yCAAD,EAAsBd,yCAAtB,CAAA,GAA2CQ,6CAAkB,CAACK,iCAAD,CAAnE,AAAA;AAGA,MAAM,CAACE,oCAAD,EAAiBC,sCAAjB,CAAA,GAAqCF,yCAAmB,CAAqBD,iCAArB,CAA9D,AAAA;AAWA,MAAMZ,yCAAM,GAAA,aAAGI,CAAAA,uBAAA,CACb,CAACa,KAAD,EAAkCC,YAAlC,GAAmD;IACjD,MAAM,E,eACJC,aADI,CAAA,E,MAEJC,IAFI,CAAA,EAGJC,OAAO,EAAEC,WAHL,CAAA,E,gBAIJC,cAJI,CAAA,E,UAKJC,QALI,CAAA,E,UAMJC,QANI,CAAA,SAOJC,KAAK,GAAG,IAPJ,G,iBAQJC,eARI,CAAA,EASJ,GAAGC,WAAH,EATI,GAUFX,KAVJ,AAAM;IAWN,MAAM,CAACY,MAAD,EAASC,SAAT,CAAA,GAAsB1B,qBAAA,CAAyC,IAAzC,CAA5B,AAAA;IACA,MAAM4B,YAAY,GAAG1B,8CAAe,CAACY,YAAD,EAAgBe,CAAAA,IAAD,G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cAAc,EAAEpC,OAAhB;KAHF,EAIMqC,UAJN,EAAA;QAKE,QAAQ,EAAE,EALZ;QAME,GAAG,EAAEC,GANP;QAOE,KAAK,EAAE;YACL,GAAG1C,KAAK,CAACyD,KADJ;YAEL,GAAGd,WAFE;YAGLe,QAAQ,EAAE,UAHL;YAILC,aAAa,EAAE,MAJV;YAKLC,OAAO,EAAE,CALJ;YAMLC,MAAM,EAAE,CAARA;SANK;KAPT,CAAA,CADF,CACE;CApBJ,AAqCC;AAED,SAASnC,8BAAT,CAAkBtB,OAAlB,EAAoC;IAClC,OAAOA,OAAO,GAAG,SAAH,GAAe,WAA7B,CAAA;CACD;AAED,MAAMnB,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAK,GAAGF,yCAAd,AAAA;;ADvLA","sources":["packages/react/switch/src/index.ts","packages/react/switch/src/Switch.tsx"],"sourcesContent":["export {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n} from './Switch';\nexport type { SwitchProps, SwitchThumbProps } from './Switch';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nconst SWITCH_NAME = 'Switch';\n\ntype ScopedProps<P> = P & { __scopeSwitch?: Scope };\nconst [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\n\ntype SwitchContextValue = { checked: boolean; disabled?: boolean };\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<SwitchContextValue>(SWITCH_NAME);\n\ntype SwitchElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface SwitchProps extends PrimitiveButtonProps {\n checked?: boolean;\n defaultChecked?: boolean;\n required?: boolean;\n onCheckedChange?(checked: boolean): void;\n}\n\nconst Switch = React.forwardRef<SwitchElement, SwitchProps>(\n (props: ScopedProps<SwitchProps>, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n\n return (\n <SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...switchProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if switch is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect switch updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </SwitchProvider>\n );\n }\n);\n\nSwitch.displayName = SWITCH_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb';\n\ntype SwitchThumbElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface SwitchThumbProps extends PrimitiveSpanProps {}\n\nconst SwitchThumb = React.forwardRef<SwitchThumbElement, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return (\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...thumbProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSwitchThumb.displayName = THUMB_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Switch;\nconst Thumb = SwitchThumb;\n\nexport {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n};\nexport type { SwitchProps, SwitchThumbProps };\n"],"names":["createSwitchScope","Switch","SwitchThumb","Root","Thumb","React","composeEventHandlers","useComposedRefs","createContextScope","useControllableState","usePrevious","useSize","Primitive","SWITCH_NAME","createSwitchContext","SwitchProvider","useSwitchContext","forwardRef","props","forwardedRef","__scopeSwitch","name","checked","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","switchProps","button","setButton","useState","composedRefs","node","hasConsumerStoppedPropagationRef","useRef","isFormControl","Boolean","closest","setChecked","prop","defaultProp","onChange","getState","undefined","onClick","event","prevChecked","current","isPropagationStopped","stopPropagation","transform","THUMB_NAME","thumbProps","context","BubbleInput","control","bubbles","inputProps","ref","controlSize","useEffect","input","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","set","Event","call","dispatchEvent","style","position","pointerEvents","opacity","margin"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Switch.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nconst SWITCH_NAME = 'Switch';\n\ntype ScopedProps<P> = P & { __scopeSwitch?: Scope };\nconst [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\n\ntype SwitchContextValue = { checked: boolean; disabled?: boolean };\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<SwitchContextValue>(SWITCH_NAME);\n\ntype SwitchElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface SwitchProps extends PrimitiveButtonProps {\n checked?: boolean;\n defaultChecked?: boolean;\n required?: boolean;\n onCheckedChange?(checked: boolean): void;\n}\n\nconst Switch = React.forwardRef<SwitchElement, SwitchProps>(\n (props: ScopedProps<SwitchProps>, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n\n return (\n <SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...switchProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if switch is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect switch updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </SwitchProvider>\n );\n }\n);\n\nSwitch.displayName = SWITCH_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb';\n\ntype SwitchThumbElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface SwitchThumbProps extends PrimitiveSpanProps {}\n\nconst SwitchThumb = React.forwardRef<SwitchThumbElement, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return (\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...thumbProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSwitchThumb.displayName = THUMB_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Switch;\nconst Thumb = SwitchThumb;\n\nexport {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n};\nexport type { SwitchProps, SwitchThumbProps };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,yBAAqC;AACrC,kCAAgC;AAChC,6BAAmC;AACnC,4CAAqC;AACrC,kCAA4B;AAC5B,8BAAwB;AACxB,+BAA0B;AAmDpB;AA1CN,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,iBAAiB,QAAI,yCAAmB,WAAW;AAG/E,MAAM,CAAC,gBAAgB,gBAAgB,IAAI,oBAAwC,WAAW;AAW9F,MAAM,SAAe;AAAA,IACnB,CAAC,OAAiC,iBAAiB;AACjD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,QACA,GAAG;AAAA,MACL,IAAI;AACJ,YAAM,CAAC,QAAQ,SAAS,IAAU,eAAmC,IAAI;AACzE,YAAM,mBAAe,2CAAgB,cAAc,CAAC,SAAS,UAAU,IAAI,CAAC;AAC5E,YAAM,mCAAyC,aAAO,KAAK;AAE3D,YAAM,gBAAgB,SAAS,QAAQ,OAAO,QAAQ,MAAM,CAAC,IAAI;AACjE,YAAM,CAAC,UAAU,OAAO,UAAU,QAAI,0DAAqB;AAAA,QACzD,MAAM;AAAA,QACN,aAAa;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UAAU,MAAM,GAAG,WAAW,IAAI;AAC5D,UAAM,MAAY,aAAyB,IAAI;AAC/C,UAAM,kBAAc,uCAAY,OAAO;AACvC,UAAM,kBAAc,+BAAQ,OAAO;AAGnC,IAAM,gBAAU,MAAM;AACpB,YAAM,QAAQ,IAAI;AAClB,YAAM,aAAa,OAAO,iBAAiB;AAC3C,YAAM,aAAa,OAAO,yBAAyB,YAAY,SAAS;AACxE,YAAM,aAAa,WAAW;AAC9B,UAAI,gBAAgB,WAAW,YAAY;AACzC,cAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,mBAAW,KAAK,OAAO,OAAO;AAC9B,cAAM,cAAc,KAAK;AAAA,MAC3B;AAAA,IACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAElC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,eAAW;AAAA,QACX,gBAAgB;AAAA,QACf,GAAG;AAAA,QACJ,UAAU;AAAA,QACV;AAAA,QACA,OAAO;AAAA,UACL,GAAG,MAAM;AAAA,UACT,GAAG;AAAA,UACH,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,WAAS,SAAS,SAAkB;AAClC,WAAO,UAAU,YAAY;AAAA,EAC/B;AAEA,MAAM,OAAO;AACb,MAAM,QAAQ;",
6
+ "names": []
7
+ }
package/dist/index.mjs CHANGED
@@ -1,144 +1,141 @@
1
- import $irPIl$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import {forwardRef as $irPIl$forwardRef, useState as $irPIl$useState, useRef as $irPIl$useRef, createElement as $irPIl$createElement, useEffect as $irPIl$useEffect} from "react";
3
- import {composeEventHandlers as $irPIl$composeEventHandlers} from "@radix-ui/primitive";
4
- import {useComposedRefs as $irPIl$useComposedRefs} from "@radix-ui/react-compose-refs";
5
- import {createContextScope as $irPIl$createContextScope} from "@radix-ui/react-context";
6
- import {useControllableState as $irPIl$useControllableState} from "@radix-ui/react-use-controllable-state";
7
- import {usePrevious as $irPIl$usePrevious} from "@radix-ui/react-use-previous";
8
- import {useSize as $irPIl$useSize} from "@radix-ui/react-use-size";
9
- import {Primitive as $irPIl$Primitive} from "@radix-ui/react-primitive";
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- /* -------------------------------------------------------------------------------------------------
21
- * Switch
22
- * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$SWITCH_NAME = 'Switch';
23
- const [$6be4966fd9bbc698$var$createSwitchContext, $6be4966fd9bbc698$export$cf7f5f17f69cbd43] = $irPIl$createContextScope($6be4966fd9bbc698$var$SWITCH_NAME);
24
- const [$6be4966fd9bbc698$var$SwitchProvider, $6be4966fd9bbc698$var$useSwitchContext] = $6be4966fd9bbc698$var$createSwitchContext($6be4966fd9bbc698$var$SWITCH_NAME);
25
- const $6be4966fd9bbc698$export$b5d5cf8927ab7262 = /*#__PURE__*/ $irPIl$forwardRef((props, forwardedRef)=>{
26
- const { __scopeSwitch: __scopeSwitch , name: name , checked: checkedProp , defaultChecked: defaultChecked , required: required , disabled: disabled , value: value = 'on' , onCheckedChange: onCheckedChange , ...switchProps } = props;
27
- const [button, setButton] = $irPIl$useState(null);
28
- const composedRefs = $irPIl$useComposedRefs(forwardedRef, (node)=>setButton(node)
29
- );
30
- const hasConsumerStoppedPropagationRef = $irPIl$useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
31
- const isFormControl = button ? Boolean(button.closest('form')) : true;
32
- const [checked = false, setChecked] = $irPIl$useControllableState({
33
- prop: checkedProp,
34
- defaultProp: defaultChecked,
35
- onChange: onCheckedChange
1
+ // packages/react/switch/src/Switch.tsx
2
+ import * as React from "react";
3
+ import { composeEventHandlers } from "@radix-ui/primitive";
4
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
5
+ import { createContextScope } from "@radix-ui/react-context";
6
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
7
+ import { usePrevious } from "@radix-ui/react-use-previous";
8
+ import { useSize } from "@radix-ui/react-use-size";
9
+ import { Primitive } from "@radix-ui/react-primitive";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var SWITCH_NAME = "Switch";
12
+ var [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);
13
+ var [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
14
+ var Switch = React.forwardRef(
15
+ (props, forwardedRef) => {
16
+ const {
17
+ __scopeSwitch,
18
+ name,
19
+ checked: checkedProp,
20
+ defaultChecked,
21
+ required,
22
+ disabled,
23
+ value = "on",
24
+ onCheckedChange,
25
+ ...switchProps
26
+ } = props;
27
+ const [button, setButton] = React.useState(null);
28
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
29
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
30
+ const isFormControl = button ? Boolean(button.closest("form")) : true;
31
+ const [checked = false, setChecked] = useControllableState({
32
+ prop: checkedProp,
33
+ defaultProp: defaultChecked,
34
+ onChange: onCheckedChange
36
35
  });
37
- return /*#__PURE__*/ $irPIl$createElement($6be4966fd9bbc698$var$SwitchProvider, {
38
- scope: __scopeSwitch,
39
- checked: checked,
40
- disabled: disabled
41
- }, /*#__PURE__*/ $irPIl$createElement($irPIl$Primitive.button, $irPIl$babelruntimehelpersesmextends({
42
- type: "button",
43
- role: "switch",
44
- "aria-checked": checked,
45
- "aria-required": required,
46
- "data-state": $6be4966fd9bbc698$var$getState(checked),
47
- "data-disabled": disabled ? '' : undefined,
48
- disabled: disabled,
49
- value: value
50
- }, switchProps, {
51
- ref: composedRefs,
52
- onClick: $irPIl$composeEventHandlers(props.onClick, (event)=>{
53
- setChecked((prevChecked)=>!prevChecked
54
- );
36
+ return /* @__PURE__ */ jsxs(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [
37
+ /* @__PURE__ */ jsx(
38
+ Primitive.button,
39
+ {
40
+ type: "button",
41
+ role: "switch",
42
+ "aria-checked": checked,
43
+ "aria-required": required,
44
+ "data-state": getState(checked),
45
+ "data-disabled": disabled ? "" : void 0,
46
+ disabled,
47
+ value,
48
+ ...switchProps,
49
+ ref: composedRefs,
50
+ onClick: composeEventHandlers(props.onClick, (event) => {
51
+ setChecked((prevChecked) => !prevChecked);
55
52
  if (isFormControl) {
56
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if switch is in a form, stop propagation from the button so that we only propagate
57
- // one click event (from the input). We propagate changes from an input so that native
58
- // form validation works and form events reflect switch updates.
59
- if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
53
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
54
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
60
55
  }
61
- })
62
- })), isFormControl && /*#__PURE__*/ $irPIl$createElement($6be4966fd9bbc698$var$BubbleInput, {
63
- control: button,
64
- bubbles: !hasConsumerStoppedPropagationRef.current,
65
- name: name,
66
- value: value,
67
- checked: checked,
68
- required: required,
69
- disabled: disabled // We transform because the input is absolutely positioned but we have
70
- ,
71
- style: {
72
- transform: 'translateX(-100%)'
73
- }
74
- }));
75
- });
76
- /*#__PURE__*/ Object.assign($6be4966fd9bbc698$export$b5d5cf8927ab7262, {
77
- displayName: $6be4966fd9bbc698$var$SWITCH_NAME
78
- });
79
- /* -------------------------------------------------------------------------------------------------
80
- * SwitchThumb
81
- * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$THUMB_NAME = 'SwitchThumb';
82
- const $6be4966fd9bbc698$export$4d07bf653ea69106 = /*#__PURE__*/ $irPIl$forwardRef((props, forwardedRef)=>{
83
- const { __scopeSwitch: __scopeSwitch , ...thumbProps } = props;
84
- const context = $6be4966fd9bbc698$var$useSwitchContext($6be4966fd9bbc698$var$THUMB_NAME, __scopeSwitch);
85
- return /*#__PURE__*/ $irPIl$createElement($irPIl$Primitive.span, $irPIl$babelruntimehelpersesmextends({
86
- "data-state": $6be4966fd9bbc698$var$getState(context.checked),
87
- "data-disabled": context.disabled ? '' : undefined
88
- }, thumbProps, {
89
- ref: forwardedRef
90
- }));
91
- });
92
- /*#__PURE__*/ Object.assign($6be4966fd9bbc698$export$4d07bf653ea69106, {
93
- displayName: $6be4966fd9bbc698$var$THUMB_NAME
94
- });
95
- /* ---------------------------------------------------------------------------------------------- */ const $6be4966fd9bbc698$var$BubbleInput = (props)=>{
96
- const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
97
- const ref = $irPIl$useRef(null);
98
- const prevChecked = $irPIl$usePrevious(checked);
99
- const controlSize = $irPIl$useSize(control); // Bubble checked change to parents (e.g form change event)
100
- $irPIl$useEffect(()=>{
101
- const input = ref.current;
102
- const inputProto = window.HTMLInputElement.prototype;
103
- const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
104
- const setChecked = descriptor.set;
105
- if (prevChecked !== checked && setChecked) {
106
- const event = new Event('click', {
107
- bubbles: bubbles
108
- });
109
- setChecked.call(input, checked);
110
- input.dispatchEvent(event);
56
+ })
111
57
  }
112
- }, [
113
- prevChecked,
114
- checked,
115
- bubbles
116
- ]);
117
- return /*#__PURE__*/ $irPIl$createElement("input", $irPIl$babelruntimehelpersesmextends({
118
- type: "checkbox",
119
- "aria-hidden": true,
120
- defaultChecked: checked
121
- }, inputProps, {
122
- tabIndex: -1,
123
- ref: ref,
124
- style: {
125
- ...props.style,
126
- ...controlSize,
127
- position: 'absolute',
128
- pointerEvents: 'none',
129
- opacity: 0,
130
- margin: 0
58
+ ),
59
+ isFormControl && /* @__PURE__ */ jsx(
60
+ BubbleInput,
61
+ {
62
+ control: button,
63
+ bubbles: !hasConsumerStoppedPropagationRef.current,
64
+ name,
65
+ value,
66
+ checked,
67
+ required,
68
+ disabled,
69
+ style: { transform: "translateX(-100%)" }
131
70
  }
132
- }));
71
+ )
72
+ ] });
73
+ }
74
+ );
75
+ Switch.displayName = SWITCH_NAME;
76
+ var THUMB_NAME = "SwitchThumb";
77
+ var SwitchThumb = React.forwardRef(
78
+ (props, forwardedRef) => {
79
+ const { __scopeSwitch, ...thumbProps } = props;
80
+ const context = useSwitchContext(THUMB_NAME, __scopeSwitch);
81
+ return /* @__PURE__ */ jsx(
82
+ Primitive.span,
83
+ {
84
+ "data-state": getState(context.checked),
85
+ "data-disabled": context.disabled ? "" : void 0,
86
+ ...thumbProps,
87
+ ref: forwardedRef
88
+ }
89
+ );
90
+ }
91
+ );
92
+ SwitchThumb.displayName = THUMB_NAME;
93
+ var BubbleInput = (props) => {
94
+ const { control, checked, bubbles = true, ...inputProps } = props;
95
+ const ref = React.useRef(null);
96
+ const prevChecked = usePrevious(checked);
97
+ const controlSize = useSize(control);
98
+ React.useEffect(() => {
99
+ const input = ref.current;
100
+ const inputProto = window.HTMLInputElement.prototype;
101
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
102
+ const setChecked = descriptor.set;
103
+ if (prevChecked !== checked && setChecked) {
104
+ const event = new Event("click", { bubbles });
105
+ setChecked.call(input, checked);
106
+ input.dispatchEvent(event);
107
+ }
108
+ }, [prevChecked, checked, bubbles]);
109
+ return /* @__PURE__ */ jsx(
110
+ "input",
111
+ {
112
+ type: "checkbox",
113
+ "aria-hidden": true,
114
+ defaultChecked: checked,
115
+ ...inputProps,
116
+ tabIndex: -1,
117
+ ref,
118
+ style: {
119
+ ...props.style,
120
+ ...controlSize,
121
+ position: "absolute",
122
+ pointerEvents: "none",
123
+ opacity: 0,
124
+ margin: 0
125
+ }
126
+ }
127
+ );
133
128
  };
134
- function $6be4966fd9bbc698$var$getState(checked) {
135
- return checked ? 'checked' : 'unchecked';
129
+ function getState(checked) {
130
+ return checked ? "checked" : "unchecked";
136
131
  }
137
- const $6be4966fd9bbc698$export$be92b6f5f03c0fe9 = $6be4966fd9bbc698$export$b5d5cf8927ab7262;
138
- const $6be4966fd9bbc698$export$6521433ed15a34db = $6be4966fd9bbc698$export$4d07bf653ea69106;
139
-
140
-
141
-
142
-
143
- export {$6be4966fd9bbc698$export$cf7f5f17f69cbd43 as createSwitchScope, $6be4966fd9bbc698$export$b5d5cf8927ab7262 as Switch, $6be4966fd9bbc698$export$4d07bf653ea69106 as SwitchThumb, $6be4966fd9bbc698$export$be92b6f5f03c0fe9 as Root, $6be4966fd9bbc698$export$6521433ed15a34db as Thumb};
132
+ var Root = Switch;
133
+ var Thumb = SwitchThumb;
134
+ export {
135
+ Root,
136
+ Switch,
137
+ SwitchThumb,
138
+ Thumb,
139
+ createSwitchScope
140
+ };
144
141
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;A;;;;;;;;;ACYA;;oGAEA,CAEA,MAAMa,iCAAW,GAAG,QAApB,AAAA;AAGA,MAAM,CAACC,yCAAD,EAAsBd,yCAAtB,CAAA,GAA2CQ,yBAAkB,CAACK,iCAAD,CAAnE,AAAA;AAGA,MAAM,CAACE,oCAAD,EAAiBC,sCAAjB,CAAA,GAAqCF,yCAAmB,CAAqBD,iCAArB,CAA9D,AAAA;AAWA,MAAMZ,yCAAM,GAAA,aAAGI,CAAAA,iBAAA,CACb,CAACa,KAAD,EAAkCC,YAAlC,GAAmD;IACjD,MAAM,E,eACJC,aADI,CAAA,E,MAEJC,IAFI,CAAA,EAGJC,OAAO,EAAEC,WAHL,CAAA,E,gBAIJC,cAJI,CAAA,E,UAKJC,QALI,CAAA,E,UAMJC,QANI,CAAA,SAOJC,KAAK,GAAG,IAPJ,G,iBAQJC,eARI,CAAA,EASJ,GAAGC,WAAH,EATI,GAUFX,KAVJ,AAAM;IAWN,MAAM,CAACY,MAAD,EAASC,SAAT,CAAA,GAAsB1B,eAAA,CAAyC,IAAzC,CAA5B,AAAA;IACA,MAAM4B,YAAY,GAAG1B,sBAAe,CAACY,YAAD,EAAgBe,CAAAA,IAAD,GAAUH,SAAS,CAACG,IAAD,CAAlC;IAAA,CAApC,AAAA;IACA,MAAMC,gCAAgC,GAAG9B,aAAA,C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C,GANP;QAOE,KAAK,EAAE;YACL,GAAG1C,KAAK,CAACyD,KADJ;YAEL,GAAGd,WAFE;YAGLe,QAAQ,EAAE,UAHL;YAILC,aAAa,EAAE,MAJV;YAKLC,OAAO,EAAE,CALJ;YAMLC,MAAM,EAAE,CAARA;SANK;KAPT,CAAA,CADF,CACE;CApBJ,AAqCC;AAED,SAASnC,8BAAT,CAAkBtB,OAAlB,EAAoC;IAClC,OAAOA,OAAO,GAAG,SAAH,GAAe,WAA7B,CAAA;CACD;AAED,MAAMnB,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAK,GAAGF,yCAAd,AAAA;;ADvLA","sources":["packages/react/switch/src/index.ts","packages/react/switch/src/Switch.tsx"],"sourcesContent":["export {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n} from './Switch';\nexport type { SwitchProps, SwitchThumbProps } from './Switch';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nconst SWITCH_NAME = 'Switch';\n\ntype ScopedProps<P> = P & { __scopeSwitch?: Scope };\nconst [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\n\ntype SwitchContextValue = { checked: boolean; disabled?: boolean };\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<SwitchContextValue>(SWITCH_NAME);\n\ntype SwitchElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface SwitchProps extends PrimitiveButtonProps {\n checked?: boolean;\n defaultChecked?: boolean;\n required?: boolean;\n onCheckedChange?(checked: boolean): void;\n}\n\nconst Switch = React.forwardRef<SwitchElement, SwitchProps>(\n (props: ScopedProps<SwitchProps>, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n\n return (\n <SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...switchProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if switch is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect switch updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </SwitchProvider>\n );\n }\n);\n\nSwitch.displayName = SWITCH_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb';\n\ntype SwitchThumbElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface SwitchThumbProps extends PrimitiveSpanProps {}\n\nconst SwitchThumb = React.forwardRef<SwitchThumbElement, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return (\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...thumbProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSwitchThumb.displayName = THUMB_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Switch;\nconst Thumb = SwitchThumb;\n\nexport {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n};\nexport type { SwitchProps, SwitchThumbProps };\n"],"names":["createSwitchScope","Switch","SwitchThumb","Root","Thumb","React","composeEventHandlers","useComposedRefs","createContextScope","useControllableState","usePrevious","useSize","Primitive","SWITCH_NAME","createSwitchContext","SwitchProvider","useSwitchContext","forwardRef","props","forwardedRef","__scopeSwitch","name","checked","checkedProp","defaultChecked","required","disabled","value","onCheckedChange","switchProps","button","setButton","useState","composedRefs","node","hasConsumerStoppedPropagationRef","useRef","isFormControl","Boolean","closest","setChecked","prop","defaultProp","onChange","getState","undefined","onClick","event","prevChecked","current","isPropagationStopped","stopPropagation","transform","THUMB_NAME","thumbProps","context","BubbleInput","control","bubbles","inputProps","ref","controlSize","useEffect","input","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","set","Event","call","dispatchEvent","style","position","pointerEvents","opacity","margin"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Switch.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nconst SWITCH_NAME = 'Switch';\n\ntype ScopedProps<P> = P & { __scopeSwitch?: Scope };\nconst [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);\n\ntype SwitchContextValue = { checked: boolean; disabled?: boolean };\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<SwitchContextValue>(SWITCH_NAME);\n\ntype SwitchElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface SwitchProps extends PrimitiveButtonProps {\n checked?: boolean;\n defaultChecked?: boolean;\n required?: boolean;\n onCheckedChange?(checked: boolean): void;\n}\n\nconst Switch = React.forwardRef<SwitchElement, SwitchProps>(\n (props: ScopedProps<SwitchProps>, forwardedRef) => {\n const {\n __scopeSwitch,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n ...switchProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange,\n });\n\n return (\n <SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...switchProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if switch is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect switch updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </SwitchProvider>\n );\n }\n);\n\nSwitch.displayName = SWITCH_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb';\n\ntype SwitchThumbElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;\ninterface SwitchThumbProps extends PrimitiveSpanProps {}\n\nconst SwitchThumb = React.forwardRef<SwitchThumbElement, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props;\n const context = useSwitchContext(THUMB_NAME, __scopeSwitch);\n return (\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...thumbProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSwitchThumb.displayName = THUMB_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"checkbox\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nconst Root = Switch;\nconst Thumb = SwitchThumb;\n\nexport {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n};\nexport type { SwitchProps, SwitchThumbProps };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAmDpB,SACE,KADF;AA1CN,IAAM,cAAc;AAGpB,IAAM,CAAC,qBAAqB,iBAAiB,IAAI,mBAAmB,WAAW;AAG/E,IAAM,CAAC,gBAAgB,gBAAgB,IAAI,oBAAwC,WAAW;AAW9F,IAAM,SAAe;AAAA,EACnB,CAAC,OAAiC,iBAAiB;AACjD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,UAAM,CAAC,QAAQ,SAAS,IAAU,eAAmC,IAAI;AACzE,UAAM,eAAe,gBAAgB,cAAc,CAAC,SAAS,UAAU,IAAI,CAAC;AAC5E,UAAM,mCAAyC,aAAO,KAAK;AAE3D,UAAM,gBAAgB,SAAS,QAAQ,OAAO,QAAQ,MAAM,CAAC,IAAI;AACjE,UAAM,CAAC,UAAU,OAAO,UAAU,IAAI,qBAAqB;AAAA,MACzD,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU;AAAA,IACZ,CAAC;AAED,WACE,qBAAC,kBAAe,OAAO,eAAe,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Y,OAAO;AACvC,QAAM,cAAc,QAAQ,OAAO;AAGnC,EAAM,gBAAU,MAAM;AACpB,UAAM,QAAQ,IAAI;AAClB,UAAM,aAAa,OAAO,iBAAiB;AAC3C,UAAM,aAAa,OAAO,yBAAyB,YAAY,SAAS;AACxE,UAAM,aAAa,WAAW;AAC9B,QAAI,gBAAgB,WAAW,YAAY;AACzC,YAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,iBAAW,KAAK,OAAO,OAAO;AAC9B,YAAM,cAAc,KAAK;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,eAAW;AAAA,MACX,gBAAgB;AAAA,MACf,GAAG;AAAA,MACJ,UAAU;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,GAAG,MAAM;AAAA,QACT,GAAG;AAAA,QACH,UAAU;AAAA,QACV,eAAe;AAAA,QACf,SAAS;AAAA,QACT,QAAQ;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,SAAS,SAAkB;AAClC,SAAO,UAAU,YAAY;AAC/B;AAEA,IAAM,OAAO;AACb,IAAM,QAAQ;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-switch",
3
- "version": "1.0.3",
3
+ "version": "1.1.0-rc.1",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -28,14 +28,13 @@
28
28
  "version": "yarn version"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.13.10",
32
- "@radix-ui/primitive": "1.0.1",
33
- "@radix-ui/react-compose-refs": "1.0.1",
34
- "@radix-ui/react-context": "1.0.1",
35
- "@radix-ui/react-primitive": "1.0.3",
36
- "@radix-ui/react-use-controllable-state": "1.0.1",
37
- "@radix-ui/react-use-previous": "1.0.1",
38
- "@radix-ui/react-use-size": "1.0.1"
31
+ "@radix-ui/primitive": "1.1.0-rc.1",
32
+ "@radix-ui/react-compose-refs": "1.1.0-rc.1",
33
+ "@radix-ui/react-context": "1.1.0-rc.1",
34
+ "@radix-ui/react-primitive": "1.1.0-rc.1",
35
+ "@radix-ui/react-use-controllable-state": "1.1.0-rc.1",
36
+ "@radix-ui/react-use-previous": "1.1.0-rc.1",
37
+ "@radix-ui/react-use-size": "1.1.0-rc.1"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "@types/react": "*",
@@ -58,5 +57,6 @@
58
57
  },
59
58
  "bugs": {
60
59
  "url": "https://github.com/radix-ui/primitives/issues"
61
- }
60
+ },
61
+ "stableVersion": "1.0.3"
62
62
  }
@@ -1 +0,0 @@
1
- {"mappings":";;;AAmBA,OAAA,wFAAgF,CAAC;AAMjF,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,4BAAsB,SAAQ,oBAAoB;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1C;AAED,OAAA,MAAM,6FAkEL,CAAC;AAWF,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC;AAChF,iCAA2B,SAAQ,kBAAkB;CAAG;AAExD,OAAA,MAAM,qGAaL,CAAC;AAwDF,OAAA,MAAM,2FAAa,CAAC;AACpB,OAAA,MAAM,+FAAmB,CAAC","sources":["packages/react/switch/src/packages/react/switch/src/Switch.tsx","packages/react/switch/src/packages/react/switch/src/index.ts","packages/react/switch/src/index.ts"],"sourcesContent":[null,null,"export {\n createSwitchScope,\n //\n Switch,\n SwitchThumb,\n //\n Root,\n Thumb,\n} from './Switch';\nexport type { SwitchProps, SwitchThumbProps } from './Switch';\n"],"names":[],"version":3,"file":"index.d.ts.map"}