@radix-ui/react-radio-group 1.4.3 → 1.4.4-rc.1784074599772
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 +63 -80
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +64 -80
- package/dist/index.mjs.map +3 -3
- package/package.json +9 -10
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
10
|
var __export = (target, all) => {
|
|
10
11
|
for (var name in all)
|
|
11
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -64,7 +65,6 @@ var import_primitive = require("@radix-ui/primitive");
|
|
|
64
65
|
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
65
66
|
var import_react_context = require("@radix-ui/react-context");
|
|
66
67
|
var import_react_use_size = require("@radix-ui/react-use-size");
|
|
67
|
-
var import_react_use_previous = require("@radix-ui/react-use-previous");
|
|
68
68
|
var import_react_presence = require("@radix-ui/react-presence");
|
|
69
69
|
var import_react_primitive = require("@radix-ui/react-primitive");
|
|
70
70
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -88,6 +88,10 @@ function RadioProvider(props) {
|
|
|
88
88
|
const [control, setControl] = React.useState(null);
|
|
89
89
|
const [bubbleInput, setBubbleInput] = React.useState(null);
|
|
90
90
|
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
91
|
+
const [userInteractionCount, onUserInteraction] = React.useReducer(
|
|
92
|
+
(count) => count + 1,
|
|
93
|
+
0
|
|
94
|
+
);
|
|
91
95
|
const isFormControl = control ? !!form || !!control.closest("form") : (
|
|
92
96
|
// We set this to true by default so that events bubble to forms without JS (SSR)
|
|
93
97
|
true
|
|
@@ -102,16 +106,19 @@ function RadioProvider(props) {
|
|
|
102
106
|
control,
|
|
103
107
|
setControl,
|
|
104
108
|
hasConsumerStoppedPropagationRef,
|
|
109
|
+
userInteractionCount,
|
|
110
|
+
onUserInteraction,
|
|
105
111
|
isFormControl,
|
|
106
112
|
bubbleInput,
|
|
107
113
|
setBubbleInput,
|
|
108
|
-
onCheck: () => onCheck?.()
|
|
114
|
+
onCheck: /* @__PURE__ */ __name(() => onCheck?.(), "onCheck")
|
|
109
115
|
};
|
|
110
116
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioProviderImpl, { scope: __scopeRadio, ...context, children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children });
|
|
111
117
|
}
|
|
118
|
+
__name(RadioProvider, "RadioProvider");
|
|
112
119
|
var TRIGGER_NAME = "RadioTrigger";
|
|
113
|
-
var RadioTrigger = React.forwardRef(
|
|
114
|
-
({ __scopeRadio, onClick, ...radioProps }, forwardedRef)
|
|
120
|
+
var RadioTrigger = /* @__PURE__ */ React.forwardRef(
|
|
121
|
+
/* @__PURE__ */ __name(function RadioTrigger2({ __scopeRadio, onClick, ...radioProps }, forwardedRef) {
|
|
115
122
|
const {
|
|
116
123
|
checked,
|
|
117
124
|
disabled,
|
|
@@ -119,6 +126,7 @@ var RadioTrigger = React.forwardRef(
|
|
|
119
126
|
setControl,
|
|
120
127
|
onCheck,
|
|
121
128
|
hasConsumerStoppedPropagationRef,
|
|
129
|
+
onUserInteraction,
|
|
122
130
|
isFormControl,
|
|
123
131
|
bubbleInput
|
|
124
132
|
} = useRadioContext(TRIGGER_NAME, __scopeRadio);
|
|
@@ -136,7 +144,10 @@ var RadioTrigger = React.forwardRef(
|
|
|
136
144
|
...radioProps,
|
|
137
145
|
ref: composedRefs,
|
|
138
146
|
onClick: (0, import_primitive.composeEventHandlers)(onClick, (event) => {
|
|
139
|
-
if (!checked)
|
|
147
|
+
if (!checked) {
|
|
148
|
+
onUserInteraction();
|
|
149
|
+
onCheck();
|
|
150
|
+
}
|
|
140
151
|
if (bubbleInput && isFormControl) {
|
|
141
152
|
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
142
153
|
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
@@ -144,47 +155,11 @@ var RadioTrigger = React.forwardRef(
|
|
|
144
155
|
})
|
|
145
156
|
}
|
|
146
157
|
);
|
|
147
|
-
}
|
|
158
|
+
}, "RadioTrigger")
|
|
148
159
|
);
|
|
149
|
-
RadioTrigger.displayName = TRIGGER_NAME;
|
|
150
|
-
var Radio = React.forwardRef(
|
|
151
|
-
(props, forwardedRef) => {
|
|
152
|
-
const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } = props;
|
|
153
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
154
|
-
RadioProvider,
|
|
155
|
-
{
|
|
156
|
-
__scopeRadio,
|
|
157
|
-
checked,
|
|
158
|
-
disabled,
|
|
159
|
-
required,
|
|
160
|
-
onCheck,
|
|
161
|
-
name,
|
|
162
|
-
form,
|
|
163
|
-
value,
|
|
164
|
-
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
-
RadioTrigger,
|
|
167
|
-
{
|
|
168
|
-
...radioProps,
|
|
169
|
-
ref: forwardedRef,
|
|
170
|
-
__scopeRadio
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
|
-
RadioBubbleInput,
|
|
175
|
-
{
|
|
176
|
-
__scopeRadio
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
] })
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
Radio.displayName = RADIO_NAME;
|
|
185
160
|
var INDICATOR_NAME = "RadioIndicator";
|
|
186
|
-
var RadioIndicator = React.forwardRef(
|
|
187
|
-
(props, forwardedRef)
|
|
161
|
+
var RadioIndicator = /* @__PURE__ */ React.forwardRef(
|
|
162
|
+
/* @__PURE__ */ __name(function RadioIndicator2(props, forwardedRef) {
|
|
188
163
|
const { __scopeRadio, forceMount, ...indicatorProps } = props;
|
|
189
164
|
const context = useRadioContext(INDICATOR_NAME, __scopeRadio);
|
|
190
165
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || context.checked, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -196,12 +171,11 @@ var RadioIndicator = React.forwardRef(
|
|
|
196
171
|
ref: forwardedRef
|
|
197
172
|
}
|
|
198
173
|
) });
|
|
199
|
-
}
|
|
174
|
+
}, "RadioIndicator")
|
|
200
175
|
);
|
|
201
|
-
RadioIndicator.displayName = INDICATOR_NAME;
|
|
202
176
|
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
|
|
203
|
-
var RadioBubbleInput = React.forwardRef(
|
|
204
|
-
({ __scopeRadio, ...props }, forwardedRef)
|
|
177
|
+
var RadioBubbleInput = /* @__PURE__ */ React.forwardRef(
|
|
178
|
+
/* @__PURE__ */ __name(function RadioBubbleInput2({ __scopeRadio, onClick, ...props }, forwardedRef) {
|
|
205
179
|
const {
|
|
206
180
|
control,
|
|
207
181
|
checked,
|
|
@@ -212,11 +186,14 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
212
186
|
form,
|
|
213
187
|
bubbleInput,
|
|
214
188
|
setBubbleInput,
|
|
215
|
-
hasConsumerStoppedPropagationRef
|
|
189
|
+
hasConsumerStoppedPropagationRef,
|
|
190
|
+
userInteractionCount
|
|
216
191
|
} = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);
|
|
217
192
|
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setBubbleInput);
|
|
218
|
-
const prevChecked = (0, import_react_use_previous.usePrevious)(checked);
|
|
219
193
|
const controlSize = (0, import_react_use_size.useSize)(control);
|
|
194
|
+
const shouldStopClickPropagationRef = React.useRef(false);
|
|
195
|
+
const prevCheckedRef = React.useRef(checked);
|
|
196
|
+
const prevUserInteractionCountRef = React.useRef(userInteractionCount);
|
|
220
197
|
React.useEffect(() => {
|
|
221
198
|
const input = bubbleInput;
|
|
222
199
|
if (!input) return;
|
|
@@ -226,13 +203,19 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
226
203
|
"checked"
|
|
227
204
|
);
|
|
228
205
|
const setChecked = descriptor.set;
|
|
229
|
-
const
|
|
230
|
-
|
|
206
|
+
const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;
|
|
207
|
+
prevUserInteractionCountRef.current = userInteractionCount;
|
|
208
|
+
const checkedChanged = prevCheckedRef.current !== checked;
|
|
209
|
+
prevCheckedRef.current = checked;
|
|
210
|
+
const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);
|
|
211
|
+
if (checkedChanged && setChecked) {
|
|
212
|
+
shouldStopClickPropagationRef.current = !isUserInteraction;
|
|
231
213
|
const event = new Event("click", { bubbles });
|
|
232
214
|
setChecked.call(input, checked);
|
|
233
215
|
input.dispatchEvent(event);
|
|
216
|
+
shouldStopClickPropagationRef.current = false;
|
|
234
217
|
}
|
|
235
|
-
}, [bubbleInput,
|
|
218
|
+
}, [bubbleInput, checked, hasConsumerStoppedPropagationRef, userInteractionCount]);
|
|
236
219
|
const defaultCheckedRef = React.useRef(checked);
|
|
237
220
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
221
|
import_react_primitive.Primitive.input,
|
|
@@ -248,6 +231,11 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
248
231
|
...props,
|
|
249
232
|
tabIndex: -1,
|
|
250
233
|
ref: composedRefs,
|
|
234
|
+
onClick: (0, import_primitive.composeEventHandlers)(onClick, (event) => {
|
|
235
|
+
if (shouldStopClickPropagationRef.current) {
|
|
236
|
+
event.stopPropagation();
|
|
237
|
+
}
|
|
238
|
+
}),
|
|
251
239
|
style: {
|
|
252
240
|
...props.style,
|
|
253
241
|
...controlSize,
|
|
@@ -262,15 +250,16 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
262
250
|
}
|
|
263
251
|
}
|
|
264
252
|
);
|
|
265
|
-
}
|
|
253
|
+
}, "RadioBubbleInput")
|
|
266
254
|
);
|
|
267
|
-
RadioBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
268
255
|
function isFunction(value) {
|
|
269
256
|
return typeof value === "function";
|
|
270
257
|
}
|
|
258
|
+
__name(isFunction, "isFunction");
|
|
271
259
|
function getState(checked) {
|
|
272
260
|
return checked ? "checked" : "unchecked";
|
|
273
261
|
}
|
|
262
|
+
__name(getState, "getState");
|
|
274
263
|
|
|
275
264
|
// src/radio-group.tsx
|
|
276
265
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -283,8 +272,8 @@ var [createRadioGroupContext, createRadioGroupScope] = (0, import_react_context2
|
|
|
283
272
|
var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
|
|
284
273
|
var useRadioScope = createRadioScope();
|
|
285
274
|
var [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
286
|
-
var RadioGroup = React2.forwardRef(
|
|
287
|
-
(props, forwardedRef)
|
|
275
|
+
var RadioGroup = /* @__PURE__ */ React2.forwardRef(
|
|
276
|
+
/* @__PURE__ */ __name(function RadioGroup2(props, forwardedRef) {
|
|
288
277
|
const {
|
|
289
278
|
__scopeRadioGroup,
|
|
290
279
|
name,
|
|
@@ -313,7 +302,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
313
302
|
React2.useEffect(() => {
|
|
314
303
|
const associatedForm = form ? control?.ownerDocument.getElementById(form) : control?.closest("form");
|
|
315
304
|
if (associatedForm instanceof HTMLFormElement) {
|
|
316
|
-
const reset = () => setValue(initialValueRef.current);
|
|
305
|
+
const reset = /* @__PURE__ */ __name(() => setValue(initialValueRef.current), "reset");
|
|
317
306
|
associatedForm.addEventListener("reset", reset);
|
|
318
307
|
return () => associatedForm.removeEventListener("reset", reset);
|
|
319
308
|
}
|
|
@@ -352,13 +341,10 @@ var RadioGroup = React2.forwardRef(
|
|
|
352
341
|
)
|
|
353
342
|
}
|
|
354
343
|
);
|
|
355
|
-
}
|
|
344
|
+
}, "RadioGroup")
|
|
356
345
|
);
|
|
357
|
-
RadioGroup.displayName = RADIO_GROUP_NAME;
|
|
358
|
-
var ITEM_NAME = "RadioGroupItem";
|
|
359
346
|
var ITEM_PROVIDER_NAME = "RadioGroupItemProvider";
|
|
360
347
|
var ITEM_TRIGGER_NAME = "RadioGroupItemTrigger";
|
|
361
|
-
var ITEM_BUBBLE_INPUT_NAME = "RadioGroupItemBubbleInput";
|
|
362
348
|
function RadioGroupItemProvider(props) {
|
|
363
349
|
const {
|
|
364
350
|
__scopeRadioGroup,
|
|
@@ -387,7 +373,8 @@ function RadioGroupItemProvider(props) {
|
|
|
387
373
|
}
|
|
388
374
|
);
|
|
389
375
|
}
|
|
390
|
-
|
|
376
|
+
__name(RadioGroupItemProvider, "RadioGroupItemProvider");
|
|
377
|
+
var RadioGroupItemTrigger = /* @__PURE__ */ React2.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemTrigger2(props, forwardedRef) {
|
|
391
378
|
const { __scopeRadioGroup, ...triggerProps } = props;
|
|
392
379
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
393
380
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
@@ -396,12 +383,12 @@ var RadioGroupItemTrigger = React2.forwardRef((props, forwardedRef) => {
|
|
|
396
383
|
const composedRefs = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, ref);
|
|
397
384
|
const isArrowKeyPressedRef = React2.useRef(false);
|
|
398
385
|
React2.useEffect(() => {
|
|
399
|
-
const handleKeyDown = (event) => {
|
|
386
|
+
const handleKeyDown = /* @__PURE__ */ __name((event) => {
|
|
400
387
|
if (ARROW_KEYS.includes(event.key)) {
|
|
401
388
|
isArrowKeyPressedRef.current = true;
|
|
402
389
|
}
|
|
403
|
-
};
|
|
404
|
-
const handleKeyUp = () => isArrowKeyPressedRef.current = false;
|
|
390
|
+
}, "handleKeyDown");
|
|
391
|
+
const handleKeyUp = /* @__PURE__ */ __name(() => isArrowKeyPressedRef.current = false, "handleKeyUp");
|
|
405
392
|
document.addEventListener("keydown", handleKeyDown);
|
|
406
393
|
document.addEventListener("keyup", handleKeyUp);
|
|
407
394
|
return () => {
|
|
@@ -434,10 +421,9 @@ var RadioGroupItemTrigger = React2.forwardRef((props, forwardedRef) => {
|
|
|
434
421
|
)
|
|
435
422
|
}
|
|
436
423
|
);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
(props, forwardedRef) => {
|
|
424
|
+
}, "RadioGroupItemTrigger"));
|
|
425
|
+
var RadioGroupItem = /* @__PURE__ */ React2.forwardRef(
|
|
426
|
+
/* @__PURE__ */ __name(function RadioGroupItem2(props, forwardedRef) {
|
|
441
427
|
const { __scopeRadioGroup, value, disabled, ...itemProps } = props;
|
|
442
428
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
443
429
|
RadioGroupItemProvider,
|
|
@@ -463,22 +449,19 @@ var RadioGroupItem = React2.forwardRef(
|
|
|
463
449
|
] })
|
|
464
450
|
}
|
|
465
451
|
);
|
|
466
|
-
}
|
|
452
|
+
}, "RadioGroupItem")
|
|
467
453
|
);
|
|
468
|
-
|
|
469
|
-
var RadioGroupItemBubbleInput = React2.forwardRef((props, forwardedRef) => {
|
|
454
|
+
var RadioGroupItemBubbleInput = /* @__PURE__ */ React2.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemBubbleInput2(props, forwardedRef) {
|
|
470
455
|
const { __scopeRadioGroup, ...bubbleProps } = props;
|
|
471
456
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
472
457
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RadioBubbleInput, { ...radioScope, ...bubbleProps, ref: forwardedRef });
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
(props, forwardedRef) => {
|
|
458
|
+
}, "RadioGroupItemBubbleInput"));
|
|
459
|
+
var RadioGroupIndicator = /* @__PURE__ */ React2.forwardRef(
|
|
460
|
+
// blank line to reduce diff noise
|
|
461
|
+
/* @__PURE__ */ __name(function RadioGroupIndicator2(props, forwardedRef) {
|
|
478
462
|
const { __scopeRadioGroup, ...indicatorProps } = props;
|
|
479
463
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
480
464
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RadioIndicator, { ...radioScope, ...indicatorProps, ref: forwardedRef });
|
|
481
|
-
}
|
|
465
|
+
}, "RadioGroupIndicator")
|
|
482
466
|
);
|
|
483
|
-
RadioGroupIndicator.displayName = INDICATOR_NAME2;
|
|
484
467
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/radio-group.tsx", "../src/radio.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider as unstable_RadioGroupItemProvider,\n RadioGroupItemTrigger as unstable_RadioGroupItemTrigger,\n RadioGroupItemBubbleInput as unstable_RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n Root,\n Item,\n ItemProvider as unstable_ItemProvider,\n ItemTrigger as unstable_ItemTrigger,\n ItemBubbleInput as unstable_ItemBubbleInput,\n Indicator,\n} from './radio-group';\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps as unstable_RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps as unstable_RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps as unstable_RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n} from './radio-group';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "import_primitive", "import_react_compose_refs", "import_react_context", "import_react_primitive", "import_jsx_runtime", "
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider as unstable_RadioGroupItemProvider,\n RadioGroupItemTrigger as unstable_RadioGroupItemTrigger,\n RadioGroupItemBubbleInput as unstable_RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n Root,\n Item,\n ItemProvider as unstable_ItemProvider,\n ItemTrigger as unstable_ItemTrigger,\n ItemBubbleInput as unstable_ItemBubbleInput,\n Indicator,\n} from './radio-group';\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps as unstable_RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps as unstable_RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps as unstable_RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n} from './radio-group';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = /* @__PURE__ */ React.forwardRef<RadioGroupElement, RadioGroupProps>(\n function RadioGroup(props: ScopedProps<RadioGroupProps>, forwardedRef) {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>(function RadioGroupItemTrigger(props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = /* @__PURE__ */ React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n function RadioGroupItem(props: ScopedProps<RadioGroupItemProps>, forwardedRef) {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = /* @__PURE__ */ React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>(function RadioGroupItemBubbleInput(\n props: ScopedProps<RadioGroupItemBubbleInputProps>,\n forwardedRef,\n) {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = /* @__PURE__ */ React.forwardRef<\n RadioGroupIndicatorElement,\n RadioGroupIndicatorProps\n>(\n // blank line to reduce diff noise\n function RadioGroupIndicator(props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n userInteractionCount: number;\n onUserInteraction: () => void;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n\n // Incremented on every user interaction with the trigger. The bubble input\n // compares this against the value it last handled to tell whether a `checked`\n // change was driven by the user (vs. a controlled/programmatic update). Using\n // a counter guarantees the marker is updated in the same commit as the\n // resulting render, so it can never go stale and leak into a later\n // programmatic update.\n const [userInteractionCount, onUserInteraction] = React.useReducer(\n (count: number): number => count + 1,\n 0,\n );\n\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n userInteractionCount,\n onUserInteraction,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = /* @__PURE__ */ React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n function RadioTrigger(\n { __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>,\n forwardedRef,\n ) {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n onUserInteraction,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state.\n // Only mark a user interaction when the click actually changes the\n // value, otherwise re-selecting the checked radio would leave a stale\n // interaction marker.\n if (!checked) {\n onUserInteraction();\n onCheck();\n }\n\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = /* @__PURE__ */ React.forwardRef<RadioElement, RadioProps>(\n // blank line to reduce diff noise\n function Radio(props: ScopedProps<RadioProps>, forwardedRef) {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = /* @__PURE__ */ React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n function RadioIndicator(props: ScopedProps<RadioIndicatorProps>, forwardedRef) {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = /* @__PURE__ */ React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n function RadioBubbleInput(\n { __scopeRadio, onClick, ...props }: ScopedProps<RadioBubbleInputProps>,\n forwardedRef,\n ) {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n userInteractionCount,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const controlSize = useSize(control);\n // When the checked change is not driven by a user interaction (e.g. a\n // controlled `checked` update), the `click` event we dispatch to notify\n // forms must not reach ancestor `onClick` handlers. We can't simply make it\n // non-bubbling because React derives the radio's `change` event from a\n // bubbling `click`. Instead we stop propagation of the synthetic click,\n // which still lets the `change` event reach the form.\n const shouldStopClickPropagationRef = React.useRef(false);\n // The `checked` value we last synced to the input, and the interaction\n // counter we last accounted for. Comparing against these lets us detect a\n // genuine `checked` change and whether it followed a user interaction, even\n // on renders caused by clicks that don't change `checked` (e.g. re-selecting\n // a checked radio, or a controlled value that ignores the change).\n const prevCheckedRef = React.useRef(checked);\n const prevUserInteractionCountRef = React.useRef(userInteractionCount);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;\n prevUserInteractionCountRef.current = userInteractionCount;\n const checkedChanged = prevCheckedRef.current !== checked;\n prevCheckedRef.current = checked;\n\n const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);\n if (checkedChanged && setChecked) {\n shouldStopClickPropagationRef.current = !isUserInteraction;\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n shouldStopClickPropagationRef.current = false;\n }\n }, [bubbleInput, checked, hasConsumerStoppedPropagationRef, userInteractionCount]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // Prevent the synthetic click dispatched on controlled/programmatic\n // updates from triggering ancestor `onClick` handlers, while still\n // allowing the resulting `change` event to reach the form.\n if (shouldStopClickPropagationRef.current) {\n event.stopPropagation();\n }\n })}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AACvB,IAAAC,oBAAqC;AACrC,IAAAC,6BAAgC;AAChC,IAAAC,wBAAmC;AACnC,IAAAC,0BAA0B;AAC1B,uBAAkC;AAClC,gCAA4C;AAC5C,0CA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E,gBAAI,MAAM,QAAQ,QAAS,OAAM,eAAe;AAAA,UAClD,CAAC;AAAA,UACD,aAAS,wCAAqB,aAAa,SAAS,MAAM;AAOxD,gBAAI,qBAAqB,SAAS;AAChC,kBAAI,SAAS,MAAM;AAAA,YACrB;AAAA,UACF,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ,GAtDE,wBAsDD;AAYD,IAAM,iBAAiC,gBAAM;AAAA,EAC3C,gCAASC,gBAAe,OAAyC,cAAc;AAC7E,UAAM,EAAE,mBAAmB,OAAO,UAAU,GAAG,UAAU,IAAI;AAE7D,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEA,4BAA4B,CAAC,EAAE,cAAc,MAC3C,8EACE;AAAA;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,KAAK;AAAA,cAEL;AAAA;AAAA,UACF;AAAA,UACC,iBACC;AAAA,YAAC;AAAA;AAAA,cAEC;AAAA;AAAA,UACF;AAAA,WAEJ;AAAA;AAAA,IAEJ;AAAA,EAEJ,GA3BA;AA4BF;AAWA,IAAM,4BAA4C,gBAAM,kBAGtD,gCAASC,2BACT,OACA,cACA;AACA,QAAM,EAAE,mBAAmB,GAAG,YAAY,IAAI;AAC9C,QAAM,aAAa,cAAc,iBAAiB;AAClD,SAAO,6CAAC,oBAAkB,GAAG,YAAa,GAAG,aAAa,KAAK,cAAc;AAC/E,GAPE,4BAOD;AAUD,IAAM,sBAAsC,gBAAM;AAAA;AAAA,EAKhD,gCAASC,qBAAoB,OAA8C,cAAc;AACvF,UAAM,EAAE,mBAAmB,GAAG,eAAe,IAAI;AACjD,UAAM,aAAa,cAAc,iBAAiB;AAClD,WAAO,6CAAC,kBAAgB,GAAG,YAAa,GAAG,gBAAgB,KAAK,cAAc;AAAA,EAChF,GAJA;AAKF;",
|
|
6
|
+
"names": ["React", "import_primitive", "import_react_compose_refs", "import_react_context", "import_react_primitive", "RadioTrigger", "RadioIndicator", "RadioBubbleInput", "import_jsx_runtime", "RadioGroup", "RadioGroupItemTrigger", "RadioGroupItem", "RadioGroupItemBubbleInput", "RadioGroupIndicator"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
4
|
|
|
3
5
|
// src/radio-group.tsx
|
|
4
6
|
import * as React2 from "react";
|
|
@@ -17,7 +19,6 @@ import { composeEventHandlers } from "@radix-ui/primitive";
|
|
|
17
19
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
18
20
|
import { createContextScope } from "@radix-ui/react-context";
|
|
19
21
|
import { useSize } from "@radix-ui/react-use-size";
|
|
20
|
-
import { usePrevious } from "@radix-ui/react-use-previous";
|
|
21
22
|
import { Presence } from "@radix-ui/react-presence";
|
|
22
23
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
23
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -41,6 +42,10 @@ function RadioProvider(props) {
|
|
|
41
42
|
const [control, setControl] = React.useState(null);
|
|
42
43
|
const [bubbleInput, setBubbleInput] = React.useState(null);
|
|
43
44
|
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
45
|
+
const [userInteractionCount, onUserInteraction] = React.useReducer(
|
|
46
|
+
(count) => count + 1,
|
|
47
|
+
0
|
|
48
|
+
);
|
|
44
49
|
const isFormControl = control ? !!form || !!control.closest("form") : (
|
|
45
50
|
// We set this to true by default so that events bubble to forms without JS (SSR)
|
|
46
51
|
true
|
|
@@ -55,16 +60,19 @@ function RadioProvider(props) {
|
|
|
55
60
|
control,
|
|
56
61
|
setControl,
|
|
57
62
|
hasConsumerStoppedPropagationRef,
|
|
63
|
+
userInteractionCount,
|
|
64
|
+
onUserInteraction,
|
|
58
65
|
isFormControl,
|
|
59
66
|
bubbleInput,
|
|
60
67
|
setBubbleInput,
|
|
61
|
-
onCheck: () => onCheck?.()
|
|
68
|
+
onCheck: /* @__PURE__ */ __name(() => onCheck?.(), "onCheck")
|
|
62
69
|
};
|
|
63
70
|
return /* @__PURE__ */ jsx(RadioProviderImpl, { scope: __scopeRadio, ...context, children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children });
|
|
64
71
|
}
|
|
72
|
+
__name(RadioProvider, "RadioProvider");
|
|
65
73
|
var TRIGGER_NAME = "RadioTrigger";
|
|
66
|
-
var RadioTrigger = React.forwardRef(
|
|
67
|
-
({ __scopeRadio, onClick, ...radioProps }, forwardedRef)
|
|
74
|
+
var RadioTrigger = /* @__PURE__ */ React.forwardRef(
|
|
75
|
+
/* @__PURE__ */ __name(function RadioTrigger2({ __scopeRadio, onClick, ...radioProps }, forwardedRef) {
|
|
68
76
|
const {
|
|
69
77
|
checked,
|
|
70
78
|
disabled,
|
|
@@ -72,6 +80,7 @@ var RadioTrigger = React.forwardRef(
|
|
|
72
80
|
setControl,
|
|
73
81
|
onCheck,
|
|
74
82
|
hasConsumerStoppedPropagationRef,
|
|
83
|
+
onUserInteraction,
|
|
75
84
|
isFormControl,
|
|
76
85
|
bubbleInput
|
|
77
86
|
} = useRadioContext(TRIGGER_NAME, __scopeRadio);
|
|
@@ -89,7 +98,10 @@ var RadioTrigger = React.forwardRef(
|
|
|
89
98
|
...radioProps,
|
|
90
99
|
ref: composedRefs,
|
|
91
100
|
onClick: composeEventHandlers(onClick, (event) => {
|
|
92
|
-
if (!checked)
|
|
101
|
+
if (!checked) {
|
|
102
|
+
onUserInteraction();
|
|
103
|
+
onCheck();
|
|
104
|
+
}
|
|
93
105
|
if (bubbleInput && isFormControl) {
|
|
94
106
|
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
95
107
|
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
@@ -97,47 +109,11 @@ var RadioTrigger = React.forwardRef(
|
|
|
97
109
|
})
|
|
98
110
|
}
|
|
99
111
|
);
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
RadioTrigger.displayName = TRIGGER_NAME;
|
|
103
|
-
var Radio = React.forwardRef(
|
|
104
|
-
(props, forwardedRef) => {
|
|
105
|
-
const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } = props;
|
|
106
|
-
return /* @__PURE__ */ jsx(
|
|
107
|
-
RadioProvider,
|
|
108
|
-
{
|
|
109
|
-
__scopeRadio,
|
|
110
|
-
checked,
|
|
111
|
-
disabled,
|
|
112
|
-
required,
|
|
113
|
-
onCheck,
|
|
114
|
-
name,
|
|
115
|
-
form,
|
|
116
|
-
value,
|
|
117
|
-
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
118
|
-
/* @__PURE__ */ jsx(
|
|
119
|
-
RadioTrigger,
|
|
120
|
-
{
|
|
121
|
-
...radioProps,
|
|
122
|
-
ref: forwardedRef,
|
|
123
|
-
__scopeRadio
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
isFormControl && /* @__PURE__ */ jsx(
|
|
127
|
-
RadioBubbleInput,
|
|
128
|
-
{
|
|
129
|
-
__scopeRadio
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
] })
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
}
|
|
112
|
+
}, "RadioTrigger")
|
|
136
113
|
);
|
|
137
|
-
Radio.displayName = RADIO_NAME;
|
|
138
114
|
var INDICATOR_NAME = "RadioIndicator";
|
|
139
|
-
var RadioIndicator = React.forwardRef(
|
|
140
|
-
(props, forwardedRef)
|
|
115
|
+
var RadioIndicator = /* @__PURE__ */ React.forwardRef(
|
|
116
|
+
/* @__PURE__ */ __name(function RadioIndicator2(props, forwardedRef) {
|
|
141
117
|
const { __scopeRadio, forceMount, ...indicatorProps } = props;
|
|
142
118
|
const context = useRadioContext(INDICATOR_NAME, __scopeRadio);
|
|
143
119
|
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.checked, children: /* @__PURE__ */ jsx(
|
|
@@ -149,12 +125,11 @@ var RadioIndicator = React.forwardRef(
|
|
|
149
125
|
ref: forwardedRef
|
|
150
126
|
}
|
|
151
127
|
) });
|
|
152
|
-
}
|
|
128
|
+
}, "RadioIndicator")
|
|
153
129
|
);
|
|
154
|
-
RadioIndicator.displayName = INDICATOR_NAME;
|
|
155
130
|
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
|
|
156
|
-
var RadioBubbleInput = React.forwardRef(
|
|
157
|
-
({ __scopeRadio, ...props }, forwardedRef)
|
|
131
|
+
var RadioBubbleInput = /* @__PURE__ */ React.forwardRef(
|
|
132
|
+
/* @__PURE__ */ __name(function RadioBubbleInput2({ __scopeRadio, onClick, ...props }, forwardedRef) {
|
|
158
133
|
const {
|
|
159
134
|
control,
|
|
160
135
|
checked,
|
|
@@ -165,11 +140,14 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
165
140
|
form,
|
|
166
141
|
bubbleInput,
|
|
167
142
|
setBubbleInput,
|
|
168
|
-
hasConsumerStoppedPropagationRef
|
|
143
|
+
hasConsumerStoppedPropagationRef,
|
|
144
|
+
userInteractionCount
|
|
169
145
|
} = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);
|
|
170
146
|
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
171
|
-
const prevChecked = usePrevious(checked);
|
|
172
147
|
const controlSize = useSize(control);
|
|
148
|
+
const shouldStopClickPropagationRef = React.useRef(false);
|
|
149
|
+
const prevCheckedRef = React.useRef(checked);
|
|
150
|
+
const prevUserInteractionCountRef = React.useRef(userInteractionCount);
|
|
173
151
|
React.useEffect(() => {
|
|
174
152
|
const input = bubbleInput;
|
|
175
153
|
if (!input) return;
|
|
@@ -179,13 +157,19 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
179
157
|
"checked"
|
|
180
158
|
);
|
|
181
159
|
const setChecked = descriptor.set;
|
|
182
|
-
const
|
|
183
|
-
|
|
160
|
+
const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;
|
|
161
|
+
prevUserInteractionCountRef.current = userInteractionCount;
|
|
162
|
+
const checkedChanged = prevCheckedRef.current !== checked;
|
|
163
|
+
prevCheckedRef.current = checked;
|
|
164
|
+
const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);
|
|
165
|
+
if (checkedChanged && setChecked) {
|
|
166
|
+
shouldStopClickPropagationRef.current = !isUserInteraction;
|
|
184
167
|
const event = new Event("click", { bubbles });
|
|
185
168
|
setChecked.call(input, checked);
|
|
186
169
|
input.dispatchEvent(event);
|
|
170
|
+
shouldStopClickPropagationRef.current = false;
|
|
187
171
|
}
|
|
188
|
-
}, [bubbleInput,
|
|
172
|
+
}, [bubbleInput, checked, hasConsumerStoppedPropagationRef, userInteractionCount]);
|
|
189
173
|
const defaultCheckedRef = React.useRef(checked);
|
|
190
174
|
return /* @__PURE__ */ jsx(
|
|
191
175
|
Primitive.input,
|
|
@@ -201,6 +185,11 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
201
185
|
...props,
|
|
202
186
|
tabIndex: -1,
|
|
203
187
|
ref: composedRefs,
|
|
188
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
189
|
+
if (shouldStopClickPropagationRef.current) {
|
|
190
|
+
event.stopPropagation();
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
204
193
|
style: {
|
|
205
194
|
...props.style,
|
|
206
195
|
...controlSize,
|
|
@@ -215,15 +204,16 @@ var RadioBubbleInput = React.forwardRef(
|
|
|
215
204
|
}
|
|
216
205
|
}
|
|
217
206
|
);
|
|
218
|
-
}
|
|
207
|
+
}, "RadioBubbleInput")
|
|
219
208
|
);
|
|
220
|
-
RadioBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
221
209
|
function isFunction(value) {
|
|
222
210
|
return typeof value === "function";
|
|
223
211
|
}
|
|
212
|
+
__name(isFunction, "isFunction");
|
|
224
213
|
function getState(checked) {
|
|
225
214
|
return checked ? "checked" : "unchecked";
|
|
226
215
|
}
|
|
216
|
+
__name(getState, "getState");
|
|
227
217
|
|
|
228
218
|
// src/radio-group.tsx
|
|
229
219
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -236,8 +226,8 @@ var [createRadioGroupContext, createRadioGroupScope] = createContextScope2(RADIO
|
|
|
236
226
|
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
237
227
|
var useRadioScope = createRadioScope();
|
|
238
228
|
var [RadioGroupProvider, useRadioGroupContext] = createRadioGroupContext(RADIO_GROUP_NAME);
|
|
239
|
-
var RadioGroup = React2.forwardRef(
|
|
240
|
-
(props, forwardedRef)
|
|
229
|
+
var RadioGroup = /* @__PURE__ */ React2.forwardRef(
|
|
230
|
+
/* @__PURE__ */ __name(function RadioGroup2(props, forwardedRef) {
|
|
241
231
|
const {
|
|
242
232
|
__scopeRadioGroup,
|
|
243
233
|
name,
|
|
@@ -266,7 +256,7 @@ var RadioGroup = React2.forwardRef(
|
|
|
266
256
|
React2.useEffect(() => {
|
|
267
257
|
const associatedForm = form ? control?.ownerDocument.getElementById(form) : control?.closest("form");
|
|
268
258
|
if (associatedForm instanceof HTMLFormElement) {
|
|
269
|
-
const reset = () => setValue(initialValueRef.current);
|
|
259
|
+
const reset = /* @__PURE__ */ __name(() => setValue(initialValueRef.current), "reset");
|
|
270
260
|
associatedForm.addEventListener("reset", reset);
|
|
271
261
|
return () => associatedForm.removeEventListener("reset", reset);
|
|
272
262
|
}
|
|
@@ -305,13 +295,10 @@ var RadioGroup = React2.forwardRef(
|
|
|
305
295
|
)
|
|
306
296
|
}
|
|
307
297
|
);
|
|
308
|
-
}
|
|
298
|
+
}, "RadioGroup")
|
|
309
299
|
);
|
|
310
|
-
RadioGroup.displayName = RADIO_GROUP_NAME;
|
|
311
|
-
var ITEM_NAME = "RadioGroupItem";
|
|
312
300
|
var ITEM_PROVIDER_NAME = "RadioGroupItemProvider";
|
|
313
301
|
var ITEM_TRIGGER_NAME = "RadioGroupItemTrigger";
|
|
314
|
-
var ITEM_BUBBLE_INPUT_NAME = "RadioGroupItemBubbleInput";
|
|
315
302
|
function RadioGroupItemProvider(props) {
|
|
316
303
|
const {
|
|
317
304
|
__scopeRadioGroup,
|
|
@@ -340,7 +327,8 @@ function RadioGroupItemProvider(props) {
|
|
|
340
327
|
}
|
|
341
328
|
);
|
|
342
329
|
}
|
|
343
|
-
|
|
330
|
+
__name(RadioGroupItemProvider, "RadioGroupItemProvider");
|
|
331
|
+
var RadioGroupItemTrigger = /* @__PURE__ */ React2.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemTrigger2(props, forwardedRef) {
|
|
344
332
|
const { __scopeRadioGroup, ...triggerProps } = props;
|
|
345
333
|
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);
|
|
346
334
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
@@ -349,12 +337,12 @@ var RadioGroupItemTrigger = React2.forwardRef((props, forwardedRef) => {
|
|
|
349
337
|
const composedRefs = useComposedRefs2(forwardedRef, ref);
|
|
350
338
|
const isArrowKeyPressedRef = React2.useRef(false);
|
|
351
339
|
React2.useEffect(() => {
|
|
352
|
-
const handleKeyDown = (event) => {
|
|
340
|
+
const handleKeyDown = /* @__PURE__ */ __name((event) => {
|
|
353
341
|
if (ARROW_KEYS.includes(event.key)) {
|
|
354
342
|
isArrowKeyPressedRef.current = true;
|
|
355
343
|
}
|
|
356
|
-
};
|
|
357
|
-
const handleKeyUp = () => isArrowKeyPressedRef.current = false;
|
|
344
|
+
}, "handleKeyDown");
|
|
345
|
+
const handleKeyUp = /* @__PURE__ */ __name(() => isArrowKeyPressedRef.current = false, "handleKeyUp");
|
|
358
346
|
document.addEventListener("keydown", handleKeyDown);
|
|
359
347
|
document.addEventListener("keyup", handleKeyUp);
|
|
360
348
|
return () => {
|
|
@@ -387,10 +375,9 @@ var RadioGroupItemTrigger = React2.forwardRef((props, forwardedRef) => {
|
|
|
387
375
|
)
|
|
388
376
|
}
|
|
389
377
|
);
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
(props, forwardedRef) => {
|
|
378
|
+
}, "RadioGroupItemTrigger"));
|
|
379
|
+
var RadioGroupItem = /* @__PURE__ */ React2.forwardRef(
|
|
380
|
+
/* @__PURE__ */ __name(function RadioGroupItem2(props, forwardedRef) {
|
|
394
381
|
const { __scopeRadioGroup, value, disabled, ...itemProps } = props;
|
|
395
382
|
return /* @__PURE__ */ jsx2(
|
|
396
383
|
RadioGroupItemProvider,
|
|
@@ -416,24 +403,21 @@ var RadioGroupItem = React2.forwardRef(
|
|
|
416
403
|
] })
|
|
417
404
|
}
|
|
418
405
|
);
|
|
419
|
-
}
|
|
406
|
+
}, "RadioGroupItem")
|
|
420
407
|
);
|
|
421
|
-
|
|
422
|
-
var RadioGroupItemBubbleInput = React2.forwardRef((props, forwardedRef) => {
|
|
408
|
+
var RadioGroupItemBubbleInput = /* @__PURE__ */ React2.forwardRef(/* @__PURE__ */ __name(function RadioGroupItemBubbleInput2(props, forwardedRef) {
|
|
423
409
|
const { __scopeRadioGroup, ...bubbleProps } = props;
|
|
424
410
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
425
411
|
return /* @__PURE__ */ jsx2(RadioBubbleInput, { ...radioScope, ...bubbleProps, ref: forwardedRef });
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
(props, forwardedRef) => {
|
|
412
|
+
}, "RadioGroupItemBubbleInput"));
|
|
413
|
+
var RadioGroupIndicator = /* @__PURE__ */ React2.forwardRef(
|
|
414
|
+
// blank line to reduce diff noise
|
|
415
|
+
/* @__PURE__ */ __name(function RadioGroupIndicator2(props, forwardedRef) {
|
|
431
416
|
const { __scopeRadioGroup, ...indicatorProps } = props;
|
|
432
417
|
const radioScope = useRadioScope(__scopeRadioGroup);
|
|
433
418
|
return /* @__PURE__ */ jsx2(RadioIndicator, { ...radioScope, ...indicatorProps, ref: forwardedRef });
|
|
434
|
-
}
|
|
419
|
+
}, "RadioGroupIndicator")
|
|
435
420
|
);
|
|
436
|
-
RadioGroupIndicator.displayName = INDICATOR_NAME2;
|
|
437
421
|
export {
|
|
438
422
|
RadioGroupIndicator as Indicator,
|
|
439
423
|
RadioGroupItem as Item,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/radio-group.tsx", "../src/radio.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\nconst ITEM_BUBBLE_INPUT_NAME = 'RadioGroupItemBubbleInput';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>((props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\nRadioGroupItemTrigger.displayName = ITEM_TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n (props: ScopedProps<RadioGroupItemProps>, forwardedRef) => {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>((props: ScopedProps<RadioGroupItemBubbleInputProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\nRadioGroupItemBubbleInput.displayName = ITEM_BUBBLE_INPUT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = React.forwardRef<RadioGroupIndicatorElement, RadioGroupIndicatorProps>(\n (props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) => {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\nRadioGroupIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n ({ __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>, forwardedRef) => {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck();\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\nRadioTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n (props: ScopedProps<RadioIndicatorProps>, forwardedRef) => {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\nRadioIndicator.displayName = INDICATOR_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n ({ __scopeRadio, ...props }: ScopedProps<RadioBubbleInputProps>, forwardedRef) => {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const bubbles = !hasConsumerStoppedPropagationRef.current;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\nRadioBubbleInput.displayName = BUBBLE_INPUT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "composeEventHandlers", "useComposedRefs", "createContextScope", "Primitive", "Fragment", "jsx", "jsxs", "createContextScope", "useComposedRefs", "Primitive", "composeEventHandlers", "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useDirection } from '@radix-ui/react-direction';\nimport {\n type Radio,\n RadioProvider,\n RadioTrigger,\n RadioBubbleInput,\n RadioIndicator,\n createRadioScope,\n useRadioContext,\n} from './radio';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroup\n * -----------------------------------------------------------------------------------------------*/\nconst RADIO_GROUP_NAME = 'RadioGroup';\n\ntype ScopedProps<P> = P & { __scopeRadioGroup?: Scope };\nconst [createRadioGroupContext, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n form?: string;\n required: boolean;\n disabled: boolean;\n value: string | null;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContext<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ComponentRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n form?: React.ComponentPropsWithoutRef<typeof Radio>['form'];\n required?: React.ComponentPropsWithoutRef<typeof Radio>['required'];\n disabled?: React.ComponentPropsWithoutRef<typeof Radio>['disabled'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: string | null;\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = /* @__PURE__ */ React.forwardRef<RadioGroupElement, RadioGroupProps>(\n function RadioGroup(props: ScopedProps<RadioGroupProps>, forwardedRef) {\n const {\n __scopeRadioGroup,\n name,\n form,\n defaultValue,\n value: valueProp,\n required = false,\n disabled = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n onChange: onValueChange as (value: string | null) => void,\n caller: RADIO_GROUP_NAME,\n });\n const [control, setControl] = React.useState<RadioGroupElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n const initialValueRef = React.useRef(value);\n React.useEffect(() => {\n const associatedForm = form\n ? control?.ownerDocument.getElementById(form)\n : control?.closest('form');\n if (associatedForm instanceof HTMLFormElement) {\n const reset = () => setValue(initialValueRef.current);\n associatedForm.addEventListener('reset', reset);\n return () => associatedForm.removeEventListener('reset', reset);\n }\n }, [control, form, setValue]);\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n form={form}\n required={required}\n disabled={disabled}\n value={value}\n onValueChange={setValue}\n >\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={orientation}\n dir={direction}\n loop={loop}\n >\n <Primitive.div\n role=\"radiogroup\"\n aria-required={required}\n aria-orientation={orientation}\n data-disabled={disabled ? '' : undefined}\n dir={direction}\n {...groupProps}\n ref={composedRefs}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemProvider\n * -----------------------------------------------------------------------------------------------*/\nconst ITEM_PROVIDER_NAME = 'RadioGroupItemProvider';\nconst ITEM_TRIGGER_NAME = 'RadioGroupItemTrigger';\n\ninterface RadioGroupItemProviderProps {\n value: string;\n disabled?: boolean;\n children?: React.ReactNode;\n}\n\nfunction RadioGroupItemProvider(props: ScopedProps<RadioGroupItemProviderProps>) {\n const {\n __scopeRadioGroup,\n value,\n disabled,\n children,\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n const context = useRadioGroupContext(ITEM_PROVIDER_NAME, __scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const isDisabled = context.disabled || disabled;\n\n return (\n <RadioProvider\n {...radioScope}\n checked={context.value === value}\n disabled={isDisabled}\n required={context.required}\n name={context.name}\n form={context.form}\n value={value}\n onCheck={() => context.onValueChange(value)}\n // @ts-expect-error\n internal_do_not_use_render={internal_do_not_use_render}\n >\n {children}\n </RadioProvider>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemTrigger\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemTriggerElement = React.ComponentRef<typeof RadioTrigger>;\ninterface RadioGroupItemTriggerProps extends React.ComponentPropsWithoutRef<typeof RadioTrigger> {}\n\nconst RadioGroupItemTrigger = /* @__PURE__ */ React.forwardRef<\n RadioGroupItemTriggerElement,\n RadioGroupItemTriggerProps\n>(function RadioGroupItemTrigger(props: ScopedProps<RadioGroupItemTriggerProps>, forwardedRef) {\n const { __scopeRadioGroup, ...triggerProps } = props;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const { checked, disabled } = useRadioContext(ITEM_TRIGGER_NAME, radioScope.__scopeRadio);\n const ref = React.useRef<RadioGroupItemTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const isArrowKeyPressedRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (ARROW_KEYS.includes(event.key)) {\n isArrowKeyPressedRef.current = true;\n }\n };\n const handleKeyUp = () => (isArrowKeyPressedRef.current = false);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('keyup', handleKeyUp);\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('keyup', handleKeyUp);\n };\n }, []);\n\n return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={checked}\n >\n <RadioTrigger\n {...radioScope}\n {...triggerProps}\n ref={composedRefs}\n onKeyDown={composeEventHandlers(triggerProps.onKeyDown, (event) => {\n // According to WAI ARIA, radio groups don't activate items on enter\n // keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(triggerProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with\n * arrow keys and we need to \"check\" it in that case. We click it to\n * \"check\" it (instead of updating `context.value`) so that the radio\n * change event fires.\n */\n if (isArrowKeyPressedRef.current) {\n ref.current?.click();\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemElement = React.ComponentRef<typeof Radio>;\ntype RadioProps = React.ComponentPropsWithoutRef<typeof Radio>;\ninterface RadioGroupItemProps extends Omit<RadioProps, 'onCheck' | 'name'> {\n value: string;\n}\n\nconst RadioGroupItem = /* @__PURE__ */ React.forwardRef<RadioGroupItemElement, RadioGroupItemProps>(\n function RadioGroupItem(props: ScopedProps<RadioGroupItemProps>, forwardedRef) {\n const { __scopeRadioGroup, value, disabled, ...itemProps } = props;\n\n return (\n <RadioGroupItemProvider\n __scopeRadioGroup={__scopeRadioGroup}\n value={value}\n disabled={disabled}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: { isFormControl: boolean }) => (\n <>\n <RadioGroupItemTrigger\n {...itemProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n {isFormControl && (\n <RadioGroupItemBubbleInput\n // @ts-expect-error\n __scopeRadioGroup={__scopeRadioGroup}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItemBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupItemBubbleInputElement = React.ComponentRef<typeof RadioBubbleInput>;\ninterface RadioGroupItemBubbleInputProps extends React.ComponentPropsWithoutRef<\n typeof RadioBubbleInput\n> {}\n\nconst RadioGroupItemBubbleInput = /* @__PURE__ */ React.forwardRef<\n RadioGroupItemBubbleInputElement,\n RadioGroupItemBubbleInputProps\n>(function RadioGroupItemBubbleInput(\n props: ScopedProps<RadioGroupItemBubbleInputProps>,\n forwardedRef,\n) {\n const { __scopeRadioGroup, ...bubbleProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioBubbleInput {...radioScope} {...bubbleProps} ref={forwardedRef} />;\n});\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioGroupIndicatorElement = React.ComponentRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = React.ComponentPropsWithoutRef<typeof RadioIndicator>;\ninterface RadioGroupIndicatorProps extends RadioIndicatorProps {}\n\nconst RadioGroupIndicator = /* @__PURE__ */ React.forwardRef<\n RadioGroupIndicatorElement,\n RadioGroupIndicatorProps\n>(\n // blank line to reduce diff noise\n function RadioGroupIndicator(props: ScopedProps<RadioGroupIndicatorProps>, forwardedRef) {\n const { __scopeRadioGroup, ...indicatorProps } = props;\n const radioScope = useRadioScope(__scopeRadioGroup);\n return <RadioIndicator {...radioScope} {...indicatorProps} ref={forwardedRef} />;\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupItemProvider,\n RadioGroupItemTrigger,\n RadioGroupItemBubbleInput,\n RadioGroupIndicator,\n //\n RadioGroup as Root,\n RadioGroupItem as Item,\n RadioGroupItemProvider as ItemProvider,\n RadioGroupItemTrigger as ItemTrigger,\n RadioGroupItemBubbleInput as ItemBubbleInput,\n RadioGroupIndicator as Indicator,\n};\nexport type {\n RadioGroupProps,\n RadioGroupItemProps,\n RadioGroupItemProviderProps,\n RadioGroupItemTriggerProps,\n RadioGroupItemBubbleInputProps,\n RadioGroupIndicatorProps,\n};\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useSize } from '@radix-ui/react-use-size';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = {\n checked: boolean;\n disabled: boolean | undefined;\n required: boolean | undefined;\n name: string | undefined;\n form: string | undefined;\n value: string | number | readonly string[];\n control: HTMLButtonElement | null;\n setControl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;\n hasConsumerStoppedPropagationRef: React.RefObject<boolean>;\n userInteractionCount: number;\n onUserInteraction: () => void;\n isFormControl: boolean;\n bubbleInput: HTMLInputElement | null;\n setBubbleInput: React.Dispatch<React.SetStateAction<HTMLInputElement | null>>;\n onCheck(): void;\n};\n\nconst [RadioProviderImpl, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface RadioProviderProps {\n checked?: boolean;\n required?: boolean;\n disabled?: boolean;\n name?: string;\n form?: string;\n value?: string | number | readonly string[];\n onCheck?(): void;\n children?: React.ReactNode;\n}\n\nfunction RadioProvider(props: ScopedProps<RadioProviderProps>) {\n const {\n __scopeRadio,\n checked = false,\n children,\n disabled,\n form,\n name,\n onCheck,\n required,\n value = 'on',\n // @ts-expect-error\n internal_do_not_use_render,\n } = props;\n\n const [control, setControl] = React.useState<HTMLButtonElement | null>(null);\n const [bubbleInput, setBubbleInput] = React.useState<HTMLInputElement | null>(null);\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n\n // Incremented on every user interaction with the trigger. The bubble input\n // compares this against the value it last handled to tell whether a `checked`\n // change was driven by the user (vs. a controlled/programmatic update). Using\n // a counter guarantees the marker is updated in the same commit as the\n // resulting render, so it can never go stale and leak into a later\n // programmatic update.\n const [userInteractionCount, onUserInteraction] = React.useReducer(\n (count: number): number => count + 1,\n 0,\n );\n\n const isFormControl = control\n ? !!form || !!control.closest('form')\n : // We set this to true by default so that events bubble to forms without JS (SSR)\n true;\n\n const context: RadioContextValue = {\n checked,\n disabled,\n required,\n name,\n form,\n value,\n control,\n setControl,\n hasConsumerStoppedPropagationRef,\n userInteractionCount,\n onUserInteraction,\n isFormControl,\n bubbleInput,\n setBubbleInput,\n onCheck: () => onCheck?.(),\n };\n\n return (\n <RadioProviderImpl scope={__scopeRadio} {...context}>\n {isFunction(internal_do_not_use_render) ? internal_do_not_use_render(context) : children}\n </RadioProviderImpl>\n );\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RadioTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'RadioTrigger';\n\ninterface RadioTriggerProps extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive.button>,\n keyof RadioProviderProps\n> {\n children?: React.ReactNode;\n}\n\nconst RadioTrigger = /* @__PURE__ */ React.forwardRef<HTMLButtonElement, RadioTriggerProps>(\n function RadioTrigger(\n { __scopeRadio, onClick, ...radioProps }: ScopedProps<RadioTriggerProps>,\n forwardedRef,\n ) {\n const {\n checked,\n disabled,\n value,\n setControl,\n onCheck,\n hasConsumerStoppedPropagationRef,\n onUserInteraction,\n isFormControl,\n bubbleInput,\n } = useRadioContext(TRIGGER_NAME, __scopeRadio);\n const composedRefs = useComposedRefs(forwardedRef, setControl);\n\n return (\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state.\n // Only mark a user interaction when the click actually changes the\n // value, otherwise re-selecting the checked radio would leave a stale\n // interaction marker.\n if (!checked) {\n onUserInteraction();\n onCheck();\n }\n\n if (bubbleInput && isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio has a bubble input and is a form control, stop propagation\n // from the button so that we only propagate one click event (from the\n // input). We propagate changes from an input so that native form\n // validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\ntype RadioElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends Omit<PrimitiveButtonProps, 'checked'> {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = /* @__PURE__ */ React.forwardRef<RadioElement, RadioProps>(\n // blank line to reduce diff noise\n function Radio(props: ScopedProps<RadioProps>, forwardedRef) {\n const { __scopeRadio, name, checked, required, disabled, value, onCheck, form, ...radioProps } =\n props;\n\n return (\n <RadioProvider\n __scopeRadio={__scopeRadio}\n checked={checked}\n disabled={disabled}\n required={required}\n onCheck={onCheck}\n name={name}\n form={form}\n value={value}\n // @ts-expect-error\n internal_do_not_use_render={({ isFormControl }: RadioContextValue) => (\n <>\n <RadioTrigger\n {...radioProps}\n ref={forwardedRef}\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n {isFormControl && (\n <RadioBubbleInput\n // @ts-expect-error\n __scopeRadio={__scopeRadio}\n />\n )}\n </>\n )}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ComponentRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;\nexport interface RadioIndicatorProps extends PrimitiveSpanProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst RadioIndicator = /* @__PURE__ */ React.forwardRef<RadioIndicatorElement, RadioIndicatorProps>(\n function RadioIndicator(props: ScopedProps<RadioIndicatorProps>, forwardedRef) {\n const { __scopeRadio, forceMount, ...indicatorProps } = props;\n const context = useRadioContext(INDICATOR_NAME, __scopeRadio);\n return (\n <Presence present={forceMount || context.checked}>\n <Primitive.span\n data-state={getState(context.checked)}\n data-disabled={context.disabled ? '' : undefined}\n {...indicatorProps}\n ref={forwardedRef}\n />\n </Presence>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * RadioBubbleInput\n * -----------------------------------------------------------------------------------------------*/\n\nconst BUBBLE_INPUT_NAME = 'RadioBubbleInput';\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Primitive.input>;\ninterface RadioBubbleInputProps extends Omit<InputProps, 'checked'> {}\n\nconst RadioBubbleInput = /* @__PURE__ */ React.forwardRef<HTMLInputElement, RadioBubbleInputProps>(\n function RadioBubbleInput(\n { __scopeRadio, onClick, ...props }: ScopedProps<RadioBubbleInputProps>,\n forwardedRef,\n ) {\n const {\n control,\n checked,\n required,\n disabled,\n name,\n value,\n form,\n bubbleInput,\n setBubbleInput,\n hasConsumerStoppedPropagationRef,\n userInteractionCount,\n } = useRadioContext(BUBBLE_INPUT_NAME, __scopeRadio);\n\n const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);\n const controlSize = useSize(control);\n // When the checked change is not driven by a user interaction (e.g. a\n // controlled `checked` update), the `click` event we dispatch to notify\n // forms must not reach ancestor `onClick` handlers. We can't simply make it\n // non-bubbling because React derives the radio's `change` event from a\n // bubbling `click`. Instead we stop propagation of the synthetic click,\n // which still lets the `change` event reach the form.\n const shouldStopClickPropagationRef = React.useRef(false);\n // The `checked` value we last synced to the input, and the interaction\n // counter we last accounted for. Comparing against these lets us detect a\n // genuine `checked` change and whether it followed a user interaction, even\n // on renders caused by clicks that don't change `checked` (e.g. re-selecting\n // a checked radio, or a controlled value that ignores the change).\n const prevCheckedRef = React.useRef(checked);\n const prevUserInteractionCountRef = React.useRef(userInteractionCount);\n\n // Bubble checked change to parents (e.g form change event)\n React.useEffect(() => {\n const input = bubbleInput;\n if (!input) return;\n\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(\n inputProto,\n 'checked',\n ) as PropertyDescriptor;\n const setChecked = descriptor.set;\n\n const isUserInteraction = userInteractionCount !== prevUserInteractionCountRef.current;\n prevUserInteractionCountRef.current = userInteractionCount;\n const checkedChanged = prevCheckedRef.current !== checked;\n prevCheckedRef.current = checked;\n\n const bubbles = !(isUserInteraction && hasConsumerStoppedPropagationRef.current);\n if (checkedChanged && setChecked) {\n shouldStopClickPropagationRef.current = !isUserInteraction;\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n shouldStopClickPropagationRef.current = false;\n }\n }, [bubbleInput, checked, hasConsumerStoppedPropagationRef, userInteractionCount]);\n\n const defaultCheckedRef = React.useRef(checked);\n return (\n <Primitive.input\n type=\"radio\"\n aria-hidden\n defaultChecked={defaultCheckedRef.current}\n required={required}\n disabled={disabled}\n name={name}\n value={value}\n form={form}\n {...props}\n tabIndex={-1}\n ref={composedRefs}\n onClick={composeEventHandlers(onClick, (event) => {\n // Prevent the synthetic click dispatched on controlled/programmatic\n // updates from triggering ancestor `onClick` handlers, while still\n // allowing the resulting `change` event to reach the form.\n if (shouldStopClickPropagationRef.current) {\n event.stopPropagation();\n }\n })}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n // We transform because the input is absolutely positioned but we have\n // rendered it **after** the button. This pulls it back to sit on top\n // of the button.\n transform: 'translateX(-100%)',\n }}\n />\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === 'function';\n}\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n useRadioContext,\n //\n Radio,\n RadioProvider,\n RadioTrigger,\n RadioIndicator,\n RadioBubbleInput,\n};\nexport type { RadioProps, RadioProviderProps, RadioTriggerProps, RadioBubbleInputProps };\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAYA,YAAW;AACvB,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,sBAAAC,2BAA0B;AACnC,SAAS,aAAAC,kBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;;;ACR7B,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAkGtB,SAsGM,UAtGN,KAsGM,YAtGN;AA9FJ,IAAM,aAAa;AAGnB,IAAM,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,UAAU;AAoB5E,IAAM,CAAC,mBAAmB,eAAe,IAAI,m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A,UACF,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ,GAtDE,wBAsDD;AAYD,IAAM,iBAAiC,gBAAM;AAAA,EAC3C,gCAASC,gBAAe,OAAyC,cAAc;AAC7E,UAAM,EAAE,mBAAmB,OAAO,UAAU,GAAG,UAAU,IAAI;AAE7D,WACE,gBAAAR;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEA,4BAA4B,CAAC,EAAE,cAAc,MAC3C,gBAAAC,MAAAF,WAAA,EACE;AAAA,0BAAAC;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,KAAK;AAAA,cAEL;AAAA;AAAA,UACF;AAAA,UACC,iBACC,gBAAAA;AAAA,YAAC;AAAA;AAAA,cAEC;AAAA;AAAA,UACF;AAAA,WAEJ;AAAA;AAAA,IAEJ;AAAA,EAEJ,GA3BA;AA4BF;AAWA,IAAM,4BAA4C,gBAAM,kBAGtD,gCAASS,2BACT,OACA,cACA;AACA,QAAM,EAAE,mBAAmB,GAAG,YAAY,IAAI;AAC9C,QAAM,aAAa,cAAc,iBAAiB;AAClD,SAAO,gBAAAT,KAAC,oBAAkB,GAAG,YAAa,GAAG,aAAa,KAAK,cAAc;AAC/E,GAPE,4BAOD;AAUD,IAAM,sBAAsC,gBAAM;AAAA;AAAA,EAKhD,gCAASU,qBAAoB,OAA8C,cAAc;AACvF,UAAM,EAAE,mBAAmB,GAAG,eAAe,IAAI;AACjD,UAAM,aAAa,cAAc,iBAAiB;AAClD,WAAO,gBAAAV,KAAC,kBAAgB,GAAG,YAAa,GAAG,gBAAgB,KAAK,cAAc;AAAA,EAChF,GAJA;AAKF;",
|
|
6
|
+
"names": ["React", "composeEventHandlers", "useComposedRefs", "createContextScope", "Primitive", "RadioTrigger", "RadioIndicator", "RadioBubbleInput", "Fragment", "jsx", "jsxs", "createContextScope", "RadioGroup", "useComposedRefs", "Primitive", "RadioGroupItemTrigger", "composeEventHandlers", "RadioGroupItem", "RadioGroupItemBubbleInput", "RadioGroupIndicator"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-radio-group",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4-rc.1784074599772",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,16 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@radix-ui/primitive": "1.1.
|
|
14
|
+
"@radix-ui/primitive": "1.1.6-rc.1784074599772",
|
|
15
15
|
"@radix-ui/react-compose-refs": "1.1.3",
|
|
16
16
|
"@radix-ui/react-context": "1.2.0",
|
|
17
|
-
"@radix-ui/react-
|
|
18
|
-
"@radix-ui/react-
|
|
17
|
+
"@radix-ui/react-presence": "1.1.8-rc.1784074599772",
|
|
18
|
+
"@radix-ui/react-roving-focus": "1.1.16-rc.1784074599772",
|
|
19
|
+
"@radix-ui/react-use-controllable-state": "1.2.4-rc.1784074599772",
|
|
20
|
+
"@radix-ui/react-use-size": "1.1.2",
|
|
19
21
|
"@radix-ui/react-primitive": "2.1.7",
|
|
20
|
-
"@radix-ui/react-
|
|
21
|
-
"@radix-ui/react-use-controllable-state": "1.2.3",
|
|
22
|
-
"@radix-ui/react-use-previous": "1.1.2",
|
|
23
|
-
"@radix-ui/react-use-size": "1.1.2"
|
|
22
|
+
"@radix-ui/react-direction": "1.1.2"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@types/react": "^19.2.2",
|
|
@@ -28,8 +27,8 @@
|
|
|
28
27
|
"react": "^19.2.0",
|
|
29
28
|
"react-dom": "^19.2.0",
|
|
30
29
|
"typescript": "^5.9.3",
|
|
31
|
-
"@repo/
|
|
32
|
-
"@repo/
|
|
30
|
+
"@repo/typescript-config": "0.0.0",
|
|
31
|
+
"@repo/builder": "0.0.1-rc.1784074599772"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"@types/react": "*",
|