@tamagui/switch 1.2.9 → 1.2.10

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.
@@ -0,0 +1,242 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { usePrevious } from "@radix-ui/react-use-previous";
3
+ import { useComposedRefs } from "@tamagui/compose-refs";
4
+ import {
5
+ getVariableValue,
6
+ isWeb,
7
+ styled,
8
+ withStaticProperties
9
+ } from "@tamagui/core";
10
+ import { createContextScope } from "@tamagui/create-context";
11
+ import { registerFocusable } from "@tamagui/focusable";
12
+ import { getSize } from "@tamagui/get-size";
13
+ import { useLabelContext } from "@tamagui/label";
14
+ import { ThemeableStack, XStack } from "@tamagui/stacks";
15
+ import { useControllableState } from "@tamagui/use-controllable-state";
16
+ import * as React from "react";
17
+ const SWITCH_NAME = "Switch";
18
+ const getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65);
19
+ const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
20
+ const scopeContexts = createContextScope(SWITCH_NAME);
21
+ const [createSwitchContext] = scopeContexts;
22
+ const createSwitchScope = scopeContexts[1];
23
+ const [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
24
+ const THUMB_NAME = "SwitchThumb";
25
+ const SwitchThumbFrame = styled(ThemeableStack, {
26
+ name: "SwitchThumb",
27
+ backgroundColor: "$background",
28
+ borderRadius: 1e3,
29
+ variants: {
30
+ size: {
31
+ "...size": (val) => {
32
+ const size = getSwitchHeight(val);
33
+ return {
34
+ height: size,
35
+ width: size
36
+ };
37
+ }
38
+ }
39
+ },
40
+ defaultVariants: {
41
+ size: "$true"
42
+ }
43
+ });
44
+ const SwitchThumb = SwitchThumbFrame.extractable(
45
+ React.forwardRef(
46
+ (props, forwardedRef) => {
47
+ const { __scopeSwitch, ...thumbProps } = props;
48
+ const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch);
49
+ return /* @__PURE__ */ jsx(
50
+ SwitchThumbFrame,
51
+ {
52
+ size,
53
+ "data-state": getState(checked),
54
+ "data-disabled": disabled ? "" : void 0,
55
+ ...thumbProps,
56
+ x: checked ? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size)) : 0,
57
+ ref: forwardedRef
58
+ }
59
+ );
60
+ }
61
+ )
62
+ );
63
+ SwitchThumb.displayName = THUMB_NAME;
64
+ const SwitchFrame = styled(XStack, {
65
+ name: "Switch",
66
+ tag: "button",
67
+ borderRadius: 1e3,
68
+ borderWidth: 2,
69
+ borderColor: "transparent",
70
+ backgroundColor: "$background",
71
+ focusStyle: {
72
+ borderColor: "$borderColorFocus"
73
+ },
74
+ variants: {
75
+ size: {
76
+ "...size": (val) => {
77
+ const height = getSwitchHeight(val) + 4;
78
+ const width = getSwitchWidth(val) + 4;
79
+ return {
80
+ height,
81
+ minHeight: height,
82
+ width
83
+ };
84
+ }
85
+ }
86
+ },
87
+ defaultVariants: {
88
+ size: "$true"
89
+ }
90
+ });
91
+ const Switch = withStaticProperties(
92
+ SwitchFrame.extractable(
93
+ React.forwardRef(
94
+ (props, forwardedRef) => {
95
+ const {
96
+ __scopeSwitch,
97
+ labeledBy: ariaLabelledby,
98
+ name,
99
+ checked: checkedProp,
100
+ defaultChecked,
101
+ required,
102
+ disabled,
103
+ value = "on",
104
+ onCheckedChange,
105
+ size = "$true",
106
+ ...switchProps
107
+ } = props;
108
+ const [button, setButton] = React.useState(null);
109
+ const composedRefs = useComposedRefs(
110
+ forwardedRef,
111
+ (node) => setButton(node)
112
+ );
113
+ const labelId = useLabelContext(button);
114
+ const labelledBy = ariaLabelledby || labelId;
115
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
116
+ const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
117
+ const [checked = false, setChecked] = useControllableState({
118
+ prop: checkedProp,
119
+ defaultProp: defaultChecked || false,
120
+ onChange: onCheckedChange,
121
+ transition: true
122
+ });
123
+ if (!isWeb) {
124
+ React.useEffect(() => {
125
+ if (!props.id)
126
+ return;
127
+ return registerFocusable(props.id, {
128
+ focus: () => {
129
+ setChecked((x) => !x);
130
+ }
131
+ });
132
+ }, [props.id, setChecked]);
133
+ }
134
+ return /* @__PURE__ */ jsxs(
135
+ SwitchProvider,
136
+ {
137
+ scope: __scopeSwitch,
138
+ checked,
139
+ disabled,
140
+ size,
141
+ children: [
142
+ /* @__PURE__ */ jsx(
143
+ SwitchFrame,
144
+ {
145
+ size,
146
+ role: "switch",
147
+ "aria-checked": checked,
148
+ "aria-labelledby": labelledBy,
149
+ "aria-required": required,
150
+ "data-state": getState(checked),
151
+ "data-disabled": disabled ? "" : void 0,
152
+ disabled,
153
+ theme: checked ? "active" : null,
154
+ themeShallow: true,
155
+ tabIndex: disabled ? void 0 : 0,
156
+ value,
157
+ ...switchProps,
158
+ ref: composedRefs,
159
+ onPress: (event) => {
160
+ var _a;
161
+ (_a = props.onPress) == null ? void 0 : _a.call(props, event);
162
+ setChecked((prevChecked) => !prevChecked);
163
+ if (isWeb && isFormControl) {
164
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
165
+ if (!hasConsumerStoppedPropagationRef.current)
166
+ event.stopPropagation();
167
+ }
168
+ }
169
+ }
170
+ ),
171
+ isWeb && isFormControl && /* @__PURE__ */ jsx(
172
+ BubbleInput,
173
+ {
174
+ control: button,
175
+ bubbles: !hasConsumerStoppedPropagationRef.current,
176
+ name,
177
+ value,
178
+ checked,
179
+ required,
180
+ disabled,
181
+ style: { transform: "translateX(-100%)" }
182
+ }
183
+ )
184
+ ]
185
+ }
186
+ );
187
+ }
188
+ )
189
+ ),
190
+ {
191
+ Thumb: SwitchThumb
192
+ }
193
+ );
194
+ const BubbleInput = (props) => {
195
+ const { control, checked, bubbles = true, ...inputProps } = props;
196
+ const ref = React.useRef(null);
197
+ const prevChecked = usePrevious(checked);
198
+ React.useEffect(() => {
199
+ const input = ref.current;
200
+ const inputProto = window.HTMLInputElement.prototype;
201
+ const descriptor = Object.getOwnPropertyDescriptor(
202
+ inputProto,
203
+ "checked"
204
+ );
205
+ const setChecked = descriptor.set;
206
+ if (prevChecked !== checked && setChecked) {
207
+ const event = new Event("click", { bubbles });
208
+ setChecked.call(input, checked);
209
+ input.dispatchEvent(event);
210
+ }
211
+ }, [prevChecked, checked, bubbles]);
212
+ return /* @__PURE__ */ jsx(
213
+ "input",
214
+ {
215
+ type: "checkbox",
216
+ "aria-hidden": true,
217
+ defaultChecked: checked,
218
+ ...inputProps,
219
+ tabIndex: -1,
220
+ ref,
221
+ style: {
222
+ ...props.style,
223
+ // ...controlSize,
224
+ position: "absolute",
225
+ pointerEvents: "none",
226
+ opacity: 0,
227
+ margin: 0
228
+ }
229
+ }
230
+ );
231
+ };
232
+ function getState(checked) {
233
+ return checked ? "checked" : "unchecked";
234
+ }
235
+ export {
236
+ Switch,
237
+ SwitchFrame,
238
+ SwitchThumb,
239
+ SwitchThumbFrame,
240
+ createSwitchScope
241
+ };
242
+ //# sourceMappingURL=Switch.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Switch.tsx"],
4
+ "sourcesContent": ["// via radix\n// https://github.com/radix-ui/primitives/blob/main/packages/react/switch/src/Switch.tsx\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n SizeTokens,\n getVariableValue,\n isWeb,\n styled,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ScopedProps, createContextScope } from '@tamagui/create-context'\nimport { registerFocusable } from '@tamagui/focusable'\nimport { getSize } from '@tamagui/get-size'\nimport { useLabelContext } from '@tamagui/label'\nimport { ThemeableStack, XStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst SWITCH_NAME = 'Switch'\n\n// TODO make customizable\nconst getSwitchHeight = (val: SizeTokens) =>\n Math.round(getVariableValue(getSize(val)) * 0.65)\nconst getSwitchWidth = (val: SizeTokens) => getSwitchHeight(val) * 2\n\nconst scopeContexts = createContextScope(SWITCH_NAME)\nconst [createSwitchContext] = scopeContexts\nexport const createSwitchScope = scopeContexts[1]\n\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<{\n checked: boolean\n disabled?: boolean\n size: SizeTokens\n}>(SWITCH_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb'\n\nexport const SwitchThumbFrame = styled(ThemeableStack, {\n name: 'SwitchThumb',\n backgroundColor: '$background',\n borderRadius: 1000,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = getSwitchHeight(val)\n return {\n height: size,\n width: size,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\nexport type SwitchThumbProps = GetProps<typeof SwitchThumbFrame>\n\nexport const SwitchThumb = SwitchThumbFrame.extractable(\n React.forwardRef<React.ElementRef<'span'>, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps, 'Switch'>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props\n const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch)\n return (\n <SwitchThumbFrame\n size={size}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n {...thumbProps}\n x={\n checked\n ? getVariableValue(getSwitchWidth(size)) -\n getVariableValue(getSwitchHeight(size))\n : 0\n }\n ref={forwardedRef}\n />\n )\n }\n )\n)\n\nSwitchThumb.displayName = THUMB_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SwitchFrame = styled(XStack, {\n name: 'Switch',\n tag: 'button',\n borderRadius: 1000,\n borderWidth: 2,\n borderColor: 'transparent',\n backgroundColor: '$background',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': (val) => {\n const height = getSwitchHeight(val) + 4\n const width = getSwitchWidth(val) + 4\n return {\n height,\n minHeight: height,\n width,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\ntype SwitchButtonProps = GetProps<typeof SwitchFrame>\n\nexport type SwitchProps = SwitchButtonProps & {\n labeledBy?: string\n name?: string\n value?: string\n checked?: boolean\n defaultChecked?: boolean\n required?: boolean\n onCheckedChange?(checked: boolean): void\n}\n\nexport const Switch = withStaticProperties(\n SwitchFrame.extractable(\n React.forwardRef<HTMLButtonElement | View, SwitchProps>(\n (props: ScopedProps<SwitchProps, 'Switch'>, forwardedRef) => {\n const {\n __scopeSwitch,\n labeledBy: ariaLabelledby,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n size = '$true',\n ...switchProps\n } = props\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) =>\n setButton(node as any)\n )\n const labelId = useLabelContext(button)\n const labelledBy = ariaLabelledby || labelId\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 = isWeb\n ? button\n ? Boolean(button.closest('form'))\n : true\n : false\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked || false,\n onChange: onCheckedChange,\n transition: true,\n })\n\n if (!isWeb) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!props.id) return\n return registerFocusable(props.id, {\n focus: () => {\n setChecked((x) => !x)\n },\n })\n }, [props.id, setChecked])\n }\n\n return (\n <SwitchProvider\n scope={__scopeSwitch}\n checked={checked}\n disabled={disabled}\n size={size}\n >\n <SwitchFrame\n size={size}\n // @ts-ignore\n role=\"switch\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n theme={checked ? 'active' : null}\n themeShallow\n // @ts-ignore\n tabIndex={disabled ? undefined : 0}\n // @ts-ignore\n value={value}\n {...switchProps}\n ref={composedRefs}\n onPress={(event) => {\n props.onPress?.(event)\n setChecked((prevChecked) => !prevChecked)\n if (isWeb && 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 {isWeb && 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 ),\n {\n Thumb: SwitchThumb,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = any //Radix.ComponentPropsWithoutRef<'input'>\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean\n control: HTMLElement | null\n bubbles: boolean\n}\n\n// TODO make this native friendly\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(\n inputProto,\n 'checked'\n ) 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"],
5
+ "mappings": "AA2EQ,cAqHE,YArHF;AAxER,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAsB,0BAA0B;AAChD,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,cAAc;AACvC,SAAS,4BAA4B;AACrC,YAAY,WAAW;AAGvB,MAAM,cAAc;AAGpB,MAAM,kBAAkB,CAAC,QACvB,KAAK,MAAM,iBAAiB,QAAQ,GAAG,CAAC,IAAI,IAAI;AAClD,MAAM,iBAAiB,CAAC,QAAoB,gBAAgB,GAAG,IAAI;AAEnE,MAAM,gBAAgB,mBAAmB,WAAW;AACpD,MAAM,CAAC,mBAAmB,IAAI;AACvB,MAAM,oBAAoB,cAAc,CAAC;AAEhD,MAAM,CAAC,gBAAgB,gBAAgB,IAAI,oBAIxC,WAAW;AAMd,MAAM,aAAa;AAEZ,MAAM,mBAAmB,OAAO,gBAAgB;AAAA,EACrD,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,cAAc;AAAA,EAEd,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,QAAQ;AAClB,cAAM,OAAO,gBAAgB,GAAG;AAChC,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAIM,MAAM,cAAc,iBAAiB;AAAA,EAC1C,MAAM;AAAA,IACJ,CAAC,OAAgD,iBAAiB;AAChE,YAAM,EAAE,eAAe,GAAG,WAAW,IAAI;AACzC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7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Switch";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Switch'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,224 @@
1
+ import { usePrevious } from "@radix-ui/react-use-previous";
2
+ import { useComposedRefs } from "@tamagui/compose-refs";
3
+ import {
4
+ getVariableValue,
5
+ isWeb,
6
+ styled,
7
+ withStaticProperties
8
+ } from "@tamagui/core";
9
+ import { createContextScope } from "@tamagui/create-context";
10
+ import { registerFocusable } from "@tamagui/focusable";
11
+ import { getSize } from "@tamagui/get-size";
12
+ import { useLabelContext } from "@tamagui/label";
13
+ import { ThemeableStack, XStack } from "@tamagui/stacks";
14
+ import { useControllableState } from "@tamagui/use-controllable-state";
15
+ import * as React from "react";
16
+ const SWITCH_NAME = "Switch";
17
+ const getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65);
18
+ const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
19
+ const scopeContexts = createContextScope(SWITCH_NAME);
20
+ const [createSwitchContext] = scopeContexts;
21
+ const createSwitchScope = scopeContexts[1];
22
+ const [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
23
+ const THUMB_NAME = "SwitchThumb";
24
+ const SwitchThumbFrame = styled(ThemeableStack, {
25
+ name: "SwitchThumb",
26
+ backgroundColor: "$background",
27
+ borderRadius: 1e3,
28
+ variants: {
29
+ size: {
30
+ "...size": (val) => {
31
+ const size = getSwitchHeight(val);
32
+ return {
33
+ height: size,
34
+ width: size
35
+ };
36
+ }
37
+ }
38
+ },
39
+ defaultVariants: {
40
+ size: "$true"
41
+ }
42
+ });
43
+ const SwitchThumb = SwitchThumbFrame.extractable(
44
+ React.forwardRef(
45
+ (props, forwardedRef) => {
46
+ const { __scopeSwitch, ...thumbProps } = props;
47
+ const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch);
48
+ return <SwitchThumbFrame
49
+ size={size}
50
+ data-state={getState(checked)}
51
+ data-disabled={disabled ? "" : void 0}
52
+ {...thumbProps}
53
+ x={checked ? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size)) : 0}
54
+ ref={forwardedRef}
55
+ />;
56
+ }
57
+ )
58
+ );
59
+ SwitchThumb.displayName = THUMB_NAME;
60
+ const SwitchFrame = styled(XStack, {
61
+ name: "Switch",
62
+ tag: "button",
63
+ borderRadius: 1e3,
64
+ borderWidth: 2,
65
+ borderColor: "transparent",
66
+ backgroundColor: "$background",
67
+ focusStyle: {
68
+ borderColor: "$borderColorFocus"
69
+ },
70
+ variants: {
71
+ size: {
72
+ "...size": (val) => {
73
+ const height = getSwitchHeight(val) + 4;
74
+ const width = getSwitchWidth(val) + 4;
75
+ return {
76
+ height,
77
+ minHeight: height,
78
+ width
79
+ };
80
+ }
81
+ }
82
+ },
83
+ defaultVariants: {
84
+ size: "$true"
85
+ }
86
+ });
87
+ const Switch = withStaticProperties(
88
+ SwitchFrame.extractable(
89
+ React.forwardRef(
90
+ (props, forwardedRef) => {
91
+ const {
92
+ __scopeSwitch,
93
+ labeledBy: ariaLabelledby,
94
+ name,
95
+ checked: checkedProp,
96
+ defaultChecked,
97
+ required,
98
+ disabled,
99
+ value = "on",
100
+ onCheckedChange,
101
+ size = "$true",
102
+ ...switchProps
103
+ } = props;
104
+ const [button, setButton] = React.useState(null);
105
+ const composedRefs = useComposedRefs(
106
+ forwardedRef,
107
+ (node) => setButton(node)
108
+ );
109
+ const labelId = useLabelContext(button);
110
+ const labelledBy = ariaLabelledby || labelId;
111
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
112
+ const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
113
+ const [checked = false, setChecked] = useControllableState({
114
+ prop: checkedProp,
115
+ defaultProp: defaultChecked || false,
116
+ onChange: onCheckedChange,
117
+ transition: true
118
+ });
119
+ if (!isWeb) {
120
+ React.useEffect(() => {
121
+ if (!props.id)
122
+ return;
123
+ return registerFocusable(props.id, {
124
+ focus: () => {
125
+ setChecked((x) => !x);
126
+ }
127
+ });
128
+ }, [props.id, setChecked]);
129
+ }
130
+ return <SwitchProvider
131
+ scope={__scopeSwitch}
132
+ checked={checked}
133
+ disabled={disabled}
134
+ size={size}
135
+ >
136
+ <SwitchFrame
137
+ size={size}
138
+ role="switch"
139
+ aria-checked={checked}
140
+ aria-labelledby={labelledBy}
141
+ aria-required={required}
142
+ data-state={getState(checked)}
143
+ data-disabled={disabled ? "" : void 0}
144
+ disabled={disabled}
145
+ theme={checked ? "active" : null}
146
+ themeShallow
147
+ tabIndex={disabled ? void 0 : 0}
148
+ value={value}
149
+ {...switchProps}
150
+ ref={composedRefs}
151
+ onPress={(event) => {
152
+ props.onPress?.(event);
153
+ setChecked((prevChecked) => !prevChecked);
154
+ if (isWeb && isFormControl) {
155
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
156
+ if (!hasConsumerStoppedPropagationRef.current)
157
+ event.stopPropagation();
158
+ }
159
+ }}
160
+ />
161
+ {isWeb && isFormControl && <BubbleInput
162
+ control={button}
163
+ bubbles={!hasConsumerStoppedPropagationRef.current}
164
+ name={name}
165
+ value={value}
166
+ checked={checked}
167
+ required={required}
168
+ disabled={disabled}
169
+ style={{ transform: "translateX(-100%)" }}
170
+ />}
171
+ </SwitchProvider>;
172
+ }
173
+ )
174
+ ),
175
+ {
176
+ Thumb: SwitchThumb
177
+ }
178
+ );
179
+ const BubbleInput = (props) => {
180
+ const { control, checked, bubbles = true, ...inputProps } = props;
181
+ const ref = React.useRef(null);
182
+ const prevChecked = usePrevious(checked);
183
+ React.useEffect(() => {
184
+ const input = ref.current;
185
+ const inputProto = window.HTMLInputElement.prototype;
186
+ const descriptor = Object.getOwnPropertyDescriptor(
187
+ inputProto,
188
+ "checked"
189
+ );
190
+ const setChecked = descriptor.set;
191
+ if (prevChecked !== checked && setChecked) {
192
+ const event = new Event("click", { bubbles });
193
+ setChecked.call(input, checked);
194
+ input.dispatchEvent(event);
195
+ }
196
+ }, [prevChecked, checked, bubbles]);
197
+ return <input
198
+ type="checkbox"
199
+ aria-hidden
200
+ defaultChecked={checked}
201
+ {...inputProps}
202
+ tabIndex={-1}
203
+ ref={ref}
204
+ style={{
205
+ ...props.style,
206
+ // ...controlSize,
207
+ position: "absolute",
208
+ pointerEvents: "none",
209
+ opacity: 0,
210
+ margin: 0
211
+ }}
212
+ />;
213
+ };
214
+ function getState(checked) {
215
+ return checked ? "checked" : "unchecked";
216
+ }
217
+ export {
218
+ Switch,
219
+ SwitchFrame,
220
+ SwitchThumb,
221
+ SwitchThumbFrame,
222
+ createSwitchScope
223
+ };
224
+ //# sourceMappingURL=Switch.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Switch.tsx"],
4
+ "sourcesContent": ["// via radix\n// https://github.com/radix-ui/primitives/blob/main/packages/react/switch/src/Switch.tsx\n\nimport { usePrevious } from '@radix-ui/react-use-previous'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n SizeTokens,\n getVariableValue,\n isWeb,\n styled,\n withStaticProperties,\n} from '@tamagui/core'\nimport { ScopedProps, createContextScope } from '@tamagui/create-context'\nimport { registerFocusable } from '@tamagui/focusable'\nimport { getSize } from '@tamagui/get-size'\nimport { useLabelContext } from '@tamagui/label'\nimport { ThemeableStack, XStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst SWITCH_NAME = 'Switch'\n\n// TODO make customizable\nconst getSwitchHeight = (val: SizeTokens) =>\n Math.round(getVariableValue(getSize(val)) * 0.65)\nconst getSwitchWidth = (val: SizeTokens) => getSwitchHeight(val) * 2\n\nconst scopeContexts = createContextScope(SWITCH_NAME)\nconst [createSwitchContext] = scopeContexts\nexport const createSwitchScope = scopeContexts[1]\n\nconst [SwitchProvider, useSwitchContext] = createSwitchContext<{\n checked: boolean\n disabled?: boolean\n size: SizeTokens\n}>(SWITCH_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb'\n\nexport const SwitchThumbFrame = styled(ThemeableStack, {\n name: 'SwitchThumb',\n backgroundColor: '$background',\n borderRadius: 1000,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = getSwitchHeight(val)\n return {\n height: size,\n width: size,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\nexport type SwitchThumbProps = GetProps<typeof SwitchThumbFrame>\n\nexport const SwitchThumb = SwitchThumbFrame.extractable(\n React.forwardRef<React.ElementRef<'span'>, SwitchThumbProps>(\n (props: ScopedProps<SwitchThumbProps, 'Switch'>, forwardedRef) => {\n const { __scopeSwitch, ...thumbProps } = props\n const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch)\n return (\n <SwitchThumbFrame\n size={size}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n {...thumbProps}\n x={\n checked\n ? getVariableValue(getSwitchWidth(size)) -\n getVariableValue(getSwitchHeight(size))\n : 0\n }\n ref={forwardedRef}\n />\n )\n }\n )\n)\n\nSwitchThumb.displayName = THUMB_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Switch\n * -----------------------------------------------------------------------------------------------*/\n\nexport const SwitchFrame = styled(XStack, {\n name: 'Switch',\n tag: 'button',\n borderRadius: 1000,\n borderWidth: 2,\n borderColor: 'transparent',\n backgroundColor: '$background',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': (val) => {\n const height = getSwitchHeight(val) + 4\n const width = getSwitchWidth(val) + 4\n return {\n height,\n minHeight: height,\n width,\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\ntype SwitchButtonProps = GetProps<typeof SwitchFrame>\n\nexport type SwitchProps = SwitchButtonProps & {\n labeledBy?: string\n name?: string\n value?: string\n checked?: boolean\n defaultChecked?: boolean\n required?: boolean\n onCheckedChange?(checked: boolean): void\n}\n\nexport const Switch = withStaticProperties(\n SwitchFrame.extractable(\n React.forwardRef<HTMLButtonElement | View, SwitchProps>(\n (props: ScopedProps<SwitchProps, 'Switch'>, forwardedRef) => {\n const {\n __scopeSwitch,\n labeledBy: ariaLabelledby,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = 'on',\n onCheckedChange,\n size = '$true',\n ...switchProps\n } = props\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null)\n const composedRefs = useComposedRefs(forwardedRef, (node) =>\n setButton(node as any)\n )\n const labelId = useLabelContext(button)\n const labelledBy = ariaLabelledby || labelId\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 = isWeb\n ? button\n ? Boolean(button.closest('form'))\n : true\n : false\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked || false,\n onChange: onCheckedChange,\n transition: true,\n })\n\n if (!isWeb) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!props.id) return\n return registerFocusable(props.id, {\n focus: () => {\n setChecked((x) => !x)\n },\n })\n }, [props.id, setChecked])\n }\n\n return (\n <SwitchProvider\n scope={__scopeSwitch}\n checked={checked}\n disabled={disabled}\n size={size}\n >\n <SwitchFrame\n size={size}\n // @ts-ignore\n role=\"switch\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n aria-required={required}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n theme={checked ? 'active' : null}\n themeShallow\n // @ts-ignore\n tabIndex={disabled ? undefined : 0}\n // @ts-ignore\n value={value}\n {...switchProps}\n ref={composedRefs}\n onPress={(event) => {\n props.onPress?.(event)\n setChecked((prevChecked) => !prevChecked)\n if (isWeb && 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 {isWeb && 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 ),\n {\n Thumb: SwitchThumb,\n }\n)\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype InputProps = any //Radix.ComponentPropsWithoutRef<'input'>\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean\n control: HTMLElement | null\n bubbles: boolean\n}\n\n// TODO make this native friendly\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(\n inputProto,\n 'checked'\n ) 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 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AAO,EAAE,WAAW,oBAAoB;AAAA,UAC1C;AAAA,QAEJ,EAnDC;AAAA,MAqDL;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,OAAO;AAAA,EACT;AACF;AAYA,MAAM,cAAc,CAAC,UAA4B;AAC/C,QAAM,EAAE,SAAS,SAAS,UAAU,MAAM,GAAG,WAAW,IAAI;AAC5D,QAAM,MAAM,MAAM,OAAyB,IAAI;AAC/C,QAAM,cAAc,YAAY,OAAO;AAIvC,QAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,IAAI;AAClB,UAAM,aAAa,OAAO,iBAAiB;AAC3C,UAAM,aAAa,OAAO;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AACA,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,CAAC;AAAA,IACC,KAAK;AAAA,IACL;AAAA,IACA,gBAAgB;AAAA,QACZ;AAAA,IACJ,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,MACL,GAAG,MAAM;AAAA;AAAA,MAET,UAAU;AAAA,MACV,eAAe;AAAA,MACf,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,EACF;AAEJ;AAEA,SAAS,SAAS,SAAkB;AAClC,SAAO,UAAU,YAAY;AAC/B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Switch";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Switch'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/switch",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -24,14 +24,14 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@radix-ui/react-use-previous": "^0.1.1",
27
- "@tamagui/compose-refs": "^1.2.9",
28
- "@tamagui/core": "^1.2.9",
29
- "@tamagui/create-context": "^1.2.9",
30
- "@tamagui/focusable": "^1.2.9",
31
- "@tamagui/get-size": "^1.2.9",
32
- "@tamagui/label": "^1.2.9",
33
- "@tamagui/stacks": "^1.2.9",
34
- "@tamagui/use-controllable-state": "^1.2.9"
27
+ "@tamagui/compose-refs": "^1.2.10",
28
+ "@tamagui/core": "^1.2.10",
29
+ "@tamagui/create-context": "^1.2.10",
30
+ "@tamagui/focusable": "^1.2.10",
31
+ "@tamagui/get-size": "^1.2.10",
32
+ "@tamagui/label": "^1.2.10",
33
+ "@tamagui/stacks": "^1.2.10",
34
+ "@tamagui/use-controllable-state": "^1.2.10"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "*",
@@ -39,7 +39,7 @@
39
39
  "react-native": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "^1.2.9",
42
+ "@tamagui/build": "^1.2.10",
43
43
  "react": "^18.2.0",
44
44
  "react-dom": "^18.2.0",
45
45
  "react-native": "*"