@tamagui/toggle-group 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.
@@ -0,0 +1,287 @@
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 ToggleGroup_exports = {};
25
+ __export(ToggleGroup_exports, {
26
+ ToggleGroup: () => ToggleGroup,
27
+ createToggleGroupScope: () => createToggleGroupScope
28
+ });
29
+ module.exports = __toCommonJS(ToggleGroup_exports);
30
+ var import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_font_size = require("@tamagui/font-size"), import_get_token = require("@tamagui/get-token"), import_group = require("@tamagui/group"), import_helpers_tamagui = require("@tamagui/helpers-tamagui"), import_roving_focus = require("@tamagui/roving-focus"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_direction = require("@tamagui/use-direction"), import_web = require("@tamagui/web"), import_react = __toESM(require("react")), import_Toggle = require("./Toggle"), import_jsx_runtime = require("react/jsx-runtime");
31
+ const TOGGLE_GROUP_NAME = "ToggleGroup", [createToggleGroupContext, createToggleGroupScope] = (0, import_create_context.createContextScope)(
32
+ TOGGLE_GROUP_NAME,
33
+ [import_roving_focus.createRovingFocusGroupScope]
34
+ ), TOGGLE_GROUP_ITEM_NAME = "ToggleGroupItem", [createToggleGroupItemContext, createToggleGroupItemScope] = (0, import_create_context.createContextScope)(TOGGLE_GROUP_ITEM_NAME), [ToggleGroupItemProvider, useToggleGroupItemContext] = createToggleGroupContext(TOGGLE_GROUP_NAME), useToggleGroupItemScope = createToggleGroupItemScope(), ToggleGroupItem = import_Toggle.ToggleFrame.extractable(
35
+ import_react.default.forwardRef(
36
+ (props, forwardedRef) => {
37
+ const valueContext = useToggleGroupValueContext(
38
+ TOGGLE_GROUP_ITEM_NAME,
39
+ props.__scopeToggleGroup
40
+ ), context = useToggleGroupContext(
41
+ TOGGLE_GROUP_ITEM_NAME,
42
+ props.__scopeToggleGroup
43
+ ), __scopeToggleGroup = props.__scopeToggleGroup, rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup), pressed = valueContext.value.includes(props.value), disabled = context.disabled || props.disabled || !1, ref = import_react.default.useRef(null), groupItemProps = (0, import_group.useGroupItem)({ disabled }), size = props.size ?? context.size, sizeProps = props.unstyled ? {} : {
44
+ width: void 0,
45
+ height: void 0,
46
+ padding: (0, import_web.getVariableValue)(size) * 0.6
47
+ };
48
+ props.unstyled || (props.orientation === "horizontal" ? sizeProps.height = (0, import_web.getVariableValue)(size) * 2.4 : sizeProps.width = (0, import_web.getVariableValue)(size) * 2.4);
49
+ const iconSize = (typeof size == "number" ? size * 0.7 : (0, import_font_size.getFontSize)(size)) * 1.2, theme = (0, import_web.useTheme)(), getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color: theme.color }), children = import_react.default.Children.toArray(props.children).map((child) => props.disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child)), commonProps = { ...props, pressed, disabled, ...sizeProps, children };
50
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemProvider, { scope: __scopeToggleGroup, children: context.rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ import_roving_focus.RovingFocusGroup.Item,
52
+ {
53
+ asChild: "except-style",
54
+ ...rovingFocusGroupScope,
55
+ focusable: !disabled,
56
+ active: pressed,
57
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ import_Toggle.ToggleFrame,
59
+ {
60
+ asChild: "except-style",
61
+ focusable: !disabled,
62
+ disabled,
63
+ ref,
64
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ ToggleGroupItemImpl,
66
+ {
67
+ ...commonProps,
68
+ ref: forwardedRef,
69
+ ...groupItemProps
70
+ }
71
+ )
72
+ }
73
+ )
74
+ }
75
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ import_Toggle.ToggleFrame,
77
+ {
78
+ asChild: "except-style",
79
+ focusable: !disabled,
80
+ disabled,
81
+ ref,
82
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
83
+ }
84
+ ) });
85
+ }
86
+ )
87
+ );
88
+ ToggleGroupItem.displayName = TOGGLE_GROUP_ITEM_NAME;
89
+ const ToggleGroupItemImpl = import_Toggle.ToggleFrame.extractable(
90
+ import_react.default.forwardRef(
91
+ (props, forwardedRef) => {
92
+ const { __scopeToggleGroup, value, ...itemProps } = props, valueContext = useToggleGroupValueContext(
93
+ TOGGLE_GROUP_ITEM_NAME,
94
+ __scopeToggleGroup
95
+ ), singleProps = {
96
+ "aria-pressed": void 0
97
+ }, typeProps = valueContext.type === "single" ? singleProps : void 0;
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ import_Toggle.Toggle,
100
+ {
101
+ ...typeProps,
102
+ ...itemProps,
103
+ ref: forwardedRef,
104
+ onPressedChange: (pressed) => {
105
+ pressed ? valueContext.onItemActivate(value) : valueContext.onItemDeactivate(value);
106
+ }
107
+ }
108
+ );
109
+ }
110
+ )
111
+ ), useRovingFocusGroupScope = (0, import_roving_focus.createRovingFocusGroupScope)(), ToggleGroup = (0, import_web.withStaticProperties)(
112
+ import_react.default.forwardRef((props, forwardedRef) => {
113
+ const { type, ...toggleGroupProps } = props;
114
+ if (import_web.isWeb || import_react.default.useEffect(() => {
115
+ if (props.id)
116
+ return (0, import_focusable.registerFocusable)(props.id, {
117
+ // TODO: would be nice to focus on the first child later - could be done with reforest
118
+ // for now leaving it empty
119
+ focus: () => {
120
+ }
121
+ });
122
+ }, [props.id]), type === "single")
123
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplSingle, { ...toggleGroupProps, ref: forwardedRef });
124
+ if (type === "multiple")
125
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { ...toggleGroupProps, ref: forwardedRef });
126
+ throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
127
+ }),
128
+ {
129
+ Item: ToggleGroupItem
130
+ }
131
+ );
132
+ ToggleGroup.displayName = TOGGLE_GROUP_NAME;
133
+ const [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME), ToggleGroupImplSingle = import_react.default.forwardRef((props, forwardedRef) => {
134
+ const {
135
+ value: valueProp,
136
+ defaultValue,
137
+ onValueChange = () => {
138
+ },
139
+ disableDeactivation = !1,
140
+ ...toggleGroupSingleProps
141
+ } = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
142
+ prop: valueProp,
143
+ defaultProp: defaultValue,
144
+ onChange: onValueChange
145
+ });
146
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
+ ToggleGroupValueProvider,
148
+ {
149
+ scope: props.__scopeToggleGroup,
150
+ type: "single",
151
+ value: value ? [value] : [],
152
+ defaultValue: value,
153
+ onItemActivate: setValue,
154
+ onItemDeactivate: import_react.default.useCallback(
155
+ () => disableDeactivation ? null : setValue(""),
156
+ [setValue, disableDeactivation]
157
+ ),
158
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
159
+ }
160
+ );
161
+ }), ToggleGroupImplMultiple = import_react.default.forwardRef((props, forwardedRef) => {
162
+ const {
163
+ value: valueProp,
164
+ defaultValue,
165
+ onValueChange = () => {
166
+ },
167
+ ...toggleGroupMultipleProps
168
+ } = props, [value = [], setValue] = (0, import_use_controllable_state.useControllableState)({
169
+ prop: valueProp,
170
+ defaultProp: defaultValue,
171
+ onChange: onValueChange
172
+ }), handleButtonActivate = import_react.default.useCallback(
173
+ (itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
174
+ [setValue]
175
+ ), handleButtonDeactivate = import_react.default.useCallback(
176
+ (itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
177
+ [setValue]
178
+ );
179
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
+ ToggleGroupValueProvider,
181
+ {
182
+ scope: props.__scopeToggleGroup,
183
+ type: "multiple",
184
+ value,
185
+ defaultValue: value,
186
+ onItemActivate: handleButtonActivate,
187
+ onItemDeactivate: handleButtonDeactivate,
188
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
189
+ }
190
+ );
191
+ });
192
+ ToggleGroup.displayName = TOGGLE_GROUP_NAME;
193
+ const [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME), ToggleGroupImplElementFrame = (0, import_web.styled)(import_group.Group, {
194
+ name: TOGGLE_GROUP_NAME,
195
+ variants: {
196
+ unstyled: {
197
+ false: {
198
+ backgroundColor: "$background"
199
+ }
200
+ },
201
+ orientation: {
202
+ vertical: {
203
+ flexDirection: "column",
204
+ spaceDirection: "vertical"
205
+ },
206
+ horizontal: {
207
+ flexDirection: "row",
208
+ spaceDirection: "horizontal"
209
+ }
210
+ }
211
+ },
212
+ defaultVariants: {
213
+ unstyled: !1
214
+ }
215
+ }), ToggleGroupImpl = ToggleGroupImplElementFrame.extractable(
216
+ import_react.default.forwardRef(
217
+ (props, forwardedRef) => {
218
+ const {
219
+ __scopeToggleGroup,
220
+ disabled = !1,
221
+ orientation = "horizontal",
222
+ dir,
223
+ rovingFocus = !0,
224
+ loop = !0,
225
+ unstyled = !1,
226
+ size: sizeProp = "$true",
227
+ sizeAdjust = 0,
228
+ ...toggleGroupProps
229
+ } = props, rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup), direction = (0, import_use_direction.useDirection)(dir), commonProps = {
230
+ role: "group",
231
+ dir: direction,
232
+ ...toggleGroupProps
233
+ }, adjustedSize = (0, import_web.getVariableValue)(
234
+ (0, import_get_token.getSize)(props.size, {
235
+ shift: sizeAdjust
236
+ })
237
+ ), size = Math.round(adjustedSize * 0.45);
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
+ ToggleGroupContext,
240
+ {
241
+ scope: __scopeToggleGroup,
242
+ rovingFocus,
243
+ disabled,
244
+ size,
245
+ children: rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246
+ import_roving_focus.RovingFocusGroup,
247
+ {
248
+ asChild: "except-style",
249
+ ...rovingFocusGroupScope,
250
+ orientation,
251
+ dir: direction,
252
+ loop,
253
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
254
+ ToggleGroupImplElementFrame,
255
+ {
256
+ "aria-orientation": orientation,
257
+ orientation,
258
+ axis: orientation,
259
+ ref: forwardedRef,
260
+ "data-disabled": disabled ? "" : void 0,
261
+ unstyled,
262
+ ...commonProps
263
+ }
264
+ )
265
+ }
266
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
267
+ ToggleGroupImplElementFrame,
268
+ {
269
+ "aria-orientation": orientation,
270
+ ref: forwardedRef,
271
+ orientation,
272
+ "data-disabled": disabled ? "" : void 0,
273
+ unstyled,
274
+ ...commonProps
275
+ }
276
+ )
277
+ }
278
+ );
279
+ }
280
+ )
281
+ );
282
+ // Annotate the CommonJS export names for ESM import in node:
283
+ 0 && (module.exports = {
284
+ ToggleGroup,
285
+ createToggleGroupScope
286
+ });
287
+ //# sourceMappingURL=ToggleGroup.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ToggleGroup.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA0C,oCAC1C,mBAAkC,+BAClC,mBAA4B,+BAC5B,mBAAwB,+BACxB,eAAgD,2BAChD,yBAAiC,qCACjC,sBAA8D,kCAC9D,gCAAqC,4CACrC,uBAA6B,mCAC7B,aASO,yBACP,eAAkB,2BAElB,gBAAiD,qBAoGjC;AAlGhB,MAAM,oBAAoB,eACpB,CAAC,0BAA0B,sBAAsB,QAAI;AAAA,EACzD;AAAA,EACA,CAAC,+CAA2B;AAC9B,GAKM,yBAAyB,mBAIzB,CAAC,8BAA8B,0BAA0B,QAC7D,0CAAmB,sBAAsB,GACrC,CAAC,yBAAyB,yBAAyB,IACvD,yBAAsD,iBAAiB,GACnE,0BAA0B,2BAA2B,GAcrD,kBAAkB,0BAAY;AAAA,EAClC,aAAAA,QAAM;AAAA,IACJ,CAAC,OAA0C,iBAAiB;AAC1D,YAAM,eAAe;AAAA,QACnB;AAAA,QACA,MAAM;AAAA,MACR,GACM,UAAU;AAAA,QACd;AAAA,QACA,MAAM;AAAA,MACR,GACM,qBAAqB,MAAM,oBAC3B,wBAAwB,yBAAyB,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GAAG;AAAA,MACL,GACM,mBAAe;AAAA,YACnB,0BAAQ,MAAM,MAAM;AAAA,UAClB,OAAO;AAAA,QACT,CAAC;AAAA,MACH,GACM,OAAO,KAAK,MAAM,eAAe,IAAI;AAE3C,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,UAEC,wBACC;AAAA,YAAC;AAAA;AAAA,cACC,SAAQ;AAAA,cACP,GAAG;AAAA,cACJ;AAAA,cACA,KAAK;AAAA,cACL;AAAA,cAEA;AAAA,gBAAC;AAAA;AAAA,kBACC,oBAAkB;AAAA,kBAClB;AAAA,kBACA,MAAM;AAAA,kBACN,KAAK;AAAA,kBACL,iBAAe,WAAW,KAAK;AAAA,kBAC/B;AAAA,kBACC,GAAG;AAAA;AAAA,cACN;AAAA;AAAA,UACF,IAEA;AAAA,YAAC;AAAA;AAAA,cACC,oBAAkB;AAAA,cAClB,KAAK;AAAA,cACL;AAAA,cACA,iBAAe,WAAW,KAAK;AAAA,cAC/B;AAAA,cACC,GAAG;AAAA;AAAA,UACN;AAAA;AAAA,MAEJ;AAAA,IAEJ;AAAA,EACF;AACF;",
5
+ "names": ["React", "value"]
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 === "object" || typeof from === "function") {
6
+ if (from && typeof from == "object" || typeof from == "function")
8
7
  for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
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("./ToggleGroup"), module.exports);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;",
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,20 @@
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("./ToggleGroup"), module.exports);
16
+ // Annotate the CommonJS export names for ESM import in node:
17
+ 0 && (module.exports = {
18
+ ...require("./ToggleGroup")
19
+ });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;",
5
+ "names": []
6
+ }
@@ -1,16 +1,15 @@
1
- import { jsx } from "react/jsx-runtime";
2
1
  import { ThemeableStack } from "@tamagui/stacks";
3
2
  import { useControllableState } from "@tamagui/use-controllable-state";
4
3
  import { Theme, composeEventHandlers, styled } from "@tamagui/web";
5
4
  import * as React from "react";
6
- const NAME = "Toggle";
7
- const ToggleFrame = styled(ThemeableStack, {
5
+ import { jsx } from "react/jsx-runtime";
6
+ const NAME = "Toggle", ToggleFrame = styled(ThemeableStack, {
8
7
  name: NAME,
9
8
  tag: "button",
10
9
  variants: {
11
10
  unstyled: {
12
11
  false: {
13
- pressTheme: true,
12
+ pressTheme: !0,
14
13
  backgroundColor: "$background",
15
14
  alignItems: "center",
16
15
  justifyContent: "center",
@@ -56,18 +55,16 @@ const ToggleFrame = styled(ThemeableStack, {
56
55
  }
57
56
  },
58
57
  defaultVariants: {
59
- unstyled: false
58
+ unstyled: !1
60
59
  }
61
- });
62
- const Toggle = ToggleFrame.extractable(
60
+ }), Toggle = ToggleFrame.extractable(
63
61
  React.forwardRef((props, forwardedRef) => {
64
62
  const {
65
63
  pressed: pressedProp,
66
- defaultPressed = false,
64
+ defaultPressed = !1,
67
65
  onPressedChange,
68
66
  ...buttonProps
69
- } = props;
70
- const [pressed = false, setPressed] = useControllableState({
67
+ } = props, [pressed = !1, setPressed] = useControllableState({
71
68
  prop: pressedProp,
72
69
  onChange: onPressedChange,
73
70
  defaultProp: defaultPressed
@@ -75,16 +72,14 @@ const Toggle = ToggleFrame.extractable(
75
72
  return /* @__PURE__ */ jsx(Theme, { name: pressed ? "active" : null, children: /* @__PURE__ */ jsx(
76
73
  ToggleFrame,
77
74
  {
78
- active: !props.unstyled ? pressed : void 0,
75
+ active: props.unstyled ? void 0 : pressed,
79
76
  "aria-pressed": pressed,
80
77
  "data-state": pressed ? "on" : "off",
81
78
  "data-disabled": props.disabled ? "" : void 0,
82
79
  ...buttonProps,
83
80
  ref: forwardedRef,
84
81
  onPress: composeEventHandlers(props.onPress ?? void 0, (event) => {
85
- if (!props.disabled) {
86
- setPressed(!pressed);
87
- }
82
+ props.disabled || setPressed(!pressed);
88
83
  })
89
84
  }
90
85
  ) });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Toggle.tsx"],
4
- "mappings": "AAqGQ;AArGR,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAmB,OAAO,sBAA6B,cAAc;AACrE,YAAY,WAAW;AAMvB,MAAM,OAAO;AAMb,MAAM,cAAc,OAAO,gBAAgB;AAAA,EACzC,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,iBAAiB;AAAA,QACjB,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,SAAS;AAAA,QACT,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ;AAAA,QACR,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QACA,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QACA,YAAY;AAAA,UACV,aAAa;AAAA,UACb,cAAc;AAAA,UACd,cAAc;AAAA,UACd,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ;AAAA,QACR,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QACA,YAAY;AAAA,UACV,aAAa;AAAA,UACb,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,aAAa;AAAA,MACX,YAAY;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