@tamagui/switch 2.0.0-rc.4 → 2.0.0-rc.40
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/StyledContext.cjs +14 -12
- package/dist/cjs/StyledContext.native.js +20 -18
- package/dist/cjs/StyledContext.native.js.map +1 -1
- package/dist/cjs/Switch.cjs +76 -74
- package/dist/cjs/Switch.native.js +81 -80
- package/dist/cjs/Switch.native.js.map +1 -1
- package/dist/cjs/createSwitch.cjs +156 -144
- package/dist/cjs/createSwitch.native.js +161 -153
- package/dist/cjs/createSwitch.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -13
- package/dist/cjs/index.native.js +20 -18
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useSwitchNative.cjs +12 -10
- package/dist/cjs/useSwitchNative.native.js +40 -33
- package/dist/cjs/useSwitchNative.native.js.map +1 -1
- package/dist/esm/StyledContext.mjs +2 -2
- package/dist/esm/StyledContext.native.js +2 -2
- package/dist/esm/Switch.mjs +61 -61
- package/dist/esm/Switch.mjs.map +1 -1
- package/dist/esm/Switch.native.js +65 -66
- package/dist/esm/Switch.native.js.map +1 -1
- package/dist/esm/createSwitch.mjs +124 -114
- package/dist/esm/createSwitch.mjs.map +1 -1
- package/dist/esm/createSwitch.native.js +129 -123
- package/dist/esm/createSwitch.native.js.map +1 -1
- package/dist/esm/index.js +8 -11
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useSwitchNative.native.js +11 -6
- package/dist/esm/useSwitchNative.native.js.map +1 -1
- package/dist/jsx/StyledContext.mjs +2 -2
- package/dist/jsx/StyledContext.native.js +20 -18
- package/dist/jsx/StyledContext.native.js.map +1 -1
- package/dist/jsx/Switch.mjs +61 -61
- package/dist/jsx/Switch.mjs.map +1 -1
- package/dist/jsx/Switch.native.js +81 -80
- package/dist/jsx/Switch.native.js.map +1 -1
- package/dist/jsx/createSwitch.mjs +124 -114
- package/dist/jsx/createSwitch.mjs.map +1 -1
- package/dist/jsx/createSwitch.native.js +161 -153
- package/dist/jsx/createSwitch.native.js.map +1 -1
- package/dist/jsx/index.js +8 -11
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +20 -18
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.native.js +7 -5
- package/dist/jsx/useSwitchNative.native.js +40 -33
- package/dist/jsx/useSwitchNative.native.js.map +1 -1
- package/package.json +17 -20
- package/types/createSwitch.d.ts +4 -4
- package/types/index.d.ts +4 -4
- package/dist/cjs/StyledContext.js +0 -28
- package/dist/cjs/StyledContext.js.map +0 -6
- package/dist/cjs/Switch.js +0 -93
- package/dist/cjs/Switch.js.map +0 -6
- package/dist/cjs/createSwitch.js +0 -146
- package/dist/cjs/createSwitch.js.map +0 -6
- package/dist/cjs/index.js +0 -31
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useSwitchNative.js +0 -23
- package/dist/cjs/useSwitchNative.js.map +0 -6
- package/dist/esm/StyledContext.js +0 -12
- package/dist/esm/StyledContext.js.map +0 -6
- package/dist/esm/Switch.js +0 -79
- package/dist/esm/Switch.js.map +0 -6
- package/dist/esm/createSwitch.js +0 -135
- package/dist/esm/createSwitch.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useSwitchNative.js +0 -7
- package/dist/esm/useSwitchNative.js.map +0 -6
- package/dist/jsx/StyledContext.js +0 -12
- package/dist/jsx/StyledContext.js.map +0 -6
- package/dist/jsx/Switch.js +0 -79
- package/dist/jsx/Switch.js.map +0 -6
- package/dist/jsx/createSwitch.js +0 -135
- package/dist/jsx/createSwitch.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
- package/dist/jsx/useSwitchNative.js +0 -7
- package/dist/jsx/useSwitchNative.js.map +0 -6
|
@@ -11,127 +11,137 @@ function createSwitch(createProps) {
|
|
|
11
11
|
Frame = DefaultSwitchFrame,
|
|
12
12
|
Thumb = SwitchThumb
|
|
13
13
|
} = createProps;
|
|
14
|
-
process.env.NODE_ENV === "development"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
if (process.env.NODE_ENV === "development") {
|
|
15
|
+
if (Frame !== DefaultSwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== SwitchStyledContext || Thumb !== SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== SwitchStyledContext) {
|
|
16
|
+
console.warn(`Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Frame.staticConfig.context = SwitchStyledContext;
|
|
20
|
+
Thumb.staticConfig.context = SwitchStyledContext;
|
|
21
|
+
const SwitchThumbComponent = Thumb.styleable(function SwitchThumb2(props, forwardedRef) {
|
|
22
|
+
const {
|
|
23
|
+
size: sizeProp,
|
|
24
|
+
unstyled: unstyledProp,
|
|
25
|
+
activeStyle,
|
|
26
|
+
...thumbProps
|
|
27
|
+
} = props;
|
|
28
|
+
const styledContext = SwitchStyledContext.useStyledContext();
|
|
29
|
+
const {
|
|
30
|
+
unstyled: unstyledContext,
|
|
31
|
+
size: sizeContext,
|
|
32
|
+
active,
|
|
33
|
+
disabled,
|
|
34
|
+
frameWidth = 0
|
|
35
|
+
} = styledContext;
|
|
36
|
+
const unstyled = process.env.TAMAGUI_HEADLESS === "1" ? true : unstyledProp ?? unstyledContext ?? false;
|
|
37
|
+
const size = sizeProp ?? sizeContext ?? "$true";
|
|
38
|
+
const initialChecked = React.useRef(active).current;
|
|
39
|
+
const initialWidth = getVariableValue(props.width || size, "size");
|
|
40
|
+
const [thumbWidth, setThumbWidth] = React.useState(typeof initialWidth === "number" ? initialWidth : 0);
|
|
41
|
+
const distance = frameWidth - thumbWidth;
|
|
42
|
+
const x = initialChecked ? active ? 0 : -distance : active ? distance : 0;
|
|
43
|
+
return /* @__PURE__ */jsx(Thumb, {
|
|
44
|
+
ref: forwardedRef,
|
|
45
|
+
unstyled,
|
|
46
|
+
...(unstyled === false && {
|
|
47
|
+
size
|
|
48
|
+
}),
|
|
49
|
+
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
50
|
+
x,
|
|
51
|
+
onLayout: composeEventHandlers(props.onLayout, e => {
|
|
52
|
+
const next = e.nativeEvent.layout.width;
|
|
53
|
+
setThumbWidth(next);
|
|
54
|
+
}),
|
|
55
|
+
disabled,
|
|
56
|
+
...thumbProps,
|
|
57
|
+
...(active && activeStyle)
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
const SwitchComponent = Frame.styleable(function SwitchFrame(_props, forwardedRef) {
|
|
61
|
+
const {
|
|
62
|
+
native,
|
|
63
|
+
nativeProps,
|
|
64
|
+
checked: checkedProp,
|
|
65
|
+
defaultChecked,
|
|
66
|
+
onCheckedChange,
|
|
67
|
+
activeStyle,
|
|
68
|
+
unstyled: unstyledProp,
|
|
69
|
+
activeTheme: activeThemeProp,
|
|
70
|
+
...props
|
|
71
|
+
} = _props;
|
|
72
|
+
const [checked, setChecked] = useControllableState({
|
|
73
|
+
prop: checkedProp,
|
|
74
|
+
defaultProp: defaultChecked || false,
|
|
75
|
+
onChange: onCheckedChange,
|
|
76
|
+
transition: true
|
|
77
|
+
});
|
|
78
|
+
const styledContext = React.useContext(SwitchStyledContext.context);
|
|
79
|
+
const [frameWidth, setFrameInnerWidth] = React.useState(0);
|
|
80
|
+
const {
|
|
81
|
+
switchProps,
|
|
82
|
+
bubbleInput,
|
|
83
|
+
switchRef
|
|
84
|
+
} = useSwitch(props, [checked, setChecked],
|
|
85
|
+
// @ts-ignore TODO tamagui react 19 type error
|
|
86
|
+
forwardedRef);
|
|
87
|
+
const nativeSwitch = useSwitchNative({
|
|
88
|
+
id: props.id,
|
|
89
|
+
disabled: props.disabled,
|
|
90
|
+
native,
|
|
91
|
+
nativeProps,
|
|
92
|
+
checked,
|
|
93
|
+
setChecked
|
|
94
|
+
});
|
|
95
|
+
if (nativeSwitch) {
|
|
96
|
+
return nativeSwitch;
|
|
97
|
+
}
|
|
98
|
+
const disabled = props.disabled;
|
|
99
|
+
const handleLayout = e => {
|
|
100
|
+
const next = e.nativeEvent.layout.width;
|
|
101
|
+
if (next !== frameWidth) {
|
|
102
|
+
setFrameInnerWidth(next);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const unstyled = styledContext.unstyled ?? unstyledProp ?? false;
|
|
106
|
+
return /* @__PURE__ */jsxs(Fragment, {
|
|
107
|
+
children: [/* @__PURE__ */jsx(SwitchStyledContext.Provider, {
|
|
108
|
+
size: styledContext.size ?? props.size ?? "$true",
|
|
39
109
|
unstyled,
|
|
40
|
-
|
|
41
|
-
size
|
|
42
|
-
}),
|
|
43
|
-
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
44
|
-
x,
|
|
45
|
-
onLayout: composeEventHandlers(props.onLayout, e => {
|
|
46
|
-
const next = e.nativeEvent.layout.width;
|
|
47
|
-
setThumbWidth(next);
|
|
48
|
-
}),
|
|
110
|
+
active: checked,
|
|
49
111
|
disabled,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
activeStyle,
|
|
62
|
-
unstyled: unstyledProp,
|
|
63
|
-
activeTheme: activeThemeProp,
|
|
64
|
-
...props
|
|
65
|
-
} = _props,
|
|
66
|
-
[checked, setChecked] = useControllableState({
|
|
67
|
-
prop: checkedProp,
|
|
68
|
-
defaultProp: defaultChecked || !1,
|
|
69
|
-
onChange: onCheckedChange,
|
|
70
|
-
transition: !0
|
|
71
|
-
}),
|
|
72
|
-
styledContext = React.useContext(SwitchStyledContext.context),
|
|
73
|
-
[frameWidth, setFrameInnerWidth] = React.useState(0),
|
|
74
|
-
{
|
|
75
|
-
switchProps,
|
|
76
|
-
bubbleInput,
|
|
77
|
-
switchRef
|
|
78
|
-
} = useSwitch(props, [checked, setChecked],
|
|
79
|
-
// @ts-ignore TODO tamagui react 19 type error
|
|
80
|
-
forwardedRef),
|
|
81
|
-
nativeSwitch = useSwitchNative({
|
|
82
|
-
id: props.id,
|
|
83
|
-
disabled: props.disabled,
|
|
84
|
-
native,
|
|
85
|
-
nativeProps,
|
|
86
|
-
checked,
|
|
87
|
-
setChecked
|
|
88
|
-
});
|
|
89
|
-
if (nativeSwitch) return nativeSwitch;
|
|
90
|
-
const disabled = props.disabled,
|
|
91
|
-
handleLayout = e => {
|
|
92
|
-
const next = e.nativeEvent.layout.width;
|
|
93
|
-
next !== frameWidth && setFrameInnerWidth(next);
|
|
94
|
-
},
|
|
95
|
-
unstyled = styledContext.unstyled ?? unstyledProp ?? !1;
|
|
96
|
-
return /* @__PURE__ */jsxs(Fragment, {
|
|
97
|
-
children: [/* @__PURE__ */jsx(SwitchStyledContext.Provider, {
|
|
98
|
-
size: styledContext.size ?? props.size ?? "$true",
|
|
112
|
+
frameWidth,
|
|
113
|
+
children: /* @__PURE__ */jsx(Frame, {
|
|
114
|
+
ref: switchRef,
|
|
115
|
+
render: "button",
|
|
116
|
+
theme: activeThemeProp ?? null,
|
|
117
|
+
...(isWeb && {
|
|
118
|
+
type: "button"
|
|
119
|
+
}),
|
|
120
|
+
...(!unstyled && {
|
|
121
|
+
size: styledContext.size ?? props.size ?? "$true"
|
|
122
|
+
}),
|
|
99
123
|
unstyled,
|
|
100
|
-
|
|
124
|
+
...props,
|
|
125
|
+
...switchProps,
|
|
101
126
|
disabled,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
render: "button",
|
|
106
|
-
theme: activeThemeProp ?? null,
|
|
107
|
-
...(isWeb && {
|
|
108
|
-
type: "button"
|
|
109
|
-
}),
|
|
110
|
-
...(!unstyled && {
|
|
111
|
-
size: styledContext.size ?? props.size ?? "$true"
|
|
127
|
+
...(checked && {
|
|
128
|
+
...(!unstyled && !activeStyle && {
|
|
129
|
+
backgroundColor: "$backgroundActive"
|
|
112
130
|
}),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}),
|
|
121
|
-
...activeStyle
|
|
122
|
-
}),
|
|
123
|
-
children: /* @__PURE__ */jsx(View, {
|
|
124
|
-
alignSelf: "stretch",
|
|
125
|
-
flex: 1,
|
|
126
|
-
onLayout: handleLayout,
|
|
127
|
-
children: props.children
|
|
128
|
-
})
|
|
131
|
+
...activeStyle
|
|
132
|
+
}),
|
|
133
|
+
children: /* @__PURE__ */jsx(View, {
|
|
134
|
+
alignSelf: "stretch",
|
|
135
|
+
flex: 1,
|
|
136
|
+
onLayout: handleLayout,
|
|
137
|
+
children: props.children
|
|
129
138
|
})
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
}, {
|
|
133
|
-
disableTheme: !0
|
|
139
|
+
})
|
|
140
|
+
}), bubbleInput]
|
|
134
141
|
});
|
|
142
|
+
}, {
|
|
143
|
+
disableTheme: true
|
|
144
|
+
});
|
|
135
145
|
return withStaticProperties(SwitchComponent, {
|
|
136
146
|
Thumb: SwitchThumbComponent
|
|
137
147
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["composeEventHandlers","getVariableValue","isWeb","View","withStaticProperties","useSwitch","useControllableState","React","SwitchStyledContext","SwitchFrame","DefaultSwitchFrame","SwitchThumb","useSwitchNative","Fragment","jsx","jsxs","createSwitch","createProps","Frame","Thumb","process","env","NODE_ENV","staticConfig","context","console","warn","SwitchThumbComponent","styleable","props","forwardedRef","size","sizeProp","unstyled","unstyledProp","activeStyle","thumbProps","styledContext","useStyledContext","unstyledContext","sizeContext","active","disabled","frameWidth","TAMAGUI_HEADLESS","initialChecked","useRef","current","initialWidth","width","thumbWidth","setThumbWidth","useState","distance","x","ref","alignSelf","onLayout","e","next","nativeEvent","layout","SwitchComponent","_props","native","nativeProps","checked","checkedProp","defaultChecked","onCheckedChange","activeTheme","activeThemeProp","setChecked","prop","defaultProp","onChange","transition","useContext","setFrameInnerWidth","switchProps","bubbleInput","switchRef","nativeSwitch","id","handleLayout","children","Provider","render","theme","type","backgroundColor","flex","disableTheme"],"sources":["../../src/createSwitch.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,oBAAA,EACAC,gBAAA,EACAC,KAAA,EACAC,IAAA,EACAC,oBAAA,QACK;AACP,SAASC,SAAA,QAAiB;AAC1B,SAASC,oBAAA,QAA4B;AACrC,YAAYC,KAAA,MAAW;AAEvB,SAASC,mBAAA,QAA2B;AACpC,SAASC,WAAA,IAAeC,kBAAA,EAAoBC,WAAA,QAAmB;AAQ/D,SAASC,eAAA,QAAuB;AAwDxB,SA6EAC,QAAA,EA7EAC,GAAA,EA6EAC,IAAA,QA7EA;AApDD,SAASC,aAGdC,WAAA,EAAuC;EACvC,MAAM;IAAEC,KAAA,GAAQR,kBAAA;IAAoBS,KAAA,GAAQR;EAAY,IAAIM,WAAA;
|
|
1
|
+
{"version":3,"names":["composeEventHandlers","getVariableValue","isWeb","View","withStaticProperties","useSwitch","useControllableState","React","SwitchStyledContext","SwitchFrame","DefaultSwitchFrame","SwitchThumb","useSwitchNative","Fragment","jsx","jsxs","createSwitch","createProps","Frame","Thumb","process","env","NODE_ENV","staticConfig","context","console","warn","SwitchThumbComponent","styleable","SwitchThumb2","props","forwardedRef","size","sizeProp","unstyled","unstyledProp","activeStyle","thumbProps","styledContext","useStyledContext","unstyledContext","sizeContext","active","disabled","frameWidth","TAMAGUI_HEADLESS","initialChecked","useRef","current","initialWidth","width","thumbWidth","setThumbWidth","useState","distance","x","ref","alignSelf","onLayout","e","next","nativeEvent","layout","SwitchComponent","_props","native","nativeProps","checked","checkedProp","defaultChecked","onCheckedChange","activeTheme","activeThemeProp","setChecked","prop","defaultProp","onChange","transition","useContext","setFrameInnerWidth","switchProps","bubbleInput","switchRef","nativeSwitch","id","handleLayout","children","Provider","render","theme","type","backgroundColor","flex","disableTheme"],"sources":["../../src/createSwitch.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,oBAAA,EACAC,gBAAA,EACAC,KAAA,EACAC,IAAA,EACAC,oBAAA,QACK;AACP,SAASC,SAAA,QAAiB;AAC1B,SAASC,oBAAA,QAA4B;AACrC,YAAYC,KAAA,MAAW;AAEvB,SAASC,mBAAA,QAA2B;AACpC,SAASC,WAAA,IAAeC,kBAAA,EAAoBC,WAAA,QAAmB;AAQ/D,SAASC,eAAA,QAAuB;AAwDxB,SA6EAC,QAAA,EA7EAC,GAAA,EA6EAC,IAAA,QA7EA;AApDD,SAASC,aAGdC,WAAA,EAAuC;EACvC,MAAM;IAAEC,KAAA,GAAQR,kBAAA;IAAoBS,KAAA,GAAQR;EAAY,IAAIM,WAAA;EAK5D,IAAIG,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,eAAe;IAC1C,IACGJ,KAAA,KAAUR,kBAAA,IACTQ,KAAA,CAAMK,YAAA,CAAaC,OAAA,IACnBN,KAAA,CAAMK,YAAA,CAAaC,OAAA,KAAYhB,mBAAA,IAChCW,KAAA,KAAUR,WAAA,IACTQ,KAAA,CAAMI,YAAA,CAAaC,OAAA,IACnBL,KAAA,CAAMI,YAAA,CAAaC,OAAA,KAAYhB,mBAAA,EACjC;MACAiB,OAAA,CAAQC,IAAA,CACN,2IACF;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AAAxD,KAAA,CAAMwD;UAAA,CACT;QAAA,CACF;MAAA,CACF,GAECL,WAAA;IAAA,CACH;EAEJ,GACA;IACEY,YAAA,EAAc;EAChB,CACF;EAEA,OAAOzF,oBAAA,CAAqB2D,eAAA,EAAiB;IAC3C5C,KAAA,EAAOQ;EACT,CAAC;AACH","ignoreList":[]}
|
|
@@ -11,136 +11,142 @@ function createSwitch(createProps) {
|
|
|
11
11
|
Frame = DefaultSwitchFrame,
|
|
12
12
|
Thumb = SwitchThumb
|
|
13
13
|
} = createProps;
|
|
14
|
-
process.env.NODE_ENV === "development"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
if (process.env.NODE_ENV === "development") {
|
|
15
|
+
if (Frame !== DefaultSwitchFrame && Frame.staticConfig.context && Frame.staticConfig.context !== SwitchStyledContext || Thumb !== SwitchThumb && Thumb.staticConfig.context && Thumb.staticConfig.context !== SwitchStyledContext) {
|
|
16
|
+
console.warn(`Warning: createSwitch() needs to control context to pass checked state from Frame to Thumb, any custom context passed will be overridden.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Frame.staticConfig.context = SwitchStyledContext;
|
|
20
|
+
Thumb.staticConfig.context = SwitchStyledContext;
|
|
21
|
+
var SwitchThumbComponent = Thumb.styleable(function SwitchThumb2(props, forwardedRef) {
|
|
22
|
+
var {
|
|
23
|
+
size: sizeProp,
|
|
24
|
+
unstyled: unstyledProp,
|
|
25
|
+
activeStyle,
|
|
26
|
+
...thumbProps
|
|
27
|
+
} = props;
|
|
28
|
+
var styledContext = SwitchStyledContext.useStyledContext();
|
|
29
|
+
var {
|
|
30
|
+
unstyled: unstyledContext,
|
|
31
|
+
size: sizeContext,
|
|
32
|
+
active,
|
|
33
|
+
disabled,
|
|
34
|
+
frameWidth = 0
|
|
35
|
+
} = styledContext;
|
|
36
|
+
var _ref;
|
|
37
|
+
var unstyled = process.env.TAMAGUI_HEADLESS === "1" ? true : (_ref = unstyledProp !== null && unstyledProp !== void 0 ? unstyledProp : unstyledContext) !== null && _ref !== void 0 ? _ref : false;
|
|
38
|
+
var _ref1;
|
|
39
|
+
var size = (_ref1 = sizeProp !== null && sizeProp !== void 0 ? sizeProp : sizeContext) !== null && _ref1 !== void 0 ? _ref1 : "$true";
|
|
40
|
+
var initialChecked = React.useRef(active).current;
|
|
41
|
+
var initialWidth = getVariableValue(props.width || size, "size");
|
|
42
|
+
var [thumbWidth, setThumbWidth] = React.useState(typeof initialWidth === "number" ? initialWidth : 0);
|
|
43
|
+
var distance = frameWidth - thumbWidth;
|
|
44
|
+
var x = initialChecked ? active ? 0 : -distance : active ? distance : 0;
|
|
45
|
+
return /* @__PURE__ */_jsx(Thumb, {
|
|
46
|
+
ref: forwardedRef,
|
|
47
|
+
unstyled,
|
|
48
|
+
...(unstyled === false && {
|
|
49
|
+
size
|
|
50
|
+
}),
|
|
51
|
+
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
52
|
+
x,
|
|
53
|
+
onLayout: composeEventHandlers(props.onLayout, function (e) {
|
|
54
|
+
var next = e.nativeEvent.layout.width;
|
|
55
|
+
setThumbWidth(next);
|
|
56
|
+
}),
|
|
57
|
+
disabled,
|
|
58
|
+
...thumbProps,
|
|
59
|
+
...(active && activeStyle)
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
var SwitchComponent = Frame.styleable(function SwitchFrame(_props, forwardedRef) {
|
|
63
|
+
var {
|
|
64
|
+
native,
|
|
65
|
+
nativeProps,
|
|
66
|
+
checked: checkedProp,
|
|
67
|
+
defaultChecked,
|
|
68
|
+
onCheckedChange,
|
|
69
|
+
activeStyle,
|
|
70
|
+
unstyled: unstyledProp,
|
|
71
|
+
activeTheme: activeThemeProp,
|
|
72
|
+
...props
|
|
73
|
+
} = _props;
|
|
74
|
+
var [checked, setChecked] = useControllableState({
|
|
75
|
+
prop: checkedProp,
|
|
76
|
+
defaultProp: defaultChecked || false,
|
|
77
|
+
onChange: onCheckedChange,
|
|
78
|
+
transition: true
|
|
79
|
+
});
|
|
80
|
+
var styledContext = React.useContext(SwitchStyledContext.context);
|
|
81
|
+
var [frameWidth, setFrameInnerWidth] = React.useState(0);
|
|
82
|
+
var {
|
|
83
|
+
switchProps,
|
|
84
|
+
bubbleInput,
|
|
85
|
+
switchRef
|
|
86
|
+
} = useSwitch(props, [checked, setChecked],
|
|
87
|
+
// @ts-ignore TODO tamagui react 19 type error
|
|
88
|
+
forwardedRef);
|
|
89
|
+
var nativeSwitch = useSwitchNative({
|
|
90
|
+
id: props.id,
|
|
91
|
+
disabled: props.disabled,
|
|
92
|
+
native,
|
|
93
|
+
nativeProps,
|
|
94
|
+
checked,
|
|
95
|
+
setChecked
|
|
96
|
+
});
|
|
97
|
+
if (nativeSwitch) {
|
|
98
|
+
return nativeSwitch;
|
|
99
|
+
}
|
|
100
|
+
var disabled = props.disabled;
|
|
101
|
+
var handleLayout = function (e) {
|
|
102
|
+
var next = e.nativeEvent.layout.width;
|
|
103
|
+
if (next !== frameWidth) {
|
|
104
|
+
setFrameInnerWidth(next);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var _styledContext_unstyled, _ref;
|
|
108
|
+
var unstyled = (_ref = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : unstyledProp) !== null && _ref !== void 0 ? _ref : false;
|
|
109
|
+
var _styledContext_size, _ref1, _styledContext_size1, _ref2;
|
|
110
|
+
return /* @__PURE__ */_jsxs(_Fragment, {
|
|
111
|
+
children: [/* @__PURE__ */_jsx(SwitchStyledContext.Provider, {
|
|
112
|
+
size: (_ref1 = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref1 !== void 0 ? _ref1 : "$true",
|
|
41
113
|
unstyled,
|
|
42
|
-
|
|
43
|
-
size
|
|
44
|
-
}),
|
|
45
|
-
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
46
|
-
x,
|
|
47
|
-
onLayout: composeEventHandlers(props.onLayout, function (e) {
|
|
48
|
-
var next = e.nativeEvent.layout.width;
|
|
49
|
-
setThumbWidth(next);
|
|
50
|
-
}),
|
|
114
|
+
active: checked,
|
|
51
115
|
disabled,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
unstyled: unstyledProp,
|
|
65
|
-
activeTheme: activeThemeProp,
|
|
66
|
-
...props
|
|
67
|
-
} = _props,
|
|
68
|
-
[checked, setChecked] = useControllableState({
|
|
69
|
-
prop: checkedProp,
|
|
70
|
-
defaultProp: defaultChecked || !1,
|
|
71
|
-
onChange: onCheckedChange,
|
|
72
|
-
transition: !0
|
|
73
|
-
}),
|
|
74
|
-
styledContext = React.useContext(SwitchStyledContext.context),
|
|
75
|
-
[frameWidth, setFrameInnerWidth] = React.useState(0),
|
|
76
|
-
{
|
|
77
|
-
switchProps,
|
|
78
|
-
bubbleInput,
|
|
79
|
-
switchRef
|
|
80
|
-
} = useSwitch(props, [checked, setChecked],
|
|
81
|
-
// @ts-ignore TODO tamagui react 19 type error
|
|
82
|
-
forwardedRef),
|
|
83
|
-
nativeSwitch = useSwitchNative({
|
|
84
|
-
id: props.id,
|
|
85
|
-
disabled: props.disabled,
|
|
86
|
-
native,
|
|
87
|
-
nativeProps,
|
|
88
|
-
checked,
|
|
89
|
-
setChecked
|
|
90
|
-
});
|
|
91
|
-
if (nativeSwitch) return nativeSwitch;
|
|
92
|
-
var disabled = props.disabled,
|
|
93
|
-
handleLayout = function (e) {
|
|
94
|
-
var next = e.nativeEvent.layout.width;
|
|
95
|
-
next !== frameWidth && setFrameInnerWidth(next);
|
|
96
|
-
},
|
|
97
|
-
_styledContext_unstyled,
|
|
98
|
-
_ref,
|
|
99
|
-
unstyled = (_ref = (_styledContext_unstyled = styledContext.unstyled) !== null && _styledContext_unstyled !== void 0 ? _styledContext_unstyled : unstyledProp) !== null && _ref !== void 0 ? _ref : !1,
|
|
100
|
-
_styledContext_size,
|
|
101
|
-
_ref1,
|
|
102
|
-
_styledContext_size1,
|
|
103
|
-
_ref2;
|
|
104
|
-
return /* @__PURE__ */_jsxs(_Fragment, {
|
|
105
|
-
children: [/* @__PURE__ */_jsx(SwitchStyledContext.Provider, {
|
|
106
|
-
size: (_ref1 = (_styledContext_size = styledContext.size) !== null && _styledContext_size !== void 0 ? _styledContext_size : props.size) !== null && _ref1 !== void 0 ? _ref1 : "$true",
|
|
116
|
+
frameWidth,
|
|
117
|
+
children: /* @__PURE__ */_jsx(Frame, {
|
|
118
|
+
ref: switchRef,
|
|
119
|
+
render: "button",
|
|
120
|
+
// activeThemeProp should be a theme name string like "active", not a style object
|
|
121
|
+
theme: activeThemeProp !== null && activeThemeProp !== void 0 ? activeThemeProp : null,
|
|
122
|
+
...(isWeb && {
|
|
123
|
+
type: "button"
|
|
124
|
+
}),
|
|
125
|
+
...(!unstyled && {
|
|
126
|
+
size: (_ref2 = (_styledContext_size1 = styledContext.size) !== null && _styledContext_size1 !== void 0 ? _styledContext_size1 : props.size) !== null && _ref2 !== void 0 ? _ref2 : "$true"
|
|
127
|
+
}),
|
|
107
128
|
unstyled,
|
|
108
|
-
|
|
129
|
+
...props,
|
|
130
|
+
...switchProps,
|
|
109
131
|
disabled,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
render: "button",
|
|
114
|
-
// activeThemeProp should be a theme name string like "active", not a style object
|
|
115
|
-
theme: activeThemeProp ?? null,
|
|
116
|
-
...(isWeb && {
|
|
117
|
-
type: "button"
|
|
118
|
-
}),
|
|
119
|
-
...(!unstyled && {
|
|
120
|
-
size: (_ref2 = (_styledContext_size1 = styledContext.size) !== null && _styledContext_size1 !== void 0 ? _styledContext_size1 : props.size) !== null && _ref2 !== void 0 ? _ref2 : "$true"
|
|
132
|
+
...(checked && {
|
|
133
|
+
...(!unstyled && !activeStyle && {
|
|
134
|
+
backgroundColor: "$backgroundActive"
|
|
121
135
|
}),
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}),
|
|
130
|
-
...activeStyle
|
|
131
|
-
}),
|
|
132
|
-
children: /* @__PURE__ */_jsx(View, {
|
|
133
|
-
alignSelf: "stretch",
|
|
134
|
-
flex: 1,
|
|
135
|
-
onLayout: handleLayout,
|
|
136
|
-
children: props.children
|
|
137
|
-
})
|
|
136
|
+
...activeStyle
|
|
137
|
+
}),
|
|
138
|
+
children: /* @__PURE__ */_jsx(View, {
|
|
139
|
+
alignSelf: "stretch",
|
|
140
|
+
flex: 1,
|
|
141
|
+
onLayout: handleLayout,
|
|
142
|
+
children: props.children
|
|
138
143
|
})
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
}, {
|
|
142
|
-
disableTheme: !0
|
|
144
|
+
})
|
|
145
|
+
}), bubbleInput]
|
|
143
146
|
});
|
|
147
|
+
}, {
|
|
148
|
+
disableTheme: true
|
|
149
|
+
});
|
|
144
150
|
return withStaticProperties(SwitchComponent, {
|
|
145
151
|
Thumb: SwitchThumbComponent
|
|
146
152
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","composeEventHandlers","getVariableValue","isWeb","View","withStaticProperties","useSwitch","useControllableState","React","SwitchStyledContext","SwitchFrame","DefaultSwitchFrame","SwitchThumb","useSwitchNative","createSwitch","createProps","Frame","Thumb","process","env","NODE_ENV","staticConfig","context","console","warn","SwitchThumbComponent","styleable","props","forwardedRef","size","sizeProp","unstyled","unstyledProp","activeStyle","thumbProps","styledContext","useStyledContext","unstyledContext","sizeContext","active","disabled","frameWidth","_ref","TAMAGUI_HEADLESS","_ref1","initialChecked","useRef","current","initialWidth","width","thumbWidth","setThumbWidth","useState","distance","x","ref","alignSelf","onLayout","e","next","nativeEvent","layout","SwitchComponent","_props","native","nativeProps","checked","checkedProp","defaultChecked","onCheckedChange","activeTheme","activeThemeProp","setChecked","prop","defaultProp","onChange","transition","useContext","setFrameInnerWidth","switchProps","bubbleInput","switchRef","nativeSwitch","id","handleLayout","_styledContext_unstyled","_styledContext_size","_styledContext_size1","_ref2","children","Provider","render","theme","type","backgroundColor","flex","disableTheme"],"sources":["../../src/createSwitch.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAAA,SACEC,oBAAA,EAAAC,gBAAA,EAAAC,KAAA,EAAAC,IAAA,EAAAC,oBAAA;AAAA,SACAC,SAAA;AAAA,SACAC,oBAAA;AAAA,OACA,KAAAC,KAAA;AAAA,SACAC,mBAAA;AAAA,SACKC,WAAA,IAAAC,kBAAA,EAAAC,WAAA;AACP,SAASC,eAAA,QAAiB;AAC1B,SAASC,aAAAC,WAAA;EACT;IAAAC,KAAY,GAAAL,kBAAW;IAAAM,KAAA,GAAAL;EAAA,IAAAG,WAAA;
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","composeEventHandlers","getVariableValue","isWeb","View","withStaticProperties","useSwitch","useControllableState","React","SwitchStyledContext","SwitchFrame","DefaultSwitchFrame","SwitchThumb","useSwitchNative","createSwitch","createProps","Frame","Thumb","process","env","NODE_ENV","staticConfig","context","console","warn","SwitchThumbComponent","styleable","SwitchThumb2","props","forwardedRef","size","sizeProp","unstyled","unstyledProp","activeStyle","thumbProps","styledContext","useStyledContext","unstyledContext","sizeContext","active","disabled","frameWidth","_ref","TAMAGUI_HEADLESS","_ref1","initialChecked","useRef","current","initialWidth","width","thumbWidth","setThumbWidth","useState","distance","x","ref","alignSelf","onLayout","e","next","nativeEvent","layout","SwitchComponent","_props","native","nativeProps","checked","checkedProp","defaultChecked","onCheckedChange","activeTheme","activeThemeProp","setChecked","prop","defaultProp","onChange","transition","useContext","setFrameInnerWidth","switchProps","bubbleInput","switchRef","nativeSwitch","id","handleLayout","_styledContext_unstyled","_styledContext_size","_styledContext_size1","_ref2","children","Provider","render","theme","type","backgroundColor","flex","disableTheme"],"sources":["../../src/createSwitch.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAAA,SACEC,oBAAA,EAAAC,gBAAA,EAAAC,KAAA,EAAAC,IAAA,EAAAC,oBAAA;AAAA,SACAC,SAAA;AAAA,SACAC,oBAAA;AAAA,OACA,KAAAC,KAAA;AAAA,SACAC,mBAAA;AAAA,SACKC,WAAA,IAAAC,kBAAA,EAAAC,WAAA;AACP,SAASC,eAAA,QAAiB;AAC1B,SAASC,aAAAC,WAAA;EACT;IAAAC,KAAY,GAAAL,kBAAW;IAAAM,KAAA,GAAAL;EAAA,IAAAG,WAAA;EAEvB,IAAAG,OAAS,CAAAC,GAAA,CAAAC,QAAA,kBAA2B;IACpC,IAAAJ,KAAS,KAAAL,kBAAe,IAAAK,KAAoB,CAAAK,YAAA,CAAAC,OAAmB,IAAAN,KAAA,CAAAK,YAAA,CAAAC,OAAA,KAAAb,mBAAA,IAAAQ,KAAA,KAAAL,WAAA,IAAAK,KAAA,CAAAI,YAAA,CAAAC,OAAA,IAAAL,KAAA,CAAAI,YAAA,CAAAC,OAAA,KAAAb,mBAAA;MAQ/Dc,OAAS,CAAAC,IAAA,4IAAu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QAAM;UACF,GAAAJ,KAAA;UACF,GAAAoD,WAAA;UACFvC,QAAA;UACF,IAAA0B,OAAA;YAEM,KAAAnC,QAAW,KAAAE,WAAc;cAG7B6D,eAAA;YACE;YAAC,GAAA7D;UAAA;UACCwD,QAAM,iBAAc9F,IAAQ,CAAAQ,IAAM;YAClCqD,SAAA;YACAuC,IAAA,EAAQ;YACRtC,QAAA,EAAA2B,YAAA;YACAK,QAAA,EAAA9D,KAAA,CAAA8D;UAEA;QAAA;MAAC,IAAAT,WACC;IACO;EAEmB;IACKgB,YAC9B;EAAiB;EAC0B,OAAA5F,oBAC5C,CAAA0D,eAAA;IAAA9C,KAAA,EAAAQ;EACA;AACI;AACC,SACLX,YAAA","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { createSwitch } from "./createSwitch";
|
|
2
|
-
import { SwitchFrame, SwitchThumb } from "./Switch";
|
|
3
|
-
export * from "./createSwitch";
|
|
4
|
-
export * from "./StyledContext";
|
|
5
|
-
export * from "./Switch";
|
|
6
|
-
export * from "./types";
|
|
7
|
-
import { useSwitchNative } from "./useSwitchNative";
|
|
1
|
+
import { createSwitch } from "./createSwitch.mjs";
|
|
2
|
+
import { SwitchFrame, SwitchThumb } from "./Switch.mjs";
|
|
3
|
+
export * from "./createSwitch.mjs";
|
|
4
|
+
export * from "./StyledContext.mjs";
|
|
5
|
+
export * from "./Switch.mjs";
|
|
6
|
+
export * from "./types.mjs";
|
|
7
|
+
import { useSwitchNative } from "./useSwitchNative.mjs";
|
|
8
8
|
const Switch = createSwitch({
|
|
9
9
|
Frame: SwitchFrame,
|
|
10
10
|
Thumb: SwitchThumb
|
|
11
11
|
});
|
|
12
|
-
export {
|
|
13
|
-
Switch,
|
|
14
|
-
useSwitchNative
|
|
15
|
-
};
|
|
12
|
+
export { Switch, useSwitchNative };
|
|
16
13
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,aAAa,mBAAmB;AAEzC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAazB,MAAM,SAAS,aAAa;AAAA,EACjC,OAAO;AAAA,EACP,OAAO;AACT,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["createSwitch","SwitchFrame","SwitchThumb","useSwitchNative","Switch","Frame","Thumb"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAA,QAAoB;AAC7B,SAASC,WAAA,EAAaC,WAAA,QAAmB;AAEzC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASC,eAAA,QAAuB;AAazB,MAAMC,MAAA,GAASJ,YAAA,CAAa;EACjCK,KAAA,EAAOJ,WAAA;EACPK,KAAA,EAAOJ;AACT,CAAC","ignoreList":[]}
|