@tamagui/switch 1.61.2 → 1.62.0
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 +12 -24
- package/dist/cjs/Switch.js.map +1 -1
- package/dist/cjs/Switch.native.js +99 -0
- package/dist/cjs/Switch.native.js.map +6 -0
- package/dist/cjs/createSwitch.js +64 -129
- package/dist/cjs/createSwitch.js.map +2 -2
- package/dist/cjs/createSwitch.native.js +196 -0
- package/dist/cjs/createSwitch.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/Switch.js +6 -11
- package/dist/esm/Switch.js.map +1 -1
- package/dist/esm/createSwitch.js +57 -107
- package/dist/esm/createSwitch.js.map +2 -2
- package/dist/jsx/Switch.js +6 -11
- package/dist/jsx/Switch.js.map +1 -1
- package/dist/jsx/Switch.native.js +79 -0
- package/dist/jsx/Switch.native.js.map +6 -0
- package/dist/jsx/createSwitch.js +51 -101
- package/dist/jsx/createSwitch.js.map +2 -2
- package/dist/jsx/createSwitch.native.js +172 -0
- package/dist/jsx/createSwitch.native.js.map +6 -0
- package/dist/jsx/index.native.js +3 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +11 -11
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
+
mod
|
|
23
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
+
var createSwitch_exports = {};
|
|
25
|
+
__export(createSwitch_exports, {
|
|
26
|
+
SwitchContext: () => SwitchContext,
|
|
27
|
+
createSwitch: () => createSwitch
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(createSwitch_exports);
|
|
30
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_focusable = require("@tamagui/focusable"), import_get_token = require("@tamagui/get-token"), import_label = require("@tamagui/label"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_react_native = require("react-native"), import_jsx_runtime = (
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
require("react/jsx-runtime")
|
|
33
|
+
);
|
|
34
|
+
const SwitchContext = (0, import_core.createStyledContext)({
|
|
35
|
+
checked: !1,
|
|
36
|
+
disabled: !1,
|
|
37
|
+
size: void 0,
|
|
38
|
+
frameWidth: 0,
|
|
39
|
+
unstyled: !1
|
|
40
|
+
});
|
|
41
|
+
function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
42
|
+
const SwitchThumb = Thumb.styleable(function(props, forwardedRef) {
|
|
43
|
+
const { size: sizeProp, ...thumbProps } = props, { disabled, checked, unstyled, frameWidth } = React.useContext(SwitchContext), [thumbWidth, setThumbWidth] = React.useState(0), initialChecked = React.useRef(checked).current, distance = frameWidth - thumbWidth;
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
Thumb,
|
|
46
|
+
{
|
|
47
|
+
theme: unstyled === !1 && checked ? "active" : null,
|
|
48
|
+
"data-state": getState(checked),
|
|
49
|
+
"data-disabled": disabled ? "" : void 0,
|
|
50
|
+
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
51
|
+
x: initialChecked ? checked ? 0 : -distance : checked ? distance : 0,
|
|
52
|
+
...thumbProps,
|
|
53
|
+
onLayout: (0, import_core.composeEventHandlers)(
|
|
54
|
+
props.onLayout,
|
|
55
|
+
(e) => (
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
setThumbWidth(e.nativeEvent.layout.width)
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
ref: forwardedRef
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}), SwitchComponent = Frame.extractable(
|
|
64
|
+
React.forwardRef(function(propsIn, forwardedRef) {
|
|
65
|
+
const styledContext = React.useContext(SwitchContext), props = (0, import_core.useProps)(propsIn), {
|
|
66
|
+
labeledBy: ariaLabelledby,
|
|
67
|
+
name,
|
|
68
|
+
checked: checkedProp,
|
|
69
|
+
defaultChecked,
|
|
70
|
+
required,
|
|
71
|
+
disabled,
|
|
72
|
+
value = "on",
|
|
73
|
+
onCheckedChange,
|
|
74
|
+
size = styledContext.size ?? "$true",
|
|
75
|
+
unstyled = styledContext.unstyled ?? !1,
|
|
76
|
+
native: nativeProp,
|
|
77
|
+
nativeProps,
|
|
78
|
+
...switchProps
|
|
79
|
+
} = props, leftBorderWidth = (() => {
|
|
80
|
+
let _;
|
|
81
|
+
for (const key in switchProps)
|
|
82
|
+
(key === "borderWidth" || key === "borderLeftWidth") && (_ = switchProps[key]);
|
|
83
|
+
return acceptsUnstyled && _ === void 0 && unstyled === !1 && (_ = 2), typeof _ == "string" && (_ = (0, import_core.getVariableValue)((0, import_get_token.getSize)(_))), +_;
|
|
84
|
+
})(), native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !import_core.isWeb && nativeProp === !0 || !import_core.isWeb && native.includes("mobile") || native.includes("android") && import_react_native.Platform.OS === "android" || native.includes("ios") && import_react_native.Platform.OS === "ios", [button, setButton] = React.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node)), labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId, hasConsumerStoppedPropagationRef = React.useRef(!1), isFormControl = import_core.isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React.useState(0), [checked = !1, setChecked] = (0, import_use_controllable_state.useControllableState)({
|
|
85
|
+
prop: checkedProp,
|
|
86
|
+
defaultProp: defaultChecked || !1,
|
|
87
|
+
onChange: onCheckedChange,
|
|
88
|
+
transition: !0
|
|
89
|
+
});
|
|
90
|
+
return shouldRenderMobileNative ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
91
|
+
import_react_native.Switch,
|
|
92
|
+
{
|
|
93
|
+
value: checkedProp,
|
|
94
|
+
onValueChange: onCheckedChange,
|
|
95
|
+
...nativeProps
|
|
96
|
+
}
|
|
97
|
+
) : (import_core.isWeb || React.useEffect(() => {
|
|
98
|
+
if (props.id)
|
|
99
|
+
return (0, import_focusable.registerFocusable)(props.id, {
|
|
100
|
+
focus: () => {
|
|
101
|
+
setChecked((x) => !x);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}, [props.id, setChecked]), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
Frame,
|
|
107
|
+
{
|
|
108
|
+
unstyled,
|
|
109
|
+
size,
|
|
110
|
+
checked,
|
|
111
|
+
disabled,
|
|
112
|
+
frameWidth: frameWidth ? frameWidth - leftBorderWidth * 2 : 0,
|
|
113
|
+
theme: checked ? "active" : null,
|
|
114
|
+
themeShallow: !0,
|
|
115
|
+
role: "switch",
|
|
116
|
+
"aria-checked": checked,
|
|
117
|
+
"aria-labelledby": labelledBy,
|
|
118
|
+
"aria-required": required,
|
|
119
|
+
"data-state": getState(checked),
|
|
120
|
+
"data-disabled": disabled ? "" : void 0,
|
|
121
|
+
tabIndex: disabled ? void 0 : 0,
|
|
122
|
+
value,
|
|
123
|
+
...switchProps,
|
|
124
|
+
ref: composedRefs,
|
|
125
|
+
onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
|
|
126
|
+
setChecked((prevChecked) => !prevChecked), import_core.isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
127
|
+
}),
|
|
128
|
+
onLayout: (0, import_core.composeEventHandlers)(
|
|
129
|
+
props.onLayout,
|
|
130
|
+
(e) => (
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
setFrameWidth(e.nativeEvent.layout.width)
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
import_core.isWeb && isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
138
|
+
BubbleInput,
|
|
139
|
+
{
|
|
140
|
+
control: button,
|
|
141
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
142
|
+
name,
|
|
143
|
+
value,
|
|
144
|
+
checked,
|
|
145
|
+
required,
|
|
146
|
+
disabled,
|
|
147
|
+
style: { transform: "translateX(-100%)" }
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] }));
|
|
151
|
+
})
|
|
152
|
+
), BubbleInput = (props) => {
|
|
153
|
+
const { control, checked, bubbles = !0, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
154
|
+
return React.useEffect(() => {
|
|
155
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
156
|
+
inputProto,
|
|
157
|
+
"checked"
|
|
158
|
+
).set;
|
|
159
|
+
if (prevChecked !== checked && setChecked) {
|
|
160
|
+
const event = new Event("click", { bubbles });
|
|
161
|
+
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
162
|
+
}
|
|
163
|
+
}, [prevChecked, checked, bubbles]), // @ts-ignore
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
+
"input",
|
|
166
|
+
{
|
|
167
|
+
type: "checkbox",
|
|
168
|
+
"aria-hidden": !0,
|
|
169
|
+
defaultChecked: checked,
|
|
170
|
+
...inputProps,
|
|
171
|
+
tabIndex: -1,
|
|
172
|
+
ref,
|
|
173
|
+
style: {
|
|
174
|
+
...props.style,
|
|
175
|
+
// ...controlSize,
|
|
176
|
+
position: "absolute",
|
|
177
|
+
pointerEvents: "none",
|
|
178
|
+
opacity: 0,
|
|
179
|
+
margin: 0
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
function getState(checked) {
|
|
185
|
+
return checked ? "checked" : "unchecked";
|
|
186
|
+
}
|
|
187
|
+
return (0, import_core.withStaticProperties)(SwitchComponent, {
|
|
188
|
+
Thumb: SwitchThumb
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
+
0 && (module.exports = {
|
|
193
|
+
SwitchContext,
|
|
194
|
+
createSwitch
|
|
195
|
+
});
|
|
196
|
+
//# sourceMappingURL=createSwitch.js.map
|
|
@@ -0,0 +1,6 @@
|
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AAE,WAAW,oBAAoB;AAAA;AAAA,QAC1C;AAAA,SAEJ;AAAA,IAEJ,CAAC;AAAA,EACH,GAaM,cAAc,CAAC,UAA4B;AAC/C,UAAM,EAAE,SAAS,SAAS,UAAU,IAAM,GAAG,WAAW,IAAI,OACtD,MAAM,MAAM,OAAyB,IAAI,GACzC,kBAAc,iCAAY,OAAO;AAIvC,iBAAM,UAAU,MAAM;AACpB,YAAM,QAAQ,IAAI,SACZ,aAAa,OAAO,iBAAiB,WAKrC,aAJa,OAAO;AAAA,QACxB;AAAA,QACA;AAAA,MACF,EAC8B;AAC9B,UAAI,gBAAgB,WAAW,YAAY;AACzC,cAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,mBAAW,KAAK,OAAO,OAAO,GAC9B,MAAM,cAAc,KAAK;AAAA,MAC3B;AAAA,IACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAAA,IAIhC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,eAAW;AAAA,QACX,gBAAgB;AAAA,QACf,GAAG;AAAA,QACJ,UAAU;AAAA,QACV;AAAA,QACA,OAAO;AAAA,UACL,GAAG,MAAM;AAAA;AAAA,UAET,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,WAAS,SAAS,SAAkB;AAClC,WAAO,UAAU,YAAY;AAAA,EAC/B;AAMA,aAJe,kCAAqB,iBAAiB;AAAA,IACnD,OAAO;AAAA,EACT,CAAC;AAGH;",
|
|
5
|
+
"names": ["NativeSwitch"]
|
|
6
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
7
|
for (let key of __getOwnPropNames(from))
|
|
9
|
-
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
9
|
return to;
|
|
13
|
-
};
|
|
14
|
-
var
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
12
|
var src_exports = {};
|
|
17
13
|
module.exports = __toCommonJS(src_exports);
|
|
18
14
|
__reExport(src_exports, require("./Switch"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var src_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(src_exports);
|
|
15
|
+
__reExport(src_exports, require("./Switch"), module.exports);
|
|
16
|
+
__reExport(src_exports, require("./createSwitch"), module.exports);
|
|
17
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
18
|
+
0 && (module.exports = {
|
|
19
|
+
...require("./Switch"),
|
|
20
|
+
...require("./createSwitch")
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/Switch.js
CHANGED
|
@@ -24,12 +24,9 @@ const SwitchThumb = styled(ThemeableStack, {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
defaultVariants: {
|
|
27
|
-
unstyled:
|
|
27
|
+
unstyled: !1
|
|
28
28
|
}
|
|
29
|
-
})
|
|
30
|
-
const getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65);
|
|
31
|
-
const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
|
|
32
|
-
const SwitchFrame = styled(YStack, {
|
|
29
|
+
}), getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65), getSwitchWidth = (val) => getSwitchHeight(val) * 2, SwitchFrame = styled(YStack, {
|
|
33
30
|
name: "Switch",
|
|
34
31
|
tag: "button",
|
|
35
32
|
context: SwitchContext,
|
|
@@ -57,8 +54,7 @@ const SwitchFrame = styled(YStack, {
|
|
|
57
54
|
},
|
|
58
55
|
size: {
|
|
59
56
|
"...size": (val) => {
|
|
60
|
-
const height = getSwitchHeight(val) + 4;
|
|
61
|
-
const width = getSwitchWidth(val) + 4;
|
|
57
|
+
const height = getSwitchHeight(val) + 4, width = getSwitchWidth(val) + 4;
|
|
62
58
|
return {
|
|
63
59
|
height,
|
|
64
60
|
minHeight: height,
|
|
@@ -68,13 +64,12 @@ const SwitchFrame = styled(YStack, {
|
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
66
|
defaultVariants: {
|
|
71
|
-
unstyled:
|
|
67
|
+
unstyled: !1
|
|
72
68
|
}
|
|
73
|
-
})
|
|
74
|
-
const Switch = createSwitch({
|
|
69
|
+
}), Switch = createSwitch({
|
|
75
70
|
Frame: SwitchFrame,
|
|
76
71
|
Thumb: SwitchThumb,
|
|
77
|
-
acceptsUnstyled:
|
|
72
|
+
acceptsUnstyled: !0
|
|
78
73
|
});
|
|
79
74
|
export {
|
|
80
75
|
Switch,
|
package/dist/esm/Switch.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Switch.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAqB,kBAAkB,cAAc;AACrD,SAAS,eAAe;AACxB,SAAS,gBAAgB,cAAc;AAEvC,SAAS,eAAe,oBAAoB;AAErC,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EAET,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB;AAAA,IACF;AAAA,IAEA,MAAM;AAAA,MACJ,WAAW,CAAC,QAAQ;AAClB,cAAM,OAAO,gBAAgB,GAAG;AAChC,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,OAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC
|
|
4
|
+
"mappings": "AAAA,SAAqB,kBAAkB,cAAc;AACrD,SAAS,eAAe;AACxB,SAAS,gBAAgB,cAAc;AAEvC,SAAS,eAAe,oBAAoB;AAErC,MAAM,cAAc,OAAO,gBAAgB;AAAA,EAChD,MAAM;AAAA,EACN,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ACjC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,iBAAiB;AACnB,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/createSwitch.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
2
|
import {
|
|
4
3
|
composeEventHandlers,
|
|
@@ -18,26 +17,23 @@ import {
|
|
|
18
17
|
Switch as NativeSwitch,
|
|
19
18
|
Platform
|
|
20
19
|
} from "react-native";
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
21
|
const SwitchContext = createStyledContext({
|
|
22
|
-
checked:
|
|
23
|
-
disabled:
|
|
22
|
+
checked: !1,
|
|
23
|
+
disabled: !1,
|
|
24
24
|
size: void 0,
|
|
25
25
|
frameWidth: 0,
|
|
26
|
-
unstyled:
|
|
26
|
+
unstyled: !1
|
|
27
27
|
});
|
|
28
28
|
function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
29
|
-
const SwitchThumb = Thumb.styleable(function
|
|
30
|
-
const { size: sizeProp, ...thumbProps } = props;
|
|
31
|
-
const { disabled, checked, unstyled, frameWidth } = React.useContext(SwitchContext);
|
|
32
|
-
const [thumbWidth, setThumbWidth] = React.useState(0);
|
|
33
|
-
const initialChecked = React.useRef(checked).current;
|
|
34
|
-
const distance = frameWidth - thumbWidth;
|
|
29
|
+
const SwitchThumb = Thumb.styleable(function(props, forwardedRef) {
|
|
30
|
+
const { size: sizeProp, ...thumbProps } = props, { disabled, checked, unstyled, frameWidth } = React.useContext(SwitchContext), [thumbWidth, setThumbWidth] = React.useState(0), initialChecked = React.useRef(checked).current, distance = frameWidth - thumbWidth;
|
|
35
31
|
return (
|
|
36
32
|
// @ts-ignore
|
|
37
33
|
/* @__PURE__ */ jsx(
|
|
38
34
|
Thumb,
|
|
39
35
|
{
|
|
40
|
-
theme: unstyled ===
|
|
36
|
+
theme: unstyled === !1 && checked ? "active" : null,
|
|
41
37
|
"data-state": getState(checked),
|
|
42
38
|
"data-disabled": disabled ? "" : void 0,
|
|
43
39
|
alignSelf: initialChecked ? "flex-end" : "flex-start",
|
|
@@ -54,12 +50,9 @@ function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
|
54
50
|
}
|
|
55
51
|
)
|
|
56
52
|
);
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const styledContext = React.useContext(SwitchContext);
|
|
61
|
-
const props = useProps(propsIn);
|
|
62
|
-
const {
|
|
53
|
+
}), SwitchComponent = Frame.extractable(
|
|
54
|
+
React.forwardRef(function(propsIn, forwardedRef) {
|
|
55
|
+
const styledContext = React.useContext(SwitchContext), props = useProps(propsIn), {
|
|
63
56
|
labeledBy: ariaLabelledby,
|
|
64
57
|
name,
|
|
65
58
|
checked: checkedProp,
|
|
@@ -69,63 +62,36 @@ function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
|
69
62
|
value = "on",
|
|
70
63
|
onCheckedChange,
|
|
71
64
|
size = styledContext.size ?? "$true",
|
|
72
|
-
unstyled = styledContext.unstyled ??
|
|
65
|
+
unstyled = styledContext.unstyled ?? !1,
|
|
73
66
|
native: nativeProp,
|
|
74
67
|
nativeProps,
|
|
75
68
|
...switchProps
|
|
76
|
-
} = props
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (acceptsUnstyled && _ === void 0 && unstyled === false) {
|
|
85
|
-
_ = 2;
|
|
86
|
-
}
|
|
87
|
-
if (typeof _ === "string") {
|
|
88
|
-
_ = getVariableValue(getSize(_));
|
|
89
|
-
}
|
|
90
|
-
return +_;
|
|
91
|
-
})();
|
|
92
|
-
const native = Array.isArray(nativeProp) ? nativeProp : [nativeProp];
|
|
93
|
-
const shouldRenderMobileNative = !isWeb && nativeProp === true || !isWeb && native.includes("mobile") || native.includes("android") && Platform.OS === "android" || native.includes("ios") && Platform.OS === "ios";
|
|
94
|
-
const [button, setButton] = React.useState(null);
|
|
95
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
96
|
-
const labelId = useLabelContext(button);
|
|
97
|
-
const labelledBy = ariaLabelledby || labelId;
|
|
98
|
-
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
99
|
-
const isFormControl = isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
100
|
-
const [frameWidth, setFrameWidth] = React.useState(0);
|
|
101
|
-
const [checked = false, setChecked] = useControllableState({
|
|
69
|
+
} = props, leftBorderWidth = (() => {
|
|
70
|
+
let _;
|
|
71
|
+
for (const key in switchProps)
|
|
72
|
+
(key === "borderWidth" || key === "borderLeftWidth") && (_ = switchProps[key]);
|
|
73
|
+
return acceptsUnstyled && _ === void 0 && unstyled === !1 && (_ = 2), typeof _ == "string" && (_ = getVariableValue(getSize(_))), +_;
|
|
74
|
+
})(), native = Array.isArray(nativeProp) ? nativeProp : [nativeProp], shouldRenderMobileNative = !isWeb && nativeProp === !0 || !isWeb && native.includes("mobile") || native.includes("android") && Platform.OS === "android" || native.includes("ios") && Platform.OS === "ios", [button, setButton] = React.useState(null), composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node)), labelId = useLabelContext(button), labelledBy = ariaLabelledby || labelId, hasConsumerStoppedPropagationRef = React.useRef(!1), isFormControl = isWeb ? button ? !!button.closest("form") : !0 : !1, [frameWidth, setFrameWidth] = React.useState(0), [checked = !1, setChecked] = useControllableState({
|
|
102
75
|
prop: checkedProp,
|
|
103
|
-
defaultProp: defaultChecked ||
|
|
76
|
+
defaultProp: defaultChecked || !1,
|
|
104
77
|
onChange: onCheckedChange,
|
|
105
|
-
transition:
|
|
78
|
+
transition: !0
|
|
106
79
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
if (!isWeb) {
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
if (!props.id)
|
|
120
|
-
return;
|
|
80
|
+
return shouldRenderMobileNative ? /* @__PURE__ */ jsx(
|
|
81
|
+
NativeSwitch,
|
|
82
|
+
{
|
|
83
|
+
value: checkedProp,
|
|
84
|
+
onValueChange: onCheckedChange,
|
|
85
|
+
...nativeProps
|
|
86
|
+
}
|
|
87
|
+
) : (isWeb || React.useEffect(() => {
|
|
88
|
+
if (props.id)
|
|
121
89
|
return registerFocusable(props.id, {
|
|
122
90
|
focus: () => {
|
|
123
91
|
setChecked((x) => !x);
|
|
124
92
|
}
|
|
125
93
|
});
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
|
+
}, [props.id, setChecked]), /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
95
|
/* @__PURE__ */ jsx(
|
|
130
96
|
Frame,
|
|
131
97
|
{
|
|
@@ -135,7 +101,7 @@ function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
|
135
101
|
disabled,
|
|
136
102
|
frameWidth: frameWidth ? frameWidth - leftBorderWidth * 2 : 0,
|
|
137
103
|
theme: checked ? "active" : null,
|
|
138
|
-
themeShallow:
|
|
104
|
+
themeShallow: !0,
|
|
139
105
|
role: "switch",
|
|
140
106
|
"aria-checked": checked,
|
|
141
107
|
"aria-labelledby": labelledBy,
|
|
@@ -147,12 +113,7 @@ function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
|
147
113
|
...switchProps,
|
|
148
114
|
ref: composedRefs,
|
|
149
115
|
onPress: composeEventHandlers(props.onPress, (event) => {
|
|
150
|
-
setChecked((prevChecked) => !prevChecked);
|
|
151
|
-
if (isWeb && isFormControl) {
|
|
152
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
153
|
-
if (!hasConsumerStoppedPropagationRef.current)
|
|
154
|
-
event.stopPropagation();
|
|
155
|
-
}
|
|
116
|
+
setChecked((prevChecked) => !prevChecked), isWeb && isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
156
117
|
}),
|
|
157
118
|
onLayout: composeEventHandlers(
|
|
158
119
|
props.onLayout,
|
|
@@ -176,57 +137,46 @@ function createSwitch({ Frame, Thumb, acceptsUnstyled }) {
|
|
|
176
137
|
style: { transform: "translateX(-100%)" }
|
|
177
138
|
}
|
|
178
139
|
)
|
|
179
|
-
] });
|
|
140
|
+
] }));
|
|
180
141
|
})
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const prevChecked = usePrevious(checked);
|
|
186
|
-
React.useEffect(() => {
|
|
187
|
-
const input = ref.current;
|
|
188
|
-
const inputProto = window.HTMLInputElement.prototype;
|
|
189
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
142
|
+
), BubbleInput = (props) => {
|
|
143
|
+
const { control, checked, bubbles = !0, ...inputProps } = props, ref = React.useRef(null), prevChecked = usePrevious(checked);
|
|
144
|
+
return React.useEffect(() => {
|
|
145
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
190
146
|
inputProto,
|
|
191
147
|
"checked"
|
|
192
|
-
);
|
|
193
|
-
const setChecked = descriptor.set;
|
|
148
|
+
).set;
|
|
194
149
|
if (prevChecked !== checked && setChecked) {
|
|
195
150
|
const event = new Event("click", { bubbles });
|
|
196
|
-
setChecked.call(input, checked);
|
|
197
|
-
input.dispatchEvent(event);
|
|
151
|
+
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
198
152
|
}
|
|
199
|
-
}, [prevChecked, checked, bubbles])
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
opacity: 0,
|
|
217
|
-
margin: 0
|
|
218
|
-
}
|
|
153
|
+
}, [prevChecked, checked, bubbles]), // @ts-ignore
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
"input",
|
|
156
|
+
{
|
|
157
|
+
type: "checkbox",
|
|
158
|
+
"aria-hidden": !0,
|
|
159
|
+
defaultChecked: checked,
|
|
160
|
+
...inputProps,
|
|
161
|
+
tabIndex: -1,
|
|
162
|
+
ref,
|
|
163
|
+
style: {
|
|
164
|
+
...props.style,
|
|
165
|
+
// ...controlSize,
|
|
166
|
+
position: "absolute",
|
|
167
|
+
pointerEvents: "none",
|
|
168
|
+
opacity: 0,
|
|
169
|
+
margin: 0
|
|
219
170
|
}
|
|
220
|
-
|
|
171
|
+
}
|
|
221
172
|
);
|
|
222
173
|
};
|
|
223
174
|
function getState(checked) {
|
|
224
175
|
return checked ? "checked" : "unchecked";
|
|
225
176
|
}
|
|
226
|
-
|
|
177
|
+
return withStaticProperties(SwitchComponent, {
|
|
227
178
|
Thumb: SwitchThumb
|
|
228
179
|
});
|
|
229
|
-
return Switch;
|
|
230
180
|
}
|
|
231
181
|
export {
|
|
232
182
|
SwitchContext,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createSwitch.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC;AAAA,EAME;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,YAAY,WAAW;AAC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AM;AACpB,YAAM,QAAQ,IAAI,SACZ,aAAa,OAAO,iBAAiB,WAKrC,aAJa,OAAO;AAAA,QACxB;AAAA,QACA;AAAA,MACF,EAC8B;AAC9B,UAAI,gBAAgB,WAAW,YAAY;AACzC,cAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,QAAQ,CAAC;AAC5C,mBAAW,KAAK,OAAO,OAAO,GAC9B,MAAM,cAAc,KAAK;AAAA,MAC3B;AAAA,IACF,GAAG,CAAC,aAAa,SAAS,OAAO,CAAC;AAAA,IAIhC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,eAAW;AAAA,QACX,gBAAgB;AAAA,QACf,GAAG;AAAA,QACJ,UAAU;AAAA,QACV;AAAA,QACA,OAAO;AAAA,UACL,GAAG,MAAM;AAAA;AAAA,UAET,UAAU;AAAA,UACV,eAAe;AAAA,UACf,SAAS;AAAA,UACT,QAAQ;AAAA,QACV;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,WAAS,SAAS,SAAkB;AAClC,WAAO,UAAU,YAAY;AAAA,EAC/B;AAMA,SAJe,qBAAqB,iBAAiB;AAAA,IACnD,OAAO;AAAA,EACT,CAAC;AAGH;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
package/dist/jsx/Switch.js
CHANGED
|
@@ -24,12 +24,9 @@ const SwitchThumb = styled(ThemeableStack, {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
defaultVariants: {
|
|
27
|
-
unstyled:
|
|
27
|
+
unstyled: !1
|
|
28
28
|
}
|
|
29
|
-
})
|
|
30
|
-
const getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65);
|
|
31
|
-
const getSwitchWidth = (val) => getSwitchHeight(val) * 2;
|
|
32
|
-
const SwitchFrame = styled(YStack, {
|
|
29
|
+
}), getSwitchHeight = (val) => Math.round(getVariableValue(getSize(val)) * 0.65), getSwitchWidth = (val) => getSwitchHeight(val) * 2, SwitchFrame = styled(YStack, {
|
|
33
30
|
name: "Switch",
|
|
34
31
|
tag: "button",
|
|
35
32
|
context: SwitchContext,
|
|
@@ -57,8 +54,7 @@ const SwitchFrame = styled(YStack, {
|
|
|
57
54
|
},
|
|
58
55
|
size: {
|
|
59
56
|
"...size": (val) => {
|
|
60
|
-
const height = getSwitchHeight(val) + 4;
|
|
61
|
-
const width = getSwitchWidth(val) + 4;
|
|
57
|
+
const height = getSwitchHeight(val) + 4, width = getSwitchWidth(val) + 4;
|
|
62
58
|
return {
|
|
63
59
|
height,
|
|
64
60
|
minHeight: height,
|
|
@@ -68,13 +64,12 @@ const SwitchFrame = styled(YStack, {
|
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
66
|
defaultVariants: {
|
|
71
|
-
unstyled:
|
|
67
|
+
unstyled: !1
|
|
72
68
|
}
|
|
73
|
-
})
|
|
74
|
-
const Switch = createSwitch({
|
|
69
|
+
}), Switch = createSwitch({
|
|
75
70
|
Frame: SwitchFrame,
|
|
76
71
|
Thumb: SwitchThumb,
|
|
77
|
-
acceptsUnstyled:
|
|
72
|
+
acceptsUnstyled: !0
|
|
78
73
|
});
|
|
79
74
|
export {
|
|
80
75
|
Switch,
|