@radix-ui/react-radio-group 0.1.6-rc.5 → 0.1.6-rc.50

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.
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;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;A;A;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"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"index.d.ts.map"}
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,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,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 {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n} from './RadioGroup';\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps } from './RadioGroup';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,296 @@
1
- var e,r=require("@radix-ui/react-presence").Presence,t=require("@radix-ui/react-use-previous").usePrevious,o=require("@radix-ui/react-use-size").useSize,a=require("@radix-ui/react-direction").useDirection,n=require("@radix-ui/react-use-controllable-state").useControllableState,i=require("@radix-ui/react-roving-focus"),c=v({},i),u=i.createRovingFocusGroupScope,d=require("@radix-ui/react-primitive").Primitive,s=require("@radix-ui/react-context").createContextScope,l=require("@radix-ui/react-compose-refs").useComposedRefs,p=require("@radix-ui/react-label").useLabelContext,f=require("@radix-ui/primitive").composeEventHandlers,b=v({},require("react")),m=(e=require("@babel/runtime/helpers/extends"))&&e.__esModule?e.default:e;function v(e,r){return Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e}const[R,h]=s("Radio"),[k,E]=R("Radio"),x=/*#__PURE__*/b.forwardRef(((e,r)=>{const{__scopeRadio:t,"aria-labelledby":o,name:a,checked:n=!1,required:i,disabled:c,value:u="on",onCheck:s,...v}=e,[R,h]=b.useState(null),E=l(r,(e=>h(e))),x=p(R),y=o||x,C=b.useRef(!1),_=!R||Boolean(R.closest("form"));/*#__PURE__*/return b.createElement(k,{scope:t,checked:n,disabled:c},/*#__PURE__*/b.createElement(d.button,m({type:"button",role:"radio","aria-checked":n,"aria-labelledby":y,"data-state":w(n),"data-disabled":c?"":void 0,disabled:c,value:u},v,{ref:E,onClick:f(e.onClick,(e=>{n||null==s||s(),_&&(C.current=e.isPropagationStopped(),C.current||e.stopPropagation())}))})),_&&/*#__PURE__*/b.createElement(q,{control:R,bubbles:!C.current,name:a,value:u,checked:n,required:i,disabled:c,style:{transform:"translateX(-100%)"}}))})),y=/*#__PURE__*/b.forwardRef(((e,t)=>{const{__scopeRadio:o,forceMount:a,...n}=e,i=E("RadioIndicator",o);/*#__PURE__*/return b.createElement(r,{present:a||i.checked},/*#__PURE__*/b.createElement(d.span,m({"data-state":w(i.checked),"data-disabled":i.disabled?"":void 0},n,{ref:t})))})),q=e=>{const{control:r,checked:a,bubbles:n=!0,...i}=e,c=b.useRef(null),u=t(a),d=o(r);return b.useEffect((()=>{const e=c.current,r=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(r,"checked").set;if(u!==a&&t){const r=new Event("click",{bubbles:n});t.call(e,a),e.dispatchEvent(r)}}),[u,a,n]),/*#__PURE__*/b.createElement("input",m({type:"radio","aria-hidden":!0,defaultChecked:a},i,{tabIndex:-1,ref:c,style:{...e.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function w(e){return e?"checked":"unchecked"}const C=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],[_,g]=s("RadioGroup",[u,h]);exports.createRadioGroupScope=g;const G=u(),I=h(),[P,L]=_("RadioGroup"),S=/*#__PURE__*/b.forwardRef(((e,r)=>{const{__scopeRadioGroup:t,name:o,"aria-labelledby":i,defaultValue:u,value:s,required:l=!1,orientation:f,dir:v,loop:R=!0,onValueChange:h,...k}=e,E=p(),x=i||E,y=G(t),q=a(v),[w,C]=n({prop:s,defaultProp:u,onChange:h});/*#__PURE__*/return b.createElement(P,{scope:t,name:o,required:l,value:w,onValueChange:C},/*#__PURE__*/b.createElement(c.Root,m({asChild:!0},y,{orientation:f,dir:q,loop:R}),/*#__PURE__*/b.createElement(d.div,m({role:"radiogroup","aria-orientation":f,"aria-labelledby":x,dir:q},k,{ref:r}))))}));exports.RadioGroup=S;const D=/*#__PURE__*/b.forwardRef(((e,r)=>{const{__scopeRadioGroup:t,disabled:o,...a}=e,n=L("RadioGroupItem",t),i=G(t),u=I(t),d=b.useRef(null),s=l(r,d),p=n.value===a.value,v=b.useRef(!1);return b.useEffect((()=>{const e=e=>{C.includes(e.key)&&(v.current=!0)},r=()=>v.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",r)}}),[]),/*#__PURE__*/b.createElement(c.Item,m({asChild:!0},i,{focusable:!o,active:p}),/*#__PURE__*/b.createElement(x,m({disabled:o,required:n.required,checked:p},u,a,{name:n.name,ref:s,onCheck:()=>n.onValueChange(a.value),onKeyDown:f((e=>{"Enter"===e.key&&e.preventDefault()})),onFocus:f(a.onFocus,(()=>{var e;v.current&&(null===(e=d.current)||void 0===e||e.click())}))})))}));exports.RadioGroupItem=D;const A=/*#__PURE__*/b.forwardRef(((e,r)=>{const{__scopeRadioGroup:t,...o}=e,a=I(t);/*#__PURE__*/return b.createElement(y,m({},a,o,{ref:r}))}));exports.RadioGroupIndicator=A;const M=S;exports.Root=M;const O=D;exports.Item=O;const V=A;exports.Indicator=V;
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$export(e, n, v, s) {
16
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
17
+ }
18
+ function $parcel$interopDefault(a) {
19
+ return a && a.__esModule ? a.default : a;
20
+ }
21
+
22
+ $parcel$export(module.exports, "createRadioGroupScope", () => $240483839a8a76fd$export$c547093f11b76da2);
23
+ $parcel$export(module.exports, "RadioGroup", () => $240483839a8a76fd$export$a98f0dcb43a68a25);
24
+ $parcel$export(module.exports, "RadioGroupItem", () => $240483839a8a76fd$export$9f866c100ef519e4);
25
+ $parcel$export(module.exports, "RadioGroupIndicator", () => $240483839a8a76fd$export$5fb54c671a65c88);
26
+ $parcel$export(module.exports, "Root", () => $240483839a8a76fd$export$be92b6f5f03c0fe9);
27
+ $parcel$export(module.exports, "Item", () => $240483839a8a76fd$export$6d08773d2e66f8f2);
28
+ $parcel$export(module.exports, "Indicator", () => $240483839a8a76fd$export$adb584737d712b70);
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ /* -------------------------------------------------------------------------------------------------
51
+ * Radio
52
+ * -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$RADIO_NAME = 'Radio';
53
+ const [$ce74a64c62457efb$var$createRadioContext, $ce74a64c62457efb$export$67d2296460f1b002] = $9yYIj$radixuireactcontext.createContextScope($ce74a64c62457efb$var$RADIO_NAME);
54
+ const [$ce74a64c62457efb$var$RadioProvider, $ce74a64c62457efb$var$useRadioContext] = $ce74a64c62457efb$var$createRadioContext($ce74a64c62457efb$var$RADIO_NAME);
55
+ const $ce74a64c62457efb$export$d7b12c4107be0d61 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
56
+ const { __scopeRadio: __scopeRadio , 'aria-labelledby': ariaLabelledby , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
57
+ const [button, setButton] = $9yYIj$react.useState(null);
58
+ const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setButton(node)
59
+ );
60
+ const labelId = $9yYIj$radixuireactlabel.useLabelContext(button);
61
+ const labelledBy = ariaLabelledby || labelId;
62
+ const hasConsumerStoppedPropagationRef = $9yYIj$react.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
63
+ const isFormControl = button ? Boolean(button.closest('form')) : true;
64
+ return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$RadioProvider, {
65
+ scope: __scopeRadio,
66
+ checked: checked,
67
+ disabled: disabled
68
+ }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
69
+ type: "button",
70
+ role: "radio",
71
+ "aria-checked": checked,
72
+ "aria-labelledby": labelledBy,
73
+ "data-state": $ce74a64c62457efb$var$getState(checked),
74
+ "data-disabled": disabled ? '' : undefined,
75
+ disabled: disabled,
76
+ value: value
77
+ }, radioProps, {
78
+ ref: composedRefs,
79
+ onClick: $9yYIj$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
80
+ // radios cannot be unchecked so we only communicate a checked state
81
+ if (!checked) onCheck === null || onCheck === void 0 || onCheck();
82
+ if (isFormControl) {
83
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
84
+ // one click event (from the input). We propagate changes from an input so that native
85
+ // form validation works and form events reflect radio updates.
86
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
87
+ }
88
+ })
89
+ })), isFormControl && /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$BubbleInput, {
90
+ control: button,
91
+ bubbles: !hasConsumerStoppedPropagationRef.current,
92
+ name: name,
93
+ value: value,
94
+ checked: checked,
95
+ required: required,
96
+ disabled: disabled // We transform because the input is absolutely positioned but we have
97
+ ,
98
+ style: {
99
+ transform: 'translateX(-100%)'
100
+ }
101
+ }));
102
+ });
103
+ /*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d7b12c4107be0d61, {
104
+ displayName: $ce74a64c62457efb$var$RADIO_NAME
105
+ });
106
+ /* -------------------------------------------------------------------------------------------------
107
+ * RadioIndicator
108
+ * -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$INDICATOR_NAME = 'RadioIndicator';
109
+ const $ce74a64c62457efb$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
110
+ const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
111
+ const context = $ce74a64c62457efb$var$useRadioContext($ce74a64c62457efb$var$INDICATOR_NAME, __scopeRadio);
112
+ return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactpresence.Presence, {
113
+ present: forceMount || context.checked
114
+ }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
115
+ "data-state": $ce74a64c62457efb$var$getState(context.checked),
116
+ "data-disabled": context.disabled ? '' : undefined
117
+ }, indicatorProps, {
118
+ ref: forwardedRef
119
+ })));
120
+ });
121
+ /*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d35a9ffa9a04f9e7, {
122
+ displayName: $ce74a64c62457efb$var$INDICATOR_NAME
123
+ });
124
+ /* ---------------------------------------------------------------------------------------------- */ const $ce74a64c62457efb$var$BubbleInput = (props)=>{
125
+ const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
126
+ const ref = $9yYIj$react.useRef(null);
127
+ const prevChecked = $9yYIj$radixuireactuseprevious.usePrevious(checked);
128
+ const controlSize = $9yYIj$radixuireactusesize.useSize(control); // Bubble checked change to parents (e.g form change event)
129
+ $9yYIj$react.useEffect(()=>{
130
+ const input = ref.current;
131
+ const inputProto = window.HTMLInputElement.prototype;
132
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
133
+ const setChecked = descriptor.set;
134
+ if (prevChecked !== checked && setChecked) {
135
+ const event = new Event('click', {
136
+ bubbles: bubbles
137
+ });
138
+ setChecked.call(input, checked);
139
+ input.dispatchEvent(event);
140
+ }
141
+ }, [
142
+ prevChecked,
143
+ checked,
144
+ bubbles
145
+ ]);
146
+ return /*#__PURE__*/ $9yYIj$react.createElement("input", ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
147
+ type: "radio",
148
+ "aria-hidden": true,
149
+ defaultChecked: checked
150
+ }, inputProps, {
151
+ tabIndex: -1,
152
+ ref: ref,
153
+ style: {
154
+ ...props.style,
155
+ ...controlSize,
156
+ position: 'absolute',
157
+ pointerEvents: 'none',
158
+ opacity: 0,
159
+ margin: 0
160
+ }
161
+ }));
162
+ };
163
+ function $ce74a64c62457efb$var$getState(checked) {
164
+ return checked ? 'checked' : 'unchecked';
165
+ }
166
+
167
+
168
+ const $240483839a8a76fd$var$ARROW_KEYS = [
169
+ 'ArrowUp',
170
+ 'ArrowDown',
171
+ 'ArrowLeft',
172
+ 'ArrowRight'
173
+ ];
174
+ /* -------------------------------------------------------------------------------------------------
175
+ * RadioGroup
176
+ * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$RADIO_GROUP_NAME = 'RadioGroup';
177
+ const [$240483839a8a76fd$var$createRadioGroupContet, $240483839a8a76fd$export$c547093f11b76da2] = $9yYIj$radixuireactcontext.createContextScope($240483839a8a76fd$var$RADIO_GROUP_NAME, [
178
+ $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope,
179
+ $ce74a64c62457efb$export$67d2296460f1b002
180
+ ]);
181
+ const $240483839a8a76fd$var$useRovingFocusGroupScope = $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope();
182
+ const $240483839a8a76fd$var$useRadioScope = $ce74a64c62457efb$export$67d2296460f1b002();
183
+ const [$240483839a8a76fd$var$RadioGroupProvider, $240483839a8a76fd$var$useRadioGroupContext] = $240483839a8a76fd$var$createRadioGroupContet($240483839a8a76fd$var$RADIO_GROUP_NAME);
184
+ const $240483839a8a76fd$export$a98f0dcb43a68a25 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
185
+ 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;
186
+ const labelId = $9yYIj$radixuireactlabel.useLabelContext();
187
+ const labelledBy = ariaLabelledby || labelId;
188
+ const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
189
+ const direction = $9yYIj$radixuireactdirection.useDirection(dir);
190
+ const [value, setValue] = $9yYIj$radixuireactusecontrollablestate.useControllableState({
191
+ prop: valueProp,
192
+ defaultProp: defaultValue,
193
+ onChange: onValueChange
194
+ });
195
+ return /*#__PURE__*/ $9yYIj$react.createElement($240483839a8a76fd$var$RadioGroupProvider, {
196
+ scope: __scopeRadioGroup,
197
+ name: name,
198
+ required: required,
199
+ value: value,
200
+ onValueChange: setValue
201
+ }, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Root, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
202
+ asChild: true
203
+ }, rovingFocusGroupScope, {
204
+ orientation: orientation,
205
+ dir: direction,
206
+ loop: loop
207
+ }), /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
208
+ role: "radiogroup",
209
+ "aria-required": required,
210
+ "aria-orientation": orientation,
211
+ "aria-labelledby": labelledBy,
212
+ dir: direction
213
+ }, groupProps, {
214
+ ref: forwardedRef
215
+ }))));
216
+ });
217
+ /*#__PURE__*/ Object.assign($240483839a8a76fd$export$a98f0dcb43a68a25, {
218
+ displayName: $240483839a8a76fd$var$RADIO_GROUP_NAME
219
+ });
220
+ /* -------------------------------------------------------------------------------------------------
221
+ * RadioGroupItem
222
+ * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$ITEM_NAME = 'RadioGroupItem';
223
+ const $240483839a8a76fd$export$9f866c100ef519e4 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
224
+ const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
225
+ const context = $240483839a8a76fd$var$useRadioGroupContext($240483839a8a76fd$var$ITEM_NAME, __scopeRadioGroup);
226
+ const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
227
+ const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
228
+ const ref = $9yYIj$react.useRef(null);
229
+ const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
230
+ const checked = context.value === itemProps.value;
231
+ const isArrowKeyPressedRef = $9yYIj$react.useRef(false);
232
+ $9yYIj$react.useEffect(()=>{
233
+ const handleKeyDown = (event)=>{
234
+ if ($240483839a8a76fd$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
235
+ };
236
+ const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
237
+ ;
238
+ document.addEventListener('keydown', handleKeyDown);
239
+ document.addEventListener('keyup', handleKeyUp);
240
+ return ()=>{
241
+ document.removeEventListener('keydown', handleKeyDown);
242
+ document.removeEventListener('keyup', handleKeyUp);
243
+ };
244
+ }, []);
245
+ return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Item, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
246
+ asChild: true
247
+ }, rovingFocusGroupScope, {
248
+ focusable: !disabled,
249
+ active: checked
250
+ }), /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d7b12c4107be0d61, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
251
+ disabled: disabled,
252
+ required: context.required,
253
+ checked: checked
254
+ }, radioScope, itemProps, {
255
+ name: context.name,
256
+ ref: composedRefs,
257
+ onCheck: ()=>context.onValueChange(itemProps.value)
258
+ ,
259
+ onKeyDown: $9yYIj$radixuiprimitive.composeEventHandlers((event)=>{
260
+ // According to WAI ARIA, radio groups don't activate items on enter keypress
261
+ if (event.key === 'Enter') event.preventDefault();
262
+ }),
263
+ onFocus: $9yYIj$radixuiprimitive.composeEventHandlers(itemProps.onFocus, ()=>{
264
+ var _ref$current;
265
+ /**
266
+ * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
267
+ * and we need to "check" it in that case. We click it to "check" it (instead
268
+ * of updating `context.value`) so that the radio change event fires.
269
+ */ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
270
+ })
271
+ })));
272
+ });
273
+ /*#__PURE__*/ Object.assign($240483839a8a76fd$export$9f866c100ef519e4, {
274
+ displayName: $240483839a8a76fd$var$ITEM_NAME
275
+ });
276
+ /* -------------------------------------------------------------------------------------------------
277
+ * RadioGroupIndicator
278
+ * -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$INDICATOR_NAME = 'RadioGroupIndicator';
279
+ const $240483839a8a76fd$export$5fb54c671a65c88 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
280
+ const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
281
+ const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
282
+ return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d35a9ffa9a04f9e7, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({}, radioScope, indicatorProps, {
283
+ ref: forwardedRef
284
+ }));
285
+ });
286
+ /*#__PURE__*/ Object.assign($240483839a8a76fd$export$5fb54c671a65c88, {
287
+ displayName: $240483839a8a76fd$var$INDICATOR_NAME
288
+ });
289
+ /* ---------------------------------------------------------------------------------------------- */ const $240483839a8a76fd$export$be92b6f5f03c0fe9 = $240483839a8a76fd$export$a98f0dcb43a68a25;
290
+ const $240483839a8a76fd$export$6d08773d2e66f8f2 = $240483839a8a76fd$export$9f866c100ef519e4;
291
+ const $240483839a8a76fd$export$adb584737d712b70 = $240483839a8a76fd$export$5fb54c671a65c88;
292
+
293
+
294
+
295
+
2
296
  //# 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,EACA,kBAAmBC,EAFfC,KAGJA,EAHIC,QAIJA,GAAU,EAJNC,SAKJA,EALIC,SAMJA,EANIC,MAOJA,EAAQ,KAPJC,QAQJA,KACGC,GACDV,GACGW,EAAQC,GAAad,EAAMe,SAAmC,MAC/DC,EAAeC,EAAgBd,GAAee,GAASJ,EAAUI,KACjEC,EAAUC,EAAgBP,GAC1BQ,EAAahB,GAAkBc,EAC/BG,EAAmCtB,EAAMuB,QAAO,GAEhDC,GAAgBX,GAASY,QAAQZ,EAAOa,QAAQ,sBAEtD,OACEC,EAAAC,cAACC,EAAD,CAAeC,MAAO1B,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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,EAAqB5D,yCAArB,CAAA,GAAyCR,6CAAkB,CAACmE,gCAAD,CAAjE,AAAA;AAGA,MAAM,CAACE,mCAAD,EAAgBC,qCAAhB,CAAA,GAAmC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A,EAAA;IAAA,WAAA,EAAA,oCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMzB,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAS,GAAGH,wCAAlB,AAAA;;ADjNA","sources":["packages/react/radio-group/src/index.ts","packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/Radio.tsx"],"sourcesContent":["export {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n} from './RadioGroup';\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps } 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-required={required}\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":["createRadioGroupScope","RadioGroup","RadioGroupItem","RadioGroupIndicator","Root","Item","Indicator","React","composeEventHandlers","useLabelContext","useComposedRefs","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","useControllableState","useDirection","Radio","RadioIndicator","createRadioScope","ARROW_KEYS","RADIO_GROUP_NAME","createRadioGroupContet","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","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","disabled","itemProps","context","radioScope","ref","useRef","composedRefs","checked","isArrowKeyPressedRef","useEffect","handleKeyDown","event","includes","key","current","handleKeyUp","document","addEventListener","removeEventListener","preventDefault","onFocus","click","INDICATOR_NAME","indicatorProps","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"}
@@ -1,2 +1,283 @@
1
- import{Presence as e}from"@radix-ui/react-presence";import{usePrevious as r}from"@radix-ui/react-use-previous";import{useSize as o}from"@radix-ui/react-use-size";import{useDirection as t}from"@radix-ui/react-direction";import{useControllableState as a}from"@radix-ui/react-use-controllable-state";import*as n from"@radix-ui/react-roving-focus";import{createRovingFocusGroupScope as i}from"@radix-ui/react-roving-focus";import{Primitive as c}from"@radix-ui/react-primitive";import{createContextScope as d}from"@radix-ui/react-context";import{useComposedRefs as u}from"@radix-ui/react-compose-refs";import{useLabelContext as l}from"@radix-ui/react-label";import{composeEventHandlers as s}from"@radix-ui/primitive";import*as p from"react";import m from"@babel/runtime/helpers/esm/extends";const[f,b]=d("Radio"),[v,R]=f("Radio"),h=/*#__PURE__*/p.forwardRef(((e,r)=>{const{__scopeRadio:o,"aria-labelledby":t,name:a,checked:n=!1,required:i,disabled:d,value:f="on",onCheck:b,...R}=e,[h,k]=p.useState(null),y=u(r,(e=>k(e))),w=l(h),g=t||w,G=p.useRef(!1),C=!h||Boolean(h.closest("form"));/*#__PURE__*/return p.createElement(v,{scope:o,checked:n,disabled:d},/*#__PURE__*/p.createElement(c.button,m({type:"button",role:"radio","aria-checked":n,"aria-labelledby":g,"data-state":x(n),"data-disabled":d?"":void 0,disabled:d,value:f},R,{ref:y,onClick:s(e.onClick,(e=>{n||null==b||b(),C&&(G.current=e.isPropagationStopped(),G.current||e.stopPropagation())}))})),C&&/*#__PURE__*/p.createElement(E,{control:h,bubbles:!G.current,name:a,value:f,checked:n,required:i,disabled:d,style:{transform:"translateX(-100%)"}}))})),k=/*#__PURE__*/p.forwardRef(((r,o)=>{const{__scopeRadio:t,forceMount:a,...n}=r,i=R("RadioIndicator",t);/*#__PURE__*/return p.createElement(e,{present:a||i.checked},/*#__PURE__*/p.createElement(c.span,m({"data-state":x(i.checked),"data-disabled":i.disabled?"":void 0},n,{ref:o})))})),E=e=>{const{control:t,checked:a,bubbles:n=!0,...i}=e,c=p.useRef(null),d=r(a),u=o(t);return p.useEffect((()=>{const e=c.current,r=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"checked").set;if(d!==a&&o){const r=new Event("click",{bubbles:n});o.call(e,a),e.dispatchEvent(r)}}),[d,a,n]),/*#__PURE__*/p.createElement("input",m({type:"radio","aria-hidden":!0,defaultChecked:a},i,{tabIndex:-1,ref:c,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function x(e){return e?"checked":"unchecked"}const y=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],[w,g]=d("RadioGroup",[i,b]);export{g as createRadioGroupScope};const G=i(),C=b(),[I,_]=w("RadioGroup");export const RadioGroup=/*#__PURE__*/p.forwardRef(((e,r)=>{const{__scopeRadioGroup:o,name:i,"aria-labelledby":d,defaultValue:u,value:s,required:f=!1,orientation:b,dir:v,loop:R=!0,onValueChange:h,...k}=e,E=l(),x=d||E,y=G(o),w=t(v),[g,C]=a({prop:s,defaultProp:u,onChange:h});/*#__PURE__*/return p.createElement(I,{scope:o,name:i,required:f,value:g,onValueChange:C},/*#__PURE__*/p.createElement(n.Root,m({asChild:!0},y,{orientation:b,dir:w,loop:R}),/*#__PURE__*/p.createElement(c.div,m({role:"radiogroup","aria-orientation":b,"aria-labelledby":x,dir:w},k,{ref:r}))))}));/*#__PURE__*/export const RadioGroupItem=/*#__PURE__*/p.forwardRef(((e,r)=>{const{__scopeRadioGroup:o,disabled:t,...a}=e,i=_("RadioGroupItem",o),c=G(o),d=C(o),l=p.useRef(null),f=u(r,l),b=i.value===a.value,v=p.useRef(!1);return p.useEffect((()=>{const e=e=>{y.includes(e.key)&&(v.current=!0)},r=()=>v.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",r)}}),[]),/*#__PURE__*/p.createElement(n.Item,m({asChild:!0},c,{focusable:!t,active:b}),/*#__PURE__*/p.createElement(h,m({disabled:t,required:i.required,checked:b},d,a,{name:i.name,ref:f,onCheck:()=>i.onValueChange(a.value),onKeyDown:s((e=>{"Enter"===e.key&&e.preventDefault()})),onFocus:s(a.onFocus,(()=>{var e;v.current&&(null===(e=l.current)||void 0===e||e.click())}))})))}));/*#__PURE__*/export const RadioGroupIndicator=/*#__PURE__*/p.forwardRef(((e,r)=>{const{__scopeRadioGroup:o,...t}=e,a=C(o);/*#__PURE__*/return p.createElement(k,m({},a,t,{ref:r}))}));/*#__PURE__*/export const Root=RadioGroup;export const Item=RadioGroupItem;export const Indicator=RadioGroupIndicator;
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
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ /* -------------------------------------------------------------------------------------------------
37
+ * Radio
38
+ * -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$RADIO_NAME = 'Radio';
39
+ const [$ce77a8961b41be9e$var$createRadioContext, $ce77a8961b41be9e$export$67d2296460f1b002] = $8Wolv$createContextScope($ce77a8961b41be9e$var$RADIO_NAME);
40
+ const [$ce77a8961b41be9e$var$RadioProvider, $ce77a8961b41be9e$var$useRadioContext] = $ce77a8961b41be9e$var$createRadioContext($ce77a8961b41be9e$var$RADIO_NAME);
41
+ const $ce77a8961b41be9e$export$d7b12c4107be0d61 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
42
+ const { __scopeRadio: __scopeRadio , 'aria-labelledby': ariaLabelledby , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
43
+ const [button, setButton] = $8Wolv$useState(null);
44
+ const composedRefs = $8Wolv$useComposedRefs(forwardedRef, (node)=>setButton(node)
45
+ );
46
+ const labelId = $8Wolv$useLabelContext(button);
47
+ const labelledBy = ariaLabelledby || labelId;
48
+ const hasConsumerStoppedPropagationRef = $8Wolv$useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
49
+ const isFormControl = button ? Boolean(button.closest('form')) : true;
50
+ return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$RadioProvider, {
51
+ scope: __scopeRadio,
52
+ checked: checked,
53
+ disabled: disabled
54
+ }, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.button, $8Wolv$babelruntimehelpersesmextends({
55
+ type: "button",
56
+ role: "radio",
57
+ "aria-checked": checked,
58
+ "aria-labelledby": labelledBy,
59
+ "data-state": $ce77a8961b41be9e$var$getState(checked),
60
+ "data-disabled": disabled ? '' : undefined,
61
+ disabled: disabled,
62
+ value: value
63
+ }, radioProps, {
64
+ ref: composedRefs,
65
+ onClick: $8Wolv$composeEventHandlers(props.onClick, (event)=>{
66
+ // radios cannot be unchecked so we only communicate a checked state
67
+ if (!checked) onCheck === null || onCheck === void 0 || onCheck();
68
+ if (isFormControl) {
69
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
70
+ // one click event (from the input). We propagate changes from an input so that native
71
+ // form validation works and form events reflect radio updates.
72
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
73
+ }
74
+ })
75
+ })), isFormControl && /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$BubbleInput, {
76
+ control: button,
77
+ bubbles: !hasConsumerStoppedPropagationRef.current,
78
+ name: name,
79
+ value: value,
80
+ checked: checked,
81
+ required: required,
82
+ disabled: disabled // We transform because the input is absolutely positioned but we have
83
+ ,
84
+ style: {
85
+ transform: 'translateX(-100%)'
86
+ }
87
+ }));
88
+ });
89
+ /*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d7b12c4107be0d61, {
90
+ displayName: $ce77a8961b41be9e$var$RADIO_NAME
91
+ });
92
+ /* -------------------------------------------------------------------------------------------------
93
+ * RadioIndicator
94
+ * -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$INDICATOR_NAME = 'RadioIndicator';
95
+ const $ce77a8961b41be9e$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
96
+ const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
97
+ const context = $ce77a8961b41be9e$var$useRadioContext($ce77a8961b41be9e$var$INDICATOR_NAME, __scopeRadio);
98
+ return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Presence, {
99
+ present: forceMount || context.checked
100
+ }, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.span, $8Wolv$babelruntimehelpersesmextends({
101
+ "data-state": $ce77a8961b41be9e$var$getState(context.checked),
102
+ "data-disabled": context.disabled ? '' : undefined
103
+ }, indicatorProps, {
104
+ ref: forwardedRef
105
+ })));
106
+ });
107
+ /*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, {
108
+ displayName: $ce77a8961b41be9e$var$INDICATOR_NAME
109
+ });
110
+ /* ---------------------------------------------------------------------------------------------- */ const $ce77a8961b41be9e$var$BubbleInput = (props)=>{
111
+ const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
112
+ const ref = $8Wolv$useRef(null);
113
+ const prevChecked = $8Wolv$usePrevious(checked);
114
+ const controlSize = $8Wolv$useSize(control); // Bubble checked change to parents (e.g form change event)
115
+ $8Wolv$useEffect(()=>{
116
+ const input = ref.current;
117
+ const inputProto = window.HTMLInputElement.prototype;
118
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
119
+ const setChecked = descriptor.set;
120
+ if (prevChecked !== checked && setChecked) {
121
+ const event = new Event('click', {
122
+ bubbles: bubbles
123
+ });
124
+ setChecked.call(input, checked);
125
+ input.dispatchEvent(event);
126
+ }
127
+ }, [
128
+ prevChecked,
129
+ checked,
130
+ bubbles
131
+ ]);
132
+ return /*#__PURE__*/ $8Wolv$createElement("input", $8Wolv$babelruntimehelpersesmextends({
133
+ type: "radio",
134
+ "aria-hidden": true,
135
+ defaultChecked: checked
136
+ }, inputProps, {
137
+ tabIndex: -1,
138
+ ref: ref,
139
+ style: {
140
+ ...props.style,
141
+ ...controlSize,
142
+ position: 'absolute',
143
+ pointerEvents: 'none',
144
+ opacity: 0,
145
+ margin: 0
146
+ }
147
+ }));
148
+ };
149
+ function $ce77a8961b41be9e$var$getState(checked) {
150
+ return checked ? 'checked' : 'unchecked';
151
+ }
152
+
153
+
154
+ const $f99a8c78507165f7$var$ARROW_KEYS = [
155
+ 'ArrowUp',
156
+ 'ArrowDown',
157
+ 'ArrowLeft',
158
+ 'ArrowRight'
159
+ ];
160
+ /* -------------------------------------------------------------------------------------------------
161
+ * RadioGroup
162
+ * -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$RADIO_GROUP_NAME = 'RadioGroup';
163
+ const [$f99a8c78507165f7$var$createRadioGroupContet, $f99a8c78507165f7$export$c547093f11b76da2] = $8Wolv$createContextScope($f99a8c78507165f7$var$RADIO_GROUP_NAME, [
164
+ $8Wolv$createRovingFocusGroupScope,
165
+ $ce77a8961b41be9e$export$67d2296460f1b002
166
+ ]);
167
+ const $f99a8c78507165f7$var$useRovingFocusGroupScope = $8Wolv$createRovingFocusGroupScope();
168
+ const $f99a8c78507165f7$var$useRadioScope = $ce77a8961b41be9e$export$67d2296460f1b002();
169
+ const [$f99a8c78507165f7$var$RadioGroupProvider, $f99a8c78507165f7$var$useRadioGroupContext] = $f99a8c78507165f7$var$createRadioGroupContet($f99a8c78507165f7$var$RADIO_GROUP_NAME);
170
+ const $f99a8c78507165f7$export$a98f0dcb43a68a25 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
171
+ 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;
172
+ const labelId = $8Wolv$useLabelContext();
173
+ const labelledBy = ariaLabelledby || labelId;
174
+ const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
175
+ const direction = $8Wolv$useDirection(dir);
176
+ const [value, setValue] = $8Wolv$useControllableState({
177
+ prop: valueProp,
178
+ defaultProp: defaultValue,
179
+ onChange: onValueChange
180
+ });
181
+ return /*#__PURE__*/ $8Wolv$createElement($f99a8c78507165f7$var$RadioGroupProvider, {
182
+ scope: __scopeRadioGroup,
183
+ name: name,
184
+ required: required,
185
+ value: value,
186
+ onValueChange: setValue
187
+ }, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Root, $8Wolv$babelruntimehelpersesmextends({
188
+ asChild: true
189
+ }, rovingFocusGroupScope, {
190
+ orientation: orientation,
191
+ dir: direction,
192
+ loop: loop
193
+ }), /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.div, $8Wolv$babelruntimehelpersesmextends({
194
+ role: "radiogroup",
195
+ "aria-required": required,
196
+ "aria-orientation": orientation,
197
+ "aria-labelledby": labelledBy,
198
+ dir: direction
199
+ }, groupProps, {
200
+ ref: forwardedRef
201
+ }))));
202
+ });
203
+ /*#__PURE__*/ Object.assign($f99a8c78507165f7$export$a98f0dcb43a68a25, {
204
+ displayName: $f99a8c78507165f7$var$RADIO_GROUP_NAME
205
+ });
206
+ /* -------------------------------------------------------------------------------------------------
207
+ * RadioGroupItem
208
+ * -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$ITEM_NAME = 'RadioGroupItem';
209
+ const $f99a8c78507165f7$export$9f866c100ef519e4 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
210
+ const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
211
+ const context = $f99a8c78507165f7$var$useRadioGroupContext($f99a8c78507165f7$var$ITEM_NAME, __scopeRadioGroup);
212
+ const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
213
+ const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
214
+ const ref = $8Wolv$useRef(null);
215
+ const composedRefs = $8Wolv$useComposedRefs(forwardedRef, ref);
216
+ const checked = context.value === itemProps.value;
217
+ const isArrowKeyPressedRef = $8Wolv$useRef(false);
218
+ $8Wolv$useEffect(()=>{
219
+ const handleKeyDown = (event)=>{
220
+ if ($f99a8c78507165f7$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
221
+ };
222
+ const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
223
+ ;
224
+ document.addEventListener('keydown', handleKeyDown);
225
+ document.addEventListener('keyup', handleKeyUp);
226
+ return ()=>{
227
+ document.removeEventListener('keydown', handleKeyDown);
228
+ document.removeEventListener('keyup', handleKeyUp);
229
+ };
230
+ }, []);
231
+ return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Item, $8Wolv$babelruntimehelpersesmextends({
232
+ asChild: true
233
+ }, rovingFocusGroupScope, {
234
+ focusable: !disabled,
235
+ active: checked
236
+ }), /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d7b12c4107be0d61, $8Wolv$babelruntimehelpersesmextends({
237
+ disabled: disabled,
238
+ required: context.required,
239
+ checked: checked
240
+ }, radioScope, itemProps, {
241
+ name: context.name,
242
+ ref: composedRefs,
243
+ onCheck: ()=>context.onValueChange(itemProps.value)
244
+ ,
245
+ onKeyDown: $8Wolv$composeEventHandlers((event)=>{
246
+ // According to WAI ARIA, radio groups don't activate items on enter keypress
247
+ if (event.key === 'Enter') event.preventDefault();
248
+ }),
249
+ onFocus: $8Wolv$composeEventHandlers(itemProps.onFocus, ()=>{
250
+ var _ref$current;
251
+ /**
252
+ * Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
253
+ * and we need to "check" it in that case. We click it to "check" it (instead
254
+ * of updating `context.value`) so that the radio change event fires.
255
+ */ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
256
+ })
257
+ })));
258
+ });
259
+ /*#__PURE__*/ Object.assign($f99a8c78507165f7$export$9f866c100ef519e4, {
260
+ displayName: $f99a8c78507165f7$var$ITEM_NAME
261
+ });
262
+ /* -------------------------------------------------------------------------------------------------
263
+ * RadioGroupIndicator
264
+ * -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$INDICATOR_NAME = 'RadioGroupIndicator';
265
+ const $f99a8c78507165f7$export$5fb54c671a65c88 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
266
+ const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
267
+ const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
268
+ return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, $8Wolv$babelruntimehelpersesmextends({}, radioScope, indicatorProps, {
269
+ ref: forwardedRef
270
+ }));
271
+ });
272
+ /*#__PURE__*/ Object.assign($f99a8c78507165f7$export$5fb54c671a65c88, {
273
+ displayName: $f99a8c78507165f7$var$INDICATOR_NAME
274
+ });
275
+ /* ---------------------------------------------------------------------------------------------- */ const $f99a8c78507165f7$export$be92b6f5f03c0fe9 = $f99a8c78507165f7$export$a98f0dcb43a68a25;
276
+ const $f99a8c78507165f7$export$6d08773d2e66f8f2 = $f99a8c78507165f7$export$9f866c100ef519e4;
277
+ const $f99a8c78507165f7$export$adb584737d712b70 = $f99a8c78507165f7$export$5fb54c671a65c88;
278
+
279
+
280
+
281
+
282
+ 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
283
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":"kxBAiBA,MAGOA,EAAoBC,GAAoBC,EAH5B,UAMZC,EAAeC,GAAmBJ,EANtB,SAgBbK,eAAQC,EAAMC,YAClB,CAACC,EAAgCC,KAC/B,MAAMC,aACJA,EACA,kBAAmBC,EAFfC,KAGJA,EAHIC,QAIJA,GAAU,EAJNC,SAKJA,EALIC,SAMJA,EANIC,MAOJA,EAAQ,KAPJC,QAQJA,KACGC,GACDV,GACGW,EAAQC,GAAad,EAAMe,SAAmC,M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,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,EAAqB5D,yCAArB,CAAA,GAAyCR,yBAAkB,CAACmE,gCAAD,CAAjE,AAAA;AAGA,MAAM,CAACE,mCAAD,EAAgBC,qCAAhB,CAAA,GAAmCF,wCAAkB,CAAoBD,gCAApB,CAA3D,AAAA;AAUA,MAAM7D,yCAAK,GAAA,aAAGV,CAAAA,iBAAA,CACZ,CAACqB,KAAD,EAAiCC,YAAjC,GAAkD;IAChD,MAAM,E,cACJqD,YADI,CAAA,EAEJ,iBAAA,EAAmBlD,cAFf,CAAA,E,MAGJD,IAHI,CAAA,WAIJ2B,OAAO,GAAG,KAJN,G,UAKJtB,QALI,CAAA,E,UAMJe,QANI,CAAA,SAOJjB,KAAK,GAAG,IAPJ,G,SAQJiD,OARI,CAAA,EASJ,GAAGC,UAAH,EATI,GAUFxD,KAVJ,AAAM;IAWN,MAAM,CAACyD,MAAD,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AAA,YAAA,GAAAV,GAAG,CAACU,OAAJ,CAAA,KAAA,IAAA,IAAA,YAAA,KAAA,KAAA,CAAA,IAAA,YAAA,CAAaO,KAAb,EAAlC,CAAA;SAN2B,CAO5B;KApBH,CAAA,CANF,CADF,CAOI;CAjCe,CAAvB,AAyDG;AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,+BAAA;CAAA,CAAA,CAAA;AAEA;;oGAEA,CAEA,MAAMC,oCAAc,GAAG,qBAAvB,AAAA;AAMA,MAAMtE,wCAAmB,GAAA,aAAGI,CAAAA,iBAAA,CAC1B,CAACqB,KAAD,EAA+CC,YAA/C,GAAgE;IAC9D,MAAM,E,mBAAEC,iBAAF,CAAA,EAAqB,GAAG4C,cAAH,EAArB,GAA2C9C,KAAjD,AAAM;IACN,MAAM0B,UAAU,GAAG9B,mCAAa,CAACM,iBAAD,CAAhC,AAAA;IACA,OAAA,aAAO,CAAA,oBAAA,CAAC,yCAAD,EAAA,oCAAA,CAAA,EAAA,EAAoBwB,UAApB,EAAoCoB,cAApC,EAAP;QAA2D,GAAG,EAAE7C,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,MAAMzB,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAI,GAAGH,yCAAb,AAAA;AACA,MAAMI,yCAAS,GAAGH,wCAAlB,AAAA;;ADjNA","sources":["packages/react/radio-group/src/index.ts","packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/Radio.tsx"],"sourcesContent":["export {\n createRadioGroupScope,\n //\n RadioGroup,\n RadioGroupItem,\n RadioGroupIndicator,\n //\n Root,\n Item,\n Indicator,\n} from './RadioGroup';\nexport type { RadioGroupProps, RadioGroupItemProps, RadioGroupIndicatorProps } 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-required={required}\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":["createRadioGroupScope","RadioGroup","RadioGroupItem","RadioGroupIndicator","Root","Item","Indicator","React","composeEventHandlers","useLabelContext","useComposedRefs","createContextScope","Primitive","RovingFocusGroup","createRovingFocusGroupScope","useControllableState","useDirection","Radio","RadioIndicator","createRadioScope","ARROW_KEYS","RADIO_GROUP_NAME","createRadioGroupContet","useRovingFocusGroupScope","useRadioScope","RadioGroupProvider","useRadioGroupContext","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","disabled","itemProps","context","radioScope","ref","useRef","composedRefs","checked","isArrowKeyPressedRef","useEffect","handleKeyDown","event","includes","key","current","handleKeyUp","document","addEventListener","removeEventListener","preventDefault","onFocus","click","INDICATOR_NAME","indicatorProps","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.5",
3
+ "version": "0.1.6-rc.50",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -17,20 +17,21 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.13.10",
20
- "@radix-ui/primitive": "0.1.0",
21
- "@radix-ui/react-compose-refs": "0.1.1-rc.2",
22
- "@radix-ui/react-context": "0.1.2-rc.2",
23
- "@radix-ui/react-direction": "0.1.0-rc.5",
24
- "@radix-ui/react-label": "0.1.6-rc.2",
25
- "@radix-ui/react-presence": "0.1.3-rc.2",
26
- "@radix-ui/react-primitive": "0.1.5-rc.2",
27
- "@radix-ui/react-roving-focus": "0.1.6-rc.5",
28
- "@radix-ui/react-use-controllable-state": "0.1.1-rc.2",
29
- "@radix-ui/react-use-previous": "0.1.2-rc.2",
30
- "@radix-ui/react-use-size": "0.1.2-rc.2"
20
+ "@radix-ui/primitive": "0.1.1-rc.7",
21
+ "@radix-ui/react-compose-refs": "0.1.1-rc.47",
22
+ "@radix-ui/react-context": "0.1.2-rc.47",
23
+ "@radix-ui/react-direction": "0.1.0-rc.50",
24
+ "@radix-ui/react-label": "0.1.6-rc.47",
25
+ "@radix-ui/react-presence": "0.1.3-rc.47",
26
+ "@radix-ui/react-primitive": "0.1.5-rc.47",
27
+ "@radix-ui/react-roving-focus": "0.1.6-rc.50",
28
+ "@radix-ui/react-use-controllable-state": "0.1.1-rc.47",
29
+ "@radix-ui/react-use-previous": "0.1.2-rc.47",
30
+ "@radix-ui/react-use-size": "0.1.2-rc.47"
31
31
  },
32
32
  "peerDependencies": {
33
- "react": "^16.8 || ^17.0 || ^18.0"
33
+ "react": "^16.8 || ^17.0 || ^18.0",
34
+ "react-dom": "^16.8 || ^17.0 || ^18.0"
34
35
  },
35
36
  "homepage": "https://radix-ui.com/primitives",
36
37
  "repository": {