@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.
@@ -1,2 +1,245 @@
1
- import{usePrevious as $}from"@radix-ui/react-use-previous";import{useComposedRefs as W}from"@tamagui/compose-refs";import{getVariableValue as P,isWeb as m,styled as z,withStaticProperties as q}from"@tamagui/core";import{createContextScope as G}from"@tamagui/create-context";import{registerFocusable as N}from"@tamagui/focusable";import{getSize as O}from"@tamagui/get-size";import{useLabelContext as A}from"@tamagui/label";import{ThemeableStack as D,XStack as X}from"@tamagui/stacks";import{useControllableState as j}from"@tamagui/use-controllable-state";import*as i from"react";const y="Switch",S=e=>Math.round(P(O(e))*.65),T=e=>S(e)*2,x=G(y),[U]=x,he=x[1],[J,K]=U(y),v="SwitchThumb",B=z(D,{name:"SwitchThumb",variants:{unstyled:{false:{size:"$true",backgroundColor:"$background",borderRadius:1e3}},size:{"...size":e=>{const o=S(e);return{height:o,width:o}}}},defaultVariants:{unstyled:!1}}),E=B.extractable(i.forwardRef((e,o)=>{const{__scopeSwitch:t,size:a,...u}=e,{size:l,disabled:d,checked:r,unstyled:s}=K(v,t),n=a??l;return<B unstyled={s}size={n}theme={r?"active":null}data-state={I(r)}data-disabled={d?"":void 0}{...u}x={r?P(T(n))-P(S(n)):0}ref={o}/>}));E.displayName=v;const R=z(X,{name:y,tag:"button",variants:{unstyled:{false:{size:"$true",borderRadius:1e3,borderWidth:2,borderColor:"transparent",backgroundColor:"$background",focusStyle:{borderColor:"$borderColorFocus"}}},size:{"...size":e=>{const o=S(e)+4,t=T(e)+4;return{height:o,minHeight:o,width:t}}}},defaultVariants:{unstyled:!1}}),pe=q(R.extractable(i.forwardRef((e,o)=>{const{__scopeSwitch:t,labeledBy:a,name:u,checked:l,defaultChecked:d,required:r,disabled:s,value:n="on",onCheckedChange:p,size:b="$true",unstyled:g=!1,...H}=e,[f,M]=i.useState(null),F=W(o,c=>M(c)),L=A(f),V=a||L,w=i.useRef(!1),C=m?f?Boolean(f.closest("form")):!0:!1,[h=!1,k]=j({prop:l,defaultProp:d||!1,onChange:p,transition:!0});return m||i.useEffect(()=>{if(e.id)return N(e.id,{focus:()=>{k(c=>!c)}})},[e.id,k]),<J scope={t}checked={h}disabled={s}size={b}unstyled={g}><R unstyled={g}size={b}role="switch"aria-checked={h}aria-labelledby={V}aria-required={r}data-state={I(h)}data-disabled={s?"":void 0}disabled={s}theme={h?"active":null}themeShallow tabIndex={s?void 0:0}value={n}{...H}ref={F}onPress={c=>{e.onPress?.(c),k(_=>!_),m&&C&&(w.current=c.isPropagationStopped(),w.current||c.stopPropagation())}}/>{m&&C&&<Q control={f}bubbles={!w.current}name={u}value={n}checked={h}required={r}disabled={s}style={{transform:"translateX(-100%)"}}/>}</J>})),{Thumb:E}),Q=e=>{const{control:o,checked:t,bubbles:a=!0,...u}=e,l=i.useRef(null),d=$(t);return i.useEffect(()=>{const r=l.current,s=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(s,"checked").set;if(d!==t&&p){const b=new Event("click",{bubbles:a});p.call(r,t),r.dispatchEvent(b)}},[d,t,a]),<input type="checkbox"aria-hidden defaultChecked={t}{...u}tabIndex={-1}ref={l}style={{...e.style,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}/>};function I(e){return e?"checked":"unchecked"}export{pe as Switch,R as SwitchFrame,E as SwitchThumb,B as SwitchThumbFrame,he as createSwitchScope};
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.mjs.map
@@ -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,OAAS,eAAAA,MAAmB,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F,EAC8B,IAC9B,GAAIP,IAAgB1B,GAAWuB,EAAY,CACzC,MAAME,EAAQ,IAAI,MAAM,QAAS,CAAE,QAAAI,CAAQ,CAAC,EAC5CN,EAAW,KAAKS,EAAOhC,CAAO,EAC9BgC,EAAM,cAAcP,CAAK,CAC3B,CACF,EAAG,CAACC,EAAa1B,EAAS6B,CAAO,CAAC,EAGhC,CAAC,MACC,KAAK,UACL,YACA,gBAAgB7B,MACZ8B,EACJ,UAAU,GACV,KAAKC,EACL,OAAO,CACL,GAAGtC,EAAM,MAET,SAAU,WACV,cAAe,OACf,QAAS,EACT,OAAQ,CACV,EACF,EAEJ,EAEA,SAASS,EAASF,EAAkB,CAClC,OAAOA,EAAU,UAAY,WAC/B",
6
- "names": ["usePrevious", "useComposedRefs", "getVariableValue", "isWeb", "styled", "withStaticProperties", "createContextScope", "registerFocusable", "getSize", "useLabelContext", "ThemeableStack", "XStack", "useControllableState", "React", "SWITCH_NAME", "getSwitchHeight", "val", "getSwitchWidth", "scopeContexts", "createSwitchContext", "createSwitchScope", "SwitchProvider", "useSwitchContext", "THUMB_NAME", "SwitchThumbFrame", "size", "SwitchThumb", "props", "forwardedRef", "__scopeSwitch", "sizeProp", "thumbProps", "sizeContext", "disabled", "checked", "unstyled", "getState", "SwitchFrame", "height", "width", "Switch", "ariaLabelledby", "name", "checkedProp", "defaultChecked", "required", "value", "onCheckedChange", "switchProps", "button", "setButton", "composedRefs", "node", "labelId", "labelledBy", "hasConsumerStoppedPropagationRef", "isFormControl", "setChecked", "x", "event", "prevChecked", "BubbleInput", "control", "bubbles", "inputProps", "ref", "input", "inputProto"]
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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AAO;AAAA,YACP,SAAS;AAAA,YACT,UAAU;AAAA,YACV,UAAU;AAAA,YAIV,OAAO,EAAE,WAAW,oBAAoB;AAAA,UAC1C;AAAA,QAEJ,EArDC;AAAA,MAuDL;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
7
  }
package/dist/jsx/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export*from"./Switch";
1
+ export * from "./Switch";
2
2
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './Switch'\n"],
5
- "mappings": "AAAA,WAAc",
5
+ "mappings": "AAAA,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- export*from"./Switch";
1
+ export * from "./Switch";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export * from './Switch'\n"],
5
- "mappings": "AAAA,WAAc",
5
+ "mappings": "AAAA,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/switch",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -32,21 +32,21 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@radix-ui/react-use-previous": "^0.1.1",
35
- "@tamagui/compose-refs": "1.14.0",
36
- "@tamagui/core": "1.14.0",
37
- "@tamagui/create-context": "1.14.0",
38
- "@tamagui/focusable": "1.14.0",
39
- "@tamagui/get-size": "1.14.0",
40
- "@tamagui/label": "1.14.0",
41
- "@tamagui/stacks": "1.14.0",
42
- "@tamagui/use-controllable-state": "1.14.0"
35
+ "@tamagui/compose-refs": "1.14.2",
36
+ "@tamagui/core": "1.14.2",
37
+ "@tamagui/create-context": "1.14.2",
38
+ "@tamagui/focusable": "1.14.2",
39
+ "@tamagui/get-size": "1.14.2",
40
+ "@tamagui/label": "1.14.2",
41
+ "@tamagui/stacks": "1.14.2",
42
+ "@tamagui/use-controllable-state": "1.14.2"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "*",
46
46
  "react-native": "*"
47
47
  },
48
48
  "devDependencies": {
49
- "@tamagui/build": "1.14.0",
49
+ "@tamagui/build": "1.14.2",
50
50
  "react": "^18.2.0",
51
51
  "react-native": "^0.71.4"
52
52
  },