@tamagui/switch 1.0.1-beta.103
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/Card.js +144 -0
- package/dist/cjs/Card.js.map +7 -0
- package/dist/cjs/Switch.js +262 -0
- package/dist/cjs/Switch.js.map +7 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/Card.js +119 -0
- package/dist/esm/Card.js.map +7 -0
- package/dist/esm/Switch.js +241 -0
- package/dist/esm/Switch.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/jsx/Card.js +87 -0
- package/dist/jsx/Card.js.map +7 -0
- package/dist/jsx/Switch.js +159 -0
- package/dist/jsx/Switch.js.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +7 -0
- package/package.json +48 -0
- package/src/Switch.tsx +293 -0
- package/src/index.ts +1 -0
- package/types/Switch.d.ts +246 -0
- package/types/Switch.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
package/src/Switch.tsx
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// via radix
|
|
2
|
+
// https://github.com/radix-ui/primitives/blob/main/packages/react/switch/src/Switch.tsx
|
|
3
|
+
|
|
4
|
+
import { usePrevious } from '@radix-ui/react-use-previous'
|
|
5
|
+
import { useComposedRefs } from '@tamagui/compose-refs'
|
|
6
|
+
import {
|
|
7
|
+
GetProps,
|
|
8
|
+
SizeTokens,
|
|
9
|
+
Theme,
|
|
10
|
+
calc,
|
|
11
|
+
getSize,
|
|
12
|
+
getVariableValue,
|
|
13
|
+
isWeb,
|
|
14
|
+
styled,
|
|
15
|
+
themeable,
|
|
16
|
+
useTheme,
|
|
17
|
+
useThemeName,
|
|
18
|
+
withStaticProperties,
|
|
19
|
+
} from '@tamagui/core'
|
|
20
|
+
import { ScopedProps, createContextScope } from '@tamagui/create-context'
|
|
21
|
+
import { registerFocusable } from '@tamagui/focusable'
|
|
22
|
+
import { useLabelContext } from '@tamagui/label'
|
|
23
|
+
import { ThemeableStack, XStack } from '@tamagui/stacks'
|
|
24
|
+
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
25
|
+
import * as React from 'react'
|
|
26
|
+
import { View } from 'react-native'
|
|
27
|
+
|
|
28
|
+
const SWITCH_NAME = 'Switch'
|
|
29
|
+
|
|
30
|
+
// TODO make customizable
|
|
31
|
+
const getSwitchHeight = (val: SizeTokens) => Math.round(getVariableValue(getSize(val)) * 0.65)
|
|
32
|
+
const getSwitchWidth = (val: SizeTokens) => getSwitchHeight(val) * 2
|
|
33
|
+
|
|
34
|
+
const scopeContexts = createContextScope(SWITCH_NAME)
|
|
35
|
+
const [createSwitchContext] = scopeContexts
|
|
36
|
+
export const createSwitchScope = scopeContexts[1]
|
|
37
|
+
|
|
38
|
+
const [SwitchProvider, useSwitchContext] = createSwitchContext<{
|
|
39
|
+
checked: boolean
|
|
40
|
+
disabled?: boolean
|
|
41
|
+
size: SizeTokens
|
|
42
|
+
}>(SWITCH_NAME)
|
|
43
|
+
|
|
44
|
+
/* -------------------------------------------------------------------------------------------------
|
|
45
|
+
* SwitchThumb
|
|
46
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
47
|
+
|
|
48
|
+
const THUMB_NAME = 'SwitchThumb'
|
|
49
|
+
|
|
50
|
+
export const SwitchThumbFrame = styled(ThemeableStack, {
|
|
51
|
+
name: 'SwitchThumb',
|
|
52
|
+
backgroundColor: '$background',
|
|
53
|
+
borderRadius: 1000,
|
|
54
|
+
|
|
55
|
+
variants: {
|
|
56
|
+
size: {
|
|
57
|
+
'...size': (val) => ({
|
|
58
|
+
height: getSwitchHeight(val),
|
|
59
|
+
width: getSwitchHeight(val),
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
size: '$4',
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
export type SwitchThumbProps = GetProps<typeof SwitchThumbFrame>
|
|
70
|
+
|
|
71
|
+
export const SwitchThumb = SwitchThumbFrame.extractable(
|
|
72
|
+
React.forwardRef<React.ElementRef<'span'>, SwitchThumbProps>(
|
|
73
|
+
(props: ScopedProps<SwitchThumbProps, 'Switch'>, forwardedRef) => {
|
|
74
|
+
const { __scopeSwitch, ...thumbProps } = props
|
|
75
|
+
const { size, disabled, checked } = useSwitchContext(THUMB_NAME, __scopeSwitch)
|
|
76
|
+
return (
|
|
77
|
+
<SwitchThumbFrame
|
|
78
|
+
size={size}
|
|
79
|
+
data-state={getState(checked)}
|
|
80
|
+
data-disabled={disabled ? '' : undefined}
|
|
81
|
+
{...thumbProps}
|
|
82
|
+
x={
|
|
83
|
+
checked
|
|
84
|
+
? getVariableValue(getSwitchWidth(size)) - getVariableValue(getSwitchHeight(size))
|
|
85
|
+
: 0
|
|
86
|
+
}
|
|
87
|
+
ref={forwardedRef}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
SwitchThumb.displayName = THUMB_NAME
|
|
95
|
+
|
|
96
|
+
/* -------------------------------------------------------------------------------------------------
|
|
97
|
+
* Switch
|
|
98
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
99
|
+
|
|
100
|
+
export const SwitchFrame = styled(XStack, {
|
|
101
|
+
name: 'Switch',
|
|
102
|
+
tag: 'button',
|
|
103
|
+
borderRadius: 1000,
|
|
104
|
+
borderWidth: 2,
|
|
105
|
+
borderColor: 'transparent',
|
|
106
|
+
backgroundColor: '$background',
|
|
107
|
+
|
|
108
|
+
focusStyle: {
|
|
109
|
+
borderColor: '$borderColorFocus',
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
variants: {
|
|
113
|
+
size: {
|
|
114
|
+
'...size': (val) => {
|
|
115
|
+
const height = calc(getSwitchHeight(val), '+', 4)
|
|
116
|
+
const width = calc(getSwitchWidth(val), '+', 4)
|
|
117
|
+
return {
|
|
118
|
+
height,
|
|
119
|
+
minHeight: height,
|
|
120
|
+
width,
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
defaultVariants: {
|
|
127
|
+
size: '$4',
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
type SwitchButtonProps = GetProps<typeof SwitchFrame>
|
|
132
|
+
|
|
133
|
+
export type SwitchProps = SwitchButtonProps & {
|
|
134
|
+
labeledBy?: string
|
|
135
|
+
name?: string
|
|
136
|
+
value?: string
|
|
137
|
+
checked?: boolean
|
|
138
|
+
defaultChecked?: boolean
|
|
139
|
+
required?: boolean
|
|
140
|
+
onCheckedChange?(checked: boolean): void
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const Switch = withStaticProperties(
|
|
144
|
+
SwitchFrame.extractable(
|
|
145
|
+
React.forwardRef<HTMLButtonElement | View, SwitchProps>(
|
|
146
|
+
(props: ScopedProps<SwitchProps, 'Switch'>, forwardedRef) => {
|
|
147
|
+
const {
|
|
148
|
+
__scopeSwitch,
|
|
149
|
+
labeledBy: ariaLabelledby,
|
|
150
|
+
name,
|
|
151
|
+
checked: checkedProp,
|
|
152
|
+
defaultChecked,
|
|
153
|
+
required,
|
|
154
|
+
disabled,
|
|
155
|
+
value = 'on',
|
|
156
|
+
onCheckedChange,
|
|
157
|
+
size = '$4',
|
|
158
|
+
...switchProps
|
|
159
|
+
} = props
|
|
160
|
+
const [button, setButton] = React.useState<HTMLButtonElement | null>(null)
|
|
161
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node as any))
|
|
162
|
+
const labelId = useLabelContext(button)
|
|
163
|
+
const labelledBy = ariaLabelledby || labelId
|
|
164
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false)
|
|
165
|
+
// We set this to true by default so that events bubble to forms without JS (SSR)
|
|
166
|
+
const isFormControl = isWeb ? (button ? Boolean(button.closest('form')) : true) : false
|
|
167
|
+
const [checked = false, setChecked] = useControllableState({
|
|
168
|
+
prop: checkedProp,
|
|
169
|
+
defaultProp: defaultChecked || false,
|
|
170
|
+
onChange: onCheckedChange,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
if (!isWeb) {
|
|
174
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
175
|
+
React.useEffect(() => {
|
|
176
|
+
if (!props.id) return
|
|
177
|
+
return registerFocusable(props.id, {
|
|
178
|
+
focus: () => {
|
|
179
|
+
setChecked((x) => !x)
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
}, [props.id, setChecked])
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<SwitchProvider scope={__scopeSwitch} checked={checked} disabled={disabled} size={size}>
|
|
187
|
+
<SwitchFrame
|
|
188
|
+
size={size}
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
role="switch"
|
|
191
|
+
aria-checked={checked}
|
|
192
|
+
aria-labelledby={labelledBy}
|
|
193
|
+
aria-required={required}
|
|
194
|
+
data-state={getState(checked)}
|
|
195
|
+
data-disabled={disabled ? '' : undefined}
|
|
196
|
+
disabled={disabled}
|
|
197
|
+
theme={checked ? 'active' : null}
|
|
198
|
+
themeShallow
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
tabIndex={disabled ? undefined : 0}
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
value={value}
|
|
203
|
+
{...switchProps}
|
|
204
|
+
ref={composedRefs}
|
|
205
|
+
onPress={(event) => {
|
|
206
|
+
props.onPress?.(event)
|
|
207
|
+
setChecked((prevChecked) => !prevChecked)
|
|
208
|
+
if (isWeb && isFormControl) {
|
|
209
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped()
|
|
210
|
+
// if switch is in a form, stop propagation from the button so that we only propagate
|
|
211
|
+
// one click event (from the input). We propagate changes from an input so that native
|
|
212
|
+
// form validation works and form events reflect switch updates.
|
|
213
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation()
|
|
214
|
+
}
|
|
215
|
+
}}
|
|
216
|
+
/>
|
|
217
|
+
{isWeb && isFormControl && (
|
|
218
|
+
<BubbleInput
|
|
219
|
+
control={button}
|
|
220
|
+
bubbles={!hasConsumerStoppedPropagationRef.current}
|
|
221
|
+
name={name}
|
|
222
|
+
value={value}
|
|
223
|
+
checked={checked}
|
|
224
|
+
required={required}
|
|
225
|
+
disabled={disabled}
|
|
226
|
+
// We transform because the input is absolutely positioned but we have
|
|
227
|
+
// rendered it **after** the button. This pulls it back to sit on top
|
|
228
|
+
// of the button.
|
|
229
|
+
style={{ transform: 'translateX(-100%)' }}
|
|
230
|
+
/>
|
|
231
|
+
)}
|
|
232
|
+
</SwitchProvider>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
),
|
|
237
|
+
{
|
|
238
|
+
Thumb: SwitchThumb,
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
/* ---------------------------------------------------------------------------------------------- */
|
|
243
|
+
|
|
244
|
+
type InputProps = any //Radix.ComponentPropsWithoutRef<'input'>
|
|
245
|
+
interface BubbleInputProps extends Omit<InputProps, 'checked'> {
|
|
246
|
+
checked: boolean
|
|
247
|
+
control: HTMLElement | null
|
|
248
|
+
bubbles: boolean
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// TODO make this native friendly
|
|
252
|
+
const BubbleInput = (props: BubbleInputProps) => {
|
|
253
|
+
const { control, checked, bubbles = true, ...inputProps } = props
|
|
254
|
+
const ref = React.useRef<HTMLInputElement>(null)
|
|
255
|
+
const prevChecked = usePrevious(checked)
|
|
256
|
+
// const controlSize = useSize(control)
|
|
257
|
+
|
|
258
|
+
// Bubble checked change to parents (e.g form change event)
|
|
259
|
+
React.useEffect(() => {
|
|
260
|
+
const input = ref.current!
|
|
261
|
+
const inputProto = window.HTMLInputElement.prototype
|
|
262
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor
|
|
263
|
+
const setChecked = descriptor.set
|
|
264
|
+
if (prevChecked !== checked && setChecked) {
|
|
265
|
+
const event = new Event('click', { bubbles })
|
|
266
|
+
setChecked.call(input, checked)
|
|
267
|
+
input.dispatchEvent(event)
|
|
268
|
+
}
|
|
269
|
+
}, [prevChecked, checked, bubbles])
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<input
|
|
273
|
+
type="checkbox"
|
|
274
|
+
aria-hidden
|
|
275
|
+
defaultChecked={checked}
|
|
276
|
+
{...inputProps}
|
|
277
|
+
tabIndex={-1}
|
|
278
|
+
ref={ref}
|
|
279
|
+
style={{
|
|
280
|
+
...props.style,
|
|
281
|
+
// ...controlSize,
|
|
282
|
+
position: 'absolute',
|
|
283
|
+
pointerEvents: 'none',
|
|
284
|
+
opacity: 0,
|
|
285
|
+
margin: 0,
|
|
286
|
+
}}
|
|
287
|
+
/>
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function getState(checked: boolean) {
|
|
292
|
+
return checked ? 'checked' : 'unchecked'
|
|
293
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Switch'
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { GetProps, SizeTokens } from '@tamagui/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
export declare const createSwitchScope: import("@tamagui/create-context").CreateScope;
|
|
5
|
+
export declare const SwitchThumbFrame: import("@tamagui/core").TamaguiComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
6
|
+
readonly fullscreen?: boolean | undefined;
|
|
7
|
+
readonly elevation?: SizeTokens | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
fontFamily?: unknown;
|
|
10
|
+
backgrounded?: boolean | undefined;
|
|
11
|
+
radiused?: boolean | undefined;
|
|
12
|
+
hoverTheme?: boolean | undefined;
|
|
13
|
+
pressTheme?: boolean | undefined;
|
|
14
|
+
focusTheme?: boolean | undefined;
|
|
15
|
+
circular?: boolean | undefined;
|
|
16
|
+
padded?: boolean | undefined;
|
|
17
|
+
elevate?: boolean | undefined;
|
|
18
|
+
bordered?: number | boolean | undefined;
|
|
19
|
+
transparent?: boolean | undefined;
|
|
20
|
+
chromeless?: boolean | undefined;
|
|
21
|
+
}, "size"> & {
|
|
22
|
+
size?: SizeTokens | undefined;
|
|
23
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
24
|
+
readonly fullscreen?: boolean | undefined;
|
|
25
|
+
readonly elevation?: SizeTokens | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
fontFamily?: unknown;
|
|
28
|
+
backgrounded?: boolean | undefined;
|
|
29
|
+
radiused?: boolean | undefined;
|
|
30
|
+
hoverTheme?: boolean | undefined;
|
|
31
|
+
pressTheme?: boolean | undefined;
|
|
32
|
+
focusTheme?: boolean | undefined;
|
|
33
|
+
circular?: boolean | undefined;
|
|
34
|
+
padded?: boolean | undefined;
|
|
35
|
+
elevate?: boolean | undefined;
|
|
36
|
+
bordered?: number | boolean | undefined;
|
|
37
|
+
transparent?: boolean | undefined;
|
|
38
|
+
chromeless?: boolean | undefined;
|
|
39
|
+
}, "size"> & {
|
|
40
|
+
size?: SizeTokens | undefined;
|
|
41
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
42
|
+
readonly fullscreen?: boolean | undefined;
|
|
43
|
+
readonly elevation?: SizeTokens | undefined;
|
|
44
|
+
} & {
|
|
45
|
+
fontFamily?: unknown;
|
|
46
|
+
backgrounded?: boolean | undefined;
|
|
47
|
+
radiused?: boolean | undefined;
|
|
48
|
+
hoverTheme?: boolean | undefined;
|
|
49
|
+
pressTheme?: boolean | undefined;
|
|
50
|
+
focusTheme?: boolean | undefined;
|
|
51
|
+
circular?: boolean | undefined;
|
|
52
|
+
padded?: boolean | undefined;
|
|
53
|
+
elevate?: boolean | undefined;
|
|
54
|
+
bordered?: number | boolean | undefined;
|
|
55
|
+
transparent?: boolean | undefined;
|
|
56
|
+
chromeless?: boolean | undefined;
|
|
57
|
+
}, "size"> & {
|
|
58
|
+
size?: SizeTokens | undefined;
|
|
59
|
+
}>>, any, import("@tamagui/core").StackPropsBase, {
|
|
60
|
+
readonly fullscreen?: boolean | undefined;
|
|
61
|
+
readonly elevation?: SizeTokens | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
fontFamily?: unknown;
|
|
64
|
+
backgrounded?: boolean | undefined;
|
|
65
|
+
radiused?: boolean | undefined;
|
|
66
|
+
hoverTheme?: boolean | undefined;
|
|
67
|
+
pressTheme?: boolean | undefined;
|
|
68
|
+
focusTheme?: boolean | undefined;
|
|
69
|
+
circular?: boolean | undefined;
|
|
70
|
+
padded?: boolean | undefined;
|
|
71
|
+
elevate?: boolean | undefined;
|
|
72
|
+
bordered?: number | boolean | undefined;
|
|
73
|
+
transparent?: boolean | undefined;
|
|
74
|
+
chromeless?: boolean | undefined;
|
|
75
|
+
} & {
|
|
76
|
+
size?: SizeTokens | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export declare type SwitchThumbProps = GetProps<typeof SwitchThumbFrame>;
|
|
79
|
+
export declare const SwitchThumb: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
80
|
+
readonly fullscreen?: boolean | undefined;
|
|
81
|
+
readonly elevation?: SizeTokens | undefined;
|
|
82
|
+
} & {
|
|
83
|
+
fontFamily?: unknown;
|
|
84
|
+
backgrounded?: boolean | undefined;
|
|
85
|
+
radiused?: boolean | undefined;
|
|
86
|
+
hoverTheme?: boolean | undefined;
|
|
87
|
+
pressTheme?: boolean | undefined;
|
|
88
|
+
focusTheme?: boolean | undefined;
|
|
89
|
+
circular?: boolean | undefined;
|
|
90
|
+
padded?: boolean | undefined;
|
|
91
|
+
elevate?: boolean | undefined;
|
|
92
|
+
bordered?: number | boolean | undefined;
|
|
93
|
+
transparent?: boolean | undefined;
|
|
94
|
+
chromeless?: boolean | undefined;
|
|
95
|
+
}, "size"> & {
|
|
96
|
+
size?: SizeTokens | undefined;
|
|
97
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
98
|
+
readonly fullscreen?: boolean | undefined;
|
|
99
|
+
readonly elevation?: SizeTokens | undefined;
|
|
100
|
+
} & {
|
|
101
|
+
fontFamily?: unknown;
|
|
102
|
+
backgrounded?: boolean | undefined;
|
|
103
|
+
radiused?: boolean | undefined;
|
|
104
|
+
hoverTheme?: boolean | undefined;
|
|
105
|
+
pressTheme?: boolean | undefined;
|
|
106
|
+
focusTheme?: boolean | undefined;
|
|
107
|
+
circular?: boolean | undefined;
|
|
108
|
+
padded?: boolean | undefined;
|
|
109
|
+
elevate?: boolean | undefined;
|
|
110
|
+
bordered?: number | boolean | undefined;
|
|
111
|
+
transparent?: boolean | undefined;
|
|
112
|
+
chromeless?: boolean | undefined;
|
|
113
|
+
}, "size"> & {
|
|
114
|
+
size?: SizeTokens | undefined;
|
|
115
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
116
|
+
readonly fullscreen?: boolean | undefined;
|
|
117
|
+
readonly elevation?: SizeTokens | undefined;
|
|
118
|
+
} & {
|
|
119
|
+
fontFamily?: unknown;
|
|
120
|
+
backgrounded?: boolean | undefined;
|
|
121
|
+
radiused?: boolean | undefined;
|
|
122
|
+
hoverTheme?: boolean | undefined;
|
|
123
|
+
pressTheme?: boolean | undefined;
|
|
124
|
+
focusTheme?: boolean | undefined;
|
|
125
|
+
circular?: boolean | undefined;
|
|
126
|
+
padded?: boolean | undefined;
|
|
127
|
+
elevate?: boolean | undefined;
|
|
128
|
+
bordered?: number | boolean | undefined;
|
|
129
|
+
transparent?: boolean | undefined;
|
|
130
|
+
chromeless?: boolean | undefined;
|
|
131
|
+
}, "size"> & {
|
|
132
|
+
size?: SizeTokens | undefined;
|
|
133
|
+
}>> & React.RefAttributes<HTMLSpanElement>>;
|
|
134
|
+
export declare const SwitchFrame: import("@tamagui/core").TamaguiComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
135
|
+
readonly fullscreen?: boolean | undefined;
|
|
136
|
+
readonly elevation?: SizeTokens | undefined;
|
|
137
|
+
}, "size"> & {
|
|
138
|
+
size?: SizeTokens | undefined;
|
|
139
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
140
|
+
readonly fullscreen?: boolean | undefined;
|
|
141
|
+
readonly elevation?: SizeTokens | undefined;
|
|
142
|
+
}, "size"> & {
|
|
143
|
+
size?: SizeTokens | undefined;
|
|
144
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
145
|
+
readonly fullscreen?: boolean | undefined;
|
|
146
|
+
readonly elevation?: SizeTokens | undefined;
|
|
147
|
+
}, "size"> & {
|
|
148
|
+
size?: SizeTokens | undefined;
|
|
149
|
+
}>>, any, import("@tamagui/core").StackPropsBase, {
|
|
150
|
+
readonly fullscreen?: boolean | undefined;
|
|
151
|
+
readonly elevation?: SizeTokens | undefined;
|
|
152
|
+
} & {
|
|
153
|
+
size?: SizeTokens | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
declare type SwitchButtonProps = GetProps<typeof SwitchFrame>;
|
|
156
|
+
export declare type SwitchProps = SwitchButtonProps & {
|
|
157
|
+
labeledBy?: string;
|
|
158
|
+
name?: string;
|
|
159
|
+
value?: string;
|
|
160
|
+
checked?: boolean;
|
|
161
|
+
defaultChecked?: boolean;
|
|
162
|
+
required?: boolean;
|
|
163
|
+
onCheckedChange?(checked: boolean): void;
|
|
164
|
+
};
|
|
165
|
+
export declare const Switch: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
166
|
+
readonly fullscreen?: boolean | undefined;
|
|
167
|
+
readonly elevation?: SizeTokens | undefined;
|
|
168
|
+
}, "size"> & {
|
|
169
|
+
size?: SizeTokens | undefined;
|
|
170
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
171
|
+
readonly fullscreen?: boolean | undefined;
|
|
172
|
+
readonly elevation?: SizeTokens | undefined;
|
|
173
|
+
}, "size"> & {
|
|
174
|
+
size?: SizeTokens | undefined;
|
|
175
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
176
|
+
readonly fullscreen?: boolean | undefined;
|
|
177
|
+
readonly elevation?: SizeTokens | undefined;
|
|
178
|
+
}, "size"> & {
|
|
179
|
+
size?: SizeTokens | undefined;
|
|
180
|
+
}>> & {
|
|
181
|
+
labeledBy?: string | undefined;
|
|
182
|
+
name?: string | undefined;
|
|
183
|
+
value?: string | undefined;
|
|
184
|
+
checked?: boolean | undefined;
|
|
185
|
+
defaultChecked?: boolean | undefined;
|
|
186
|
+
required?: boolean | undefined;
|
|
187
|
+
onCheckedChange?(checked: boolean): void;
|
|
188
|
+
} & React.RefAttributes<View | HTMLButtonElement>> & {
|
|
189
|
+
Thumb: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
190
|
+
readonly fullscreen?: boolean | undefined;
|
|
191
|
+
readonly elevation?: SizeTokens | undefined;
|
|
192
|
+
} & {
|
|
193
|
+
fontFamily?: unknown;
|
|
194
|
+
backgrounded?: boolean | undefined;
|
|
195
|
+
radiused?: boolean | undefined;
|
|
196
|
+
hoverTheme?: boolean | undefined;
|
|
197
|
+
pressTheme?: boolean | undefined;
|
|
198
|
+
focusTheme?: boolean | undefined;
|
|
199
|
+
circular?: boolean | undefined;
|
|
200
|
+
padded?: boolean | undefined;
|
|
201
|
+
elevate?: boolean | undefined;
|
|
202
|
+
bordered?: number | boolean | undefined;
|
|
203
|
+
transparent?: boolean | undefined;
|
|
204
|
+
chromeless?: boolean | undefined;
|
|
205
|
+
}, "size"> & {
|
|
206
|
+
size?: SizeTokens | undefined;
|
|
207
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
208
|
+
readonly fullscreen?: boolean | undefined;
|
|
209
|
+
readonly elevation?: SizeTokens | undefined;
|
|
210
|
+
} & {
|
|
211
|
+
fontFamily?: unknown;
|
|
212
|
+
backgrounded?: boolean | undefined;
|
|
213
|
+
radiused?: boolean | undefined;
|
|
214
|
+
hoverTheme?: boolean | undefined;
|
|
215
|
+
pressTheme?: boolean | undefined;
|
|
216
|
+
focusTheme?: boolean | undefined;
|
|
217
|
+
circular?: boolean | undefined;
|
|
218
|
+
padded?: boolean | undefined;
|
|
219
|
+
elevate?: boolean | undefined;
|
|
220
|
+
bordered?: number | boolean | undefined;
|
|
221
|
+
transparent?: boolean | undefined;
|
|
222
|
+
chromeless?: boolean | undefined;
|
|
223
|
+
}, "size"> & {
|
|
224
|
+
size?: SizeTokens | undefined;
|
|
225
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
226
|
+
readonly fullscreen?: boolean | undefined;
|
|
227
|
+
readonly elevation?: SizeTokens | undefined;
|
|
228
|
+
} & {
|
|
229
|
+
fontFamily?: unknown;
|
|
230
|
+
backgrounded?: boolean | undefined;
|
|
231
|
+
radiused?: boolean | undefined;
|
|
232
|
+
hoverTheme?: boolean | undefined;
|
|
233
|
+
pressTheme?: boolean | undefined;
|
|
234
|
+
focusTheme?: boolean | undefined;
|
|
235
|
+
circular?: boolean | undefined;
|
|
236
|
+
padded?: boolean | undefined;
|
|
237
|
+
elevate?: boolean | undefined;
|
|
238
|
+
bordered?: number | boolean | undefined;
|
|
239
|
+
transparent?: boolean | undefined;
|
|
240
|
+
chromeless?: boolean | undefined;
|
|
241
|
+
}, "size"> & {
|
|
242
|
+
size?: SizeTokens | undefined;
|
|
243
|
+
}>> & React.RefAttributes<HTMLSpanElement>>;
|
|
244
|
+
};
|
|
245
|
+
export {};
|
|
246
|
+
//# sourceMappingURL=Switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EACR,UAAU,EAWX,MAAM,eAAe,CAAA;AAMtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAUnC,eAAO,MAAM,iBAAiB,+CAAmB,CAAA;AAcjD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiB3B,CAAA;AAEF,oBAAY,gBAAgB,GAAG,QAAQ,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEhE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAqBvB,CAAA;AAQD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;EA6BtB,CAAA;AAEF,aAAK,iBAAiB,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD,oBAAY,WAAW,GAAG,iBAAiB,GAAG;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;8BAHS,OAAO,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGzC,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|