@tamagui/switch-headless 2.7.7 → 3.0.0-beta.643.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/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useSwitch.cjs +92 -110
- package/dist/cjs/useSwitch.native.cjs +51 -0
- package/dist/cjs/useSwitch.native.js +28 -37
- package/dist/cjs/useSwitch.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/esm/useSwitch.mjs +76 -84
- package/dist/esm/useSwitch.mjs.map +1 -1
- package/dist/esm/useSwitch.native.js +11 -12
- package/dist/esm/useSwitch.native.js.map +1 -1
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +21 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useSwitch.mjs +76 -84
- package/dist/jsx/useSwitch.mjs.map +1 -1
- package/dist/jsx/useSwitch.native.cjs +51 -0
- package/dist/jsx/useSwitch.native.js +28 -37
- package/dist/jsx/useSwitch.native.js.map +1 -1
- package/package.json +8 -8
- package/types/useSwitch.d.ts +5 -5
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
15
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
17
|
var index_exports = {};
|
|
19
18
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./useSwitch.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./useSwitch.cjs"), module.exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./useSwitch.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
var index_exports = {};
|
|
21
20
|
module.exports = __toCommonJS(index_exports);
|
|
22
21
|
__reExport(index_exports, require("./useSwitch.native.js"), module.exports);
|
|
22
|
+
|
|
23
23
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./useSwitch\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,uBAAa,GAAG,OAAO,OAAO"}
|
package/dist/cjs/useSwitch.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,36 +6,27 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var useSwitch_exports = {};
|
|
35
|
-
__export(useSwitch_exports, {
|
|
36
|
-
useSwitch: () => useSwitch
|
|
37
|
-
});
|
|
29
|
+
__export(useSwitch_exports, { useSwitch: () => useSwitch });
|
|
38
30
|
module.exports = __toCommonJS(useSwitch_exports);
|
|
39
31
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
32
|
var import_constants = require("@tamagui/constants");
|
|
@@ -44,91 +36,81 @@ var import_use_previous = require("@tamagui/use-previous");
|
|
|
44
36
|
var React = __toESM(require("react"), 1);
|
|
45
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
38
|
function getState(checked) {
|
|
47
|
-
|
|
39
|
+
return checked ? "checked" : "unchecked";
|
|
48
40
|
}
|
|
49
|
-
const BubbleInput = props => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
margin: 0
|
|
83
|
-
}
|
|
84
|
-
});
|
|
41
|
+
const BubbleInput = (props) => {
|
|
42
|
+
const { control, checked, bubbles = true, ...inputProps } = props;
|
|
43
|
+
const ref = React.useRef(null);
|
|
44
|
+
const prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const input = ref.current;
|
|
47
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
48
|
+
const setChecked = Object.getOwnPropertyDescriptor(inputProto, "checked").set;
|
|
49
|
+
if (prevChecked !== checked && setChecked) {
|
|
50
|
+
const event = new Event("click", { bubbles });
|
|
51
|
+
setChecked.call(input, checked);
|
|
52
|
+
input.dispatchEvent(event);
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
prevChecked,
|
|
56
|
+
checked,
|
|
57
|
+
bubbles
|
|
58
|
+
]);
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
60
|
+
type: "checkbox",
|
|
61
|
+
"aria-hidden": true,
|
|
62
|
+
defaultChecked: checked,
|
|
63
|
+
...inputProps,
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
ref,
|
|
66
|
+
style: {
|
|
67
|
+
...props.style,
|
|
68
|
+
position: "absolute",
|
|
69
|
+
pointerEvents: "none",
|
|
70
|
+
opacity: 0,
|
|
71
|
+
margin: 0
|
|
72
|
+
}
|
|
73
|
+
});
|
|
85
74
|
};
|
|
86
75
|
function useSwitch(props, [checked, setChecked], ref) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
style: {
|
|
129
|
-
transform: "translateX(-100%)"
|
|
130
|
-
}
|
|
131
|
-
}) : null
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
76
|
+
{
|
|
77
|
+
const { disabled, name, value, required } = props;
|
|
78
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
79
|
+
const [button, setButton] = React.useState(null);
|
|
80
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(ref, setButton);
|
|
81
|
+
const isFormControl = import_constants.isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
82
|
+
const labelId = (0, import_label.useLabelContext)(button);
|
|
83
|
+
const ariaLabelledBy = props["aria-labelledby"] || props.labeledBy || labelId;
|
|
84
|
+
return {
|
|
85
|
+
switchProps: {
|
|
86
|
+
role: "switch",
|
|
87
|
+
"aria-checked": checked,
|
|
88
|
+
...import_constants.isWeb ? {
|
|
89
|
+
tabIndex: disabled ? void 0 : 0,
|
|
90
|
+
"data-state": getState(checked),
|
|
91
|
+
"data-disabled": disabled ? "" : void 0,
|
|
92
|
+
disabled
|
|
93
|
+
} : {},
|
|
94
|
+
"aria-labelledby": ariaLabelledBy,
|
|
95
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, (event) => {
|
|
96
|
+
setChecked((prevChecked) => !prevChecked);
|
|
97
|
+
if (import_constants.isWeb && isFormControl) {
|
|
98
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
99
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
switchRef: composedRefs,
|
|
104
|
+
bubbleInput: import_constants.isWeb && isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BubbleInput, {
|
|
105
|
+
control: button,
|
|
106
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
107
|
+
name,
|
|
108
|
+
value,
|
|
109
|
+
checked,
|
|
110
|
+
required,
|
|
111
|
+
disabled,
|
|
112
|
+
style: { transform: "translateX(-100%)" }
|
|
113
|
+
}) : null
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var useSwitch_exports = {};
|
|
31
|
+
__export(useSwitch_exports, { useSwitch: () => useSwitch });
|
|
32
|
+
module.exports = __toCommonJS(useSwitch_exports);
|
|
33
|
+
require("react/jsx-runtime");
|
|
34
|
+
require("@tamagui/compose-refs");
|
|
35
|
+
require("@tamagui/constants");
|
|
36
|
+
require("@tamagui/helpers");
|
|
37
|
+
require("@tamagui/label");
|
|
38
|
+
require("@tamagui/use-previous");
|
|
39
|
+
__toESM(require("react"), 1);
|
|
40
|
+
function useSwitch(props, param, ref) {
|
|
41
|
+
var [checked, setChecked] = param;
|
|
42
|
+
return {
|
|
43
|
+
switchProps: { onPress() {
|
|
44
|
+
setChecked(function(prevChecked) {
|
|
45
|
+
return !prevChecked;
|
|
46
|
+
});
|
|
47
|
+
} },
|
|
48
|
+
switchRef: ref,
|
|
49
|
+
bubbleInput: null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,36 +8,27 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
23
24
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
32
28
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
30
|
var useSwitch_exports = {};
|
|
37
|
-
__export(useSwitch_exports, {
|
|
38
|
-
useSwitch: () => useSwitch
|
|
39
|
-
});
|
|
31
|
+
__export(useSwitch_exports, { useSwitch: () => useSwitch });
|
|
40
32
|
module.exports = __toCommonJS(useSwitch_exports);
|
|
41
33
|
require("react/jsx-runtime");
|
|
42
34
|
require("@tamagui/compose-refs");
|
|
@@ -46,17 +38,16 @@ require("@tamagui/label");
|
|
|
46
38
|
require("@tamagui/use-previous");
|
|
47
39
|
__toESM(require("react"), 1);
|
|
48
40
|
function useSwitch(props, param, ref) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
bubbleInput: null
|
|
60
|
-
};
|
|
41
|
+
var [checked, setChecked] = param;
|
|
42
|
+
return {
|
|
43
|
+
switchProps: { onPress() {
|
|
44
|
+
setChecked(function(prevChecked) {
|
|
45
|
+
return !prevChecked;
|
|
46
|
+
});
|
|
47
|
+
} },
|
|
48
|
+
switchRef: ref,
|
|
49
|
+
bubbleInput: null
|
|
50
|
+
};
|
|
61
51
|
}
|
|
52
|
+
|
|
62
53
|
//# sourceMappingURL=useSwitch.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useSwitch.native.js","names":[],"sources":["cjs/useSwitch.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n\t// If the importer is in node compatibility mode or this is not an ESM\n\t// file that has been converted to a CommonJS file using a Babel-\n\t// compatible transform (i.e. \"__esModule\" has not been set), then set\n\t// \"default\" to the CommonJS \"module.exports\" for node compatibility.\n\tisNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\t\tvalue: mod,\n\t\tenumerable: true\n\t}) : target,\n\tmod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useSwitch_exports = {};\n__export(useSwitch_exports, { useSwitch: () => useSwitch });\nmodule.exports = __toCommonJS(useSwitch_exports);\nrequire(\"react/jsx-runtime\");\nrequire(\"@tamagui/compose-refs\");\nrequire(\"@tamagui/constants\");\nrequire(\"@tamagui/helpers\");\nrequire(\"@tamagui/label\");\nrequire(\"@tamagui/use-previous\");\n__toESM(require(\"react\"), 1);\nfunction useSwitch(props, param, ref) {\n\tvar [checked, setChecked] = param;\n\treturn {\n\t\tswitchProps: { onPress() {\n\t\t\tsetChecked(function(prevChecked) {\n\t\t\t\treturn !prevChecked;\n\t\t\t});\n\t\t} },\n\t\tswitchRef: ref,\n\t\tbubbleInput: null\n\t};\n}\n//# sourceMappingURL=useSwitch.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKpG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CACpE,OAAO;CACP,YAAY;AACb,CAAC,IAAI,QACL,GACD;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,oBAAoB,CAAC;AACzB,SAAS,mBAAmB,EAAE,iBAAiB,UAAU,CAAC;AAC1D,OAAO,UAAU,aAAa,iBAAiB;AAC/C,QAAQ,mBAAmB;AAC3B,QAAQ,uBAAuB;AAC/B,QAAQ,oBAAoB;AAC5B,QAAQ,kBAAkB;AAC1B,QAAQ,gBAAgB;AACxB,QAAQ,uBAAuB;AAC/B,QAAQ,QAAQ,OAAO,GAAG,CAAC;AAC3B,SAAS,UAAU,OAAO,OAAO,KAAK;CACrC,IAAI,CAAC,SAAS,cAAc;CAC5B,OAAO;EACN,aAAa,EAAE,UAAU;GACxB,WAAW,SAAS,aAAa;IAChC,OAAO,CAAC;GACT,CAAC;EACF,EAAE;EACF,WAAW;EACX,aAAa;CACd;AACD"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./useSwitch.mjs"
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./useSwitch.mjs"
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./useSwitch.mjs"
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from "./useSwitch.mjs"
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./useSwitch.native.js"
|
|
2
|
-
//# sourceMappingURL=index.native.js.map
|
|
1
|
+
export * from "./useSwitch.native.js"
|