@tamagui/toggle-group 1.114.4 → 1.115.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 +129 -0
- package/dist/cjs/ToggleGroup.cjs +291 -0
- package/dist/cjs/index.cjs +18 -0
- package/package.json +17 -16
- package/dist/cjs/Toggle.js +0 -118
- package/dist/cjs/ToggleGroup.js +0 -252
- package/dist/cjs/index.js +0 -15
- /package/dist/cjs/{Toggle.js.map → Toggle.cjs.map} +0 -0
- /package/dist/cjs/{ToggleGroup.js.map → ToggleGroup.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
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);
|
|
32
|
+
var Toggle_exports = {};
|
|
33
|
+
__export(Toggle_exports, {
|
|
34
|
+
Toggle: () => Toggle,
|
|
35
|
+
ToggleFrame: () => ToggleFrame
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(Toggle_exports);
|
|
38
|
+
var import_helpers = require("@tamagui/helpers"),
|
|
39
|
+
import_stacks = require("@tamagui/stacks"),
|
|
40
|
+
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
41
|
+
import_web = require("@tamagui/web"),
|
|
42
|
+
React = __toESM(require("react")),
|
|
43
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
const NAME = "Toggle",
|
|
45
|
+
ToggleFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
46
|
+
name: NAME,
|
|
47
|
+
tag: "button",
|
|
48
|
+
variants: {
|
|
49
|
+
unstyled: {
|
|
50
|
+
false: {
|
|
51
|
+
pressTheme: !0,
|
|
52
|
+
backgroundColor: "$background",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
justifyContent: "center",
|
|
55
|
+
display: "flex",
|
|
56
|
+
borderColor: "$borderColor",
|
|
57
|
+
borderWidth: 1,
|
|
58
|
+
margin: -1,
|
|
59
|
+
hoverStyle: {
|
|
60
|
+
backgroundColor: "$backgroundHover"
|
|
61
|
+
},
|
|
62
|
+
pressStyle: {
|
|
63
|
+
backgroundColor: "$backgroundPress"
|
|
64
|
+
},
|
|
65
|
+
focusStyle: {
|
|
66
|
+
borderColor: "$borderColorFocus"
|
|
67
|
+
},
|
|
68
|
+
focusVisibleStyle: {
|
|
69
|
+
outlineColor: "$outlineColor",
|
|
70
|
+
outlineWidth: 2,
|
|
71
|
+
outlineStyle: "solid"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
active: {
|
|
76
|
+
true: {
|
|
77
|
+
zIndex: 1,
|
|
78
|
+
hoverStyle: {
|
|
79
|
+
backgroundColor: "$background"
|
|
80
|
+
},
|
|
81
|
+
focusStyle: {
|
|
82
|
+
borderColor: "$borderColor",
|
|
83
|
+
backgroundColor: "$background"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
orientation: {
|
|
88
|
+
horizontal: {
|
|
89
|
+
flexDirection: "row",
|
|
90
|
+
spaceDirection: "horizontal"
|
|
91
|
+
},
|
|
92
|
+
vertical: {
|
|
93
|
+
flexDirection: "column",
|
|
94
|
+
spaceDirection: "vertical"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
defaultVariants: {
|
|
99
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
Toggle = React.forwardRef(function (props, forwardedRef) {
|
|
103
|
+
const {
|
|
104
|
+
pressed: pressedProp,
|
|
105
|
+
defaultPressed = !1,
|
|
106
|
+
onPressedChange,
|
|
107
|
+
...buttonProps
|
|
108
|
+
} = props,
|
|
109
|
+
[pressed = !1, setPressed] = (0, import_use_controllable_state.useControllableState)({
|
|
110
|
+
prop: pressedProp,
|
|
111
|
+
onChange: onPressedChange,
|
|
112
|
+
defaultProp: defaultPressed
|
|
113
|
+
});
|
|
114
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleFrame, {
|
|
115
|
+
...(!props.unstyled && {
|
|
116
|
+
theme: pressed ? "active" : null,
|
|
117
|
+
themeShallow: !0
|
|
118
|
+
}),
|
|
119
|
+
active: props.unstyled ? void 0 : pressed,
|
|
120
|
+
"aria-pressed": pressed,
|
|
121
|
+
"data-state": pressed ? "on" : "off",
|
|
122
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
123
|
+
...buttonProps,
|
|
124
|
+
ref: forwardedRef,
|
|
125
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, () => {
|
|
126
|
+
props.disabled || setPressed(!pressed);
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
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);
|
|
32
|
+
var ToggleGroup_exports = {};
|
|
33
|
+
__export(ToggleGroup_exports, {
|
|
34
|
+
ToggleGroup: () => ToggleGroup
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(ToggleGroup_exports);
|
|
37
|
+
var import_constants = require("@tamagui/constants"),
|
|
38
|
+
import_focusable = require("@tamagui/focusable"),
|
|
39
|
+
import_font_size = require("@tamagui/font-size"),
|
|
40
|
+
import_get_token = require("@tamagui/get-token"),
|
|
41
|
+
import_group = require("@tamagui/group"),
|
|
42
|
+
import_helpers = require("@tamagui/helpers"),
|
|
43
|
+
import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
|
|
44
|
+
import_roving_focus = require("@tamagui/roving-focus"),
|
|
45
|
+
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
46
|
+
import_use_direction = require("@tamagui/use-direction"),
|
|
47
|
+
import_web = require("@tamagui/web"),
|
|
48
|
+
import_react = __toESM(require("react")),
|
|
49
|
+
import_Toggle = require("./Toggle.cjs"),
|
|
50
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
const TOGGLE_GROUP_NAME = "ToggleGroup",
|
|
52
|
+
TOGGLE_GROUP_ITEM_NAME = "ToggleGroupItem",
|
|
53
|
+
TOGGLE_GROUP_CONTEXT = "ToggleGroup",
|
|
54
|
+
{
|
|
55
|
+
Provider: ToggleGroupItemProvider,
|
|
56
|
+
useStyledContext: useToggleGroupItemContext
|
|
57
|
+
} = (0, import_web.createStyledContext)(),
|
|
58
|
+
{
|
|
59
|
+
Provider: ToggleGroupContext,
|
|
60
|
+
useStyledContext: useToggleGroupContext
|
|
61
|
+
} = (0, import_web.createStyledContext)(),
|
|
62
|
+
ToggleGroupItem = import_Toggle.ToggleFrame.extractable(import_react.default.forwardRef((props, forwardedRef) => {
|
|
63
|
+
const {
|
|
64
|
+
disablePassStyles,
|
|
65
|
+
...rest
|
|
66
|
+
} = props,
|
|
67
|
+
valueContext = useToggleGroupValueContext(props.__scopeToggleGroup),
|
|
68
|
+
context = useToggleGroupContext(props.__scopeToggleGroup),
|
|
69
|
+
pressed = valueContext?.value.includes(props.value),
|
|
70
|
+
disabled = context.disabled || props.disabled || !1,
|
|
71
|
+
groupItemProps = (0, import_group.useGroupItem)({
|
|
72
|
+
disabled
|
|
73
|
+
}),
|
|
74
|
+
size = props.size ?? context.size,
|
|
75
|
+
sizeProps = props.unstyled ? {} : {
|
|
76
|
+
width: void 0,
|
|
77
|
+
height: void 0,
|
|
78
|
+
padding: (0, import_web.getVariableValue)(size) * 0.6
|
|
79
|
+
},
|
|
80
|
+
iconSize = (typeof size == "number" ? size * 0.7 : (0, import_font_size.getFontSize)(size)) * 1.2,
|
|
81
|
+
theme = (0, import_web.useTheme)(),
|
|
82
|
+
getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
83
|
+
size: iconSize,
|
|
84
|
+
color: theme.color
|
|
85
|
+
}),
|
|
86
|
+
children = import_react.default.Children.toArray(props.children).map(child => props.disablePassStyles || !import_react.default.isValidElement(child) ? child : getThemedIcon(child)),
|
|
87
|
+
commonProps = {
|
|
88
|
+
pressed,
|
|
89
|
+
disabled,
|
|
90
|
+
...sizeProps,
|
|
91
|
+
...rest,
|
|
92
|
+
children
|
|
93
|
+
},
|
|
94
|
+
inner = /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupItemImpl, {
|
|
95
|
+
...commonProps,
|
|
96
|
+
ref: forwardedRef,
|
|
97
|
+
focusable: !disabled,
|
|
98
|
+
disabled,
|
|
99
|
+
...groupItemProps
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupItemProvider, {
|
|
102
|
+
scope: props.__scopeToggleGroup,
|
|
103
|
+
children: context.rovingFocus ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
|
|
104
|
+
asChild: "except-style",
|
|
105
|
+
__scopeRovingFocusGroup: props.__scopeToggleGroup || TOGGLE_GROUP_CONTEXT,
|
|
106
|
+
focusable: !disabled,
|
|
107
|
+
active: pressed,
|
|
108
|
+
children: inner
|
|
109
|
+
}) : inner
|
|
110
|
+
});
|
|
111
|
+
}));
|
|
112
|
+
ToggleGroupItem.displayName = TOGGLE_GROUP_ITEM_NAME;
|
|
113
|
+
const ToggleGroupItemImpl = import_react.default.forwardRef((props, forwardedRef) => {
|
|
114
|
+
const {
|
|
115
|
+
__scopeToggleGroup,
|
|
116
|
+
value,
|
|
117
|
+
...itemProps
|
|
118
|
+
} = props,
|
|
119
|
+
valueContext = useToggleGroupValueContext(__scopeToggleGroup),
|
|
120
|
+
singleProps = {
|
|
121
|
+
"aria-pressed": void 0
|
|
122
|
+
},
|
|
123
|
+
typeProps = valueContext.type === "single" ? singleProps : void 0;
|
|
124
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Toggle.Toggle, {
|
|
125
|
+
...typeProps,
|
|
126
|
+
...itemProps,
|
|
127
|
+
ref: forwardedRef,
|
|
128
|
+
onPressedChange: pressed => {
|
|
129
|
+
pressed ? valueContext.onItemActivate(value) : valueContext.onItemDeactivate(value);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}),
|
|
133
|
+
ToggleGroup = (0, import_helpers.withStaticProperties)(import_react.default.forwardRef((props, forwardedRef) => {
|
|
134
|
+
const {
|
|
135
|
+
type,
|
|
136
|
+
...toggleGroupProps
|
|
137
|
+
} = props;
|
|
138
|
+
if (import_constants.isWeb || import_react.default.useEffect(() => {
|
|
139
|
+
if (props.id) return (0, import_focusable.registerFocusable)(props.id, {
|
|
140
|
+
// TODO: would be nice to focus on the first child later - could be done with reforest
|
|
141
|
+
// for now leaving it empty
|
|
142
|
+
focus: () => {}
|
|
143
|
+
});
|
|
144
|
+
}, [props.id]), type === "single") return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImplSingle, {
|
|
145
|
+
...toggleGroupProps,
|
|
146
|
+
ref: forwardedRef
|
|
147
|
+
});
|
|
148
|
+
if (type === "multiple") return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, {
|
|
149
|
+
...toggleGroupProps,
|
|
150
|
+
ref: forwardedRef
|
|
151
|
+
});
|
|
152
|
+
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
153
|
+
}), {
|
|
154
|
+
Item: ToggleGroupItem
|
|
155
|
+
});
|
|
156
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
157
|
+
const {
|
|
158
|
+
Provider: ToggleGroupValueProvider,
|
|
159
|
+
useStyledContext: useToggleGroupValueContext
|
|
160
|
+
} = (0, import_web.createStyledContext)(),
|
|
161
|
+
ToggleGroupImplSingle = import_react.default.forwardRef((props, forwardedRef) => {
|
|
162
|
+
const {
|
|
163
|
+
value: valueProp,
|
|
164
|
+
defaultValue,
|
|
165
|
+
onValueChange = () => {},
|
|
166
|
+
disableDeactivation = !1,
|
|
167
|
+
...toggleGroupSingleProps
|
|
168
|
+
} = props,
|
|
169
|
+
[value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
170
|
+
prop: valueProp,
|
|
171
|
+
defaultProp: defaultValue,
|
|
172
|
+
onChange: onValueChange
|
|
173
|
+
});
|
|
174
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupValueProvider, {
|
|
175
|
+
scope: props.__scopeToggleGroup,
|
|
176
|
+
type: "single",
|
|
177
|
+
value: value ? [value] : [],
|
|
178
|
+
defaultValue: value,
|
|
179
|
+
onItemActivate: setValue,
|
|
180
|
+
onItemDeactivate: import_react.default.useCallback(() => disableDeactivation ? null : setValue(""), [setValue, disableDeactivation]),
|
|
181
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImpl, {
|
|
182
|
+
...toggleGroupSingleProps,
|
|
183
|
+
ref: forwardedRef
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}),
|
|
187
|
+
ToggleGroupImplMultiple = import_react.default.forwardRef((props, forwardedRef) => {
|
|
188
|
+
const {
|
|
189
|
+
value: valueProp,
|
|
190
|
+
defaultValue,
|
|
191
|
+
onValueChange = () => {},
|
|
192
|
+
disableDeactivation,
|
|
193
|
+
...toggleGroupMultipleProps
|
|
194
|
+
} = props,
|
|
195
|
+
[value = [], setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
196
|
+
prop: valueProp,
|
|
197
|
+
defaultProp: defaultValue,
|
|
198
|
+
onChange: onValueChange
|
|
199
|
+
}),
|
|
200
|
+
handleButtonActivate = import_react.default.useCallback(itemValue => setValue((prevValue = []) => [...prevValue, itemValue]), [setValue]),
|
|
201
|
+
handleButtonDeactivate = import_react.default.useCallback(itemValue => setValue((prevValue = []) => prevValue.filter(value2 => value2 !== itemValue)), [setValue]);
|
|
202
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupValueProvider, {
|
|
203
|
+
scope: props.__scopeToggleGroup,
|
|
204
|
+
type: "multiple",
|
|
205
|
+
value,
|
|
206
|
+
defaultValue: value,
|
|
207
|
+
onItemActivate: handleButtonActivate,
|
|
208
|
+
onItemDeactivate: handleButtonDeactivate,
|
|
209
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImpl, {
|
|
210
|
+
...toggleGroupMultipleProps,
|
|
211
|
+
ref: forwardedRef
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
216
|
+
const ToggleGroupImplElementFrame = (0, import_web.styled)(import_group.Group, {
|
|
217
|
+
name: TOGGLE_GROUP_NAME,
|
|
218
|
+
variants: {
|
|
219
|
+
unstyled: {
|
|
220
|
+
false: {
|
|
221
|
+
backgroundColor: "$background"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
orientation: {
|
|
225
|
+
vertical: {
|
|
226
|
+
flexDirection: "column",
|
|
227
|
+
spaceDirection: "vertical"
|
|
228
|
+
},
|
|
229
|
+
horizontal: {
|
|
230
|
+
flexDirection: "row",
|
|
231
|
+
spaceDirection: "horizontal"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
defaultVariants: {
|
|
236
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
237
|
+
}
|
|
238
|
+
}),
|
|
239
|
+
ToggleGroupImpl = ToggleGroupImplElementFrame.extractable(import_react.default.forwardRef((props, forwardedRef) => {
|
|
240
|
+
const {
|
|
241
|
+
__scopeToggleGroup,
|
|
242
|
+
disabled = !1,
|
|
243
|
+
orientation = "horizontal",
|
|
244
|
+
dir,
|
|
245
|
+
rovingFocus = !0,
|
|
246
|
+
loop = !0,
|
|
247
|
+
unstyled = !1,
|
|
248
|
+
size: sizeProp = "$true",
|
|
249
|
+
sizeAdjust = 0,
|
|
250
|
+
...toggleGroupProps
|
|
251
|
+
} = props,
|
|
252
|
+
direction = (0, import_use_direction.useDirection)(dir),
|
|
253
|
+
commonProps = {
|
|
254
|
+
role: "group",
|
|
255
|
+
dir: direction,
|
|
256
|
+
...toggleGroupProps
|
|
257
|
+
},
|
|
258
|
+
adjustedSize = (0, import_web.getVariableValue)((0, import_get_token.getSize)(sizeProp, {
|
|
259
|
+
shift: sizeAdjust
|
|
260
|
+
})),
|
|
261
|
+
size = Math.round(adjustedSize * 0.45);
|
|
262
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupContext, {
|
|
263
|
+
scope: __scopeToggleGroup,
|
|
264
|
+
rovingFocus,
|
|
265
|
+
disabled,
|
|
266
|
+
size,
|
|
267
|
+
children: rovingFocus ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
|
|
268
|
+
asChild: "except-style",
|
|
269
|
+
__scopeRovingFocusGroup: __scopeToggleGroup || TOGGLE_GROUP_CONTEXT,
|
|
270
|
+
orientation,
|
|
271
|
+
dir: direction,
|
|
272
|
+
loop,
|
|
273
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImplElementFrame, {
|
|
274
|
+
"aria-orientation": orientation,
|
|
275
|
+
orientation,
|
|
276
|
+
axis: orientation,
|
|
277
|
+
ref: forwardedRef,
|
|
278
|
+
"data-disabled": disabled ? "" : void 0,
|
|
279
|
+
unstyled,
|
|
280
|
+
...commonProps
|
|
281
|
+
})
|
|
282
|
+
}) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToggleGroupImplElementFrame, {
|
|
283
|
+
"aria-orientation": orientation,
|
|
284
|
+
ref: forwardedRef,
|
|
285
|
+
orientation,
|
|
286
|
+
"data-disabled": disabled ? "" : void 0,
|
|
287
|
+
unstyled,
|
|
288
|
+
...commonProps
|
|
289
|
+
})
|
|
290
|
+
});
|
|
291
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./ToggleGroup.cjs"), module.exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/toggle-group",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -29,26 +29,27 @@
|
|
|
29
29
|
"react-native": "./dist/cjs/index.native.js",
|
|
30
30
|
"types": "./types/index.d.ts",
|
|
31
31
|
"import": "./dist/esm/index.mjs",
|
|
32
|
-
"require": "./dist/cjs/index.
|
|
32
|
+
"require": "./dist/cjs/index.cjs",
|
|
33
|
+
"default": "./dist/cjs/index.native.js"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@tamagui/constants": "1.
|
|
37
|
-
"@tamagui/create-context": "1.
|
|
38
|
-
"@tamagui/focusable": "1.
|
|
39
|
-
"@tamagui/font-size": "1.
|
|
40
|
-
"@tamagui/get-token": "1.
|
|
41
|
-
"@tamagui/group": "1.
|
|
42
|
-
"@tamagui/helpers": "1.
|
|
43
|
-
"@tamagui/helpers-tamagui": "1.
|
|
44
|
-
"@tamagui/roving-focus": "1.
|
|
45
|
-
"@tamagui/stacks": "1.
|
|
46
|
-
"@tamagui/use-controllable-state": "1.
|
|
47
|
-
"@tamagui/use-direction": "1.
|
|
48
|
-
"@tamagui/web": "1.
|
|
37
|
+
"@tamagui/constants": "1.115.1",
|
|
38
|
+
"@tamagui/create-context": "1.115.1",
|
|
39
|
+
"@tamagui/focusable": "1.115.1",
|
|
40
|
+
"@tamagui/font-size": "1.115.1",
|
|
41
|
+
"@tamagui/get-token": "1.115.1",
|
|
42
|
+
"@tamagui/group": "1.115.1",
|
|
43
|
+
"@tamagui/helpers": "1.115.1",
|
|
44
|
+
"@tamagui/helpers-tamagui": "1.115.1",
|
|
45
|
+
"@tamagui/roving-focus": "1.115.1",
|
|
46
|
+
"@tamagui/stacks": "1.115.1",
|
|
47
|
+
"@tamagui/use-controllable-state": "1.115.1",
|
|
48
|
+
"@tamagui/use-direction": "1.115.1",
|
|
49
|
+
"@tamagui/web": "1.115.1"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@tamagui/build": "1.
|
|
52
|
+
"@tamagui/build": "1.115.1",
|
|
52
53
|
"react": "^18.2.0 || ^19.0.0"
|
|
53
54
|
},
|
|
54
55
|
"publishConfig": {
|
package/dist/cjs/Toggle.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var Toggle_exports = {};
|
|
24
|
-
__export(Toggle_exports, {
|
|
25
|
-
Toggle: () => Toggle,
|
|
26
|
-
ToggleFrame: () => ToggleFrame
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(Toggle_exports);
|
|
29
|
-
var import_helpers = require("@tamagui/helpers"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_web = require("@tamagui/web"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
const NAME = "Toggle", ToggleFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
31
|
-
name: NAME,
|
|
32
|
-
tag: "button",
|
|
33
|
-
variants: {
|
|
34
|
-
unstyled: {
|
|
35
|
-
false: {
|
|
36
|
-
pressTheme: !0,
|
|
37
|
-
backgroundColor: "$background",
|
|
38
|
-
alignItems: "center",
|
|
39
|
-
justifyContent: "center",
|
|
40
|
-
display: "flex",
|
|
41
|
-
borderColor: "$borderColor",
|
|
42
|
-
borderWidth: 1,
|
|
43
|
-
margin: -1,
|
|
44
|
-
hoverStyle: {
|
|
45
|
-
backgroundColor: "$backgroundHover"
|
|
46
|
-
},
|
|
47
|
-
pressStyle: {
|
|
48
|
-
backgroundColor: "$backgroundPress"
|
|
49
|
-
},
|
|
50
|
-
focusStyle: {
|
|
51
|
-
borderColor: "$borderColorFocus"
|
|
52
|
-
},
|
|
53
|
-
focusVisibleStyle: {
|
|
54
|
-
outlineColor: "$outlineColor",
|
|
55
|
-
outlineWidth: 2,
|
|
56
|
-
outlineStyle: "solid"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
active: {
|
|
61
|
-
true: {
|
|
62
|
-
zIndex: 1,
|
|
63
|
-
hoverStyle: {
|
|
64
|
-
backgroundColor: "$background"
|
|
65
|
-
},
|
|
66
|
-
focusStyle: {
|
|
67
|
-
borderColor: "$borderColor",
|
|
68
|
-
backgroundColor: "$background"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
orientation: {
|
|
73
|
-
horizontal: {
|
|
74
|
-
flexDirection: "row",
|
|
75
|
-
spaceDirection: "horizontal"
|
|
76
|
-
},
|
|
77
|
-
vertical: {
|
|
78
|
-
flexDirection: "column",
|
|
79
|
-
spaceDirection: "vertical"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
defaultVariants: {
|
|
84
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
85
|
-
}
|
|
86
|
-
}), Toggle = React.forwardRef(
|
|
87
|
-
function(props, forwardedRef) {
|
|
88
|
-
const {
|
|
89
|
-
pressed: pressedProp,
|
|
90
|
-
defaultPressed = !1,
|
|
91
|
-
onPressedChange,
|
|
92
|
-
...buttonProps
|
|
93
|
-
} = props, [pressed = !1, setPressed] = (0, import_use_controllable_state.useControllableState)({
|
|
94
|
-
prop: pressedProp,
|
|
95
|
-
onChange: onPressedChange,
|
|
96
|
-
defaultProp: defaultPressed
|
|
97
|
-
});
|
|
98
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
-
ToggleFrame,
|
|
100
|
-
{
|
|
101
|
-
...!props.unstyled && {
|
|
102
|
-
theme: pressed ? "active" : null,
|
|
103
|
-
themeShallow: !0
|
|
104
|
-
},
|
|
105
|
-
active: props.unstyled ? void 0 : pressed,
|
|
106
|
-
"aria-pressed": pressed,
|
|
107
|
-
"data-state": pressed ? "on" : "off",
|
|
108
|
-
"data-disabled": props.disabled ? "" : void 0,
|
|
109
|
-
...buttonProps,
|
|
110
|
-
ref: forwardedRef,
|
|
111
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, () => {
|
|
112
|
-
props.disabled || setPressed(!pressed);
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
//# sourceMappingURL=Toggle.js.map
|
package/dist/cjs/ToggleGroup.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var ToggleGroup_exports = {};
|
|
24
|
-
__export(ToggleGroup_exports, {
|
|
25
|
-
ToggleGroup: () => ToggleGroup
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(ToggleGroup_exports);
|
|
28
|
-
var import_constants = require("@tamagui/constants"), 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 = require("@tamagui/helpers"), 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");
|
|
29
|
-
const TOGGLE_GROUP_NAME = "ToggleGroup", TOGGLE_GROUP_ITEM_NAME = "ToggleGroupItem", TOGGLE_GROUP_CONTEXT = "ToggleGroup", { Provider: ToggleGroupItemProvider, useStyledContext: useToggleGroupItemContext } = (0, import_web.createStyledContext)(), { Provider: ToggleGroupContext, useStyledContext: useToggleGroupContext } = (0, import_web.createStyledContext)(), ToggleGroupItem = import_Toggle.ToggleFrame.extractable(
|
|
30
|
-
import_react.default.forwardRef(
|
|
31
|
-
(props, forwardedRef) => {
|
|
32
|
-
const { disablePassStyles, ...rest } = props, valueContext = useToggleGroupValueContext(props.__scopeToggleGroup), context = useToggleGroupContext(props.__scopeToggleGroup), pressed = valueContext?.value.includes(props.value), disabled = context.disabled || props.disabled || !1, groupItemProps = (0, import_group.useGroupItem)({ disabled }), size = props.size ?? context.size, sizeProps = props.unstyled ? {} : {
|
|
33
|
-
width: void 0,
|
|
34
|
-
height: void 0,
|
|
35
|
-
padding: (0, import_web.getVariableValue)(size) * 0.6
|
|
36
|
-
}, 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 = { pressed, disabled, ...sizeProps, ...rest, children }, inner = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
37
|
-
ToggleGroupItemImpl,
|
|
38
|
-
{
|
|
39
|
-
...commonProps,
|
|
40
|
-
ref: forwardedRef,
|
|
41
|
-
focusable: !disabled,
|
|
42
|
-
disabled,
|
|
43
|
-
...groupItemProps
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupItemProvider, { scope: props.__scopeToggleGroup, children: context.rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
|
-
import_roving_focus.RovingFocusGroup.Item,
|
|
48
|
-
{
|
|
49
|
-
asChild: "except-style",
|
|
50
|
-
__scopeRovingFocusGroup: props.__scopeToggleGroup || TOGGLE_GROUP_CONTEXT,
|
|
51
|
-
focusable: !disabled,
|
|
52
|
-
active: pressed,
|
|
53
|
-
children: inner
|
|
54
|
-
}
|
|
55
|
-
) : inner });
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
ToggleGroupItem.displayName = TOGGLE_GROUP_ITEM_NAME;
|
|
60
|
-
const ToggleGroupItemImpl = import_react.default.forwardRef((props, forwardedRef) => {
|
|
61
|
-
const { __scopeToggleGroup, value, ...itemProps } = props, valueContext = useToggleGroupValueContext(__scopeToggleGroup), singleProps = {
|
|
62
|
-
"aria-pressed": void 0
|
|
63
|
-
}, typeProps = valueContext.type === "single" ? singleProps : void 0;
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
|
-
import_Toggle.Toggle,
|
|
66
|
-
{
|
|
67
|
-
...typeProps,
|
|
68
|
-
...itemProps,
|
|
69
|
-
ref: forwardedRef,
|
|
70
|
-
onPressedChange: (pressed) => {
|
|
71
|
-
pressed ? valueContext.onItemActivate(value) : valueContext.onItemDeactivate(value);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
}), ToggleGroup = (0, import_helpers.withStaticProperties)(
|
|
76
|
-
import_react.default.forwardRef(
|
|
77
|
-
(props, forwardedRef) => {
|
|
78
|
-
const { type, ...toggleGroupProps } = props;
|
|
79
|
-
if (import_constants.isWeb || import_react.default.useEffect(() => {
|
|
80
|
-
if (props.id)
|
|
81
|
-
return (0, import_focusable.registerFocusable)(props.id, {
|
|
82
|
-
// TODO: would be nice to focus on the first child later - could be done with reforest
|
|
83
|
-
// for now leaving it empty
|
|
84
|
-
focus: () => {
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}, [props.id]), type === "single")
|
|
88
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplSingle, { ...toggleGroupProps, ref: forwardedRef });
|
|
89
|
-
if (type === "multiple")
|
|
90
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImplMultiple, { ...toggleGroupProps, ref: forwardedRef });
|
|
91
|
-
throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
|
|
92
|
-
}
|
|
93
|
-
),
|
|
94
|
-
{
|
|
95
|
-
Item: ToggleGroupItem
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
99
|
-
const {
|
|
100
|
-
Provider: ToggleGroupValueProvider,
|
|
101
|
-
useStyledContext: useToggleGroupValueContext
|
|
102
|
-
} = (0, import_web.createStyledContext)(), ToggleGroupImplSingle = import_react.default.forwardRef((props, forwardedRef) => {
|
|
103
|
-
const {
|
|
104
|
-
value: valueProp,
|
|
105
|
-
defaultValue,
|
|
106
|
-
onValueChange = () => {
|
|
107
|
-
},
|
|
108
|
-
disableDeactivation = !1,
|
|
109
|
-
...toggleGroupSingleProps
|
|
110
|
-
} = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
111
|
-
prop: valueProp,
|
|
112
|
-
defaultProp: defaultValue,
|
|
113
|
-
onChange: onValueChange
|
|
114
|
-
});
|
|
115
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
-
ToggleGroupValueProvider,
|
|
117
|
-
{
|
|
118
|
-
scope: props.__scopeToggleGroup,
|
|
119
|
-
type: "single",
|
|
120
|
-
value: value ? [value] : [],
|
|
121
|
-
defaultValue: value,
|
|
122
|
-
onItemActivate: setValue,
|
|
123
|
-
onItemDeactivate: import_react.default.useCallback(
|
|
124
|
-
() => disableDeactivation ? null : setValue(""),
|
|
125
|
-
[setValue, disableDeactivation]
|
|
126
|
-
),
|
|
127
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
}), ToggleGroupImplMultiple = import_react.default.forwardRef((props, forwardedRef) => {
|
|
131
|
-
const {
|
|
132
|
-
value: valueProp,
|
|
133
|
-
defaultValue,
|
|
134
|
-
onValueChange = () => {
|
|
135
|
-
},
|
|
136
|
-
disableDeactivation,
|
|
137
|
-
...toggleGroupMultipleProps
|
|
138
|
-
} = props, [value = [], setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
139
|
-
prop: valueProp,
|
|
140
|
-
defaultProp: defaultValue,
|
|
141
|
-
onChange: onValueChange
|
|
142
|
-
}), handleButtonActivate = import_react.default.useCallback(
|
|
143
|
-
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
144
|
-
[setValue]
|
|
145
|
-
), handleButtonDeactivate = import_react.default.useCallback(
|
|
146
|
-
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
147
|
-
[setValue]
|
|
148
|
-
);
|
|
149
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
-
ToggleGroupValueProvider,
|
|
151
|
-
{
|
|
152
|
-
scope: props.__scopeToggleGroup,
|
|
153
|
-
type: "multiple",
|
|
154
|
-
value,
|
|
155
|
-
defaultValue: value,
|
|
156
|
-
onItemActivate: handleButtonActivate,
|
|
157
|
-
onItemDeactivate: handleButtonDeactivate,
|
|
158
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
ToggleGroup.displayName = TOGGLE_GROUP_NAME;
|
|
163
|
-
const ToggleGroupImplElementFrame = (0, import_web.styled)(import_group.Group, {
|
|
164
|
-
name: TOGGLE_GROUP_NAME,
|
|
165
|
-
variants: {
|
|
166
|
-
unstyled: {
|
|
167
|
-
false: {
|
|
168
|
-
backgroundColor: "$background"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
orientation: {
|
|
172
|
-
vertical: {
|
|
173
|
-
flexDirection: "column",
|
|
174
|
-
spaceDirection: "vertical"
|
|
175
|
-
},
|
|
176
|
-
horizontal: {
|
|
177
|
-
flexDirection: "row",
|
|
178
|
-
spaceDirection: "horizontal"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
defaultVariants: {
|
|
183
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
184
|
-
}
|
|
185
|
-
}), ToggleGroupImpl = ToggleGroupImplElementFrame.extractable(
|
|
186
|
-
import_react.default.forwardRef(
|
|
187
|
-
(props, forwardedRef) => {
|
|
188
|
-
const {
|
|
189
|
-
__scopeToggleGroup,
|
|
190
|
-
disabled = !1,
|
|
191
|
-
orientation = "horizontal",
|
|
192
|
-
dir,
|
|
193
|
-
rovingFocus = !0,
|
|
194
|
-
loop = !0,
|
|
195
|
-
unstyled = !1,
|
|
196
|
-
size: sizeProp = "$true",
|
|
197
|
-
sizeAdjust = 0,
|
|
198
|
-
...toggleGroupProps
|
|
199
|
-
} = props, direction = (0, import_use_direction.useDirection)(dir), commonProps = {
|
|
200
|
-
role: "group",
|
|
201
|
-
dir: direction,
|
|
202
|
-
...toggleGroupProps
|
|
203
|
-
}, adjustedSize = (0, import_web.getVariableValue)(
|
|
204
|
-
(0, import_get_token.getSize)(sizeProp, {
|
|
205
|
-
shift: sizeAdjust
|
|
206
|
-
})
|
|
207
|
-
), size = Math.round(adjustedSize * 0.45);
|
|
208
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
209
|
-
ToggleGroupContext,
|
|
210
|
-
{
|
|
211
|
-
scope: __scopeToggleGroup,
|
|
212
|
-
rovingFocus,
|
|
213
|
-
disabled,
|
|
214
|
-
size,
|
|
215
|
-
children: rovingFocus ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
216
|
-
import_roving_focus.RovingFocusGroup,
|
|
217
|
-
{
|
|
218
|
-
asChild: "except-style",
|
|
219
|
-
__scopeRovingFocusGroup: __scopeToggleGroup || TOGGLE_GROUP_CONTEXT,
|
|
220
|
-
orientation,
|
|
221
|
-
dir: direction,
|
|
222
|
-
loop,
|
|
223
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
|
-
ToggleGroupImplElementFrame,
|
|
225
|
-
{
|
|
226
|
-
"aria-orientation": orientation,
|
|
227
|
-
orientation,
|
|
228
|
-
axis: orientation,
|
|
229
|
-
ref: forwardedRef,
|
|
230
|
-
"data-disabled": disabled ? "" : void 0,
|
|
231
|
-
unstyled,
|
|
232
|
-
...commonProps
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
|
-
ToggleGroupImplElementFrame,
|
|
238
|
-
{
|
|
239
|
-
"aria-orientation": orientation,
|
|
240
|
-
ref: forwardedRef,
|
|
241
|
-
orientation,
|
|
242
|
-
"data-disabled": disabled ? "" : void 0,
|
|
243
|
-
unstyled,
|
|
244
|
-
...commonProps
|
|
245
|
-
}
|
|
246
|
-
)
|
|
247
|
-
}
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
)
|
|
251
|
-
);
|
|
252
|
-
//# sourceMappingURL=ToggleGroup.js.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var src_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(src_exports);
|
|
14
|
-
__reExport(src_exports, require("./ToggleGroup"), module.exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|