@tamagui/switch 1.67.0 → 1.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Switch.js +3 -9
- package/dist/cjs/Switch.js.map +1 -1
- package/dist/cjs/Switch.native.js +3 -9
- package/dist/cjs/Switch.native.js.map +1 -1
- package/dist/cjs/SwitchContext.js +32 -0
- package/dist/cjs/SwitchContext.js.map +6 -0
- package/dist/cjs/SwitchContext.native.js +33 -0
- package/dist/cjs/SwitchContext.native.js.map +6 -0
- package/dist/cjs/createSwitch.js +36 -24
- package/dist/cjs/createSwitch.js.map +2 -2
- package/dist/cjs/createSwitch.native.js +36 -24
- package/dist/cjs/createSwitch.native.js.map +2 -2
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +14 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Switch.js +1 -6
- package/dist/esm/Switch.js.map +1 -1
- package/dist/esm/SwitchContext.js +12 -0
- package/dist/esm/SwitchContext.js.map +6 -0
- package/dist/esm/createSwitch.js +36 -22
- package/dist/esm/createSwitch.js.map +2 -2
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/Switch.js +1 -6
- package/dist/jsx/Switch.js.map +1 -1
- package/dist/jsx/Switch.native.js +1 -6
- package/dist/jsx/Switch.native.js.map +1 -1
- package/dist/jsx/SwitchContext.js +12 -0
- package/dist/jsx/SwitchContext.js.map +6 -0
- package/dist/jsx/SwitchContext.native.js +12 -0
- package/dist/jsx/SwitchContext.native.js.map +6 -0
- package/dist/jsx/createSwitch.js +35 -22
- package/dist/jsx/createSwitch.js.map +2 -2
- package/dist/jsx/createSwitch.native.js +35 -22
- package/dist/jsx/createSwitch.native.js.map +2 -2
- package/dist/jsx/index.js +10 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.native.js +10 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +11 -11
- package/src/Switch.tsx +1 -7
- package/src/SwitchContext.tsx +15 -0
- package/src/createSwitch.tsx +80 -34
- package/src/index.ts +9 -0
- package/types/Switch.d.ts +0 -21
- package/types/Switch.d.ts.map +1 -1
- package/types/SwitchContext.d.ts +9 -0
- package/types/SwitchContext.d.ts.map +1 -0
- package/types/createSwitch.d.ts +12 -13
- package/types/createSwitch.d.ts.map +1 -1
- package/types/index.d.ts +24 -0
- package/types/index.d.ts.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;",
|
|
4
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,aAAa,mBAAmB;AAEzC,cAAc;AACd,cAAc;AAEP,MAAM,SAAS,aAAa;AAAA,EACjC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,iBAAiB;AACnB,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/switch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/compose-refs": "1.
|
|
35
|
-
"@tamagui/core": "1.
|
|
36
|
-
"@tamagui/create-context": "1.
|
|
37
|
-
"@tamagui/focusable": "1.
|
|
38
|
-
"@tamagui/get-token": "1.
|
|
39
|
-
"@tamagui/label": "1.
|
|
40
|
-
"@tamagui/stacks": "1.
|
|
41
|
-
"@tamagui/use-controllable-state": "1.
|
|
42
|
-
"@tamagui/use-previous": "1.
|
|
34
|
+
"@tamagui/compose-refs": "1.68.1",
|
|
35
|
+
"@tamagui/core": "1.68.1",
|
|
36
|
+
"@tamagui/create-context": "1.68.1",
|
|
37
|
+
"@tamagui/focusable": "1.68.1",
|
|
38
|
+
"@tamagui/get-token": "1.68.1",
|
|
39
|
+
"@tamagui/label": "1.68.1",
|
|
40
|
+
"@tamagui/stacks": "1.68.1",
|
|
41
|
+
"@tamagui/use-controllable-state": "1.68.1",
|
|
42
|
+
"@tamagui/use-previous": "1.68.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "*",
|
|
46
46
|
"react-native": "*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@tamagui/build": "1.
|
|
49
|
+
"@tamagui/build": "1.68.1",
|
|
50
50
|
"react": "^18.2.0",
|
|
51
51
|
"react-native": "^0.72.1"
|
|
52
52
|
},
|
package/src/Switch.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { SizeTokens, getVariableValue, styled } from '@tamagui/core'
|
|
|
2
2
|
import { getSize } from '@tamagui/get-token'
|
|
3
3
|
import { ThemeableStack, YStack } from '@tamagui/stacks'
|
|
4
4
|
|
|
5
|
-
import { SwitchContext
|
|
5
|
+
import { SwitchContext } from './SwitchContext'
|
|
6
6
|
|
|
7
7
|
export const SwitchThumb = styled(ThemeableStack, {
|
|
8
8
|
name: 'SwitchThumb',
|
|
@@ -86,9 +86,3 @@ export const SwitchFrame = styled(YStack, {
|
|
|
86
86
|
unstyled: false,
|
|
87
87
|
},
|
|
88
88
|
})
|
|
89
|
-
|
|
90
|
-
export const Switch = createSwitch({
|
|
91
|
-
Frame: SwitchFrame,
|
|
92
|
-
Thumb: SwitchThumb,
|
|
93
|
-
acceptsUnstyled: true,
|
|
94
|
-
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SizeTokens, createStyledContext } from '@tamagui/core'
|
|
2
|
+
|
|
3
|
+
export const SwitchContext = createStyledContext<{
|
|
4
|
+
checked: boolean
|
|
5
|
+
disabled?: boolean
|
|
6
|
+
frameWidth: number
|
|
7
|
+
size?: SizeTokens
|
|
8
|
+
unstyled?: boolean
|
|
9
|
+
}>({
|
|
10
|
+
checked: false,
|
|
11
|
+
disabled: false,
|
|
12
|
+
size: undefined,
|
|
13
|
+
frameWidth: 0,
|
|
14
|
+
unstyled: false,
|
|
15
|
+
})
|
package/src/createSwitch.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
TamaguiComponentExpectingVariants,
|
|
7
7
|
TamaguiElement,
|
|
8
8
|
composeEventHandlers,
|
|
9
|
-
createStyledContext,
|
|
10
9
|
getVariableValue,
|
|
11
10
|
isWeb,
|
|
12
11
|
useProps,
|
|
@@ -24,19 +23,8 @@ import {
|
|
|
24
23
|
Platform,
|
|
25
24
|
} from 'react-native'
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
disabled?: boolean
|
|
30
|
-
frameWidth: number
|
|
31
|
-
size?: SizeTokens
|
|
32
|
-
unstyled?: boolean
|
|
33
|
-
}>({
|
|
34
|
-
checked: false,
|
|
35
|
-
disabled: false,
|
|
36
|
-
size: undefined,
|
|
37
|
-
frameWidth: 0,
|
|
38
|
-
unstyled: false,
|
|
39
|
-
})
|
|
26
|
+
import { SwitchFrame, SwitchThumb } from './Switch'
|
|
27
|
+
import { SwitchContext } from './SwitchContext'
|
|
40
28
|
|
|
41
29
|
type SwitchSharedProps = {
|
|
42
30
|
size?: SizeTokens | number
|
|
@@ -57,29 +45,73 @@ export type SwitchExtraProps = {
|
|
|
57
45
|
onCheckedChange?(checked: boolean): void
|
|
58
46
|
}
|
|
59
47
|
|
|
60
|
-
export type SwitchProps = SwitchBaseProps & SwitchExtraProps
|
|
48
|
+
export type SwitchProps = Omit<SwitchBaseProps & SwitchExtraProps, 'children'> & {
|
|
49
|
+
children?: JSX.Element | ((checked: boolean) => JSX.Element)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type SwitchComponent = TamaguiComponentExpectingVariants<
|
|
53
|
+
SwitchProps,
|
|
54
|
+
SwitchSharedProps & SwitchExtraProps
|
|
55
|
+
>
|
|
56
|
+
|
|
57
|
+
type SwitchThumbComponent = TamaguiComponentExpectingVariants<
|
|
58
|
+
SwitchBaseProps,
|
|
59
|
+
SwitchSharedProps
|
|
60
|
+
>
|
|
61
|
+
|
|
62
|
+
export function createSwitch<F extends SwitchComponent, T extends SwitchThumbComponent>({
|
|
63
|
+
Frame = SwitchFrame as any,
|
|
64
|
+
Thumb = SwitchThumb as any,
|
|
65
|
+
acceptsUnstyled,
|
|
66
|
+
}: {
|
|
67
|
+
Frame?: F
|
|
68
|
+
Thumb?: T
|
|
69
|
+
acceptsUnstyled?: boolean
|
|
70
|
+
}) {
|
|
71
|
+
if (process.env.NODE_ENV === 'development') {
|
|
72
|
+
if (Frame !== SwitchFrame && Frame.staticConfig.context) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden.`
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
if (Thumb !== SwitchThumb && Thumb.staticConfig.context) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden.`
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Frame.staticConfig.context = SwitchContext
|
|
85
|
+
Thumb.staticConfig.context = SwitchContext
|
|
61
86
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
const SwitchThumbComponent = Thumb.styleable(function SwitchThumb(props, forwardedRef) {
|
|
88
|
+
const { size: sizeProp, unstyled: unstyledProp, ...thumbProps } = props
|
|
89
|
+
const context = React.useContext(SwitchContext)
|
|
90
|
+
const {
|
|
91
|
+
disabled,
|
|
92
|
+
checked,
|
|
93
|
+
unstyled: unstyledContext,
|
|
94
|
+
frameWidth,
|
|
95
|
+
size: sizeContext,
|
|
96
|
+
} = context
|
|
72
97
|
const [thumbWidth, setThumbWidth] = React.useState(0)
|
|
73
98
|
const initialChecked = React.useRef(checked).current
|
|
74
99
|
const distance = frameWidth - thumbWidth
|
|
100
|
+
const x = initialChecked ? (checked ? 0 : -distance) : checked ? distance : 0
|
|
101
|
+
const unstyled = unstyledProp ?? unstyledContext ?? false
|
|
102
|
+
|
|
75
103
|
return (
|
|
76
104
|
// @ts-ignore
|
|
77
105
|
<Thumb
|
|
78
|
-
|
|
106
|
+
{...(unstyled === false && {
|
|
107
|
+
unstyled: false,
|
|
108
|
+
size: sizeProp ?? sizeContext ?? '$true',
|
|
109
|
+
theme: checked ? 'active' : null,
|
|
110
|
+
})}
|
|
79
111
|
data-state={getState(checked)}
|
|
80
112
|
data-disabled={disabled ? '' : undefined}
|
|
81
113
|
alignSelf={initialChecked ? 'flex-end' : 'flex-start'}
|
|
82
|
-
x={
|
|
114
|
+
x={x}
|
|
83
115
|
{...thumbProps}
|
|
84
116
|
// @ts-ignore
|
|
85
117
|
onLayout={composeEventHandlers(props.onLayout, (e) =>
|
|
@@ -111,6 +143,7 @@ export function createSwitch<
|
|
|
111
143
|
unstyled = styledContext.unstyled ?? false,
|
|
112
144
|
native: nativeProp,
|
|
113
145
|
nativeProps,
|
|
146
|
+
children,
|
|
114
147
|
...switchProps
|
|
115
148
|
} = props
|
|
116
149
|
|
|
@@ -121,13 +154,21 @@ export function createSwitch<
|
|
|
121
154
|
_ = switchProps[key]
|
|
122
155
|
}
|
|
123
156
|
}
|
|
124
|
-
if (
|
|
157
|
+
if (
|
|
158
|
+
Frame === SwitchFrame &&
|
|
159
|
+
acceptsUnstyled &&
|
|
160
|
+
_ == undefined &&
|
|
161
|
+
unstyled === false
|
|
162
|
+
) {
|
|
125
163
|
_ = 2 // default we use for styled
|
|
126
164
|
}
|
|
127
165
|
if (typeof _ === 'string') {
|
|
128
166
|
_ = getVariableValue(getSize(_))
|
|
129
167
|
}
|
|
130
|
-
|
|
168
|
+
if (typeof _ === 'number') {
|
|
169
|
+
return _
|
|
170
|
+
}
|
|
171
|
+
return 0
|
|
131
172
|
})()
|
|
132
173
|
|
|
133
174
|
const native = Array.isArray(nativeProp) ? nativeProp : [nativeProp]
|
|
@@ -214,12 +255,17 @@ export function createSwitch<
|
|
|
214
255
|
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation()
|
|
215
256
|
}
|
|
216
257
|
})}
|
|
217
|
-
|
|
218
|
-
onLayout={composeEventHandlers(props.onLayout, (e) =>
|
|
258
|
+
onLayout={composeEventHandlers(
|
|
219
259
|
// @ts-ignore
|
|
220
|
-
|
|
260
|
+
props.onLayout,
|
|
261
|
+
(e) => {
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
setFrameWidth(e.nativeEvent.layout.width)
|
|
264
|
+
}
|
|
221
265
|
)}
|
|
222
|
-
|
|
266
|
+
>
|
|
267
|
+
{typeof children === 'function' ? children(checked) : children}
|
|
268
|
+
</Frame>
|
|
223
269
|
{isWeb && isFormControl && (
|
|
224
270
|
<BubbleInput
|
|
225
271
|
control={button}
|
|
@@ -299,7 +345,7 @@ export function createSwitch<
|
|
|
299
345
|
}
|
|
300
346
|
|
|
301
347
|
const Switch = withStaticProperties(SwitchComponent, {
|
|
302
|
-
Thumb:
|
|
348
|
+
Thumb: SwitchThumbComponent,
|
|
303
349
|
})
|
|
304
350
|
|
|
305
351
|
return Switch
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import { createSwitch } from './createSwitch'
|
|
2
|
+
import { SwitchFrame, SwitchThumb } from './Switch'
|
|
3
|
+
|
|
1
4
|
export * from './Switch'
|
|
2
5
|
export * from './createSwitch'
|
|
6
|
+
|
|
7
|
+
export const Switch = createSwitch({
|
|
8
|
+
Frame: SwitchFrame,
|
|
9
|
+
Thumb: SwitchThumb,
|
|
10
|
+
acceptsUnstyled: true,
|
|
11
|
+
})
|
package/types/Switch.d.ts
CHANGED
|
@@ -159,25 +159,4 @@ export declare const SwitchFrame: import("@tamagui/core").TamaguiComponent<Omit<
|
|
|
159
159
|
readonly elevation?: SizeTokens | undefined;
|
|
160
160
|
};
|
|
161
161
|
}>;
|
|
162
|
-
export declare const Switch: import("react").ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers) | "style"> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & {
|
|
163
|
-
style?: import("@tamagui/core").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
164
|
-
} & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>> & import("@tamagui/core").MediaProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>>> & {
|
|
165
|
-
size?: number | SizeTokens | undefined;
|
|
166
|
-
unstyled?: boolean | undefined;
|
|
167
|
-
} & import("./createSwitch").SwitchExtraProps & import("react").RefAttributes<import("@tamagui/core").TamaguiElement>> & {
|
|
168
|
-
Thumb: import("@tamagui/core").ReactComponentWithRef<Object & Omit<Omit<import("react-native").ViewProps, "display" | "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers) | "style"> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & {
|
|
169
|
-
style?: import("@tamagui/core").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
170
|
-
} & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>> & import("@tamagui/core").MediaProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>>> & {
|
|
171
|
-
size?: number | SizeTokens | undefined;
|
|
172
|
-
unstyled?: boolean | undefined;
|
|
173
|
-
}, keyof Object>, any> & {
|
|
174
|
-
staticConfig: import("@tamagui/core").StaticConfig;
|
|
175
|
-
styleable: import("@tamagui/core").Styleable<Omit<import("react-native").ViewProps, "display" | "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers) | "style"> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & {
|
|
176
|
-
style?: import("@tamagui/core").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
177
|
-
} & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>> & import("@tamagui/core").MediaProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>>> & {
|
|
178
|
-
size?: number | SizeTokens | undefined;
|
|
179
|
-
unstyled?: boolean | undefined;
|
|
180
|
-
}, any>;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
162
|
//# sourceMappingURL=Switch.d.ts.map
|
package/types/Switch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA4B,MAAM,eAAe,CAAA;AAMpE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BtB,CAAA;AAOF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CtB,CAAA
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA4B,MAAM,eAAe,CAAA;AAMpE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BtB,CAAA;AAOF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CtB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SizeTokens } from '@tamagui/core';
|
|
2
|
+
export declare const SwitchContext: import("@tamagui/core").StyledContext<{
|
|
3
|
+
checked: boolean;
|
|
4
|
+
disabled?: boolean | undefined;
|
|
5
|
+
frameWidth: number;
|
|
6
|
+
size?: SizeTokens | undefined;
|
|
7
|
+
unstyled?: boolean | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=SwitchContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchContext.d.ts","sourceRoot":"","sources":["../src/SwitchContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,eAAe,CAAA;AAE/D,eAAO,MAAM,aAAa;aACf,OAAO;;gBAEJ,MAAM;;;EASlB,CAAA"}
|
package/types/createSwitch.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { NativeValue, SizeTokens, StackProps, TamaguiComponentExpectingVariants, TamaguiElement } from '@tamagui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { SwitchProps as NativeSwitchProps } from 'react-native';
|
|
4
|
-
export declare const SwitchContext: import("@tamagui/core").StyledContext<{
|
|
5
|
-
checked: boolean;
|
|
6
|
-
disabled?: boolean | undefined;
|
|
7
|
-
frameWidth: number;
|
|
8
|
-
size?: SizeTokens | undefined;
|
|
9
|
-
unstyled?: boolean | undefined;
|
|
10
|
-
}>;
|
|
11
4
|
type SwitchSharedProps = {
|
|
12
5
|
size?: SizeTokens | number;
|
|
13
6
|
unstyled?: boolean;
|
|
@@ -24,14 +17,20 @@ export type SwitchExtraProps = {
|
|
|
24
17
|
nativeProps?: NativeSwitchProps;
|
|
25
18
|
onCheckedChange?(checked: boolean): void;
|
|
26
19
|
};
|
|
27
|
-
export type SwitchProps = SwitchBaseProps & SwitchExtraProps
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
export type SwitchProps = Omit<SwitchBaseProps & SwitchExtraProps, 'children'> & {
|
|
21
|
+
children?: JSX.Element | ((checked: boolean) => JSX.Element);
|
|
22
|
+
};
|
|
23
|
+
type SwitchComponent = TamaguiComponentExpectingVariants<SwitchProps, SwitchSharedProps & SwitchExtraProps>;
|
|
24
|
+
type SwitchThumbComponent = TamaguiComponentExpectingVariants<SwitchBaseProps, SwitchSharedProps>;
|
|
25
|
+
export declare function createSwitch<F extends SwitchComponent, T extends SwitchThumbComponent>({ Frame, Thumb, acceptsUnstyled, }: {
|
|
26
|
+
Frame?: F;
|
|
27
|
+
Thumb?: T;
|
|
31
28
|
acceptsUnstyled?: boolean;
|
|
32
|
-
}): React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)
|
|
29
|
+
}): React.ForwardRefExoticComponent<Omit<Omit<import("react-native").ViewProps, "display" | "children" | "style" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & {
|
|
33
30
|
style?: import("@tamagui/core").StyleProp<import("react-native").ViewStyle | React.CSSProperties | (React.CSSProperties & import("react-native").ViewStyle)>;
|
|
34
|
-
} & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>> & import("@tamagui/core").MediaProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>>> & SwitchSharedProps & SwitchExtraProps
|
|
31
|
+
} & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>> & import("@tamagui/core").MediaProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core").PseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>>>> & SwitchSharedProps & SwitchExtraProps, "children"> & {
|
|
32
|
+
children?: JSX.Element | ((checked: boolean) => JSX.Element) | undefined;
|
|
33
|
+
} & React.RefAttributes<TamaguiElement>> & {
|
|
35
34
|
Thumb: import("@tamagui/core").ReactComponentWithRef<Object & Omit<SwitchBaseProps, keyof Object>, any> & {
|
|
36
35
|
staticConfig: import("@tamagui/core").StaticConfig;
|
|
37
36
|
styleable: import("@tamagui/core").Styleable<SwitchBaseProps, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSwitch.d.ts","sourceRoot":"","sources":["../src/createSwitch.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,EACV,iCAAiC,EACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"createSwitch.d.ts","sourceRoot":"","sources":["../src/createSwitch.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,EACV,iCAAiC,EACjC,cAAc,EAMf,MAAM,eAAe,CAAA;AAMtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAEL,WAAW,IAAI,iBAAiB,EAEjC,MAAM,cAAc,CAAA;AAKrB,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,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,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,eAAe,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,GAAG,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAC/E,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,CAAA;CAC7D,CAAA;AAED,KAAK,eAAe,GAAG,iCAAiC,CACtD,WAAW,EACX,iBAAiB,GAAG,gBAAgB,CACrC,CAAA;AAED,KAAK,oBAAoB,GAAG,iCAAiC,CAC3D,eAAe,EACf,iBAAiB,CAClB,CAAA;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,eAAe,EAAE,CAAC,SAAS,oBAAoB,EAAE,EACtF,KAA0B,EAC1B,KAA0B,EAC1B,eAAe,GAChB,EAAE;IACD,KAAK,CAAC,EAAE,CAAC,CAAA;IACT,KAAK,CAAC,EAAE,CAAC,CAAA;IACT,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;;;;;;;;;EA0RA"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export * from './Switch';
|
|
2
3
|
export * from './createSwitch';
|
|
4
|
+
export declare const Switch: import("react").ForwardRefExoticComponent<Omit<Omit<import("react-native").ViewProps, "display" | "children" | "style" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & {
|
|
5
|
+
style?: import("@tamagui/web").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
6
|
+
} & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>> & import("@tamagui/web").MediaProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>>> & {
|
|
7
|
+
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
8
|
+
unstyled?: boolean | undefined;
|
|
9
|
+
} & import("./createSwitch").SwitchExtraProps, "children"> & {
|
|
10
|
+
children?: JSX.Element | ((checked: boolean) => JSX.Element) | undefined;
|
|
11
|
+
} & import("react").RefAttributes<import("@tamagui/web").TamaguiElement>> & {
|
|
12
|
+
Thumb: import("@tamagui/web").ReactComponentWithRef<Object & Omit<Omit<import("react-native").ViewProps, "display" | "children" | "style" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & {
|
|
13
|
+
style?: import("@tamagui/web").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
14
|
+
} & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>> & import("@tamagui/web").MediaProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>>> & {
|
|
15
|
+
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
16
|
+
unstyled?: boolean | undefined;
|
|
17
|
+
}, keyof Object>, any> & {
|
|
18
|
+
staticConfig: import("@tamagui/web").StaticConfig;
|
|
19
|
+
styleable: import("@tamagui/web").Styleable<Omit<import("react-native").ViewProps, "display" | "children" | "style" | ("onLayout" | keyof import("react-native").GestureResponderHandlers)> & import("@tamagui/web").ExtendBaseStackProps & import("@tamagui/web").TamaguiComponentPropsBase & {
|
|
20
|
+
style?: import("@tamagui/web").StyleProp<import("react-native").ViewStyle | import("react").CSSProperties | (import("react").CSSProperties & import("react-native").ViewStyle)>;
|
|
21
|
+
} & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>> & import("@tamagui/web").MediaProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>> & import("@tamagui/web").PseudoProps<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStylePropsBase>>>> & {
|
|
22
|
+
size?: number | import("@tamagui/web").SizeTokens | undefined;
|
|
23
|
+
unstyled?: boolean | undefined;
|
|
24
|
+
}, any>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
3
27
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAE9B,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;CAIjB,CAAA"}
|