@tamagui/switch 1.14.0 → 1.14.2
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/cjs/Switch.js +295 -1
- package/dist/cjs/Switch.js.map +2 -2
- package/dist/cjs/index.js +18 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/Switch.js +262 -1
- package/dist/esm/Switch.js.map +2 -2
- package/dist/esm/Switch.mjs +262 -1
- package/dist/esm/Switch.mjs.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/jsx/Switch.js +244 -1
- package/dist/jsx/Switch.js.map +2 -2
- package/dist/jsx/Switch.mjs +244 -1
- package/dist/jsx/Switch.mjs.map +2 -2
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/esm/Switch.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Switch.tsx"],
|
|
4
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 unstyled?: boolean\n}>(SWITCH_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb'\n\nexport const SwitchThumbFrame = styled(ThemeableStack, {\n name: 'SwitchThumb',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n backgroundColor: '$background',\n borderRadius: 1000,\n },\n },\n\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 unstyled: false,\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, size: sizeProp, ...thumbProps } = props\n const {\n size: sizeContext,\n disabled,\n checked,\n unstyled,\n } = useSwitchContext(THUMB_NAME, __scopeSwitch)\n const size = sizeProp ?? sizeContext\n return (\n <SwitchThumbFrame\n unstyled={unstyled}\n size={size}\n theme={checked ? 'active' : null}\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_NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n borderRadius: 1000,\n borderWidth: 2,\n borderColor: 'transparent',\n backgroundColor: '$background',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n },\n },\n\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 unstyled: false,\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 unstyled = false,\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 unstyled={unstyled}\n >\n <SwitchFrame\n unstyled={unstyled}\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": "AAwFQ,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAwFQ,cA8HE,YA9HF;AArFR,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,oBAKxC,WAAW;AAMd,MAAM,aAAa;AAEZ,MAAM,mBAAmB,OAAO,gBAAgB;AAAA,EACrD,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,iBAAiB;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AAM,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;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;AAAA,QAET,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;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./Switch";
|
|
1
|
+
export * from "./Switch";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./Switch";
|
|
1
|
+
export * from "./Switch";
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
package/dist/jsx/Switch.js
CHANGED
|
@@ -1,2 +1,245 @@
|
|
|
1
|
-
import{usePrevious
|
|
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
|
+
variants: {
|
|
27
|
+
unstyled: {
|
|
28
|
+
false: {
|
|
29
|
+
size: "$true",
|
|
30
|
+
backgroundColor: "$background",
|
|
31
|
+
borderRadius: 1e3
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
"...size": (val) => {
|
|
36
|
+
const size = getSwitchHeight(val);
|
|
37
|
+
return {
|
|
38
|
+
height: size,
|
|
39
|
+
width: size
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
unstyled: false
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const SwitchThumb = SwitchThumbFrame.extractable(
|
|
49
|
+
React.forwardRef(
|
|
50
|
+
(props, forwardedRef) => {
|
|
51
|
+
const { __scopeSwitch, size: sizeProp, ...thumbProps } = props;
|
|
52
|
+
const {
|
|
53
|
+
size: sizeContext,
|
|
54
|
+
disabled,
|
|
55
|
+
checked,
|
|
56
|
+
unstyled
|
|
57
|
+
} = useSwitchContext(THUMB_NAME, __scopeSwitch);
|
|
58
|
+
const size = sizeProp ?? sizeContext;
|
|
59
|
+
return <SwitchThumbFrame
|
|
60
|
+
unstyled={unstyled}
|
|
61
|
+
size={size}
|
|
62
|
+
theme={checked ? "active" : null}
|
|
63
|
+
data-state={getState(checked)}
|
|
64
|
+
data-disabled={disabled ? "" : void 0}
|
|
65
|
+
{...thumbProps}
|
|
66
|
+
x={checked ? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size)) : 0}
|
|
67
|
+
ref={forwardedRef}
|
|
68
|
+
/>;
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
SwitchThumb.displayName = THUMB_NAME;
|
|
73
|
+
const SwitchFrame = styled(XStack, {
|
|
74
|
+
name: SWITCH_NAME,
|
|
75
|
+
tag: "button",
|
|
76
|
+
variants: {
|
|
77
|
+
unstyled: {
|
|
78
|
+
false: {
|
|
79
|
+
size: "$true",
|
|
80
|
+
borderRadius: 1e3,
|
|
81
|
+
borderWidth: 2,
|
|
82
|
+
borderColor: "transparent",
|
|
83
|
+
backgroundColor: "$background",
|
|
84
|
+
focusStyle: {
|
|
85
|
+
borderColor: "$borderColorFocus"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
size: {
|
|
90
|
+
"...size": (val) => {
|
|
91
|
+
const height = getSwitchHeight(val) + 4;
|
|
92
|
+
const width = getSwitchWidth(val) + 4;
|
|
93
|
+
return {
|
|
94
|
+
height,
|
|
95
|
+
minHeight: height,
|
|
96
|
+
width
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
unstyled: false
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const Switch = withStaticProperties(
|
|
106
|
+
SwitchFrame.extractable(
|
|
107
|
+
React.forwardRef(
|
|
108
|
+
(props, forwardedRef) => {
|
|
109
|
+
const {
|
|
110
|
+
__scopeSwitch,
|
|
111
|
+
labeledBy: ariaLabelledby,
|
|
112
|
+
name,
|
|
113
|
+
checked: checkedProp,
|
|
114
|
+
defaultChecked,
|
|
115
|
+
required,
|
|
116
|
+
disabled,
|
|
117
|
+
value = "on",
|
|
118
|
+
onCheckedChange,
|
|
119
|
+
size = "$true",
|
|
120
|
+
unstyled = false,
|
|
121
|
+
...switchProps
|
|
122
|
+
} = props;
|
|
123
|
+
const [button, setButton] = React.useState(null);
|
|
124
|
+
const composedRefs = useComposedRefs(
|
|
125
|
+
forwardedRef,
|
|
126
|
+
(node) => setButton(node)
|
|
127
|
+
);
|
|
128
|
+
const labelId = useLabelContext(button);
|
|
129
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
130
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
131
|
+
const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
132
|
+
const [checked = false, setChecked] = useControllableState({
|
|
133
|
+
prop: checkedProp,
|
|
134
|
+
defaultProp: defaultChecked || false,
|
|
135
|
+
onChange: onCheckedChange,
|
|
136
|
+
transition: true
|
|
137
|
+
});
|
|
138
|
+
if (!isWeb) {
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
if (!props.id)
|
|
141
|
+
return;
|
|
142
|
+
return registerFocusable(props.id, {
|
|
143
|
+
focus: () => {
|
|
144
|
+
setChecked((x) => !x);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}, [props.id, setChecked]);
|
|
148
|
+
}
|
|
149
|
+
return <SwitchProvider
|
|
150
|
+
scope={__scopeSwitch}
|
|
151
|
+
checked={checked}
|
|
152
|
+
disabled={disabled}
|
|
153
|
+
size={size}
|
|
154
|
+
unstyled={unstyled}
|
|
155
|
+
>
|
|
156
|
+
<SwitchFrame
|
|
157
|
+
unstyled={unstyled}
|
|
158
|
+
size={size}
|
|
159
|
+
role="switch"
|
|
160
|
+
aria-checked={checked}
|
|
161
|
+
aria-labelledby={labelledBy}
|
|
162
|
+
aria-required={required}
|
|
163
|
+
data-state={getState(checked)}
|
|
164
|
+
data-disabled={disabled ? "" : void 0}
|
|
165
|
+
disabled={disabled}
|
|
166
|
+
theme={checked ? "active" : null}
|
|
167
|
+
themeShallow
|
|
168
|
+
tabIndex={disabled ? void 0 : 0}
|
|
169
|
+
value={value}
|
|
170
|
+
{...switchProps}
|
|
171
|
+
ref={composedRefs}
|
|
172
|
+
onPress={(event) => {
|
|
173
|
+
props.onPress?.(event);
|
|
174
|
+
setChecked((prevChecked) => !prevChecked);
|
|
175
|
+
if (isWeb && isFormControl) {
|
|
176
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
177
|
+
if (!hasConsumerStoppedPropagationRef.current)
|
|
178
|
+
event.stopPropagation();
|
|
179
|
+
}
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
{isWeb && isFormControl && <BubbleInput
|
|
183
|
+
control={button}
|
|
184
|
+
bubbles={!hasConsumerStoppedPropagationRef.current}
|
|
185
|
+
name={name}
|
|
186
|
+
value={value}
|
|
187
|
+
checked={checked}
|
|
188
|
+
required={required}
|
|
189
|
+
disabled={disabled}
|
|
190
|
+
style={{ transform: "translateX(-100%)" }}
|
|
191
|
+
/>}
|
|
192
|
+
</SwitchProvider>;
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
),
|
|
196
|
+
{
|
|
197
|
+
Thumb: SwitchThumb
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
const BubbleInput = (props) => {
|
|
201
|
+
const { control, checked, bubbles = true, ...inputProps } = props;
|
|
202
|
+
const ref = React.useRef(null);
|
|
203
|
+
const prevChecked = usePrevious(checked);
|
|
204
|
+
React.useEffect(() => {
|
|
205
|
+
const input = ref.current;
|
|
206
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
207
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
208
|
+
inputProto,
|
|
209
|
+
"checked"
|
|
210
|
+
);
|
|
211
|
+
const setChecked = descriptor.set;
|
|
212
|
+
if (prevChecked !== checked && setChecked) {
|
|
213
|
+
const event = new Event("click", { bubbles });
|
|
214
|
+
setChecked.call(input, checked);
|
|
215
|
+
input.dispatchEvent(event);
|
|
216
|
+
}
|
|
217
|
+
}, [prevChecked, checked, bubbles]);
|
|
218
|
+
return <input
|
|
219
|
+
type="checkbox"
|
|
220
|
+
aria-hidden
|
|
221
|
+
defaultChecked={checked}
|
|
222
|
+
{...inputProps}
|
|
223
|
+
tabIndex={-1}
|
|
224
|
+
ref={ref}
|
|
225
|
+
style={{
|
|
226
|
+
...props.style,
|
|
227
|
+
// ...controlSize,
|
|
228
|
+
position: "absolute",
|
|
229
|
+
pointerEvents: "none",
|
|
230
|
+
opacity: 0,
|
|
231
|
+
margin: 0
|
|
232
|
+
}}
|
|
233
|
+
/>;
|
|
234
|
+
};
|
|
235
|
+
function getState(checked) {
|
|
236
|
+
return checked ? "checked" : "unchecked";
|
|
237
|
+
}
|
|
238
|
+
export {
|
|
239
|
+
Switch,
|
|
240
|
+
SwitchFrame,
|
|
241
|
+
SwitchThumb,
|
|
242
|
+
SwitchThumbFrame,
|
|
243
|
+
createSwitchScope
|
|
244
|
+
};
|
|
2
245
|
//# sourceMappingURL=Switch.js.map
|
package/dist/jsx/Switch.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Switch.tsx"],
|
|
4
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 unstyled?: boolean\n}>(SWITCH_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * SwitchThumb\n * -----------------------------------------------------------------------------------------------*/\n\nconst THUMB_NAME = 'SwitchThumb'\n\nexport const SwitchThumbFrame = styled(ThemeableStack, {\n name: 'SwitchThumb',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n backgroundColor: '$background',\n borderRadius: 1000,\n },\n },\n\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 unstyled: false,\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, size: sizeProp, ...thumbProps } = props\n const {\n size: sizeContext,\n disabled,\n checked,\n unstyled,\n } = useSwitchContext(THUMB_NAME, __scopeSwitch)\n const size = sizeProp ?? sizeContext\n return (\n <SwitchThumbFrame\n unstyled={unstyled}\n size={size}\n theme={checked ? 'active' : null}\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_NAME,\n tag: 'button',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n borderRadius: 1000,\n borderWidth: 2,\n borderColor: 'transparent',\n backgroundColor: '$background',\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n },\n },\n\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 unstyled: false,\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 unstyled = false,\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 unstyled={unstyled}\n >\n <SwitchFrame\n unstyled={unstyled}\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": "AAGA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAGA,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,o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