node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# `react-radio-group`
## Installation
```sh
$ yarn add @radix-ui/react-radio-group
# or
$ npm install @radix-ui/react-radio-group
```
## Usage
View docs [here](https://radix-ui.com/primitives/docs/components/radio-group).

View File

@@ -0,0 +1,56 @@
import * as React from "react";
import * as Radix from "@radix-ui/react-primitive";
import { Primitive } from "@radix-ui/react-primitive";
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
interface RadioProps extends PrimitiveButtonProps {
checked?: boolean;
required?: boolean;
onCheck?(): void;
}
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLButtonElement>>;
type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
interface RadioIndicatorProps extends PrimitiveSpanProps {
/**
* Used to force mounting when more control is needed. Useful when
* controlling animation with React animation libraries.
*/
forceMount?: true;
}
declare const RadioIndicator: React.ForwardRefExoticComponent<RadioIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
export const createRadioGroupScope: import("@radix-ui/react-context").CreateScope;
type RadioGroupContextValue = {
name?: string;
required: boolean;
disabled: boolean;
value?: string;
onValueChange(value: string): void;
};
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
export interface RadioGroupProps extends PrimitiveDivProps {
name?: RadioGroupContextValue['name'];
required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];
disabled?: Radix.ComponentPropsWithoutRef<typeof Radio>['disabled'];
dir?: RovingFocusGroupProps['dir'];
orientation?: RovingFocusGroupProps['orientation'];
loop?: RovingFocusGroupProps['loop'];
defaultValue?: string;
value?: RadioGroupContextValue['value'];
onValueChange?: RadioGroupContextValue['onValueChange'];
}
export const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
type _RadioProps1 = Radix.ComponentPropsWithoutRef<typeof Radio>;
export interface RadioGroupItemProps extends Omit<_RadioProps1, 'onCheck' | 'name'> {
value: string;
}
export const RadioGroupItem: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
type _RadioIndicatorProps1 = Radix.ComponentPropsWithoutRef<typeof RadioIndicator>;
export interface RadioGroupIndicatorProps extends _RadioIndicatorProps1 {
}
export const RadioGroupIndicator: React.ForwardRefExoticComponent<RadioGroupIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
export const Root: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
export const Item: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
export const Indicator: React.ForwardRefExoticComponent<RadioGroupIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,56 @@
import * as React from "react";
import * as Radix from "@radix-ui/react-primitive";
import { Primitive } from "@radix-ui/react-primitive";
import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
interface RadioProps extends PrimitiveButtonProps {
checked?: boolean;
required?: boolean;
onCheck?(): void;
}
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLButtonElement>>;
type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
interface RadioIndicatorProps extends PrimitiveSpanProps {
/**
* Used to force mounting when more control is needed. Useful when
* controlling animation with React animation libraries.
*/
forceMount?: true;
}
declare const RadioIndicator: React.ForwardRefExoticComponent<RadioIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
export const createRadioGroupScope: import("@radix-ui/react-context").CreateScope;
type RadioGroupContextValue = {
name?: string;
required: boolean;
disabled: boolean;
value?: string;
onValueChange(value: string): void;
};
type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
export interface RadioGroupProps extends PrimitiveDivProps {
name?: RadioGroupContextValue['name'];
required?: Radix.ComponentPropsWithoutRef<typeof Radio>['required'];
disabled?: Radix.ComponentPropsWithoutRef<typeof Radio>['disabled'];
dir?: RovingFocusGroupProps['dir'];
orientation?: RovingFocusGroupProps['orientation'];
loop?: RovingFocusGroupProps['loop'];
defaultValue?: string;
value?: RadioGroupContextValue['value'];
onValueChange?: RadioGroupContextValue['onValueChange'];
}
export const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
type _RadioProps1 = Radix.ComponentPropsWithoutRef<typeof Radio>;
export interface RadioGroupItemProps extends Omit<_RadioProps1, 'onCheck' | 'name'> {
value: string;
}
export const RadioGroupItem: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
type _RadioIndicatorProps1 = Radix.ComponentPropsWithoutRef<typeof RadioIndicator>;
export interface RadioGroupIndicatorProps extends _RadioIndicatorProps1 {
}
export const RadioGroupIndicator: React.ForwardRefExoticComponent<RadioGroupIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
export const Root: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
export const Item: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
export const Indicator: React.ForwardRefExoticComponent<RadioGroupIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"mappings":";;;;AAyBA,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,2FA4DL,CAAC;AAWF,0BAA0B,MAAM,wBAAwB,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC;AAChF,6BAAqC,SAAQ,kBAAkB;IAC7D;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED,QAAA,MAAM,2GAeL,CAAC;ACzGF,OAAA,4FAGE,CAAC;AAIH,8BAA8B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,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,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,6GA2DL,CAAC;AAWF,6BAA2B,MAAM,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;AACjF,yCAAmC,SAAQ,qBAAmB;CAAG;AAEjE,OAAA,MAAM,qHAML,CAAC;AAMF,OAAA,MAAM,4FAAiB,CAAC;AACxB,OAAA,MAAM,mGAAqB,CAAC;AAC5B,OAAA,MAAM,2GAA+B,CAAC","sources":["packages/react/radio-group/src/packages/react/radio-group/src/Radio.tsx","packages/react/radio-group/src/packages/react/radio-group/src/RadioGroup.tsx","packages/react/radio-group/src/packages/react/radio-group/src/index.ts","packages/react/radio-group/src/index.ts"],"sourcesContent":[null,null,null,"export {\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"}

View File

@@ -0,0 +1,290 @@
var $9yYIj$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
var $9yYIj$react = require("react");
var $9yYIj$radixuiprimitive = require("@radix-ui/primitive");
var $9yYIj$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
var $9yYIj$radixuireactcontext = require("@radix-ui/react-context");
var $9yYIj$radixuireactprimitive = require("@radix-ui/react-primitive");
var $9yYIj$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
var $9yYIj$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
var $9yYIj$radixuireactdirection = require("@radix-ui/react-direction");
var $9yYIj$radixuireactusesize = require("@radix-ui/react-use-size");
var $9yYIj$radixuireactuseprevious = require("@radix-ui/react-use-previous");
var $9yYIj$radixuireactpresence = require("@radix-ui/react-presence");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "createRadioGroupScope", () => $240483839a8a76fd$export$c547093f11b76da2);
$parcel$export(module.exports, "RadioGroup", () => $240483839a8a76fd$export$a98f0dcb43a68a25);
$parcel$export(module.exports, "RadioGroupItem", () => $240483839a8a76fd$export$9f866c100ef519e4);
$parcel$export(module.exports, "RadioGroupIndicator", () => $240483839a8a76fd$export$5fb54c671a65c88);
$parcel$export(module.exports, "Root", () => $240483839a8a76fd$export$be92b6f5f03c0fe9);
$parcel$export(module.exports, "Item", () => $240483839a8a76fd$export$6d08773d2e66f8f2);
$parcel$export(module.exports, "Indicator", () => $240483839a8a76fd$export$adb584737d712b70);
/* -------------------------------------------------------------------------------------------------
* Radio
* -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$RADIO_NAME = 'Radio';
const [$ce74a64c62457efb$var$createRadioContext, $ce74a64c62457efb$export$67d2296460f1b002] = $9yYIj$radixuireactcontext.createContextScope($ce74a64c62457efb$var$RADIO_NAME);
const [$ce74a64c62457efb$var$RadioProvider, $ce74a64c62457efb$var$useRadioContext] = $ce74a64c62457efb$var$createRadioContext($ce74a64c62457efb$var$RADIO_NAME);
const $ce74a64c62457efb$export$d7b12c4107be0d61 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
const { __scopeRadio: __scopeRadio , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
const [button, setButton] = $9yYIj$react.useState(null);
const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setButton(node)
);
const hasConsumerStoppedPropagationRef = $9yYIj$react.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
const isFormControl = button ? Boolean(button.closest('form')) : true;
return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$RadioProvider, {
scope: __scopeRadio,
checked: checked,
disabled: disabled
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
type: "button",
role: "radio",
"aria-checked": checked,
"data-state": $ce74a64c62457efb$var$getState(checked),
"data-disabled": disabled ? '' : undefined,
disabled: disabled,
value: value
}, radioProps, {
ref: composedRefs,
onClick: $9yYIj$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
// radios cannot be unchecked so we only communicate a checked state
if (!checked) onCheck === null || onCheck === void 0 || onCheck();
if (isFormControl) {
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
// one click event (from the input). We propagate changes from an input so that native
// form validation works and form events reflect radio updates.
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
}
})
})), isFormControl && /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$var$BubbleInput, {
control: button,
bubbles: !hasConsumerStoppedPropagationRef.current,
name: name,
value: value,
checked: checked,
required: required,
disabled: disabled // We transform because the input is absolutely positioned but we have
,
style: {
transform: 'translateX(-100%)'
}
}));
});
/*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d7b12c4107be0d61, {
displayName: $ce74a64c62457efb$var$RADIO_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioIndicator
* -----------------------------------------------------------------------------------------------*/ const $ce74a64c62457efb$var$INDICATOR_NAME = 'RadioIndicator';
const $ce74a64c62457efb$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
const context = $ce74a64c62457efb$var$useRadioContext($ce74a64c62457efb$var$INDICATOR_NAME, __scopeRadio);
return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactpresence.Presence, {
present: forceMount || context.checked
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
"data-state": $ce74a64c62457efb$var$getState(context.checked),
"data-disabled": context.disabled ? '' : undefined
}, indicatorProps, {
ref: forwardedRef
})));
});
/*#__PURE__*/ Object.assign($ce74a64c62457efb$export$d35a9ffa9a04f9e7, {
displayName: $ce74a64c62457efb$var$INDICATOR_NAME
});
/* ---------------------------------------------------------------------------------------------- */ const $ce74a64c62457efb$var$BubbleInput = (props)=>{
const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
const ref = $9yYIj$react.useRef(null);
const prevChecked = $9yYIj$radixuireactuseprevious.usePrevious(checked);
const controlSize = $9yYIj$radixuireactusesize.useSize(control); // Bubble checked change to parents (e.g form change event)
$9yYIj$react.useEffect(()=>{
const input = ref.current;
const inputProto = window.HTMLInputElement.prototype;
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
const setChecked = descriptor.set;
if (prevChecked !== checked && setChecked) {
const event = new Event('click', {
bubbles: bubbles
});
setChecked.call(input, checked);
input.dispatchEvent(event);
}
}, [
prevChecked,
checked,
bubbles
]);
return /*#__PURE__*/ $9yYIj$react.createElement("input", ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
type: "radio",
"aria-hidden": true,
defaultChecked: checked
}, inputProps, {
tabIndex: -1,
ref: ref,
style: {
...props.style,
...controlSize,
position: 'absolute',
pointerEvents: 'none',
opacity: 0,
margin: 0
}
}));
};
function $ce74a64c62457efb$var$getState(checked) {
return checked ? 'checked' : 'unchecked';
}
const $240483839a8a76fd$var$ARROW_KEYS = [
'ArrowUp',
'ArrowDown',
'ArrowLeft',
'ArrowRight'
];
/* -------------------------------------------------------------------------------------------------
* RadioGroup
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$RADIO_GROUP_NAME = 'RadioGroup';
const [$240483839a8a76fd$var$createRadioGroupContext, $240483839a8a76fd$export$c547093f11b76da2] = $9yYIj$radixuireactcontext.createContextScope($240483839a8a76fd$var$RADIO_GROUP_NAME, [
$9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope,
$ce74a64c62457efb$export$67d2296460f1b002
]);
const $240483839a8a76fd$var$useRovingFocusGroupScope = $9yYIj$radixuireactrovingfocus.createRovingFocusGroupScope();
const $240483839a8a76fd$var$useRadioScope = $ce74a64c62457efb$export$67d2296460f1b002();
const [$240483839a8a76fd$var$RadioGroupProvider, $240483839a8a76fd$var$useRadioGroupContext] = $240483839a8a76fd$var$createRadioGroupContext($240483839a8a76fd$var$RADIO_GROUP_NAME);
const $240483839a8a76fd$export$a98f0dcb43a68a25 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , name: name , defaultValue: defaultValue , value: valueProp , required: required = false , disabled: disabled = false , orientation: orientation , dir: dir , loop: loop = true , onValueChange: onValueChange , ...groupProps } = props;
const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
const direction = $9yYIj$radixuireactdirection.useDirection(dir);
const [value, setValue] = $9yYIj$radixuireactusecontrollablestate.useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
return /*#__PURE__*/ $9yYIj$react.createElement($240483839a8a76fd$var$RadioGroupProvider, {
scope: __scopeRadioGroup,
name: name,
required: required,
disabled: disabled,
value: value,
onValueChange: setValue
}, /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Root, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
asChild: true
}, rovingFocusGroupScope, {
orientation: orientation,
dir: direction,
loop: loop
}), /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
role: "radiogroup",
"aria-required": required,
"aria-orientation": orientation,
"data-disabled": disabled ? '' : undefined,
dir: direction
}, groupProps, {
ref: forwardedRef
}))));
});
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$a98f0dcb43a68a25, {
displayName: $240483839a8a76fd$var$RADIO_GROUP_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioGroupItem
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$ITEM_NAME = 'RadioGroupItem';
const $240483839a8a76fd$export$9f866c100ef519e4 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
const context = $240483839a8a76fd$var$useRadioGroupContext($240483839a8a76fd$var$ITEM_NAME, __scopeRadioGroup);
const isDisabled = context.disabled || disabled;
const rovingFocusGroupScope = $240483839a8a76fd$var$useRovingFocusGroupScope(__scopeRadioGroup);
const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
const ref = $9yYIj$react.useRef(null);
const composedRefs = $9yYIj$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
const checked = context.value === itemProps.value;
const isArrowKeyPressedRef = $9yYIj$react.useRef(false);
$9yYIj$react.useEffect(()=>{
const handleKeyDown = (event)=>{
if ($240483839a8a76fd$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
};
const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
;
document.addEventListener('keydown', handleKeyDown);
document.addEventListener('keyup', handleKeyUp);
return ()=>{
document.removeEventListener('keydown', handleKeyDown);
document.removeEventListener('keyup', handleKeyUp);
};
}, []);
return /*#__PURE__*/ $9yYIj$react.createElement($9yYIj$radixuireactrovingfocus.Item, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
asChild: true
}, rovingFocusGroupScope, {
focusable: !isDisabled,
active: checked
}), /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d7b12c4107be0d61, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({
disabled: isDisabled,
required: context.required,
checked: checked
}, radioScope, itemProps, {
name: context.name,
ref: composedRefs,
onCheck: ()=>context.onValueChange(itemProps.value)
,
onKeyDown: $9yYIj$radixuiprimitive.composeEventHandlers((event)=>{
// According to WAI ARIA, radio groups don't activate items on enter keypress
if (event.key === 'Enter') event.preventDefault();
}),
onFocus: $9yYIj$radixuiprimitive.composeEventHandlers(itemProps.onFocus, ()=>{
var _ref$current;
/**
* Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
* and we need to "check" it in that case. We click it to "check" it (instead
* of updating `context.value`) so that the radio change event fires.
*/ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
})
})));
});
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$9f866c100ef519e4, {
displayName: $240483839a8a76fd$var$ITEM_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioGroupIndicator
* -----------------------------------------------------------------------------------------------*/ const $240483839a8a76fd$var$INDICATOR_NAME = 'RadioGroupIndicator';
const $240483839a8a76fd$export$5fb54c671a65c88 = /*#__PURE__*/ $9yYIj$react.forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
const radioScope = $240483839a8a76fd$var$useRadioScope(__scopeRadioGroup);
return /*#__PURE__*/ $9yYIj$react.createElement($ce74a64c62457efb$export$d35a9ffa9a04f9e7, ($parcel$interopDefault($9yYIj$babelruntimehelpersextends))({}, radioScope, indicatorProps, {
ref: forwardedRef
}));
});
/*#__PURE__*/ Object.assign($240483839a8a76fd$export$5fb54c671a65c88, {
displayName: $240483839a8a76fd$var$INDICATOR_NAME
});
/* ---------------------------------------------------------------------------------------------- */ const $240483839a8a76fd$export$be92b6f5f03c0fe9 = $240483839a8a76fd$export$a98f0dcb43a68a25;
const $240483839a8a76fd$export$6d08773d2e66f8f2 = $240483839a8a76fd$export$9f866c100ef519e4;
const $240483839a8a76fd$export$adb584737d712b70 = $240483839a8a76fd$export$5fb54c671a65c88;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,277 @@
import $8Wolv$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
import {forwardRef as $8Wolv$forwardRef, createElement as $8Wolv$createElement, useRef as $8Wolv$useRef, useEffect as $8Wolv$useEffect, useState as $8Wolv$useState} from "react";
import {composeEventHandlers as $8Wolv$composeEventHandlers} from "@radix-ui/primitive";
import {useComposedRefs as $8Wolv$useComposedRefs} from "@radix-ui/react-compose-refs";
import {createContextScope as $8Wolv$createContextScope} from "@radix-ui/react-context";
import {Primitive as $8Wolv$Primitive} from "@radix-ui/react-primitive";
import {createRovingFocusGroupScope as $8Wolv$createRovingFocusGroupScope, Root as $8Wolv$Root, Item as $8Wolv$Item} from "@radix-ui/react-roving-focus";
import {useControllableState as $8Wolv$useControllableState} from "@radix-ui/react-use-controllable-state";
import {useDirection as $8Wolv$useDirection} from "@radix-ui/react-direction";
import {useSize as $8Wolv$useSize} from "@radix-ui/react-use-size";
import {usePrevious as $8Wolv$usePrevious} from "@radix-ui/react-use-previous";
import {Presence as $8Wolv$Presence} from "@radix-ui/react-presence";
/* -------------------------------------------------------------------------------------------------
* Radio
* -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$RADIO_NAME = 'Radio';
const [$ce77a8961b41be9e$var$createRadioContext, $ce77a8961b41be9e$export$67d2296460f1b002] = $8Wolv$createContextScope($ce77a8961b41be9e$var$RADIO_NAME);
const [$ce77a8961b41be9e$var$RadioProvider, $ce77a8961b41be9e$var$useRadioContext] = $ce77a8961b41be9e$var$createRadioContext($ce77a8961b41be9e$var$RADIO_NAME);
const $ce77a8961b41be9e$export$d7b12c4107be0d61 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
const { __scopeRadio: __scopeRadio , name: name , checked: checked = false , required: required , disabled: disabled , value: value = 'on' , onCheck: onCheck , ...radioProps } = props;
const [button, setButton] = $8Wolv$useState(null);
const composedRefs = $8Wolv$useComposedRefs(forwardedRef, (node)=>setButton(node)
);
const hasConsumerStoppedPropagationRef = $8Wolv$useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
const isFormControl = button ? Boolean(button.closest('form')) : true;
return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$RadioProvider, {
scope: __scopeRadio,
checked: checked,
disabled: disabled
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.button, $8Wolv$babelruntimehelpersesmextends({
type: "button",
role: "radio",
"aria-checked": checked,
"data-state": $ce77a8961b41be9e$var$getState(checked),
"data-disabled": disabled ? '' : undefined,
disabled: disabled,
value: value
}, radioProps, {
ref: composedRefs,
onClick: $8Wolv$composeEventHandlers(props.onClick, (event)=>{
// radios cannot be unchecked so we only communicate a checked state
if (!checked) onCheck === null || onCheck === void 0 || onCheck();
if (isFormControl) {
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if radio is in a form, stop propagation from the button so that we only propagate
// one click event (from the input). We propagate changes from an input so that native
// form validation works and form events reflect radio updates.
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
}
})
})), isFormControl && /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$var$BubbleInput, {
control: button,
bubbles: !hasConsumerStoppedPropagationRef.current,
name: name,
value: value,
checked: checked,
required: required,
disabled: disabled // We transform because the input is absolutely positioned but we have
,
style: {
transform: 'translateX(-100%)'
}
}));
});
/*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d7b12c4107be0d61, {
displayName: $ce77a8961b41be9e$var$RADIO_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioIndicator
* -----------------------------------------------------------------------------------------------*/ const $ce77a8961b41be9e$var$INDICATOR_NAME = 'RadioIndicator';
const $ce77a8961b41be9e$export$d35a9ffa9a04f9e7 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
const { __scopeRadio: __scopeRadio , forceMount: forceMount , ...indicatorProps } = props;
const context = $ce77a8961b41be9e$var$useRadioContext($ce77a8961b41be9e$var$INDICATOR_NAME, __scopeRadio);
return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Presence, {
present: forceMount || context.checked
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.span, $8Wolv$babelruntimehelpersesmextends({
"data-state": $ce77a8961b41be9e$var$getState(context.checked),
"data-disabled": context.disabled ? '' : undefined
}, indicatorProps, {
ref: forwardedRef
})));
});
/*#__PURE__*/ Object.assign($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, {
displayName: $ce77a8961b41be9e$var$INDICATOR_NAME
});
/* ---------------------------------------------------------------------------------------------- */ const $ce77a8961b41be9e$var$BubbleInput = (props)=>{
const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
const ref = $8Wolv$useRef(null);
const prevChecked = $8Wolv$usePrevious(checked);
const controlSize = $8Wolv$useSize(control); // Bubble checked change to parents (e.g form change event)
$8Wolv$useEffect(()=>{
const input = ref.current;
const inputProto = window.HTMLInputElement.prototype;
const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
const setChecked = descriptor.set;
if (prevChecked !== checked && setChecked) {
const event = new Event('click', {
bubbles: bubbles
});
setChecked.call(input, checked);
input.dispatchEvent(event);
}
}, [
prevChecked,
checked,
bubbles
]);
return /*#__PURE__*/ $8Wolv$createElement("input", $8Wolv$babelruntimehelpersesmextends({
type: "radio",
"aria-hidden": true,
defaultChecked: checked
}, inputProps, {
tabIndex: -1,
ref: ref,
style: {
...props.style,
...controlSize,
position: 'absolute',
pointerEvents: 'none',
opacity: 0,
margin: 0
}
}));
};
function $ce77a8961b41be9e$var$getState(checked) {
return checked ? 'checked' : 'unchecked';
}
const $f99a8c78507165f7$var$ARROW_KEYS = [
'ArrowUp',
'ArrowDown',
'ArrowLeft',
'ArrowRight'
];
/* -------------------------------------------------------------------------------------------------
* RadioGroup
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$RADIO_GROUP_NAME = 'RadioGroup';
const [$f99a8c78507165f7$var$createRadioGroupContext, $f99a8c78507165f7$export$c547093f11b76da2] = $8Wolv$createContextScope($f99a8c78507165f7$var$RADIO_GROUP_NAME, [
$8Wolv$createRovingFocusGroupScope,
$ce77a8961b41be9e$export$67d2296460f1b002
]);
const $f99a8c78507165f7$var$useRovingFocusGroupScope = $8Wolv$createRovingFocusGroupScope();
const $f99a8c78507165f7$var$useRadioScope = $ce77a8961b41be9e$export$67d2296460f1b002();
const [$f99a8c78507165f7$var$RadioGroupProvider, $f99a8c78507165f7$var$useRadioGroupContext] = $f99a8c78507165f7$var$createRadioGroupContext($f99a8c78507165f7$var$RADIO_GROUP_NAME);
const $f99a8c78507165f7$export$a98f0dcb43a68a25 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , name: name , defaultValue: defaultValue , value: valueProp , required: required = false , disabled: disabled = false , orientation: orientation , dir: dir , loop: loop = true , onValueChange: onValueChange , ...groupProps } = props;
const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
const direction = $8Wolv$useDirection(dir);
const [value, setValue] = $8Wolv$useControllableState({
prop: valueProp,
defaultProp: defaultValue,
onChange: onValueChange
});
return /*#__PURE__*/ $8Wolv$createElement($f99a8c78507165f7$var$RadioGroupProvider, {
scope: __scopeRadioGroup,
name: name,
required: required,
disabled: disabled,
value: value,
onValueChange: setValue
}, /*#__PURE__*/ $8Wolv$createElement($8Wolv$Root, $8Wolv$babelruntimehelpersesmextends({
asChild: true
}, rovingFocusGroupScope, {
orientation: orientation,
dir: direction,
loop: loop
}), /*#__PURE__*/ $8Wolv$createElement($8Wolv$Primitive.div, $8Wolv$babelruntimehelpersesmextends({
role: "radiogroup",
"aria-required": required,
"aria-orientation": orientation,
"data-disabled": disabled ? '' : undefined,
dir: direction
}, groupProps, {
ref: forwardedRef
}))));
});
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$a98f0dcb43a68a25, {
displayName: $f99a8c78507165f7$var$RADIO_GROUP_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioGroupItem
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$ITEM_NAME = 'RadioGroupItem';
const $f99a8c78507165f7$export$9f866c100ef519e4 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , disabled: disabled , ...itemProps } = props;
const context = $f99a8c78507165f7$var$useRadioGroupContext($f99a8c78507165f7$var$ITEM_NAME, __scopeRadioGroup);
const isDisabled = context.disabled || disabled;
const rovingFocusGroupScope = $f99a8c78507165f7$var$useRovingFocusGroupScope(__scopeRadioGroup);
const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
const ref = $8Wolv$useRef(null);
const composedRefs = $8Wolv$useComposedRefs(forwardedRef, ref);
const checked = context.value === itemProps.value;
const isArrowKeyPressedRef = $8Wolv$useRef(false);
$8Wolv$useEffect(()=>{
const handleKeyDown = (event)=>{
if ($f99a8c78507165f7$var$ARROW_KEYS.includes(event.key)) isArrowKeyPressedRef.current = true;
};
const handleKeyUp = ()=>isArrowKeyPressedRef.current = false
;
document.addEventListener('keydown', handleKeyDown);
document.addEventListener('keyup', handleKeyUp);
return ()=>{
document.removeEventListener('keydown', handleKeyDown);
document.removeEventListener('keyup', handleKeyUp);
};
}, []);
return /*#__PURE__*/ $8Wolv$createElement($8Wolv$Item, $8Wolv$babelruntimehelpersesmextends({
asChild: true
}, rovingFocusGroupScope, {
focusable: !isDisabled,
active: checked
}), /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d7b12c4107be0d61, $8Wolv$babelruntimehelpersesmextends({
disabled: isDisabled,
required: context.required,
checked: checked
}, radioScope, itemProps, {
name: context.name,
ref: composedRefs,
onCheck: ()=>context.onValueChange(itemProps.value)
,
onKeyDown: $8Wolv$composeEventHandlers((event)=>{
// According to WAI ARIA, radio groups don't activate items on enter keypress
if (event.key === 'Enter') event.preventDefault();
}),
onFocus: $8Wolv$composeEventHandlers(itemProps.onFocus, ()=>{
var _ref$current;
/**
* Our `RovingFocusGroup` will focus the radio when navigating with arrow keys
* and we need to "check" it in that case. We click it to "check" it (instead
* of updating `context.value`) so that the radio change event fires.
*/ if (isArrowKeyPressedRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.click();
})
})));
});
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$9f866c100ef519e4, {
displayName: $f99a8c78507165f7$var$ITEM_NAME
});
/* -------------------------------------------------------------------------------------------------
* RadioGroupIndicator
* -----------------------------------------------------------------------------------------------*/ const $f99a8c78507165f7$var$INDICATOR_NAME = 'RadioGroupIndicator';
const $f99a8c78507165f7$export$5fb54c671a65c88 = /*#__PURE__*/ $8Wolv$forwardRef((props, forwardedRef)=>{
const { __scopeRadioGroup: __scopeRadioGroup , ...indicatorProps } = props;
const radioScope = $f99a8c78507165f7$var$useRadioScope(__scopeRadioGroup);
return /*#__PURE__*/ $8Wolv$createElement($ce77a8961b41be9e$export$d35a9ffa9a04f9e7, $8Wolv$babelruntimehelpersesmextends({}, radioScope, indicatorProps, {
ref: forwardedRef
}));
});
/*#__PURE__*/ Object.assign($f99a8c78507165f7$export$5fb54c671a65c88, {
displayName: $f99a8c78507165f7$var$INDICATOR_NAME
});
/* ---------------------------------------------------------------------------------------------- */ const $f99a8c78507165f7$export$be92b6f5f03c0fe9 = $f99a8c78507165f7$export$a98f0dcb43a68a25;
const $f99a8c78507165f7$export$6d08773d2e66f8f2 = $f99a8c78507165f7$export$9f866c100ef519e4;
const $f99a8c78507165f7$export$adb584737d712b70 = $f99a8c78507165f7$export$5fb54c671a65c88;
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};
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,65 @@
{
"name": "@radix-ui/react-radio-group",
"version": "1.1.3",
"license": "MIT",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"source": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist",
"README.md"
],
"sideEffects": false,
"scripts": {
"clean": "rm -rf dist",
"version": "yarn version"
},
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
"@radix-ui/react-compose-refs": "1.0.1",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-direction": "1.0.1",
"@radix-ui/react-presence": "1.0.1",
"@radix-ui/react-primitive": "1.0.3",
"@radix-ui/react-roving-focus": "1.0.4",
"@radix-ui/react-use-controllable-state": "1.0.1",
"@radix-ui/react-use-previous": "1.0.1",
"@radix-ui/react-use-size": "1.0.1"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
},
"homepage": "https://radix-ui.com/primitives",
"repository": {
"type": "git",
"url": "git+https://github.com/radix-ui/primitives.git"
},
"bugs": {
"url": "https://github.com/radix-ui/primitives/issues"
}
}