@tamagui/toggle-group 2.7.6 → 3.0.0-beta.637.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/Toggle.cjs +65 -130
- package/dist/cjs/Toggle.native.cjs +100 -0
- package/dist/cjs/Toggle.native.js +75 -136
- package/dist/cjs/Toggle.native.js.map +1 -1
- package/dist/cjs/ToggleGroup.cjs +158 -211
- package/dist/cjs/ToggleGroup.native.cjs +208 -0
- package/dist/cjs/ToggleGroup.native.js +173 -225
- package/dist/cjs/ToggleGroup.native.js.map +1 -1
- package/dist/cjs/context.cjs +19 -20
- package/dist/cjs/context.native.cjs +37 -0
- package/dist/cjs/context.native.js +20 -20
- package/dist/cjs/context.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -18
- package/dist/cjs/index.native.cjs +29 -0
- package/dist/cjs/index.native.js +15 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Toggle.mjs +53 -104
- package/dist/esm/Toggle.mjs.map +1 -1
- package/dist/esm/Toggle.native.js +61 -115
- package/dist/esm/Toggle.native.js.map +1 -1
- package/dist/esm/ToggleGroup.mjs +145 -188
- package/dist/esm/ToggleGroup.mjs.map +1 -1
- package/dist/esm/ToggleGroup.native.js +160 -203
- package/dist/esm/ToggleGroup.native.js.map +1 -1
- package/dist/esm/context.mjs +5 -3
- package/dist/esm/context.mjs.map +1 -1
- package/dist/esm/context.native.js +6 -4
- package/dist/esm/context.native.js.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.mjs +4 -3
- package/dist/esm/index.native.js +4 -3
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/Toggle.mjs +53 -104
- package/dist/jsx/Toggle.mjs.map +1 -1
- package/dist/jsx/Toggle.native.cjs +100 -0
- package/dist/jsx/Toggle.native.js +75 -136
- package/dist/jsx/Toggle.native.js.map +1 -1
- package/dist/jsx/ToggleGroup.mjs +145 -188
- package/dist/jsx/ToggleGroup.mjs.map +1 -1
- package/dist/jsx/ToggleGroup.native.cjs +208 -0
- package/dist/jsx/ToggleGroup.native.js +173 -225
- package/dist/jsx/ToggleGroup.native.js.map +1 -1
- package/dist/jsx/context.mjs +5 -3
- package/dist/jsx/context.mjs.map +1 -1
- package/dist/jsx/context.native.cjs +37 -0
- package/dist/jsx/context.native.js +20 -20
- package/dist/jsx/context.native.js.map +1 -1
- package/dist/jsx/index.js +4 -3
- package/dist/jsx/index.mjs +4 -3
- package/dist/jsx/index.native.cjs +29 -0
- package/dist/jsx/index.native.js +15 -17
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +16 -15
- package/src/Toggle.tsx +27 -66
- package/src/ToggleGroup.tsx +13 -10
- package/types/Toggle.d.ts +45 -49
- package/types/Toggle.d.ts.map +1 -1
- package/types/ToggleGroup.d.ts +26 -87
- package/types/ToggleGroup.d.ts.map +1 -1
- package/types/context.d.ts +1 -1
- package/types/context.d.ts.map +1 -1
- 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/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
package/dist/cjs/Toggle.cjs
CHANGED
|
@@ -1,150 +1,85 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
6
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
12
11
|
};
|
|
13
12
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
21
20
|
};
|
|
22
|
-
var
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
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
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
22
|
var Toggle_exports = {};
|
|
35
23
|
__export(Toggle_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
Toggle: () => Toggle,
|
|
25
|
+
ToggleFrame: () => ToggleFrame
|
|
38
26
|
});
|
|
39
27
|
module.exports = __toCommonJS(Toggle_exports);
|
|
28
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
40
29
|
var import_helpers = require("@tamagui/helpers");
|
|
30
|
+
var import_size = require("@tamagui/size");
|
|
41
31
|
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
42
32
|
var import_web = require("@tamagui/web");
|
|
43
|
-
var React = __toESM(require("react"), 1);
|
|
44
33
|
var import_context = require("./context.cjs");
|
|
45
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
35
|
const NAME = "Toggle";
|
|
47
36
|
const ToggleFrame = (0, import_web.styled)(import_web.View, {
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
hoverStyle: {
|
|
97
|
-
backgroundColor: "$backgroundActive"
|
|
98
|
-
},
|
|
99
|
-
focusStyle: {
|
|
100
|
-
backgroundColor: "$backgroundActive"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
defaultVariants: {
|
|
106
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
accept: {
|
|
110
|
-
activeStyle: "style"
|
|
111
|
-
}
|
|
37
|
+
displayName: NAME,
|
|
38
|
+
render: "button",
|
|
39
|
+
context: import_context.context,
|
|
40
|
+
size: true,
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
justifyContent: "center",
|
|
43
|
+
display: "flex",
|
|
44
|
+
variants: {
|
|
45
|
+
size: {
|
|
46
|
+
number: (val) => ({
|
|
47
|
+
width: val,
|
|
48
|
+
height: val
|
|
49
|
+
}),
|
|
50
|
+
Size: (val, { tokens }) => {
|
|
51
|
+
if (!val) return;
|
|
52
|
+
const sizeToken = (0, import_size.resolveSizeToken)(val, "size");
|
|
53
|
+
const size = typeof sizeToken === "number" ? sizeToken : tokens.size[sizeToken];
|
|
54
|
+
return {
|
|
55
|
+
width: size,
|
|
56
|
+
height: size
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
defaultActiveStyle: { true: {} }
|
|
61
|
+
}
|
|
62
|
+
}, { accept: { activeStyle: "style" } });
|
|
63
|
+
const Toggle = (0, import_compose_refs.createRefComponent)(function Toggle2(props, forwardedRef) {
|
|
64
|
+
const { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;
|
|
65
|
+
const [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({
|
|
66
|
+
prop: activeProp,
|
|
67
|
+
onChange: onActiveChange,
|
|
68
|
+
defaultProp: defaultActive
|
|
69
|
+
});
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
71
|
+
theme: activeTheme ?? null,
|
|
72
|
+
"aria-pressed": active,
|
|
73
|
+
"data-state": active ? "on" : "off",
|
|
74
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
75
|
+
...active && !activeStyle && { defaultActiveStyle: true },
|
|
76
|
+
...buttonProps,
|
|
77
|
+
...active && activeStyle ? activeStyle : void 0,
|
|
78
|
+
ref: forwardedRef,
|
|
79
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, () => {
|
|
80
|
+
if (!props.disabled) {
|
|
81
|
+
setActive((prev) => !prev);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
});
|
|
112
85
|
});
|
|
113
|
-
const Toggle = React.forwardRef(function Toggle2(props, forwardedRef) {
|
|
114
|
-
const {
|
|
115
|
-
active: activeProp,
|
|
116
|
-
activeStyle,
|
|
117
|
-
defaultActive = false,
|
|
118
|
-
onActiveChange,
|
|
119
|
-
activeTheme,
|
|
120
|
-
unstyled = false,
|
|
121
|
-
...buttonProps
|
|
122
|
-
} = props;
|
|
123
|
-
const [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({
|
|
124
|
-
prop: activeProp,
|
|
125
|
-
onChange: onActiveChange,
|
|
126
|
-
defaultProp: defaultActive
|
|
127
|
-
});
|
|
128
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
129
|
-
theme: activeTheme ?? null,
|
|
130
|
-
"aria-pressed": active,
|
|
131
|
-
"data-state": active ? "on" : "off",
|
|
132
|
-
"data-disabled": props.disabled ? "" : void 0,
|
|
133
|
-
unstyled,
|
|
134
|
-
...(active && !activeStyle && !unstyled && {
|
|
135
|
-
defaultActiveStyle: true
|
|
136
|
-
}),
|
|
137
|
-
...buttonProps,
|
|
138
|
-
...(active && activeStyle && {
|
|
139
|
-
...activeStyle,
|
|
140
|
-
hoverStyle: activeStyle,
|
|
141
|
-
focusStyle: activeStyle
|
|
142
|
-
}),
|
|
143
|
-
ref: forwardedRef,
|
|
144
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, () => {
|
|
145
|
-
if (!props.disabled) {
|
|
146
|
-
setActive(prev => !prev);
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
});
|
|
150
|
-
});
|
|
@@ -0,0 +1,100 @@
|
|
|
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 Toggle_exports = {};
|
|
31
|
+
__export(Toggle_exports, {
|
|
32
|
+
Toggle: () => Toggle,
|
|
33
|
+
ToggleFrame: () => ToggleFrame
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Toggle_exports);
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
38
|
+
var import_helpers = require("@tamagui/helpers");
|
|
39
|
+
var import_size = require("@tamagui/size");
|
|
40
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
41
|
+
var import_web = require("@tamagui/web");
|
|
42
|
+
var React = __toESM(require("react"), 1);
|
|
43
|
+
var import_context = require("./context.native.js");
|
|
44
|
+
var NAME = "Toggle";
|
|
45
|
+
var ToggleFrame = (0, import_web.styled)(import_web.View, {
|
|
46
|
+
displayName: NAME,
|
|
47
|
+
render: "button",
|
|
48
|
+
context: import_context.context,
|
|
49
|
+
size: true,
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
display: "flex",
|
|
53
|
+
variants: {
|
|
54
|
+
size: {
|
|
55
|
+
number: function(val) {
|
|
56
|
+
return {
|
|
57
|
+
width: val,
|
|
58
|
+
height: val
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
Size: function(val, param) {
|
|
62
|
+
var { tokens } = param;
|
|
63
|
+
if (!val) return;
|
|
64
|
+
var sizeToken = (0, import_size.resolveSizeToken)(val, "size");
|
|
65
|
+
var size = typeof sizeToken === "number" ? sizeToken : tokens.size[sizeToken];
|
|
66
|
+
return {
|
|
67
|
+
width: size,
|
|
68
|
+
height: size
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
defaultActiveStyle: { true: {} }
|
|
73
|
+
}
|
|
74
|
+
}, { accept: { activeStyle: "style" } });
|
|
75
|
+
var Toggle = (0, import_compose_refs.createRefComponent)(function Toggle2(props, forwardedRef) {
|
|
76
|
+
var { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;
|
|
77
|
+
var [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({
|
|
78
|
+
prop: activeProp,
|
|
79
|
+
onChange: onActiveChange,
|
|
80
|
+
defaultProp: defaultActive
|
|
81
|
+
});
|
|
82
|
+
var _props_onPress;
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
84
|
+
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
85
|
+
"aria-pressed": active,
|
|
86
|
+
"data-state": active ? "on" : "off",
|
|
87
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
88
|
+
...active && !activeStyle && { defaultActiveStyle: true },
|
|
89
|
+
...buttonProps,
|
|
90
|
+
...active && activeStyle ? activeStyle : void 0,
|
|
91
|
+
ref: forwardedRef,
|
|
92
|
+
onPress: (0, import_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {
|
|
93
|
+
if (!props.disabled) {
|
|
94
|
+
setActive(function(prev) {
|
|
95
|
+
return !prev;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -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,157 +8,95 @@ 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 Toggle_exports = {};
|
|
37
31
|
__export(Toggle_exports, {
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
Toggle: () => Toggle,
|
|
33
|
+
ToggleFrame: () => ToggleFrame
|
|
40
34
|
});
|
|
41
35
|
module.exports = __toCommonJS(Toggle_exports);
|
|
42
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
43
38
|
var import_helpers = require("@tamagui/helpers");
|
|
39
|
+
var import_size = require("@tamagui/size");
|
|
44
40
|
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
45
41
|
var import_web = require("@tamagui/web");
|
|
46
42
|
var React = __toESM(require("react"), 1);
|
|
47
43
|
var import_context = require("./context.native.js");
|
|
48
44
|
var NAME = "Toggle";
|
|
49
45
|
var ToggleFrame = (0, import_web.styled)(import_web.View, {
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
focusStyle: {
|
|
105
|
-
backgroundColor: "$backgroundActive"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
defaultVariants: {
|
|
111
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
accept: {
|
|
115
|
-
activeStyle: "style"
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
var Toggle = /* @__PURE__ */React.forwardRef(function Toggle2(props, forwardedRef) {
|
|
119
|
-
var {
|
|
120
|
-
active: activeProp,
|
|
121
|
-
activeStyle,
|
|
122
|
-
defaultActive = false,
|
|
123
|
-
onActiveChange,
|
|
124
|
-
activeTheme,
|
|
125
|
-
unstyled = false,
|
|
126
|
-
...buttonProps
|
|
127
|
-
} = props;
|
|
128
|
-
var [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({
|
|
129
|
-
prop: activeProp,
|
|
130
|
-
onChange: onActiveChange,
|
|
131
|
-
defaultProp: defaultActive
|
|
132
|
-
});
|
|
133
|
-
var _props_onPress;
|
|
134
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
135
|
-
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
136
|
-
"aria-pressed": active,
|
|
137
|
-
"data-state": active ? "on" : "off",
|
|
138
|
-
"data-disabled": props.disabled ? "" : void 0,
|
|
139
|
-
unstyled,
|
|
140
|
-
...(active && !activeStyle && !unstyled && {
|
|
141
|
-
defaultActiveStyle: true
|
|
142
|
-
}),
|
|
143
|
-
...buttonProps,
|
|
144
|
-
// spread activeStyle after buttonProps so it wins when active: a styled()
|
|
145
|
-
// variant (e.g. a resting `backgroundColor`) forwards that value as a plain
|
|
146
|
-
// prop into buttonProps, which would otherwise clobber the activeStyle merge
|
|
147
|
-
// on overlapping keys and leave the active item stuck at its resting style.
|
|
148
|
-
...(active && activeStyle && {
|
|
149
|
-
...activeStyle,
|
|
150
|
-
hoverStyle: activeStyle,
|
|
151
|
-
focusStyle: activeStyle
|
|
152
|
-
}),
|
|
153
|
-
ref: forwardedRef,
|
|
154
|
-
onPress: (0, import_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function () {
|
|
155
|
-
if (!props.disabled) {
|
|
156
|
-
setActive(function (prev) {
|
|
157
|
-
return !prev;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
});
|
|
46
|
+
displayName: NAME,
|
|
47
|
+
render: "button",
|
|
48
|
+
context: import_context.context,
|
|
49
|
+
size: true,
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
display: "flex",
|
|
53
|
+
variants: {
|
|
54
|
+
size: {
|
|
55
|
+
number: function(val) {
|
|
56
|
+
return {
|
|
57
|
+
width: val,
|
|
58
|
+
height: val
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
Size: function(val, param) {
|
|
62
|
+
var { tokens } = param;
|
|
63
|
+
if (!val) return;
|
|
64
|
+
var sizeToken = (0, import_size.resolveSizeToken)(val, "size");
|
|
65
|
+
var size = typeof sizeToken === "number" ? sizeToken : tokens.size[sizeToken];
|
|
66
|
+
return {
|
|
67
|
+
width: size,
|
|
68
|
+
height: size
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
defaultActiveStyle: { true: {} }
|
|
73
|
+
}
|
|
74
|
+
}, { accept: { activeStyle: "style" } });
|
|
75
|
+
var Toggle = (0, import_compose_refs.createRefComponent)(function Toggle2(props, forwardedRef) {
|
|
76
|
+
var { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;
|
|
77
|
+
var [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({
|
|
78
|
+
prop: activeProp,
|
|
79
|
+
onChange: onActiveChange,
|
|
80
|
+
defaultProp: defaultActive
|
|
81
|
+
});
|
|
82
|
+
var _props_onPress;
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
84
|
+
theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,
|
|
85
|
+
"aria-pressed": active,
|
|
86
|
+
"data-state": active ? "on" : "off",
|
|
87
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
88
|
+
...active && !activeStyle && { defaultActiveStyle: true },
|
|
89
|
+
...buttonProps,
|
|
90
|
+
...active && activeStyle ? activeStyle : void 0,
|
|
91
|
+
ref: forwardedRef,
|
|
92
|
+
onPress: (0, import_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {
|
|
93
|
+
if (!props.disabled) {
|
|
94
|
+
setActive(function(prev) {
|
|
95
|
+
return !prev;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
162
100
|
});
|
|
101
|
+
|
|
163
102
|
//# sourceMappingURL=Toggle.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Toggle.native.js","names":[],"sources":["cjs/Toggle.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 for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar Toggle_exports = {};\n__export(Toggle_exports, {\n Toggle: () => Toggle,\n ToggleFrame: () => ToggleFrame\n});\nmodule.exports = __toCommonJS(Toggle_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_helpers = require(\"@tamagui/helpers\");\nvar import_size = require(\"@tamagui/size\");\nvar import_use_controllable_state = require(\"@tamagui/use-controllable-state\");\nvar import_web = require(\"@tamagui/web\");\nvar React = __toESM(require(\"react\"), 1);\nvar import_context = require(\"./context\");\nvar NAME = \"Toggle\";\nvar ToggleFrame = (0, import_web.styled)(import_web.View, {\n displayName: NAME,\n render: \"button\",\n context: import_context.context,\n size: true,\n alignItems: \"center\",\n justifyContent: \"center\",\n display: \"flex\",\n variants: {\n size: {\n number: function(val) {\n return {\n width: val,\n height: val\n };\n },\n Size: function(val, param) {\n var { tokens } = param;\n if (!val) return;\n var sizeToken = (0, import_size.resolveSizeToken)(val, \"size\");\n var size = typeof sizeToken === \"number\" ? sizeToken : tokens.size[sizeToken];\n return {\n width: size,\n height: size\n };\n }\n },\n defaultActiveStyle: {\n true: {}\n }\n }\n}, {\n accept: {\n activeStyle: \"style\"\n }\n});\nvar Toggle = (0, import_compose_refs.createRefComponent)(function Toggle2(props, forwardedRef) {\n var { active: activeProp, activeStyle, defaultActive = false, onActiveChange, activeTheme, ...buttonProps } = props;\n var [active = false, setActive] = (0, import_use_controllable_state.useControllableState)({\n prop: activeProp,\n onChange: onActiveChange,\n defaultProp: defaultActive\n });\n var _props_onPress;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleFrame, {\n theme: activeTheme !== null && activeTheme !== void 0 ? activeTheme : null,\n \"aria-pressed\": active,\n \"data-state\": active ? \"on\" : \"off\",\n \"data-disabled\": props.disabled ? \"\" : void 0,\n ...active && !activeStyle && {\n defaultActiveStyle: true\n },\n ...buttonProps,\n ...active && activeStyle ? activeStyle : void 0,\n ref: forwardedRef,\n onPress: (0, import_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function() {\n if (!props.disabled) {\n setActive(function(prev) {\n return !prev;\n });\n }\n })\n });\n});\n//# sourceMappingURL=Toggle.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAA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