@radix-ui/react-radio-group 0.1.6-rc.5 → 0.1.6-rc.6
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.d.ts.map +1 -1
- package/dist/index.js +312 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +293 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;AA0BA,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,oBAAqB,SAAQ,oBAAoB;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB;AAED,QAAA,MAAM,2FAgEL,CAAC;AAWF,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC;AAChF,6BAAqC,SAAQ,kBAAkB;IAC7D;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED,QAAA,MAAM,2GAeL,CAAC;AC7GF,OAAA,4FAGE,CAAC;AAIH,8BAA8B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC,CAAC;AAMF,6BAA6B,MAAM,wBAAwB,CAAC,OAAO,iBAAiB,IAAI,CAAC,CAAC;AAC1F,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,gCAA0B,SAAQ,iBAAiB;IACjD,IAAI,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC;IACpE,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACnD,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC,CAAC;CACzD;AAED,OAAA,MAAM,kGAoDL,CAAC;AAWF,oBAAkB,MAAM,wBAAwB,CAAC,YAAY,CAAC,CAAC;AAC/D,oCAA8B,SAAQ,IAAI,CAAC,YAAU,EAAE,SAAS,GAAG,MAAM,CAAC;IACxE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,OAAA,MAAM,6GA0DL,CAAC;AAWF,6BAA2B,MAAM,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;AACjF,yCAAmC,SAAQ,qBAAmB;CAAG;AAEjE,OAAA,MAAM,qHAML,CAAC;AAMF,OAAA,MAAM,4FAAiB,CAAC;AACxB,OAAA,MAAM,mGAAqB,CAAC;AAC5B,OAAA,MAAM,2GAA+B,CAAC","sources":["packages/react/radio-group/src/packages/react/radio-group/src/Radio.tsx","packages/react/radio-group/src/packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/packages/react/radio-group/src/index.ts","packages/react/radio-group/src/index.ts"],"sourcesContent":[null,null,null,"export * from './RadioGroup';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,313 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $9yYIj$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $9yYIj$react = require("react");
|
|
3
|
+
var $9yYIj$radixuiprimitive = require("@radix-ui/primitive");
|
|
4
|
+
var $9yYIj$radixuireactlabel = require("@radix-ui/react-label");
|
|
5
|
+
var $9yYIj$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
6
|
+
var $9yYIj$radixuireactcontext = require("@radix-ui/react-context");
|
|
7
|
+
var $9yYIj$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
8
|
+
var $9yYIj$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
|
|
9
|
+
var $9yYIj$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
|
|
10
|
+
var $9yYIj$radixuireactdirection = require("@radix-ui/react-direction");
|
|
11
|
+
var $9yYIj$radixuireactusesize = require("@radix-ui/react-use-size");
|
|
12
|
+
var $9yYIj$radixuireactuseprevious = require("@radix-ui/react-use-previous");
|
|
13
|
+
var $9yYIj$radixuireactpresence = require("@radix-ui/react-presence");
|
|
14
|
+
|
|
15
|
+
function $parcel$exportWildcard(dest, source) {
|
|
16
|
+
Object.keys(source).forEach(function(key) {
|
|
17
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(dest, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return source[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return dest;
|
|
30
|
+
}
|
|
31
|
+
function $parcel$interopDefault(a) {
|
|
32
|
+
return a && a.__esModule ? a.default : a;
|
|
33
|
+
}
|
|
34
|
+
function $parcel$export(e, n, v, s) {
|
|
35
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
36
|
+
}
|
|
37
|
+
var $240483839a8a76fd$exports = {};
|
|
38
|
+
|
|
39
|
+
$parcel$export($240483839a8a76fd$exports, "createRadioGroupScope", () => $240483839a8a76fd$export$c547093f11b76da2);
|
|
40
|
+
$parcel$export($240483839a8a76fd$exports, "RadioGroup", () => $240483839a8a76fd$export$a98f0dcb43a68a25);
|
|
41
|
+
$parcel$export($240483839a8a76fd$exports, "RadioGroupItem", () => $240483839a8a76fd$export$9f866c100ef519e4);
|
|
42
|
+
$parcel$export($240483839a8a76fd$exports, "RadioGroupIndicator", () => $240483839a8a76fd$export$5fb54c671a65c88);
|
|
43
|
+
$parcel$export($240483839a8a76fd$exports, "Root", () => $240483839a8a76fd$export$be92b6f5f03c0fe9);
|
|
44
|
+
$parcel$export($240483839a8a76fd$exports, "Item", () => $240483839a8a76fd$export$6d08773d2e66f8f2);
|
|
45
|
+
$parcel$export($240483839a8a76fd$exports, "Indicator", () => $240483839a8a76fd$export$adb584737d712b70);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/* -------------------------------------------------------------------------------------------------
|
|
68
|
+
* Radio
|
|
69
|
+
* -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$RADIO_NAME = 'Radio';
|
|
70
|
+
const [$ce74a64c62457efb$var$createRadioContext, $ce74a64c62457efb$export$67d2296460f1b002] = $9yYIj$radixuireactcontext.createContextScope($ce74a64c62457efb$var$RADIO_NAME);
|
|
71
|
+
const [$ce74a64c62457efb$var$RadioProvider, $ce74a64c62457efb$var$useRadioContext] = $ce74a64c62457efb$var$createRadioContext($ce74a64c62457efb$var$RADIO_NAME);
|
|
72
|
+
const $ce74a64c62457efb$export$d7b12c4107be0d61 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
|
|
73
|
+
const { __scopeRadio: __scopeRadio , 'aria-labelledby': ariaLabelledby , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
|
|
74
|
+
const [button, setButton] = $9yYIj$react.useState(null);
|
|
75
|
+
const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setButton(node)
|
|
76
|
+
);
|
|
77
|
+
const labelId = $9yYIj$radixuireactlabel.useLabelContext(button);
|
|
78
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
79
|
+
const hasConsumerStoppedPropagationRef = $9yYIj$react.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
|
|
80
|
+
const isFormControl = button ? Boolean(button.closest('form')) : true;
|
|
81
|
+
return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$RadioProvider, {
|
|
82
|
+
scope: __scopeRadio,
|
|
83
|
+
checked: checked,
|
|
84
|
+
disabled: disabled
|
|
85
|
+
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
86
|
+
type: "button",
|
|
87
|
+
role: "radio",
|
|
88
|
+
"aria-checked": checked,
|
|
89
|
+
"aria-labelledby": labelledBy,
|
|
90
|
+
"data-state": $ce74a64c62457efb$var$getState(checked),
|
|
91
|
+
"data-disabled": disabled ? '' : undefined,
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
value: value
|
|
94
|
+
}, radioProps, {
|
|
95
|
+
ref: composedRefs,
|
|
96
|
+
onClick: $9yYIj$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
|
|
97
|
+
// radios cannot be unchecked so we only communicate a checked state
|
|
98
|
+
if (!checked) onCheck === null || onCheck === void 0 || onCheck();
|
|
99
|
+
if (isFormControl) {
|
|
100
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
|
|
101
|
+
// one click event (from the input). We propagate changes from an input so that native
|
|
102
|
+
// form validation works and form events reflect radio updates.
|
|
103
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
})), isFormControl && /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$BubbleInput, {
|
|
107
|
+
control: button,
|
|
108
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
109
|
+
name: name,
|
|
110
|
+
value: value,
|
|
111
|
+
checked: checked,
|
|
112
|
+
required: required,
|
|
113
|
+
disabled: disabled // We transform because the input is absolutely positioned but we have
|
|
114
|
+
,
|
|
115
|
+
style: {
|
|
116
|
+
transform: 'translateX(-100%)'
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
/*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d7b12c4107be0d61, {
|
|
121
|
+
displayName: $ce74a64c62457efb$var$RADIO_NAME
|
|
122
|
+
});
|
|
123
|
+
/* -------------------------------------------------------------------------------------------------
|
|
124
|
+
* RadioIndicator
|
|
125
|
+
* -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$INDICATOR_NAME = 'RadioIndicator';
|
|
126
|
+
const $ce74a64c62457efb$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
|
|
127
|
+
const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
|
|
128
|
+
const context = $ce74a64c62457efb$var$useRadioContext($ce74a64c62457efb$var$INDICATOR_NAME, __scopeRadio);
|
|
129
|
+
return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactpresence.Presence, {
|
|
130
|
+
present: forceMount || context.checked
|
|
131
|
+
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
132
|
+
"data-state": $ce74a64c62457efb$var$getState(context.checked),
|
|
133
|
+
"data-disabled": context.disabled ? '' : undefined
|
|
134
|
+
}, indicatorProps, {
|
|
135
|
+
ref: forwardedRef
|
|
136
|
+
})));
|
|
137
|
+
});
|
|
138
|
+
/*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d35a9ffa9a04f9e7, {
|
|
139
|
+
displayName: $ce74a64c62457efb$var$INDICATOR_NAME
|
|
140
|
+
});
|
|
141
|
+
/* ---------------------------------------------------------------------------------------------- */ const $ce74a64c62457efb$var$BubbleInput = (props)=>{
|
|
142
|
+
const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
|
|
143
|
+
const ref = $9yYIj$react.useRef(null);
|
|
144
|
+
const prevChecked = $9yYIj$radixuireactuseprevious.usePrevious(checked);
|
|
145
|
+
const controlSize = $9yYIj$radixuireactusesize.useSize(control); // Bubble checked change to parents (e.g form change event)
|
|
146
|
+
$9yYIj$react.useEffect(()=>{
|
|
147
|
+
const input = ref.current;
|
|
148
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
149
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
|
|
150
|
+
const setChecked = descriptor.set;
|
|
151
|
+
if (prevChecked !== checked && setChecked) {
|
|
152
|
+
const event = new Event('click', {
|
|
153
|
+
bubbles: bubbles
|
|
154
|
+
});
|
|
155
|
+
setChecked.call(input, checked);
|
|
156
|
+
input.dispatchEvent(event);
|
|
157
|
+
}
|
|
158
|
+
}, [
|
|
159
|
+
prevChecked,
|
|
160
|
+
checked,
|
|
161
|
+
bubbles
|
|
162
|
+
]);
|
|
163
|
+
return /*#__PURE__*/ $9yYIj$react.createElement("input", ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
164
|
+
type: "radio",
|
|
165
|
+
"aria-hidden": true,
|
|
166
|
+
defaultChecked: checked
|
|
167
|
+
}, inputProps, {
|
|
168
|
+
tabIndex: -1,
|
|
169
|
+
ref: ref,
|
|
170
|
+
style: {
|
|
171
|
+
...props.style,
|
|
172
|
+
...controlSize,
|
|
173
|
+
position: 'absolute',
|
|
174
|
+
pointerEvents: 'none',
|
|
175
|
+
opacity: 0,
|
|
176
|
+
margin: 0
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
};
|
|
180
|
+
function $ce74a64c62457efb$var$getState(checked) {
|
|
181
|
+
return checked ? 'checked' : 'unchecked';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const $240483839a8a76fd$var$ARROW_KEYS = [
|
|
186
|
+
'ArrowUp',
|
|
187
|
+
'ArrowDown',
|
|
188
|
+
'ArrowLeft',
|
|
189
|
+
'ArrowRight'
|
|
190
|
+
];
|
|
191
|
+
/* -------------------------------------------------------------------------------------------------
|
|
192
|
+
* RadioGroup
|
|
193
|
+
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$RADIO_GROUP_NAME = 'RadioGroup';
|
|
194
|
+
const [$240483839a8a76fd$var$createRadioGroupContet, $240483839a8a76fd$export$c547093f11b76da2] = $9yYIj$radixuireactcontext.createContextScope($240483839a8a76fd$var$RADIO_GROUP_NAME, [
|
|
195
|
+
$9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope,
|
|
196
|
+
$ce74a64c62457efb$export$67d2296460f1b002
|
|
197
|
+
]);
|
|
198
|
+
const $240483839a8a76fd$var$useRovingFocusGroupScope = $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope();
|
|
199
|
+
const $240483839a8a76fd$var$useRadioScope = $ce74a64c62457efb$export$67d2296460f1b002();
|
|
200
|
+
const [$240483839a8a76fd$var$RadioGroupProvider, $240483839a8a76fd$var$useRadioGroupContext] = $240483839a8a76fd$var$createRadioGroupContet($240483839a8a76fd$var$RADIO_GROUP_NAME);
|
|
201
|
+
const $240483839a8a76fd$export$a98f0dcb43a68a25 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
|
|
202
|
+
const { __scopeRadioGroup: __scopeRadioGroup , name: name , 'aria-labelledby': ariaLabelledby , defaultValue: defaultValue , value: valueProp , required: required = false , orientation: orientation , dir: dir , loop: loop = true , onValueChange: onValueChange , ...groupProps } = props;
|
|
203
|
+
const labelId = $9yYIj$radixuireactlabel.useLabelContext();
|
|
204
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
205
|
+
const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
|
|
206
|
+
const direction = $9yYIj$radixuireactdirection.useDirection(dir);
|
|
207
|
+
const [value, setValue] = $9yYIj$radixuireactusecontrollablestate.useControllableState({
|
|
208
|
+
prop: valueProp,
|
|
209
|
+
defaultProp: defaultValue,
|
|
210
|
+
onChange: onValueChange
|
|
211
|
+
});
|
|
212
|
+
return /*#__PURE__*/ $9yYIj$react.createElement($240483839a8a76fd$var$RadioGroupProvider, {
|
|
213
|
+
scope: __scopeRadioGroup,
|
|
214
|
+
name: name,
|
|
215
|
+
required: required,
|
|
216
|
+
value: value,
|
|
217
|
+
onValueChange: setValue
|
|
218
|
+
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Root, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
219
|
+
asChild: true
|
|
220
|
+
}, rovingFocusGroupScope, {
|
|
221
|
+
orientation: orientation,
|
|
222
|
+
dir: direction,
|
|
223
|
+
loop: loop
|
|
224
|
+
}), /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
225
|
+
role: "radiogroup",
|
|
226
|
+
"aria-orientation": orientation,
|
|
227
|
+
"aria-labelledby": labelledBy,
|
|
228
|
+
dir: direction
|
|
229
|
+
}, groupProps, {
|
|
230
|
+
ref: forwardedRef
|
|
231
|
+
}))));
|
|
232
|
+
});
|
|
233
|
+
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$a98f0dcb43a68a25, {
|
|
234
|
+
displayName: $240483839a8a76fd$var$RADIO_GROUP_NAME
|
|
235
|
+
});
|
|
236
|
+
/* -------------------------------------------------------------------------------------------------
|
|
237
|
+
* RadioGroupItem
|
|
238
|
+
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$ITEM_NAME = 'RadioGroupItem';
|
|
239
|
+
const $240483839a8a76fd$export$9f866c100ef519e4 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
|
|
240
|
+
const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
|
|
241
|
+
const context = $240483839a8a76fd$var$useRadioGroupContext($240483839a8a76fd$var$ITEM_NAME, __scopeRadioGroup);
|
|
242
|
+
const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
|
|
243
|
+
const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
|
|
244
|
+
const ref = $9yYIj$react.useRef(null);
|
|
245
|
+
const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
|
|
246
|
+
const checked = context.value === itemProps.value;
|
|
247
|
+
const isArrowKeyPressedRef = $9yYIj$react.useRef(false);
|
|
248
|
+
$9yYIj$react.useEffect(()=>{
|
|
249
|
+
const handleKeyDown = (event)=>{
|
|
250
|
+
if ($240483839a8a76fd$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
|
|
251
|
+
};
|
|
252
|
+
const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
|
|
253
|
+
;
|
|
254
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
255
|
+
document.addEventListener('keyup', handleKeyUp);
|
|
256
|
+
return ()=>{
|
|
257
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
258
|
+
document.removeEventListener('keyup', handleKeyUp);
|
|
259
|
+
};
|
|
260
|
+
}, []);
|
|
261
|
+
return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Item, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
262
|
+
asChild: true
|
|
263
|
+
}, rovingFocusGroupScope, {
|
|
264
|
+
focusable: !disabled,
|
|
265
|
+
active: checked
|
|
266
|
+
}), /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d7b12c4107be0d61, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
|
|
267
|
+
disabled: disabled,
|
|
268
|
+
required: context.required,
|
|
269
|
+
checked: checked
|
|
270
|
+
}, radioScope, itemProps, {
|
|
271
|
+
name: context.name,
|
|
272
|
+
ref: composedRefs,
|
|
273
|
+
onCheck: ()=>context.onValueChange(itemProps.value)
|
|
274
|
+
,
|
|
275
|
+
onKeyDown: $9yYIj$radixuiprimitive.composeEventHandlers((event)=>{
|
|
276
|
+
// According to WAI ARIA, radio groups don't activate items on enter keypress
|
|
277
|
+
if (event.key === 'Enter') event.preventDefault();
|
|
278
|
+
}),
|
|
279
|
+
onFocus: $9yYIj$radixuiprimitive.composeEventHandlers(itemProps.onFocus, ()=>{
|
|
280
|
+
var _ref$current;
|
|
281
|
+
/**
|
|
282
|
+
* Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
|
|
283
|
+
* and we need to "check" it in that case. We click it to "check" it (instead
|
|
284
|
+
* of updating `context.value`) so that the radio change event fires.
|
|
285
|
+
*/ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
|
|
286
|
+
})
|
|
287
|
+
})));
|
|
288
|
+
});
|
|
289
|
+
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$9f866c100ef519e4, {
|
|
290
|
+
displayName: $240483839a8a76fd$var$ITEM_NAME
|
|
291
|
+
});
|
|
292
|
+
/* -------------------------------------------------------------------------------------------------
|
|
293
|
+
* RadioGroupIndicator
|
|
294
|
+
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$INDICATOR_NAME = 'RadioGroupIndicator';
|
|
295
|
+
const $240483839a8a76fd$export$5fb54c671a65c88 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
|
|
296
|
+
const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
|
|
297
|
+
const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
|
|
298
|
+
return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d35a9ffa9a04f9e7, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({}, radioScope, indicatorProps, {
|
|
299
|
+
ref: forwardedRef
|
|
300
|
+
}));
|
|
301
|
+
});
|
|
302
|
+
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$5fb54c671a65c88, {
|
|
303
|
+
displayName: $240483839a8a76fd$var$INDICATOR_NAME
|
|
304
|
+
});
|
|
305
|
+
/* ---------------------------------------------------------------------------------------------- */ const $240483839a8a76fd$export$be92b6f5f03c0fe9 = $240483839a8a76fd$export$a98f0dcb43a68a25;
|
|
306
|
+
const $240483839a8a76fd$export$6d08773d2e66f8f2 = $240483839a8a76fd$export$9f866c100ef519e4;
|
|
307
|
+
const $240483839a8a76fd$export$adb584737d712b70 = $240483839a8a76fd$export$5fb54c671a65c88;
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
$parcel$exportWildcard(module.exports, $240483839a8a76fd$exports);
|
|
311
|
+
|
|
312
|
+
|
|
2
313
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"IAAgCA,8oBAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECTT,MAGOS,EAAoBC,GAAoBC,EAH5B,UAMZC,EAAeC,GAAmBJ,EANtB,SAgBbK,eAAQC,EAAMC,YAClB,CAACC,EAAgCC,KAC/B,MAAMC,aACJA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A,EACVD,SAAU4C,EAAQ5C,SAClBD,QAASA,GACL0G,EACAD,EALN,CAME1G,KAAM8C,EAAQ9C,KACd+B,IAAKrB,EACLL,QAAS,IAAMyC,EAAQ4C,cAAcgB,EAAUtG,OAC/CmH,UAAWtF,GAAsBC,IAEb,UAAdA,EAAMlD,KAAiBkD,EAAMsF,oBAEnCC,QAASxF,EAAqByE,EAAUe,SAAS,KAAM,IAAAC,EAMjDd,EAAqBzE,UAAS,QAAAuF,EAAA3F,EAAII,eAAJ,IAAAuF,GAAAA,EAAaC,4CAc3D,MAMMC,eAAsBlI,EAAMC,YAChC,CAACC,EAA8CC,KAC7C,MAAMuF,kBAAEA,KAAsBvC,GAAmBjD,EAC3C+G,EAAa3B,EAAcI,gBACjC,OAAO/D,EAAAC,cAAAuG,EAAAnG,EAAA,GAAoBiF,EAAgB9D,EAApC,CAAoDd,IAAKlC,sCAQpE,MAAMyG,EAAOnB,iBACb,MAAMgC,EAAOV,iBACb,MAAMqB,EAAYF","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/radio-group/src/Radio.tsx","./packages/react/radio-group/src/RadioGroup.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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';\nimport { useLabelContext } from '@radix-ui/react-label';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = { checked: boolean; disabled?: boolean };\nconst [RadioProvider, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\ntype RadioElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends PrimitiveButtonProps {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const {\n __scopeRadio,\n 'aria-labelledby': ariaLabelledby,\n name,\n checked = false,\n required,\n disabled,\n value = 'on',\n onCheck,\n ...radioProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const labelId = useLabelContext(button);\n const labelledBy = ariaLabelledby || labelId;\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n\n return (\n <RadioProvider scope={__scopeRadio} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck?.();\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\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 style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </RadioProvider>\n );\n }\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.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\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\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 = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"radio\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n //\n Radio,\n RadioIndicator,\n};\nexport type { RadioProps };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useLabelContext } from '@radix-ui/react-label';\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 { Radio, RadioIndicator, createRadioScope } from './Radio';\n\nimport type * as Radix from '@radix-ui/react-primitive';\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 [createRadioGroupContet, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n value?: string;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContet<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: RadioGroupContextValue['value'];\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n 'aria-labelledby': ariaLabelledby,\n defaultValue,\n value: valueProp,\n required = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const labelId = useLabelContext();\n const labelledBy = ariaLabelledby || labelId;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\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-orientation={orientation}\n aria-labelledby={labelledBy}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n }\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\n\ntype RadioGroupItemElement = React.ElementRef<typeof Radio>;\ntype RadioProps = Radix.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, disabled, ...itemProps } = props;\n const context = useRadioGroupContext(ITEM_NAME, __scopeRadioGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const ref = React.useRef<React.ElementRef<typeof Radio>>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const checked = context.value === itemProps.value;\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 <Radio\n disabled={disabled}\n required={context.required}\n checked={checked}\n {...radioScope}\n {...itemProps}\n name={context.name}\n ref={composedRefs}\n onCheck={() => context.onValueChange(itemProps.value)}\n onKeyDown={composeEventHandlers((event) => {\n // According to WAI ARIA, radio groups don't activate items on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(itemProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys\n * and we need to \"check\" it in that case. We click it to \"check\" it (instead\n * of updating `context.value`) so that the radio change event fires.\n */\n if (isArrowKeyPressedRef.current) ref.current?.click();\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ElementRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = Radix.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\nconst Root = RadioGroup;\nconst Item = RadioGroupItem;\nconst Indicator = RadioGroupIndicator;\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n};\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps };\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","createRadioContext","createRadioScope","createContextScope","RadioProvider","useRadioContext","Radio","React","forwardRef","props","forwardedRef","__scopeRadio","ariaLabelledby","name","checked","required","disabled","value","onCheck","radioProps","button","setButton","useState","composedRefs","useComposedRefs","node","labelId","useLabelContext","labelledBy","hasConsumerStoppedPropagationRef","useRef","isFormControl","Boolean","closest","_react","createElement","$c40e389c8bd5637683139221ff5860e$var$RadioProvider","scope","Primitive","_babelRuntimeHelpersExtends","type","role","getState","undefined","ref","onClick","composeEventHandlers","event","current","isPropagationStopped","stopPropagation","$c40e389c8bd5637683139221ff5860e$var$BubbleInput","control","bubbles","style","transform","RadioIndicator","forceMount","indicatorProps","context","Presence","present","span","BubbleInput","inputProps","prevChecked","usePrevious","controlSize","useSize","useEffect","input","inputProto","window","HTMLInputElement","prototype","setChecked","getOwnPropertyDescriptor","set","Event","call","dispatchEvent","defaultChecked","tabIndex","position","pointerEvents","opacity","margin","ARROW_KEYS","createRadioGroupContet","createRadioGroupScope","createRovingFocusGroupScope","$c40e389c8bd5637683139221ff5860e$export$createRadioScope","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","RadioGroup","__scopeRadioGroup","defaultValue","valueProp","orientation","dir","loop","onValueChange","groupProps","rovingFocusGroupScope","direction","useDirection","setValue","useControllableState","prop","defaultProp","onChange","$f0591e76470a81aa49d2bd8c37d2b$var$RadioGroupProvider","_radixUiReactRovingFocus","Root","asChild","div","RadioGroupItem","itemProps","radioScope","isArrowKeyPressedRef","handleKeyDown","includes","handleKeyUp","document","addEventListener","removeEventListener","Item","focusable","active","$c40e389c8bd5637683139221ff5860e$export$Radio","onKeyDown","preventDefault","onFocus","_ref$current","click","RadioGroupIndicator","$c40e389c8bd5637683139221ff5860e$export$RadioIndicator","Indicator"],"version":3,"file":"index.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;;A;;;;;;;;;;AEaA;;oGAEA,CAEA,MAAM8E,gCAAU,GAAG,OAAnB,AAAA;AAGA,MAAM,CAACC,wCAAD,EAAqBnE,yCAArB,CAAA,GAAyCR,6CAAkB,CAAC0E,gCAAD,CAAjE,AAAA;AAGA,MAAM,CAACE,mCAAD,EAAgBC,qCAAhB,CAAA,GAAmCF,wCAAkB,CAAoBD,gCAApB,CAA3D,AAAA;AAUA,MAAMpE,yCAAK,GAAA,aAAGV,CAAAA,uBAAA,CACZ,CAACuB,KAAD,EAAiCC,YAAjC,GAAkD;IAChD,MAAM,E,cACJ0D,YADI,CAAA,EAEJ,iBAAA,EAAmBvD,cAFf,CAAA,E,MAGJD,IAHI,CAAA,WAIJ4B,OAAO,GAAG,KAJN,G,UAKJvB,QALI,CAAA,E,UAMJgB,QANI,CAAA,SAOJlB,KAAK,GAAG,IAPJ,G,SAQJsD,OARI,CAAA,EASJ,GAAGC,UAAH,EATI,GAUF7D,KAVJ,AAAM;IAWN,MAAM,CAAC8D,MAAD,EAASC,SAAT,CAAA,GAAsBtF,qBAAA,CAAyC,IAAzC,CAA5B,AAAA;IACA,MAAMqD,YAAY,GAAGlD,8CAAe,CAACqB,YAAD,EAAgBgE,CAAAA,IAAD,GAAUF,SAAS,CAACE,IAAD,CAAlC;IAAA,CAApC,AAAA;IACA,MAAMnD,OAAO,GAAGnC,wCAAe,CAACmF,MAAD,CAA/B,AAAA;IACA,MAAM/C,UAAU,GAAGX,cAAc,IAAIU,OAArC,AAAA;IACA,MAAMoD,gCAAgC,GAAGzF,mBAAA,CAAa,KAAb,CAAzC,AAhBgD,EAiBhD,iFADA;IAEA,MAAM0F,aAAa,GAAGL,MAAM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C,YAA/C,GAAgE;IAC9D,MAAM,E,mBAAEC,iBAAF,CAAA,EAAqB,GAAG8C,cAAH,EAArB,GAA2ChD,KAAjD,AAAM;IACN,MAAM2B,UAAU,GAAGhC,mCAAa,CAACO,iBAAD,CAAhC,AAAA;IACA,OAAA,aAAO,CAAA,0BAAA,CAAC,yCAAD,EAAA,2DAAA,CAAA,EAAA,EAAoByB,UAApB,EAAoCqB,cAApC,EAAP;QAA2D,GAAG,EAAE/C,YAAL;KAApD,CAAA,CAAP,CAAO;CAJiB,CAA5B,AAKG;AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,wCAAA,EAAA;IAAA,WAAA,EAAA,oCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMgD,yCAAI,GAAGnD,yCAAb,AAAA;AACA,MAAMoD,yCAAI,GAAG3B,yCAAb,AAAA;AACA,MAAM4B,yCAAS,GAAGJ,wCAAlB,AAAA;;ADhNA","sources":["packages/react/radio-group/src/index.ts","packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/Radio.tsx"],"sourcesContent":["export * from './RadioGroup';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useLabelContext } from '@radix-ui/react-label';\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 { Radio, RadioIndicator, createRadioScope } from './Radio';\n\nimport type * as Radix from '@radix-ui/react-primitive';\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 [createRadioGroupContet, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n value?: string;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContet<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: RadioGroupContextValue['value'];\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n 'aria-labelledby': ariaLabelledby,\n defaultValue,\n value: valueProp,\n required = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const labelId = useLabelContext();\n const labelledBy = ariaLabelledby || labelId;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\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-orientation={orientation}\n aria-labelledby={labelledBy}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n }\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\n\ntype RadioGroupItemElement = React.ElementRef<typeof Radio>;\ntype RadioProps = Radix.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, disabled, ...itemProps } = props;\n const context = useRadioGroupContext(ITEM_NAME, __scopeRadioGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const ref = React.useRef<React.ElementRef<typeof Radio>>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const checked = context.value === itemProps.value;\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 <Radio\n disabled={disabled}\n required={context.required}\n checked={checked}\n {...radioScope}\n {...itemProps}\n name={context.name}\n ref={composedRefs}\n onCheck={() => context.onValueChange(itemProps.value)}\n onKeyDown={composeEventHandlers((event) => {\n // According to WAI ARIA, radio groups don't activate items on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(itemProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys\n * and we need to \"check\" it in that case. We click it to \"check\" it (instead\n * of updating `context.value`) so that the radio change event fires.\n */\n if (isArrowKeyPressedRef.current) ref.current?.click();\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ElementRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = Radix.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\nconst Root = RadioGroup;\nconst Item = RadioGroupItem;\nconst Indicator = RadioGroupIndicator;\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n};\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps };\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';\nimport { useLabelContext } from '@radix-ui/react-label';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = { checked: boolean; disabled?: boolean };\nconst [RadioProvider, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\ntype RadioElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends PrimitiveButtonProps {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const {\n __scopeRadio,\n 'aria-labelledby': ariaLabelledby,\n name,\n checked = false,\n required,\n disabled,\n value = 'on',\n onCheck,\n ...radioProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const labelId = useLabelContext(button);\n const labelledBy = ariaLabelledby || labelId;\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n\n return (\n <RadioProvider scope={__scopeRadio} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck?.();\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\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 style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </RadioProvider>\n );\n }\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.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\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\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 = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"radio\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n //\n Radio,\n RadioIndicator,\n};\nexport type { RadioProps };\n"],"names":["React","composeEventHandlers","useLabelContext","useComposedRefs","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","useControllableState","useDirection","Radio","RadioIndicator","createRadioScope","ARROW_KEYS","RADIO_GROUP_NAME","createRadioGroupContet","createRadioGroupScope","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","RadioGroup","forwardRef","props","forwardedRef","__scopeRadioGroup","name","ariaLabelledby","defaultValue","value","valueProp","required","orientation","dir","loop","onValueChange","groupProps","labelId","labelledBy","rovingFocusGroupScope","direction","setValue","prop","defaultProp","onChange","ITEM_NAME","RadioGroupItem","disabled","itemProps","context","radioScope","ref","useRef","composedRefs","checked","isArrowKeyPressedRef","useEffect","handleKeyDown","event","includes","key","current","handleKeyUp","document","addEventListener","removeEventListener","preventDefault","onFocus","click","INDICATOR_NAME","RadioGroupIndicator","indicatorProps","Root","Item","Indicator","useSize","usePrevious","Presence","RADIO_NAME","createRadioContext","RadioProvider","useRadioContext","__scopeRadio","onCheck","radioProps","button","setButton","useState","node","hasConsumerStoppedPropagationRef","isFormControl","Boolean","closest","getState","undefined","onClick","isPropagationStopped","stopPropagation","transform","forceMount","BubbleInput","control","bubbles","inputProps","prevChecked","controlSize","input","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","setChecked","set","Event","call","dispatchEvent","style","position","pointerEvents","opacity","margin"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,294 @@
|
|
|
1
|
-
import
|
|
1
|
+
import $8Wolv$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import {forwardRef as $8Wolv$forwardRef, createElement as $8Wolv$createElement, useRef as $8Wolv$useRef, useEffect as $8Wolv$useEffect, useState as $8Wolv$useState} from "react";
|
|
3
|
+
import {composeEventHandlers as $8Wolv$composeEventHandlers} from "@radix-ui/primitive";
|
|
4
|
+
import {useLabelContext as $8Wolv$useLabelContext} from "@radix-ui/react-label";
|
|
5
|
+
import {useComposedRefs as $8Wolv$useComposedRefs} from "@radix-ui/react-compose-refs";
|
|
6
|
+
import {createContextScope as $8Wolv$createContextScope} from "@radix-ui/react-context";
|
|
7
|
+
import {Primitive as $8Wolv$Primitive} from "@radix-ui/react-primitive";
|
|
8
|
+
import {createRovingFocusGroupScope as $8Wolv$createRovingFocusGroupScope, Root as $8Wolv$Root, Item as $8Wolv$Item} from "@radix-ui/react-roving-focus";
|
|
9
|
+
import {useControllableState as $8Wolv$useControllableState} from "@radix-ui/react-use-controllable-state";
|
|
10
|
+
import {useDirection as $8Wolv$useDirection} from "@radix-ui/react-direction";
|
|
11
|
+
import {useSize as $8Wolv$useSize} from "@radix-ui/react-use-size";
|
|
12
|
+
import {usePrevious as $8Wolv$usePrevious} from "@radix-ui/react-use-previous";
|
|
13
|
+
import {Presence as $8Wolv$Presence} from "@radix-ui/react-presence";
|
|
14
|
+
|
|
15
|
+
function $parcel$export(e, n, v, s) {
|
|
16
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
17
|
+
}
|
|
18
|
+
var $f99a8c78507165f7$exports = {};
|
|
19
|
+
|
|
20
|
+
$parcel$export($f99a8c78507165f7$exports, "createRadioGroupScope", () => $f99a8c78507165f7$export$c547093f11b76da2);
|
|
21
|
+
$parcel$export($f99a8c78507165f7$exports, "RadioGroup", () => $f99a8c78507165f7$export$a98f0dcb43a68a25);
|
|
22
|
+
$parcel$export($f99a8c78507165f7$exports, "RadioGroupItem", () => $f99a8c78507165f7$export$9f866c100ef519e4);
|
|
23
|
+
$parcel$export($f99a8c78507165f7$exports, "RadioGroupIndicator", () => $f99a8c78507165f7$export$5fb54c671a65c88);
|
|
24
|
+
$parcel$export($f99a8c78507165f7$exports, "Root", () => $f99a8c78507165f7$export$be92b6f5f03c0fe9);
|
|
25
|
+
$parcel$export($f99a8c78507165f7$exports, "Item", () => $f99a8c78507165f7$export$6d08773d2e66f8f2);
|
|
26
|
+
$parcel$export($f99a8c78507165f7$exports, "Indicator", () => $f99a8c78507165f7$export$adb584737d712b70);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/* -------------------------------------------------------------------------------------------------
|
|
49
|
+
* Radio
|
|
50
|
+
* -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$RADIO_NAME = 'Radio';
|
|
51
|
+
const [$ce77a8961b41be9e$var$createRadioContext, $ce77a8961b41be9e$export$67d2296460f1b002] = $8Wolv$createContextScope($ce77a8961b41be9e$var$RADIO_NAME);
|
|
52
|
+
const [$ce77a8961b41be9e$var$RadioProvider, $ce77a8961b41be9e$var$useRadioContext] = $ce77a8961b41be9e$var$createRadioContext($ce77a8961b41be9e$var$RADIO_NAME);
|
|
53
|
+
const $ce77a8961b41be9e$export$d7b12c4107be0d61 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
|
|
54
|
+
const { __scopeRadio: __scopeRadio , 'aria-labelledby': ariaLabelledby , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
|
|
55
|
+
const [button, setButton] = $8Wolv$useState(null);
|
|
56
|
+
const composedRefs = $8Wolv$useComposedRefs(forwardedRef, (node)=>setButton(node)
|
|
57
|
+
);
|
|
58
|
+
const labelId = $8Wolv$useLabelContext(button);
|
|
59
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
60
|
+
const hasConsumerStoppedPropagationRef = $8Wolv$useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
|
|
61
|
+
const isFormControl = button ? Boolean(button.closest('form')) : true;
|
|
62
|
+
return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$RadioProvider, {
|
|
63
|
+
scope: __scopeRadio,
|
|
64
|
+
checked: checked,
|
|
65
|
+
disabled: disabled
|
|
66
|
+
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.button, $8Wolv$babelruntimehelpersesmextends({
|
|
67
|
+
type: "button",
|
|
68
|
+
role: "radio",
|
|
69
|
+
"aria-checked": checked,
|
|
70
|
+
"aria-labelledby": labelledBy,
|
|
71
|
+
"data-state": $ce77a8961b41be9e$var$getState(checked),
|
|
72
|
+
"data-disabled": disabled ? '' : undefined,
|
|
73
|
+
disabled: disabled,
|
|
74
|
+
value: value
|
|
75
|
+
}, radioProps, {
|
|
76
|
+
ref: composedRefs,
|
|
77
|
+
onClick: $8Wolv$composeEventHandlers(props.onClick, (event)=>{
|
|
78
|
+
// radios cannot be unchecked so we only communicate a checked state
|
|
79
|
+
if (!checked) onCheck === null || onCheck === void 0 || onCheck();
|
|
80
|
+
if (isFormControl) {
|
|
81
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
|
|
82
|
+
// one click event (from the input). We propagate changes from an input so that native
|
|
83
|
+
// form validation works and form events reflect radio updates.
|
|
84
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
})), isFormControl && /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$BubbleInput, {
|
|
88
|
+
control: button,
|
|
89
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
90
|
+
name: name,
|
|
91
|
+
value: value,
|
|
92
|
+
checked: checked,
|
|
93
|
+
required: required,
|
|
94
|
+
disabled: disabled // We transform because the input is absolutely positioned but we have
|
|
95
|
+
,
|
|
96
|
+
style: {
|
|
97
|
+
transform: 'translateX(-100%)'
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
/*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d7b12c4107be0d61, {
|
|
102
|
+
displayName: $ce77a8961b41be9e$var$RADIO_NAME
|
|
103
|
+
});
|
|
104
|
+
/* -------------------------------------------------------------------------------------------------
|
|
105
|
+
* RadioIndicator
|
|
106
|
+
* -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$INDICATOR_NAME = 'RadioIndicator';
|
|
107
|
+
const $ce77a8961b41be9e$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
|
|
108
|
+
const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
|
|
109
|
+
const context = $ce77a8961b41be9e$var$useRadioContext($ce77a8961b41be9e$var$INDICATOR_NAME, __scopeRadio);
|
|
110
|
+
return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Presence, {
|
|
111
|
+
present: forceMount || context.checked
|
|
112
|
+
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.span, $8Wolv$babelruntimehelpersesmextends({
|
|
113
|
+
"data-state": $ce77a8961b41be9e$var$getState(context.checked),
|
|
114
|
+
"data-disabled": context.disabled ? '' : undefined
|
|
115
|
+
}, indicatorProps, {
|
|
116
|
+
ref: forwardedRef
|
|
117
|
+
})));
|
|
118
|
+
});
|
|
119
|
+
/*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, {
|
|
120
|
+
displayName: $ce77a8961b41be9e$var$INDICATOR_NAME
|
|
121
|
+
});
|
|
122
|
+
/* ---------------------------------------------------------------------------------------------- */ const $ce77a8961b41be9e$var$BubbleInput = (props)=>{
|
|
123
|
+
const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
|
|
124
|
+
const ref = $8Wolv$useRef(null);
|
|
125
|
+
const prevChecked = $8Wolv$usePrevious(checked);
|
|
126
|
+
const controlSize = $8Wolv$useSize(control); // Bubble checked change to parents (e.g form change event)
|
|
127
|
+
$8Wolv$useEffect(()=>{
|
|
128
|
+
const input = ref.current;
|
|
129
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
130
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
|
|
131
|
+
const setChecked = descriptor.set;
|
|
132
|
+
if (prevChecked !== checked && setChecked) {
|
|
133
|
+
const event = new Event('click', {
|
|
134
|
+
bubbles: bubbles
|
|
135
|
+
});
|
|
136
|
+
setChecked.call(input, checked);
|
|
137
|
+
input.dispatchEvent(event);
|
|
138
|
+
}
|
|
139
|
+
}, [
|
|
140
|
+
prevChecked,
|
|
141
|
+
checked,
|
|
142
|
+
bubbles
|
|
143
|
+
]);
|
|
144
|
+
return /*#__PURE__*/ $8Wolv$createElement("input", $8Wolv$babelruntimehelpersesmextends({
|
|
145
|
+
type: "radio",
|
|
146
|
+
"aria-hidden": true,
|
|
147
|
+
defaultChecked: checked
|
|
148
|
+
}, inputProps, {
|
|
149
|
+
tabIndex: -1,
|
|
150
|
+
ref: ref,
|
|
151
|
+
style: {
|
|
152
|
+
...props.style,
|
|
153
|
+
...controlSize,
|
|
154
|
+
position: 'absolute',
|
|
155
|
+
pointerEvents: 'none',
|
|
156
|
+
opacity: 0,
|
|
157
|
+
margin: 0
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
};
|
|
161
|
+
function $ce77a8961b41be9e$var$getState(checked) {
|
|
162
|
+
return checked ? 'checked' : 'unchecked';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
const $f99a8c78507165f7$var$ARROW_KEYS = [
|
|
167
|
+
'ArrowUp',
|
|
168
|
+
'ArrowDown',
|
|
169
|
+
'ArrowLeft',
|
|
170
|
+
'ArrowRight'
|
|
171
|
+
];
|
|
172
|
+
/* -------------------------------------------------------------------------------------------------
|
|
173
|
+
* RadioGroup
|
|
174
|
+
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$RADIO_GROUP_NAME = 'RadioGroup';
|
|
175
|
+
const [$f99a8c78507165f7$var$createRadioGroupContet, $f99a8c78507165f7$export$c547093f11b76da2] = $8Wolv$createContextScope($f99a8c78507165f7$var$RADIO_GROUP_NAME, [
|
|
176
|
+
$8Wolv$createRovingFocusGroupScope,
|
|
177
|
+
$ce77a8961b41be9e$export$67d2296460f1b002
|
|
178
|
+
]);
|
|
179
|
+
const $f99a8c78507165f7$var$useRovingFocusGroupScope = $8Wolv$createRovingFocusGroupScope();
|
|
180
|
+
const $f99a8c78507165f7$var$useRadioScope = $ce77a8961b41be9e$export$67d2296460f1b002();
|
|
181
|
+
const [$f99a8c78507165f7$var$RadioGroupProvider, $f99a8c78507165f7$var$useRadioGroupContext] = $f99a8c78507165f7$var$createRadioGroupContet($f99a8c78507165f7$var$RADIO_GROUP_NAME);
|
|
182
|
+
const $f99a8c78507165f7$export$a98f0dcb43a68a25 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
|
|
183
|
+
const { __scopeRadioGroup: __scopeRadioGroup , name: name , 'aria-labelledby': ariaLabelledby , defaultValue: defaultValue , value: valueProp , required: required = false , orientation: orientation , dir: dir , loop: loop = true , onValueChange: onValueChange , ...groupProps } = props;
|
|
184
|
+
const labelId = $8Wolv$useLabelContext();
|
|
185
|
+
const labelledBy = ariaLabelledby || labelId;
|
|
186
|
+
const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
|
|
187
|
+
const direction = $8Wolv$useDirection(dir);
|
|
188
|
+
const [value, setValue] = $8Wolv$useControllableState({
|
|
189
|
+
prop: valueProp,
|
|
190
|
+
defaultProp: defaultValue,
|
|
191
|
+
onChange: onValueChange
|
|
192
|
+
});
|
|
193
|
+
return /*#__PURE__*/ $8Wolv$createElement($f99a8c78507165f7$var$RadioGroupProvider, {
|
|
194
|
+
scope: __scopeRadioGroup,
|
|
195
|
+
name: name,
|
|
196
|
+
required: required,
|
|
197
|
+
value: value,
|
|
198
|
+
onValueChange: setValue
|
|
199
|
+
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Root, $8Wolv$babelruntimehelpersesmextends({
|
|
200
|
+
asChild: true
|
|
201
|
+
}, rovingFocusGroupScope, {
|
|
202
|
+
orientation: orientation,
|
|
203
|
+
dir: direction,
|
|
204
|
+
loop: loop
|
|
205
|
+
}), /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.div, $8Wolv$babelruntimehelpersesmextends({
|
|
206
|
+
role: "radiogroup",
|
|
207
|
+
"aria-orientation": orientation,
|
|
208
|
+
"aria-labelledby": labelledBy,
|
|
209
|
+
dir: direction
|
|
210
|
+
}, groupProps, {
|
|
211
|
+
ref: forwardedRef
|
|
212
|
+
}))));
|
|
213
|
+
});
|
|
214
|
+
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$a98f0dcb43a68a25, {
|
|
215
|
+
displayName: $f99a8c78507165f7$var$RADIO_GROUP_NAME
|
|
216
|
+
});
|
|
217
|
+
/* -------------------------------------------------------------------------------------------------
|
|
218
|
+
* RadioGroupItem
|
|
219
|
+
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$ITEM_NAME = 'RadioGroupItem';
|
|
220
|
+
const $f99a8c78507165f7$export$9f866c100ef519e4 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
|
|
221
|
+
const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
|
|
222
|
+
const context = $f99a8c78507165f7$var$useRadioGroupContext($f99a8c78507165f7$var$ITEM_NAME, __scopeRadioGroup);
|
|
223
|
+
const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
|
|
224
|
+
const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
|
|
225
|
+
const ref = $8Wolv$useRef(null);
|
|
226
|
+
const composedRefs = $8Wolv$useComposedRefs(forwardedRef, ref);
|
|
227
|
+
const checked = context.value === itemProps.value;
|
|
228
|
+
const isArrowKeyPressedRef = $8Wolv$useRef(false);
|
|
229
|
+
$8Wolv$useEffect(()=>{
|
|
230
|
+
const handleKeyDown = (event)=>{
|
|
231
|
+
if ($f99a8c78507165f7$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
|
|
232
|
+
};
|
|
233
|
+
const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
|
|
234
|
+
;
|
|
235
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
236
|
+
document.addEventListener('keyup', handleKeyUp);
|
|
237
|
+
return ()=>{
|
|
238
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
239
|
+
document.removeEventListener('keyup', handleKeyUp);
|
|
240
|
+
};
|
|
241
|
+
}, []);
|
|
242
|
+
return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Item, $8Wolv$babelruntimehelpersesmextends({
|
|
243
|
+
asChild: true
|
|
244
|
+
}, rovingFocusGroupScope, {
|
|
245
|
+
focusable: !disabled,
|
|
246
|
+
active: checked
|
|
247
|
+
}), /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d7b12c4107be0d61, $8Wolv$babelruntimehelpersesmextends({
|
|
248
|
+
disabled: disabled,
|
|
249
|
+
required: context.required,
|
|
250
|
+
checked: checked
|
|
251
|
+
}, radioScope, itemProps, {
|
|
252
|
+
name: context.name,
|
|
253
|
+
ref: composedRefs,
|
|
254
|
+
onCheck: ()=>context.onValueChange(itemProps.value)
|
|
255
|
+
,
|
|
256
|
+
onKeyDown: $8Wolv$composeEventHandlers((event)=>{
|
|
257
|
+
// According to WAI ARIA, radio groups don't activate items on enter keypress
|
|
258
|
+
if (event.key === 'Enter') event.preventDefault();
|
|
259
|
+
}),
|
|
260
|
+
onFocus: $8Wolv$composeEventHandlers(itemProps.onFocus, ()=>{
|
|
261
|
+
var _ref$current;
|
|
262
|
+
/**
|
|
263
|
+
* Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
|
|
264
|
+
* and we need to "check" it in that case. We click it to "check" it (instead
|
|
265
|
+
* of updating `context.value`) so that the radio change event fires.
|
|
266
|
+
*/ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
|
|
267
|
+
})
|
|
268
|
+
})));
|
|
269
|
+
});
|
|
270
|
+
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$9f866c100ef519e4, {
|
|
271
|
+
displayName: $f99a8c78507165f7$var$ITEM_NAME
|
|
272
|
+
});
|
|
273
|
+
/* -------------------------------------------------------------------------------------------------
|
|
274
|
+
* RadioGroupIndicator
|
|
275
|
+
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$INDICATOR_NAME = 'RadioGroupIndicator';
|
|
276
|
+
const $f99a8c78507165f7$export$5fb54c671a65c88 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
|
|
277
|
+
const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
|
|
278
|
+
const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
|
|
279
|
+
return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, $8Wolv$babelruntimehelpersesmextends({}, radioScope, indicatorProps, {
|
|
280
|
+
ref: forwardedRef
|
|
281
|
+
}));
|
|
282
|
+
});
|
|
283
|
+
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$5fb54c671a65c88, {
|
|
284
|
+
displayName: $f99a8c78507165f7$var$INDICATOR_NAME
|
|
285
|
+
});
|
|
286
|
+
/* ---------------------------------------------------------------------------------------------- */ const $f99a8c78507165f7$export$be92b6f5f03c0fe9 = $f99a8c78507165f7$export$a98f0dcb43a68a25;
|
|
287
|
+
const $f99a8c78507165f7$export$6d08773d2e66f8f2 = $f99a8c78507165f7$export$9f866c100ef519e4;
|
|
288
|
+
const $f99a8c78507165f7$export$adb584737d712b70 = $f99a8c78507165f7$export$5fb54c671a65c88;
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
export {$f99a8c78507165f7$export$c547093f11b76da2 as createRadioGroupScope, $f99a8c78507165f7$export$a98f0dcb43a68a25 as RadioGroup, $f99a8c78507165f7$export$9f866c100ef519e4 as RadioGroupItem, $f99a8c78507165f7$export$5fb54c671a65c88 as RadioGroupIndicator, $f99a8c78507165f7$export$be92b6f5f03c0fe9 as Root, $f99a8c78507165f7$export$6d08773d2e66f8f2 as Item, $f99a8c78507165f7$export$adb584737d712b70 as Indicator};
|
|
2
294
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"kxBAiBA,MAGOA,EAAoBC,GAAoBC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ACE8E,SAAO,GACHX,EAFN,CAGEyB,WAAYnH,EACZoH,OAAQtH,iBAERoB,EAAAC,cAAAkG,EAAA9F,EAAA,CACEvB,SAAUA,EACVD,SAAU4C,EAAQ5C,SAClBD,QAASA,GACL2G,EACAD,EALN,CAME3G,KAAM8C,EAAQ9C,KACd+B,IAAKrB,EACLL,QAAS,IAAMyC,EAAQ6C,cAAcgB,EAAUvG,OAC/CqH,UAAWxF,GAAsBC,IAEb,UAAdA,EAAM8E,KAAiB9E,EAAMwF,oBAEnCC,QAAS1F,EAAqB0E,EAAUgB,SAAS,KAAM,IAAAC,EAMjDf,EAAqB1E,UAAS,QAAAyF,EAAA7F,EAAII,eAAJ,IAAAyF,GAAAA,EAAaC,uCAoB3D,MAAMC,iCAAsBpI,EAAMC,YAChC,CAACC,EAA8CC,KAC7C,MAAMwF,kBAAEA,KAAsBxC,GAAmBjD,EAC3CgH,EAAa3B,EAAcI,gBACjC,OAAOhE,EAAAC,cAAAyG,EAAArG,EAAA,GAAoBkF,EAAgB/D,EAApC,CAAoDd,IAAKlC,4BAQpE,MAAM0G,KAAOnB,kBACb,MAAMiC,KAAOX,sBACb,MAAMsB,UAAYF","sources":["./packages/react/radio-group/src/Radio.tsx","./packages/react/radio-group/src/RadioGroup.tsx"],"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 { 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';\nimport { useLabelContext } from '@radix-ui/react-label';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = { checked: boolean; disabled?: boolean };\nconst [RadioProvider, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\ntype RadioElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends PrimitiveButtonProps {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const {\n __scopeRadio,\n 'aria-labelledby': ariaLabelledby,\n name,\n checked = false,\n required,\n disabled,\n value = 'on',\n onCheck,\n ...radioProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const labelId = useLabelContext(button);\n const labelledBy = ariaLabelledby || labelId;\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n\n return (\n <RadioProvider scope={__scopeRadio} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck?.();\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\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 style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </RadioProvider>\n );\n }\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.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\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\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 = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"radio\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n //\n Radio,\n RadioIndicator,\n};\nexport type { RadioProps };\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useLabelContext } from '@radix-ui/react-label';\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 { Radio, RadioIndicator, createRadioScope } from './Radio';\n\nimport type * as Radix from '@radix-ui/react-primitive';\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 [createRadioGroupContet, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n value?: string;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContet<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: RadioGroupContextValue['value'];\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n 'aria-labelledby': ariaLabelledby,\n defaultValue,\n value: valueProp,\n required = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const labelId = useLabelContext();\n const labelledBy = ariaLabelledby || labelId;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\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-orientation={orientation}\n aria-labelledby={labelledBy}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n }\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\n\ntype RadioGroupItemElement = React.ElementRef<typeof Radio>;\ntype RadioProps = Radix.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, disabled, ...itemProps } = props;\n const context = useRadioGroupContext(ITEM_NAME, __scopeRadioGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const ref = React.useRef<React.ElementRef<typeof Radio>>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const checked = context.value === itemProps.value;\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 <Radio\n disabled={disabled}\n required={context.required}\n checked={checked}\n {...radioScope}\n {...itemProps}\n name={context.name}\n ref={composedRefs}\n onCheck={() => context.onValueChange(itemProps.value)}\n onKeyDown={composeEventHandlers((event) => {\n // According to WAI ARIA, radio groups don't activate items on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(itemProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys\n * and we need to \"check\" it in that case. We click it to \"check\" it (instead\n * of updating `context.value`) so that the radio change event fires.\n */\n if (isArrowKeyPressedRef.current) ref.current?.click();\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ElementRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = Radix.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\nconst Root = RadioGroup;\nconst Item = RadioGroupItem;\nconst Indicator = RadioGroupIndicator;\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n};\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps };\n"],"names":["createRadioContext","createRadioScope","createContextScope","RadioProvider","useRadioContext","Radio","React","forwardRef","props","forwardedRef","__scopeRadio","ariaLabelledby","name","checked","required","disabled","value","onCheck","radioProps","button","setButton","useState","composedRefs","useComposedRefs","node","labelId","useLabelContext","labelledBy","hasConsumerStoppedPropagationRef","useRef","isFormControl","Boolean","closest","_react","createElement","$f7b37f51b2f1beab198838503d6ba083$var$RadioProvider","scope","Primitive","_babelRuntimeHelpersEsmExtends","type","role","getState","undefined","ref","onClick","composeEventHandlers","event","current","isPropagationStopped","stopPropagation","$f7b37f51b2f1beab198838503d6ba083$var$BubbleInput","control","bubbles","style","transform","RadioIndicator","forceMount","indicatorProps","context","Presence","present","span","BubbleInput","inputProps","prevChecked","usePrevious","controlSize","useSize","useEffect","input","inputProto","window","HTMLInputElement","prototype","setChecked","Object","getOwnPropertyDescriptor","set","Event","call","dispatchEvent","defaultChecked","tabIndex","position","pointerEvents","opacity","margin","ARROW_KEYS","createRadioGroupContet","createRadioGroupScope","createRovingFocusGroupScope","$f7b37f51b2f1beab198838503d6ba083$export$createRadioScope","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","RadioGroup","__scopeRadioGroup","defaultValue","valueProp","orientation","dir","loop","onValueChange","groupProps","rovingFocusGroupScope","direction","useDirection","setValue","useControllableState","prop","defaultProp","onChange","$b7d81d84737f46dda013f23006a0b2fd$var$RadioGroupProvider","_radixUiReactRovingFocus","Root","asChild","div","RadioGroupItem","itemProps","radioScope","isArrowKeyPressedRef","handleKeyDown","includes","key","handleKeyUp","document","addEventListener","removeEventListener","Item","focusable","active","$f7b37f51b2f1beab198838503d6ba083$export$Radio","onKeyDown","preventDefault","onFocus","_ref$current","click","RadioGroupIndicator","$f7b37f51b2f1beab198838503d6ba083$export$RadioIndicator","Indicator"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;;A;;;;;;;;;;AEaA;;oGAEA,CAEA,MAAM8E,gCAAU,GAAG,OAAnB,AAAA;AAGA,MAAM,CAACC,wCAAD,EAAqBnE,yCAArB,CAAA,GAAyCR,yBAAkB,CAAC0E,gCAAD,CAAjE,AAAA;AAGA,MAAM,CAACE,mCAAD,EAAgBC,qCAAhB,CAAA,GAAmCF,wCAAkB,CAAoBD,gCAApB,CAA3D,AAAA;AAUA,MAAMpE,yCAAK,GAAA,aAAGV,CAAAA,iBAAA,CACZ,CAACuB,KAAD,EAAiCC,YAAjC,GAA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AAM4B,yCAAS,GAAGJ,wCAAlB,AAAA;;ADhNA","sources":["packages/react/radio-group/src/index.ts","packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/Radio.tsx"],"sourcesContent":["export * from './RadioGroup';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useLabelContext } from '@radix-ui/react-label';\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 { Radio, RadioIndicator, createRadioScope } from './Radio';\n\nimport type * as Radix from '@radix-ui/react-primitive';\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 [createRadioGroupContet, createRadioGroupScope] = createContextScope(RADIO_GROUP_NAME, [\n createRovingFocusGroupScope,\n createRadioScope,\n]);\nconst useRovingFocusGroupScope = createRovingFocusGroupScope();\nconst useRadioScope = createRadioScope();\n\ntype RadioGroupContextValue = {\n name?: string;\n required: boolean;\n value?: string;\n onValueChange(value: string): void;\n};\n\nconst [RadioGroupProvider, useRadioGroupContext] =\n createRadioGroupContet<RadioGroupContextValue>(RADIO_GROUP_NAME);\n\ntype RadioGroupElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface RadioGroupProps extends PrimitiveDivProps {\n name?: RadioGroupContextValue['name'];\n required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];\n dir?: RovingFocusGroupProps['dir'];\n orientation?: RovingFocusGroupProps['orientation'];\n loop?: RovingFocusGroupProps['loop'];\n defaultValue?: string;\n value?: RadioGroupContextValue['value'];\n onValueChange?: RadioGroupContextValue['onValueChange'];\n}\n\nconst RadioGroup = React.forwardRef<RadioGroupElement, RadioGroupProps>(\n (props: ScopedProps<RadioGroupProps>, forwardedRef) => {\n const {\n __scopeRadioGroup,\n name,\n 'aria-labelledby': ariaLabelledby,\n defaultValue,\n value: valueProp,\n required = false,\n orientation,\n dir,\n loop = true,\n onValueChange,\n ...groupProps\n } = props;\n const labelId = useLabelContext();\n const labelledBy = ariaLabelledby || labelId;\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const direction = useDirection(dir);\n const [value, setValue] = useControllableState({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n return (\n <RadioGroupProvider\n scope={__scopeRadioGroup}\n name={name}\n required={required}\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-orientation={orientation}\n aria-labelledby={labelledBy}\n dir={direction}\n {...groupProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n </RadioGroupProvider>\n );\n }\n);\n\nRadioGroup.displayName = RADIO_GROUP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupItem\n * -----------------------------------------------------------------------------------------------*/\n\nconst ITEM_NAME = 'RadioGroupItem';\n\ntype RadioGroupItemElement = React.ElementRef<typeof Radio>;\ntype RadioProps = Radix.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, disabled, ...itemProps } = props;\n const context = useRadioGroupContext(ITEM_NAME, __scopeRadioGroup);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeRadioGroup);\n const radioScope = useRadioScope(__scopeRadioGroup);\n const ref = React.useRef<React.ElementRef<typeof Radio>>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const checked = context.value === itemProps.value;\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 <Radio\n disabled={disabled}\n required={context.required}\n checked={checked}\n {...radioScope}\n {...itemProps}\n name={context.name}\n ref={composedRefs}\n onCheck={() => context.onValueChange(itemProps.value)}\n onKeyDown={composeEventHandlers((event) => {\n // According to WAI ARIA, radio groups don't activate items on enter keypress\n if (event.key === 'Enter') event.preventDefault();\n })}\n onFocus={composeEventHandlers(itemProps.onFocus, () => {\n /**\n * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys\n * and we need to \"check\" it in that case. We click it to \"check\" it (instead\n * of updating `context.value`) so that the radio change event fires.\n */\n if (isArrowKeyPressedRef.current) ref.current?.click();\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nRadioGroupItem.displayName = ITEM_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioGroupIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioGroupIndicator';\n\ntype RadioGroupIndicatorElement = React.ElementRef<typeof RadioIndicator>;\ntype RadioIndicatorProps = Radix.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\nconst Root = RadioGroup;\nconst Item = RadioGroupItem;\nconst Indicator = RadioGroupIndicator;\n\nexport {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n};\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps };\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';\nimport { useLabelContext } from '@radix-ui/react-label';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Radio\n * -----------------------------------------------------------------------------------------------*/\n\nconst RADIO_NAME = 'Radio';\n\ntype ScopedProps<P> = P & { __scopeRadio?: Scope };\nconst [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);\n\ntype RadioContextValue = { checked: boolean; disabled?: boolean };\nconst [RadioProvider, useRadioContext] = createRadioContext<RadioContextValue>(RADIO_NAME);\n\ntype RadioElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface RadioProps extends PrimitiveButtonProps {\n checked?: boolean;\n required?: boolean;\n onCheck?(): void;\n}\n\nconst Radio = React.forwardRef<RadioElement, RadioProps>(\n (props: ScopedProps<RadioProps>, forwardedRef) => {\n const {\n __scopeRadio,\n 'aria-labelledby': ariaLabelledby,\n name,\n checked = false,\n required,\n disabled,\n value = 'on',\n onCheck,\n ...radioProps\n } = props;\n const [button, setButton] = React.useState<HTMLButtonElement | null>(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const labelId = useLabelContext(button);\n const labelledBy = ariaLabelledby || labelId;\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n // We set this to true by default so that events bubble to forms without JS (SSR)\n const isFormControl = button ? Boolean(button.closest('form')) : true;\n\n return (\n <RadioProvider scope={__scopeRadio} checked={checked} disabled={disabled}>\n <Primitive.button\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-labelledby={labelledBy}\n data-state={getState(checked)}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n value={value}\n {...radioProps}\n ref={composedRefs}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // radios cannot be unchecked so we only communicate a checked state\n if (!checked) onCheck?.();\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })}\n />\n {isFormControl && (\n <BubbleInput\n control={button}\n bubbles={!hasConsumerStoppedPropagationRef.current}\n name={name}\n value={value}\n checked={checked}\n required={required}\n disabled={disabled}\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 style={{ transform: 'translateX(-100%)' }}\n />\n )}\n </RadioProvider>\n );\n }\n);\n\nRadio.displayName = RADIO_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * RadioIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'RadioIndicator';\n\ntype RadioIndicatorElement = React.ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = Radix.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\ntype InputProps = Radix.ComponentPropsWithoutRef<'input'>;\ninterface BubbleInputProps extends Omit<InputProps, 'checked'> {\n checked: boolean;\n control: HTMLElement | null;\n bubbles: boolean;\n}\n\nconst BubbleInput = (props: BubbleInputProps) => {\n const { control, checked, bubbles = true, ...inputProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\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 = ref.current!;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked') as PropertyDescriptor;\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event('click', { bubbles });\n setChecked.call(input, checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n\n return (\n <input\n type=\"radio\"\n aria-hidden\n defaultChecked={checked}\n {...inputProps}\n tabIndex={-1}\n ref={ref}\n style={{\n ...props.style,\n ...controlSize,\n position: 'absolute',\n pointerEvents: 'none',\n opacity: 0,\n margin: 0,\n }}\n />\n );\n};\n\nfunction getState(checked: boolean) {\n return checked ? 'checked' : 'unchecked';\n}\n\nexport {\n createRadioScope,\n //\n Radio,\n RadioIndicator,\n};\nexport type { RadioProps };\n"],"names":["React","composeEventHandlers","useLabelContext","useComposedRefs","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","useControllableState","useDirection","Radio","RadioIndicator","createRadioScope","ARROW_KEYS","RADIO_GROUP_NAME","createRadioGroupContet","createRadioGroupScope","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","RadioGroup","forwardRef","props","forwardedRef","__scopeRadioGroup","name","ariaLabelledby","defaultValue","value","valueProp","required","orientation","dir","loop","onValueChange","groupProps","labelId","labelledBy","rovingFocusGroupScope","direction","setValue","prop","defaultProp","onChange","ITEM_NAME","RadioGroupItem","disabled","itemProps","context","radioScope","ref","useRef","composedRefs","checked","isArrowKeyPressedRef","useEffect","handleKeyDown","event","includes","key","current","handleKeyUp","document","addEventListener","removeEventListener","preventDefault","onFocus","click","INDICATOR_NAME","RadioGroupIndicator","indicatorProps","Root","Item","Indicator","useSize","usePrevious","Presence","RADIO_NAME","createRadioContext","RadioProvider","useRadioContext","__scopeRadio","onCheck","radioProps","button","setButton","useState","node","hasConsumerStoppedPropagationRef","isFormControl","Boolean","closest","getState","undefined","onClick","isPropagationStopped","stopPropagation","transform","forceMount","BubbleInput","control","bubbles","inputProps","prevChecked","controlSize","input","inputProto","window","HTMLInputElement","prototype","descriptor","Object","getOwnPropertyDescriptor","setChecked","set","Event","call","dispatchEvent","style","position","pointerEvents","opacity","margin"],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-radio-group",
|
|
3
|
-
"version": "0.1.6-rc.
|
|
3
|
+
"version": "0.1.6-rc.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
20
|
"@radix-ui/primitive": "0.1.0",
|
|
21
|
-
"@radix-ui/react-compose-refs": "0.1.1-rc.
|
|
22
|
-
"@radix-ui/react-context": "0.1.2-rc.
|
|
23
|
-
"@radix-ui/react-direction": "0.1.0-rc.
|
|
24
|
-
"@radix-ui/react-label": "0.1.6-rc.
|
|
25
|
-
"@radix-ui/react-presence": "0.1.3-rc.
|
|
26
|
-
"@radix-ui/react-primitive": "0.1.5-rc.
|
|
27
|
-
"@radix-ui/react-roving-focus": "0.1.6-rc.
|
|
28
|
-
"@radix-ui/react-use-controllable-state": "0.1.1-rc.
|
|
29
|
-
"@radix-ui/react-use-previous": "0.1.2-rc.
|
|
30
|
-
"@radix-ui/react-use-size": "0.1.2-rc.
|
|
21
|
+
"@radix-ui/react-compose-refs": "0.1.1-rc.3",
|
|
22
|
+
"@radix-ui/react-context": "0.1.2-rc.3",
|
|
23
|
+
"@radix-ui/react-direction": "0.1.0-rc.6",
|
|
24
|
+
"@radix-ui/react-label": "0.1.6-rc.3",
|
|
25
|
+
"@radix-ui/react-presence": "0.1.3-rc.3",
|
|
26
|
+
"@radix-ui/react-primitive": "0.1.5-rc.3",
|
|
27
|
+
"@radix-ui/react-roving-focus": "0.1.6-rc.6",
|
|
28
|
+
"@radix-ui/react-use-controllable-state": "0.1.1-rc.3",
|
|
29
|
+
"@radix-ui/react-use-previous": "0.1.2-rc.3",
|
|
30
|
+
"@radix-ui/react-use-size": "0.1.2-rc.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^16.8 || ^17.0 || ^18.0"
|