@radix-ui/react-radio-group 1.1.4-rc.9 → 1.2.0-rc.2

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/index.js CHANGED
@@ -1,290 +1,308 @@
1
- var $9yYIj$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $9yYIj$react = require("react");
3
- var $9yYIj$radixuiprimitive = require("@radix-ui/primitive");
4
- var $9yYIj$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
5
- var $9yYIj$radixuireactcontext = require("@radix-ui/react-context");
6
- var $9yYIj$radixuireactprimitive = require("@radix-ui/react-primitive");
7
- var $9yYIj$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
8
- var $9yYIj$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
9
- var $9yYIj$radixuireactdirection = require("@radix-ui/react-direction");
10
- var $9yYIj$radixuireactusesize = require("@radix-ui/react-use-size");
11
- var $9yYIj$radixuireactuseprevious = require("@radix-ui/react-use-previous");
12
- var $9yYIj$radixuireactpresence = require("@radix-ui/react-presence");
1
+ "use strict";
2
+ "use client";
3
+ (() => {
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
13
32
 
14
- function $parcel$export(e, n, v, s) {
15
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
16
- }
17
- function $parcel$interopDefault(a) {
18
- return a && a.__esModule ? a.default : a;
19
- }
33
+ // packages/react/radio-group/src/RadioGroup.tsx
34
+ var React2 = __toESM(__require("react"));
35
+ var import_primitive2 = __require("@radix-ui/primitive");
36
+ var import_react_compose_refs2 = __require("@radix-ui/react-compose-refs");
37
+ var import_react_context2 = __require("@radix-ui/react-context");
38
+ var import_react_primitive2 = __require("@radix-ui/react-primitive");
39
+ var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus"));
40
+ var import_react_roving_focus = __require("@radix-ui/react-roving-focus");
41
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
42
+ var import_react_direction = __require("@radix-ui/react-direction");
20
43
 
21
- $parcel$export(module.exports, "createRadioGroupScope", () => $240483839a8a76fd$export$c547093f11b76da2);
22
- $parcel$export(module.exports, "RadioGroup", () => $240483839a8a76fd$export$a98f0dcb43a68a25);
23
- $parcel$export(module.exports, "RadioGroupItem", () => $240483839a8a76fd$export$9f866c100ef519e4);
24
- $parcel$export(module.exports, "RadioGroupIndicator", () => $240483839a8a76fd$export$5fb54c671a65c88);
25
- $parcel$export(module.exports, "Root", () => $240483839a8a76fd$export$be92b6f5f03c0fe9);
26
- $parcel$export(module.exports, "Item", () => $240483839a8a76fd$export$6d08773d2e66f8f2);
27
- $parcel$export(module.exports, "Indicator", () => $240483839a8a76fd$export$adb584737d712b70);
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
- /* -------------------------------------------------------------------------------------------------
48
- * Radio
49
- * -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$RADIO_NAME = 'Radio';
50
- const [$ce74a64c62457efb$var$createRadioContext, $ce74a64c62457efb$export$67d2296460f1b002] = $9yYIj$radixuireactcontext.createContextScope($ce74a64c62457efb$var$RADIO_NAME);
51
- const [$ce74a64c62457efb$var$RadioProvider, $ce74a64c62457efb$var$useRadioContext] = $ce74a64c62457efb$var$createRadioContext($ce74a64c62457efb$var$RADIO_NAME);
52
- const $ce74a64c62457efb$export$d7b12c4107be0d61 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
53
- const { __scopeRadio: __scopeRadio , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
54
- const [button, setButton] = $9yYIj$react.useState(null);
55
- const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setButton(node)
56
- );
57
- const hasConsumerStoppedPropagationRef = $9yYIj$react.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
58
- const isFormControl = button ? Boolean(button.closest('form')) : true;
59
- return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$RadioProvider, {
60
- scope: __scopeRadio,
61
- checked: checked,
62
- disabled: disabled
63
- }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
64
- type: "button",
65
- role: "radio",
66
- "aria-checked": checked,
67
- "data-state": $ce74a64c62457efb$var$getState(checked),
68
- "data-disabled": disabled ? '' : undefined,
69
- disabled: disabled,
70
- value: value
71
- }, radioProps, {
72
- ref: composedRefs,
73
- onClick: $9yYIj$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
74
- // radios cannot be unchecked so we only communicate a checked state
75
- if (!checked) onCheck === null || onCheck === void 0 || onCheck();
76
- if (isFormControl) {
77
- hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
78
- // one click event (from the input). We propagate changes from an input so that native
79
- // form validation works and form events reflect radio updates.
44
+ // packages/react/radio-group/src/Radio.tsx
45
+ var React = __toESM(__require("react"));
46
+ var import_primitive = __require("@radix-ui/primitive");
47
+ var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
48
+ var import_react_context = __require("@radix-ui/react-context");
49
+ var import_react_use_size = __require("@radix-ui/react-use-size");
50
+ var import_react_use_previous = __require("@radix-ui/react-use-previous");
51
+ var import_react_presence = __require("@radix-ui/react-presence");
52
+ var import_react_primitive = __require("@radix-ui/react-primitive");
53
+ var import_jsx_runtime = __require("react/jsx-runtime");
54
+ var RADIO_NAME = "Radio";
55
+ var [createRadioContext, createRadioScope] = (0, import_react_context.createContextScope)(RADIO_NAME);
56
+ var [RadioProvider, useRadioContext] = createRadioContext(RADIO_NAME);
57
+ var Radio = React.forwardRef(
58
+ (props, forwardedRef) => {
59
+ const {
60
+ __scopeRadio,
61
+ name,
62
+ checked = false,
63
+ required,
64
+ disabled,
65
+ value = "on",
66
+ onCheck,
67
+ ...radioProps
68
+ } = props;
69
+ const [button, setButton] = React.useState(null);
70
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setButton(node));
71
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
72
+ const isFormControl = button ? Boolean(button.closest("form")) : true;
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioProvider, { scope: __scopeRadio, checked, disabled, children: [
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ import_react_primitive.Primitive.button,
76
+ {
77
+ type: "button",
78
+ role: "radio",
79
+ "aria-checked": checked,
80
+ "data-state": getState(checked),
81
+ "data-disabled": disabled ? "" : void 0,
82
+ disabled,
83
+ value,
84
+ ...radioProps,
85
+ ref: composedRefs,
86
+ onClick: (0, import_primitive.composeEventHandlers)(props.onClick, (event) => {
87
+ if (!checked) onCheck?.();
88
+ if (isFormControl) {
89
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
80
90
  if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
81
- }
82
- })
83
- })), isFormControl && /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$BubbleInput, {
84
- control: button,
85
- bubbles: !hasConsumerStoppedPropagationRef.current,
86
- name: name,
87
- value: value,
88
- checked: checked,
89
- required: required,
90
- disabled: disabled // We transform because the input is absolutely positioned but we have
91
- ,
92
- style: {
93
- transform: 'translateX(-100%)'
94
- }
95
- }));
96
- });
97
- /*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d7b12c4107be0d61, {
98
- displayName: $ce74a64c62457efb$var$RADIO_NAME
99
- });
100
- /* -------------------------------------------------------------------------------------------------
101
- * RadioIndicator
102
- * -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$INDICATOR_NAME = 'RadioIndicator';
103
- const $ce74a64c62457efb$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
104
- const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
105
- const context = $ce74a64c62457efb$var$useRadioContext($ce74a64c62457efb$var$INDICATOR_NAME, __scopeRadio);
106
- return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactpresence.Presence, {
107
- present: forceMount || context.checked
108
- }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
109
- "data-state": $ce74a64c62457efb$var$getState(context.checked),
110
- "data-disabled": context.disabled ? '' : undefined
111
- }, indicatorProps, {
112
- ref: forwardedRef
113
- })));
114
- });
115
- /*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d35a9ffa9a04f9e7, {
116
- displayName: $ce74a64c62457efb$var$INDICATOR_NAME
117
- });
118
- /* ---------------------------------------------------------------------------------------------- */ const $ce74a64c62457efb$var$BubbleInput = (props)=>{
119
- const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
120
- const ref = $9yYIj$react.useRef(null);
121
- const prevChecked = $9yYIj$radixuireactuseprevious.usePrevious(checked);
122
- const controlSize = $9yYIj$radixuireactusesize.useSize(control); // Bubble checked change to parents (e.g form change event)
123
- $9yYIj$react.useEffect(()=>{
124
- const input = ref.current;
125
- const inputProto = window.HTMLInputElement.prototype;
126
- const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
127
- const setChecked = descriptor.set;
128
- if (prevChecked !== checked && setChecked) {
129
- const event = new Event('click', {
130
- bubbles: bubbles
131
- });
132
- setChecked.call(input, checked);
133
- input.dispatchEvent(event);
91
+ }
92
+ })
93
+ }
94
+ ),
95
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
+ BubbleInput,
97
+ {
98
+ control: button,
99
+ bubbles: !hasConsumerStoppedPropagationRef.current,
100
+ name,
101
+ value,
102
+ checked,
103
+ required,
104
+ disabled,
105
+ style: { transform: "translateX(-100%)" }
106
+ }
107
+ )
108
+ ] });
109
+ }
110
+ );
111
+ Radio.displayName = RADIO_NAME;
112
+ var INDICATOR_NAME = "RadioIndicator";
113
+ var RadioIndicator = React.forwardRef(
114
+ (props, forwardedRef) => {
115
+ const { __scopeRadio, forceMount, ...indicatorProps } = props;
116
+ const context = useRadioContext(INDICATOR_NAME, __scopeRadio);
117
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.checked, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
118
+ import_react_primitive.Primitive.span,
119
+ {
120
+ "data-state": getState(context.checked),
121
+ "data-disabled": context.disabled ? "" : void 0,
122
+ ...indicatorProps,
123
+ ref: forwardedRef
134
124
  }
135
- }, [
136
- prevChecked,
137
- checked,
138
- bubbles
139
- ]);
140
- return /*#__PURE__*/ $9yYIj$react.createElement("input", ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
125
+ ) });
126
+ }
127
+ );
128
+ RadioIndicator.displayName = INDICATOR_NAME;
129
+ var BubbleInput = (props) => {
130
+ const { control, checked, bubbles = true, ...inputProps } = props;
131
+ const ref = React.useRef(null);
132
+ const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
133
+ const controlSize = (0, import_react_use_size.useSize)(control);
134
+ React.useEffect(() => {
135
+ const input = ref.current;
136
+ const inputProto = window.HTMLInputElement.prototype;
137
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
138
+ const setChecked = descriptor.set;
139
+ if (prevChecked !== checked && setChecked) {
140
+ const event = new Event("click", { bubbles });
141
+ setChecked.call(input, checked);
142
+ input.dispatchEvent(event);
143
+ }
144
+ }, [prevChecked, checked, bubbles]);
145
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
146
+ "input",
147
+ {
141
148
  type: "radio",
142
149
  "aria-hidden": true,
143
- defaultChecked: checked
144
- }, inputProps, {
150
+ defaultChecked: checked,
151
+ ...inputProps,
145
152
  tabIndex: -1,
146
- ref: ref,
153
+ ref,
147
154
  style: {
148
- ...props.style,
149
- ...controlSize,
150
- position: 'absolute',
151
- pointerEvents: 'none',
152
- opacity: 0,
153
- margin: 0
155
+ ...props.style,
156
+ ...controlSize,
157
+ position: "absolute",
158
+ pointerEvents: "none",
159
+ opacity: 0,
160
+ margin: 0
154
161
  }
155
- }));
156
- };
157
- function $ce74a64c62457efb$var$getState(checked) {
158
- return checked ? 'checked' : 'unchecked';
159
- }
160
-
162
+ }
163
+ );
164
+ };
165
+ function getState(checked) {
166
+ return checked ? "checked" : "unchecked";
167
+ }
161
168
 
162
- const $240483839a8a76fd$var$ARROW_KEYS = [
163
- 'ArrowUp',
164
- 'ArrowDown',
165
- 'ArrowLeft',
166
- 'ArrowRight'
167
- ];
168
- /* -------------------------------------------------------------------------------------------------
169
- * RadioGroup
170
- * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$RADIO_GROUP_NAME = 'RadioGroup';
171
- const [$240483839a8a76fd$var$createRadioGroupContext, $240483839a8a76fd$export$c547093f11b76da2] = $9yYIj$radixuireactcontext.createContextScope($240483839a8a76fd$var$RADIO_GROUP_NAME, [
172
- $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope,
173
- $ce74a64c62457efb$export$67d2296460f1b002
174
- ]);
175
- const $240483839a8a76fd$var$useRovingFocusGroupScope = $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope();
176
- const $240483839a8a76fd$var$useRadioScope = $ce74a64c62457efb$export$67d2296460f1b002();
177
- const [$240483839a8a76fd$var$RadioGroupProvider, $240483839a8a76fd$var$useRadioGroupContext] = $240483839a8a76fd$var$createRadioGroupContext($240483839a8a76fd$var$RADIO_GROUP_NAME);
178
- const $240483839a8a76fd$export$a98f0dcb43a68a25 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
179
- const { __scopeRadioGroup: __scopeRadioGroup , name: name , defaultValue: defaultValue , value: valueProp , required: required = false , disabled: disabled = false , orientation: orientation , dir: dir , loop: loop = true , onValueChange: onValueChange , ...groupProps } = props;
180
- const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
181
- const direction = $9yYIj$radixuireactdirection.useDirection(dir);
182
- const [value, setValue] = $9yYIj$radixuireactusecontrollablestate.useControllableState({
169
+ // packages/react/radio-group/src/RadioGroup.tsx
170
+ var import_jsx_runtime2 = __require("react/jsx-runtime");
171
+ var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
172
+ var RADIO_GROUP_NAME = "RadioGroup";
173
+ var [createRadioGroupContext, createRadioGroupScope] = (0, import_react_context2.createContextScope)(RADIO_GROUP_NAME, [
174
+ import_react_roving_focus.createRovingFocusGroupScope,
175
+ createRadioScope
176
+ ]);
177
+ var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
178
+ var useRadioScope = createRadioScope();
179
+ var [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
180
+ var RadioGroup = React2.forwardRef(
181
+ (props, forwardedRef) => {
182
+ const {
183
+ __scopeRadioGroup,
184
+ name,
185
+ defaultValue,
186
+ value: valueProp,
187
+ required = false,
188
+ disabled = false,
189
+ orientation,
190
+ dir,
191
+ loop = true,
192
+ onValueChange,
193
+ ...groupProps
194
+ } = props;
195
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
196
+ const direction = (0, import_react_direction.useDirection)(dir);
197
+ const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
183
198
  prop: valueProp,
184
199
  defaultProp: defaultValue,
185
200
  onChange: onValueChange
186
- });
187
- return /*#__PURE__*/ $9yYIj$react.createElement($240483839a8a76fd$var$RadioGroupProvider, {
188
- scope: __scopeRadioGroup,
189
- name: name,
190
- required: required,
191
- disabled: disabled,
192
- value: value,
193
- onValueChange: setValue
194
- }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Root, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
195
- asChild: true
196
- }, rovingFocusGroupScope, {
197
- orientation: orientation,
198
- dir: direction,
199
- loop: loop
200
- }), /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
201
- role: "radiogroup",
202
- "aria-required": required,
203
- "aria-orientation": orientation,
204
- "data-disabled": disabled ? '' : undefined,
205
- dir: direction
206
- }, groupProps, {
207
- ref: forwardedRef
208
- }))));
209
- });
210
- /*#__PURE__*/ Object.assign($240483839a8a76fd$export$a98f0dcb43a68a25, {
211
- displayName: $240483839a8a76fd$var$RADIO_GROUP_NAME
212
- });
213
- /* -------------------------------------------------------------------------------------------------
214
- * RadioGroupItem
215
- * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$ITEM_NAME = 'RadioGroupItem';
216
- const $240483839a8a76fd$export$9f866c100ef519e4 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
217
- const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
218
- const context = $240483839a8a76fd$var$useRadioGroupContext($240483839a8a76fd$var$ITEM_NAME, __scopeRadioGroup);
219
- const isDisabled = context.disabled || disabled;
220
- const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
221
- const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
222
- const ref = $9yYIj$react.useRef(null);
223
- const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
224
- const checked = context.value === itemProps.value;
225
- const isArrowKeyPressedRef = $9yYIj$react.useRef(false);
226
- $9yYIj$react.useEffect(()=>{
227
- const handleKeyDown = (event)=>{
228
- if ($240483839a8a76fd$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
201
+ });
202
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
203
+ RadioGroupProvider,
204
+ {
205
+ scope: __scopeRadioGroup,
206
+ name,
207
+ required,
208
+ disabled,
209
+ value,
210
+ onValueChange: setValue,
211
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
212
+ RovingFocusGroup.Root,
213
+ {
214
+ asChild: true,
215
+ ...rovingFocusGroupScope,
216
+ orientation,
217
+ dir: direction,
218
+ loop,
219
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
220
+ import_react_primitive2.Primitive.div,
221
+ {
222
+ role: "radiogroup",
223
+ "aria-required": required,
224
+ "aria-orientation": orientation,
225
+ "data-disabled": disabled ? "" : void 0,
226
+ dir: direction,
227
+ ...groupProps,
228
+ ref: forwardedRef
229
+ }
230
+ )
231
+ }
232
+ )
233
+ }
234
+ );
235
+ }
236
+ );
237
+ RadioGroup.displayName = RADIO_GROUP_NAME;
238
+ var ITEM_NAME = "RadioGroupItem";
239
+ var RadioGroupItem = React2.forwardRef(
240
+ (props, forwardedRef) => {
241
+ const { __scopeRadioGroup, disabled, ...itemProps } = props;
242
+ const context = useRadioGroupContext(ITEM_NAME, __scopeRadioGroup);
243
+ const isDisabled = context.disabled || disabled;
244
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
245
+ const radioScope = useRadioScope(__scopeRadioGroup);
246
+ const ref = React2.useRef(null);
247
+ const composedRefs = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, ref);
248
+ const checked = context.value === itemProps.value;
249
+ const isArrowKeyPressedRef = React2.useRef(false);
250
+ React2.useEffect(() => {
251
+ const handleKeyDown = (event) => {
252
+ if (ARROW_KEYS.includes(event.key)) {
253
+ isArrowKeyPressedRef.current = true;
254
+ }
229
255
  };
230
- const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
231
- ;
232
- document.addEventListener('keydown', handleKeyDown);
233
- document.addEventListener('keyup', handleKeyUp);
234
- return ()=>{
235
- document.removeEventListener('keydown', handleKeyDown);
236
- document.removeEventListener('keyup', handleKeyUp);
256
+ const handleKeyUp = () => isArrowKeyPressedRef.current = false;
257
+ document.addEventListener("keydown", handleKeyDown);
258
+ document.addEventListener("keyup", handleKeyUp);
259
+ return () => {
260
+ document.removeEventListener("keydown", handleKeyDown);
261
+ document.removeEventListener("keyup", handleKeyUp);
237
262
  };
238
- }, []);
239
- return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Item, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
240
- asChild: true
241
- }, rovingFocusGroupScope, {
242
- focusable: !isDisabled,
243
- active: checked
244
- }), /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d7b12c4107be0d61, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
245
- disabled: isDisabled,
246
- required: context.required,
247
- checked: checked
248
- }, radioScope, itemProps, {
249
- name: context.name,
250
- ref: composedRefs,
251
- onCheck: ()=>context.onValueChange(itemProps.value)
252
- ,
253
- onKeyDown: $9yYIj$radixuiprimitive.composeEventHandlers((event)=>{
254
- // According to WAI ARIA, radio groups don't activate items on enter keypress
255
- if (event.key === 'Enter') event.preventDefault();
256
- }),
257
- onFocus: $9yYIj$radixuiprimitive.composeEventHandlers(itemProps.onFocus, ()=>{
258
- var _ref$current;
259
- /**
260
- * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
261
- * and we need to "check" it in that case. We click it to "check" it (instead
262
- * of updating `context.value`) so that the radio change event fires.
263
- */ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
264
- })
265
- })));
266
- });
267
- /*#__PURE__*/ Object.assign($240483839a8a76fd$export$9f866c100ef519e4, {
268
- displayName: $240483839a8a76fd$var$ITEM_NAME
269
- });
270
- /* -------------------------------------------------------------------------------------------------
271
- * RadioGroupIndicator
272
- * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$INDICATOR_NAME = 'RadioGroupIndicator';
273
- const $240483839a8a76fd$export$5fb54c671a65c88 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
274
- const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
275
- const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
276
- return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d35a9ffa9a04f9e7, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({}, radioScope, indicatorProps, {
277
- ref: forwardedRef
278
- }));
279
- });
280
- /*#__PURE__*/ Object.assign($240483839a8a76fd$export$5fb54c671a65c88, {
281
- displayName: $240483839a8a76fd$var$INDICATOR_NAME
282
- });
283
- /* ---------------------------------------------------------------------------------------------- */ const $240483839a8a76fd$export$be92b6f5f03c0fe9 = $240483839a8a76fd$export$a98f0dcb43a68a25;
284
- const $240483839a8a76fd$export$6d08773d2e66f8f2 = $240483839a8a76fd$export$9f866c100ef519e4;
285
- const $240483839a8a76fd$export$adb584737d712b70 = $240483839a8a76fd$export$5fb54c671a65c88;
286
-
287
-
288
-
289
-
263
+ }, []);
264
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
265
+ RovingFocusGroup.Item,
266
+ {
267
+ asChild: true,
268
+ ...rovingFocusGroupScope,
269
+ focusable: !isDisabled,
270
+ active: checked,
271
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
272
+ Radio,
273
+ {
274
+ disabled: isDisabled,
275
+ required: context.required,
276
+ checked,
277
+ ...radioScope,
278
+ ...itemProps,
279
+ name: context.name,
280
+ ref: composedRefs,
281
+ onCheck: () => context.onValueChange(itemProps.value),
282
+ onKeyDown: (0, import_primitive2.composeEventHandlers)((event) => {
283
+ if (event.key === "Enter") event.preventDefault();
284
+ }),
285
+ onFocus: (0, import_primitive2.composeEventHandlers)(itemProps.onFocus, () => {
286
+ if (isArrowKeyPressedRef.current) ref.current?.click();
287
+ })
288
+ }
289
+ )
290
+ }
291
+ );
292
+ }
293
+ );
294
+ RadioGroupItem.displayName = ITEM_NAME;
295
+ var INDICATOR_NAME2 = "RadioGroupIndicator";
296
+ var RadioGroupIndicator = React2.forwardRef(
297
+ (props, forwardedRef) => {
298
+ const { __scopeRadioGroup, ...indicatorProps } = props;
299
+ const radioScope = useRadioScope(__scopeRadioGroup);
300
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RadioIndicator, { ...radioScope, ...indicatorProps, ref: forwardedRef });
301
+ }
302
+ );
303
+ RadioGroupIndicator.displayName = INDICATOR_NAME2;
304
+ var Root2 = RadioGroup;
305
+ var Item2 = RadioGroupItem;
306
+ var Indicator = RadioGroupIndicator;
307
+ })();
290
308
  //# sourceMappingURL=index.js.map