@hanzogui/toggle-group 3.0.2 → 7.3.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.
Files changed (53) hide show
  1. package/LICENSE +40 -19
  2. package/dist/cjs/Toggle.cjs +129 -124
  3. package/dist/cjs/Toggle.native.js +132 -127
  4. package/dist/cjs/Toggle.native.js.map +1 -1
  5. package/dist/cjs/ToggleGroup.cjs +218 -202
  6. package/dist/cjs/ToggleGroup.native.js +232 -222
  7. package/dist/cjs/ToggleGroup.native.js.map +1 -1
  8. package/dist/cjs/context.cjs +20 -16
  9. package/dist/cjs/context.native.js +20 -18
  10. package/dist/cjs/context.native.js.map +1 -1
  11. package/dist/cjs/index.cjs +13 -11
  12. package/dist/cjs/index.native.js +13 -11
  13. package/dist/cjs/index.native.js.map +1 -1
  14. package/dist/cjs/types.cjs +7 -5
  15. package/dist/cjs/types.native.js +7 -5
  16. package/dist/cjs/types.native.js.map +1 -1
  17. package/dist/esm/Toggle.mjs +98 -95
  18. package/dist/esm/Toggle.mjs.map +1 -1
  19. package/dist/esm/Toggle.native.js +102 -99
  20. package/dist/esm/Toggle.native.js.map +1 -1
  21. package/dist/esm/ToggleGroup.mjs +182 -168
  22. package/dist/esm/ToggleGroup.mjs.map +1 -1
  23. package/dist/esm/ToggleGroup.native.js +197 -189
  24. package/dist/esm/ToggleGroup.native.js.map +1 -1
  25. package/dist/esm/context.mjs +6 -4
  26. package/dist/esm/context.mjs.map +1 -1
  27. package/dist/esm/context.native.js +6 -6
  28. package/dist/esm/context.native.js.map +1 -1
  29. package/dist/jsx/Toggle.mjs +98 -95
  30. package/dist/jsx/Toggle.mjs.map +1 -1
  31. package/dist/jsx/Toggle.native.js +132 -127
  32. package/dist/jsx/Toggle.native.js.map +1 -1
  33. package/dist/jsx/ToggleGroup.mjs +182 -168
  34. package/dist/jsx/ToggleGroup.mjs.map +1 -1
  35. package/dist/jsx/ToggleGroup.native.js +232 -222
  36. package/dist/jsx/ToggleGroup.native.js.map +1 -1
  37. package/dist/jsx/context.mjs +6 -4
  38. package/dist/jsx/context.mjs.map +1 -1
  39. package/dist/jsx/context.native.js +20 -18
  40. package/dist/jsx/context.native.js.map +1 -1
  41. package/dist/jsx/index.native.js +13 -11
  42. package/dist/jsx/types.native.js +7 -5
  43. package/package.json +22 -19
  44. package/src/Toggle.tsx +1 -1
  45. package/types/Toggle.d.ts +17 -17
  46. package/types/Toggle.d.ts.map +1 -0
  47. package/types/ToggleGroup.d.ts +40 -40
  48. package/types/ToggleGroup.d.ts.map +1 -0
  49. package/types/context.d.ts +1 -1
  50. package/types/context.d.ts.map +1 -0
  51. package/types/index.d.ts.map +1 -0
  52. package/types/types.d.ts +1 -1
  53. package/types/types.d.ts.map +1 -0
package/LICENSE CHANGED
@@ -1,21 +1,42 @@
1
- MIT License
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026-present, Hanzo AI, Inc.
4
+
5
+ Portions of this software are derived from upstream code originally licensed under
6
+ the MIT License, with the following copyright notices retained per its terms:
2
7
 
3
8
  Copyright (c) 2020 Nate Wienert
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ Copyright (c) 2015-present, Nicolas Gallagher.
10
+ Copyright (c) 2015-present, Facebook, Inc.
11
+ Copyright (c) 2021 Radix
12
+ Copyright (c) 2017 Carmelo Pullara
13
+ Copyright (c) 2018 Framer B.V.
14
+ Copyright (c) 2022 WorkOS
15
+
16
+ All rights reserved.
17
+
18
+ Redistribution and use in source and binary forms, with or without
19
+ modification, are permitted provided that the following conditions are met:
20
+
21
+ 1. Redistributions of source code must retain the above copyright notice, this
22
+ list of conditions and the following disclaimer.
23
+
24
+ 2. Redistributions in binary form must reproduce the above copyright notice,
25
+ this list of conditions and the following disclaimer in the documentation
26
+ and/or other materials provided with the distribution.
27
+
28
+ 3. Neither the name of the copyright holder nor the names of its contributors
29
+ may be used to endorse or promote products derived from this software
30
+ without specific prior written permission.
31
+
32
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
36
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
+ POSSIBILITY OF SUCH DAMAGE.
@@ -2,144 +2,149 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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);
32
34
  var Toggle_exports = {};
33
35
  __export(Toggle_exports, {
34
36
  Toggle: () => Toggle,
35
37
  ToggleFrame: () => ToggleFrame
36
38
  });
37
39
  module.exports = __toCommonJS(Toggle_exports);
38
- var import_gui_helpers = require("@hanzogui/helpers"),
39
- import_gui_use_controllable_state = require("@hanzogui/use-controllable-state"),
40
- import_gui_web = require("@hanzogui/web"),
41
- React = __toESM(require("react"), 1),
42
- import_context = require("./context.cjs"),
43
- import_jsx_runtime = require("react/jsx-runtime");
44
- const NAME = "Toggle",
45
- ToggleFrame = (0, import_gui_web.styled)(import_gui_web.View, {
46
- name: NAME,
47
- render: "button",
48
- context: import_context.context,
49
- variants: {
50
- unstyled: {
51
- false: {
52
- size: "$true",
53
- alignItems: "center",
54
- justifyContent: "center",
55
- display: "flex",
56
- backgroundColor: "$background",
57
- borderColor: "$borderColor",
58
- borderWidth: 1,
59
- margin: -1,
60
- hoverStyle: {
61
- backgroundColor: "$backgroundHover",
62
- borderColor: "$borderColorHover"
63
- },
64
- pressStyle: {
65
- backgroundColor: "$backgroundPress",
66
- borderColor: "$borderColorPress"
67
- },
68
- focusVisibleStyle: {
69
- outlineColor: "$outlineColor",
70
- outlineWidth: 2,
71
- outlineStyle: "solid",
72
- zIndex: 10
73
- }
40
+ var import_helpers = require("@hanzogui/helpers");
41
+ var import_use_controllable_state = require("@hanzogui/use-controllable-state");
42
+ var import_web = require("@hanzogui/web");
43
+ var React = __toESM(require("react"), 1);
44
+ var import_context = require("./context.cjs");
45
+ var import_jsx_runtime = require("react/jsx-runtime");
46
+ const NAME = "Toggle";
47
+ const ToggleFrame = (0, import_web.styled)(import_web.View, {
48
+ name: NAME,
49
+ render: "button",
50
+ context: import_context.context,
51
+ variants: {
52
+ unstyled: {
53
+ false: {
54
+ size: "$true",
55
+ alignItems: "center",
56
+ justifyContent: "center",
57
+ display: "flex",
58
+ backgroundColor: "$background",
59
+ borderColor: "$borderColor",
60
+ borderWidth: 1,
61
+ margin: -1,
62
+ hoverStyle: {
63
+ backgroundColor: "$backgroundHover",
64
+ borderColor: "$borderColorHover"
65
+ },
66
+ pressStyle: {
67
+ backgroundColor: "$backgroundPress",
68
+ borderColor: "$borderColorPress"
69
+ },
70
+ focusVisibleStyle: {
71
+ outlineColor: "$outlineColor",
72
+ outlineWidth: 2,
73
+ outlineStyle: "solid",
74
+ zIndex: 10
74
75
  }
76
+ }
77
+ },
78
+ size: {
79
+ "...size": (val, {
80
+ tokens
81
+ }) => {
82
+ if (!val) return;
83
+ return {
84
+ width: tokens.size[val],
85
+ height: tokens.size[val]
86
+ };
75
87
  },
76
- size: {
77
- "...size": (val, {
78
- tokens
79
- }) => {
80
- if (val) return {
81
- width: tokens.size[val],
82
- height: tokens.size[val]
83
- };
88
+ ":number": val => ({
89
+ width: val,
90
+ height: val
91
+ })
92
+ },
93
+ defaultActiveStyle: {
94
+ true: {
95
+ backgroundColor: "$backgroundActive",
96
+ hoverStyle: {
97
+ backgroundColor: "$backgroundActive"
84
98
  },
85
- ":number": val => ({
86
- width: val,
87
- height: val
88
- })
89
- },
90
- defaultActiveStyle: {
91
- true: {
92
- backgroundColor: "$backgroundActive",
93
- hoverStyle: {
94
- backgroundColor: "$backgroundActive"
95
- },
96
- focusStyle: {
97
- backgroundColor: "$backgroundActive"
98
- }
99
+ focusStyle: {
100
+ backgroundColor: "$backgroundActive"
99
101
  }
100
102
  }
101
- },
102
- defaultVariants: {
103
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
104
103
  }
105
- }, {
106
- accept: {
107
- activeStyle: "style"
108
- }
109
- }),
110
- Toggle = React.forwardRef(function (props, forwardedRef) {
111
- const {
112
- active: activeProp,
113
- activeStyle,
114
- defaultActive = !1,
115
- onActiveChange,
116
- activeTheme,
117
- unstyled = !1,
118
- ...buttonProps
119
- } = props,
120
- [active = !1, setActive] = (0, import_gui_use_controllable_state.useControllableState)({
121
- prop: activeProp,
122
- onChange: onActiveChange,
123
- defaultProp: defaultActive
124
- });
125
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleFrame, {
126
- theme: activeTheme ?? null,
127
- "aria-pressed": active,
128
- "data-state": active ? "on" : "off",
129
- "data-disabled": props.disabled ? "" : void 0,
130
- unstyled,
131
- ...(active && !activeStyle && !unstyled && {
132
- defaultActiveStyle: !0
133
- }),
134
- ...(active && activeStyle && {
135
- ...activeStyle,
136
- hoverStyle: activeStyle,
137
- focusStyle: activeStyle
138
- }),
139
- ...buttonProps,
140
- ref: forwardedRef,
141
- onPress: (0, import_gui_helpers.composeEventHandlers)(props.onPress ?? void 0, () => {
142
- props.disabled || setActive(prev => !prev);
143
- })
144
- });
145
- });
104
+ },
105
+ defaultVariants: {
106
+ unstyled: process.env.GUI_HEADLESS === "1"
107
+ }
108
+ }, {
109
+ accept: {
110
+ activeStyle: "style"
111
+ }
112
+ });
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
+ ...(active && activeStyle && {
138
+ ...activeStyle,
139
+ hoverStyle: activeStyle,
140
+ focusStyle: activeStyle
141
+ }),
142
+ ...buttonProps,
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
+ });
@@ -4,151 +4,156 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
18
  get: () => from[key],
18
19
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
20
  });
20
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
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
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
34
36
  var Toggle_exports = {};
35
37
  __export(Toggle_exports, {
36
38
  Toggle: () => Toggle,
37
39
  ToggleFrame: () => ToggleFrame
38
40
  });
39
41
  module.exports = __toCommonJS(Toggle_exports);
40
- var import_jsx_runtime = require("react/jsx-runtime"),
41
- import_gui_helpers = require("@hanzogui/helpers"),
42
- import_gui_use_controllable_state = require("@hanzogui/use-controllable-state"),
43
- import_gui_web = require("@hanzogui/web"),
44
- React = __toESM(require("react"), 1),
45
- import_context = require("./context.native.js"),
46
- NAME = "Toggle",
47
- ToggleFrame = (0, import_gui_web.styled)(import_gui_web.View, {
48
- name: NAME,
49
- render: "button",
50
- context: import_context.context,
51
- variants: {
52
- unstyled: {
53
- false: {
54
- size: "$true",
55
- alignItems: "center",
56
- justifyContent: "center",
57
- display: "flex",
58
- backgroundColor: "$background",
59
- borderColor: "$borderColor",
60
- borderWidth: 1,
61
- margin: -1,
62
- hoverStyle: {
63
- backgroundColor: "$backgroundHover",
64
- borderColor: "$borderColorHover"
65
- },
66
- pressStyle: {
67
- backgroundColor: "$backgroundPress",
68
- borderColor: "$borderColorPress"
69
- },
70
- focusVisibleStyle: {
71
- outlineColor: "$outlineColor",
72
- outlineWidth: 2,
73
- outlineStyle: "solid",
74
- zIndex: 10
75
- }
76
- }
77
- },
78
- size: {
79
- "...size": function (val, param) {
80
- var {
81
- tokens
82
- } = param;
83
- if (val) return {
84
- width: tokens.size[val],
85
- height: tokens.size[val]
86
- };
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var import_helpers = require("@hanzogui/helpers");
44
+ var import_use_controllable_state = require("@hanzogui/use-controllable-state");
45
+ var import_web = require("@hanzogui/web");
46
+ var React = __toESM(require("react"), 1);
47
+ var import_context = require("./context.native.js");
48
+ var NAME = "Toggle";
49
+ var ToggleFrame = (0, import_web.styled)(import_web.View, {
50
+ name: NAME,
51
+ render: "button",
52
+ context: import_context.context,
53
+ variants: {
54
+ unstyled: {
55
+ false: {
56
+ size: "$true",
57
+ alignItems: "center",
58
+ justifyContent: "center",
59
+ display: "flex",
60
+ backgroundColor: "$background",
61
+ borderColor: "$borderColor",
62
+ borderWidth: 1,
63
+ margin: -1,
64
+ hoverStyle: {
65
+ backgroundColor: "$backgroundHover",
66
+ borderColor: "$borderColorHover"
87
67
  },
88
- ":number": function (val) {
89
- return {
90
- width: val,
91
- height: val
92
- };
68
+ pressStyle: {
69
+ backgroundColor: "$backgroundPress",
70
+ borderColor: "$borderColorPress"
71
+ },
72
+ focusVisibleStyle: {
73
+ outlineColor: "$outlineColor",
74
+ outlineWidth: 2,
75
+ outlineStyle: "solid",
76
+ zIndex: 10
93
77
  }
78
+ }
79
+ },
80
+ size: {
81
+ "...size": function (val, param) {
82
+ var {
83
+ tokens
84
+ } = param;
85
+ if (!val) return;
86
+ return {
87
+ width: tokens.size[val],
88
+ height: tokens.size[val]
89
+ };
94
90
  },
95
- defaultActiveStyle: {
96
- true: {
97
- backgroundColor: "$backgroundActive",
98
- hoverStyle: {
99
- backgroundColor: "$backgroundActive"
100
- },
101
- focusStyle: {
102
- backgroundColor: "$backgroundActive"
103
- }
104
- }
91
+ ":number": function (val) {
92
+ return {
93
+ width: val,
94
+ height: val
95
+ };
105
96
  }
106
97
  },
107
- defaultVariants: {
108
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
109
- }
110
- }, {
111
- accept: {
112
- activeStyle: "style"
98
+ defaultActiveStyle: {
99
+ true: {
100
+ backgroundColor: "$backgroundActive",
101
+ hoverStyle: {
102
+ backgroundColor: "$backgroundActive"
103
+ },
104
+ focusStyle: {
105
+ backgroundColor: "$backgroundActive"
106
+ }
107
+ }
113
108
  }
114
- }),
115
- Toggle = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
116
- var {
117
- active: activeProp,
118
- activeStyle,
119
- defaultActive = !1,
120
- onActiveChange,
121
- activeTheme,
122
- unstyled = !1,
123
- ...buttonProps
124
- } = props,
125
- [active = !1, setActive] = (0, import_gui_use_controllable_state.useControllableState)({
126
- prop: activeProp,
127
- onChange: onActiveChange,
128
- defaultProp: defaultActive
129
- }),
130
- _props_onPress;
131
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleFrame, {
132
- theme: activeTheme ?? null,
133
- "aria-pressed": active,
134
- "data-state": active ? "on" : "off",
135
- "data-disabled": props.disabled ? "" : void 0,
136
- unstyled,
137
- ...(active && !activeStyle && !unstyled && {
138
- defaultActiveStyle: !0
139
- }),
140
- ...(active && activeStyle && {
141
- ...activeStyle,
142
- hoverStyle: activeStyle,
143
- focusStyle: activeStyle
144
- }),
145
- ...buttonProps,
146
- ref: forwardedRef,
147
- onPress: (0, import_gui_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function () {
148
- props.disabled || setActive(function (prev) {
109
+ },
110
+ defaultVariants: {
111
+ unstyled: process.env.GUI_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
+ ...(active && activeStyle && {
144
+ ...activeStyle,
145
+ hoverStyle: activeStyle,
146
+ focusStyle: activeStyle
147
+ }),
148
+ ...buttonProps,
149
+ ref: forwardedRef,
150
+ onPress: (0, import_helpers.composeEventHandlers)((_props_onPress = props.onPress) !== null && _props_onPress !== void 0 ? _props_onPress : void 0, function () {
151
+ if (!props.disabled) {
152
+ setActive(function (prev) {
149
153
  return !prev;
150
154
  });
151
- })
152
- });
155
+ }
156
+ })
153
157
  });
158
+ });
154
159
  //# sourceMappingURL=Toggle.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Toggle_exports","__export","Toggle","ToggleFrame","module","exports","import_jsx_runtime","require","import_gui_helpers","import_gui_use_controllable_state","import_gui_web","React","__toESM","import_context","NAME","styled","View","name","render","context","variants","unstyled","false","size","alignItems","justifyContent","display","backgroundColor","borderColor","borderWidth","margin","hoverStyle","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","...size","val","param","tokens","width","height",":number","defaultActiveStyle","true","focusStyle","defaultVariants","process","env","HANZO_GUI_HEADLESS","accept","activeStyle","forwardRef","props","forwardedRef","active","activeProp","defaultActive","onActiveChange","activeTheme","buttonProps","setActive","useControllableState","prop","onChange","defaultProp","_props_onPress","jsx","theme","disabled","ref","onPress","composeEventHandlers","prev"],"sources":["../../src/Toggle.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;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AAAb,KACrC,CAAAgB,QAAA,IAAAR,SAAA,WAAAY,IAAA;UACC,OAAI,CAAAA,IAAA;QAEU;MACS;IACtB;EAEe","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Toggle_exports","__export","Toggle","ToggleFrame","module","exports","import_jsx_runtime","require","import_helpers","import_use_controllable_state","import_web","React","__toESM","import_context","NAME","styled","View","name","render","context","variants","unstyled","false","size","alignItems","justifyContent","display","backgroundColor","borderColor","borderWidth","margin","hoverStyle","pressStyle","focusVisibleStyle","outlineColor","outlineWidth","outlineStyle","zIndex","...size","val","param","tokens","width","height",":number","defaultActiveStyle","true","focusStyle","defaultVariants","process","env","GUI_HEADLESS","accept","activeStyle","forwardRef","Toggle2","props","forwardedRef","active","activeProp","defaultActive","onActiveChange","activeTheme","buttonProps","setActive","useControllableState","prop","onChange","defaultProp","_props_onPress","jsx","theme","disabled","ref","onPress","composeEventHandlers","prev"],"sources":["../../src/Toggle.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,MAAA,EAAAA,CAAA,KAAAA,MAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAAqC,CAAAK,cAAA;AACrC,IAAAM,kBAAA,GAAAC,OAAA,oBAAqC;AAErC,IAAAC,cAA6B,GAAAD,OAAA;AAC7B,IAAAE,6BAAuB,GAAAF,OAAA;AACvB,IAAAG,UAAA,GAAAH,OAAwB;AAmHlB,IAAAI,KAAA,GAAAC,OAAA,CAAAL,OAAA;AA7GN,IAAAM,cAAa,GAAAN,OAAA;AAEN,IAAAO,IAAM;AAAc,IACzBX,WAAA,OAAAO,UAAA,CAAAK,M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