@tamagui/radio-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.
- package/dist/cjs/RadioGroup.js +49 -130
- package/dist/cjs/RadioGroup.js.map +1 -1
- package/dist/cjs/RadioGroup.native.js +321 -0
- package/dist/cjs/RadioGroup.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/RadioGroup.js +43 -109
- package/dist/esm/RadioGroup.js.map +1 -1
- package/dist/jsx/RadioGroup.js +38 -103
- package/dist/jsx/RadioGroup.js.map +1 -1
- package/dist/jsx/RadioGroup.native.js +284 -0
- package/dist/jsx/RadioGroup.native.js.map +6 -0
- package/dist/jsx/index.native.js +2 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +11 -11
package/dist/cjs/RadioGroup.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,35 +17,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var RadioGroup_exports = {};
|
|
30
24
|
__export(RadioGroup_exports, {
|
|
31
25
|
RadioGroup: () => RadioGroup,
|
|
32
26
|
createRadioGroupScope: () => createRadioGroupScope
|
|
33
27
|
});
|
|
34
28
|
module.exports = __toCommonJS(RadioGroup_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
|
|
37
|
-
var import_create_context = require("@tamagui/create-context");
|
|
38
|
-
var import_focusable = require("@tamagui/focusable");
|
|
39
|
-
var import_get_token = require("@tamagui/get-token");
|
|
40
|
-
var import_label = require("@tamagui/label");
|
|
41
|
-
var import_stacks = require("@tamagui/stacks");
|
|
42
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
43
|
-
var import_use_previous = require("@tamagui/use-previous");
|
|
44
|
-
var React = __toESM(require("react"));
|
|
45
|
-
const RADIO_GROUP_NAME = "RadioGroup";
|
|
46
|
-
const ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
47
|
-
const [createRadioGroupContext, createRadioGroupScope] = (0, import_create_context.createContextScope)(RADIO_GROUP_NAME);
|
|
48
|
-
const [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
49
|
-
const getState = (checked) => {
|
|
50
|
-
return checked ? "checked" : "unchecked";
|
|
51
|
-
};
|
|
52
|
-
const RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator";
|
|
53
|
-
const RadioIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
29
|
+
var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_get_token = require("@tamagui/get-token"), import_label = require("@tamagui/label"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const RADIO_GROUP_NAME = "RadioGroup", ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], [createRadioGroupContext, createRadioGroupScope] = (0, import_create_context.createContextScope)(RADIO_GROUP_NAME), [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME), getState = (checked) => checked ? "checked" : "unchecked", RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator", RadioIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
54
31
|
name: RADIO_GROUP_INDICATOR_NAME,
|
|
55
32
|
variants: {
|
|
56
33
|
unstyled: {
|
|
@@ -59,41 +36,34 @@ const RadioIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack
|
|
|
59
36
|
height: "33%",
|
|
60
37
|
borderRadius: 1e3,
|
|
61
38
|
backgroundColor: "$color",
|
|
62
|
-
pressTheme:
|
|
39
|
+
pressTheme: !0
|
|
63
40
|
}
|
|
64
41
|
}
|
|
65
42
|
},
|
|
66
43
|
defaultVariants: {
|
|
67
|
-
unstyled:
|
|
44
|
+
unstyled: !1
|
|
68
45
|
}
|
|
69
|
-
})
|
|
70
|
-
const RadioIndicator = RadioIndicatorFrame.extractable(
|
|
46
|
+
}), RadioIndicator = RadioIndicatorFrame.extractable(
|
|
71
47
|
React.forwardRef(
|
|
72
48
|
(props, forwardedRef) => {
|
|
73
|
-
const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props
|
|
74
|
-
const { checked } = useRadioGroupItemContext(
|
|
49
|
+
const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props, { checked } = useRadioGroupItemContext(
|
|
75
50
|
RADIO_GROUP_INDICATOR_NAME,
|
|
76
51
|
__scopeRadioGroupItem
|
|
77
52
|
);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
53
|
+
return forceMount || checked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
RadioIndicatorFrame,
|
|
55
|
+
{
|
|
56
|
+
"data-state": getState(checked),
|
|
57
|
+
"data-disabled": disabled ? "" : void 0,
|
|
58
|
+
...indicatorProps,
|
|
59
|
+
ref: forwardedRef
|
|
60
|
+
}
|
|
61
|
+
) : null;
|
|
90
62
|
}
|
|
91
63
|
)
|
|
92
64
|
);
|
|
93
65
|
RadioIndicator.displayName = RADIO_GROUP_INDICATOR_NAME;
|
|
94
|
-
const RADIO_GROUP_ITEM_NAME = "RadioGroupItem"
|
|
95
|
-
const [RadioGroupItemProvider, useRadioGroupItemContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
96
|
-
const RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
66
|
+
const RADIO_GROUP_ITEM_NAME = "RadioGroupItem", [RadioGroupItemProvider, useRadioGroupItemContext] = createRadioGroupContext(RADIO_GROUP_NAME), RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
97
67
|
name: RADIO_GROUP_ITEM_NAME,
|
|
98
68
|
tag: "button",
|
|
99
69
|
variants: {
|
|
@@ -124,7 +94,7 @@ const RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack
|
|
|
124
94
|
size: {
|
|
125
95
|
"...size": (value, { props }) => {
|
|
126
96
|
const size = Math.floor(
|
|
127
|
-
(0, import_core.getVariableValue)((0, import_get_token.getSize)(value)) * (props
|
|
97
|
+
(0, import_core.getVariableValue)((0, import_get_token.getSize)(value)) * (props.scaleSize ?? 0.5)
|
|
128
98
|
);
|
|
129
99
|
return {
|
|
130
100
|
width: size,
|
|
@@ -134,10 +104,9 @@ const RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack
|
|
|
134
104
|
}
|
|
135
105
|
},
|
|
136
106
|
defaultVariants: {
|
|
137
|
-
unstyled:
|
|
107
|
+
unstyled: !1
|
|
138
108
|
}
|
|
139
|
-
})
|
|
140
|
-
const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
109
|
+
}), RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
141
110
|
React.forwardRef(
|
|
142
111
|
(props, forwardedRef) => {
|
|
143
112
|
const {
|
|
@@ -146,8 +115,7 @@ const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
|
146
115
|
labelledBy: ariaLabelledby,
|
|
147
116
|
disabled: itemDisabled,
|
|
148
117
|
...itemProps
|
|
149
|
-
} = props
|
|
150
|
-
const {
|
|
118
|
+
} = props, {
|
|
151
119
|
value: groupValue,
|
|
152
120
|
disabled,
|
|
153
121
|
required,
|
|
@@ -155,47 +123,19 @@ const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
|
155
123
|
name,
|
|
156
124
|
native,
|
|
157
125
|
accentColor
|
|
158
|
-
} = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup);
|
|
159
|
-
const [button, setButton] = React.useState(null);
|
|
160
|
-
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
161
|
-
const ref = React.useRef(null);
|
|
162
|
-
const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node), ref);
|
|
163
|
-
const isArrowKeyPressedRef = React.useRef(false);
|
|
164
|
-
const isFormControl = import_core.isWeb ? button ? Boolean(button.closest("form")) : true : false;
|
|
165
|
-
const checked = groupValue === value;
|
|
166
|
-
const labelId = (0, import_label.useLabelContext)(button);
|
|
167
|
-
const labelledBy = ariaLabelledby || labelId;
|
|
126
|
+
} = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup), [button, setButton] = React.useState(null), hasConsumerStoppedPropagationRef = React.useRef(!1), ref = React.useRef(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node), ref), isArrowKeyPressedRef = React.useRef(!1), isFormControl = import_core.isWeb ? button ? !!button.closest("form") : !0 : !1, checked = groupValue === value, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
|
|
168
127
|
React.useEffect(() => {
|
|
169
128
|
if (import_core.isWeb) {
|
|
170
129
|
const handleKeyDown = (event) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
130
|
+
ARROW_KEYS.includes(event.key) && (isArrowKeyPressedRef.current = !0);
|
|
131
|
+
}, handleKeyUp = () => {
|
|
132
|
+
isArrowKeyPressedRef.current = !1;
|
|
174
133
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
179
|
-
document.addEventListener("keyup", handleKeyUp);
|
|
180
|
-
return () => {
|
|
181
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
182
|
-
document.removeEventListener("keyup", handleKeyUp);
|
|
134
|
+
return document.addEventListener("keydown", handleKeyDown), document.addEventListener("keyup", handleKeyUp), () => {
|
|
135
|
+
document.removeEventListener("keydown", handleKeyDown), document.removeEventListener("keyup", handleKeyUp);
|
|
183
136
|
};
|
|
184
137
|
}
|
|
185
138
|
}, []);
|
|
186
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
187
|
-
React.useEffect(() => {
|
|
188
|
-
if (!props.id)
|
|
189
|
-
return;
|
|
190
|
-
return (0, import_focusable.registerFocusable)(props.id, {
|
|
191
|
-
focusAndSelect: () => {
|
|
192
|
-
onChange == null ? void 0 : onChange(value);
|
|
193
|
-
},
|
|
194
|
-
focus: () => {
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}, [props.id, value]);
|
|
198
|
-
}
|
|
199
139
|
const isDisabled = disabled || itemDisabled;
|
|
200
140
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemProvider, { checked, scope: __scopeRadioGroup, children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
141
|
BubbleInput,
|
|
@@ -228,27 +168,17 @@ const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
|
228
168
|
},
|
|
229
169
|
...itemProps,
|
|
230
170
|
onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
|
|
231
|
-
|
|
232
|
-
onChange == null ? void 0 : onChange(value);
|
|
233
|
-
}
|
|
234
|
-
if (isFormControl) {
|
|
235
|
-
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
236
|
-
if (!hasConsumerStoppedPropagationRef.current)
|
|
237
|
-
event.stopPropagation();
|
|
238
|
-
}
|
|
171
|
+
checked || onChange?.(value), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
239
172
|
}),
|
|
240
173
|
...import_core.isWeb && {
|
|
241
174
|
onKeyDown: (0, import_core.composeEventHandlers)(
|
|
242
175
|
props.onKeyDown,
|
|
243
176
|
(event) => {
|
|
244
|
-
|
|
245
|
-
event.preventDefault();
|
|
177
|
+
event.key === "Enter" && event.preventDefault();
|
|
246
178
|
}
|
|
247
179
|
),
|
|
248
180
|
onFocus: (0, import_core.composeEventHandlers)(itemProps.onFocus, () => {
|
|
249
|
-
|
|
250
|
-
if (isArrowKeyPressedRef.current)
|
|
251
|
-
(_a = ref.current) == null ? void 0 : _a.click();
|
|
181
|
+
isArrowKeyPressedRef.current && ref.current?.click();
|
|
252
182
|
})
|
|
253
183
|
}
|
|
254
184
|
}
|
|
@@ -256,7 +186,7 @@ const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
|
256
186
|
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
257
187
|
BubbleInput,
|
|
258
188
|
{
|
|
259
|
-
isHidden:
|
|
189
|
+
isHidden: !0,
|
|
260
190
|
control: button,
|
|
261
191
|
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
262
192
|
name,
|
|
@@ -269,26 +199,18 @@ const RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
|
269
199
|
] }) });
|
|
270
200
|
}
|
|
271
201
|
)
|
|
272
|
-
)
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
277
|
-
React.useEffect(() => {
|
|
278
|
-
const input = ref.current;
|
|
279
|
-
const inputProto = window.HTMLInputElement.prototype;
|
|
280
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
202
|
+
), BubbleInput = (props) => {
|
|
203
|
+
const { checked, bubbles = !0, control, isHidden, accentColor, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
204
|
+
return React.useEffect(() => {
|
|
205
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
281
206
|
inputProto,
|
|
282
207
|
"checked"
|
|
283
|
-
);
|
|
284
|
-
const setChecked = descriptor.set;
|
|
208
|
+
).set;
|
|
285
209
|
if (prevChecked !== checked && setChecked) {
|
|
286
210
|
const event = new Event("click", { bubbles });
|
|
287
|
-
setChecked.call(input, checked);
|
|
288
|
-
input.dispatchEvent(event);
|
|
211
|
+
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
289
212
|
}
|
|
290
|
-
}, [prevChecked, checked, bubbles])
|
|
291
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
292
214
|
"input",
|
|
293
215
|
{
|
|
294
216
|
type: "radio",
|
|
@@ -312,8 +234,7 @@ const BubbleInput = (props) => {
|
|
|
312
234
|
}
|
|
313
235
|
}
|
|
314
236
|
);
|
|
315
|
-
}
|
|
316
|
-
const RadioGroupFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
237
|
+
}, RadioGroupFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
317
238
|
name: RADIO_GROUP_NAME,
|
|
318
239
|
variants: {
|
|
319
240
|
orientation: {
|
|
@@ -327,8 +248,7 @@ const RadioGroupFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
|
327
248
|
}
|
|
328
249
|
}
|
|
329
250
|
}
|
|
330
|
-
})
|
|
331
|
-
const RadioGroup = (0, import_core.withStaticProperties)(
|
|
251
|
+
}), RadioGroup = (0, import_core.withStaticProperties)(
|
|
332
252
|
RadioGroupFrame.extractable(
|
|
333
253
|
React.forwardRef(
|
|
334
254
|
(props, forwardedRef) => {
|
|
@@ -337,15 +257,14 @@ const RadioGroup = (0, import_core.withStaticProperties)(
|
|
|
337
257
|
value: valueProp,
|
|
338
258
|
defaultValue,
|
|
339
259
|
onValueChange,
|
|
340
|
-
disabled =
|
|
341
|
-
required =
|
|
260
|
+
disabled = !1,
|
|
261
|
+
required = !1,
|
|
342
262
|
name,
|
|
343
263
|
orientation,
|
|
344
264
|
native,
|
|
345
265
|
accentColor,
|
|
346
266
|
...radioGroupProps
|
|
347
|
-
} = props
|
|
348
|
-
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
267
|
+
} = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
349
268
|
prop: valueProp,
|
|
350
269
|
defaultProp: defaultValue,
|
|
351
270
|
onChange: onValueChange
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/RadioGroup.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAQO,0BACP,wBAA0C,oCAC1C,mBAAkC,+BAClC,mBAAwB,+BACxB,eAAgC,2BAChC,gBAA+B,4BAC/B,gCAAqC,4CACrC,sBAA4B,kCAC5B,QAAuB,2BAqEb;AAlEV,MAAM,mBAAmB,cAEnB,aAAa,CAAC,WAAW,aAAa,aAAa,YAAY,GAE/D,CAAC,yBAAyB,qBAAqB,QACnD,0CAAmB,gBAAgB,GAU/B,CAAC,oBAAoB,oBAAoB,IAC7C,wBAAgD,gBAAgB,GAE5D,WAAW,CAAC,YACT,UAAU,YAAY,aAOzB,6BAA6B,uBAE7B,0BAAsB,oBAAO,8BAAgB;AAAA,EACjD,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AA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AA,UACA;AAAA,UACA,GAAG;AAAA,QACL,IAAI,OACE,CAAC,OAAO,QAAQ,QAAI,oDAAqB;AAAA,UAC7C,MAAM;AAAA,UACN,aAAa;AAAA,UACb,UAAU;AAAA,QACZ,CAAC;AAED,eACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC,kBAAgB;AAAA,gBAChB,MAAK;AAAA,gBACL,oBAAkB;AAAA,gBAClB,KAAK;AAAA,gBACL;AAAA,gBACA,iBAAe,WAAW,KAAK;AAAA,gBAC9B,GAAG;AAAA;AAAA,YACN;AAAA;AAAA,QACF;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,WAAW;AAAA,IACX,MAAM;AAAA,EACR;AACF;AAEA,WAAW,cAAc;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,321 @@
|
|
|
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 RadioGroup_exports = {};
|
|
25
|
+
__export(RadioGroup_exports, {
|
|
26
|
+
RadioGroup: () => RadioGroup,
|
|
27
|
+
createRadioGroupScope: () => createRadioGroupScope
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(RadioGroup_exports);
|
|
30
|
+
var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_get_token = require("@tamagui/get-token"), import_label = require("@tamagui/label"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_previous = require("@tamagui/use-previous"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
const RADIO_GROUP_NAME = "RadioGroup", ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], [createRadioGroupContext, createRadioGroupScope] = (0, import_create_context.createContextScope)(RADIO_GROUP_NAME), [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME), getState = (checked) => checked ? "checked" : "unchecked", RADIO_GROUP_INDICATOR_NAME = "RadioGroupIndicator", RadioIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
32
|
+
name: RADIO_GROUP_INDICATOR_NAME,
|
|
33
|
+
variants: {
|
|
34
|
+
unstyled: {
|
|
35
|
+
false: {
|
|
36
|
+
width: "33%",
|
|
37
|
+
height: "33%",
|
|
38
|
+
borderRadius: 1e3,
|
|
39
|
+
backgroundColor: "$color",
|
|
40
|
+
pressTheme: !0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
unstyled: !1
|
|
46
|
+
}
|
|
47
|
+
}), RadioIndicator = RadioIndicatorFrame.extractable(
|
|
48
|
+
React.forwardRef(
|
|
49
|
+
(props, forwardedRef) => {
|
|
50
|
+
const { __scopeRadioGroupItem, forceMount, disabled, ...indicatorProps } = props, { checked } = useRadioGroupItemContext(
|
|
51
|
+
RADIO_GROUP_INDICATOR_NAME,
|
|
52
|
+
__scopeRadioGroupItem
|
|
53
|
+
);
|
|
54
|
+
return forceMount || checked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
RadioIndicatorFrame,
|
|
56
|
+
{
|
|
57
|
+
"data-state": getState(checked),
|
|
58
|
+
"data-disabled": disabled ? "" : void 0,
|
|
59
|
+
...indicatorProps,
|
|
60
|
+
ref: forwardedRef
|
|
61
|
+
}
|
|
62
|
+
) : null;
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
RadioIndicator.displayName = RADIO_GROUP_INDICATOR_NAME;
|
|
67
|
+
const RADIO_GROUP_ITEM_NAME = "RadioGroupItem", [RadioGroupItemProvider, useRadioGroupItemContext] = createRadioGroupContext(RADIO_GROUP_NAME), RadioGroupItemFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
68
|
+
name: RADIO_GROUP_ITEM_NAME,
|
|
69
|
+
tag: "button",
|
|
70
|
+
variants: {
|
|
71
|
+
unstyled: {
|
|
72
|
+
false: {
|
|
73
|
+
size: "$true",
|
|
74
|
+
borderRadius: 1e3,
|
|
75
|
+
backgroundColor: "$background",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
justifyContent: "center",
|
|
78
|
+
borderWidth: 1,
|
|
79
|
+
borderColor: "$borderColor",
|
|
80
|
+
padding: 0,
|
|
81
|
+
hoverStyle: {
|
|
82
|
+
borderColor: "$borderColorHover",
|
|
83
|
+
backgroundColor: "$backgroundHover"
|
|
84
|
+
},
|
|
85
|
+
focusStyle: {
|
|
86
|
+
borderColor: "$borderColorHover",
|
|
87
|
+
backgroundColor: "$backgroundHover"
|
|
88
|
+
},
|
|
89
|
+
pressStyle: {
|
|
90
|
+
borderColor: "$borderColorFocus",
|
|
91
|
+
backgroundColor: "$backgroundFocus"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
size: {
|
|
96
|
+
"...size": (value, { props }) => {
|
|
97
|
+
const size = Math.floor(
|
|
98
|
+
(0, import_core.getVariableValue)((0, import_get_token.getSize)(value)) * (props.scaleSize ?? 0.5)
|
|
99
|
+
);
|
|
100
|
+
return {
|
|
101
|
+
width: size,
|
|
102
|
+
height: size
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
defaultVariants: {
|
|
108
|
+
unstyled: !1
|
|
109
|
+
}
|
|
110
|
+
}), RadioGroupItem = RadioGroupItemFrame.extractable(
|
|
111
|
+
React.forwardRef(
|
|
112
|
+
(props, forwardedRef) => {
|
|
113
|
+
const {
|
|
114
|
+
__scopeRadioGroup,
|
|
115
|
+
value,
|
|
116
|
+
labelledBy: ariaLabelledby,
|
|
117
|
+
disabled: itemDisabled,
|
|
118
|
+
...itemProps
|
|
119
|
+
} = props, {
|
|
120
|
+
value: groupValue,
|
|
121
|
+
disabled,
|
|
122
|
+
required,
|
|
123
|
+
onChange,
|
|
124
|
+
name,
|
|
125
|
+
native,
|
|
126
|
+
accentColor
|
|
127
|
+
} = useRadioGroupContext(RADIO_GROUP_ITEM_NAME, __scopeRadioGroup), [button, setButton] = React.useState(null), hasConsumerStoppedPropagationRef = React.useRef(!1), ref = React.useRef(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, (node) => setButton(node), ref), isArrowKeyPressedRef = React.useRef(!1), isFormControl = import_core.isWeb ? button ? !!button.closest("form") : !0 : !1, checked = groupValue === value, labelId = (0, import_label.useLabelContext)(button), labelledBy = ariaLabelledby || labelId;
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
if (import_core.isWeb) {
|
|
130
|
+
const handleKeyDown = (event) => {
|
|
131
|
+
ARROW_KEYS.includes(event.key) && (isArrowKeyPressedRef.current = !0);
|
|
132
|
+
}, handleKeyUp = () => {
|
|
133
|
+
isArrowKeyPressedRef.current = !1;
|
|
134
|
+
};
|
|
135
|
+
return document.addEventListener("keydown", handleKeyDown), document.addEventListener("keyup", handleKeyUp), () => {
|
|
136
|
+
document.removeEventListener("keydown", handleKeyDown), document.removeEventListener("keyup", handleKeyUp);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}, []), React.useEffect(() => {
|
|
140
|
+
if (props.id)
|
|
141
|
+
return (0, import_focusable.registerFocusable)(props.id, {
|
|
142
|
+
focusAndSelect: () => {
|
|
143
|
+
onChange?.(value);
|
|
144
|
+
},
|
|
145
|
+
focus: () => {
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}, [props.id, value]);
|
|
149
|
+
const isDisabled = disabled || itemDisabled;
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroupItemProvider, { checked, scope: __scopeRadioGroup, children: import_core.isWeb && native ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
|
+
BubbleInput,
|
|
152
|
+
{
|
|
153
|
+
control: button,
|
|
154
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
155
|
+
name,
|
|
156
|
+
value,
|
|
157
|
+
checked,
|
|
158
|
+
required,
|
|
159
|
+
disabled: isDisabled,
|
|
160
|
+
id: props.id,
|
|
161
|
+
accentColor
|
|
162
|
+
}
|
|
163
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
+
RadioGroupItemFrame,
|
|
166
|
+
{
|
|
167
|
+
"data-state": getState(checked),
|
|
168
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
169
|
+
role: "radio",
|
|
170
|
+
"aria-labelledby": labelledBy,
|
|
171
|
+
"aria-checked": checked,
|
|
172
|
+
"aria-required": required,
|
|
173
|
+
disabled: isDisabled,
|
|
174
|
+
ref: composedRefs,
|
|
175
|
+
...import_core.isWeb && {
|
|
176
|
+
type: "button",
|
|
177
|
+
value
|
|
178
|
+
},
|
|
179
|
+
...itemProps,
|
|
180
|
+
onPress: (0, import_core.composeEventHandlers)(props.onPress, (event) => {
|
|
181
|
+
checked || onChange?.(value), isFormControl && (hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(), hasConsumerStoppedPropagationRef.current || event.stopPropagation());
|
|
182
|
+
}),
|
|
183
|
+
...import_core.isWeb && {
|
|
184
|
+
onKeyDown: (0, import_core.composeEventHandlers)(
|
|
185
|
+
props.onKeyDown,
|
|
186
|
+
(event) => {
|
|
187
|
+
event.key === "Enter" && event.preventDefault();
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
onFocus: (0, import_core.composeEventHandlers)(itemProps.onFocus, () => {
|
|
191
|
+
isArrowKeyPressedRef.current && ref.current?.click();
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
|
+
BubbleInput,
|
|
198
|
+
{
|
|
199
|
+
isHidden: !0,
|
|
200
|
+
control: button,
|
|
201
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
202
|
+
name,
|
|
203
|
+
value,
|
|
204
|
+
checked,
|
|
205
|
+
required,
|
|
206
|
+
disabled: isDisabled
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
] }) });
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
), BubbleInput = (props) => {
|
|
213
|
+
const { checked, bubbles = !0, control, isHidden, accentColor, ...inputProps } = props, ref = React.useRef(null), prevChecked = (0, import_use_previous.usePrevious)(checked);
|
|
214
|
+
return React.useEffect(() => {
|
|
215
|
+
const input = ref.current, inputProto = window.HTMLInputElement.prototype, setChecked = Object.getOwnPropertyDescriptor(
|
|
216
|
+
inputProto,
|
|
217
|
+
"checked"
|
|
218
|
+
).set;
|
|
219
|
+
if (prevChecked !== checked && setChecked) {
|
|
220
|
+
const event = new Event("click", { bubbles });
|
|
221
|
+
setChecked.call(input, checked), input.dispatchEvent(event);
|
|
222
|
+
}
|
|
223
|
+
}, [prevChecked, checked, bubbles]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
|
+
"input",
|
|
225
|
+
{
|
|
226
|
+
type: "radio",
|
|
227
|
+
defaultChecked: checked,
|
|
228
|
+
...inputProps,
|
|
229
|
+
tabIndex: -1,
|
|
230
|
+
ref,
|
|
231
|
+
"aria-hidden": isHidden,
|
|
232
|
+
style: {
|
|
233
|
+
...isHidden ? {
|
|
234
|
+
// ...controlSize,
|
|
235
|
+
position: "absolute",
|
|
236
|
+
pointerEvents: "none",
|
|
237
|
+
opacity: 0,
|
|
238
|
+
margin: 0
|
|
239
|
+
} : {
|
|
240
|
+
appearance: "auto",
|
|
241
|
+
accentColor
|
|
242
|
+
},
|
|
243
|
+
...props.style
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
}, RadioGroupFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
248
|
+
name: RADIO_GROUP_NAME,
|
|
249
|
+
variants: {
|
|
250
|
+
orientation: {
|
|
251
|
+
horizontal: {
|
|
252
|
+
flexDirection: "row",
|
|
253
|
+
spaceDirection: "horizontal"
|
|
254
|
+
},
|
|
255
|
+
vertical: {
|
|
256
|
+
flexDirection: "column",
|
|
257
|
+
spaceDirection: "vertical"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}), RadioGroup = (0, import_core.withStaticProperties)(
|
|
262
|
+
RadioGroupFrame.extractable(
|
|
263
|
+
React.forwardRef(
|
|
264
|
+
(props, forwardedRef) => {
|
|
265
|
+
const {
|
|
266
|
+
__scopeRadioGroup,
|
|
267
|
+
value: valueProp,
|
|
268
|
+
defaultValue,
|
|
269
|
+
onValueChange,
|
|
270
|
+
disabled = !1,
|
|
271
|
+
required = !1,
|
|
272
|
+
name,
|
|
273
|
+
orientation,
|
|
274
|
+
native,
|
|
275
|
+
accentColor,
|
|
276
|
+
...radioGroupProps
|
|
277
|
+
} = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
278
|
+
prop: valueProp,
|
|
279
|
+
defaultProp: defaultValue,
|
|
280
|
+
onChange: onValueChange
|
|
281
|
+
});
|
|
282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
283
|
+
RadioGroupProvider,
|
|
284
|
+
{
|
|
285
|
+
scope: __scopeRadioGroup,
|
|
286
|
+
value,
|
|
287
|
+
required,
|
|
288
|
+
onChange: setValue,
|
|
289
|
+
disabled,
|
|
290
|
+
name,
|
|
291
|
+
native,
|
|
292
|
+
accentColor,
|
|
293
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
294
|
+
RadioGroupFrame,
|
|
295
|
+
{
|
|
296
|
+
"aria-valuetext": value,
|
|
297
|
+
role: "radiogroup",
|
|
298
|
+
"aria-orientation": orientation,
|
|
299
|
+
ref: forwardedRef,
|
|
300
|
+
orientation,
|
|
301
|
+
"data-disabled": disabled ? "" : void 0,
|
|
302
|
+
...radioGroupProps
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
),
|
|
310
|
+
{
|
|
311
|
+
Indicator: RadioIndicator,
|
|
312
|
+
Item: RadioGroupItem
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
RadioGroup.displayName = RADIO_GROUP_NAME;
|
|
316
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
317
|
+
0 && (module.exports = {
|
|
318
|
+
RadioGroup,
|
|
319
|
+
createRadioGroupScope
|
|
320
|
+
});
|
|
321
|
+
//# sourceMappingURL=RadioGroup.js.map
|